Exemplo n.º 1
0
        /// <summary>
        /// Adds the internal E mail2 incident.
        /// </summary>
        /// <param name="IncidentId">The incident id.</param>
        /// <param name="EMailMessageId">The E mail message id.</param>
        /// <param name="SenderName">Name of the sender.</param>
        /// <param name="SenderEmail">The sender email.</param>
        /// <returns></returns>
        private static int AddInternalEMail2Incident(int IncidentId, int EMailMessageId, string SenderName, string SenderEmail)
        {
            ForumThreadNodeInfo info = null;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                BaseIbnContainer FOcontainer  = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IncidentId));
                ForumStorage     forumStorage = (ForumStorage)FOcontainer.LoadControl("ForumStorage");

                int SenderUserID    = Security.UserID;
                EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId);

                info = forumStorage.CreateForumThreadNode(EMailMessageInfo.ExtractTextFromHtml(mi.HtmlBody),
                                                          DateTime.UtcNow,
                                                          Security.UserID,
                                                          EMailMessageId,
                                                          (int)ForumStorage.NodeContentType.EMail);

                ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id);
                settings.Add(ForumThreadNodeSetting.Outgoing, "1");

                if (HttpContext.Current != null && HttpContext.Current.Items.Contains(ForumThreadNodeSetting.AllRecipients))
                {
                    settings.Add(ForumThreadNodeSetting.AllRecipients, HttpContext.Current.Items[ForumThreadNodeSetting.AllRecipients].ToString());
                }

                tran.Commit();
            }

            return(info.Id);
        }
Exemplo n.º 2
0
        //newRespId: UserId OR "-2" - NotSet, "-1" - GroupResponsibility
        public static int AddForumMesageWithResponsibleChange(int IncidentId, int ForumNodeId, int newRespId)
        {
            ForumThreadNodeInfo info = null;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                BaseIbnContainer destContainer = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IncidentId));
                ForumStorage     forumStorage  = (ForumStorage)destContainer.LoadControl("ForumStorage");
                if (ForumNodeId > 0)
                {
                    info = forumStorage.GetForumThreadNode(ForumNodeId);
                }
                else
                {
                    info = forumStorage.CreateForumThreadNode("", Security.CurrentUser.UserID, (int)ForumStorage.NodeContentType.Text);
                }

                ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id);
//				settings.Add("IssueEvent", IssueEvent.Responsibility.ToString());
                settings.Add(IssueEvent.Responsibility.ToString(), newRespId.ToString());

                tran.Commit();
            }
            return(info.Id);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the external E mail to incident.
        /// </summary>
        /// <param name="IncidentId">The incident id.</param>
        /// <param name="EMailMessageId">The E mail message id.</param>
        /// <param name="message">The message.</param>
        private static int AddExternalEMail2Incident(int IncidentId, int EMailMessageId, string SenderName, string SenderEmail)
        {
            ForumThreadNodeInfo info = null;

            using (DbTransaction tran = DbTransaction.Begin())
            {
                BaseIbnContainer FOcontainer  = BaseIbnContainer.Create("FileLibrary", string.Format("IncidentId_{0}", IncidentId));
                ForumStorage     forumStorage = (ForumStorage)FOcontainer.LoadControl("ForumStorage");

                EMailMessageInfo mi = EMailMessageInfo.Load(EMailMessageId);

                info = forumStorage.CreateForumThreadNode(EMailMessageInfo.ExtractTextFromHtml(mi.HtmlBody),
                                                          DateTime.UtcNow,
                                                          Security.UserID,
                                                          EMailMessageId,
                                                          (int)ForumStorage.NodeContentType.EMail);

                // 2006-12-12 OZ: Register EMail External Recepient
                if (!EMailIssueExternalRecipient.Contains(IncidentId, SenderEmail))
                {
                    EMailIssueExternalRecipient.Create(IncidentId, SenderEmail);
                }

                ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(info.Id);
                settings.Add(ForumThreadNodeSetting.Incoming, "1");

                if (HttpContext.Current != null && HttpContext.Current.Items.Contains(ForumThreadNodeSetting.AllRecipients))
                {
                    settings.Add(ForumThreadNodeSetting.AllRecipients, HttpContext.Current.Items[ForumThreadNodeSetting.AllRecipients].ToString());
                }

                // O.R. [2008-09-19]: Recalculate Expected Dates
                DBIncident.RecalculateExpectedResponseDate(IncidentId);
                DBIncident.RecalculateExpectedAssignDate(IncidentId);

                tran.Commit();
            }

            return(info.Id);
        }
Exemplo n.º 4
0
        public static void SetPrivateStatus(int ThreadNodeId)
        {
            ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId);

            if (settings.Contains(ForumThreadNodeSetting.Outgoing))
            {
                settings.Remove(ForumThreadNodeSetting.Outgoing);
            }
            if (settings.Contains(ForumThreadNodeSetting.Incoming))
            {
                settings.Remove(ForumThreadNodeSetting.Incoming);
            }

            settings.Add(ForumThreadNodeSetting.Internal, "1");
        }
Exemplo n.º 5
0
        public static void SetWorkaroundStatus(int ThreadNodeId)
        {
            ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId);

            settings.Add(ForumThreadNodeSetting.Workaround, "1");
        }
Exemplo n.º 6
0
        public static void SetResolutionStatus(int ThreadNodeId)
        {
            ForumThreadNodeSettingCollection settings = new ForumThreadNodeSettingCollection(ThreadNodeId);

            settings.Add(ForumThreadNodeSetting.Resolution, "1");
        }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
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();
            }
        }