private void ExecPrintFromEditRichContract(int pConfirmId) { TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr); TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto(); //Int64 confirmIdLong = Convert.ToInt64(pConfirmId); trcBlobData = trcBlobDal.Get(pConfirmId); DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt); if (trcBlobData.DocBlob.Length > 0) { //byte[] docBytes = System.Text.Encoding.UTF8.GetBytes(AContractBody); using (MemoryStream contractStream = new MemoryStream(trcBlobData.DocBlob)) { editContractForm.richeditConfirm.LoadDocument(contractStream, docFormat); } } editContractForm.printItem1.PerformClick(); }
private void SendContractForCurrentRqmt(Int32 ATradeId) { try { string cptySn = ""; string tradeSysTicket = ""; string filterStr = "TradeId = " + ATradeId.ToString(); foreach (DataRow summaryRow in summaryDataTable.Select(filterStr)) { cptySn = summaryRow["CptySn"].ToString(); tradeSysTicket = summaryRow["TradeSysTicket"].ToString(); } string ticketNo = ATradeId.ToString(); string transMethodInd = ""; string faxTelexNumber = ""; string activeFlag = ""; Int32 rqmtId = 0; Int32 confirmId = 0; //Int32 templateId = 0; string confirmLabel = ""; string filterStr2 = "TradeId = " + ticketNo; foreach (DataRow row in confirmDataTable.Select(filterStr2)) { confirmLabel = row["ConfirmLabel"].ToString(); //Israel 11/19/2015 -- Added active flag test to prevent GUI-driven errors activeFlag = row["ActiveFlag"].ToString(); if (confirmLabel == CONFIRM_LABEL_CONFIRM && activeFlag == "Y") { confirmId = Int32.Parse(row["Id"].ToString()); rqmtId = Int32.Parse(row["RqmtId"].ToString()); //templateId = Int32.Parse(row["TemplateId"].ToString()); transMethodInd = row["FaxTelexInd"].ToString(); faxTelexNumber = row["FaxTelexNumber"].ToString(); break; } } //string contractBody = GetContractFromVault(confirmId, 0); TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr); TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto(); //Int64 confirmIdLong = Convert.ToInt64(confirmId); trcBlobData = trcBlobDal.Get(confirmId); DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt); using (var ts = new TransactionScope()) { Vaulter vaulter = new Vaulter(sqlConnectionStr); vaulter.VaultTradeRqmtConfirm(confirmId, null); if (transMethodInd.Length > 0 && faxTelexNumber.Length > 2) SendToFaxGateway(transMethodInd, faxTelexNumber, CONFIRM_LABEL_CONFIRM, trcBlobData.DocBlob, docFormat, cptySn, ATradeId,tradeSysTicket, rqmtId, confirmId, false, "", "", "", false); ts.Complete(); } } catch (Exception ex) { throw new Exception("An error occurred while preparing a Confirm to send to the fax gateway for the following Trade Id:" + ATradeId + Environment.NewLine + "Error CNF-149 in " + FORM_NAME + ".SendContractForCurrentRqmt(): " + ex.Message); } }
private void DisplayContract(int ATradeRqmtConfirmId, bool AEMailEnabled) { try { //Israel 9/21/2015 //rtfContract.Rtf = AContractBody; //rtfContract.SelectAll(); //rtfContract.SelectionProtected = true; //rtfContract.Select(5, 0); TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr); TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto(); //Int64 confirmIdLong = Convert.ToInt64(ATradeRqmtConfirmId); trcBlobData = trcBlobDal.Get(ATradeRqmtConfirmId); DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt); if (trcBlobData.DocBlob.Length > 0) { using (MemoryStream contractStream = new MemoryStream(trcBlobData.DocBlob)) { richeditConfirmBrowser.LoadDocument(contractStream, docFormat); } } tabctrlBrowserApps.SelectedTabPage = tabpgContract; //barDockControl3.Visible = false; //barBrowserStatusBar.Visible = false; btnEmail.Enabled = AEMailEnabled; } catch (Exception ex) { throw new Exception("An error occurred while attempting to display a Confirm using the following values:" + Environment.NewLine + "Confirm Id: " + ATradeRqmtConfirmId.ToString() + ", EMail Option enabled?: " + AEMailEnabled + Environment.NewLine + "Error CNF-143 in " + FORM_NAME + ".DisplayContract(): " + ex.Message); } }
private void SendToFaxGateway(Int32 AConfirmId, string ACptySn, bool ARtf, string ATitle, string AMessage, bool ACoverPage) { try { this.Cursor = Cursors.WaitCursor; string faxTelexInd = ""; string faxTelexNumber = ""; string confirmLabel = ""; Int32 tradeId = 0; string tradeSysTicket = ""; Int32 rqmtId = 0; //Int32 templateId = 0; string cptySn = ""; string filterStr = "Id = " + AConfirmId.ToString(); foreach (DataRow row in confirmDataTable.Select(filterStr)) { faxTelexInd = row["FaxTelexInd"].ToString(); faxTelexNumber = row["FaxTelexNumber"].ToString(); confirmLabel = row["ConfirmLabel"].ToString(); tradeId = Int32.Parse(row["TradeId"].ToString()); tradeSysTicket = GetTradeSummaryData(tradeId, "TradeSysTicket"); //row["TradeSysTicket"].ToString(); rqmtId = Int32.Parse(row["RqmtId"].ToString()); //templateId = Int32.Parse(row["TemplateId"].ToString()); } //contractBody = GetContractFromVault(AConfirmId, 0); TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr); TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto(); //Int64 confirmIdLong = Convert.ToInt64(AConfirmId); trcBlobData = trcBlobDal.Get(AConfirmId); DocumentFormat docFormat = Utils.GetDocumentFormat(trcBlobData.ImageFileExt); string title = ""; string message = ""; if (ACoverPage) { title = ATitle; message = AMessage; } SendToFaxGateway(faxTelexInd, faxTelexNumber, confirmLabel, trcBlobData.DocBlob, docFormat, ACptySn, tradeId, tradeSysTicket, rqmtId, Convert.ToInt32(AConfirmId), ARtf, "", title, message, ACoverPage); } catch (Exception ex) { throw new Exception("An error occurred while attempting to prepare then request SendToFaxGateway([14 parms]) using the following values:" + Environment.NewLine + "Confirm Id: " + AConfirmId.ToString() + ", Counterparty Short Name: " + ACptySn + ", IsRtf?: " + ARtf + Environment.NewLine + "Title: " + ATitle + ", Message: " + AMessage + ", IncludeCoverPage?: " + ACoverPage + Environment.NewLine + "Error CNF-144 in " + FORM_NAME + ".SendToFaxGateway([6 parms]): " + ex.Message); } finally { this.Cursor = Cursors.Default; } }
private void GetAutoContract(GridView AGridView) { try { this.Cursor = Cursors.WaitCursor; CGMethod cgMethod = CGMethod.GetContract; string tradingSystem = ""; string trdSysTicket = ""; string tradeIdStr = ""; string rqmtId = ""; string contractType = "NEW"; //string contractBody = ""; byte[] contractBody = null; string templateName = ""; string preparerCanSendFlag = ""; string savedTransMethod = "FAX"; string savedTransInd = "F"; string savedFaxNumber = ""; string cmt = ""; string nextStatusCode = ""; string statusCode = ""; string activeFlag = "Y"; //Int32 templateId = 0; Int32 rqmtConfirmId = 0; Int32 tradeId = 0; int summaryRowHandle = GetGridViewFocusedRowHandle(gridViewSummary); tradingSystem = gridViewSummary.GetRowCellDisplayText(summaryRowHandle, "TrdSysCode").ToString(); trdSysTicket = gridViewSummary.GetRowCellDisplayText(summaryRowHandle, "TradeSysTicket").ToString(); tradeIdStr = gridViewSummary.GetRowCellDisplayText(summaryRowHandle, "TradeId").ToString(); tradeId = Int32.Parse(tradeIdStr); //int tradeIdInt = int.Parse(ticketNo); //If adding a new confirm row, this will get the correct status. If the focus is on the confirm //row and the wrong rqmt row is focused, this bogus status will get replaced by the correct one below. statusCode = gridViewRqmt.GetRowCellDisplayText(gridViewRqmt.FocusedRowHandle, "Status").ToString(); //If only one row they could be accessing it from the rqmt gid //If more then one access is only from the confirm grid so we know the focus. int rowHandle = 0; rowHandle = AGridView.FocusedRowHandle; //if (gridViewConfirm.RowCount == 1) // rowHandle = gridViewConfirm.GetVisibleRowHandle(0); //else // rowHandle = gridViewConfirm.FocusedRowHandle; //if (AGridView.Name == gridViewRqmt.Name) if (gridViewConfirm.RowCount > 0) { rqmtId = gridViewRqmt.GetRowCellDisplayText(rowHandle, "Id").ToString(); rqmtConfirmId = GetContractRowId(tradeId); savedTransInd = GetContractConfirmData(tradeId, "FaxTelexInd"); savedFaxNumber = GetContractConfirmData(tradeId, "FaxTelexNumber"); savedTransMethod = GetFaxMethodFromInd(savedTransInd); templateName = GetContractConfirmData(tradeId, "TemplateName"); preparerCanSendFlag = GetContractConfirmData(tradeId, "PreparerCanSendFlag"); //templateId = GetContractTemplateId(tradeId); cmt = GetContractConfirmData(tradeId, "ConfirmCmt"); nextStatusCode = GetContractConfirmData(tradeId, "NextStatusCode"); statusCode = gridViewRqmt.GetRowCellDisplayText(rowHandle, "Status").ToString(); } else if (gridViewConfirm.RowCount > 0) { rqmtId = gridViewConfirm.GetRowCellDisplayText(rowHandle, "RqmtId").ToString(); rqmtConfirmId = Int32.Parse(gridViewConfirm.GetRowCellDisplayText(rowHandle, "Id").ToString()); savedTransInd = gridViewConfirm.GetRowCellDisplayText(rowHandle, "FaxTelexInd").ToString(); savedFaxNumber = gridViewConfirm.GetRowCellDisplayText(rowHandle, "FaxTelexNumber").ToString(); savedTransMethod = GetFaxMethodFromInd(savedTransInd); templateName = gridViewConfirm.GetRowCellDisplayText(rowHandle, "TemplateName").ToString(); preparerCanSendFlag = GetContractConfirmData(tradeId, "PreparerCanSendFlag"); //templateId = Int32.Parse(gridViewConfirm.GetRowCellDisplayText(rowHandle, "TemplateId").ToString()); cmt = gridViewConfirm.GetRowCellDisplayText(rowHandle, "ConfirmCmt").ToString(); nextStatusCode = gridViewConfirm.GetRowCellValue(rowHandle, "NextStatusCode").ToString(); int iRqmtId = int.Parse(rqmtId); statusCode = GetTradeRqmtData(iRqmtId, "Status"); } bool okToCallEditor = false; //bool contractExists = rqmtConfirmId > 0; string getDocumentUrl = Properties.Settings.Default.ExtSvcAPIBaseUrl; string svcUserName = Properties.Settings.Default.ExtSvcAPIUserName; string svcPassword = Properties.Settings.Default.ExtSvcAPIPassword; ConfirmDocsAPIDal confirmDocsDal = ConfirmDocsAPIDal.Instance(getDocumentUrl, svcUserName, svcPassword); string docFileExt = ""; DocumentFormat docFormat = DocumentFormat.Undefined; if (statusCode == "NEW") { try { //Israel 12/09/2015 -- Provide cancel when no template given. bool okToCallServer = true; if (String.IsNullOrEmpty(templateName)) { DialogResult result = XtraMessageBox.Show("No template has been supplied for this trade. Continue with the request?" + Environment.NewLine + "(If you choose 'No' you can retry by selecting a Manual Contract instead.)", "Missing Template", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.No) okToCallServer = false; } if (okToCallServer) { contractBody = confirmDocsDal.GetConfirm(tradingSystem, trdSysTicket, templateName, out docFileExt); okToCallEditor = true; if (contractBody == null || contractBody.Length < 2) { if (editContractForm.richeditConfirm.Document.Length > 0) { DocumentRange docRange = editContractForm.richeditConfirm.Document.CreateRange(0, editContractForm.richeditConfirm.Document.Length); editContractForm.richeditConfirm.Document.Delete(docRange); } MessageBox.Show("The Confirmation Web Service call returned a blank document.", "Empty Confirm", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception ex) { okToCallEditor = false; //string message = "An error occurred while requesting a Confirm from the GetConfirmations Web Service." + Environment.NewLine + // "Error CNF-282 in GetAutoContract: " + ex.Message; //string caption = MAIN_FORM_ERROR_CAPTION; //MessageBoxIcon icon = MessageBoxIcon.Error; //if (ex.Message.IndexOf("Confirm Web Service(s) not available") > -1) //{ // message = "A Confirm Web Service is not available. Please contact ConfirmSupport." + Environment.NewLine; // message += "When it is available just try again-- no need to restart " + APP_NAME + "."; // caption = "Confirm Web Service Unavailable"; // icon = MessageBoxIcon.Exclamation; //} //XtraMessageBox.Show(message, caption, MessageBoxButtons.OK, icon); XtraMessageBox.Show("An error occurred while requesting a Confirm from the GetConfirmations Web Service." + Environment.NewLine + "Error CNF-282 in " + FORM_NAME + ".GetAutoContract(): " + ex.Message, MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //if (contractExists) { //Retrieve contract body from vault. //contractBody = GetContractFromVault(rqmtConfirmId, 0); TradeRqmtConfirmBlobDto trcBlobData = new TradeRqmtConfirmBlobDto(); TradeRqmtConfirmBlobDal trcBlobDal = new TradeRqmtConfirmBlobDal(sqlConnectionStr); trcBlobData = trcBlobDal.Get(rqmtConfirmId); contractBody = trcBlobData.DocBlob; docFileExt = trcBlobData.ImageFileExt; //Israel 11/20/2015 -- Broken rows caused an error when bringing up the screen. if (contractBody != null) okToCallEditor = true; } //else // XtraMessageBox.Show("Contract doesn't exist. Status must be NEW to add new contract"); if (nextStatusCode == "") nextStatusCode = "PREP"; //Israel 11/20/2015 -- Broken rows caused an error when calling GetDocumentFormat. //docFormat = Utils.GetDocumentFormat(docFileExt); //docFormat = DocumentFormat.OpenXml; if (okToCallEditor) { docFormat = Utils.GetDocumentFormat(docFileExt); CallEditContractForm(contractBody, docFormat, templateName, savedTransMethod, savedFaxNumber, rqmtConfirmId, cmt, nextStatusCode, activeFlag,preparerCanSendFlag); } } catch (Exception ex) { XtraMessageBox.Show("An error occurred while requesting a Confirm from the GetConfirmations Web Service." + Environment.NewLine + "Error CNF-123 in " + FORM_NAME + ".GetAutoContract(): " + ex.Message, MAIN_FORM_ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }