I have a set of tasks that I would like to execute every night.
These tasks include querying a database, moving and renaming some images and lastly updating a database table. My first thought had been to create a SQL Server job and use xp_cmdshell to move the files but after a bit of research i decided against it.
My question now is what is the best way to implement this as a .NET application? Should I create a Windows service? A console application that is scheduled to run once per night? Some other cool way that I don't even know about?
iam using c#,asp.net and iis, i want to simulate slow internet connection on my pc for testing my app.
is it possible i can control bandwidth of iis.
please dont suggest
System.Threading.Thread.Sleep(someDuration);
in c# file.
I have a python script which reads email addresses from a database for a particular date, example today, and sends out an email message to them one by one. It reads data from MySQL using the MySQLdb module and stores all results in a dictionary and sends out emails using :
rows = cursor.fetchall () #All email addresses returned that are supposed to go out on todays date.
for row is rows: #send email
However, my hosting service only lets me send out 500 emails per hour. How can I limit my script from making sure only 500 emails are sent in an hour and then to check the database if more emails are left for today or not and then to send them in the next hour.
The script is activated using a cron job.
I am overriding System.IdentityModel.Policy.IAuthorizationPolicy.Evaluate as follows:
public bool Evaluate(EvaluationContext evaluationContext,ref object state)
{
var ids = (IList<IIdentity>)evaluationContext.Properties["Identities"];
var userName = ids[0].Name;
// look up "userName" in a database to check for app. permissions
}
Recently one of the users had her user name changed in Active Directory. She is able to login to her Windows box fine with her new user name, but when she tries to run the client side of our application, the server gets her old user name in the "userName" variable in the code above, which messes up our authentication (since her old user name is no longer in our database).
Another piece of info: This only happens when she connects to the server code on the Production server. We have the same server code running on a QA server, and it does not have this issue (the QA server code gets her correct (new) user name)
Any ideas what could be going on?
I'm experienced with database development, but not so much with Excel. I'm looking for help writing an Excel formula that would help my client's spreadsheet behave like a database. This is what I'm looking to do, but I can't figure out how to write it in Excel 2007:
"If Q4 (on sheet 2) contains A2 (on sheet 1), append A1 (on sheet 1) with Q5 (on sheet 2)"
Some factors:
1) This formula may find multiple instances of A2, so it should not stop after finding the first match
2) The values, as they are created in A1, should be separated with comma and space
3) This is a many to many relationship between Q4 and A2
Thanks for any help with this. I've tried vlookups, match, if statements, but they all fall short in one way or another.
I would like to know what are the open source and commerical tools for window Service Testing. Like memeory usage and code leakes etc ..
C# 2.0 - Window Service.
I am new to jScript and have written this code [which works perfectly]. Its purpose is to test that the term for the amount of loan is not exceeded. Can the process be consolidated into one array where you pass the loan amount which returns the term based on the range i.e. 6000 to 7000 = 96
function TestMaxTerm()
{
var LnAmt = 14000 //Testing Purposes
var Term = 0 //Testing Purposes
if (LnAmt > 0 && LnAmt <= 1000){Term = 0;}
if (LnAmt > 1000 && LnAmt <= 2000){Term = 1;}
if (LnAmt > 2000 && LnAmt <= 3000){Term = 2;}
if (LnAmt > 3000 && LnAmt <= 4000){Term = 3;}
if (LnAmt > 4000 && LnAmt <= 5000){Term = 4;}
if (LnAmt > 5000 && LnAmt <= 6000){Term = 5;}
if (LnAmt > 6000 && LnAmt <= 7000){Term = 6;}
if (LnAmt > 7000 && LnAmt <= 8000){Term = 7;}
if (LnAmt > 8000 && LnAmt <= 9000){Term = 8;}
if (LnAmt > 9000 && LnAmt <= 10000){Term = 9;}
if (LnAmt > 10000 && LnAmt <= 11000){Term = 10;}
if (LnAmt > 11000 && LnAmt <= 12000){Term = 11;}
if (LnAmt > 11000){Term = 12;}
//Obtain Maximum Term for Loan Amount
var MaxTerm = new Array();
MaxTerm[0] = 24; MaxTerm[1]=36; MaxTerm[2] = 48; MaxTerm[3] = 60;
MaxTerm[5] = 72; MaxTerm[5]=84; MaxTerm[6] = 96; MaxTerm[7] = 108;
MaxTerm[8] = 120; MaxTerm[9]=132; MaxTerm[10] = 164; MaxTerm[11] = 176;
MaxTerm[12] = 420;
var text = MaxTerm[Term];
alert(text);
}
I have an array with a lot of data from a database. In the array, there are two fields called teameinsid and teamzweiid. The query is a very simple one :
$spiel = mysql_query("select teameinsid, teamzweiid from begegnung", $connection) or die("Keine passende Begegnung");
What I need is to search in the database for the names of these IDs. The names are in a different table.
What I have now is the following:
while($tmp = mysql_fetch_array($spiel)){
$teins = $tmp['teameinsid'];
$tzwei = $tmp['teamzweiid'];
}
So I know the two IDs, but I don't know where to save the names. If I try:
$name = mysql_query("select name from team where teameinsid = $teins", $con)
it gets overwritten every time. How can I manage this?
I'm just curious if this is possible, specifically in SQL CE (Express) with support in .NET's Entity Framework:
Table1 (primary)
-nvarchar(2000) url
-...
Table2 (with foreign key)
-nvarchar(2000) domain
-...
foreign key on Table2.domain references Table1.url such that Table.url contains Table2.domain
e.g.
Table1:
http://www.google.com/blah/blah
http://www.cnn.com/blah/
http://www.google.com/foo
Table2:
google.com
cnn.com
Is it possible for this to be scripted and enforced by SQL CE (let alone any relation database) and, if so, can .NET's Entity Framework automatically support this if I import my database into a model?
debugTestLabel.text = [[NSString alloc] initWithFormat:@"%g, %g", @"Testing String", @"I am another"];
I alloc the String and immediately assign to the text, but I don't know whether the string can auto release or not.
Hello people,
I'm sorry for this question but I'm getting crazy trying to write my first php clash,
it is supposed to connect me to server and to a database but I'm always getting this error:
Parse error: syntax error, unexpected ',', expecting T_PAAMAYIM_NEKUDOTAYIM in /Applications/XAMPP/xamppfiles/htdocs/classTest/test.php on line 9
thanks in advance, here is the code:
<?php
// include 'DBConnect.php';
class DBConnect
{
function connection($hostname = "localhost", $myname = "root", $pass = ''){
mysql_connect(&hostname, &myname, &pass) or die("Could not connect!"); //Connect to mysql
}
function choose($dbnam){
mysql_select_db(&dbnam) or die("Couldn't find database!"); //fnd specific db
}
}
$a = new DBConnect();
$connect = $a->connection("localhost", "root");
$a->choose('mydb');
?>
This is a dangerous question, so let me try to phrase it correctly. Premature optimization is the root of all evil, but if you know you need it, there is a basic set of rules that should be considered. This set is what I'm wondering about.
For instance, imagine you got a list of a few thousand items. How do you look up an item with a specific, unique ID? Of course, you simply use a Dictionary to map the ID to the item.
And if you know that there is a setting stored in a database that is required all the time, you simply cache it instead of issuing a database request hundred times a second.
I guess there are a few even more basic ideas.
I am specifically not looking for "don't do it, for experts: don't do it yet" or "use a profiler" answers, but for really simple, general hints. If you feel this is an argumentative question, you probably misunderstood my intention.
I have an arraylist that holds a subset of names found in my database. I need to write a query to get a count of the people in the arraylist for certain sections i.e.
There is a field "City" in my database from the people in the arraylist of names I want to know how many of them live in Chicago, how many live in New York etc.
Can someone help me how I might set up an sql statement to handle this. I think somehow I have to pass the subset of names to sql somehow.
so i have a list of string
{test,testertest,testing,tester,testingtest}
I want to sort it in descending order .. how do u sort strings in general ? Is it based on the length or is it character by character ??
how would it be in the example above ?? I want to sort them in a descending way.
I have an excel file that have the list of contacts( about 10 k of them) that I need to push into my SQL Server database. So, I am writing an .net windows program using visual studio 2008 to read the files, generate random password for each contact, and then push these information in to my SQL Server database.
It was easy to handle excel file in 2003 but now my computer have office 2007 in it and things seem to changed. I am digging on Microsoft.Office.Interop.Excel but it is seem to be a lot more complicated than before.
I'm wanting to store items in my database with a DATE value for a certain day. I don't know how to get the current Monday, or Tuesday, etc. from the current week. Here is my current database setup.
menuentry
id int(10) PK
menu_item_id int(10) FK
day_of_week date
message varchar(255)
So I have a class setup that holds all the info then I was going to do something like this...
foreach ( $menuEntryArray as $item )
{
if ( $item->getDate() == [DONT KNOW WHAT TO PUT HERE] )
{
// code to display menu_item information
}
}
So I'm just unsure what to put in "[DONT KNOW WHAT TO PUT HERE]" to compare to see if the date is specified for this week's Monday, or Tuesday, etc. The foreach above runs for each day of the week - so it'll look like this...
Monday
Item 1
Item 2
Item 3
Tuesday
Item 1
Wednesday
Item 1
Item 2
...
Thanks!
The Repository class has singleton behavior and the _db implements the disposable pattern. As excepted the _db object gets disposed after the first call and because of the singleton behavior any other call of _db will crash.
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class Repository : IRepository
{
private readonly DataBase _db;
public Repository(DataBase db)
{
_db = db;
}
public int GetCount()
{
using(_db)
{
return _db.Menus.Count();
}
}
public Item GetItem(int id)
{
using(_db)
{
return _db.Menus.FirstOrDefault(x=>x.Id == id);
}
}
}
My question is, is there any way to design this class to work properly without removing the singleton behavior? The Repositoryclass will be serving big amount of requests.
I am testing flash online here
http://wonderfl.net/c/sqop
I'm newbie.
The picture I want to show http://reboltutorial.com/files/2010/05/rebodex-yuml-300x262.png is 300x262
so my rectangle is of the same size. Why does Flash truncate my picture ?
C:\>mysql -uroot -padmin
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.37-community-nt-log MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| attendance |
| fusionchartsdb |
| mysql |
| sugarcrm |
| test |
+--------------------+
6 rows in set (0.09 sec)
mysql> use mysql;
Database changed
mysql>
So I want to start a process by mysql -uroot -padmin,and in that process I want to run these statements:
show databases
use mysql
insert xxx (..) values (..)
How to do it in PHP?
Hello Everyone,
I need users to create custom reports. These users do not know any technical skills like SQL. We currently have a custom database report design. So basically whatever the user does on the GUI the application will have to generate the appropriate SQL to generate the report structure.
Has anyone done this before? I know there are reporting solutions out there but we already have our own database tables for reporting. We already have a section where users can view reports displayed in HTML.
Like for example if user selects a "UserID" and "Accounts" fields from GUI, how would I know that my SQL has to join the USER and ACCOUNTS table?
I guess I'm just looking for some ideas to help me solve this problem.
Thanks.
A similar question has been asked, but since it always depends, I'm asking for my specific situation separately.
I have a web-site page that shows some data that comes from a database, and to generate the data from that database I have to do some fairly complex multiple joins queries.
The data is being updated once a day (nightly).
I would like to pre-generate the data for the said view to speed up the page access.
For that I am creating a table that contains exact data I need.
Question: for my situation, is it reasonable to do complete table wipe followed by insert? or should I do update,insert?
SQL wise seems like DELETE + INSERT will be easier (it is single SQL expression).
EDIT: RDBMS: MS SQL Server 2008 Ent
I can't find this on Google (so maybe it doesn't exist), but I basically'd like to install something on a web server such that I can run a site on Scheme, PHP is starting to annoy me, I want to get rid off it, what I want is:
Run Scheme sources towards UTF-8 output (duh)
Support for SXML, SXLT et cetera, I plan to compose the damned thing in SXML and - to normal representation on at the end.
Ability to read other files from the server, write them, set permissions et cetera
Also some things to for instance determine the filesize of files, height of images, mime-types and all that mumbo-jumbo
(optionally) connect to a database, but for what I want to do storing the entire database in S-expressions itself is feasible enough
I don't need any fancy libraries and other things that come with it like CMS'es and what-not, except the support for SXML but I'm sure I can just find a lib for that anyway that I can load.
MYMESSAGE = "<div>Hello</div><p></p>Hello"
send_mail("testing",MYMESSAGE,"[email protected]",['[email protected]'],fail_silently=False)
However, this message doesn't get the HTML mime type when it is sent. In my outlook, I see the code...
I need to move entire tables from one MySQL database to another. I don't have full access to the second one, only phpMyAdmin access. I can only upload (compressed) sql files smaller than 2MB. But the compressed output from a mysqldump of the first database's tables is larger than 10MB.
Is there a way to split the output from mysqldump into smaller files? I cannot use split(1) since I cannot cat(1) the files back on the remote server.
Or is there another solution I have missed?
Edit
The --extended-insert=FALSE option to mysqldump suggested by the first poster yields a .sql file that can then be split into importable files, provided that split(1) is called with a suitable --lines option. By trial and error I found that bzip2 compresses the .sql files by a factor of 20, so I needed to figure out how many lines of sql code correspond roughly to 40MB.