コード例 #1
0
ファイル: DataFactory.cs プロジェクト: huamanhtuyen/VNACCS
 public static void SaveToDataView(IData data, string fileName)
 {
     XmlSerializer serializer;
     if (typeof(NaccsData).IsInstanceOfType(data))
     {
         serializer = new XmlSerializer(typeof(NaccsData));
     }
     else
     {
         serializer = new XmlSerializer(typeof(IData));
     }
     TextWriter textWriter = new StreamWriter(fileName);
     data.CalcLength();
     serializer.Serialize(textWriter, data);
     textWriter.Close();
 }
コード例 #2
0
ファイル: PrintManager.cs プロジェクト: huamanhtuyen/VNACCS
 public void Printing(object Sender, string Key, IData Data, int PrintFlg, bool PreviewFlg)
 {
     if (PrintFlg == 0)
     {
         if (this.mManualFlg)
         {
             return;
         }
         this.mManualFlg = true;
     }
     this.mSender = Sender;
     this.SettingsRead();
     if ((PrintFlg != 2) || this.IsAutomaticPrint(Data))
     {
         int length = Data.Header.Length;
         if (length <= 400)
         {
             length = Data.CalcLength();
         }
         if (PrintFlg == 0)
         {
             if (ConfigFiles.printerSettings.DefaultInfo.SizeWarning && (length > this.mBorderByte))
             {
                 string str;
                 if (!PreviewFlg)
                 {
                     str = "W601";
                 }
                 else
                 {
                     str = "W602";
                 }
                 IMessageDialog dialog = new MessageDialog();
                 if (dialog.ShowMessage(str, Math.Truncate((double) (((double) this.mBorderByte) / 1024.0)).ToString(), "") != DialogResult.Yes)
                 {
                     this.mManualFlg = false;
                     return;
                 }
             }
             try
             {
                 AbstractJobConfig config;
                 this.GetJobConfig(Data, out config);
                 if (this.mCombi)
                 {
                     Data.Style = JobStyle.combi;
                     Data.JobIndex = 1;
                 }
                 PrintThread thread = new PrintThread();
                 thread.OnThPrintEnd += new OnThPrintEndHandler(this.PrintManager_OnPrintEnd);
                 thread.OnThPrintError += new OnThPrintErrorHandler(this.PrintManager_OnPrintError);
                 thread.TmThreadPrint(PrintStatus.Print, Sender, Key, PrintFlg, config, Data, PreviewFlg);
             }
             catch (NaccsException exception)
             {
                 this.mManualFlg = false;
                 if (this.OnPrintError != null)
                 {
                     this.OnPrintError(exception, Key, PrintFlg);
                 }
                 else
                 {
                     this.PrintErrMsg(exception);
                 }
             }
             catch (Exception exception2)
             {
                 this.mManualFlg = false;
                 NaccsException sender = new NaccsException(Naccs.Common.MessageKind.Error, 0x261, exception2.Message);
                 if (this.OnPrintError != null)
                 {
                     this.OnPrintError(sender, Key, PrintFlg);
                 }
                 else
                 {
                     this.PrintErrMsg(sender);
                 }
             }
         }
         else if (!ConfigFiles.printerSettings.DefaultInfo.SizeWarning || (length <= this.mBorderByte))
         {
             PQRecAttr rec = new PQRecAttr {
                 Key = Key,
                 Data = (NaccsData) Data,
                 PrintFlg = PrintFlg
             };
             this.QueueThreadStart(rec);
         }
     }
 }