예제 #1
0
        public void DoAddPmAndSendEmail(TicketsEntity ticketEntity)
        {
            #region add pm
            TicketUsersEntity ticketUserEntity = new TicketUsersEntity();
            //add pm user
            ticketUserEntity.Type     = TicketUsersType.PM;
            ticketUserEntity.TicketID = result;
            ProjectsEntity projectEntity = projectApp.Get(ticketEntity.ProjectID);
            if (projectEntity != null)
            {
                ticketUserEntity.UserID = projectEntity.PMID;
                ticketAPP.AddTicketUser(ticketUserEntity);
            }
            else
            {
                WebLogAgent.Write(string.Format("Add Pm To Ticket User Error:Project :{0},Ticket:{1},CreateDate:{2}",
                                                ticketEntity.ProjectID, ticketEntity.TicketID, DateTime.Now));
            }
            //add create user
            ticketUserEntity.Type     = TicketUsersType.Create;
            ticketUserEntity.TicketID = result;
            ticketUserEntity.UserID   = ticketEntity.CreatedBy;
            ticketAPP.AddTicketUser(ticketUserEntity);

            #endregion

            #region send email

            if (!ticketEntity.IsInternal && ticketEntity.Status != TicketsState.Draft)
            {
                TicketStatusManagerApplication ex = new TicketStatusManagerApplication();
                ex.SendEmailToPMWhenTicketAdd(result, ticketEntity.TicketType);
            }

            #endregion
        }
예제 #2
0
        /// <summary>
        /// save : 1:save ; 2:draft ;3 save and new
        /// </summary>
        /// <param name="save"></param>
        private void SaveTicket(int save)
        {
            #region add ticket
            TicketsEntity ticketsEntity = new TicketsEntity();
            ticketsEntity.Title           = txtTitle.Value.NoHTML();
            ticketsEntity.FullDescription = txtDesc.Value.NoHTML();
            ticketsEntity.URL             = txtUrl.Value;
            ticketsEntity.ProjectID       = int.Parse(ddlProject.SelectedValue);
            ticketsEntity.TicketType      = (TicketsType)int.Parse(ddlType.SelectedValue);
            ticketsEntity.TicketCode      = new TicketsApplication().ConvertTicketTypeToTicketCode(ticketsEntity.TicketType);
            ticketsEntity.Priority        = (PriorityState)int.Parse(this.radioPriority.SelectedValue);
            ProjectsEntity projectsEntity = new ProjectApplication().Get(ticketsEntity.ProjectID);
            ticketsEntity.CompanyID   = projectsEntity.CompanyID;
            ticketsEntity.IsEstimates = chkEN.Checked;

            ticketsEntity.IsInternal = false;
            ticketsEntity.CreatedBy  = UserInfo.UserID;
            ticketsEntity.CreatedOn  = DateTime.Now;
            ticketsEntity.ModifiedBy = UserInfo.UserID;
            ticketsEntity.ModifiedOn = DateTime.Now;

            ticketsEntity.PublishDate   = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
            ticketsEntity.ConvertDelete = CovertDeleteState.Normal;
            ticketsEntity.StartDate     = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
            ticketsEntity.DeliveryDate  = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
            if (UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.ADMIN)
            {
                ticketsEntity.Source = (RolesEnum)Enum.Parse(typeof(RolesEnum), ddlSource.SelectedValue);
            }
            else
            {
                ticketsEntity.Source = UserInfo.Role;
            }
            if (save == 2)
            {
                ticketsEntity.Status = TicketsState.Draft;
            }
            else
            {
                if (UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.ADMIN)
                {
                    ticketsEntity.Status = TicketsState.PM_Reviewed;
                }
                else
                {
                    ticketsEntity.Status = TicketsState.Submitted;
                }
            }
            int result = new TicketsApplication().AddTickets(ticketsEntity);

            if (result > 0)
            {
                TicketUsersEntity ticketUserEntity = new TicketUsersEntity();
                //add pm user
                ticketUserEntity.Type     = TicketUsersType.PM;
                ticketUserEntity.TicketID = result;
                ProjectsEntity projectEntity = new ProjectApplication().Get(ticketsEntity.ProjectID);
                if (projectEntity != null)
                {
                    ticketUserEntity.UserID = projectEntity.PMID;
                    new TicketsApplication().AddTicketUser(ticketUserEntity);
                }
                else
                {
                    WebLogAgent.Write(string.Format("Add Pm To Ticket User Error:Project :{0},Ticket:{1},CreateDate:{2}",
                                                    ticketsEntity.ProjectID, ticketsEntity.TicketID, DateTime.Now));
                }
                //add create user
                ticketUserEntity.Type     = TicketUsersType.Create;
                ticketUserEntity.TicketID = result;
                ticketUserEntity.UserID   = ticketsEntity.CreatedBy;
                new TicketsApplication().AddTicketUser(ticketUserEntity);

                if (UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.ADMIN)
                {
                    //添加当前Project中的Leader到此ticket下.
                    List <ProjectUsersEntity> ProjectUsers = new ProjectApplication().GetProjectSunnetUserList(projectsEntity.ID);
                    if (ProjectUsers != null)
                    {
                        List <ProjectUsersEntity> leaders = ProjectUsers.FindAll(r => r.Role == RolesEnum.Leader);
                        foreach (ProjectUsersEntity leader in leaders)
                        {
                            ticketUserEntity          = new TicketUsersEntity();
                            ticketUserEntity.Type     = TicketUsersType.Dev;
                            ticketUserEntity.TicketID = result;
                            ticketUserEntity.UserID   = leader.UserID;
                            new TicketsApplication().AddTicketUser(ticketUserEntity);
                        }
                    }
                }
            }
            #endregion

            #region send email
            TicketStatusManagerApplication ex = new TicketStatusManagerApplication();
            if (!ticketsEntity.IsInternal)
            {
                ex.SendEmailToPMWhenTicketAdd(result, ticketsEntity.TicketType);
            }

            #endregion

            #region add file

            if (fileupload.PostedFile.ContentLength > 0)
            {
                string FolderName = string.Empty;
                if (null != projectsEntity)
                {
                    FolderName = projectsEntity.ProjectID.ToString();
                }


                string filderPath    = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; //~/path
                string savepath      = Server.MapPath(filderPath) + FolderName;
                string filename      = fileupload.PostedFile.FileName;
                string fileExtension = Path.GetExtension(filename);

                if (!Directory.Exists(savepath))
                {
                    Directory.CreateDirectory(savepath);
                }

                string sNewFileName = string.Format("{0}_{1}{2}", result, DateTime.Now.ToString("yyMMddssmm"), fileExtension);

                fileupload.PostedFile.SaveAs(savepath + @"\" + sNewFileName);



                FilesEntity fileEntity = new FilesEntity();

                fileEntity.ContentType = fileExtension.ToLower();
                fileEntity.CreatedBy   = ticketsEntity.CreatedBy;
                fileEntity.FilePath    = filderPath.Substring(2) + FolderName + @"/" + sNewFileName;
                fileEntity.FileSize    = fileupload.PostedFile.ContentLength;
                fileEntity.FileTitle   = filename.Substring(0, filename.LastIndexOf('.'));
                fileEntity.IsPublic    = !ticketsEntity.IsInternal;
                fileEntity.ProjectId   = ticketsEntity.ProjectID;
                fileEntity.TicketId    = result;
                fileEntity.CreatedOn   = DateTime.Now.Date;
                fileEntity.FeedbackId  = 0;
                fileEntity.SourceType  = (int)FileSourceType.Ticket;
                fileEntity.ThumbPath   = "";
                fileEntity.CompanyID   = ticketsEntity.CompanyID;
                int response = new FileApplication().AddFile(fileEntity);
            }

            #endregion

            switch (save)
            {
            case 1:
                ShowMessageAndRedirect("The ticket has been added.", "/sunnet/Clients/ListTicket.aspx");
                break;

            case 2:
                ShowMessageAndRedirect("The ticket has been added.", "/sunnet/Clients/ListTicketDrafted.aspx");
                break;

            case 3:
                ShowMessageAndRedirect("The ticket has been added.", "/sunnet/Clients/AddBug.aspx");
                break;
            }
        }
예제 #3
0
        protected void SendEamil(TicketsEntity te, UsersEntity createUser)
        {
            TicketStatusManagerApplication ex = new TicketStatusManagerApplication();

            ex.SendEmailToPMWhenTicketAdd(te, UserInfo);
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }

                #region get value

                int    tid           = Convert.ToInt32(context.Request["tid"]);
                int    pId           = Convert.ToInt32(context.Request["pId"]);
                String tType         = context.Request["tType"];
                String ckbEn         = context.Request["ckbEn"];
                String pty           = context.Request["pty"];
                String title         = context.Request["title"].NoHTML();
                String url           = context.Server.UrlEncode(context.Request["url"]);
                String descr         = context.Request["descr"].NoHTML();
                String imageList     = context.Request["imageList"];
                String imageSizeList = context.Request["imageSizeList"];
                String StartDate     = context.Request["StartDate"];
                String DeliveryDate  = context.Request["DeliveryDate"];
                String satus         = context.Request["satus"];
                String IsSunnet      = context.Request["isSunnet"];

                #endregion

                bool update = true;

                TicketsEntity ticketEntity = TicketApp.GetTickets(tid);//get original model

                #region set original value
                {
                    originalDesc = ticketEntity.FullDescription;

                    originalState = ticketEntity.Status.ToString();

                    originalTitle = ticketEntity.Title;
                }
                #endregion

                #region set satus value

                switch (satus)
                {
                case "save":
                    ticketEntity.Status = ticketEntity.Status;
                    break;

                case "cancle":
                    ticketEntity.Status = TicketsState.Cancelled;
                    break;

                case "submit":
                    IsSend = true;
                    ticketEntity.Status = TicketsState.Submitted;
                    break;
                }

                #endregion

                #region ticket

                ticketEntity.ProjectID       = pId;
                ticketEntity.URL             = url;
                ticketEntity.FullDescription = descr;
                ticketEntity.Title           = title.NoHTML();
                ticketEntity.TicketType      = tType == "0" ? TicketsType.Bug : TicketsType.Request;
                ticketEntity.IsEstimates     = ckbEn == "checked" ? true : false;
                ticketEntity.Priority        = (PriorityState)Convert.ToInt32(pty);
                ticketEntity.ModifiedBy      = IdentityContext.UserID;

                if (IsSunnet == "true")
                {
                    ticketEntity.StartDate    = !string.IsNullOrEmpty(StartDate.ToString()) ? DateTime.Parse(StartDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                    ticketEntity.DeliveryDate = !string.IsNullOrEmpty(DeliveryDate.ToString()) ? DateTime.Parse(DeliveryDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                }
                else
                {
                    ticketEntity.StartDate    = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                    ticketEntity.DeliveryDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                }

                #region record,when title or descr or status changed

                if (originalTitle != title || originalDesc != descr)
                {
                    ticketEntity.ModifiedOn = DateTime.Now;
                }

                if ((TicketsState)Enum.Parse(typeof(TicketsState), originalState) != ticketEntity.Status)
                {
                    ticketEntity.PublishDate = DateTime.Now;
                }

                #endregion

                #region record history, when descr changed

                if (originalDesc != descr && ticketEntity.Status != TicketsState.Draft)
                {
                    TicketHistorysEntity history = new TicketHistorysEntity();
                    history.TicketID    = ticketEntity.TicketID;
                    history.ModifiedBy  = IdentityContext.UserID;
                    history.ModifiedOn  = DateTime.Now;
                    history.Description = originalDesc;

                    TicketApp.AddTicketHistory(history);
                }

                #endregion

                update = TicketApp.UpdateTickets(ticketEntity);

                #region send email
                if (IsSend)
                {
                    TicketStatusManagerApplication EX = new TicketStatusManagerApplication();
                    EX.SendEmailToQaAndDevWhenStatusChanged(ticketEntity);
                }
                #endregion

                #endregion

                #region file

                FilesEntity fileEntity = new FilesEntity();

                FolderName = ticketEntity.ProjectID.ToString();

                string sNewFileName = "";

                tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];

                string[] listStringName = imageList.Split(',');

                string[] listStringSize = imageSizeList.Split(',');

                foreach (string Name in listStringName)
                {
                    if (Name.Length == 0)
                    {
                        break;
                    }
                    string sExtension = Path.GetExtension(Name).Replace(".", "").Trim();
                    foreach (string Size in listStringSize)
                    {
                        sNewFileName           = FolderName + Name;
                        fileEntity.ContentType = "." + sExtension.ToLower();
                        fileEntity.CreatedBy   = IdentityContext.UserID;;
                        fileEntity.FilePath    = tempPath.Substring(2) + FolderName + @"/" + sNewFileName;
                        fileEntity.FileSize    = Convert.ToDecimal(Size.ToLower().Replace("kb", ""));
                        fileEntity.FileTitle   = Name.Substring(0, Name.LastIndexOf('.'));
                        fileEntity.IsPublic    = true;
                        fileEntity.TicketId    = tid;                                                           //ticketID
                        fileEntity.ProjectId   = pId;                                                           //ticketID
                        fileEntity.SourceType  = (int)FileSourceType.Ticket;
                        fileEntity.ThumbPath   = context.Server.MapPath(tempPath) + FolderName + sNewFileName;; //
                        fileEntity.CreatedOn   = DateTime.Now;
                        int responseFile = fileApp.AddFile(fileEntity);
                        if (responseFile <= 0)
                        {
                            HasFileMsG = false;
                            stringErrorMsg.Add(fileEntity.FileTitle);
                        }
                        break;
                    }
                }
                #endregion

                #region response
                if (update)
                {
                    if (HasFileMsG)
                    {
                        context.Response.Write("Update Ticket Success!");
                    }
                    else
                    {
                        string error = "";
                        foreach (string item in stringErrorMsg)
                        {
                            error += item + "File Upload Failed!";
                        }
                        context.Response.Write(error);
                    }
                }
                else
                {
                    context.Response.Write("Update Fail!");
                }
                #endregion
            }
            catch (Exception ex)
            {
                context.Response.Write("para error!");
                WebLogAgent.Write(string.Format("Error Ashx:DoEditTicketHandler.ashx Messages:\r\n{0}", ex));
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }
                int result = 0;
                #region getValue

                int    pId           = Convert.ToInt32(context.Request["pId"]);
                string tType         = context.Request["tType"];
                string ckbEn         = context.Request["ckbEn"];
                string pty           = context.Request["pty"];
                string title         = context.Request["title"];
                string url           = context.Request["url"];
                string description   = context.Request["descr"];
                string imageList     = context.Request["imageList"];
                string imageSizeList = context.Request["imageSizeList"];
                string StartDate     = context.Request["StartDate"];
                string DeliveryDate  = context.Request["DeliveryDate"];
                string satus         = context.Request["satus"];
                string IsSunnet      = context.Request["isSunnet"];
                string userlist      = context.Request["userlist"];

                #endregion

                UsersEntity    entity         = userApp.GetUser(IdentityContext.UserID);
                ProjectsEntity projectsEntity = projectApp.Get(pId);

                #region add ticket
                TicketsEntity ticketEntity = new TicketsEntity();
                pty = string.IsNullOrEmpty(pty) ? "1" : pty;
                ticketEntity.ProjectID       = pId;
                ticketEntity.CompanyID       = projectsEntity.CompanyID;
                ticketEntity.Priority        = (PriorityState)Convert.ToInt32(pty);
                ticketEntity.TicketType      = (TicketsType)Convert.ToInt32(tType);
                ticketEntity.Title           = title.NoHTML();
                ticketEntity.URL             = context.Server.UrlEncode(url);
                ticketEntity.FullDescription = description.NoHTML();
                ticketEntity.CreatedBy       = IdentityContext.UserID;
                ticketEntity.CreatedOn       = DateTime.Now;
                ticketEntity.ModifiedOn      = DateTime.Now;

                ticketEntity.IsEstimates   = ckbEn == "checked" ? true : false;
                ticketEntity.TicketCode    = new TicketsApplication().ConvertTicketTypeToTicketCode(ticketEntity.TicketType);
                ticketEntity.IsInternal    = IsSunnet == "true" ? true : false;
                ticketEntity.ModifiedBy    = 0;
                ticketEntity.PublishDate   = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                ticketEntity.ConvertDelete = CovertDeleteState.Normal;
                ticketEntity.Source        = entity.Role;
                if (IsSunnet == "true")
                {
                    ticketEntity.StartDate    = !string.IsNullOrEmpty(StartDate.ToString()) ? DateTime.Parse(StartDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                    ticketEntity.DeliveryDate = !string.IsNullOrEmpty(DeliveryDate.ToString()) ? DateTime.Parse(DeliveryDate).Date : UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                    if (entity.Role == RolesEnum.Supervisor)
                    {
                        ticketEntity.Status = TicketsState.Submitted;
                    }
                    else
                    {
                        ticketEntity.Status = TicketsState.PM_Reviewed;
                    }
                }
                else
                {
                    ticketEntity.StartDate    = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                    ticketEntity.DeliveryDate = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                    ticketEntity.Status       = satus == "0" ? TicketsState.Draft : TicketsState.Submitted;
                }

                result = ticketAPP.AddTickets(ticketEntity);

                if (result > 0)
                {
                    TicketUsersEntity ticketUserEntity = new TicketUsersEntity();
                    //add pm user
                    ticketUserEntity.Type     = TicketUsersType.PM;
                    ticketUserEntity.TicketID = result;
                    ProjectsEntity projectEntity = projectApp.Get(ticketEntity.ProjectID);
                    if (projectEntity != null)
                    {
                        ticketUserEntity.UserID = projectEntity.PMID;
                        ticketAPP.AddTicketUser(ticketUserEntity);
                    }
                    else
                    {
                        WebLogAgent.Write(string.Format("Add Pm To Ticket User Error:Project :{0},Ticket:{1},CreateDate:{2}",
                                                        ticketEntity.ProjectID, ticketEntity.TicketID, DateTime.Now));
                    }
                    //add create user
                    ticketUserEntity.Type     = TicketUsersType.Create;
                    ticketUserEntity.TicketID = result;
                    ticketUserEntity.UserID   = ticketEntity.CreatedBy;
                    ticketAPP.AddTicketUser(ticketUserEntity);
                }
                #endregion

                #region send email
                TicketStatusManagerApplication ex = new TicketStatusManagerApplication();
                if (!ticketEntity.IsInternal)
                {
                    ex.SendEmailToPMWhenTicketAdd(result, ticketEntity.TicketType);
                }

                #endregion

                #region add file

                FilesEntity fileEntity = new FilesEntity();

                if (null != projectsEntity)
                {
                    FolderName = projectsEntity.ProjectID.ToString();
                }

                string sNewFileName = "";

                tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];

                string[] listStringName = imageList.Split(',');

                string[] listStringSize = imageSizeList.Split(',');


                foreach (string Name in listStringName)
                {
                    if (Name.Length == 0)
                    {
                        break;
                    }
                    string sExtension = Path.GetExtension(Name).Replace(".", "").Trim();
                    foreach (string Size in listStringSize)
                    {
                        sNewFileName           = FolderName + Name;
                        fileEntity.ContentType = "." + sExtension.ToLower();
                        fileEntity.CreatedBy   = entity.UserID;
                        fileEntity.FilePath    = tempPath.Substring(2) + FolderName + @"/" + sNewFileName;
                        fileEntity.FileSize    = Convert.ToDecimal(Size.ToLower().Replace("kb", ""));
                        fileEntity.FileTitle   = Name.Substring(0, Name.LastIndexOf('.'));
                        fileEntity.IsPublic    = !ticketEntity.IsInternal;
                        fileEntity.ProjectId   = pId;
                        fileEntity.TicketId    = result;
                        fileEntity.CreatedOn   = DateTime.Now.Date;
                        fileEntity.FeedbackId  = 0;
                        fileEntity.SourceType  = (int)FileSourceType.Ticket;
                        fileEntity.ThumbPath   = context.Server.MapPath(tempPath) + FolderName + sNewFileName;;//
                        fileEntity.CompanyID   = IdentityContext.CompanyID;
                        int response = fileApp.AddFile(fileEntity);
                        if (response <= 0)
                        {
                            HasFileMsG = false;
                            stringErrorMsg.Add(fileEntity.FileTitle);
                        }
                        break;
                    }
                }

                #endregion

                #region response msg

                if (result > 0)
                {
                    if (HasFileMsG)
                    {
                        context.Response.Write("The ticket has been added.");
                    }
                    else
                    {
                        string error = "";
                        foreach (string item in stringErrorMsg)
                        {
                            error += item + "File Upload Failed!";
                        }
                        context.Response.Write(error);
                    }
                }
                else
                {
                    context.Response.Write("Add Fail!");
                }

                #endregion

                #region assign user and send email
                TicketUsersEntity tuEntity         = new TicketUsersEntity();;
                string[]          userWithRoleList = userlist.TrimEnd(',').Split(',');
                int assignResult = 0;
                if (userWithRoleList.Length > 0)
                {
                    foreach (string item in userWithRoleList)
                    {
                        if (item.Length > 0)
                        {
                            string[] userWithRole = item.Split('-');
                            if (userWithRole.Length > 0)
                            {
                                tuEntity.TicketID = result;
                                tuEntity.UserID   = Convert.ToInt32(userWithRole[0]);
                                tuEntity.Type     = GetUserTypeByRoleID(userWithRole[1]); //Convert.ToInt32(userWithRole[0]);
                                assignResult      = ticketAPP.AddTicketUser(tuEntity);
                                if (assignResult > 0)
                                {
                                    ex.SendEmailToAssignedUser(tuEntity);
                                }
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                context.Response.Write("Input special symbol is not allowed,please check title and description!");
                WebLogAgent.Write(string.Format("Error Ashx:DoAddTicketHandler.ashx Messages:\r\n{0}", ex));
                return;
            }
        }