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; } String statusValue = context.Request["statusValue"]; int tid = Convert.ToInt32(context.Request["tid"]); TicketsEntity ticketEntity = new TicketsEntity(); ticketEntity = ticketAPP.GetTickets(tid); TicketsState originalStatus = ticketEntity.Status; bool Update = true; bool isCompleteMsgInfo = false; if (statusValue == "pReview") { // if (HasDevOrQaUnderTicket(ticketEntity)) { ticketEntity.Status = TicketsState.PM_Reviewed; } else { context.Response.Write("696"); //context.Response.Write("Please assign user before you change status."); return; } } else if (statusValue == "pmReviewMaintenanceValidate") { ProjectApplication projectApplication = new ProjectApplication(); ProjectsEntity projectsEntity = projectApplication.Get(ticketEntity.ProjectID); if ((projectsEntity.MainPlanOption == UserMaintenancePlanOption.NO || projectsEntity.MainPlanOption == UserMaintenancePlanOption.NEEDAPPROVAL || projectsEntity.MainPlanOption == UserMaintenancePlanOption.ALLOWME) && ticketEntity.IsEstimates == false) { context.Response.Write("-1"); } else { context.Response.Write("1"); } return; } else if (statusValue == "approve") { isCompleteMsgInfo = true; ticketEntity.Status = TicketsState.Completed; } else if (statusValue == "deny") { ticketEntity.Status = TicketsState.Not_Approved; } else if (statusValue == "estApp") { ticketEntity.Status = TicketsState.Estimation_Approved; } else if (statusValue == "estDeny") { ticketEntity.Status = TicketsState.Estimation_Fail; } else if (statusValue == "notBug") { ticketEntity.ConvertDelete = CovertDeleteState.NotABug; } else if (statusValue == "isBug") { ticketEntity.ConvertDelete = CovertDeleteState.Normal; notSendEmail = true; } else if (statusValue == "toEs") { ticketEntity.IsEstimates = true; ChangeToEs = false; } else if (statusValue == "toNotEs") { ticketEntity.IsEstimates = false; } bool IsPass = true; #region //validate if (statusArray.Contains(statusValue)) { if (!BaseValidate(originalStatus, ticketEntity.Status)) { IsPass = false; } } else { if (!NostatusArray.Contains(statusValue)) { if (BaseValidate(originalStatus, (TicketsState)Enum.Parse(typeof(TicketsState), statusValue))) { ticketEntity.Status = (TicketsState)Enum.Parse(typeof(TicketsState), statusValue); } else { IsPass = false; } } } if (!IsPass) { context.Response.Write("same"); return; } #endregion ticketEntity.ModifiedOn = DateTime.Now; ticketEntity.ModifiedBy = IdentityContext.UserID; ticketEntity.PublishDate = DateTime.Now.Date; Update = ticketAPP.UpdateTickets(ticketEntity); #region send email if (!notSendEmail) { if (ChangeToEs) { ticketStatusMgr.SendEmailToSalerWithStatusToEs(ticketEntity); } else { if (statusValue == "notBug") { ticketStatusMgr.SendEmailToAllUserUnderProjectWithNotABug(ticketEntity); } else if (ticketEntity.Status == TicketsState.Ready_For_Review) { ticketStatusMgr.SendEmailtoClientForVerify(ticketEntity); } else if (ticketEntity.Status == TicketsState.Not_Approved) { ticketStatusMgr.SendEmailWithClientNotApp(ticketEntity); } else if (ticketEntity.Status == TicketsState.Waiting_For_Estimation) { ticketStatusMgr.SendEmailToAssignedUserTs(ticketEntity); } else if (ticketEntity.Status == TicketsState.Waiting_Sales_Confirm) { ticketStatusMgr.SendEmailToSalerWithStatusToEs(ticketEntity); } else if (ticketEntity.Status == TicketsState.Tested_Fail_On_Local || ticketEntity.Status == TicketsState.Testing_On_Local || ticketEntity.Status == TicketsState.Tested_Success_On_Local || ticketEntity.Status == TicketsState.Tested_Fail_On_Client || ticketEntity.Status == TicketsState.Testing_On_Client || ticketEntity.Status == TicketsState.Tested_Success_On_Client || ticketEntity.Status == TicketsState.Cancelled) { ticketStatusMgr.SendEmailToUserWithSpecStatus(ticketEntity); if (ticketEntity.Status == TicketsState.Tested_Success_On_Client) { ticketStatusMgr.SendEmailToUserWithTestRSuccToPm(ticketEntity); } } else { if (ticketEntity.Status != TicketsState.Developing) { ticketStatusMgr.SendEmailToQaAndDevWhenStatusChanged(ticketEntity); } } } } #endregion if (Update) { if (statusValue == "notBug") { context.Response.Write("Question sent, please wait for PM to verify."); } else { if (isCompleteMsgInfo) { context.Response.Write("The ticket has been approved."); } else { context.Response.Write("The ticket’s status has been updated."); } } } else { context.Response.Write("Update ticket’s status fail."); } } catch (Exception ex) { context.Response.Write("para error!" + ex.Message); WebLogAgent.Write(string.Format("Error Ashx:DoUpdateTicketStatus.ashx Messages:\r\n{0}", ex)); return; } }