Exemplo n.º 1
0
    public static void Apply(this CssStyleCollection style, PrintSetting setting)
    {
        if (setting == null) return;

        if (string.IsNullOrEmpty(setting.Top))
        { style.Remove("top"); }
        else
        { style.Add("top", setting.Top); }

        if (string.IsNullOrEmpty(setting.Left))
        { style.Remove("left"); }
        else
        { style.Add("left", setting.Left); }

        if (string.IsNullOrEmpty(setting.Font))
        { style.Remove("font"); }
        else
        { style.Add("font", setting.Font); }

        if (string.IsNullOrEmpty(setting.Size))
        { style.Remove("font-size"); }
        else
        { style.Add("font-size", setting.Size); }

        if (string.IsNullOrEmpty(setting.Width))
        { style.Remove("width"); }
        else
        { style.Add("width", setting.Width); }

        if (string.IsNullOrEmpty(setting.Height))
        { style.Remove("height"); }
        else
        { style.Add("height", setting.Height); }
    }
    void AddControl(Product item, PrintSetting ps, Panel panel, string addText)
    {
        Category_ProductLabelUserControl uc = new Category_ProductLabelUserControl();
        uc = (Category_ProductLabelUserControl)LoadControl("~/Category/ProductLabelUserControl.ascx");
        uc.Fill_Letter(item.Code, item.LabelDesc + addText);
        uc.ResizeLabel(ps);

        panel.Controls.Add(uc);
    }
Exemplo n.º 3
0
    void AddDINLabelControl(string code, string desc, PrintSetting ps, Panel panel)
    {
        BloodGroupLabelUserControl uc = new BloodGroupLabelUserControl();
        uc = (BloodGroupLabelUserControl)LoadControl("~/Category/BloodGroupLabelUserControl.ascx");
        uc.Fill_Letter(code, desc);
        uc.ResizeLabel(ps);

        panel.Controls.Add(uc);
    }
Exemplo n.º 4
0
    void AddDINLabelControl(Donation item, PrintSetting ps, Panel panel)
    {
        DINLabelUserControl uc = new DINLabelUserControl();
        uc = (DINLabelUserControl)LoadControl("~/Collect/DINLabelUserControl.ascx");
        uc.Fill_Letter(item.DIN);
        uc.ResizeLabel(ps);

        panel.Controls.Add(uc);
    }
        static void LoadData(Type type)
        {
            RedBloodDataContext db = new RedBloodDataContext();

            List<PrintSetting> list = db.PrintSettings.Where(r => r.Type == type.Name).ToList();

            var l = type
                .GetMembers(BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty)
                .Where(r => r is PropertyInfo)
                .Select(r => r as PropertyInfo)
                .Where(r => r.PropertyType == typeof(PrintSetting));

            foreach (var item in l)
            {
                item.SetValue(type, list.Where(r => r.Name == item.Name).FirstOrDefault(), null);
            }

            bool needReload = false;
            foreach (var item in l)
            {
                var v = item.GetValue(type, null);
                if (v == null)
                {
                    PrintSetting e = new PrintSetting();
                    e.Type = type.Name;
                    e.Name = item.Name;
                    e.Note = item.Name;
                    db.PrintSettings.InsertOnSubmit(e);
                    db.SubmitChanges();
                    needReload = true;
                }
            }

            if (needReload)
            {
                LoadData(type);
            }
        }
Exemplo n.º 6
0
 private decimal GetMilimeters(PrintSetting printSetting)
 {
     return(printSetting.DPI);
 }
Exemplo n.º 7
0
 private LabelSize GetLabelSizeInches(PrintSetting printSetting)
 {
     return(new LabelSize(printSetting.LabelSize.Width, printSetting.LabelSize.Heigth));
 }
 public void ResizeLabel(PrintSetting ps)
 {
     divLabel.Style.Apply(ps);
 }
Exemplo n.º 9
0
    public static void Apply(this CssStyleCollection style, PrintSetting setting)
    {
        if (setting == null)
        {
            return;
        }

        if (string.IsNullOrEmpty(setting.Top))
        {
            style.Remove("top");
        }
        else
        {
            style.Add("top", setting.Top);
        }

        if (string.IsNullOrEmpty(setting.Left))
        {
            style.Remove("left");
        }
        else
        {
            style.Add("left", setting.Left);
        }

        if (string.IsNullOrEmpty(setting.Font))
        {
            style.Remove("font");
        }
        else
        {
            style.Add("font", setting.Font);
        }

        if (string.IsNullOrEmpty(setting.Size))
        {
            style.Remove("font-size");
        }
        else
        {
            style.Add("font-size", setting.Size);
        }

        if (string.IsNullOrEmpty(setting.Width))
        {
            style.Remove("width");
        }
        else
        {
            style.Add("width", setting.Width);
        }

        if (string.IsNullOrEmpty(setting.Height))
        {
            style.Remove("height");
        }
        else
        {
            style.Add("height", setting.Height);
        }
    }
Exemplo n.º 10
0
 public abstract int Process(SheetView sheet, Report report, PrintSetting printSetting, ref string err);
Exemplo n.º 11
0
 partial void UpdatePrintSetting(PrintSetting instance);
Exemplo n.º 12
0
        private void Stream( ArrayList data, PrintSetting printSetting )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( PrintSetting ) ) );

              data.Add( new Snoop.Data.String( "Printer name", printSetting.Name ) );
              data.Add( new Snoop.Data.Object( "Printer parameters", printSetting.PrintParameters ) );
        }
Exemplo n.º 13
0
        ////[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
        public static bool PrintToDevice(
            Document doc,
            string size,
            PrintManager pm,
            string printerName,
            bool forceRaster,
            ExportLog log)
        {
            if (pm == null)
            {
                return(false);
            }

            PrintSetting ps = LoadRevitPrintSetting(doc, size, pm, printerName, forceRaster, log);

            if (ps == null)
            {
                return(false);
            }

            var t = new Transaction(doc, Resources.ApplyPrintSettings);

            t.Start();
            try
            {
                if (ps.IsValidObject)
                {
                    pm.PrintSetup.CurrentPrintSetting = ps;
                }
                else
                {
                    if (log != null)
                    {
                        log.AddWarning(null, Resources.WarningPrintSetupReadOnly);
                    }
                }
                pm.PrintRange = PrintRange.Current;
                pm.PrintSetup.CurrentPrintSetting.PrintParameters.PaperPlacement = PaperPlacementType.Margins;
                pm.PrintSetup.InSession.PrintParameters.PaperPlacement           = PaperPlacementType.Margins;
                pm.PrintSetup.CurrentPrintSetting.PrintParameters.MarginType     = MarginType.UserDefined;
                pm.PrintSetup.InSession.PrintParameters.MarginType = MarginType.UserDefined;
#if REVIT2022 || REVIT2023
                pm.PrintSetup.CurrentPrintSetting.PrintParameters.OriginOffsetX = 0;
                pm.PrintSetup.InSession.PrintParameters.OriginOffsetY           = 0;
#else
                pm.PrintSetup.CurrentPrintSetting.PrintParameters.UserDefinedMarginX = 0;
                pm.PrintSetup.InSession.PrintParameters.UserDefinedMarginX           = 0;
                pm.PrintSetup.CurrentPrintSetting.PrintParameters.UserDefinedMarginY = 0;
                pm.PrintSetup.InSession.PrintParameters.UserDefinedMarginY           = 0;
#endif
                pm.PrintToFile = false;
                pm.Apply();
                t.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                if (log != null)
                {
                    log.AddError(null, ex.ToString());
                }
                t.RollBack();
                return(false);
            }
        }
Exemplo n.º 14
0
 public bool Print(string file, string varData, PrintSetting printSetup, string printerName, bool isShowPageWindow)
 {
     return HY_Print(file, varData, (int)printSetup, printerName, isShowPageWindow) == 0;
 }
Exemplo n.º 15
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            Application   app   = uiapp.Application;

            int check = 0;

            Document openDoc = null;

            using (var formOpen = new FormOpenFile())
            {
                formOpen.ShowDialog();

                string fileName = formOpen.filePath;

                ModelPath modelP = ModelPathUtils.ConvertUserVisiblePathToModelPath(fileName);

                OpenOptions optionDetach = new OpenOptions();

                optionDetach.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets;

                openDoc = app.OpenDocumentFile(modelP, optionDetach);

                check += 1;

                if (formOpen.DialogResult == winForms.DialogResult.OK)
                {
                    using (var form = new FormPickSheets())
                    {
                        List <ViewSheet> collector = Helpers.CollectViewSheet(openDoc);

                        foreach (ViewSheet vs in collector)
                        {
                            form.sheetNames.Add(vs.Name);
                            form.sheetNumbers.Add(vs.SheetNumber);
                        }

                        List <ViewSheetSet> allViewSheets = Helpers.CollectViewSheetSets(openDoc);

                        foreach (ViewSheetSet vs in allViewSheets)
                        {
                            form.dictSheetSetsNames.Add(vs.Name, Helpers.SheetInViewSheetsSets(vs));
                        }

                        Dictionary <string, PrintSetting> printSetting = Helpers.GetPrintersSettings(openDoc);

                        form.printSettings = printSetting.Keys.ToList();

                        form.ShowDialog();

                        if (form.DialogResult == winForms.DialogResult.Cancel)
                        {
                            return(Result.Cancelled);
                        }

                        string destination = @"C:\Temp\";

                        //TaskDialog.Show("result", Helpers.CollectViewSheet(openDoc));

                        List <ViewSheet> sheetList = Helpers.FindViewSheetByNumber(openDoc, form.pickedNumbers);

                        PrintSetting chosenPrintSet = printSetting.Values.ElementAt(form.pickedPrintSet);

                        foreach (ViewSheet sheet in sheetList)
                        {
                            try
                            {
                                ViewSet vs = Helpers.CreateViewset(openDoc, sheet.SheetNumber);//create a viewset with each view to be printed (only way to be able to set the file names)
                            }
                            catch
                            {
                                TaskDialog.Show("Error", "Can't create ViewSet");
                            }
                            Helpers.PrintDrawingsFromList(openDoc, sheet, destination + form.prefix + sheet.SheetNumber + Helpers.SheetRevision(sheet) + ".pdf", chosenPrintSet);
                        }

                        openDoc.Close(false);
                        check += -1;

                        if (check == 0)
                        {
                            TaskDialog.Show("Result", "The pdfs will appear in the printer default folder (something like C:\\Users\\[your name]\\Documents)");
                        }
                        else
                        {
                            TaskDialog.Show("Result", "Something went wrong");
                        }
                    }
                }
            }


            return(Result.Succeeded);
        }
Exemplo n.º 16
0
        public void DoPrint <T>(string printerName, object head, List <T> bodyList)
        {
            if (head == null && (bodyList == null || bodyList.Count == 0))
            {
                return;
            }
            if (bodyList.Count == 0)
            {
                return;
            }
            object body = bodyList[0];

            ReportSetting rs = new ReportSetting();
            PrintSetting  ps = new PrintSetting();

            ps.MarginBottom = "0";
            ps.MarginLeft   = "0";
            ps.MarginRight  = "0";
            ps.MarginTop    = "0";
            ps.Orientation  = "H";
            ps.PaperHeight  = "29.69";
            ps.PaperName    = "A4";
            ps.PaperWidth   = "21.01";
            ps.PrinterName  = printerName;
            rs.PrintSetting = ps;

            Type type = body.GetType();

            if (type == typeof(ErrorMessageDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\ErrorMessageReport.rdlc";
            }
            else if (type == typeof(InOutResultDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\InOutRelustReport.rdlc";
            }
            else if (type == typeof(LocationStorageDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LocationStorageReport.rdlc";
            }
            else if (type == typeof(MessageDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\MessageReport.rdlc";
            }

            else if (type == typeof(OvertimeStorageDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\OvertimeStorageReport.rdlc";
            }
            else if (type == typeof(StockoutCancel))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\StockoutCancelReport.rdlc";
            }
            else if (type == typeof(StorageDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\StorageReport.rdlc";
            }
            else if (type == typeof(TicketNoAndStorageDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\TicketNoAndStorageReport.rdlc";
            }
            else if (type == typeof(WorkViewDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\WorkViewReport.rdlc";
            }
            else if (type == typeof(SIDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\SIReport.rdlc";
            }
            else if (type == typeof(AssemblyDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\AssemblyReport.rdlc";
            }
            else if (type == typeof(RetrievalOrderDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\RetrievalOrder.rdlc";
            }

            ReportViewerFrm frm = new ReportViewerFrm(rs);

            if (head != null)
            {
                frm.AddDataSource(head.GetType().FullName.Replace('.', '_'), head);
            }

            if (bodyList != null && bodyList.Count > 0)
            {
                frm.AddDataSource(body.GetType().FullName.Replace('.', '_'), bodyList);
            }
            frm.InitReport();
            frm.Print();
            //frm.Show();
        }
Exemplo n.º 17
0
        public void DoPrint(string printerName, object obj)
        {
            ReportSetting rs = new ReportSetting();
            PrintSetting  ps = new PrintSetting();

            ps.MarginBottom = "0";
            ps.MarginLeft   = "0";
            ps.MarginRight  = "0";
            ps.MarginTop    = "0";
            ps.Orientation  = "V";
            ps.PaperName    = "Card";
            ps.PaperWidth   = "11.00";
            ps.PaperHeight  = "15.00";
            ps.PrinterName  = printerName;

            string labelPaperName = ConfigurationManager.AppSettings.Get("label-paper-name");

            if (labelPaperName == "A4")
            {
                ps.PaperName   = labelPaperName;
                ps.PaperWidth  = "21.00";
                ps.PaperHeight = "29.70";
            }
            else if (labelPaperName == "A5")
            {
                ps.PaperName   = labelPaperName;
                ps.PaperWidth  = "14.80";
                ps.PaperHeight = "21.00";
            }
            else if (labelPaperName == "A6")
            {
                ps.PaperName   = labelPaperName;
                ps.PaperWidth  = "10.50";
                ps.PaperHeight = "14.80";
            }

            rs.PrintSetting = ps;

            Type type = obj.GetType();

            if (type == typeof(LabelNormal))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LabelNormalReport.rdlc";
            }
            else if (type == typeof(LabelDetail))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LabelDetailReport.rdlc";
            }
            else if (type == typeof(LabelCustomer))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LabelCustomerReport.rdlc";
            }
            else if (type == typeof(LabelFuYong))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LabelFuYongReport.rdlc";
            }
            else if (type == typeof(LabelExternal))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LabelExternalReport.rdlc";
            }
            else if (type == typeof(LabelSubdivided))
            {
                rs.ReportFilePath = System.Windows.Forms.Application.StartupPath + @"\reports\LabelSubdividedReport.rdlc";
            }
            ReportViewerFrm frm = new ReportViewerFrm(rs);

            frm.AddDataSource(type.FullName.Replace('.', '_'), obj);
            frm.InitReport();
            frm.Print();
            //frm.Show();
        }
Exemplo n.º 18
0
 public override int Process(SheetView sheet, Report report, PrintSetting printSetting, ref string err)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemplo n.º 19
0
        /// <summary>
        /// Creates print settings usable for the paper sizes of selected print set.
        /// </summary>
        private void button3_Click(object sender, EventArgs e)
        {
            List <ViewSheet> viewSheetList = new List <ViewSheet>();

            if (selectedSheetSet == "Current sheet only")
            {
                Autodesk.Revit.DB.View view = doc.ActiveView;
                viewSheetList.Add((ViewSheet)view);
            }
            else
            {
                FilteredElementCollector col = new FilteredElementCollector(doc);
                var sheetSet = col.OfClass(typeof(ViewSheetSet))
                               .Where(x => x.Name == selectedSheetSet)
                               .Cast <ViewSheetSet>().FirstOrDefault();
                foreach (ViewSheet vs in sheetSet.Views)
                {
                    viewSheetList.Add(vs);
                }
            }

            PrintManager pm = doc.PrintManager;
            PrintSetup   ps = pm.PrintSetup;

            pm.SelectNewPrintDriver("Bluebeam PDF");
            pm = doc.PrintManager;
            ps = pm.PrintSetup;
            var paperSizes = pm.PaperSizes;

            FilteredElementCollector colPs = new FilteredElementCollector(doc);
            var printSettings = colPs.OfClass(typeof(PrintSetting)).Cast <PrintSetting>().ToHashSet();

            using (Transaction trans = new Transaction(doc))
            {
                trans.Start("PrintSettings");
                //PrintManager pm = doc.PrintManager;

                foreach (ViewSheet sheet in viewSheetList)
                {
                    FamilyInstance titleBlock =
                        fi.GetElements <FamilyInstance, BuiltInParameter>(doc, BuiltInParameter.SHEET_NUMBER, sheet.SheetNumber).FirstOrDefault();

                    var widthPar = titleBlock.get_Parameter(BuiltInParameter.SHEET_WIDTH);
                    var width    = Convert.ToInt32(widthPar.AsDouble().FtToMm().Round(0));

                    var heightPar = titleBlock.get_Parameter(BuiltInParameter.SHEET_HEIGHT);
                    var height    = Convert.ToInt32(heightPar.AsDouble().FtToMm().Round(0));

                    var nameOfPaperSize = paperSizeDict[height][width];

                    if (printSettings.Any(x => x.Name == nameOfPaperSize))
                    {
                        PrintSetting pset = printSettings.Where(x => x.Name == nameOfPaperSize).FirstOrDefault();
                        printSettings = printSettings.ExceptWhere(x => x.Name == nameOfPaperSize).ToHashSet();
                        doc.Delete(pset.Id);
                        doc.Regenerate();
                    }

                    pm.PrintRange  = PrintRange.Select;
                    pm.PrintToFile = true;

                    PrintSetup pSetup = pm.PrintSetup;
                    pSetup.CurrentPrintSetting = pm.PrintSetup.InSession;
                    PrintParameters pParams = pSetup.CurrentPrintSetting.PrintParameters;

                    pParams.ZoomType        = ZoomType.Zoom;
                    pParams.Zoom            = 100;
                    pParams.PageOrientation = PageOrientationType.Landscape;
                    pParams.PaperPlacement  = PaperPlacementType.Center;
                    if (radioButton1.Checked)
                    {
                        pParams.ColorDepth = ColorDepthType.Color;
                    }
                    else if (radioButton2.Checked)
                    {
                        pParams.ColorDepth = ColorDepthType.GrayScale;
                    }
                    else if (radioButton3.Checked)
                    {
                        pParams.ColorDepth = ColorDepthType.BlackLine;
                    }
                    pParams.RasterQuality                = RasterQualityType.Presentation;
                    pParams.HiddenLineViews              = HiddenLineViewsType.VectorProcessing;
                    pParams.ViewLinksinBlue              = false;
                    pParams.HideReforWorkPlanes          = true;
                    pParams.HideUnreferencedViewTags     = true;
                    pParams.HideCropBoundaries           = true;
                    pParams.HideScopeBoxes               = true;
                    pParams.ReplaceHalftoneWithThinLines = false;
                    pParams.MaskCoincidentLines          = false;

                    var paperSize = (from PaperSize psize in paperSizes where psize.Name.Equals(nameOfPaperSize) select psize).FirstOrDefault();

                    pParams.PaperSize = paperSize ?? throw new Exception("Printer does not have specified paper size! Check paper size configuration.");

                    pm.Apply();

                    try
                    {
                        pm.PrintSetup.SaveAs(paperSize.Name);
                    }
                    catch (Exception)
                    {
                    }
                }

                trans.Commit();
            }
        }
Exemplo n.º 20
0
 partial void InsertPrintSetting(PrintSetting instance);
Exemplo n.º 21
0
        public EMFStreamPrintDocument(Microsoft.Reporting.WinForms.LocalReport localReport, PrintSetting printSetting)
            : base()
        {
            this.printSetting  = printSetting;
            this.m_LocalReport = localReport;

            setPrinterSettings(this.PrinterSettings, this.printSetting);
            string retMessage = invalidatePrintSetting(this.printSetting);

            if (retMessage != string.Empty)
            {
                throw new Exception(retMessage);
            }

            setPageSettings(this.PrinterSettings.DefaultPageSettings, this.printSetting);
            setPageSettings(this.DefaultPageSettings, this.printSetting);
        }
Exemplo n.º 22
0
 partial void DeletePrintSetting(PrintSetting instance);
Exemplo n.º 23
0
 private void setPrinterSettings(PrinterSettings printerSettings, PrintSetting printSetting)
 {
     printerSettings.PrinterName = printSetting.PrinterName;
     //setPageSettings(printerSettings.DefaultPageSettings, printSetting);
 }
 public void ResizeLabel(PrintSetting ps)
 {
     divLabel.Style.Apply(ps);
 }
Exemplo n.º 25
0
        public string toXml(string reportName, string rdlcName)
        {
            XmlWriter     writer     = null;
            Stream        stream     = null;
            XmlSerializer serializer = null;

            try
            {
                if (!Directory.Exists(Application.StartupPath + @"/PrintSetting/ReportSetting"))
                {
                    Directory.CreateDirectory(Application.StartupPath + @"/PrintSetting/ReportSetting");
                }

                string[]      fileList = Directory.GetFiles(Application.StartupPath + @"/PrintSetting/ReportSetting");
                bool          hasCustomizedPrintSetting = false;
                ReportSetting reportSetting             = null;

                for (int i = 0; i < fileList.Length; ++i)
                {
                    try
                    {
                        serializer    = new XmlSerializer(typeof(ReportSetting));
                        stream        = File.Open(fileList[i], FileMode.Open, FileAccess.Read);
                        reportSetting = serializer.Deserialize(stream) as ReportSetting;
                        if (reportSetting.ReportName == reportName)
                        {
                            hasCustomizedPrintSetting = true;
                            break;
                        }
                    }
                    catch
                    {
                        throw new Exception(string.Format("读取自定义打印配置文件'[0]'时发生错误。", fileList[i]));
                    }
                }

                if (!hasCustomizedPrintSetting)
                {
                    PrintSetting printSetting = null;
                    if (!File.Exists(Application.StartupPath + @"/PrintSetting/DefaultPrintSetting.xml"))
                    {
                        throw new Exception("未配置打印机。");
                    }

                    try
                    {
                        serializer   = new XmlSerializer(typeof(PrintSetting));
                        stream       = File.Open(Application.StartupPath + @"/PrintSetting/DefaultPrintSetting.xml", FileMode.Open, FileAccess.Read);
                        printSetting = serializer.Deserialize(stream) as PrintSetting;
                    }
                    catch
                    {
                        throw new Exception(string.Format("读取默认打印配置文件'[0]'时发生错误。", Application.StartupPath + @"/PrintSetting/DefaultPrintSetting.xml"));
                    }

                    reportSetting              = new ReportSetting();
                    reportSetting.ReportName   = reportName;
                    reportSetting.PrintSetting = printSetting;
                }

                TaskXmlNode taskXmlNode = new TaskXmlNode();

                FileInfo info            = new FileInfo(Application.ExecutablePath);
                string   applicationName = info.Name.Substring(0, info.Name.LastIndexOf('.'));
                reportSetting.ReportFilePath = string.Format(@"\{0}\{1}", applicationName, rdlcName);
                taskXmlNode.ReportSetting    = reportSetting;


                foreach (IList <object> objList in this.list)
                {
                    if (objList.Count == 0)
                    {
                        continue;
                    }

                    DataSourceXmlNode dataSourceXmlNode = new DataSourceXmlNode();
                    taskXmlNode.DataSourceList.Add(dataSourceXmlNode);

                    Type type = objList[0].GetType();
                    dataSourceXmlNode.AssemblyPath = string.Format(@"\{0}\{1}", applicationName, new FileInfo(type.Assembly.Location).Name);
                    dataSourceXmlNode.TypeFullName = type.FullName;

                    foreach (object obj in objList)
                    {
                        RecordXmlNode recordXmlNode = new RecordXmlNode();
                        dataSourceXmlNode.RecordList.Add(recordXmlNode);

                        List <PropertyXmlNode> propList = readProperty(obj, type);

                        foreach (PropertyXmlNode prop in propList)
                        {
                            recordXmlNode.PropertyList.Add(prop);
                        }
                    }
                }

                serializer = new XmlSerializer(typeof(TaskXmlNode));
                StringBuilder builder = new StringBuilder();
                writer = XmlWriter.Create(builder);
                serializer.Serialize(writer, taskXmlNode);
                return(builder.ToString().Replace("utf-16", "utf-8"));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + " 无法生成打印所需的XML文件。");
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }