private void Export(Export1cMode mode) { var dateStart = dateperiodpicker1.StartDate; var dateEnd = dateperiodpicker1.EndDate; using (var exportOperation = new ExportOperation(new OrderParametersProvider(new ParametersProvider()), mode, dateStart, dateEnd)) { this.exportInProgress = true; UpdateExportButtonSensitivity(); LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; UpdateExportButtonSensitivity(); exportData = exportOperation.Result; } this.labelTotalCounterparty.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceCounterparty) .ToString(); this.labelTotalNomenclature.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceNomenclature) .ToString(); this.labelTotalSales.Text = exportData.Objects .OfType <SalesDocumentNode>() .Count() .ToString(); this.labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C"); this.labelExportedSum.Markup = String.Format("<span foreground=\"{1}\">{0:C}</span>", exportData.ExportedTotalSum, exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red"); this.labelTotalInvoices.Text = exportData.Objects .OfType <InvoiceDocumentNode>() .Count() .ToString(); GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0; if (exportData.Errors.Count > 0) { TextTagTable textTags = new TextTagTable(); var tag = new TextTag("Red"); tag.Foreground = "red"; textTags.Add(tag); TextBuffer tempBuffer = new TextBuffer(textTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag); textviewErrors.Buffer = tempBuffer; } buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0; }
public static void PrintAll(IList <IPrintableOdtDocument> documents) { var result = LongOperationDlg.StartOperation( delegate(IWorker worker) { PrintDocuments(worker, documents); }, "Печать файлов...", documents.Count() ); if (result == LongOperationResult.Canceled) { return; } }
public void PrintAll(IEnumerable <IPrintableDocument> documents) { PrintSettings = null; if (Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix) { PrintSettings = PrintAll_Win_Workaround(documents); return; } PrintOperation printOp; printOp = new PrintOperation(); printOp.Unit = Unit.Points; printOp.UseFullPage = true; printOp.ShowProgress = true; var documentsRDL = documents.Where(doc => doc.PrintType == PrinterType.RDL).ToList(); BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL); var result = LongOperationDlg.StartOperation( renderer.PrepareDocuments, "Подготовка к печати...", documentsRDL.Count() ); if (result == LongOperationResult.Canceled) { PrintSettings = new PrintSettings(); return; } printOp.NPages = renderer.PageCount; if (documentsRDL.Any(x => x.Orientation == DocumentOrientation.Landscape)) { printOp.RequestPageSetup += renderer.RequestPageSetup; } printOp.DrawPage += renderer.DrawPage; printOp.EndPrint += (o, args) => { args.Args = documentsRDL.ToArray(); DocumentsPrinted?.Invoke(o, args); }; printOp.Run(PrintOperationAction.PrintDialog, null); PrintSettings = printOp.PrintSettings; }
protected void OnBtnRunToFileClicked(object sender, EventArgs e) { using (var exportOperation = new ExportCounterpartiesTo1C()) { this.exportInProgress = true; LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; exportData = exportOperation.Result; } var hasError = UpdateErrors(exportData.Errors); if (hasError) { return; } btnRunToFile.Sensitive = !hasError && !exportInProgress; var settings = new XmlWriterSettings { OmitXmlDeclaration = true, Indent = true, Encoding = System.Text.Encoding.UTF8, NewLineChars = "\r\n" }; var fileChooser = new Gtk.FileChooserDialog("Выберите файл для сохранения выгрузки", (Window)this.Toplevel, Gtk.FileChooserAction.Save, "Отмена", ResponseType.Cancel, "Сохранить", ResponseType.Accept ); var dateText = DateTime.Now.ToShortDateString().Replace(System.IO.Path.DirectorySeparatorChar, '-'); fileChooser.CurrentName = $"Выгрузка контрагентов на {dateText}.xml"; var filter = new FileFilter(); filter.AddPattern("*.xml"); fileChooser.Filter = filter; if (fileChooser.Run() == (int)ResponseType.Accept) { var filename = fileChooser.Filename.EndsWith(".xml") ? fileChooser.Filename : fileChooser.Filename + ".xml"; using (XmlWriter writer = XmlWriter.Create(filename, settings)) { exportData.ToXml().WriteTo(writer); } } fileChooser.Destroy(); }
private void Export(Export1cMode mode) { var dateStart = dateperiodpicker1.StartDate; var dateEnd = dateperiodpicker1.EndDate; int?organizationId = null; if (mode == Export1cMode.BuhgalteriaOOONew) { organizationId = (comboOrganization.SelectedItem as Organization)?.Id; } else if (mode == Export1cMode.BuhgalteriaOOO) { organizationId = new OrganizationParametersProvider(_parametersProvider).VodovozOrganizationId; } using (var exportOperation = new ExportOperation( mode, new OrderParametersProvider(_parametersProvider), dateStart, dateEnd, organizationId )) { this.exportInProgress = true; UpdateExportSensitivity(); LongOperationDlg.StartOperation(exportOperation.Run, "", 1, false); this.exportInProgress = false; UpdateExportSensitivity(); exportData = exportOperation.Result; } labelTotalCounterparty.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceCounterparty) .ToString(); labelTotalNomenclature.Text = exportData.Objects .OfType <CatalogObjectNode>() .Count(node => node.Type == Common1cTypes.ReferenceNomenclature) .ToString(); labelTotalSales.Text = (exportData.Objects .OfType <SalesDocumentNode>() .Count() + exportData.Objects.OfType <RetailDocumentNode>().Count()) .ToString(); labelTotalSum.Text = exportData.OrdersTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU")); labelExportedSum.Markup = $"<span foreground=\"{(exportData.ExportedTotalSum == exportData.OrdersTotalSum ? "green" : "red")}\">" + $"{exportData.ExportedTotalSum.ToString("C", CultureInfo.GetCultureInfo("ru-RU"))}</span>"; labelTotalInvoices.Text = exportData.Objects .OfType <InvoiceDocumentNode>() .Count() .ToString(); GtkScrolledWindowErrors.Visible = exportData.Errors.Count > 0; if (exportData.Errors.Count > 0) { TextTagTable textTags = new TextTagTable(); var tag = new TextTag("Red"); tag.Foreground = "red"; textTags.Add(tag); TextBuffer tempBuffer = new TextBuffer(textTags); TextIter iter = tempBuffer.EndIter; tempBuffer.InsertWithTags(ref iter, String.Join("\n", exportData.Errors), tag); textviewErrors.Buffer = tempBuffer; } buttonSave.Sensitive = exportData != null && exportData.Errors.Count == 0; }
/// <summary> /// Альтернативная релализация печати, специально для обхода бага в кайро при поворачивании(со старой реализацией печати пол Linux) /// https://bugzilla.mozilla.org/show_bug.cgi?id=1205854#c16 /// В новой при установке ориентации для каждой странице на большенстве принтеров обрезается часть выходящая за поворот. Хотя ориентация правильная. /// На некоторых принтерах например в водовозе, табличка рисуется за вертикалью листа а текст нет. /// используется только на винде, в линуксе такой проблемы нет. /// </summary> private PrintSettings PrintAll_Win_Workaround(IEnumerable <IPrintableDocument> documents) { PrintOperation printOp = null; PrintSettings printSettings = null; var documentsRDL_Portrait = documents.Where(doc => doc.PrintType == PrinterType.RDL && doc.Orientation == DocumentOrientation.Portrait).ToList(); var documentsRDL_Landscape = documents.Where(doc => doc.PrintType == PrinterType.RDL && doc.Orientation == DocumentOrientation.Landscape).ToList(); if (!documents.Any()) { printOp = new PrintOperation(); printOp.Run(PrintOperationAction.PrintDialog, null); return(printOp.PrintSettings); } if (documentsRDL_Portrait.Any()) { printOp = new PrintOperation(); printOp.Unit = Unit.Points; printOp.UseFullPage = true; printOp.ShowProgress = true; printOp.DefaultPageSetup = new PageSetup(); printOp.DefaultPageSetup.Orientation = PageOrientation.Portrait; BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Portrait); var result = LongOperationDlg.StartOperation( renderer.PrepareDocuments, "Подготовка к печати портретных страниц...", documentsRDL_Portrait.Count() ); if (result == LongOperationResult.Canceled) { return(new PrintSettings()); } printOp.NPages = renderer.PageCount; printOp.DrawPage += renderer.DrawPage; printOp.EndPrint += (o, args) => { args.Args = documentsRDL_Portrait.Concat(documentsRDL_Landscape).ToArray(); DocumentsPrinted?.Invoke(o, args); }; printOp.Run(PrintOperationAction.PrintDialog, null); printSettings = printOp.PrintSettings; } if (documentsRDL_Landscape.Any()) { printOp = new PrintOperation(); printOp.Unit = Unit.Points; printOp.UseFullPage = true; printOp.ShowProgress = true; printOp.DefaultPageSetup = new PageSetup(); //если printSettings == null, то значит, до этого не печатались RDL формата //PageOrientation.Portrait и, соответственно, не показывался PrintDialog и //нужно показать его сейчас. PrintOperationAction printOperationAction = PrintOperationAction.PrintDialog; if (printSettings != null) { printOp.PrintSettings = printSettings; printOp.PrintSettings.Orientation = PageOrientation.Landscape; printOperationAction = PrintOperationAction.Print; } printOp.DefaultPageSetup.Orientation = PageOrientation.Landscape; BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Landscape); var result = LongOperationDlg.StartOperation( renderer.PrepareDocuments, "Подготовка к печати альбомных страниц...", documentsRDL_Landscape.Count() ); if (result == LongOperationResult.Canceled) { return(new PrintSettings()); } printOp.NPages = renderer.PageCount; printOp.DrawPage += renderer.DrawPage; printOp.EndPrint += (o, args) => { args.Args = documentsRDL_Portrait.Concat(documentsRDL_Landscape).ToArray(); DocumentsPrinted?.Invoke(o, args); }; printOp.Run(printOperationAction, null); } return(printOp.PrintSettings); }