public static bool FillData_ManagerNames(OutputDocument oOutputDocument, DateTime?dDateBeg, DateTime?dDateEnd) { if (oOutputDocument == null) { return(false); } if (!dDateBeg.HasValue) { dDateBeg = DateTime.Now; } if (!dDateEnd.HasValue) { dDateEnd = DateTime.Now; } RFMCursorWait.Set(true); if (!oOutputDocument.FillTableManagerNames(dDateBeg, dDateEnd) || oOutputDocument.ErrorNumber != 0 || oOutputDocument.TableManagerNames == null) { RFMCursorWait.Set(false); RFMMessage.MessageBoxError("Ошибка при получении данных (менеджеры)..."); return(false); } RFMCursorWait.Set(false); if (oOutputDocument.TableManagerNames.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных (менеджеры)..."); return(false); } return(true); }
int nFirstCntRecords = 3; // количество первых записей для наборного текстового значения public frmSelectOneOutputDocument(Form _parentForm, bool _useCheck, OutputDocument _oOutputDocument) { oOutputDocumentList = new OutputDocument(); oOutputDocumentCur = new OutputDocument(); if (oOutputDocumentList.ErrorNumber != 0 || oOutputDocumentCur.ErrorNumber != 0) { IsValid = false; } oHost = new Host(); if (oHost.ErrorNumber != 0) { IsValid = false; } if (IsValid) { InitializeComponent(); parentForm = _parentForm; useCheck = _useCheck; oOutputDocument = _oOutputDocument; } }
//test meth //private void uploadResultonDisc(JobDocument[] jds) //{ // foreach (JobDocument jd in jds) // { // OutputDocument od = jd.OutputDocuments[0]; // FileContainer file = od.Files[0]; // String filename= jd.CustomText + ".tiff"; // byte[] content = file.FileContents; // Utils.saveToFileSystem(content, filename); // } //} protected override List <InputFile[]> getInputFilesFromJobDocuments(JobDocument[] jds) { var vs = jds.Select(jd => jd.CustomText.Substring(0, 7)).Distinct(); List <JobDocument[]> jdaList = new List <JobDocument[]>(vs.Count()); foreach (var v in vs) { IEnumerable <JobDocument> x = jds.Where(j => j.CustomText.StartsWith(v)); jdaList.Add(x.ToArray()); } List <InputFile[]> list = new List <InputFile[]>(jdaList.Count()); foreach (JobDocument[] jda in jdaList) { List <InputFile> inputFiles = new List <InputFile>(); foreach (JobDocument jd in jda) { OutputDocument od = jd.OutputDocuments[0]; FileContainer file = od.Files[0]; InputFile inputFile = new InputFile(); inputFile.OutputDocuments = jd.OutputDocuments; inputFile.Id = jd.CustomText; inputFile.FileData = file; inputFiles.Add(inputFile); } list.Add(inputFiles.ToArray()); } return(list); }
public static DocumentModel CreateDocumentModel(OutputDocument outputDoc) { DocumentModel docModel = new DocumentModel(); docModel.IssueDate = outputDoc.IssueDate; foreach (var docLine in outputDoc.Lines) { DessertInfo dessert = new DessertInfo(); dessert.Name = docLine.Dessert.Name; dessert.Quantity = docLine.Quantity; foreach (var outputDocProdLine in docLine.OutputDocLineProducts) { Ingredient ingredient = new Ingredient(); ingredient.Name = outputDocProdLine.Product.ProductDetail.Name; ingredient.Quantity = outputDocProdLine.CalcualtedQuantity; ingredient.Unit = outputDocProdLine.Product.ProductDetail.Unit; ingredient.BatchNumber = outputDocProdLine.Product.BatchNumber; dessert.Ingredients.Add(ingredient); } dessert.Ingredients = dessert.Ingredients.OrderBy(x => x.Name).ToList(); docModel.Desserts.Add(dessert); } return(docModel); }
private void RecalcSumOutputsDocuments() { int nPartnersQnt = 0, nPointsQnt = 0; decimal nNetto = 0, nBrutto = 0, nVolume = 0, nPalletsQnt = 0; nOutputsDocumentsQnt = oTrip.TableOutputsDocumentsInTrip.Rows.Count; string sOutputsDocumentsList = ""; foreach (DataRow r in oTrip.TableOutputsDocumentsInTrip.Rows) { sOutputsDocumentsList += r["ID"].ToString() + ","; } OutputDocument oOutputDocumentCalc = new OutputDocument(); oOutputDocumentCalc.CalcSum(sOutputsDocumentsList, ref nOutputsDocumentsQnt, ref nPartnersQnt, ref nPointsQnt, ref nNetto, ref nBrutto, ref nVolume, ref nPalletsQnt); nOutputsDocumentsPartnersQnt = nPartnersQnt; nOutputsDocumentsPointsQnt = nPointsQnt; nOutputsDocumentsNetto = nNetto; nOutputsDocumentsBrutto = nBrutto; nOutputsDocumentsVolume = nVolume; nOutputsDocumentsPalletsQnt = nPalletsQnt; return; }
public frmTripsBringEasy(int _nTripID) { nTripID = _nTripID; oTrip = new Trip(); if (oTrip.ErrorNumber != 0) { IsValid = false; } if (IsValid) { oOutputDocumentCur = new OutputDocument(); oOutputDocumentList = new OutputDocument(); if (oOutputDocumentCur.ErrorNumber != 0 || oOutputDocumentList.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { InitializeComponent(); } }
public frmOutputsDocumentsVeterinaryBlankData(string _sOutputsDocumentsList) { if (_sOutputsDocumentsList == null || _sOutputsDocumentsList.Length == 0) { RFMMessage.MessageBoxError("Неверный вызов"); DialogResult = DialogResult.No; IsValid = false; } if (IsValid) { sOutputsDocumentsList = _sOutputsDocumentsList; oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { InitializeComponent(); } }
public frmOutputsInputsCarries() { oOutputCur = new Output(); if (oOutputCur.ErrorNumber != 0) { IsValid = false; } oInputCur = new Input(); if (oInputCur.ErrorNumber != 0) { IsValid = false; } if (IsValid) { oOutputDocumentInOutput = new OutputDocument(); if (oOutputDocumentInOutput.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { oInputDocumentInInput = new InputDocument(); if (oInputDocumentInInput.ErrorNumber != 0) { IsValid = false; } } oOutputDocumentCur = new OutputDocument(); if (oOutputDocumentCur.ErrorNumber != 0) { IsValid = false; } oTrip = new Trip(); if (oTrip.ErrorNumber != 0) { IsValid = false; } oReportOutput = new Report(); oReportOutputDocument = new Report(); oReportInput = new Report(); if (oReportOutput.ErrorNumber != 0 || oReportOutputDocument.ErrorNumber != 0 || oReportInput.ErrorNumber != 0) { IsValid = false; } if (IsValid) { InitializeComponent(); } }
public Dictionary <string, object> Execute(OutputDocument document, Dictionary <string, object> namedPassThroughParameters) { Dictionary <string, object> results = new Dictionary <string, object>(); try { if (document.MetaParameters[StdMetaParamNames.DocumentIDKey] != "GenericReport") { throw new Exception("Report must be of type GenericReport."); } document.Data.Seek(0, SeekOrigin.Begin); using (XmlReader reader = XmlReader.Create(document.Data)) { reader.ReadToFollowing("Data"); using (MemoryStream data = new MemoryStream()) { int bytes = 0; byte[] buf = new byte[65536]; while ((bytes = reader.ReadElementContentAsBase64(buf, 0, 65536)) > 0) { data.Write(buf, 0, bytes); } if (data.Length == 0) { throw new Exception("The report has no content."); } data.Seek(0, SeekOrigin.Begin); using (ActiveReport report = new ActiveReport()) { report.Document.Load(data); //report.Document.Save(exportFilename, DataDynamics.ActiveReports.Document.RdfFormat.ARNet); if (Convert.ToBoolean(_configurationParameters[_OUTPUTENABLE])) { report.Document.Printer.PrinterName = document.PrinterDeviceName; report.Document.Printer.PrinterSettings.Copies = Convert.ToInt16(document.MetaParameters[StdMetaParamNames.NumberOfCopiesKey]); report.Document.Print(false, false, false); } } } } } catch (Exception ex) { throw new Exception("Error printing RDF report.\r\n" + ex.Message); } return(results); }
public override void Save(FileInfo outputFile) { var outputFileName = Path.ChangeExtension(outputFile.FullName, "html"); using (var output = XmlWriter.Create(outputFileName, new XmlWriterSettings() { Indent = true, ConformanceLevel = ConformanceLevel.Auto })) { Transform.Transform(OutputDocument.CreateNavigator(), output); } }
public frmOutputsDocumentsDeliveryPrices() { oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } if (IsValid) { InitializeComponent(); } }
//private InputFile[] getInputFilesFromRecord(byte[] content) //{ // InputFile[] inputFiles = new InputFile[1]; // FileContainer fileContainer = new FileContainer(); // fileContainer.FileContents = content; // InputFile inputFile = new InputFile(); // inputFile.FileData = fileContainer; // inputFiles[0] = inputFile; // return inputFiles; //} protected virtual InputFile[] getInputFilesFromOutputDocuments(OutputDocument od) { FileContainer[] files = od.Files; List <InputFile> inputFiles = new List <InputFile>(files.Count()); foreach (FileContainer file in files) { InputFile inputFile = new InputFile(); inputFile.FileData = file; inputFiles.Add(inputFile); } return(inputFiles.ToArray()); }
private void btnGuiltyEmloyeeSelect_Click(object sender, EventArgs e) { RFMCursorWait.Set(true); // ранее введеные значени¤ OutputDocument oOutputDocumentTemp = new OutputDocument(); oOutputDocumentTemp.FilterDateBeg = oOutputDocument.DateOutput.AddMonths(-1); oOutputDocumentTemp.FilterDateEnd = DateTime.Now.Date; oOutputDocumentTemp.FillData(); if (oOutputDocumentTemp.ErrorNumber != 0 || oOutputDocumentTemp.MainTable == null) { RFMCursorWait.Set(false); RFMMessage.MessageBoxError("ќшибка при получении данных о расходных документах..."); return; } if (oOutputDocument.MainTable.Rows.Count == 0) { RFMCursorWait.Set(false); RFMMessage.MessageBoxError("Ќет данных..."); return; } DataView dv = new DataView(oOutputDocumentTemp.MainTable, "GuiltyEmployees > ''", "GuiltyEmployees", DataViewRowState.CurrentRows); DataTable tdGuiltyEmployees = dv.ToTable(true, "GuiltyEmployees"); /* * DataTable dtGuiltyEmployeesDistinct = new DataTable(); * dtGuiltyEmployeesDistinct.Columns.Add("GuiltyEmployees"); * System.Collections.Hashtable hash = new System.Collections.Hashtable(); * foreach (DataRow row in oOutputDocumentTemp.MainTable.Rows) * hash[row["GuiltyEmployees"]] = row["GuiltyEmployees"]; * foreach (object name in hash.Values) * dtGuiltyEmployeesDistinct.Rows.Add(name); * DataTable tdGuiltyEmployees = CopyTable(dtGuiltyEmployeesDistinct, "tdGuiltyEmployees", "GuiltyEmployees > ''", "GuiltyEmployees"); */ RFMCursorWait.Set(false); if (StartForm(new frmSelectID(this, tdGuiltyEmployees, "GuiltyEmployees", "¬иновник проблем", false)) == DialogResult.Yes) { if (_SelectedID == null) { return; } txtGuiltyEmployees.Text = _SelectedText; } _SelectedID = null; _SelectedText = ""; return; }
//private bool bIsEditQnt = false; //private bool bIsEditBox = false; public frmOutputsDocumentsEdit(int _nOutputDocumentID) { nOutputDocumentID = _nOutputDocumentID; oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } if (IsValid) { oGoodState = new GoodState(); if (oGoodState.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { oOwner = new Partner(); if (oOwner.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { oGood = new Good(); if (oGood.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { InitializeComponent(); } nUserHostID = ((RFMFormMain)Application.OpenForms[0]).UserInfo.HostID; if (nOutputDocumentID > 0 || nUserHostID.HasValue) { PreFormName = ""; } }
public frmOutputsDocumentsTTNData(OutputDocument _oOutputDocument) { if (_oOutputDocument == null || (!_oOutputDocument.ID.HasValue && _oOutputDocument.IDList == null)) { DialogResult = DialogResult.No; IsValid = false; } if (IsValid) { oOutputDocument = _oOutputDocument; InitializeComponent(); } }
public frmOutputsDocumentsGoodsPriceEdit(int _nOutputDocumentID) { oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } if (IsValid) { oOutputDocument.ID = _nOutputDocumentID; InitializeComponent(); } }
public frmOutputsDocumentsBring(int _nOutputDocumentID) { nOutputDocumentID = _nOutputDocumentID; oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } if (IsValid) { InitializeComponent(); } }
public frmOutputsDocumentsGuiltyEmployees(int _nID) { nID = _nID; oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } if (IsValid) { InitializeComponent(); } }
private void ucSelectRecordID_ManagerNames_Restore() { if (dtrDates.dtpBegDate.IsChanged || dtrDates.dtpEndDate.IsChanged) { TableManagerNames = null; dtrDates.dtpBegDate.IsChanged = dtrDates.dtpEndDate.IsChanged = false; } if (TableManagerNames == null || TableManagerNames.Rows.Count == 0) { ucSelectRecordID_ManagerNames.sourceData = null; oOutputDocument = new OutputDocument(); DateTime dDateBeg, dDateEnd; if (dtrDates.dtpBegDate.IsEmpty) { dDateBeg = DateTime.Now; } else { dDateBeg = dtrDates.dtpBegDate.Value; } if (dtrDates.dtpEndDate.IsEmpty) { dDateEnd = DateTime.Now; } else { dDateEnd = dtrDates.dtpEndDate.Value; } if (Utilities.FillData_ManagerNames(oOutputDocument, dDateBeg, dDateEnd)) { DataColumn c = oOutputDocument.TableManagerNames.Columns.Add("ID", Type.GetType("System.Int32")); int i = 0; foreach (DataRow mn in oOutputDocument.TableManagerNames.Rows) { mn["ID"] = i; i++; } TableManagerNames = CopyTable(oOutputDocument.TableManagerNames, "TableManagerNames", "", "ManagerName"); } } if (TableManagerNames != null) { ucSelectRecordID_ManagerNames.Restore(TableManagerNames); } }
private void btnDelete_Click(object sender, EventArgs e) { if (tcList.CurrentPage.Name.ToUpper().Contains("DATA")) { if (grdData.CurrentRow == null) { return; } if (!oFactureCur.ID.HasValue) { return; } // перечитать oFactureCur.ReFillOne((int)oFactureCur.ID); // проверки if (oFactureCur.OutputDocumentID.HasValue) { OutputDocument oOutputDocumentTemp = new OutputDocument(); oOutputDocumentTemp.ID = oFactureCur.OutputDocumentID; oOutputDocumentTemp.ReFillOne((int)oOutputDocumentTemp.ID); if (oOutputDocumentTemp.DateBring != null) { RFMMessage.MessageBoxError("Заказ уже доставлен клиенту...\nУдаление не выполняется."); return; } } if (RFMMessage.MessageBoxYesNo("Удалить счет-фактуру?") == DialogResult.Yes) { Refresh(); WaitOn(this); bool bResult = oFactureCur.Delete((int)oFactureCur.ID); WaitOff(this); if (bResult && oFactureCur.ErrorNumber == 0) { RFMMessage.MessageBoxInfo("Счет-фактура удален."); } else { RFMMessage.MessageBoxError("Ошибка при удалении счета-фактуры..."); } grdData_Restore(); } } }
protected virtual List <InputFile[]> getInputFilesFromJobDocuments(JobDocument[] jds) { List <InputFile[]> list = new List <InputFile[]>(jds.Count()); foreach (JobDocument jd in jds) { List <InputFile> inputFiles = new List <InputFile>(); OutputDocument od = jd.OutputDocuments[0]; FileContainer file = od.Files[0]; InputFile inputFile = new InputFile(); inputFile.OutputDocuments = jd.OutputDocuments; inputFile.Id = jd.CustomText; inputFile.FileData = file; inputFiles.Add(inputFile); list.Add(inputFiles.ToArray()); } return(list); }
public frmOutputsDocumentsFactTime(int _nTripID) { nTripID = _nTripID; oTrip = new Trip(); if (oTrip.ErrorNumber != 0) { IsValid = false; } if (isValid) { oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } } if (IsValid) { InitializeComponent(); } }
public frmOutputsDocumentsGuiltyEmployees(int _nID, bool _bCarry) { bCarry = _bCarry; if (bCarry) { nID = -1; nCarryID = _nID; } else { nID = _nID; } oOutputDocument = new OutputDocument(); if (oOutputDocument.ErrorNumber != 0) { IsValid = false; } if (IsValid) { InitializeComponent(); } }
private void btnPrint_Click(object sender, EventArgs e) { if (grdData.Rows.Count == 0 || grdData.CurrentRow == null) { return; } // сохранение - всего подряд //DataRow dr = ((DataRowView)((DataGridViewRow)grdData.Rows[grdData.CurrentRow.Index]).DataBoundItem).Row; //DataTable dtRep = CopyTable(dt, "dtRep", "OutputsDocumentsListID = '" + dr["OutputsDocumentsListID"].ToString() + "'", ""); foreach (DataRow dr in dt.Rows) { // сохранение серии и номера, если введены if (dr["VeterinaryBlankSeries"] != null && !Convert.IsDBNull(dr["VeterinaryBlankSeries"]) && dr["VeterinaryBlankSeries"].ToString().Trim().Length > 0 || dr["VeterinaryBlankNumber"] != null && !Convert.IsDBNull(dr["VeterinaryBlankNumber"]) && dr["VeterinaryBlankNumber"].ToString().Trim().Length > 0) { string sVeterinaryBlankSeries = ""; if (dr["VeterinaryBlankSeries"] != null && !Convert.IsDBNull(dr["VeterinaryBlankSeries"]) && dr["VeterinaryBlankSeries"].ToString().Length > 0) { sVeterinaryBlankSeries = dr["VeterinaryBlankSeries"].ToString().Trim(); } string sVeterinaryBlankNumber = ""; if (dr["VeterinaryBlankNumber"] != null && !Convert.IsDBNull(dr["VeterinaryBlankNumber"]) && dr["VeterinaryBlankNumber"].ToString().Length > 0) { sVeterinaryBlankNumber = dr["VeterinaryBlankNumber"].ToString().Trim(); } string sVeterinaryBlankType = (optLocalBlank.Checked ? "4" : "2"); string sOutputsDocumentsList = dr["OutputsDocumentsListID"].ToString(); string[] sOutputsDocumentsIDSplit = sOutputsDocumentsList.Split(new char[] { ',' }); foreach (string s in sOutputsDocumentsIDSplit) { if (s.Length == 0) { continue; } try { int nOutputDocumentID = Convert.ToInt32(s); oOutputDocument.SaveVeterinaryBlankData(nOutputDocumentID, sVeterinaryBlankSeries, sVeterinaryBlankNumber, sVeterinaryBlankType, ((RFMFormMain)Application.OpenForms[0]).UserID); } catch { } } } dr["VeterinarFIO"] = txtVeterinarFio.Text; } // несколько отмеченных записей или только текущая запись DataTable dtMarked = CopyTable(dt, "dtMarked", "IsMarked = true", ""); if (dtMarked.Rows.Count == 0) { // текущая запись DataRow drMarked = ((DataRowView)((DataGridViewRow)grdData.Rows[grdData.CurrentRow.Index]).DataBoundItem).Row; DataTable dtMarkedTemp = CopyTable(dt, "dtMarkedTemp", "OutputsDocumentsListID = '" + drMarked["OutputsDocumentsListID"].ToString() + "'", ""); dtMarked.Merge(dtMarkedTemp); } if (dtMarked.Rows.Count == 0) { RFMMessage.MessageBoxInfo("Нет данных..."); return; } // печать 2-ой (обратной) страницы foreach (DataRow drp in dtMarked.Rows) { drp["IsPrintSecondPage"] = chkSecondPage.Checked; } if (chkVeterinaryListAdd.Checked) { string sMarkedOutputsDocumentsList = ""; // если печатается приложение - должны быть заполнены серия и номер foreach (DataRow drp in dtMarked.Rows) { if (drp["VeterinaryBlankSeries"] == null || Convert.IsDBNull(drp["VeterinaryBlankSeries"]) || drp["VeterinaryBlankSeries"].ToString().Trim().Length == 0 || drp["VeterinaryBlankNumber"] == null || Convert.IsDBNull(drp["VeterinaryBlankNumber"]) || drp["VeterinaryBlankNumber"].ToString().Trim().Length == 0) { RFMMessage.MessageBoxInfo("Не введены данные о серии и номере бланка ветеринарного свидетельства\n" + "(печать с приложениями)..."); return; } drp["VeterinaryMarks"] = drp["VeterinaryLaboratories"] = "см. Приложение 1"; sMarkedOutputsDocumentsList += drp["OutputsDocumentsListID"].ToString() + ","; } ActiveReport3 rep = new DataDynamics.ActiveReports.ActiveReport3(); if (optLocalBlank.Checked) { rep = new VeterinaryBlank(); } else { rep = new VeterinaryBlankSingle(); } StartForm(new frmActiveReport(dtMarked, rep)); if (RFMMessage.MessageBoxYesNo("Внимание!\n\n" + "Выполнена печать на бланках ветеринарных свидетельств.\n" + "Сейчас будет выполняться печать приложений.\n\n" + "Продолжить?") != DialogResult.Yes) { return; } // данные для приложений OutputDocument oOutputDocumentAdd = new OutputDocument(); oOutputDocumentAdd.FillVeterinaryAddTableOutputsDocumentsGoods(sMarkedOutputsDocumentsList, optPartnerGroup.Checked); if (oOutputDocumentAdd.ErrorNumber == 0 && oOutputDocumentAdd.TableOutputsDocumentsGoods != null) { if (oOutputDocumentAdd.TableOutputsDocumentsGoods.Rows.Count == 0) { RFMMessage.MessageBoxInfo("Нет данных для печати приложений к ветеринарным свидетельствам..."); return; } RFMMessage.MessageBoxAttention("Выполняется печать приложений к ветеринарным свидетельствам..."); rep = new VeterinaryListAdd(); StartForm(new frmActiveReport(oOutputDocumentAdd.TableOutputsDocumentsGoods, rep)); } } else { ActiveReport3 rep = new DataDynamics.ActiveReports.ActiveReport3(); if (optLocalBlank.Checked) { rep = new VeterinaryBlank(); } else { rep = new VeterinaryBlankSingle(); } StartForm(new frmActiveReport(dtMarked, rep)); } // отметка печати bool bOK = false; foreach (DataRow dr in dt.Rows) { if ((bool)dr["IsMarked"]) { dr["IsPrinted"] = true; bOK = true; } } if (!bOK) { // только для текущей DataRow drMarked = ((DataRowView)((DataGridViewRow)grdData.Rows[grdData.CurrentRow.Index]).DataBoundItem).Row; drMarked["IsPrinted"] = true; } }
public Dictionary <string, object> Execute(OutputDocument document, Dictionary <string, object> namedPassThroughParameters) { Dictionary <string, object> results = new Dictionary <string, object>(); try { if (document.MetaParameters[StdMetaParamNames.DocumentIDKey] != "GenericReport") { throw new Exception("Report must be of type GenericReport."); } document.Data.Seek(0, SeekOrigin.Begin); using (XmlReader reader = XmlReader.Create(document.Data)) { reader.ReadToFollowing("Data"); byte[] pdfDoc = new byte[0]; int bytesRead = 0; byte[] buf = new byte[65536]; while ((bytesRead = reader.ReadElementContentAsBase64(buf, 0, 65536)) > 0) { int oldEndIndex = pdfDoc.Length == 0 ? 0 : (pdfDoc.Length - 1); Array.Resize <byte>(ref pdfDoc, (pdfDoc.Length + bytesRead)); Array.Copy(buf, 0, pdfDoc, oldEndIndex, bytesRead); } if (pdfDoc.Length == 0) { throw new Exception("The report has no content."); } if (Convert.ToBoolean(_configurationParameters[_OUTPUTENABLE])) { PdfPrint pdfPrint = new PdfPrint("Aptean AB", "g/4JFMjn6KvRA39zUa4QClRtNo6h5TnW273JkSGKwP0="); pdfPrint.PrinterName = document.PrinterDeviceName; pdfPrint.Copies = Convert.ToInt16(document.MetaParameters[StdMetaParamNames.NumberOfCopiesKey]); PdfPrint.Status status = pdfPrint.Print(pdfDoc); if (status != PdfPrint.Status.OK) { throw new Exception("Error printing PDF report: " + status.ToString()); } } if (results.ContainsKey(StdResultParamNames.BinaryResultKey)) { results.Remove(StdResultParamNames.BinaryResultKey); } results.Add(StdResultParamNames.BinaryResultKey, pdfDoc); } } catch (Exception ex) { throw new Exception("Error printing PDF report.\r\n" + ex.Message); } return(results); }
private void WarrantsAnalysis() { // тестирование доверенностей за период DateTime dDateBeg = DateTime.Now.Date; DateTime dDateEnd = DateTime.Now.Date.AddMonths(-1); if (StartForm(new frmDateRange(dDateBeg, dDateEnd)) == DialogResult.Yes) { if (GotParam[0] != null) { dDateBeg = (DateTime)GotParam[0]; } else { dDateBeg = Convert.ToDateTime("01.01.1900"); } if (GotParam[1] != null) { dDateEnd = (DateTime)GotParam[1]; } else { dDateEnd = Convert.ToDateTime("31.12.2099"); } } WarrantNumber oWarrantAnalysis = new WarrantNumber(); oWarrantAnalysis.FilterDateBeg = dDateBeg; oWarrantAnalysis.FilterDateEnd = dDateEnd; oWarrantAnalysis.FillData(); if (oWarrantAnalysis.ErrorNumber != 0 || oWarrantAnalysis.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при анализе списка доверенностей..."); return; } if (oWarrantAnalysis.MainTable.Rows.Count == 0) { RFMMessage.MessageBoxError("Нет данных о доверенностях за период..."); return; } WaitOn(this); string sEol = Environment.NewLine; OutputDocument oOutputDocument = new OutputDocument(); InputDocument oInputDocument = new InputDocument(); DataTable dtWarrant = CopyTable(oWarrantAnalysis.MainTable, "dtWarrant", "", "PartnerSourceID, NumberInt, Number, DateIssue"); string sText = "Анализ журнала выдачи доверенностей за период " + dDateBeg.ToString("dd.MM.yyyy") + " - " + dDateEnd.ToString("dd.MM.yyyy") + sEol; int nPartnerSourceID = -1; int nNumberInt = -1; int nNumberIntOld = -1; string sNumber = ""; bool bOK = true; foreach (DataRow rW in dtWarrant.Rows) { oWarrantAnalysis.FillOne(rW); // новый партнер if (nPartnerSourceID != oWarrantAnalysis.PartnerSourceID) { sText += sEol + "Доверенности выданы фирмой: " + oWarrantAnalysis.PartnerSourceName + sEol; nPartnerSourceID = oWarrantAnalysis.PartnerSourceID; nNumberInt = -1; nNumberIntOld = -1; sNumber = ""; bOK = true; } nNumberInt = oWarrantAnalysis.NumberInt; sNumber = oWarrantAnalysis.Number; // нумерация if (nNumberIntOld != -1) { if (nNumberInt == nNumberIntOld) { sText += sNumber + "(" + nNumberInt.ToString().Trim() + "): доверенности с одинаковым порядковым номером" + sEol; bOK = false; } if (nNumberInt != nNumberIntOld + 1) { sText += sNumber + " (" + nNumberIntOld.ToString() + " - " + nNumberInt.ToString().Trim() + "): пропуск в порядковых номерах доверенностей" + sEol; bOK = false; } } // заказы // заказ на отгрузку if (oWarrantAnalysis.OutputDocumentID.HasValue) { oOutputDocument.ID = (int)oWarrantAnalysis.OutputDocumentID; oOutputDocument.FillData(); if (oOutputDocument.MainTable.Rows.Count == 0) { sText += sNumber + ": не найден заказ на отгрузку с кодом " + oWarrantAnalysis.OutputDocumentID + sEol; bOK = false; } else { oOutputDocument.FillOne(); // номера if (oOutputDocument.WarrantNumber != sNumber) { sText += sNumber + ": не совпадают номера доверенностей в журнале и в заказе на отгрузку (" + oOutputDocument.WarrantNumber.ToString().Trim() + ")" + sEol; bOK = false; } // if (oOutputDocument.IsWarrantReturned && !oWarrantAnalysis.IsReturned) { sText += sNumber + ": в заказе на отгрузку доверенность возвращена, в журнале нет" + sEol; bOK = false; } if (!oOutputDocument.IsWarrantReturned && oWarrantAnalysis.IsReturned) { sText += sNumber + ": в журнале доверенность возвращена, в заказе на отгрузку нет" + sEol; bOK = false; } if (oWarrantAnalysis != null && oWarrantAnalysis.CurrencyID != null && (oOutputDocument.GetMoneyConfirmed != oWarrantAnalysis.Amount || oOutputDocument.GetCurrencyID != oWarrantAnalysis.CurrencyID)) { sText += sNumber + ": сумма/валюта в журнале (" + ((decimal)oWarrantAnalysis.Amount).ToString("#####0.00") + oWarrantAnalysis.CurrencyName + ") и в заказе на отгрузку (" + oOutputDocument.GetMoneyConfirmed.ToString("#####0.00") + oOutputDocument.GetCurrencyName + ") не совпадают" + sEol; bOK = false; } } } // заказ на поставку if (oWarrantAnalysis.InputDocumentID.HasValue) { oInputDocument.ID = (int)oWarrantAnalysis.InputDocumentID; oInputDocument.FillData(); if (oInputDocument.MainTable.Rows.Count != 1) { sText += sNumber + ": не найден заказ на поставку с кодом " + oWarrantAnalysis.InputDocumentID + sEol; bOK = false; } else { oInputDocument.FillOne(); // номера if (oInputDocument.WarrantNumber != sNumber) { sText += sNumber + ": не совпадают номера доверенностей в журнале и в заказе на поставку (" + oInputDocument.WarrantNumber.ToString().Trim() + ")" + sEol; bOK = false; } } } // проверки законечены, переходим к следующей доверенности в списке nNumberIntOld = (int)rW["NumberInt"]; } if (bOK) { sText += "OK" + sEol; } // анализ таблиц заказов // заказы на отгрузку bOK = true; oOutputDocument.FilterDateBeg = dDateBeg; oOutputDocument.FilterDateEnd = dDateEnd; oOutputDocument.FillData(); if (oOutputDocument.ErrorNumber != 0 || oOutputDocument.MainTable == null) { RFMMessage.MessageBoxError("Ошибка при анализе списка заказов на отгрузку..."); } else { if (oOutputDocument.MainTable.Rows.Count > 0) { sText += sEol + "Анализ списка заказов на отгрузку: " + sEol; string sOutputDocument = ""; foreach (DataRow rO in oOutputDocument.MainTable.Rows) { oOutputDocument.FillOne(); sOutputDocument = oOutputDocument.ID.ToString().Trim(); sNumber = oOutputDocument.WarrantNumber; if (sNumber == null) { sNumber = ""; } // наличие доверенности if (oOutputDocument.IsConfirmed) { if (oOutputDocument.PF_WarrantNeed && sNumber.Length == 0) { sText += sOutputDocument + ": не определен номер доверенности для заказа, где требуется доверенность" + sEol; bOK = false; } } if (!oOutputDocument.PF_WarrantNeed && sNumber.Length > 0) { sText += sOutputDocument + ": определен номер доверенности (" + sNumber + ") для заказа, где не требуется доверенность" + sEol; bOK = false; } if (oOutputDocument.PF_WarrantNeed && sNumber.Length > 0) { oWarrantAnalysis.FilterOutputsDocumentsList = sOutputDocument; oWarrantAnalysis.FillData(); if (oWarrantAnalysis.MainTable.Rows.Count == 0) { sText += sOutputDocument + ": в журнале не найдена доверенность (" + sNumber + ") для заказа" + sEol; bOK = false; } if (oWarrantAnalysis.MainTable.Rows.Count > 1) { sText += sOutputDocument + ": в журнале найдено несколько доверенностей для заказа (" + sNumber + ")" + sEol; bOK = false; } oWarrantAnalysis.FilterNumberContext = sNumber; oWarrantAnalysis.FilterPartnersSourceList = oOutputDocument.PartnerSourceID.ToString(); oWarrantAnalysis.FilterDateBeg = oOutputDocument.DateOutput.AddDays(-10); oWarrantAnalysis.FilterDateEnd = oOutputDocument.DateOutput.AddDays(10); oWarrantAnalysis.FillData(); if (oWarrantAnalysis.MainTable.Rows.Count == 0) { sText += sOutputDocument + ": в журнале не найдена доверенность по номеру (" + sNumber + "), указанному в заказе" + sEol; bOK = false; } if (oWarrantAnalysis.MainTable.Rows.Count > 1) { sText += sOutputDocument + ": в журнале найдено несколько доверенностей по номеру (" + sNumber + "), указанному в заказе" + sEol; bOK = false; } oWarrantAnalysis.FillOne(); if (oWarrantAnalysis.OutputDocumentID != oOutputDocument.ID) { sText += sOutputDocument + ": в журнале найдена доверенность по номеру (" + sNumber + "), но в ней указан другой заказ" + sEol; bOK = false; } if (oWarrantAnalysis.PartnerSourceID != oOutputDocument.PartnerSourceID || oWarrantAnalysis.PartnerTargetID != oOutputDocument.PartnerTargetID) { sText += sOutputDocument + ": в журнале найдена доверенность по номеру (" + sNumber + "), но в ней указан другой клиент" + sEol; bOK = false; } if (oWarrantAnalysis.Amount != null && oWarrantAnalysis.CurrencyID != null && ((decimal)oWarrantAnalysis.Amount != oOutputDocument.GetMoneyConfirmed || (int)oWarrantAnalysis.CurrencyID != oOutputDocument.GetCurrencyID)) { sText += sOutputDocument + ": в журнале найдена доверенность по номеру (" + sNumber + "), но в ней указана другая сумма" + sEol; bOK = false; } } if (!oOutputDocument.PF_WarrantNeed) { oWarrantAnalysis.FilterOutputsDocumentsList = sOutputDocument; if (oWarrantAnalysis.MainTable.Rows.Count > 0) { sText += sOutputDocument + ": в журнале найдена доверенность (" + oWarrantAnalysis.MainTable.Rows[0]["Number"].ToString() + ") для заказа, для которого она не требуется" + sEol; bOK = false; } } // переходим к след.заказу } if (bOK) { sText += "OK"; } } } // здесь должны быть аналогичные проверки для заказов на поставку InputsDocuments bOK = true; // выводим отчет WaitOff(this); StartForm(new frmSysTextReport(sText)); /* * string sFileName = ((RFMFormMain)Application.OpenForms[0]).UserInfo.UserLocPath + "WarrantsAnalysis.txt"; * File.AppendAllText(sFileName, sText, Encoding.Default); * StartForm(new frmSysTextReport(true, sFileName)); */ }
private void mniOutputsDocumentsService_GuiltyEmployees_Click(object sender, EventArgs e) { if (grdOutputsDocuments.CurrentRow == null || grdOutputsDocuments.IsStatusRow(grdOutputsDocuments.CurrentRow.Index)) { return; } DataRow r = ((DataRowView)((DataGridViewRow)grdOutputsDocuments.Rows[grdOutputsDocuments.CurrentRow.Index]).DataBoundItem).Row; if (Convert.IsDBNull(r["OldOutputDocumentID"])) { return; } int nOldOutputDocumentID = (int)r["OldOutputDocumentID"]; int nNewOutputDocumentID = (int)r["NewOutputDocumentID"]; DateTime dDateCarry = Convert.ToDateTime(r["DateCarry"]); OutputDocument oOutputDocumentCarry = new OutputDocument(); oOutputDocumentCarry.ReFillOne(nOldOutputDocumentID); oOutputDocumentCarry.FillTableOutputsDocumentsCarries(nOldOutputDocumentID); if (oOutputDocumentCarry.ErrorNumber != 0 || !oOutputDocumentCarry.DS.Tables.Contains("TableOutputsDocumentsCarries") || oOutputDocumentCarry.DS.Tables["TableOutputsDocumentsCarries"] == null || oOutputDocumentCarry.DS.Tables["TableOutputsDocumentsCarries"].Rows.Count == 0) { RFMMessage.MessageBoxError("Ошибка при получении данных о переносах и копиях расходного документа..."); return; } int? nCarryID = null; DataTable dtCarries = oOutputDocumentCarry.DS.Tables["TableOutputsDocumentsCarries"]; foreach (DataRow roc in dtCarries.Rows) { int nX_OldOutputDocumentID = (int)roc["OutputDocumentID"]; int nX_NewOutputDocumentID = nX_OldOutputDocumentID; if (!Convert.IsDBNull(roc["NewOutputDocumentID"])) { nX_NewOutputDocumentID = (int)roc["NewOutputDocumentID"]; } if (nOldOutputDocumentID != nX_OldOutputDocumentID || nNewOutputDocumentID != nX_NewOutputDocumentID || DateTime.Compare(dDateCarry, Convert.ToDateTime(roc["DateCarry"])) != 0) { continue; } nCarryID = (int)roc["ID"]; break; } if (!nCarryID.HasValue) { RFMMessage.MessageBoxError("Ошибка при получении данных о переносе/копии расходного документа..."); return; } if (StartForm(new frmOutputsDocumentsGuiltyEmployees((int)nCarryID, true)) == DialogResult.Yes) { grdOutputsDocuments_Restore(); } }
public Dictionary <string, object> Execute(OutputDocument document, Dictionary <string, object> namedPassThroughParameters) { Dictionary <string, object> results = new Dictionary <string, object>(); string labelText = null; byte[] labelData = null; string reportID = document.ReportID; string outputJobSequence = document.OutputJobSequence.ToString(); string documentType = document.MetaParameters[StdMetaParamNames.DocumentTypeIDKey].ToString(); string outputJobId = document.OutputJobId; string documentName = string.Format("{0}_{1}_{2}_{3}", outputJobId, outputJobSequence, documentType, reportID ); try { if (document.MetaParameters[StdMetaParamNames.DocumentIDKey] != "GenericReport") { XmlDocument doc = new XmlDocument(); document.Data.Seek(0, SeekOrigin.Begin); using (StreamReader reader = new StreamReader(document.Data)) { doc.Load(reader); } ParseLabel label = GetCachedLabel(document.ReportID); string errorVariables; lock (label) { labelText = label.Execute(doc, out errorVariables); } if (!string.IsNullOrEmpty(errorVariables)) { throw new Exception(string.Format("Error processing label, unable to merge label template with label data.\r\n{0}", errorVariables)); } labelData = Encoding.Default.GetBytes(labelText); } else { document.Data.Seek(0, SeekOrigin.Begin); using (XmlReader reader = XmlReader.Create(document.Data)) { reader.ReadToFollowing("Data"); using (MemoryStream data = new MemoryStream()) { int bytes = 0; byte[] buf = new byte[65536]; while ((bytes = reader.ReadElementContentAsBase64(buf, 0, 65536)) > 0) { data.Write(buf, 0, bytes); } if (data.Length == 0) { throw new Exception("The report has no content."); } data.Seek(0, SeekOrigin.Begin); labelData = data.ToArray(); } } } if (Convert.ToBoolean(_configurationParameters[_OUTPUTENABLE])) { PrintLabel(documentName, document.PrinterDeviceName, labelData); } } catch (Exception ex) { throw new Exception("Error printing Label .\r\n" + ex.Message); } return(results); }
private DocumentModel CreateDocumentModel(Dictionary <int, int> idsToQuantities) { Cursor = Cursors.WaitCursor; DocumentModel docModel = new DocumentModel(); docModel.IssueDate = DateTime.Now; //Saving OutputDocument OutputDocument outputDoc = new OutputDocument(); outputDoc.IssueDate = DateTime.Now.Date; using (var db = new PastryShopDbContext()) { using (var tr = db.Database.BeginTransaction()) { foreach (var item in idsToQuantities) { Dessert dessert = db.Desserts.Include("RecipeLines.ProductDetail").FirstOrDefault(d => d.Id == item.Key); DessertInfo dessertInfo = new DessertInfo(); dessertInfo.Name = dessert.Name; dessertInfo.Quantity = item.Value; //Saving OutputDocument OutputDocumentLine outputDocLine = new OutputDocumentLine(); outputDocLine.Quantity = item.Value; outputDocLine.Dessert = dessert; outputDocLine.OutputDocument = outputDoc; foreach (var recipeLine in dessert.RecipeLines) { var dateNow = DateTime.Now.Date; var productsInStore = db.Products .Where(p => p.ProductDetail.Id == recipeLine.ProductDetail.Id && p.AvailableQuantity > 0 && p.ExpiryDate >= dateNow ); int productsInStoreCount = productsInStore.Count(); double neededQuantity = item.Value * recipeLine.Quantity; var productInDbSum = productsInStore.Sum(p => (double?)(p.AvailableQuantity)) ?? 0; if (productsInStoreCount == 0 || productInDbSum < neededQuantity) { throw new Exception("Няма достатъчно количество " + recipeLine.ProductDetail.Name + " за " + dessert.Name); } while (neededQuantity > 0) { var product = productsInStore.FirstOrDefault(p => p.AvailableQuantity > 0 && p.ExpiryDate >= dateNow); // product can be null if at the time of execution // the query expiry date become < DateTime.Now.Date if (product == null) { throw new Exception("Няма достатъчно количество " + recipeLine.ProductDetail.Name + " за " + dessert.Name); } Ingredient ingredient = new Ingredient(); ingredient.Name = recipeLine.ProductDetail.Name; ingredient.Unit = recipeLine.ProductDetail.Unit; ingredient.BatchNumber = product.BatchNumber; //Saving OutputDocument OutputDocLineProduct outDocLine = new OutputDocLineProduct(); outDocLine.OutputDocLine = outputDocLine; outDocLine.Product = product; if (product.AvailableQuantity >= neededQuantity) { product.AvailableQuantity -= neededQuantity; ingredient.Quantity = neededQuantity; outDocLine.CalcualtedQuantity = neededQuantity; neededQuantity = 0; } else { neededQuantity -= product.AvailableQuantity; ingredient.Quantity = product.AvailableQuantity; product.AvailableQuantity = 0; } //Saving OutputDocument outDocLine.CalcualtedQuantity = ingredient.Quantity; outputDocLine.OutputDocLineProducts.Add(outDocLine); dessertInfo.Ingredients.Add(ingredient); db.SaveChanges(); } } outputDocLine.OutputDocument = outputDoc; outputDoc.Lines.Add(outputDocLine); docModel.Desserts.Add(dessertInfo); } db.OutputDocuments.Add(outputDoc); db.SaveChanges(); tr.Commit(); } } Cursor = Cursors.Default; return(docModel); }
public CreateOutputResultCollection Execute(CreateOutputParametersCollection parameters) { List <OutputDocument> documentsToExecute = new List <OutputDocument>(); List <OutputDocument> documentsNotExecuted = new List <OutputDocument>(); foreach (CreateOutputParameters parameter in parameters) { OutputDocument newDoc = new OutputDocument(); newDoc.OutputJobId = parameter.OutputJobIdentity; newDoc.OutputJobSequence = parameter.OutputJobSequenceNumber; XmlDocument doc = new XmlDocument(); doc.LoadXml(parameter.OutputXML); newDoc.MetaParameters = new Dictionary <string, string>(); newDoc.Parameters = new Dictionary <string, string>(); newDoc.Data = new MemoryStream(); StreamWriter writer = new StreamWriter(newDoc.Data); writer.Write(parameter.OutputXML); writer.Flush(); for (int i = 0; i < doc.ChildNodes.Count; i++) { if (doc.ChildNodes[i].NodeType == XmlNodeType.Element) { newDoc.MetaParameters.Add(StdMetaParamNames.DocumentIDKey, doc.ChildNodes[i].Name); foreach (XmlNode node in doc.ChildNodes[i].ChildNodes) { switch (node.Name) { case "MetaData": foreach (XmlAttribute attribute in node.Attributes) { newDoc.MetaParameters.Add(attribute.Name.ToUpper(), attribute.Value.Trim()); } break; case "Data": break; case "Parameters": foreach (XmlNode paramNode in node.ChildNodes) { if (paramNode.Name == "Parameter") { newDoc.Parameters.Add(paramNode.Attributes["name"].Value, paramNode.Attributes["value"].Value); } } break; } } } } //Get configuration string configErrorText; if (newDoc.MetaParameters.ContainsKey(StdMetaParamNames.DocumentTypeIDKey) && newDoc.MetaParameters.ContainsKey(StdMetaParamNames.SubDocumentTypeIDKey) && newDoc.MetaParameters.ContainsKey(StdMetaParamNames.TerminalIDKey) && newDoc.MetaParameters.ContainsKey(StdMetaParamNames.PrinterIDKey)) { string reportID; byte[] reportFile; string printerDeviceName; string printerID; List <string> adapterIDs; adapterIDs = _configDataHandler.GetAdapterID_PrinterDeviceName_PrinterID_ReportID_ReportFile(newDoc.MetaParameters[StdMetaParamNames.TerminalIDKey] , newDoc.MetaParameters[StdMetaParamNames.DocumentTypeIDKey] , newDoc.MetaParameters[StdMetaParamNames.SubDocumentTypeIDKey] , newDoc.MetaParameters[StdMetaParamNames.PrinterIDKey] , out printerID, out printerDeviceName, out reportID, out reportFile, out configErrorText); newDoc.AdapterIDs = adapterIDs; newDoc.PrinterID = printerID; newDoc.PrinterDeviceName = printerDeviceName; newDoc.ReportID = reportID; newDoc.ReportFile = reportFile; } else { configErrorText = "\r\n\r\nDocument Type, Sub Document Type, TerminalID or PrinterID are missing from the document meta data."; } if (string.IsNullOrEmpty(configErrorText)) { string nonExistingAdapters = string.Empty; bool allAdaptersExists = true; foreach (string adapterId in newDoc.AdapterIDs) { if (!_adapters.ContainsKey(adapterId)) { allAdaptersExists = false; nonExistingAdapters += " [" + adapterId + "] "; } } if (allAdaptersExists) { documentsToExecute.Add(newDoc); } else { newDoc.ErrorDescription = "Adapter(s):" + nonExistingAdapters + "do not exsist."; documentsNotExecuted.Add(newDoc); } } else { newDoc.ErrorDescription += configErrorText; documentsNotExecuted.Add(newDoc); } } Dictionary <string, int> numOfDocsPerPrinter = new Dictionary <string, int>(); List <string> usedAdapters = new List <string>(); foreach (OutputDocument doc in documentsToExecute) { //Collect the printers used. if (numOfDocsPerPrinter.ContainsKey(doc.PrinterDeviceName)) { numOfDocsPerPrinter[doc.PrinterDeviceName]++; } else { numOfDocsPerPrinter.Add(doc.PrinterDeviceName, 1); } //Get all adapters used in job foreach (string adapterId in doc.AdapterIDs) { if (!usedAdapters.Contains(adapterId)) { usedAdapters.Add(adapterId); } } } //Set sufficient adapter locks foreach (string adapterId in usedAdapters) { AcquireLock(adapterId, false, _adapterLockDictionary); } try { //Set sufficient printer locks foreach (string printerDeviceName in numOfDocsPerPrinter.Keys) { bool exclusive = (numOfDocsPerPrinter[printerDeviceName] > 1); AcquireLock(printerDeviceName, exclusive, _printerLockDictionary); } try { CreateOutputResultCollection resultCollection = new CreateOutputResultCollection(); //Process each document foreach (OutputDocument doc in documentsToExecute) { Dictionary <string, object> results = new Dictionary <string, object>(); try { //Adding overall results results.Add(StdResultParamNames.PrinterDeviceNameKey, doc.PrinterDeviceName); results.Add(StdResultParamNames.ReportIDKey, doc.ReportID); results.Add(StdResultParamNames.PrinterIDKey, doc.PrinterID); if (doc.MetaParameters.ContainsKey(StdMetaParamNames.UserIdentityKey)) { results.Add(StdResultParamNames.UserIDKey, doc.MetaParameters[StdMetaParamNames.UserIdentityKey]); } results.Add(StdResultParamNames.TerminalIDKey, doc.MetaParameters[StdMetaParamNames.TerminalIDKey]); if (doc.MetaParameters.ContainsKey(StdMetaParamNames.NumberOfCopiesKey)) { results.Add(StdResultParamNames.NumberOfCopiesKey, doc.MetaParameters[StdMetaParamNames.NumberOfCopiesKey]); } results.Add(StdResultParamNames.SubDocumentTypeIDKey, doc.MetaParameters[StdMetaParamNames.SubDocumentTypeIDKey]); results.Add(StdResultParamNames.DocumentTypeIDKey, doc.MetaParameters[StdMetaParamNames.DocumentTypeIDKey]); foreach (string adapterId in doc.AdapterIDs) { Dictionary <string, object> adapterResults = _adapters[adapterId].Execute(doc, results); if (results.Count == 0) { results = adapterResults; } else { foreach (string key in adapterResults.Keys) { if (results.ContainsKey(key)) { results[key] = adapterResults[key]; } else { results.Add(key, adapterResults[key]); } } } } doc.Data.Close(); } catch (Exception ex) { doc.ErrorDescription += "\r\nError while executing adapters.\r\n" + ex.Message; } CreateOutputResult documentResult = new CreateOutputResult(); documentResult.OutputJobIdentity = doc.OutputJobId; documentResult.OutputJobSequenceNumber = doc.OutputJobSequence; documentResult.ErrorDescription = doc.ErrorDescription; documentResult.ResultProperties = new List <CreateOutputResultProperty>(); foreach (KeyValuePair <string, object> result in results) { CreateOutputResultProperty resultProperty = new CreateOutputResultProperty(result.Key, result.Value); documentResult.ResultProperties.Add(resultProperty); } resultCollection.Add(documentResult); } //Return error for non processed documents foreach (OutputDocument doc in documentsNotExecuted) { CreateOutputResult documentResult = new CreateOutputResult(); documentResult.OutputJobIdentity = doc.OutputJobId; documentResult.OutputJobSequenceNumber = doc.OutputJobSequence; documentResult.ErrorDescription = doc.ErrorDescription; documentResult.ResultProperties = new List <CreateOutputResultProperty>(); //Adding overall results documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.PrinterIDKey, doc.PrinterID)); documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.PrinterDeviceNameKey, doc.PrinterDeviceName)); documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.ReportIDKey, doc.ReportID)); if (doc.MetaParameters.ContainsKey(StdMetaParamNames.UserIdentityKey)) { documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.UserIDKey, doc.MetaParameters[StdMetaParamNames.UserIdentityKey])); } if (doc.MetaParameters.ContainsKey(StdMetaParamNames.TerminalIDKey)) { documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.TerminalIDKey, doc.MetaParameters[StdMetaParamNames.TerminalIDKey])); } if (doc.MetaParameters.ContainsKey(StdMetaParamNames.NumberOfCopiesKey)) { documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.NumberOfCopiesKey, doc.MetaParameters[StdMetaParamNames.NumberOfCopiesKey])); } if (doc.MetaParameters.ContainsKey(StdMetaParamNames.SubDocumentTypeIDKey)) { documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.SubDocumentTypeIDKey, doc.MetaParameters[StdMetaParamNames.SubDocumentTypeIDKey])); } if (doc.MetaParameters.ContainsKey(StdMetaParamNames.DocumentTypeIDKey)) { documentResult.ResultProperties.Add(new CreateOutputResultProperty(StdResultParamNames.DocumentTypeIDKey, doc.MetaParameters[StdMetaParamNames.DocumentTypeIDKey])); } resultCollection.Add(documentResult); } return(resultCollection); } finally { //Release printer locks foreach (string printerDeviceName in numOfDocsPerPrinter.Keys) { bool exclusive = (numOfDocsPerPrinter[printerDeviceName] > 1); ReleaseLock(printerDeviceName, exclusive, _printerLockDictionary); } } } finally { foreach (string adapterId in usedAdapters) { ReleaseLock(adapterId, false, _adapterLockDictionary); } } }