Пример #1
0
        public void Print(RecordSet records, ReportGenConfig config)
        {
            if (records == null | config == null)
            {
                throw new ArgumentNullException("打印参数或打印数据不能为空");
            }

            try
            {
                TECITLicense.Register();
            }
            catch (Exception ex)
            {
                throw new ReportGenLicenseException(ex);
            }

            Job job = default(Job);
            JobDataRecordSet jobdata = default(JobDataRecordSet);
            job = new Job();
            jobdata = new JobDataRecordSet();
            job.JobData = jobdata;
            job.RepositoryName = config.Template;
            job.PrinterName = config.Printer;
            job.PrinterType = config.PrinterType;
            job.NumberOfCopies = config.NumberOfCopies;
            for (int i = 0; i <= records.Count - 1; i++)
            {
                Record rec = new Record();
                foreach (KeyValuePair<string, string> ent in records[i])
                {
                    rec.Data.Add(ent.Key, ent.Value);
                }
                jobdata.Records.Add(rec);
            }

            try
            {
                job.Print();
                job.Dispose();
            }
            catch (TFORMerException ex)
            {
                if (ex.ErrorCode == 13)
                {
                    throw new ReportTypeException(ex);
                }
                else { throw new ReportPrintException(ex); }
            }
            catch (Exception ex)
            {
                throw new ReportPrintException(ex);
            }
            finally {
                if (job != null)
                    job.Dispose();
            }
        }
Пример #2
0
 public GenPrinterBase(string folderPath, string template)
 {
     this.folderPath = folderPath;
     this.taskConfig = new ReportGenConfig()
     {
         NumberOfCopies = copy,
         Printer = printerBase,
         Template = templateBasePath + "/" + template,
         PrinterType=printerType
     };
 }
Пример #3
0
 public void Print(RecordSet data,string printer_name=null,string copy=null)
 {
     IReportGen gen = new TecITGener();
     ReportGenConfig config = new ReportGenConfig()
     {
         Printer = string.IsNullOrEmpty(printer_name) ? this.Name : printer_name,
         NumberOfCopies = string.IsNullOrEmpty(copy) ? this.Copy : int.Parse(copy),
         PrinterType = (PrinterType)this.Type,
         Template = this.TemplatePath
     };
     gen.Print(data, config);
 }
Пример #4
0
 public ReturnMsg<string> Print(RecordSet data, ReportGenConfig printerConfig)
 {
     ReturnMsg<string> msg = new ReturnMsg<string>() { result = false };
     try
     {
         IReportGen gen = new TecITGener();
         gen.Print(data, printerConfig);
         msg.result = true;
         msg.content = "打印成功";
         msg.level = MsgLevel.Successful;
     }
     catch (Exception e) {
         msg.content = e.Message;
         msg.level = MsgLevel.Mistake;
     }
     return msg;
 }
Пример #5
0
 public static ReturnMsg<string> Print(PrintData data)
 {
     string template = System.IO.Path.Combine(SettingConfig.TemplatePath, data.template);
     if (!File.Exists(template))
     {
         Downloader.DownLoadTemplate(new string[] { data.template });
     }
     IGenPrinter printer = new GenPrinter();
     ReportGenConfig printerConfig = new ReportGenConfig()
     {
         NumberOfCopies = SettingConfig.Copy,
         Printer = SettingConfig.PrinterName,
         PrinterType = SettingConfig.PrinterType,
         Template = template
     };
     return printer.Print(data.dataset, printerConfig);
 }
Пример #6
0
        public void PrintTest()
        {
            string dnKey = "DN2013012820571";
            PrintData data;
            IRestDelivery restDelivery = new RestDelivery();
            data = restDelivery.DnItemPrintData(dnKey,200);

            IGenPrinter target = new GenPrinter();
            ReportGenConfig printerConfig = new ReportGenConfig()
            {
                NumberOfCopies = SettingConfig.Copy,
                Printer = SettingConfig.PrinterName,
                PrinterType = SettingConfig.PrinterType,
                Template = Path.Combine(SettingConfig.TemplatePath, data.template)
            };

            ReturnMsg<string> actual;
            actual = target.Print(data.dataset, printerConfig);
            Assert.AreEqual(true, actual.result);
        }
Пример #7
0
        public void Print(RecordSet records, ReportGenConfig config)
        {
            if (records == null | config == null)
            {
                throw new ArgumentNullException("打印参数或打印数据不能为空");
            }

            try
            {
                TECITLicense.Register();
            }
            catch (Exception ex)
            {
                throw new ReportGenLicenseException(ex);
            }

            Job job = default(Job);
            JobDataRecordSet jobdata = default(JobDataRecordSet);

            job                = new Job();
            jobdata            = new JobDataRecordSet();
            job.JobData        = jobdata;
            job.RepositoryName = config.Template;
            job.PrinterName    = config.Printer;
            job.PrinterType    = config.PrinterType;
            job.NumberOfCopies = config.NumberOfCopies;
            //job.ConfigFile = "新卷";
            //job.ConfigFile=""
            for (int i = 0; i <= records.Count - 1; i++)
            {
                Record rec = new Record();
                foreach (KeyValuePair <string, string> ent in records[i])
                {
                    rec.Data.Add(ent.Key, ent.Value);
                }
                jobdata.Records.Add(rec);
            }

            try
            {
                job.Print();
                job.Dispose();
            }
            catch (TFORMerException ex)
            {
                if (ex.ErrorCode == 13)
                {
                    throw new ReportTypeException(ex);
                }
                else
                {
                    throw new ReportPrintException(ex);
                }
            }
            catch (Exception ex)
            {
                throw new ReportPrintException(ex);
            }
            finally {
                if (job != null)
                {
                    job.Dispose();
                }
            }
        }