public void TransferSenderListDataBases(string DesDataBase, string SourceDataBases) { OLDBHelper.dataSourceStr = SourceDataBases; List <SenderList> senders = FindAllSenderListFromSourceData(); OLDBHelper.dataSourceStr = DesDataBase; InitSenderListFromDesData(); BathAddSenderListToDB(senders); OLDBHelper.DisposeDB(); }
public void TransferEmpDataBases(string DesDataBase, string SourceDataBases) { OLDBHelper.dataSourceStr = SourceDataBases; List <Emp> emps = FindAllEmpFromSourceData(); OLDBHelper.dataSourceStr = DesDataBase; InitEmpsFromDesData(); BathUpAddEmpsToDB(emps); OLDBHelper.DisposeDB(); }
/// <summary> /// 转移数据库的Record表,用于合并数据库 /// </summary> /// <param name="DesDataBase">被合并到的总库</param> /// <param name="SourceDataBases">要合并的原数据库</param> public void TransferRecordDataBases(string DesDataBase, string SourceDataBases) { List <Record> desDataRecords = new List <Record>(); OLDBHelper.dataSourceStr = SourceDataBases; List <Record> sourceDataRecords = FindSourceCompletedAndIncompletedRecords(); for (int i = 0; i < sourceDataRecords.Count; i++) { sourceDataRecords[i].M_isupload = "Y"; Record desRecord = sourceDataRecords[i].QainClone(); string shipmentConsolNo = RegexHelper.GetFirstStrByRegex(@"(S|C){1}[0-9]{10}", sourceDataRecords[i].M_requestID.Trim()); if (shipmentConsolNo.Length > 0) { desRecord.M_requestID = shipmentConsolNo; } desDataRecords.Add(desRecord); } if (desDataRecords.Count > 0) { BathUpdateRecordsToDB(sourceDataRecords); OLDBHelper.DisposeDB(); OLDBHelper.dataSourceStr = DesDataBase; BathAddRecordsToDB(desDataRecords); } OLDBHelper.DisposeDB(); }
public void GetReport(string sourceDateBaseStr, DateTime startDate, DateTime stopDate) { OLDBHelper.dataSourceStr = sourceDateBaseStr; OleDbConnection con = recordDao.Begin(); DateTime inputDate = startDate; string outputPath = @".\resultDatas\"; if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } while (DateTime.Compare(inputDate, stopDate) < 0) { List <Record> listsRecordSum = recordDao.FindRecordSumDur(con, inputDate, inputDate.AddDays(1)); HashSet <string> uniqueSub = recordDao.GetUniqueSubject(con, inputDate); //写入CSV文件 using (StreamWriter sw = new StreamWriter(outputPath + inputDate.ToString ("yyyyMMdd") + ".csv", false, Encoding.Default)) { StringBuilder sb = new StringBuilder(); sb.Append("RequestID,BsType,ActionType,MailIncomeDate"); sw.WriteLine(sb.ToString()); for (int i = 0; i < listsRecordSum.Count; i++) { Record recordSum = listsRecordSum[i]; string m_RequestID = recordSum.M_requestID.ToUpper().Trim(); if (m_RequestID.StartsWith("S")) { if (!uniqueSub.Contains(m_RequestID)) { uniqueSub.Add(m_RequestID); sw.WriteLine("\"" + m_RequestID + "\"" + "," + "\"" + recordSum.M_businessType + "\"" + "," + "\"" + recordSum.M_actiontype + "\"" + "," + "\"" + recordSum.M_mailincometime.ToString() + "\""); } } if (m_RequestID.StartsWith("C")) { if (recordSum.M_businessType.ToLower().Trim() == "import") { if (recordSum.M_actiontype.Contains("2") || recordSum.M_actiontype.ToUpper().Contains("IM") || recordSum.M_actiontype.ToUpper().Contains("FL")) { sw.WriteLine("\"" + m_RequestID + "\"" + "," + "\"" + recordSum.M_businessType + "\"" + "," + "\"" + recordSum.M_actiontype + "\"" + "," + "\"" + recordSum.M_mailincometime.ToString() + "\""); } } else if (recordSum.M_businessType.ToLower().Trim() == "export") { if (recordSum.M_actiontype.Contains("1")) { sw.WriteLine("\"" + m_RequestID + "\"" + "," + "\"" + recordSum.M_businessType + "\"" + "," + "\"" + recordSum.M_actiontype + "\"" + "," + "\"" + recordSum.M_mailincometime.ToString() + "\""); } } } } } inputDate = inputDate.AddDays(1); } recordDao.Close(); OLDBHelper.DisposeDB(); }