Example #1
0
 private void ShowReport(bool isPrint, RepReport report)
 {
     System.IO.MemoryStream stream = null;
     System.Data.DataSet ds;
     string str;
     string str2;
     RepReportTemplate template;
     System.IO.FileInfo info;
     string str3;
     DbFileFormat format;
     if (report.PackedResult != null)
     {
         stream = new System.IO.MemoryStream(report.PackedResult);
     }
     GZipStream stream2 = null;
     if (stream != null)
     {
         stream2 = new GZipStream(stream, CompressionMode.Decompress);
     }
     if (report.IsSimpleTable || report.IsTxt)
     {
         if (isPrint)
         {
             System.Windows.Forms.MessageBox.Show("Невозможно распечатать данный тип отчета:" + System.Environment.get_NewLine() + report.ReportTemplateName);
             return;
         }
         ds = null;
         if (report.PlannedDate != AIS.SN.Model.Constants.NullDate)
         {
             System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
             ds = (System.Data.DataSet) formatter.Deserialize(stream2);
         }
         else
         {
             ds = report.ds;
         }
         if (stream2 != null)
         {
             stream2.Close();
         }
         if (((ds.Tables.get_Count() < 2) || (ds.Tables.get_Item(0).Rows.get_Count() == 0)) || (ds.Tables.get_Item(1).Rows.get_Count() == 0))
         {
             System.Windows.Forms.MessageBox.Show("Отчет пуст:" + System.Environment.get_NewLine() + report.ReportTemplateName);
             return;
         }
         str = ds.Tables.get_Item(0).Rows.get_Item(0).get_Item("filename").ToString();
         try
         {
             str2 = str.Substring(0, str.LastIndexOf(@"\"));
             str = str.Substring((int) (str.LastIndexOf(@"\") + 1));
         }
         catch (System.Exception)
         {
             str2 = @"C:\";
             str = "file.dbf";
         }
         if (System.IO.Directory.Exists(str2))
         {
             this.sfdDBF.set_InitialDirectory(str2);
         }
         this.sfdDBF.set_FileName(str);
         this.sfdDBF.set_DefaultExt(report.IsTxt ? ((string) "txt") : ((string) "dbf"));
         template = RepReportTemplate.FindById(report.ReportTemplateId);
         if (this.sfdDBF.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
         {
             return;
         }
         str = this.sfdDBF.get_FileName();
         if (System.IO.File.Exists(str) && !template.IsAppending)
         {
             System.IO.File.Delete(str);
         }
         info = new System.IO.FileInfo(str);
         System.Guid guid = System.Guid.NewGuid();
         ds.Tables.get_Item(1).set_TableName('A' + guid.ToString().Substring(0, 7).ToUpper());
         str2 = info.get_DirectoryName() + ((info.get_DirectoryName() == "") ? ((string) "") : ((string) @"\"));
         if (!report.IsSimpleTable)
         {
             goto Label_04FF;
         }
         str3 = str;
         if (template.IsAppending && info.get_Exists())
         {
             info.MoveTo(str2 + ds.Tables.get_Item(1).get_TableName() + ".DBF");
         }
         format = DbFileFormat.dBase3;
         string str5 = ds.Tables.get_Item(0).Rows.get_Item(0).get_Item("fileformat").ToString();
         if (str5 != null)
         {
             if (str5 == "dBase3")
             {
                 format = DbFileFormat.dBase3;
             }
             else if (str5 == "dBase4")
             {
                 format = DbFileFormat.dBase4;
             }
             else if (str5 == "dBase5")
             {
                 format = DbFileFormat.dBase5;
             }
         }
     }
     else
     {
         System.IO.MemoryStream stream3 = new System.IO.MemoryStream();
         byte[] buffer = new byte[0x400];
         while (true)
         {
             int num = stream2.Read(buffer, 0, 0x400);
             if (num == 0)
             {
                 break;
             }
             stream3.SetLength((long) (stream3.get_Length() + num));
             stream3.Write(buffer, 0, num);
         }
         StiReport report2 = new StiReport();
         stream3.set_Position((long) 0L);
         report2.LoadDocument((System.IO.Stream) stream3);
         if (report.IsExcel)
         {
             this.sfdExcel.set_FileName("Document " + ((long) report.Id).ToString());
             this.sfdExcel.set_Filter("Excel Worksheets|*.xls");
             this.sfdExcel.set_DefaultExt(".xls");
             if (this.sfdExcel.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
             {
                 StiExcelExportSettings settings = new StiExcelExportSettings {
                     ExportPageBreaks = false,
                     UseOnePageHeaderAndFooter = true
                 };
                 report2.ExportDocument(StiExportFormat.Excel, this.sfdExcel.get_FileName(), settings);
             }
             return;
         }
         if (isPrint)
         {
             report2.Print(false);
             return;
         }
         report2.Show(false);
         return;
     }
     string tableColumns = null;
     if (ds.Tables.get_Item(0).Columns.Contains("columnlist"))
     {
         tableColumns = ds.Tables.get_Item(0).Rows.get_Item(0).get_Item("columnlist").ToString();
     }
     DBF.WriteToFile((System.Data.DataTable) ds.Tables.get_Item(1), info.get_DirectoryName(), ds.Tables.get_Item(1).get_TableName(), format, false, template.IsAppending, tableColumns);
     if (info.get_Name().ToUpper().LastIndexOf(".DBF") >= 0)
     {
         str = str2 + info.get_Name();
     }
     else
     {
         str = str2 + info.get_Name() + ".DBF";
     }
     info = new System.IO.FileInfo(str2 + ds.Tables.get_Item(1).get_TableName() + ".DBF");
     if (template.IsAppending)
     {
         info.MoveTo(str3);
     }
     else
     {
         info.MoveTo(str);
     }
     Label_04FF:
     if (report.IsTxt && (ds.Tables.get_Count() > 1))
     {
         try
         {
             if (Settings.Default.ReportsExtractTxtEncoding == "ANSI-I (Windows)")
             {
                 using (System.IO.FileStream stream4 = System.IO.File.Open(str, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
                 {
                     using (System.IO.StreamWriter writer = new System.IO.StreamWriter(stream4, System.Text.Encoding.Default))
                     {
                         foreach (System.Data.DataRow row in ds.Tables.get_Item(1).Rows)
                         {
                             writer.WriteLine(row.get_Item(0));
                         }
                         writer.Close();
                         stream4.Close();
                     }
                     return;
                 }
             }
             using (System.IO.FileStream stream5 = System.IO.File.Open(str, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.None))
             {
                 using (System.IO.StreamWriter writer2 = new System.IO.StreamWriter(stream5, System.Text.Encoding.GetEncoding(0x362)))
                 {
                     foreach (System.Data.DataRow row2 in ds.Tables.get_Item(1).Rows)
                     {
                         writer2.WriteLine(row2.get_Item(0));
                     }
                     writer2.Close();
                     stream5.Close();
                 }
             }
         }
         catch (System.Exception)
         {
             System.IO.File.Delete(str);
             throw;
         }
     }
 }
 public static void LoadReesters(ExtExternalProcessing processing, string fileName)
 {
     try
     {
         System.IO.FileInfo info = new System.IO.FileInfo(fileName);
         if (!System.IO.File.Exists(info.get_FullName()))
         {
             throw new System.Exception(string.Format("Файл [{0}] не существует", fileName));
         }
         if (info.get_Extension().ToLower() == ".dbf")
         {
             System.Data.DataTable table = DALOdbc.ExecuteDataTable(DbfFormat.dBaseIV, info.get_DirectoryName(), "select * from " + info.get_Name());
             if (table.Rows.get_Count() > 0)
             {
                 System.Data.DataTable insertData = new System.Data.DataTable();
                 insertData.Columns.Add("processingId", System.Type.GetType("System.Int64"));
                 insertData.Columns.Add("field", System.Type.GetType("System.String"));
                 insertData.Columns.Add("statusId", System.Type.GetType("System.Int64"));
                 int id = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
                 foreach (System.Data.DataRow row in table.Rows)
                 {
                     System.Data.DataRow row2 = insertData.NewRow();
                     row2.set_Item("processingId", (long) processing.Id);
                     row2.set_Item("statusId", (int) id);
                     string str = "";
                     foreach (System.Data.DataColumn column in table.Columns)
                     {
                         string str2 = row.get_Item(column).ToString();
                         if (processing.Encoding != "")
                         {
                             System.Text.Encoding encoding = System.Text.Encoding.GetEncoding(processing.Encoding);
                             str2 = System.Text.Encoding.GetEncoding(0x4e3).GetString(encoding.GetBytes(str2));
                         }
                         str2 = str2.Replace(";", "").Replace("=", "");
                         str = str + column.get_Caption();
                         str = str + "=";
                         str = str + str2;
                         str = str + ';';
                     }
                     row2.set_Item("field", str);
                     insertData.Rows.Add(row2);
                 }
                 DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", insertData);
             }
         }
         if (info.get_Extension().ToLower() == ".txt")
         {
             System.Data.DataTable table3 = new System.Data.DataTable();
             table3.Columns.Add("processingId", System.Type.GetType("System.Int64"));
             table3.Columns.Add("field", System.Type.GetType("System.String"));
             table3.Columns.Add("statusId", System.Type.GetType("System.Int64"));
             System.Text.Encoding encoding3 = System.Text.Encoding.GetEncoding(0x362);
             if (processing.Encoding != "")
             {
                 encoding3 = System.Text.Encoding.GetEncoding(processing.Encoding);
             }
             System.IO.StreamReader reader = new System.IO.StreamReader(fileName, encoding3);
             int num2 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
             while (!reader.get_EndOfStream())
             {
                 string str3 = reader.ReadLine();
                 System.Data.DataRow row3 = table3.NewRow();
                 row3.set_Item("processingId", (long) processing.Id);
                 row3.set_Item("statusId", (int) num2);
                 row3.set_Item("field", str3);
                 table3.Rows.Add(row3);
             }
             DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", table3);
         }
         if (info.get_Extension().ToLower() == ".csv")
         {
             System.Data.DataTable table4 = new System.Data.DataTable();
             table4.Columns.Add("processingId", System.Type.GetType("System.Int64"));
             table4.Columns.Add("field", System.Type.GetType("System.String"));
             table4.Columns.Add("statusId", System.Type.GetType("System.Int64"));
             System.IO.StreamReader reader2 = new System.IO.StreamReader(fileName, System.Text.Encoding.GetEncoding(0x4e3));
             int num3 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
             while (!reader2.get_EndOfStream())
             {
                 string str4 = reader2.ReadLine();
                 System.Data.DataRow row4 = table4.NewRow();
                 row4.set_Item("processingId", (long) processing.Id);
                 row4.set_Item("statusId", (int) num3);
                 row4.set_Item("field", str4);
                 table4.Rows.Add(row4);
             }
             DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", table4);
         }
         if (info.get_Extension() == ".xml")
         {
             System.Data.DataTable table5 = new System.Data.DataTable();
             table5.Columns.Add("processingId", System.Type.GetType("System.Int64"));
             table5.Columns.Add("field", System.Type.GetType("System.String"));
             table5.Columns.Add("statusId", System.Type.GetType("System.Int64"));
             System.IO.StreamReader reader3 = new System.IO.StreamReader(fileName, System.Text.Encoding.GetEncoding(0x4e3));
             int num4 = FasetItem.FindByName(FasetsEnum.PaymentReestrStatus, "Загружен").Id;
             string str5 = reader3.ReadToEnd();
             System.Data.DataRow row5 = table5.NewRow();
             row5.set_Item("processingId", (long) processing.Id);
             row5.set_Item("statusId", (int) num4);
             row5.set_Item("field", str5);
             table5.Rows.Add(row5);
             DALSql.BulkCopy("[ext].[ExternalProcessingFileRecords]", table5);
         }
     }
     catch (System.Exception exception)
     {
         throw new System.ApplicationException("Ошибка при загрузке файла реестра, возможно данные реестры уже были загружены" + fileName, exception);
     }
 }
Example #3
0
 private void Upload_Click(object sender, System.EventArgs e)
 {
     ObjectList<RemitteePaymentOrder> remitteePaymentOrders = new ObjectList<RemitteePaymentOrder>();
     ObjectList<Service> services = new ObjectList<Service>();
     foreach (System.Windows.Forms.DataGridViewRow row in (System.Collections.IEnumerable) this.dgvRemitteePaymentOrders.Rows)
     {
         if ((row.Cells.get_Item("CheckColumn").get_Value() != null) && ((bool) row.Cells.get_Item("CheckColumn").get_Value()))
         {
             long id = (long) ((long) row.Cells.get_Item("id").get_Value());
             remitteePaymentOrders.Add(ObjectWithId.FindById<RemitteePaymentOrder>(id));
         }
     }
     services = this.selectServices.Services;
     RemitteePaymentOrderUploading typeUse = (RemitteePaymentOrderUploading) this.bsUseType.get_Current();
     if (typeUse == RemitteePaymentOrderUploading.Null)
     {
         AIS.SN.UI.Messages.ShowWarning("Выберете тип");
     }
     else
     {
         System.Data.DataSet set = RemitteePaymentOrder.Upload(remitteePaymentOrders, services, typeUse);
         if (typeUse.Format != "DBF")
         {
             AIS.SN.UI.Messages.ShowWarning("Данный форма выгрузки пока не поддерживается");
         }
         else
         {
             this.sfdDBF.set_DefaultExt("dbf");
             if (this.sfdDBF.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
             {
                 System.IO.FileInfo info = new System.IO.FileInfo(this.sfdDBF.get_FileName());
                 string text1 = info.get_DirectoryName() + ((info.get_DirectoryName() == "") ? ((string) "") : ((string) @"\"));
                 DbFileFormat fileFormat = DbFileFormat.dBase3;
                 DBF.WriteToFile((System.Data.DataTable) set.Tables.get_Item(0), info.get_DirectoryName(), info.get_Name(), fileFormat, false, false);
                 AIS.SN.UI.Messages.ShowMessage("Выгрузка выполнена");
             }
         }
     }
 }