private bool CreateDataLocal(string strlasttime, string strdownfiles) { #region 加载会员资料 ArrayList alDownUser = new ArrayList(); alDownUser = m1.DownAssData(strlasttime); if (alDownUser == null) { clog.WriteLine("加载会员资料错误"); return(false); } #endregion StreamWriter swFile = new StreamWriter(strdownfiles + ".tmp", true); #region 写会员资料 CMSMStruct.AssociatorStruct asstmp = null; StructToString sts = new StructToString(); swFile.WriteLine("USERTOL=" + alDownUser.Count.ToString()); for (int i = 0; i < alDownUser.Count; i++) { asstmp = alDownUser[i] as CMSMStruct.AssociatorStruct; swFile.WriteLine(sts.ToAssString(asstmp)); } swFile.WriteLine("END"); #endregion swFile.Close(); #region 加密 DESEncryptor dese = new DESEncryptor(); dese.InputFilePath = strdownfiles + ".tmp"; dese.OutFilePath = strdownfiles; dese.EncryptKey = "cmsmyykx"; dese.FileDesEncrypt(); if (dese.NoteMessage != null) { clog.WriteLine(dese.NoteMessage); return(false); } dese = null; #endregion if (System.IO.File.Exists(strdownfiles + ".tmp")) { System.IO.File.Delete(strdownfiles + ".tmp"); } return(true); }
private void sbtnOk_Click(object sender, System.EventArgs e) { this.listBox1.Items.Clear(); string downFileName = "down" + SysInitial.LocalDept + ".L00"; string filePath = @"E:\\BreadWorksDataBak\\DownLoad\\"; string strYDate = this.dateTimePicker1.Value.Year.ToString(); string strMDate = this.dateTimePicker1.Value.Month.ToString(); string strDDate = this.dateTimePicker1.Value.Day.ToString(); if (strMDate.Length < 2) { strMDate = "0" + strMDate; } if (strDDate.Length < 2) { strDDate = "0" + strDDate; } string strBeginDate = strYDate + "-" + strMDate + "-" + strDDate; // ArrayList alDown=new ArrayList(); if (!System.IO.Directory.Exists(filePath)) { System.IO.Directory.CreateDirectory(filePath); } else { string[] fileall = Directory.GetFiles(filePath); if (fileall.Length > 0) { for (int i = 0; i < fileall.Length; i++) { System.IO.File.Delete(fileall[i]); } } } #region 载 this.listBox1.Items.Add("开始下载..."); this.listBox1.Items.Add("\n"); // err=null; // ca.DownMainDeptData(strBeginDate,downFileName,out err); #region 加载会员资料 this.listBox1.Items.Add("加载会员资料..."); this.Refresh(); ArrayList alDownUser = new ArrayList(); err = null; alDownUser = ca.DownAssData(strBeginDate, out err); if (alDownUser == null || err != null) { MessageBox.Show("加载会员资料错误,请重试!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (err != null) { clog.WriteLine(err); } return; } #endregion // #region 加载会员资料变更记录 // this.listBox1.Items.Add("加载会员资料变更记录..."); // this.Refresh(); // ArrayList alDownUserAlter=new ArrayList(); // err=null; // alDownUserAlter=ca.DownAssChange(strBeginDate,out err); // if(alDownUserAlter==null||err!=null) // { // MessageBox.Show("加载会员资料变更记录错误,请重试!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Error); // if(err!=null) // { // clog.WriteLine(err); // } // return; // } // #endregion StreamWriter swFile = new StreamWriter(filePath + downFileName + ".tmp", true); #region 写会员资料 CMSMStruct.AssociatorStruct asstmp = null; swFile.WriteLine("USERTOL=" + alDownUser.Count.ToString()); for (int i = 0; i < alDownUser.Count; i++) { asstmp = alDownUser[i] as CMSMStruct.AssociatorStruct; swFile.WriteLine(sts.ToAssString(asstmp)); } swFile.WriteLine("END"); this.listBox1.Items.Add("下载会员资料记录数:" + alDownUser.Count.ToString()); #endregion // #region 写会员资料变更记录 // CMSMStruct.AssChangeStruct assChange=null; // swFile.WriteLine("ALTETOL=" + alDownUserAlter.Count.ToString()); // for(int i=0;i<alDownUserAlter.Count;i++) // { // assChange=alDownUserAlter[i] as CMSMStruct.AssChangeStruct; // swFile.WriteLine(sts.ToAssChangeString(assChange)); // } // swFile.WriteLine("END"); // this.listBox1.Items.Add("下载会员资料变更记录数:" + alDownUserAlter.Count.ToString()); // #endregion swFile.Close(); //加密 DESEncryptor dese = new DESEncryptor(); dese.InputFilePath = filePath + downFileName + ".tmp"; dese.OutFilePath = filePath + downFileName; dese.EncryptKey = "cmsmyykx"; dese.FileDesEncrypt(); if (dese.NoteMessage != null) { MessageBox.Show("下载文件处理出错,请重试!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.clog.WriteLine(dese.NoteMessage); return; } dese = null; if (System.IO.File.Exists(filePath + downFileName + ".tmp")) { System.IO.File.Delete(filePath + downFileName + ".tmp"); } // if(err!=null) // { // this.listBox1.Items.Add("下载数据失败,请重试!"); // this.listBox1.Items.Add(err.ToString()); // return; // } this.listBox1.Items.Add("\n"); this.listBox1.Items.Add(strBeginDate + "以后的数据已经下载完成!"); this.Refresh(); #endregion }