Esempio n. 1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int ticketID = QS("tid", 0);

            if (ticketID != 0)
            {
                bool isSuccess = UpdateTicketStatusToDeny(ticketID);
                if (isSuccess)
                {
                    if (txtDescription.Text.Trim() != "" || (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0))
                    {
                        FeedBacksEntity feedbacksEntity = new FeedBacksEntity();
                        feedbacksEntity.IsDelete           = false;
                        feedbacksEntity.TicketID           = ticketID;
                        feedbacksEntity.Title              = "";
                        feedbacksEntity.Description        = txtDescription.Text.Trim().NoHTML();
                        feedbacksEntity.CreatedBy          = UserInfo.UserID;
                        feedbacksEntity.CreatedOn          = DateTime.Now;
                        feedbacksEntity.ModifiedOn         = DateTime.Now;
                        feedbacksEntity.IsPublic           = true;
                        feedbacksEntity.WaitClientFeedback = FeedbackReplyStatus.Normal;
                        feedbacksEntity.WaitPMFeedback     = FeedbackReplyStatus.Normal;

                        feedbacksEntity.ID = fbAPP.AddFeedBacks(feedbacksEntity);

                        if (feedbacksEntity.ID <= 0)
                        {
                            ShowFailMessageToClient();
                            return;
                        }
                        ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity);//状态更新不进行跟新气泡,by dave 2017/09/22

                        //if (ticketAPP.CreateNotification(ticketID,UserInfo.UserID))
                        //{
                        //    //发邮件给PM
                        //    ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity);
                        //}

                        HttpFileCollection files            = Request.Files;
                        string             fileuploadErrMsg = string.Empty;
                        TicketsEntity      ticketsEntity    = new TicketsApplication().GetTickets(feedbacksEntity.TicketID);
                        for (int i = 0; i < files.Count; i++)
                        {
                            if (files[i].ContentLength > 0 && IsValidFile(files[i].FileName))
                            {
                                if (!InsertFile(files[i], ticketsEntity.ProjectID, feedbacksEntity.TicketID, feedbacksEntity.IsPublic, feedbacksEntity.ID))
                                {
                                    fileuploadErrMsg += files[i].FileName + " Upload failed.";
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(fileuploadErrMsg))
                        {
                            ShowFailMessageToClient(fileuploadErrMsg);
                            return;
                        }
                    }

                    string returnurl = Request.QueryString["returnurl"];
                    if (string.IsNullOrEmpty(returnurl))
                    {
                        Redirect(Request.RawUrl, false, true);
                    }
                    else
                    {
                        ParentToUrl(returnurl);
                    }
                }
                else
                {
                    ShowFailMessageToClient("Update ticket’s status fail.");
                }
            }
            else
            {
                ShowFailMessageToClient("Update ticket’s status fail.");
            }
        }
Esempio n. 2
0
        public string AddFeedback(int projectID, int ticketID, string content, bool isPublic, bool isWaitClient,
                                  bool isWaitSunnetFeedback, string file, string clientsIds, HttpServerUtility Server)
        {
            try
            {
                ProjectsEntity  ProjectEntity   = projectApp.Get(projectID);
                FeedBacksEntity feedbacksEntity = GetFeedbacksEntity(ticketID, content, isPublic, isWaitClient, isWaitSunnetFeedback);
                TicketsEntity   ticket          = ticketApp.GetTickets(ticketID);

                var canAddWaiting = ticketApp.CanFeedbackWaiting(ticketID);
                if (!canAddWaiting)
                {
                    feedbacksEntity.WaitPMFeedback = feedbacksEntity.WaitClientFeedback = FeedbackReplyStatus.Normal;
                }

                string fileuploadErrMsg = string.Empty;

                feedbacksEntity.ID = fbAPP.AddFeedBacks(feedbacksEntity);
                if (feedbacksEntity.ID <= 0)
                {
                    var msg = fbAPP.BrokenRuleMessages != null && fbAPP.BrokenRuleMessages.Count > 0
                        ? fbAPP.BrokenRuleMessages[0].Message
                        : "";
                    return(ResponseMessage.GetResponse(false, msg));
                }

                // 产生气泡提示
                if (UserInfo.Role == RolesEnum.CLIENT || isPublic)
                {
                    ticketApp.CreateNotification(ticketID, UserInfo.UserID, false);
                }
                else
                {
                    ticketApp.CreateNotification(ticketID, UserInfo.UserID);
                }

                var extraStatus = new Dictionary <string, bool>();
                // 在添加FeedbackMessage时要更新Ticket 对相关人员的状态, 并且不能覆盖状态

                if (ticket.Status != TicketsState.Wait_Sunnet_Feedback &&
                    ticket.Status != TicketsState.Wait_Client_Feedback &&
                    canAddWaiting)
                {
                    if ((UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.Sales) && isWaitClient)
                    {
                        ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitClientFeedback, UserID);
                        extraStatus.Add("waitSunnet", ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitClientFeedback, TicketUsersType.Create));
                        new SendHandler(() => ticketStatusMgr.SendEmailtoClientForFeedBack(feedbacksEntity))
                        .BeginInvoke(null, null);

                        ProcessOtherClients(clientsIds, ticketID);
                    }
                    else if (UserInfo.Role == RolesEnum.CLIENT)
                    {
                        if (isWaitSunnetFeedback)
                        {
                            ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitSunnetFeedback, UserID);
                            extraStatus.Add("waitClient", ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.WaitSunnetFeedback, TicketUsersType.PM));
                        }
                        new SendHandler(() => ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity))
                        .BeginInvoke(null, null);
                    }
                }
                else
                {
                    // 相关状态人员可以通过回复清除自己的状态标识
                    if ((UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.Sales) && ticket.Status == TicketsState.Wait_Sunnet_Feedback && isPublic)
                    {
                        // Sunnet 直接清除PM的标识
                        if (ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal, TicketUsersType.PM) &&
                            fbAPP.ReplyFeedback(ticketID, true, false))
                        {
                            ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal, TicketUsersType.Create,
                                                         TicketUsersType.Client);
                            ticket.ResponsibleUser = PmReplyClient(ProjectEntity, ticket);
                            extraStatus.Add("clearSunnet", true);
                            var createrId = ticketApp.GetTicketCreateUser(ticketID);
                            var creater   = _userApp.GetUser(createrId.UserID);
                            new SendHandler(() => ticketStatusMgr.SendEmailFeedbackReplied(UserInfo, creater, ticketID))
                            .BeginInvoke(null, null);
                        }
                    }
                    if (UserInfo.Role == RolesEnum.CLIENT && ticket.Status == TicketsState.Wait_Client_Feedback)
                    {
                        // 客户方面只能清除自己的标识,因为可能需要多个客户回复
                        if (ticketApp.TryClearWaiting(ticketID, UserID, TicketUsersType.Create, TicketUsersType.Client) &&
                            fbAPP.ReplyFeedback(ticketID, false, true))
                        {
                            ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal, TicketUsersType.PM);
                            extraStatus.Add("clearClient", true);
                            var pmId = ticketApp.GetTicketPM(ticketID);
                            var pm   = _userApp.GetUser(pmId.UserID);
                            new SendHandler(() => ticketStatusMgr.SendEmailFeedbackReplied(UserInfo, pm, ticketID))
                            .BeginInvoke(null, null);

                            ticketApp.DeleteUserFromTicket(ticketID, TicketUsersType.Client);
                        }
                    }
                }
                ticket.ModifiedOn = DateTime.Now;
                if (UserInfo.Role == RolesEnum.CLIENT && isWaitSunnetFeedback)
                {
                    ChangeResponsUserToProjectManager(ProjectEntity, ticket);
                }

                ticketApp.UpdateTickets(ticket, false);

                #region add file

                int      fileID       = 0;
                string   realFileName = "";
                string[] files        = file.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                Dictionary <string, int> uploadedFiles = new Dictionary <string, int>();
                foreach (var f in files)
                {
                    if ((fileID =
                             InsertFile(f, ProjectEntity.ProjectID, ticketID, feedbacksEntity.IsPublic,
                                        feedbacksEntity.ID, Server, out realFileName)) < 1)
                    {
                        fileuploadErrMsg += realFileName + " Upload failed.";
                    }
                    uploadedFiles.Add(realFileName, fileID);
                }

                #endregion

                if (string.IsNullOrEmpty(fileuploadErrMsg))
                {
                    ResponseMessage response = new ResponseMessage();
                    response.Success = true;

                    object attachement          = null;
                    object attachementBasicInfo = null;
                    if (uploadedFiles.Count > 0)
                    {
                        attachement = uploadedFiles;
                        string[] imgFormat = ".gif,.jpg,.jpeg,.bmp,.png,.svg,.raw".Split(new char[] { ',' });
                        attachementBasicInfo = uploadedFiles.Select(it => new
                        {
                            Key   = it.Key,
                            Value = imgFormat.Any(format => format == Path.GetExtension(it.Key.ToLower())) ? fileApp.Get(it.Value).FilePath : "/Images/icons/file.png"
                        }).ToDictionary(it => it.Key, it => it.Value);
                    }

                    feedbacksEntity.Description = new HtmlHelper().ReplaceUrl(feedbacksEntity.Description);

                    response.Data = new
                    {
                        content     = feedback.FormatHTML(feedbacksEntity.Description, Server).Replace("\n", "<br/>"),
                        id          = feedbacksEntity.ID,
                        date        = feedbacksEntity.CreatedOn.ToString("MM/dd/yyyy"),
                        time        = feedbacksEntity.CreatedOn.ToString("hh:mm tt"),
                        order       = feedbacksEntity.Order,
                        createdBy   = feedbacksEntity.CreatedBy,
                        firstname   = UserInfo.FirstName,
                        lastname    = UserInfo.LastName,
                        file        = attachement,
                        basicInfo   = attachementBasicInfo,
                        extraStatus = extraStatus,
                        tdCss       = feedbacksEntity.IsPublic && UserInfo.Role == RolesEnum.PM ? "fdcontentBox3" : "fdcontentBox2"
                    };

                    return(response.ToString());
                }
                else
                {
                    return(ResponseMessage.GetResponse(false, fileuploadErrMsg));
                }
            }
            catch (Exception ex)
            {
                WebLogAgent.Write(string.Format("Error Ascx:FeedbackList.ascx Messages:\r\n{0}", ex));
                return(ResponseMessage.GetResponse(false, ex.Message));
            }
        }
Esempio n. 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //添加ticket的Rating, 和Feedback
            int star;

            if (!int.TryParse(hdStar.Value, out star))
            {
                star = 0;
            }
            int ticketID = QS("tid", 0);

            if (ticketID != 0)
            {
                TicketsApplication ticketsApplication = new TicketsApplication();
                if (ticketsApplication.UpdateTicketStar(ticketID, star))
                {
                    //添加Feedback
                    bool isSuccess = UpdateTicketStatusToApprove(ticketID);

                    if (isSuccess)
                    {
                        if (txtFeedback.Text.Trim() != string.Empty)
                        {
                            FeedBacksEntity feedbacksEntity = new FeedBacksEntity();
                            feedbacksEntity.IsDelete           = false;
                            feedbacksEntity.TicketID           = ticketID;
                            feedbacksEntity.Title              = "";
                            feedbacksEntity.Description        = txtFeedback.Text.NoHTML();
                            feedbacksEntity.CreatedBy          = UserInfo.UserID;
                            feedbacksEntity.CreatedOn          = DateTime.Now;
                            feedbacksEntity.ModifiedOn         = DateTime.Now;
                            feedbacksEntity.IsPublic           = true;
                            feedbacksEntity.WaitClientFeedback = FeedbackReplyStatus.Normal;
                            feedbacksEntity.WaitPMFeedback     = FeedbackReplyStatus.Normal;

                            feedbacksEntity.ID = fbAPP.AddFeedBacks(feedbacksEntity);

                            if (feedbacksEntity.ID <= 0)
                            {
                                ShowFailMessageToClient();
                                return;
                            }
                            ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity);//状态更新,不进行刷新气泡
                            //if (ticketAPP.CreateNotification(ticketID,UserInfo.UserID))
                            //{
                            //    //发邮件给PM
                            //    ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity);
                            //}
                        }

                        string returnurl = Request.QueryString["returnurl"];
                        if (string.IsNullOrEmpty(returnurl))
                        {
                            Redirect(Request.RawUrl, false, true);
                        }
                        else
                        {
                            ParentToUrl(returnurl);
                        }
                    }
                    else
                    {
                        ShowFailMessageToClient("Update ticket’s status fail.");
                    }
                }
            }
            else
            {
                ShowFailMessageToClient("Update ticket’s status fail.");
            }
        }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            FeedBacksEntity feedbacksEntity = new FeedBacksEntity();

            feedbacksEntity.IsDelete    = false;
            feedbacksEntity.TicketID    = int.Parse(hdTicketID.Value);
            feedbacksEntity.Title       = NoHTML(txtTitle.Value);
            feedbacksEntity.Description = txtContent.Value;
            feedbacksEntity.CreatedBy   = UserInfo.UserID;
            feedbacksEntity.CreatedOn   = DateTime.Now;
            feedbacksEntity.ModifiedOn  = DateTime.Now;
            //如果是Client则IsPublic为true, 否则就看IsPublic Checkbox是否有选中。
            feedbacksEntity.IsPublic           = UserInfo.Role == RolesEnum.CLIENT ? true : ckIsPublic.Checked;
            feedbacksEntity.WaitClientFeedback = chkIsWaitClientFeedback.Checked ? 1 : 0;
            feedbacksEntity.WaitPMFeedback     = 0;
            if (feedbacksEntity.WaitClientFeedback > 0)
            {
                feedbacksEntity.IsPublic = true;
            }

            feedbacksEntity.ID = fbAPP.AddFeedBacks(feedbacksEntity);

            if (feedbacksEntity.ID <= 0)
            {
                ShowFailMessageToClient();
                return;
            }

            if (QS("feedbackId", 0) > 0) //回复
            {
                FeedBacksEntity entity = fbAPP.GetFeedBacksEntity(QS("feedbackId", 0));
                if (entity.WaitClientFeedback == 1)  //删除通知Client回复的消息,并且将 需要回复的 Feedbacks标记为已回复
                {
                    fbmApp.DeleteClientFeedback(feedbacksEntity.CreatedBy, entity.TicketID, entity.FeedBackID);
                }
            }

            if (fbmApp.Add(feedbacksEntity)) //feedbackmessages
            {
                if (feedbacksEntity.WaitClientFeedback > 0 ||
                    (feedbacksEntity.WaitClientFeedback <= 0 &&
                     feedbacksEntity.IsPublic)) //发邮件通知 PM
                {
                    //发邮件给PM
                    ticketStatusMgr.SendEmailtoPMForFeedBack(feedbacksEntity);
                }
            }


            if (fileUpload.PostedFile.ContentLength > 0)
            {
                string FolderName = string.Empty;
                FolderName = hdProjectID.Value;
                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}", feedbacksEntity.ID, DateTime.Now.ToString("yyMMddssmm"), fileExtension);

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

                FilesEntity fileEntity = new FilesEntity();

                fileEntity.ContentType = fileExtension.ToLower();
                fileEntity.CreatedBy   = UserInfo.UserID;
                fileEntity.FilePath    = filderPath.Substring(2) + FolderName + @"/" + sNewFileName;
                fileEntity.FileSize    = fileUpload.PostedFile.ContentLength;
                fileEntity.FileTitle   = filename.Substring(0, filename.LastIndexOf('.'));
                fileEntity.IsPublic    = true;
                fileEntity.ProjectId   = int.Parse(hdProjectID.Value);
                fileEntity.TicketId    = int.Parse(hdTicketID.Value);
                fileEntity.CreatedOn   = DateTime.Now.Date;
                fileEntity.FeedbackId  = feedbacksEntity.ID;
                fileEntity.SourceType  = (int)FileSourceType.FeedBack;
                fileEntity.ThumbPath   = "";
                fileEntity.CompanyID   = ticketsApp.GetCompanyIdByTicketId(int.Parse(hdTicketID.Value));
                int response = new FileApplication().AddFile(fileEntity);
            }
            ShowSuccessMessageToClient(true, true);
        }