Exemple #1
0
 private void aisinoDataGrid1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         try
         {
             string inFileName = this.aisinoDataGrid1.CurrentRow.Cells["LJ"].Value.ToString();
             if (!this.IsMatchVTM(AES_Crypt_File.DecryptFile(inFileName)))
             {
                 MessageBoxHelper.Show("所选备份文件的税号,开票机号或版本号与当前软件不匹配,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
             else if (!string.IsNullOrEmpty(inFileName))
             {
                 if (DialogResult.Yes == MessageBoxHelper.Show("恢复到选定版本数据库?(此操作不可恢复)\n" + inFileName + "\n确定后重启。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                 {
                     PropertyUtil.SetValue("恢复数据库路径", inFileName);
                     PropertyUtil.Save();
                     FormMain.ResetForm();
                 }
                 else
                 {
                     PropertyUtil.SetValue("恢复数据库路径", "");
                     PropertyUtil.Save();
                 }
             }
         }
         catch (Exception exception)
         {
             this._Loger.Error(exception.ToString());
             ExceptionHandler.HandleError(exception);
         }
     }
 }
Exemple #2
0
        private void toolStripBtnDBFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "压缩文件(*.zip)|*.zip"
            };

            if (!string.IsNullOrEmpty(this.BackupPath))
            {
                dialog.InitialDirectory = this.BackupPath;
            }
            dialog.Multiselect = false;
            if (DialogResult.OK == dialog.ShowDialog())
            {
                string fileName = dialog.FileName;
                this.label2.Text = "备份数据库路径:";
                this.label3.Text = fileName;
                if (!string.IsNullOrEmpty(fileName))
                {
                    if (!this.IsMatchVTM(AES_Crypt_File.DecryptFile(fileName)))
                    {
                        MessageBoxHelper.Show("所选备份文件的税号,开票机号或版本号与当前软件不匹配,请重新选择!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                    else if (DialogResult.Yes == MessageBoxHelper.Show("恢复到选定版本数据库?(此操作不可恢复)\n" + fileName + "\n确定后重启。", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        PropertyUtil.SetValue("恢复数据库路径", fileName);
                        PropertyUtil.Save();
                        FormMain.ResetForm();
                    }
                }
            }
        }
Exemple #3
0
 private static void Copying(bool bTipSuccess)
 {
     try
     {
         string strDefaultPathCopy = PropertyUtil.GetValue(ZhiFuChuan.strPathCopy);
         if (!string.IsNullOrEmpty(strDefaultPathCopy) && !Directory.Exists(strDefaultPathCopy))
         {
             Directory.CreateDirectory(strDefaultPathCopy);
         }
         if (string.IsNullOrEmpty(strDefaultPathCopy) || !Directory.Exists(strDefaultPathCopy))
         {
             strDefaultPathCopy = ZhiFuChuan.strDefaultPathCopy;
             PropertyUtil.SetValue(ZhiFuChuan.strPathCopy, strDefaultPathCopy);
         }
         string path = strDefaultPathCopy + @"\" + dateTimeNow.ToString(ZhiFuChuan.strDateTimeFormat) + "-" + PropertyUtil.GetValue("MAIN_VER") + "-" + ZhiFuChuan.strDateBaseZipName;
         strDefaultPathCopy = path + @"\" + dateTimeNow.ToString(ZhiFuChuan.strDateTimeFormat) + "-" + PropertyUtil.GetValue("MAIN_VER") + "-" + ZhiFuChuan.strDateBaseName;
         File.Copy(strSrcPathCopy, strDefaultPathCopy, true);
         if (ZipUtil.Zip(path, path + ".zip", null))
         {
             if (Directory.Exists(path))
             {
                 Directory.Delete(path, true);
             }
             AES_Crypt_File.EncryptFile(path + ".zip");
         }
         else
         {
             if (Directory.Exists(path))
             {
                 Directory.Delete(path, true);
             }
             MessageManager.ShowMsgBox("INP-442215");
             return;
         }
         if (bTipSuccess)
         {
             MessageManager.ShowMsgBox("SJBF-000001", new string[] { path + ".zip" });
         }
     }
     catch (BaseException exception)
     {
         _Loger.Error(exception.Message);
         ExceptionHandler.HandleError(exception);
     }
     catch (Exception exception2)
     {
         _Loger.Error(exception2.Message);
         ExceptionHandler.HandleError(exception2);
     }
 }
Exemple #4
0
 private void CreateDataSource(string Path)
 {
     try
     {
         DirectoryInfo info   = new DirectoryInfo(Path);
         int           length = info.GetFiles("*.zip").Length;
         this.ReportProgress(0, 0, 0);
         int        validNum = 0;
         int        num3     = 0;
         FileInfo[] files    = info.GetFiles("*.zip");
         Array.Sort(files, new FileSort(FileOrder.LastWriteTime, FileAsc.Desc));
         foreach (FileInfo info2 in files)
         {
             string zipFileName = AES_Crypt_File.DecryptFile(info2.FullName);
             if ("" == zipFileName)
             {
                 this._Loger.Error("解密文件错误");
                 this.ReportProgress(validNum, ++num3, length);
             }
             else
             {
                 string          path = this.sysTempDir + info2.Name.Replace("FWSK.zip", "备份说明.txt");
                 DataGridViewRow row  = new DataGridViewRow();
                 FastZip         zip  = new FastZip();
                 try
                 {
                     zip.ExtractZip(zipFileName, this.sysTempDir, ".txt");
                 }
                 catch (Exception exception)
                 {
                     this._Loger.Error("解压缩文件错误:" + info2.FullName + exception.Message);
                     if (File.Exists(zipFileName))
                     {
                         File.Delete(zipFileName);
                     }
                     if (File.Exists(path))
                     {
                         File.Delete(path);
                     }
                     this.ReportProgress(validNum, ++num3, length);
                     goto Label_0456;
                 }
                 if (File.Exists(path))
                 {
                     DataGridViewTextBoxCell cell;
                     if (!this.IsMatchVTM(path))
                     {
                         if (File.Exists(zipFileName))
                         {
                             File.Delete(zipFileName);
                         }
                         if (File.Exists(path))
                         {
                             File.Delete(path);
                         }
                         this.ReportProgress(validNum, ++num3, length);
                         goto Label_0456;
                     }
                     string[] strArray = File.ReadAllLines(path);
                     for (int i = 0; i < 7; i++)
                     {
                         string str3 = "";
                         if (i < strArray.Length)
                         {
                             str3 = strArray[i];
                         }
                         else
                         {
                             str3 = "";
                         }
                         if (i == 0)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("数据备份时间"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1).Replace('-', '/');
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                         if (i == 1)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("数据备份满足条件"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1);
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                         if (i == 2)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("操作员"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1);
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                         if (i == 3)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("数据库备份名称"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1).Replace("cc3268.dll", "FWSK");
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                         if (i == 4)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("软件版本号"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1);
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                         if (i == 5)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("纳税人识别号"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1);
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                         if (i == 6)
                         {
                             cell = new DataGridViewTextBoxCell();
                             if (str3.StartsWith("开票机号"))
                             {
                                 cell.Value = str3.Substring(str3.IndexOf(':') + 1);
                             }
                             else
                             {
                                 cell.Value = "";
                             }
                             row.Cells.Add(cell);
                         }
                     }
                     cell = new DataGridViewTextBoxCell {
                         Value = info2.FullName
                     };
                     row.Cells.Add(cell);
                     this.AddRowsToDataGrid(row);
                     if (File.Exists(zipFileName))
                     {
                         File.Delete(zipFileName);
                     }
                     if (File.Exists(path))
                     {
                         File.Delete(path);
                     }
                     validNum++;
                 }
                 this.ReportProgress(validNum, ++num3, length);
                 Label_0456 :;
             }
         }
     }
     catch (Exception exception2)
     {
         this._Loger.Error(exception2.Message);
     }
 }