Esempio n. 1
0
        public Document NewDocument(string title, string content, string[] member_ids = null, DocumentType type = DocumentType.document, DocumentFormat format = DocumentFormat.markdown)
        {
            var request = new RestRequest("threads/new-document", Method.POST);

            request.AddHeader("Authorization", string.Format("Bearer {0}", _token));

            if (content != null)
            {
                request.AddParameter("content", content);
            }

            request.AddParameter("type", type.ToString());
            request.AddParameter("format", format.ToString());

            if (title != null)
            {
                request.AddParameter("title", title);
            }

            if (member_ids != null)
            {
                request.AddParameter("member_ids", string.Join(",", member_ids));
            }

            var response = _client.Execute <Document>(request);

            CheckResponse(response);

            return(response.Data);
        }
        public IDictionary <string, string> GetJournalData()
        {
            var journalData = new Dictionary <string, string>
            {
                { DOCUMENTATION_KEY, DocumentFormat.ToString() },
                { FORMAT_JSON_KEY, FormatJson.ToString() },
                { URL_KEY, WebUrl },
                { API_KEY, ApiKey },
            };

            return(journalData);
        }
Esempio n. 3
0
        public Document EditDocument(string id, string content, string section_id, DocumentFormat format = DocumentFormat.markdown, DocumentLocation location = DocumentLocation.Append)
        {
            var request = new RestRequest("threads/edit-document", Method.POST);

            request.AddHeader("Authorization", string.Format("Bearer {0}", _token));
            request.AddParameter("thread_id", id);

            if (content != null)
            {
                request.AddParameter("content", content);
            }

            if (section_id != null)
            {
                request.AddParameter("section_id", section_id);
            }

            request.AddParameter("format", format.ToString());

            string[] locations =
            {
                "0: APPEND",
                "1: PREPEND",
                "2: AFTER_SECTION",
                "3: BEFORE_SECTION",
                "4: REPLACE_SECTION",
                "5: DELETE_SECTION"
            };

            request.AddParameter("location", locations[(int)location]);

            var response = _client.Execute <Document>(request);

            CheckResponse(response);

            return(response.Data);
        }
Esempio n. 4
0
 private static string Ext(this DocumentFormat documentFormat)
 {
     return(documentFormat.ToString().ToLower());
 }
Esempio n. 5
0
        private void SendToFaxGateway(string AFaxTelexInd, string AFaxTelexNumbers, string AConfirmLabel,
           byte[] AContractBody, DocumentFormat ADocFormat, string ARecipient, Int32 ATradeId, string ATradeSysTicket, Int32 ARqmtId, Int32 AConfirmId,
           bool ARtf, string AFromAddress, string ASubject, string AEmailBody, bool ACoverPage)
        {

            try
            {
                if (AFaxTelexNumbers != null)
                {
                    string[] AFaxTelexNumbersList = AFaxTelexNumbers.Split(';');

                    foreach (string AFaxTelexNumber in AFaxTelexNumbersList)
                    {
                        if (AContractBody == null)
                        {
                            XtraMessageBox.Show("Confirm Data was not found. Send/Resend was cancelled.",
                               "Confirm Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            return;
                        }

                        if (!InboundSettings.IsProductionSystem)
                        {
                            var destination = new TransmitDestination(AFaxTelexNumber);
                            if (!destination.IsValidNonProdSendToAddress())
                            {
                                XtraMessageBox.Show("Please enter a valid Non-Production EMail Address or Fax Number.", "Non-Production Address Verification",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }

                        this.Cursor = Cursors.WaitCursor;
                        string faxTelexNumber = AFaxTelexNumber;

                        //5/21/09 Israel -- Create a new folder for each fax transmission.
                        string folderName = ATradeId.ToString() + "_" + String.Format("{0:yyMMddHHmmss}", DateTime.Now);
                        //string faxDir = tempFaxDir + folderName;
                        string faxDir = Path.Combine(tempFaxDir, folderName);
                        System.IO.Directory.CreateDirectory(faxDir);
                        faxDir += "\\";

                        string xmlFileNameOnly = "request.xml";
                        string xmlFileNameWithPath = faxDir + xmlFileNameOnly;
                        string rtfFileNameOnly = "Contract.rtf";
                        string rtfFileNameWithPath = faxDir + rtfFileNameOnly;
                        string pdfDocFileNameOnly = "Contract.pdf";
                        string pdfDocFileNameWithPath = faxDir + pdfDocFileNameOnly;

                        //Israel 9/3/2015 -- Replace PDFMetamorphosis with DevExpress RichEditControl
                        //SaveRtfAsPdfDoc(rtfFileNameWithPath, pdfDocFileNameWithPath);
                        WSUtils.SaveByteArrayAsPdfFile(AContractBody, ADocFormat, pdfDocFileNameWithPath);

                        //1/28/2015 Israel - Replaced DB name with system setting
                        //if (barStaticDBName.Caption.ToLower() != PROD_DB_NAME)

                        //Israel 10/26/15 Removed TestFaxNumber
                        //if (!Properties.Settings.Default.IsProductionSystem)
                        //    faxTelexNumber = Properties.Settings.Default.TestFaxNumber;

                        //PDF isn't handling E. European languages properly so send them as rtf.
                        string docFileName = pdfDocFileNameOnly;
                        string bookingCoSn = GetTradeSummaryData(ATradeId, "BookingCoSn");
                        string cdtyCode = GetTradeSummaryData(ATradeId, "CdtyCode");
                        //       bool isFreightDeal = (cdtyCode == "FRGHT");

                        string cptySn = GetTradeSummaryData(ATradeId, "CptySn");

                        //5/20/09 Israel - Handle RTF override parm
                        if (ARtf)
                            docFileName = rtfFileNameOnly;

                        string docFileNameWithPath = faxDir + docFileName;

                        TransmitDestinationType transDestType;
                        if (AFaxTelexNumber.Contains("@"))
                            transDestType = TransmitDestinationType.EMAIL;
                        else
                            transDestType = TransmitDestinationType.FAX;


                        IXmitRequestDal xmitRequestDal = new XmitRequestDal(sqlConnectionStr);
                        int xmitRequestId = xmitRequestDal.SaveTradeRqmtConfirmXmitRequest(AConfirmId, transDestType, AFaxTelexNumber, Utils.GetUserNameWithoutDomain(p_UserId));

                        string xmlText = GetFaxSubmitXML(ATradeId.ToString(),ATradeSysTicket, docFileName, AFaxTelexInd,
                           AFaxTelexNumber, ARecipient, ARqmtId.ToString(), AConfirmId.ToString(), AConfirmLabel,
                           ASubject, AEmailBody, ACoverPage, xmitRequestId.ToString());

                        System.IO.File.WriteAllText(xmlFileNameWithPath, xmlText);

                        string emailToAddress = Properties.Settings.Default.TransmissionGatewayEmailToAddress;
                        //string emailToAddress = "*****@*****.**";
                        //Israel 9/28/2015
                        //string emailFromAddress = toolbarOrWindowsUserId + "@" + Properties.Settings.Default.EMailDomain;

                        //Israel 10/26/15 -- Removed FaxGatewayEmailFromAddress
                        string emailFromAddress = ""; //Properties.Settings.Default.FaxGatewayEmailFromAddress;
                        if (AFromAddress.Length > 2)
                            emailFromAddress = AFromAddress;
                        else
                            emailFromAddress = emailToAddress;
                        string emailSubject = "Confirmation of Trade: " + ATradeSysTicket;
                        if (ASubject.Length > 2)
                            emailSubject = ASubject;

                        //Changed variable name for doc file.
                        SendEmail(emailFromAddress, emailToAddress, emailSubject, AEmailBody, xmlFileNameWithPath, docFileNameWithPath);

                        string faxDocRefCode = "";
                        string templateName = "**Template Name**";

                        //Log submission in case it becomes necessary to trace it
                        //Israel 11/13/2015 -- Removed as part of move to XmitRequest/XmitResult
                        //CallInsertToFaxLogSent(ATradeId, AFaxTelexInd, AFaxTelexNumber, faxDocRefCode);

                        if (AConfirmLabel == CONFIRM_LABEL_CONFIRM && ARqmtId > 0)
                        {
                            string reference = GetTradeRqmtData(ARqmtId, "Reference");
                            string cmt = GetTradeRqmtData(ARqmtId, "Cmt");
                            CallUpdateTradeRqmts(ATradeId, ARqmtId, SEMPRA_RQMT, "SENT", DateTime.Today, reference, cmt, true);
                        }
                        else if (AConfirmId > 0)
                        {
                            string confirmCmt = GetConfirmData(AConfirmId, "ConfirmCmt");
                            UpdateTradeRqmtConfirmRow(AConfirmId, ATradeId, Convert.ToInt32(ARqmtId),
                               templateName, AFaxTelexInd, AFaxTelexNumber, AConfirmLabel, confirmCmt, "SENT", "Y");
                        }

                        string trdSysCode = GetTradeSummaryData(ATradeId, "TrdSysCode");
                        if (trdSysCode.Length > 0)
                        {
                            trdSysCode = trdSysCode.Substring(0, 1);
                            //string cdtyGrpCode = GetTradeSummaryData(ATradeId, "CdtyGrpCode");
                            string sttlType = GetTradeSummaryData(ATradeId, "SttlType");

                            DateTime dtTradeDt = GetTradeSummaryDate(ATradeId, "TradeDt");
                            string strTradeDt = dtTradeDt.ToString("MM/dd/yyyy");
                            string strToday = DateTime.Today.ToString("MM/dd/yyyy");
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                throw new Exception("An error occurred while attempting to send a document to the Transmission Gateway using the following values:" + Environment.NewLine +
                    "Transmission Method: " + AFaxTelexInd + ", Transmission Send-To Address: " + AFaxTelexNumbers + ", Document Format: " + ADocFormat.ToString() +
                        ", Recipient: " + ARecipient + Environment.NewLine +
                    "Trade Id: " + ATradeId.ToString() + "Rqmt Id: " + ARqmtId.ToString() + "Confirm Id: " + AConfirmId.ToString() + ", IsRtf?: " + ARtf + Environment.NewLine +
                    "From Address: " + AFromAddress + ", Subject: " + ASubject + ", EMail Body: " + AEmailBody + ", IncludeCoverPage?: " + ACoverPage + Environment.NewLine +
                     "Error CNF-145 in " + FORM_NAME + ".SendToFaxGateway([14 parms]): " + ex.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        public void UpdateDocumentWriterOptions()
        {
            // Save the options
            DocumentFormat format = this.SelectedDocumentFormat;

            Properties.Settings settings = new Properties.Settings();
            settings.Format = format.ToString();

            // Update the options
            DocumentOptions documentOptions = _docWriter.GetOptions(format);

            switch (format)
            {
            case DocumentFormat.Pdf:
                // Update the PDF options
            {
                PdfDocumentOptions pdfOptions = documentOptions as PdfDocumentOptions;

                pdfOptions.DocumentType    = (PdfDocumentType)_pdfDocumentTypeComboBox.SelectedItem;
                pdfOptions.ImageOverText   = _pdfImageOverTextCheckBox.Checked;
                pdfOptions.Linearized      = _pdfLinearizedCheckBox.Checked;
                pdfOptions.PageRestriction = DocumentPageRestriction.Relaxed;

                // Description options
                pdfOptions.Title    = _pdfOptions.Title;
                pdfOptions.Subject  = _pdfOptions.Subject;
                pdfOptions.Keywords = _pdfOptions.Keywords;
                pdfOptions.Author   = _pdfOptions.Author;
                pdfOptions.Creator  = _pdfOptions.Creator;
                pdfOptions.Producer = _pdfOptions.Producer;

                // Fonts options
                pdfOptions.FontEmbedMode = _pdfOptions.FontEmbedMode;
                pdfOptions.Linearized    = _pdfOptions.Linearized;

                // Security options
                pdfOptions.Protected = _pdfOptions.Protected;
                if (pdfOptions.Protected)
                {
                    pdfOptions.UserPassword            = _pdfOptions.UserPassword;
                    pdfOptions.OwnerPassword           = _pdfOptions.OwnerPassword;
                    pdfOptions.EncryptionMode          = _pdfOptions.EncryptionMode;
                    pdfOptions.PrintEnabled            = _pdfOptions.PrintEnabled;
                    pdfOptions.HighQualityPrintEnabled = _pdfOptions.HighQualityPrintEnabled;
                    pdfOptions.CopyEnabled             = _pdfOptions.CopyEnabled;
                    pdfOptions.EditEnabled             = _pdfOptions.EditEnabled;
                    pdfOptions.AnnotationsEnabled      = _pdfOptions.AnnotationsEnabled;
                    pdfOptions.AssemblyEnabled         = _pdfOptions.AssemblyEnabled;
                }

                // Compression options
                pdfOptions.OneBitImageCompression  = _pdfOptions.OneBitImageCompression;
                pdfOptions.ColoredImageCompression = _pdfOptions.ColoredImageCompression;
                pdfOptions.QualityFactor           = _pdfOptions.QualityFactor;
                pdfOptions.ImageOverTextSize       = _pdfOptions.ImageOverTextSize;
                pdfOptions.ImageOverTextMode       = _pdfOptions.ImageOverTextMode;

                // Initial View Options
                pdfOptions.PageModeType      = _pdfOptions.PageModeType;
                pdfOptions.PageLayoutType    = _pdfOptions.PageLayoutType;
                pdfOptions.PageFitType       = _pdfOptions.PageFitType;
                pdfOptions.ZoomPercent       = _pdfOptions.ZoomPercent;
                pdfOptions.InitialPageNumber = _pdfOptions.InitialPageNumber;
                pdfOptions.FitWindow         = _pdfOptions.FitWindow;
                pdfOptions.CenterWindow      = _pdfOptions.CenterWindow;
                pdfOptions.DisplayDocTitle   = _pdfOptions.DisplayDocTitle;
                pdfOptions.HideMenubar       = _pdfOptions.HideMenubar;
                pdfOptions.HideToolbar       = _pdfOptions.HideToolbar;
                pdfOptions.HideWindowUI      = _pdfOptions.HideWindowUI;
            }
            break;

            case DocumentFormat.Doc:
                // Update the DOC options
            {
                DocDocumentOptions docOptions = documentOptions as DocDocumentOptions;
                docOptions.TextMode = (_cbFramedDoc.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed;
            }
            break;

            case DocumentFormat.Docx:
                // Update the DOCX options
            {
                DocxDocumentOptions docxOptions = documentOptions as DocxDocumentOptions;
                docxOptions.TextMode = (_cbFramedDocX.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed;
            }
            break;

            case DocumentFormat.Rtf:
                // Update the RTF options
            {
                RtfDocumentOptions rtfOptions = documentOptions as RtfDocumentOptions;
                rtfOptions.TextMode = (_cbFramedRtf.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed;
            }
            break;

            case DocumentFormat.Html:
                // Update the HTML options
            {
                HtmlDocumentOptions htmlOptions = documentOptions as HtmlDocumentOptions;
                htmlOptions.FontEmbedMode      = (DocumentFontEmbedMode)_htmlEmbedFontModeComboBox.SelectedItem;
                htmlOptions.UseBackgroundColor = _htmlUseBackgroundColorCheckBox.Checked;
                htmlOptions.BackgroundColor    = ConvertColor(_htmlBackgroundColorValueLabel.BackColor);
            }
            break;

            case DocumentFormat.Text:
                // Update the TEXT options
            {
                TextDocumentOptions textOptions = documentOptions as TextDocumentOptions;
                textOptions.DocumentType  = (TextDocumentType)_textDocumentTypeComboBox.SelectedItem;
                textOptions.AddPageNumber = _textAddPageNumberCheckBox.Checked;
                textOptions.AddPageBreak  = _textAddPageBreakCheckBox.Checked;
                textOptions.Formatted     = _textFormattedCheckBox.Checked;
            }
            break;

            case DocumentFormat.AltoXml:
                // Update the DOCX options
            {
                AltoXmlDocumentOptions altoXmlOptions = documentOptions as AltoXmlDocumentOptions;
                altoXmlOptions.FileName               = _altoXmlFileNameTextBox.Text;
                altoXmlOptions.SoftwareCreator        = _altoXmlSoftwareCreatorTextBox.Text;
                altoXmlOptions.SoftwareName           = _altoXmlSoftwareNameTextBox.Text;
                altoXmlOptions.ApplicationDescription = _altoXmlApplicationDescriptionTextBox.Text;
                altoXmlOptions.Formatted              = _altoXmlFormattedCheckBox.Checked;
                altoXmlOptions.Indentation            = _altoXmlIndentationTextBox.Text;
                altoXmlOptions.Sort              = _altoXmlSort.Checked;
                altoXmlOptions.PlainText         = _altoXmlPlainText.Checked;
                altoXmlOptions.ShowGlyphInfo     = _altoXmlShowGlyphInfo.Checked;
                altoXmlOptions.ShowGlyphVariants = _altoXmlShowGlyphVariants.Checked;
                altoXmlOptions.MeasurementUnit   = (AltoXmlMeasurementUnit)_altoXmlMeasurementUnit.SelectedItem;
            }
            break;

            case DocumentFormat.Emf:
            case DocumentFormat.Xls:
            case DocumentFormat.Pub:
            case DocumentFormat.Mob:
            case DocumentFormat.Svg:
            default:
                // These formats have no options
                break;
            }

            if (documentOptions != null)
            {
                _docWriter.SetOptions(format, documentOptions);
            }

            using (MemoryStream ms = new MemoryStream())
            {
                _docWriter.SaveOptions(ms);
                settings.FormatOptionsXml = Encoding.Unicode.GetString(ms.ToArray());
            }

            settings.Save();
        }