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;
         }
     }
 }
Example #2
0
 public static void TestXMLSerialization(ChinaWeatherCityData m_da)
 {
     MemoryStream streamObject = new MemoryStream();
     Serialize(streamObject, m_da);
     streamObject.set_Position(0L);
     Assembly.GetExecutingAssembly().GetManifestResourceStream("ChinaWeather.DataCity.ChinaWeatherCityData.xml");
     ChinaWeatherCityData data1 = Deserialize(streamObject, typeof(ChinaWeatherCityData));
 }
Example #3
0
		protected override XmlSchema GetSchemaSerializable()
		{
			MemoryStream memoryStream = new MemoryStream();
			base.WriteXmlSchema(new XmlTextWriter(memoryStream, null));
			memoryStream.set_Position(0L);
			return XmlSchema.Read(new XmlTextReader(memoryStream), null);
		}
Example #4
0
 public static XmlSchemaComplexType GetTypedTableSchema(XmlSchemaSet xs)
 {
     XmlSchemaComplexType type = new XmlSchemaComplexType();
     XmlSchemaSequence sequence = new XmlSchemaSequence();
     StreetsHousesFlatsDS sds = new StreetsHousesFlatsDS();
     XmlSchemaAny any = new XmlSchemaAny();
     any.set_Namespace("http://www.w3.org/2001/XMLSchema");
     any.set_MinOccurs(0M);
     any.set_MaxOccurs(79228162514264337593543950335M);
     any.set_ProcessContents(XmlSchemaContentProcessing.Lax);
     sequence.Items.Add(any);
     XmlSchemaAny any2 = new XmlSchemaAny();
     any2.set_Namespace("urn:schemas-microsoft-com:xml-diffgram-v1");
     any2.set_MinOccurs(1M);
     any2.set_ProcessContents(XmlSchemaContentProcessing.Lax);
     sequence.Items.Add(any2);
     XmlSchemaAttribute attribute = new XmlSchemaAttribute();
     attribute.set_Name("namespace");
     attribute.set_FixedValue(sds.get_Namespace());
     type.Attributes.Add(attribute);
     XmlSchemaAttribute attribute2 = new XmlSchemaAttribute();
     attribute2.set_Name("tableTypeName");
     attribute2.set_FixedValue("FlatsDataTable");
     type.Attributes.Add(attribute2);
     type.set_Particle(sequence);
     XmlSchema schemaSerializable = sds.GetSchemaSerializable();
     if (xs.Contains(schemaSerializable.get_TargetNamespace()))
     {
         System.IO.MemoryStream stream = new System.IO.MemoryStream();
         System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
         try
         {
             XmlSchema schema2 = null;
             schemaSerializable.Write(stream);
             System.Collections.IEnumerator enumerator = xs.Schemas(schemaSerializable.get_TargetNamespace()).GetEnumerator();
             while (enumerator.MoveNext())
             {
                 schema2 = (XmlSchema) enumerator.get_Current();
                 stream2.SetLength((long) 0L);
                 schema2.Write(stream2);
                 if (stream.get_Length() == stream2.get_Length())
                 {
                     stream.set_Position((long) 0L);
                     stream2.set_Position((long) 0L);
                     while ((stream.get_Position() != stream.get_Length()) && (stream.ReadByte() == stream2.ReadByte()))
                     {
                     }
                     if (stream.get_Position() == stream.get_Length())
                     {
                         return type;
                     }
                 }
             }
         }
         finally
         {
             if (stream != null)
             {
                 stream.Close();
             }
             if (stream2 != null)
             {
                 stream2.Close();
             }
         }
     }
     xs.Add(schemaSerializable);
     return type;
 }
Example #5
0
 protected override XmlSchema GetSchemaSerializable()
 {
     System.IO.MemoryStream stream = new System.IO.MemoryStream();
     base.WriteXmlSchema(new XmlTextWriter(stream, null));
     stream.set_Position((long) 0L);
     return XmlSchema.Read(new XmlTextReader(stream), null);
 }
Example #6
0
 public static XmlSchemaComplexType GetTypedDataSetSchema(XmlSchemaSet xs)
 {
     StreetsHousesFlatsDS sds = new StreetsHousesFlatsDS();
     XmlSchemaComplexType type = new XmlSchemaComplexType();
     XmlSchemaSequence sequence = new XmlSchemaSequence();
     XmlSchemaAny any = new XmlSchemaAny();
     any.set_Namespace(sds.get_Namespace());
     sequence.Items.Add(any);
     type.set_Particle(sequence);
     XmlSchema schemaSerializable = sds.GetSchemaSerializable();
     if (xs.Contains(schemaSerializable.get_TargetNamespace()))
     {
         System.IO.MemoryStream stream = new System.IO.MemoryStream();
         System.IO.MemoryStream stream2 = new System.IO.MemoryStream();
         try
         {
             XmlSchema schema2 = null;
             schemaSerializable.Write(stream);
             System.Collections.IEnumerator enumerator = xs.Schemas(schemaSerializable.get_TargetNamespace()).GetEnumerator();
             while (enumerator.MoveNext())
             {
                 schema2 = (XmlSchema) enumerator.get_Current();
                 stream2.SetLength((long) 0L);
                 schema2.Write(stream2);
                 if (stream.get_Length() == stream2.get_Length())
                 {
                     stream.set_Position((long) 0L);
                     stream2.set_Position((long) 0L);
                     while ((stream.get_Position() != stream.get_Length()) && (stream.ReadByte() == stream2.ReadByte()))
                     {
                     }
                     if (stream.get_Position() == stream.get_Length())
                     {
                         return type;
                     }
                 }
             }
         }
         finally
         {
             if (stream != null)
             {
                 stream.Close();
             }
             if (stream2 != null)
             {
                 stream2.Close();
             }
         }
     }
     xs.Add(schemaSerializable);
     return type;
 }