private void btnSubmitResult_Click(object sender, EventArgs e) { try { DataTable dtResult = (DataTable)dataGridView1.DataSource; BIZRace = new BIZ.Race(); foreach (DataRow item in dtResult.Rows) { if (item["Remarks"] != "NOT ARRIVE") { BIZRace.ClubID = ClubID; BIZRace.MemberID = MemberID; BIZRace.RaceReleasePointID = RaceReleasePointID; BIZRace.ArrivalTime = Convert.ToDateTime(item["ArrivalTime"]); BIZRace.SerialRFIDNo = item["SerialRFIDNo"].ToString(); BIZRace.SubmitRaceResult(); //string ApplicationDirectory = BIZ.Common.GetApplicationDirectory(); //string TodayFolder = indexDate.Year.ToString() + "_" + indexDate.Month.ToString() + "_" + indexDate.Day.ToString(); //string WithTimeRootDirectory = ApplicationDirectory + "DataCollection\\Member\\Raceresult\\" + Mode + "\\WithTime\\" + TodayFolder; //string fullpath = WithTimeRootDirectory + "\\" + item["SerialRFIDNo"].ToString() + ".inf"; //if (!File.Exists(fullpath)) File.Create(fullpath).Close(); //using (System.IO.StreamWriter file = new System.IO.StreamWriter(fullpath, true)) //{ // file.WriteLine(DateTime.Now); // file.Close(); //}; } } MessageBox.Show("Race Result Summitted."); } catch (Exception ex) { MessageBox.Show(BIZ.Common.CustomError(ex.Message), "Error"); } }
private void ProcessDoWork(string rfidfile) { try { bizRace = new BIZ.Race(); string filename = Path.GetFileNameWithoutExtension(rfidfile); string arrivaltime = ""; //get time into database if (Mode == "RaceMode") { bizRace.SerialRFIDNo = filename; bizRace.MobileNumber = MobileNumber; bizRace.SMSActivated = SMSActivated; arrivaltime = bizRace.GetArrivalTime().Tables[0].Rows[0]["ArrivalTime"].ToString(); } else { arrivaltime = DateTime.Now.ToString(); } string rfidclockdetails = filename + "|" + arrivaltime; //string rfidclockdetails = filename + "|" + GetBandNumber(filename) + "|" + arrivaltime; //band number using (System.IO.StreamWriter file = new System.IO.StreamWriter(rfidfile, true)) { file.WriteLine(Common.Encrypt(rfidclockdetails)); file.Close(); }; //application directory string ApplicationDirectory = Common.GetApplicationDirectory(); //application race result summary file string resultSummary = ApplicationDirectory + "\\DataCollection\\Member\\Raceresult\\" + Mode + "\\RaceResultSummary\\" + DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString() + ".inf"; //create file if not exists if (!File.Exists(resultSummary)) { File.Create(resultSummary).Close(); } //write into result result summary using (System.IO.StreamWriter file = new System.IO.StreamWriter(resultSummary, true)) { file.WriteLine(Common.Encrypt(rfidclockdetails)); file.Close(); }; //if race mode write into sd card for club copy if (Mode == "RaceMode") { WriteResultInSDCard(rfidclockdetails); } //application destination file string TodayFolder = DateTime.Now.Year.ToString() + "_" + DateTime.Now.Month.ToString() + "_" + DateTime.Now.Day.ToString(); string WithTimeRootDirectory = ApplicationDirectory + "\\DataCollection\\Member\\Raceresult\\" + Mode + "\\WithTime\\" + TodayFolder; if (!Directory.Exists(WithTimeRootDirectory)) { Directory.CreateDirectory(WithTimeRootDirectory); } string destinationFile = WithTimeRootDirectory + "\\" + filename + ".inf"; if (!File.Exists(destinationFile)) { File.Move(rfidfile, destinationFile); } else { File.Delete(rfidfile); } backgroundWorker1.ReportProgress(1); } catch (Exception ex) { logError(ex.Message); } }