WarcraftReamls.com
  FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups   RegisterRegister 
  ProfileProfile    Log in to check your private messagesLog in to check your private messages    Log inLog in 
simple C# example

 
Post new topic   Reply to topic    WarcraftRealms.com Forum Index -> WarcraftRealms Developers
View previous topic :: View next topic  
Author Message
rustane



Joined: 29 Sep 2005
Posts: 1

WR Updates: 0
rustane WR Profile

PostPosted: Thu Nov 24, 2005 7:17 am    Post subject: simple C# example Reply with quote

this is what i do if your status.csv != myoldsavedstatus.csv .. if they are the same i just read the file i saved on the server. (checksum is the unix timestamp from the status file)

// This is an example of a UNIX timestamp for the date/time 11-04-2005 09:25.
double timestamp = Convert.ToDouble(checksum);
// First make a System.DateTime equivalent to the UNIX Epoch.
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
// Add the number of seconds in UNIX timestamp to be converted.
dateTime = dateTime.AddSeconds(timestamp);

// The dateTime now contains the right date/time so to format the string,
// use the standard formatting methods of the DateTime object.
string printDate = dateTime.ToShortDateString() +" "+ dateTime.ToShortTimeString();

lblStatus.Text = "Got fresh guildinfo " + printDate;
TextWriter tw = new StreamWriter(Server.MapPath(@"\") + "status.txt");
tw.WriteLine(checksum2);
tw.Close();

string remoteUri = "http://www.warcraftrealms.com/exports/guildexport.php?guildid=154970";
string fileName = Server.MapPath(@"guildinfo.csv");
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Concatenate the domain with the Web resource filename.
string myStringWebResource = remoteUri;
// Download the Web resource and save it into the folder.
myWebClient.DownloadFile(myStringWebResource,fileName);


string sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + Server.MapPath(@"\") + ";" +
"Extended Properties='text;HDR=Yes;FMT=Delimited'";

// Create connection object by using the preceding connection string.
OleDbConnection objConn = new OleDbConnection(sConnectionString);

objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM guildinfo.csv", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;

DataSet objDataset1 = new DataSet();

objAdapter1.Fill(objDataset1, "XLData");

// Bind data to DataGrid control.
DataGrid1.DataSource = objDataset1;
DataGrid1.DataBind();

// Clean up objects.
objConn.Close();
DataBind();
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WarcraftRealms.com Forum Index -> WarcraftRealms Developers All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
WarcraftRealms.com  


Powered by phpBB © 2001, 2005 phpBB Group