Ejemplo n.º 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
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 3
0
        protected void SendEamil(TicketsEntity te, UsersEntity createUser)
        {
            TicketStatusManagerApplication ex = new TicketStatusManagerApplication();

            ex.SendEmailToPMWhenTicketAdd(te, UserInfo);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// save : 1:save ; 2:draft ;3 save and new
        /// </summary>
        /// <param name="save"></param>
        private void SaveTicket(int save)
        {
            ProjectsEntity projectsEntity = new ProjectApplication().Get(int.Parse(ddlProject.SelectedValue));
            TicketsEntity  ticketsEntity  = GetEntity(save, projectsEntity.ProjectID, projectsEntity.CompanyID);

            int result = new TicketsApplication().AddTickets(ticketsEntity);

            if (result > 0)
            {
                ticketsEntity.TicketID = result;
                List <int> userIds;

                AddDefaultTicketUsers(projectsEntity, ticketsEntity, result, out userIds);
                AssignTicketUsers(ticketsEntity, userIds);
                AddIniHistroy(ticketsEntity);

                if (rdoShareKnowlege.Checked)
                {
                    ShareEntity shareEntity = new ShareEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());
                    int         type        = 0;
                    shareEntity.Title            = ticketsEntity.Title;
                    shareEntity.Note             = ticketsEntity.FullDescription;
                    shareEntity.Type             = type;
                    shareEntity.TicketID         = result;
                    shareEntity.TypeEntity.Title = ticketsEntity.Title;
                    _shareApp.Save(shareEntity);
                }

                if (!ticketsEntity.IsInternal)
                {
                    new SendHandler(() => ex.SendEmailToPMWhenTicketAdd(ticketsEntity, UserInfo))
                    .BeginInvoke(null, null);
                }

                string fileName = hidUploadFile.Value;

                if (fileName.Trim() != string.Empty)
                {
                    string[] files = fileName.Split('|');
                    foreach (string str in files)
                    {
                        InsertFile(str, ticketsEntity.ProjectID, result, ticketsEntity.CompanyID);
                    }
                }
                ProposalTrackerRelationEntity model = new ProposalTrackerRelationEntity();
                if (hid_Proposal.Value != "")
                {
                    model.CreatedBy = IdentityContext.UserID;
                    model.TID       = ticketsEntity.TicketID;
                    model.WID       = int.Parse(this.hid_Proposal.Value);
                    wrApp.AddProposalTrackerRelation(model);
                }


                switch (save)
                {
                case 1:
                    Redirect("/SunnetTicket/Index.aspx", true);
                    break;

                case 3:
                    Redirect("/SunnetTicket/New.aspx?project=" + ddlProject.SelectedValue, true);
                    break;
                }
            }
            else
            {
                ShowFailMessageToClient();
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }