Esempio n. 1
0
        void NodeActions_InvokeCommand(object Sender, InvokeCommandArgs e)
        {
            SqlForumProvider fp       = new Mediachase.Ibn.Forum.SqlForumProvider();
            HttpResponse     Response = ((Control)Sender).Page.Response;

            int iObjTypeId = -1;
            int iObjId     = -1;

            if (HttpContext.Current.Items["ObjectTypeId"] != null)
            {
                iObjTypeId = (int)HttpContext.Current.Items["ObjectTypeId"];
            }
            if (HttpContext.Current.Items["ObjectId"] != null)
            {
                iObjId = (int)HttpContext.Current.Items["ObjectId"];
            }

            // TODO: (OR) У Олега Ж. пока не реализовано. Должно вытаскиваться из атрибутов.
            int emailMessageId = -1;

            switch (e.CommandUid)
            {
                #region Reply
            case "Reply":
//					((Control)Sender).Page.Response.Write("Test reply event (TestCommandManager.dll : class TestReplyHandler )<br>");
                break;

                #endregion
                #region ReplyOutlook
            case "ReplyOutlook":
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.msg"));
                Response.ContentType = "application/msoutlook";

                MsgMessage.Open(iObjId, emailMessageId, Response.OutputStream);
                Response.End();
                break;

                #endregion
                #region ReplyEML
            case "ReplyEML":
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.eml"));
                Response.ContentType = "message/rfc822";
                MsgMessage.OpenEml(iObjId, emailMessageId, Response.OutputStream);
                Response.End();
                break;

                #endregion
                #region ReSend
            case "ReSend":
                EMailRouterOutputMessage.Send(iObjId, emailMessageId);
                break;

                #endregion
                #region ReSendOut
            case "ReSendOut":
                EMailRouterOutputMessage.Send(iObjId, emailMessageId);
                break;

                #endregion
                #region Resolution
            case "Resolution":
                e.Node.SetAttribute("Resolution", "1");
                fp.SaveNode(e.Node);
                break;

                #endregion
                #region UnResolution
            case "UnResolution":
                if (e.Node.Attributes.ContainsKey("Resolution"))
                {
                    e.Node.Attributes.Remove("Resolution");
                    fp.SaveNode(e.Node);
                }
                break;

                #endregion
                #region Workaround
            case "Workaround":
                e.Node.SetAttribute("Workaround", "1");
                fp.SaveNode(e.Node);
                break;

                #endregion
                #region UnWorkaround
            case "UnWorkaround":
                if (e.Node.Attributes.ContainsKey("Workaround"))
                {
                    e.Node.Attributes.Remove("Workaround");
                    fp.SaveNode(e.Node);
                }
                break;

                #endregion
                #region OnTop
            case "OnTop":
                e.Node.SetAttribute(Node.ONTOP_ATTRIBUTE, "1");
                fp.SaveNode(e.Node);
                break;

                #endregion
                #region UnOnTop
            case "UnOnTop":
                if (e.Node.Attributes.ContainsKey(Node.ONTOP_ATTRIBUTE))
                {
                    e.Node.Attributes.Remove(Node.ONTOP_ATTRIBUTE);
                    fp.SaveNode(e.Node);
                }
                break;

                #endregion
                #region Delete
            case "Delete":
                fp.DeleteNode(e.Node.Uid);
                break;

                #endregion
            default:
                break;
            }
        }
Esempio n. 2
0
        private void dgForum_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "Resolution")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                coll.Add(ForumThreadNodeSetting.Resolution, "1");

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "Workaround")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                coll.Add(ForumThreadNodeSetting.Workaround, "1");

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "UnResolution")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                if (coll[ForumThreadNodeSetting.Resolution] != null)
                {
                    coll.Remove(ForumThreadNodeSetting.Resolution);
                }

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "UnWorkaround")
            {
                int nodeId = int.Parse(e.CommandArgument.ToString());
                ForumThreadNodeSettingCollection coll = new ForumThreadNodeSettingCollection(nodeId);
                if (coll[ForumThreadNodeSetting.Workaround] != null)
                {
                    coll.Remove(ForumThreadNodeSetting.Workaround);
                }

                if (coll[ForumThreadNodeSetting.Internal] == null &&
                    coll[ForumThreadNodeSetting.Incoming] == null &&
                    coll[ForumThreadNodeSetting.Outgoing] == null)
                {
                    coll.Add(ForumThreadNodeSetting.Internal, "1");
                }
            }
            else if (e.CommandName == "ReSend")
            {
                int emailMessageId = int.Parse(e.CommandArgument.ToString());
                try
                {
                    EMailRouterOutputMessage.Send(IncidentId, emailMessageId);
                    WasFarwarded   = 1;
                    ForwardedEMail = emailMessageId;
                }
                catch
                {
                    WasFarwarded   = -1;
                    ForwardedEMail = emailMessageId;
                }
            }
            else if (e.CommandName == "ReSendOut")
            {
                int emailMessageId = int.Parse(e.CommandArgument.ToString());
                try
                {
                    EMailRouterOutputMessage.Send(IncidentId, emailMessageId);
                    WasFarwarded   = 1;
                    ForwardedEMail = emailMessageId;
                }
                catch
                {
                    WasFarwarded   = -1;
                    ForwardedEMail = emailMessageId;
                }
            }
            else if (e.CommandName == "Reply")
            {
                try
                {
                    int emailMessageId = int.Parse(e.CommandArgument.ToString());

                    if (pc["IncForum_ReplyOutlook"] == "1")
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.msg"));
                        HttpContext.Current.Response.ContentType = "application/msoutlook";

                        MsgMessage.Open(IncidentId, emailMessageId,
                                        HttpContext.Current.Response.OutputStream);
                    }
                    else if (pc["IncForum_ReplyEML"] == "1")
                    {
                        Response.AddHeader("content-disposition", String.Format("attachment; filename=\"{0}\"", "mail.eml"));
                        HttpContext.Current.Response.ContentType = "message/rfc822";
                        MsgMessage.OpenEml(IncidentId, emailMessageId,
                                           HttpContext.Current.Response.OutputStream);
                    }

                    Response.End();
                }
                catch (Exception ex)
                {
                    HttpContext.Current.Trace.Write(ex.Message);
                }
            }
        }
Esempio n. 3
0
        private void BindDefaultValues()
        {
            string fromEmail = Security.CurrentUser.Email;

            if (IncidentId > 0)
            {
                fromEmail = EMailRouterOutputMessage.FindEMailRouterPublicEmail(IncidentId);
            }
            txtFrom.Text = String.Format(CultureInfo.InvariantCulture,
                                         "{1}&nbsp;&lt;{0}&gt;", fromEmail, Security.CurrentUser.DisplayName);
            lblCCTitle.Text = "";
            lblToTitle.Text = LocRM.GetString("tTo") + ":";
            if (IncidentId > 0)
            {
                NameValueCollection _params = new NameValueCollection();
                _params["IssueId"] = IncidentId.ToString();
                string[] erList = EMailClient.GetDefaultRecipientList(EMailClient.IssueMode, _params);
                for (int i = 0; i < erList.Length; i++)
                {
                    string sName = GetNameByEMail(erList[i]);
                    if (sName != "")
                    {
                        lblCC.Text += String.Format(CultureInfo.InvariantCulture, "{0} &lt;{1}&gt;; ", sName, erList[i]);
                    }
                    else
                    {
                        lblCC.Text += erList[i] + "; ";
                    }
                }

                string sValue = EMailMessage.GetOutgoingEmailFormatBodyPreview(IncidentId).Replace("[=Text=]", "");
                if (NodeId > 0)
                {
                    EMailMessageInfo mi = EMailMessageInfo.Load(NodeId);
                    sValue += "<br/>" + "<blockquote style='border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;' dir='ltr'>" + mi.HtmlBody + "</blockquote>";
                }
                fckEditor.Text = sValue;

                using (IDataReader reader = Incident.GetIncident(IncidentId))
                {
                    if (reader.Read())
                    {
                        txtSubject.Text = string.Format(CultureInfo.InvariantCulture
                                                        , "RE: [{0}] {1}"
                                                        , (reader["Identifier"] != DBNull.Value) ?
                                                        reader["Identifier"].ToString()
                                                                : TicketUidUtil.Create(IncidentBox.Load((int)reader["IncidentBoxId"]).IdentifierMask, IncidentId)
                                                        , HttpUtility.HtmlDecode(reader["Title"].ToString())
                                                        );
                    }
                }
            }
            if (FileIds != "")
            {
                string sFiles = FileIds.Trim();
                if (sFiles.EndsWith(","))
                {
                    sFiles = sFiles.Substring(0, sFiles.Length - 1);
                }
                string[] masFiles = sFiles.Split(',');
                if (masFiles.Length > 0)
                {
                    string _containerName   = "FileLibrary";
                    string _containerKey    = "EMailAttach";
                    CS.BaseIbnContainer bic = CS.BaseIbnContainer.Create(_containerName, _containerKey);
                    CS.FileStorage      fs  = (CS.FileStorage)bic.LoadControl("FileStorage");

                    CS.BaseIbnContainer bic2 = CS.BaseIbnContainer.Create(FilesContainerName, FilesContainerKey);
                    CS.FileStorage      fs2  = (CS.FileStorage)bic.LoadControl("FileStorage");

                    CS.DirectoryInfo di = fs.GetDirectory(fs.Root.Id, _guid, true);
                    for (int i = 0; i < masFiles.Length; i++)
                    {
                        fs2.CopyFile(int.Parse(masFiles[i]), di.Id);
                    }
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "_getFiles",
                                                            "window.setTimeout('updateAttachments()', 500);", true);
                }
            }
            if (ErrorId != "")
            {
                string support_email = GlobalResourceManager.Strings["SupportEmail"];
                //if (Security.CurrentUser != null && Security.CurrentUser.Culture.ToLower().IndexOf("ru") >= 0)
                //    support_email = "*****@*****.**";
                txtTo.Text = support_email + "; ";

                txtSubject.Text = String.Format("{0} {1} {2} Error Report", IbnConst.CompanyName, IbnConst.ProductFamilyShort, IbnConst.VersionMajorDotMinor);

                string prefix   = Request.Url.Host.Replace(".", "_");
                string FilePath = Server.MapPath("../Admin/Log/Error/" + prefix + "_" + ErrorId + ".html");
                string sTemp    = String.Empty;
                using (StreamReader sr = File.OpenText(FilePath))
                {
                    sTemp += sr.ReadToEnd();
                }

                Match match = Regex.Match(sTemp, @"<body[^>]*>(?<HtmlBody>[\s\S]*?)</body>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
                if (match.Success)
                {
                    string body       = match.Groups["HtmlBody"].Value;
                    Match  matchStyle = Regex.Match(sTemp, @"<style[^>]*>(?<HtmlStyle>[\s\S]*?)</style>", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Multiline);
                    if (matchStyle.Success)
                    {
                        body += matchStyle.Value;
                    }
                    sTemp = body;
                }
                fckEditor.Text = sTemp;
            }
            if (lblCC.Text != "")
            {
                lblCCTitle.Text = LocRM.GetString("tTo") + ":";
                lblToTitle.Text = LocRM.GetString("tCc") + ":";
            }
        }
Esempio n. 4
0
        public static void SendMessage(string[] To, string Subject, string Body, Mediachase.IBN.Business.ControlSystem.DirectoryInfo Attachments, string Mode, NameValueCollection Params)
        {
            // Cleanup Temporary files
            DbEMailTempFile.CleanUp();

            #region Validate Arguments
            if (To == null)
            {
                throw new ArgumentNullException("To");
            }

            if (Subject == null)
            {
                throw new ArgumentNullException("Subject");
            }

            if (Body == null)
            {
                throw new ArgumentNullException("Body");
            }

            //if (To.Length == 0)
            //    throw new ArgumentOutOfRangeException("To", "Email recipient list is empty.");

            if (Mode == null)
            {
                Mode = string.Empty;
            }

            if (Params == null)
            {
                Params = new NameValueCollection();
            }
            #endregion

            string FromEmail = string.Empty;

            switch (Mode)
            {
            case EMailClient.IssueMode:
            case EMailClient.SmtpTestMode:
                FromEmail = Alerts2.AlertSenderEmail;
                break;

            default:
                FromEmail = Security.CurrentUser.Email;
                break;
            }

            string FullFromEmail = string.Format("\"{0} {1}\" <{2}>",
                                                 Security.CurrentUser.LastName,
                                                 Security.CurrentUser.FirstName,
                                                 FromEmail);

            using (DbTransaction tran = DbTransaction.Begin())
            {
                EMailMessageLogSetting EmailLogSettings = EMailMessageLogSetting.Current;
                if (EmailLogSettings.IsActive)
                {
                    EMailMessageLog.CleanUp(EmailLogSettings.Period);
                }
                else
                {
                    EmailLogSettings = null;
                }

                Mode = Mode.ToLower();

                #region Pre-format incoming arguments
                switch (Mode)
                {
                case EMailClient.IssueMode:
                    if (Params["IssueId"] == null)
                    {
                        throw new ArgumentNullException("Params[\"IssueId\"]");
                    }

                    int IssueId = int.Parse(Params["IssueId"]);

                    // TODO: Validate Subject & Ticket
                    if (TicketUidUtil.LoadFromString(Subject) == string.Empty)
                    {
                        IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IssueId));

                        string IncidentTicket = Incident.GetIdentifier(IssueId);

                        if (incidentBox.Document.GeneralBlock.AllowOutgoingEmailFormat)
                        {
                            StringBuilder sb = new StringBuilder(incidentBox.Document.GeneralBlock.OutgoingEmailFormatSubject, 4096);

                            sb.Replace("[=Title=]", Subject);
                            sb.Replace("[=Ticket=]", IncidentTicket);
                            //sb.Replace("[=Text=]", Body);
                            sb.Replace("[=FirstName=]", Security.CurrentUser.FirstName);
                            sb.Replace("[=LastName=]", Security.CurrentUser.LastName);

                            Subject = sb.ToString();
                        }
                        else
                        {
                            Subject = string.Format("RE: [{0}] {1}",
                                                    IncidentTicket,
                                                    Subject);
                        }
                    }
                    break;

                default:
                    break;
                }

                #endregion

                Pop3Message msg = Create(FullFromEmail, To, Subject, Body, Attachments);

                switch (Mode)
                {
                case EMailClient.IssueMode:
                    #region Issue
                    int IssueId = int.Parse(Params["IssueId"]);

                    IncidentBox incidentBox = IncidentBox.Load(Incident.GetIncidentBox(IssueId));

                    bool AllowEMailRouting = true;

                    EMailRouterIncidentBoxBlock settings = IncidentBoxDocument.Load(incidentBox.IncidentBoxId).EMailRouterBlock;
                    if (!settings.AllowEMailRouting)
                    {
                        AllowEMailRouting = false;
                    }

                    EMailRouterPop3Box internalPop3Box = EMailRouterPop3Box.ListInternal();
                    if (internalPop3Box == null)
                    {
                        AllowEMailRouting = false;
                    }

                    // Register Email Message
                    // OZ: [2007--05-25] Fix Problem Object reference not set to an instance of an object If (internalPop3Box == NULL)
                    int EMailMessageId = EMailMessage.Create(internalPop3Box != null?
                                                             internalPop3Box.EMailRouterPop3BoxId : EMailRouterOutputMessage.FindEMailRouterPublicId(IssueId),
                                                             msg);

                    // Register Forume Node
                    int ThreadNodeId = EMailMessage.AddToIncidentMessage(true, IssueId, EMailMessageId, msg);

                    // Send Message

                    if (AllowEMailRouting)
                    {
                        ArrayList excludedUsers = EMailRouterOutputMessage.Send(IssueId, internalPop3Box, msg, To);
                        SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IssueId, -1, excludedUsers);
                    }
                    else
                    {
                        FromEmail     = EMailRouterOutputMessage.FindEMailRouterPublicEmail(IssueId);
                        FullFromEmail = string.Format("\"{0} {1}\" <{2}>",
                                                      Security.CurrentUser.LastName,
                                                      Security.CurrentUser.FirstName,
                                                      FromEmail);

                        // Create OutputMessageCreator
                        OutputMessageCreator issueOutput = new OutputMessageCreator(msg,
                                                                                    -1,
                                                                                    FromEmail,
                                                                                    FullFromEmail);

                        // Fill Recipent
                        foreach (string ToItem in To)
                        {
                            issueOutput.AddRecipient(ToItem);
                        }

                        foreach (EMailIssueExternalRecipient exRecipient in EMailIssueExternalRecipient.List(IssueId))
                        {
                            issueOutput.AddRecipient(exRecipient.EMail);
                        }

                        int emailBoxId = EMail.EMailRouterOutputMessage.FindEMailRouterPublicId(IssueId);

                        //Send Smtp Message
                        foreach (OutputMessage outputMsg in issueOutput.Create())
                        {
                            SmtpClientUtility.SendMessage(OutgoingEmailServiceType.HelpDeskEmailBox, emailBoxId, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data);
                        }

                        ArrayList excludedUsers = new ArrayList();

                        foreach (string ToItem in To)
                        {
                            int emailUserId = DBUser.GetUserByEmail(ToItem, false);
                            if (emailUserId > 0)
                            {
                                excludedUsers.Add(emailUserId);
                            }
                        }

                        SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, IssueId, -1, excludedUsers);
                    }
                    #endregion
                    break;

                case EMailClient.SmtpTestMode:
                    throw new NotImplementedException();
                //OutputMessageCreator smtpTestOutput = new OutputMessageCreator(msg,
                //    -1,
                //    FromEmail,
                //    FullFromEmail);

                //// Fill Recipent
                //foreach (string ToItem in To)
                //{
                //    smtpTestOutput.AddRecipient(ToItem);
                //}

                ////Send Smtp Message
                //foreach (OutputMessage outputMsg in smtpTestOutput.Create())
                //{
                //    //SmtpClientUtility.DirectSendMessage(outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data);
                //    //SmtpBox.SendTestEmail(
                //}
                //break;
                default:
                    #region Default
                    // Create OutputMessageCreator
                    OutputMessageCreator defaultOutput = new OutputMessageCreator(msg,
                                                                                  -1,
                                                                                  FromEmail,
                                                                                  FullFromEmail);

                    // Fill Recipent
                    foreach (string ToItem in To)
                    {
                        defaultOutput.AddRecipient(ToItem);
                    }

                    //Send Smtp Message
                    foreach (OutputMessage outputMsg in defaultOutput.Create())
                    {
                        SmtpClientUtility.SendMessage(OutgoingEmailServiceType.SendFile, null, outputMsg.MailFrom, outputMsg.RcptTo, outputMsg.Subject, outputMsg.Data);
                    }

                    #endregion
                    break;
                }

                if (Attachments != null)
                {
                    FileStorage.InnerDeleteFolder(Attachments.Id);
                }

                tran.Commit();
            }
        }
Esempio n. 5
0
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            bool withResponse = false;

            if (this.IsPostBack)
            {
                try
                {
                    string sUserLight = "userlight";

                    // check user's name and password here
                    UserLight currentUser = Security.GetUser(Login.Value, Password.Value);
                    if (currentUser == null)
                    {
                        throw new HttpException(405, "Your login or password is invalid.");
                    }

                    // Security Addon [3/2/2004]
                    UserLight retUser = null;
                    if (HttpContext.Current.Items.Contains(sUserLight))
                    {
                        retUser = (UserLight)HttpContext.Current.Items[sUserLight];
                        HttpContext.Current.Items.Remove(sUserLight);
                    }
                    HttpContext.Current.Items.Add(sUserLight, currentUser);
                    // End Security Addon [3/2/2004]

                    // New Folder System Addon [12/27/2005]
                    string ContainerName = "FileLibrary";
                    string ContainerKey  = String.Empty;
                    int    objectId      = Int32.Parse(ObjectId.Value);
                    int    objectTypeId  = Int32.Parse(ObjectTypeId.Value);
                    int    folderId      = 0;

                    switch ((ObjectTypes)objectTypeId)
                    {
                    case ObjectTypes.Project:
                        ContainerKey = "ProjectId_" + objectId.ToString();
                        break;

                    case ObjectTypes.Issue:
                        ContainerKey = string.Empty;
                        break;

                    case ObjectTypes.Task:
                        ContainerKey = "TaskId_" + objectId.ToString();
                        break;

                    case ObjectTypes.CalendarEntry:
                        ContainerKey = "EventId_" + objectId.ToString();
                        break;

                    case ObjectTypes.Folder:
                        ContainerKey = "Workspace";
                        if (objectId != 0)
                        {
                            folderId     = objectId;
                            ContainerKey = Mediachase.IBN.Business.ControlSystem.DirectoryInfo.GetContainerKey(folderId);
                        }
                        break;

                    case ObjectTypes.Document:
                        ContainerKey = "DocumentId_" + objectId.ToString();
                        break;

                    case ObjectTypes.ToDo:
                        ContainerKey = "ToDoId_" + objectId.ToString();
                        break;
                    }
                    if (ContainerKey != String.Empty)
                    {
                        Mediachase.IBN.Business.ControlSystem.BaseIbnContainer bic = Mediachase.IBN.Business.ControlSystem.BaseIbnContainer.Create(ContainerName, ContainerKey);
                        Mediachase.IBN.Business.ControlSystem.FileStorage      fs  = (Mediachase.IBN.Business.ControlSystem.FileStorage)bic.LoadControl("FileStorage");

                        if (folderId == 0)
                        {
                            folderId = fs.Root.Id;
                        }

                        string fileName = Path.GetFileName(PublishedFile.PostedFile.FileName);
                        if (FileName.Value != string.Empty)
                        {
                            fileName = FileName.Value;
                        }

                        /*int	index = 0;
                         * while (fs.FileExist(fileName, folderId))
                         * {
                         *      fileName = Path.GetFileNameWithoutExtension(PublishedFile.PostedFile.FileName) + (index++).ToString();
                         *      fileName += Path.GetExtension(PublishedFile.PostedFile.FileName);
                         * }*/
                        fs.SaveFile(folderId, fileName, PublishedFile.PostedFile.InputStream);
                    }
                    else if ((ObjectTypes)objectTypeId == ObjectTypes.List)
                    {
                        string xml = SaveNParseExcel(PublishedFile.PostedFile.FileName, PublishedFile.PostedFile.InputStream);

                        Response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(xml));
                        withResponse = true;
                    }
                    else if ((ObjectTypes)objectTypeId == ObjectTypes.Issue)
                    {
                        string fileName = Path.GetFileName(PublishedFile.PostedFile.FileName);
                        if (FileName.Value != string.Empty)
                        {
                            fileName = FileName.Value;
                        }

                        // OZ: 2008-08-19 Add Process Eml Attachments
                        if (Path.GetExtension(fileName).ToLower() == ".eml")
                        {
                            // Calculate email box
                            int emailBoxId = EMailRouterOutputMessage.FindEMailRouterPublicId(objectId);

                            // Save Email to email storage
                            int eMailMessageId = EMailMessage.CreateFromStream(emailBoxId, PublishedFile.PostedFile.InputStream);

                            EMailMessage.AddToIncidentMessage(false, objectId, eMailMessageId);

                            try
                            {
                                ArrayList excludeUsers = EMailRouterOutputMessage.Send(objectId, eMailMessageId);
                                SystemEvents.AddSystemEvents(SystemEventTypes.Issue_Updated_Forum_MessageAdded, objectId, -1, excludeUsers);
                            }
                            catch (Exception ex)
                            {
                                System.Diagnostics.Trace.WriteLine(ex);
                                //Log.WriteError(ex.ToString());
                            }
                        }
                        // Process Default files
                        else
                        {
                            BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", objectId));
                            ForumStorage     forumStorage  = (ForumStorage)destContainer.LoadControl("ForumStorage");

                            ForumThreadNodeInfo info = forumStorage.CreateForumThreadNode(string.Empty, Security.CurrentUser.UserID, (int)ForumStorage.NodeContentType.TextWithFiles);

                            BaseIbnContainer forumContainer = BaseIbnContainer.Create("FileLibrary", string.Format("ForumNodeId_{0}", info.Id));
                            FileStorage      fs             = (FileStorage)forumContainer.LoadControl("FileStorage");


                            fs.SaveFile(fileName, PublishedFile.PostedFile.InputStream);

                            ForumThreadNodeSettingCollection settings1 = new ForumThreadNodeSettingCollection(info.Id);
                            settings1.Add(ForumThreadNodeSetting.Internal, "1");
                        }
                    }
                    // End New Folder System Addon [12/27/2005]

                    // Security Addon [3/2/2004]
                    HttpContext.Current.Items.Remove(sUserLight);
                    HttpContext.Current.Items.Add(sUserLight, retUser);
                    // End Security Addon [3/2/2004]
                }
                catch (Exception ex)
                {
                    throw new HttpException(405, "Internal Exception", ex);
                }
                if (!withResponse)
                {
                    this.Response.Write("Published Completed");
                }
                this.Response.End();
            }
        }