public static ObservableCollection <CrmPluginTrace> CreateCrmPluginTraceView(EntityCollection pluginTraces)
        {
            ObservableCollection <CrmPluginTrace> crmPluginTraces = new ObservableCollection <CrmPluginTrace>();

            if (pluginTraces == null)
            {
                return(crmPluginTraces);
            }

            foreach (Entity pluginTrace in pluginTraces.Entities)
            {
                CrmPluginTrace crmPluginTrace = new CrmPluginTrace
                {
                    PluginTraceLogidId = pluginTrace.Id,
                    Entity             = pluginTrace.GetAttributeValue <string>("primaryentity"),
                    CorrelationId      = pluginTrace.GetAttributeValue <Guid>("correlationid").ToString(),
                    CreatedOn          = pluginTrace.GetAttributeValue <DateTime>("createdon").ToLocalTime(),
                    CreatedOnUtc       = pluginTrace.GetAttributeValue <DateTime>("createdon"),
                    Depth = pluginTrace.GetAttributeValue <int>("depth"),
                    ExecutionDurationMs = pluginTrace.GetAttributeValue <int>("performanceexecutionduration"),
                    ExecutionDuration   = DateFormatting.MsToReadableTime(pluginTrace.GetAttributeValue <int>("performanceexecutionduration")),
                    MessageName         = pluginTrace.GetAttributeValue <string>("messagename"),
                    MessageBlock        = pluginTrace.GetAttributeValue <string>("messageblock"),
                    TypeName            = pluginTrace.GetAttributeValue <string>("typename"),
                    Mode             = (pluginTrace.GetAttributeValue <OptionSetValue>("mode").Value == 0) ? "Synchronous" : "Asynchronous",
                    ExceptionDetails = pluginTrace.GetAttributeValue <string>("exceptiondetails"),
                    Details          = CreateDetails(pluginTrace.GetAttributeValue <string>("messageblock"), pluginTrace.GetAttributeValue <string>("exceptiondetails"))
                };

                crmPluginTraces.Add(crmPluginTrace);
            }

            return(crmPluginTraces);
        }
Esempio n. 2
0
        public void DatePrinting_FirstDayLowerThanSecond_CorrectReturn()
        {
            DateTime           dateTime1 = new DateTime(2020, 09, 10);
            DateTime           dateTime2 = new DateTime(2020, 09, 11);
            DateTimeFormatInfo currentCultureDatetimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
            string             expectedResult = dateTime1.ToString("dd", currentCultureDatetimeFormat) + "-" + dateTime2.ToString(currentCultureDatetimeFormat.ShortDatePattern);
            DateFormatting     datePrinter    = new DateFormatting();

            string result = datePrinter.DateToString(dateTime1, dateTime2);


            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 3
0
        public void DatePrinting_SameDate_CorrectReturn()
        {
            DateTime           dateTime1 = new DateTime(2020, 12, 10);
            DateTime           dateTime2 = new DateTime(2020, 12, 10);
            DateTimeFormatInfo currentCultureDatetimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
            string             expectedResult = dateTime1.ToString(currentCultureDatetimeFormat.ShortDatePattern);
            DateFormatting     datePrinter    = new DateFormatting();

            string result = datePrinter.DateToString(dateTime1, dateTime2);


            Assert.AreEqual(expectedResult, result);
        }
Esempio n. 4
0
        public void CanReconstructTheFileName(FilenameParsingFixtureModel test)
        {
            this.parser = this.FilenameParser;
            var parsed = this.parser.Parse(test.Filename);

            var actual = parsed.Reconstruct(this.TestFiles);

            var expectedDate = (test.ExpectedTzOffset, test.ExpectedDateTime) switch
            {
                (null, not null) => DateFormatting.FormatFileName(test.ExpectedDateTime.Value),
                (not null, not null) => DateFormatting.FormatFileName(
                    test.ExpectedDateTime.Value.WithOffset(test.ExpectedTzOffset.Value)),
                (null, null) => string.Empty,
            };
Esempio n. 5
0
        protected void PrepareViewMessage()
        {
            if (openMode != "view")
            {
                return;
            }

            BaseWebMailActions bwml   = new BaseWebMailActions(acct, Page);
            byte safety               = 0;
            bool showPicturesSettings = ((acct.UserOfAccount.Settings.ViewMode & ViewMode.AlwaysShowPictures) > 0) ? true : false;

            if (showPicturesSettings)
            {
                safety = 1;
            }
            WebMailMessage msg       = bwml.GetMessage(msgId, msgUid, folderId, charset, safety, true, false, false, MessageMode.None);
            MailMessage    outputMsg = msg.MailBeeMessage;

            jsClearMessageSubject = Utils.EncodeJsSaveString(outputMsg.Subject) + " - ";

            jsMessageInit  = "ViewMessage = new CMessage();\n";
            jsMessageInit += "ViewMessage.FolderId = " + msg.IDFolderDB.ToString() + ";\n";
            jsMessageInit += "ViewMessage.FolderFullName = '" + msg.FolderFullName + "';\n";
            jsMessageInit += "ViewMessage.Size = " + msg.Size.ToString() + ";\n";
            jsMessageInit += "ViewMessage.Id = " + msg.IDMsg.ToString() + ";\n";
            jsMessageInit += "ViewMessage.Uid = '" + (string.IsNullOrEmpty(msg.StrUid)
                                ? msg.IntUid.ToString() : msg.StrUid) + "';\n";
            jsMessageInit += "ViewMessage.HasHtml = " + (string.IsNullOrEmpty(outputMsg.BodyHtmlText)
                                ? "false" : "true") + ";\n";
            jsMessageInit += "ViewMessage.HasPlain = " + (string.IsNullOrEmpty(outputMsg.BodyPlainText)
                                ? "false" : "true") + ";\n";
            jsMessageInit += "ViewMessage.Importance = " + Utils.ToStringPriority(msg.Priority) + ";\n";
            jsMessageInit += "ViewMessage.Sensivity = " + Utils.ToStringSensitivity(msg.Sensitivity) + ";\n";
            jsMessageInit += "ViewMessage.Charset = " + msg.OverrideCharset.ToString(CultureInfo.InvariantCulture) + ";\n";
            jsMessageInit += "ViewMessage.HasCharset = " + (string.IsNullOrEmpty(outputMsg.Charset)
                                ? "false" : "true") + ";\n";
            string strCharset = !string.IsNullOrEmpty(outputMsg.Charset)
                                ? outputMsg.Charset
                                : Utils.GetCodePageName(msg.OverrideCharset);
            string rtl = (Utils.IsRtlCharset(strCharset, acct.UserOfAccount.Settings.RTL)) ? "true" : "false";

            jsMessageInit += "ViewMessage.RTL = " + rtl + ";\n";
            jsMessageInit += "ViewMessage.Safety = " + msg.Safety.ToString(CultureInfo.InvariantCulture) + ";\n";
            jsMessageInit += "ViewMessage.Downloaded = " + ((msg.Downloaded) ? "true" : "false") + ";\n";

            jsMessageInit += "ViewMessage.FromAddr = '" + Utils.EncodeJsSaveString(outputMsg.From.ToString()) + "';\n";
            jsMessageInit += "ViewMessage.FromDisplayName = '" + Utils.EncodeJsSaveString(outputMsg.From.DisplayName) + "';\n";
            jsMessageInit += "ViewMessage.ToAddr = '" + Utils.EncodeJsSaveString(outputMsg.To.ToString()) + "';\n";
            string shortTo = string.Empty;

            if ((outputMsg.To.ToString().IndexOf(acct.Email) == -1) && (outputMsg.To.Count > 0))
            {
                shortTo = (outputMsg.To[0].DisplayName.Length > 0) ? outputMsg.To[0].DisplayName : outputMsg.To[0].Email;
            }
            jsMessageInit += "ViewMessage.ShortToAddr = '" + Utils.EncodeJsSaveString(shortTo) + "';\n";
            jsMessageInit += "ViewMessage.CCAddr = '" + Utils.EncodeJsSaveString(outputMsg.Cc.ToString()) + "';\n";
            jsMessageInit += "ViewMessage.BCCAddr = '" + Utils.EncodeJsSaveString(outputMsg.Bcc.ToString()) + "';\n";
            jsMessageInit += "ViewMessage.ReplyToAddr = '" + Utils.EncodeJsSaveString(outputMsg.ReplyTo.ToString()) + "';\n";
            jsMessageInit += "ViewMessage.Subject = '" + Utils.EncodeJsSaveString(outputMsg.Subject) + "';\n";
            DateFormatting df = new DateFormatting(acct, msg.MsgDate);

            jsMessageInit += "ViewMessage.Date = '" + Utils.EncodeJsSaveString(df.ShortDate) + "';\n";
            jsMessageInit += "ViewMessage.FullDate = '" + Utils.EncodeJsSaveString(df.FullDate) + "';\n";
            jsMessageInit += "ViewMessage.Time = '" + Utils.EncodeJsSaveString(df.Time) + "';\n";

            jsMessageInit += "ViewMessage.HtmlBody = '" + Utils.EncodeJsSaveString(outputMsg.BodyHtmlText) + "';\n";
            jsMessageInit += "ViewMessage.PlainBody = '" + Utils.EncodeJsSaveString(Utils.MakeHtmlBodyFromPlainBody(outputMsg.BodyPlainText, true, "")) + "';\n";

            string replyHtml = Utils.GetMessageHtmlReplyToBody(acct, outputMsg);

            jsMessageInit += "ViewMessage.ReplyHtml = '" + Utils.EncodeJsSaveString(replyHtml) + "';\n";
            jsMessageInit += "ViewMessage.IsReplyHtml = true;\n";
            jsMessageInit += "ViewMessage.ForwardHtml = ViewMessage.ReplyHtml;\n";
            jsMessageInit += "ViewMessage.IsForwardHtml = true;\n";
            string replyPlain = Utils.GetMessagePlainReplyToBody(acct, outputMsg);

            jsMessageInit += "ViewMessage.ReplyPlain = '" + Utils.EncodeJsSaveString(replyPlain) + "';\n";
            jsMessageInit += "ViewMessage.IsReplyPlain = true;\n";
            jsMessageInit += "ViewMessage.ForwardPlain = ViewMessage.ReplyPlain;\n";
            jsMessageInit += "ViewMessage.IsForwardPlain = true;\n";

            if (outputMsg.Attachments.Count > 0)
            {
                jsMessageInit += "ViewMessage.Attachments = [];\n";
                foreach (Attachment attach in outputMsg.Attachments)
                {
                    string _downloadlink = string.Empty;
                    if (string.IsNullOrEmpty(attach.SavedAs))
                    {
                        _downloadlink = Utils.GetAttachmentDownloadLink(outputMsg, attach, folderFullName, false, Page.Session);
                    }
                    else
                    {
                        _downloadlink = Utils.GetAttachmentDownloadLink(attach, false);
                    }
                    string _viewlink = string.Empty;
                    if (string.IsNullOrEmpty(attach.SavedAs))
                    {
                        _viewlink = Utils.GetAttachmentDownloadLink(outputMsg, attach, folderFullName, true, Page.Session);
                    }
                    else
                    {
                        _viewlink = Utils.GetAttachmentDownloadLink(attach, true);
                    }
                    string filename = Path.GetFileName(attach.SavedAs);
                    jsMessageInit += "ViewMessage.Attachments.push({" + String.Format(@"Id: {0}, Inline: {1}, FileName: '{2}', Size: {3}, Download: '{4}', View: '{5}', TempName: '{6}', MimeType: '{7}'",
                                                                                      "-1",
                                                                                      (attach.IsInline) ? "true" : "false",
                                                                                      (attach.Filename.Length > 0) ? attach.Filename : attach.Name,
                                                                                      attach.Size.ToString(),
                                                                                      _downloadlink,
                                                                                      _viewlink,
                                                                                      filename,
                                                                                      Utils.GetAttachmentMimeTypeFromFileExtension(Path.GetExtension(filename))) + "});\n";
                }
            }

            jsMessageInit += "ViewMessage.SaveLink = '" + Utils.GetMessageDownloadLink(msg, folderId, folderFullName) + "';\n";
            jsMessageInit += "ViewMessage.PrintLink = '" + Utils.GetMessagePrintLink(msg, folderId, folderFullName) + "';\n";
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool showPicturesSettings = false;

            acct = Session[Constants.sessionAccount] as Account;
            if (acct == null)
            {
                Response.Redirect("default.aspx", true);
            }
            else
            {
                if (acct.UserOfAccount.Settings.RTL)
                {
                    _stylesRtl = true;
                }
                defaultSkin = Utils.EncodeJsSaveString(acct.UserOfAccount.Settings.DefaultSkin);
                _manager    = (new WebmailResourceManagerCreator()).CreateResourceManager();
                if ((acct.UserOfAccount != null) && (acct.UserOfAccount.Settings != null))
                {
                    showPicturesSettings = ((acct.UserOfAccount.Settings.ViewMode & ViewMode.AlwaysShowPictures) > 0) ? true : false;
                }

                try {
                    int    charset;
                    string full_name_folder;
                    long   id_folder;
                    string uid;
                    int    id;
                    if (Request.QueryString["id"] != null)
                    {
                        id               = Convert.ToInt32(Request.QueryString["id"]);
                        uid              = Request.QueryString["uid"];
                        id_folder        = Convert.ToInt64(Request.QueryString["id_folder"]);
                        full_name_folder = Request.QueryString["full_name_folder"];
                        charset          = Convert.ToInt32(Request.QueryString["charset"]);
                    }
                    else
                    {
                        id               = (int)Session["id"];
                        uid              = (string)Session["uid"];
                        id_folder        = (long)Session["id_folder"];
                        full_name_folder = (string)Session["full_name_folder"];
                        charset          = (int)Session["charset"];
                    }

                    IsHTMLMsg = false;
                    msgPlain  = null;
                    msgHTML   = null;
                    BaseWebMailActions bwml = new BaseWebMailActions(acct, Page);
                    if (showPicturesSettings)
                    {
                        msg = bwml.GetMessage(id, uid, id_folder, charset, 1, true, false, false, MessageMode.None);
                    }
                    else
                    {
                        msg = bwml.GetMessage(id, uid, id_folder, full_name_folder, charset, false, MessageMode.None);
                    }
                    LabelFrom.Text = Server.HtmlEncode(msg.FromMsg.ToString());
                    LabelTo.Text   = Server.HtmlEncode(msg.ToMsg.ToString());
                    CcAddr         = msg.CcMsg.ToString();
                    if (CcAddr != string.Empty)
                    {
                        LabelCc.Text = Server.HtmlEncode(msg.CcMsg.ToString());
                    }
                    DateFormatting df = new DateFormatting(acct, msg.MsgDate);
                    LabelDate.Text    = df.FullDate;
                    LabelSubject.Text = Server.HtmlEncode(msg.Subject);

                    AttachmentCollection AttachmentsColl = msg.MailBeeMessage.Attachments;

                    StringBuilder sb = new StringBuilder();
                    foreach (Attachment Attach in AttachmentsColl)
                    {
                        sb.AppendFormat(@"{0}, ", Attach.Filename);
                    }
                    if (sb.Length > 2)
                    {
                        sb.Remove(sb.Length - 2, 2);
                    }
                    Attachments = sb.ToString();
                    if (Attachments.Length > 0)
                    {
                        LabelAttachments.Text = Attachments;
                    }

                    msgPlain = Utils.MakeHtmlBodyFromPlainBody(msg.MailBeeMessage.BodyPlainText, true, "");
                    msgHTML  = msg.MailBeeMessage.BodyHtmlText;
                    if (msgPlain == "")
                    {
                        msgPlain = Utils.ConvertHtmlToPlain(msgHTML);
                    }
                    if (msgHTML != "")
                    {
                        IsHTMLMsg = true;
                        //Message body
                        MessageBody.Text = msgHTML;
                    }
                    else
                    {
                        IsHTMLMsg        = false;
                        MessageBody.Text = msgPlain;
                    }
                }
                catch (Exception ex) {
                    Log.WriteException(ex);
                    Response.Write(ex.Message);
                }
            }
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            bool    showPicturesSettings = false;
            Account acct = Session[Constants.sessionAccount] as Account;

            if (acct == null)
            {
                Response.Redirect("default.aspx", true);
            }
            else
            {
                try
                {
                    if (acct.UserOfAccount.Settings.RTL)
                    {
                        _stylesRtl = true;
                    }
                    defaultSkin = Utils.EncodeJsSaveString(acct.UserOfAccount.Settings.DefaultSkin);
                    _manager    = (new WebmailResourceManagerCreator()).CreateResourceManager();
                    int    id               = Convert.ToInt32(Request.QueryString["id"]);
                    string uid              = Request.QueryString["uid"];
                    long   id_folder        = Convert.ToInt64(Request.QueryString["id_folder"]);
                    string full_name_folder = Request.QueryString["full_name_folder"];
                    int    charset          = Convert.ToInt32(Request.QueryString["charset"]);
                    if ((acct.UserOfAccount != null) && (acct.UserOfAccount.Settings != null))
                    {
                        showPicturesSettings = ((acct.UserOfAccount.Settings.ViewMode & ViewMode.AlwaysShowPictures) > 0) ? true : false;
                    }

                    WebMailMessage     msg;
                    BaseWebMailActions bwml = new BaseWebMailActions(acct, Page);
                    if (showPicturesSettings)
                    {
                        msg = bwml.GetMessage(id, uid, id_folder, charset, 1, false, false, false, MessageMode.None);
                    }
                    else
                    {
                        msg = bwml.GetMessage(id, uid, id_folder, charset, 1, false, false, false, MessageMode.None);
                    }
                    if (msg != null)
                    {
                        LabelFrom.Text = Server.HtmlEncode(msg.FromMsg.ToString());
                        LabelTo.Text   = Server.HtmlEncode(msg.ToMsg.ToString());
                        DateFormatting df = new DateFormatting(acct, msg.MsgDate);
                        LabelDate.Text    = df.FullDate;
                        LabelSubject.Text = Server.HtmlEncode(msg.Subject);
                        string msgPlain = msg.MailBeeMessage.BodyPlainText;
                        string msgHTML  = msg.MailBeeMessage.BodyHtmlText;

                        switch (Request.QueryString["bodytype"])
                        {
                        case "1":
                            MessageBody.Text = msgHTML;
                            break;

                        default:
                            MessageBody.Text = string.Format("<pre>{0}</pre>", msgPlain);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex);
                    Response.Write(ex.Message);
                }
            }
        }
Esempio n. 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            acct = Session[Constants.sessionAccount] as Account;
            if (acct == null)
            {
                Response.Redirect("default.aspx", true);
            }
            else
            {
                if (acct.UserOfAccount.Settings.RTL)
                {
                    _stylesRtl = true;
                }
                defaultSkin = Utils.EncodeJsSaveString(acct.UserOfAccount.Settings.DefaultSkin);
                _manager    = (new WebmailResourceManagerCreator()).CreateResourceManager();

                if (Request.QueryString["filename"] != null)
                {
                    FileName = Request.QueryString["filename"];
                }

                try
                {
                    IsHTMLMsg = false;
                    msgPlain  = null;
                    msgHTML   = null;

                    string tempFolder = Utils.GetTempFolderName(Page.Session);
                    string FilePath   = Path.Combine(tempFolder, FileName);

                    msg.Parser.WorkingFolder = tempFolder;
                    msg.LoadMessage(FilePath);

                    LabelFrom.Text = Server.HtmlEncode(msg.From.ToString());
                    LabelTo.Text   = Server.HtmlEncode(msg.To.ToString());
                    CcAddr         = msg.Cc.ToString();
                    if (CcAddr != string.Empty)
                    {
                        LabelCc.Text = Server.HtmlEncode(msg.Cc.ToString());
                    }
                    DateFormatting df = new DateFormatting(acct, msg.Date);
                    LabelDate.Text    = df.FullDate;
                    LabelSubject.Text = Server.HtmlEncode(msg.Subject);

                    AttachmentCollection AttachmentsColl = msg.Attachments;

                    StringBuilder sb = new StringBuilder();
                    foreach (Attachment Attach in AttachmentsColl)
                    {
                        string filename = Utils.CreateTempFilePath(tempFolder,
                                                                   (Attach.Filename.Length > 0) ? Attach.Filename : Attach.Name);
                        Attach.Save(filename, true);

                        FileInfo fi = new FileInfo(filename);

                        if (Attach.ContentType.ToLower().StartsWith("image"))
                        {
                            sb.AppendFormat(@"<a href=""{1}"">{0}</a>", Attach.Filename, Utils.GetAttachmentDownloadLink(Attach, false));
                            sb.AppendFormat(@" (<a href=""{0}"">View</a>), ", Utils.GetAttachmentDownloadLink(Attach, true));
                        }
                        else if (Attach.ContentType.ToLower().StartsWith("message"))
                        {
                            sb.AppendFormat(@"<a href=""{1}"">{0}</a>", Attach.Filename, Utils.GetAttachmentDownloadLink(Attach, false));
                            sb.AppendFormat(@" (<a href=""view-embedded-msg.aspx?filename={0}"">View</a>), ", fi.Name);
                        }
                        else
                        {
                            sb.AppendFormat(@"<a href=""{1}"">{0}</a>, ", Attach.Filename, Utils.GetAttachmentDownloadLink(Attach, false));
                        }
                    }
                    if (sb.Length > 2)
                    {
                        sb.Remove(sb.Length - 2, 2);
                    }
                    Attachments = sb.ToString();
                    if (Attachments.Length > 0)
                    {
                        LabelAttachments.Text = Attachments;
                    }

                    msgPlain = Utils.MakeHtmlBodyFromPlainBody(msg.BodyPlainText, true, "");
                    msgHTML  = msg.BodyHtmlText;
                    if (msgPlain == "")
                    {
                        msgPlain = Utils.ConvertHtmlToPlain(msgHTML);
                    }
                    if (msgHTML != "")
                    {
                        IsHTMLMsg = true;
                        //Message body
                        MessageBody.Text = msgHTML;
                    }
                    else
                    {
                        IsHTMLMsg        = false;
                        MessageBody.Text = msgPlain;
                    }
                }
                catch (Exception ex)
                {
                    Log.WriteException(ex);
                }
            }
        }