Ejemplo n.º 1
0
        private void SetEditClient(TicketUsersEntity ticketUsersEntity)
        {
            if (ticketsEntity.IsInternal == true)
            {
                dvClient.Visible = false;
            }
            else
            {
                List <UsersEntity> clientUsers = projApp.GetPojectClientUsers(ticketsEntity.ProjectID,
                                                                              projApp.Get(ticketsEntity.ProjectID).CompanyID);

                ddlClient.DataSource = clientUsers;

                ddlClient.DataBind();

                clientUsers.BindDropdown(ddlClient, UserNameDisplayProp, "UserID", "Please select...", "-1");
                if (null == ticketUsersEntity || userApp.GetUser(ticketUsersEntity.UserID).Role != RolesEnum.CLIENT)
                {
                    ddlClient.SelectedValue = "-1";
                }
                else
                {
                    ddlClient.SelectedValue = ticketUsersEntity.UserID.ToString();
                }
                //找一下ticket的createuser是不是Client
                //如果是则选中这个client
                //否则选择please select
                dvClient.Visible = true;
            }
        }
Ejemplo n.º 2
0
        private void InitControls()
        {
            InitPM();
            InitCompany();

            int            id    = QS("id", 0);
            ProjectsEntity model = projApp.Get(id);

            if (model == null)
            {
                this.ShowFailMessageToClient(projApp.BrokenRuleMessages, true);
            }
            else
            {
                rblBillable.SelectedValue = model.Billable.ToString().ToLower();
                chkBugNeedApprove.Checked = model.BugNeedApproved;
                ddlCompany.SelectedValue  = model.CompanyID.ToString();
                ddlCompany.Enabled        = false;
                txtDesc.Text     = model.Description;
                txtEndDate.Text  = model.EndDate.ToString("MM/dd/yyyy");
                txtFreeHour.Text = model.FreeHour.ToString();
                ltlFreeHour.Text = model.FreeHour.ToString();
                if (UserInfo.Role == RolesEnum.Sales)
                {
                    ltlFreeHour.Visible = false;
                }
                else
                {
                    txtFreeHour.Visible = false;
                }
                ltlFreeHourText.Text = model.IsOverFreeTime ? "<font color='red'>The project has been over free hour</font>" : "The project hasn't been over free hour";

                if (null == ddlPM.Items.FindByValue(model.PMID.ToString()))
                {
                    UsersEntity usersEntity = new UserApplication().GetUser(model.PMID);
                    ddlPM.Items.Add(new ListItem()
                    {
                        Text = string.Format("{0} {1}", usersEntity.FirstName, usersEntity.LastName), Value = usersEntity.UserID.ToString()
                    });
                }
                ddlPM.SelectedValue           = model.PMID.ToString();
                ddlPriority.SelectedValue     = model.Priority;
                txtProjectCode.Text           = model.ProjectCode;
                chkRequestNeedApprove.Checked = model.RequestNeedApproved;
                txtStartDate.Text             = model.StartDate.ToString("MM/dd/yyyy");
                ddlStatus.SelectedValue       = model.Status.ToString();
                txtTestUrl.Text      = model.TestLinkURL;
                txtTestPassword.Text = model.TestPassword;
                txtTestUserName.Text = model.TestUserName;
                txtTitle.Text        = model.Title;
                this.ClientMaintenancePlan1.TotalHours         = model.TotalHours;
                this.ClientMaintenancePlan1.RemainHours        = model.TotalHours - GetRemainHours(id);
                ClientMaintenancePlan1.SelectedMaintenancePlan = model.MainPlanOption;
                InitSunnetUsers();
                InitFiles();
                InitUsers();
                InitPrincipal();
            }
        }
Ejemplo n.º 3
0
        public string DeleteFeedback(int userID, int feedbackID, int ticketID)
        {
            if (userID != UserID)
            {
                return(ResponseMessage.GetResponse(false, "Unauthorized operation.", 0));
            }
            if (feedbackID == 0)
            {
                return(ResponseMessage.GetResponse(false, "Arguments error.", 0));
            }
            FeedBackApplication feedBackApplication = new FeedBackApplication();

            //先判定feedback是不是public然后判断是不是wait client==1或waitpm ==1如果是并且ticket状态不为normal则改为normal
            FeedBacksEntity feedBacksEntity = feedBackApplication.GetFeedBacksEntity(feedbackID);

            if (feedBacksEntity.WaitClientFeedback == FeedbackReplyStatus.Requested)
            {
                ticketApp.ClearWaitingByType(ticketID, TicketUsersType.Create, TicketUsersType.Client, TicketUsersType.PM);
                ticketApp.DeleteUserFromTicket(ticketID, TicketUsersType.Client);
            }
            if (feedBacksEntity.WaitPMFeedback == FeedbackReplyStatus.Requested)
            {
                var ticketEntity  = ticketApp.GetTickets(ticketID);
                var projectEntity = projectApp.Get(ticketEntity.ProjectID);
                if (ticketApp.UpdateTicketStatus(ticketID, UserTicketStatus.Normal,
                                                 TicketUsersType.PM, TicketUsersType.Create, TicketUsersType.Client))
                {
                    ticketEntity.ResponsibleUser = PmReplyClient(projectEntity, ticketEntity);
                    ticketApp.UpdateTickets(ticketEntity, false);
                }
            }

            //再删除feedbackmessage,并且feedback状态不为normal则改为normal
            bool result = feedBackApplication.DeleteFeedback(feedbackID);

            if (result)
            {
                return(ResponseMessage.GetResponse(true));
            }
            else
            {
                var tmpMessage = feedBackApplication.BrokenRuleMessages != null &&
                                 feedBackApplication.BrokenRuleMessages.Count > 0
                    ? feedBackApplication.BrokenRuleMessages[0].Message
                    : "";
                return(ResponseMessage.GetResponse(false, tmpMessage));
            }
        }
Ejemplo n.º 4
0
        public bool UpdateTicketStatusToDeny(int ticketId)
        {
            try
            {
                if (UserInfo.UserID <= 0)
                {
                    return(false);
                }
                TicketsEntity ticketEntity = new TicketsEntity();

                ticketEntity = ticketAPP.GetTickets(ticketId);

                TicketsState originalStatus = ticketEntity.Status;
                bool         Update         = true;
                ticketEntity.Status = TicketsState.Not_Approved;

                ticketEntity.ModifiedOn  = DateTime.Now;
                ticketEntity.ModifiedBy  = UserInfo.UserID;
                ticketEntity.PublishDate = DateTime.Now.Date;
                ProjectsEntity projectEntity = projectApp.Get(ticketEntity.ProjectID);

                Update = ticketAPP.UpdateTickets(ticketEntity, true, projectEntity.PMID);
                ticketStatusMgr.SendEmailWithClientNotApp(ticketEntity);

                return(Update);
            }
            catch (Exception ex)
            {
                WebLogAgent.Write(string.Format("Error Ashx:DoUpdateTicketStatus.ashx Messages:\r\n{0}", ex));
                return(false);
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }
                String tType = context.Request["tType"];
                String pId   = context.Request["pId"];

                ProjectsEntity project = projectAPP.Get(Convert.ToInt32(pId));
                if (null != project)
                {
                    if ((tType == "0" && project.BugNeedApproved == true) ||
                        (tType == "1" && project.RequestNeedApproved == true))
                    {
                        context.Response.Write("true");
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("para error!");
                WebLogAgent.Write(string.Format("Error Ashx:DoUpdateEnStatus.ashx Messages:\r\n{0}", ex));
                return;
            }
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ((Pop)this.Master).Width = 450;
            TicketID      = QS("tid", 0);
            _ticketEntity = ticketApp.GetTickets(TicketID);

            if (!IsPostBack)
            {
                if (_ticketEntity != null)
                {
                    litHead.Text = "Ticket ID: " + _ticketEntity.TicketID + ", " + _ticketEntity.Title;

                    if (_ticketEntity.Status == TicketsState.Waiting_Confirm)
                    {
                        ltrlFinalTime.Text = _ticketEntity.FinalTime.ToString() + " hour(s)";
                    }

                    ddlClient.DataSource = projApp.GetPojectClientUsers(_ticketEntity.ProjectID, projApp.Get(_ticketEntity.ProjectID).CompanyID);
                    ddlClient.DataBind();

                    ListItem li = ddlClient.Items.FindByValue(_ticketEntity.ConfirmEstmateUserId.ToString());
                    if (li != null)
                    {
                        li.Selected = true;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void InitProject()
        {
            ProjectApplication projApp = new ProjectApplication();

            List <ProjectDetailDTO> list = projApp.GetUserProjects(UserInfo);

            if (!string.IsNullOrEmpty(WorkRequestID))
            {
                WorkRequestEntity workRequestEntity = wqApp.Get(int.Parse(WorkRequestID));
                ProjectsEntity    projectsEntity    = projApp.Get(workRequestEntity.ProjectID);
                if (!projApp.IsProjectHasPM(projectsEntity.ProjectID, UserInfo.UserID))
                {
                    list.Add(new ProjectDetailDTO()
                    {
                        Title = projectsEntity.Title, ID = projectsEntity.ProjectID
                    });
                }
            }
            if (list.Count > 1 || list.Count == 0)
            {
                list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ID", "Please select...", "0");
            }
            else if (list.Count == 1)
            {
                list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ID");
            }
        }
Ejemplo n.º 8
0
        private string GetPath(int projectId, int parentId)
        {
            string             projectTitle  = "";
            ProjectApplication projectApp    = new ProjectApplication();
            ProjectsEntity     projectEntity = projectApp.Get(projectId);

            if (projectEntity != null)
            {
                projectTitle = projectEntity.Title;
            }
            else
            {
                projectTitle = "My Document";
            }
            string folderPath = string.Empty;
            List <DocManagementEntity> docList = business.GetList(projectId, "");

            if (parentId != 0)
            {
                GetFolderName(docList, parentId);
            }
            for (int i = folderList.Count - 1; i >= 0; i--)
            {
                folderPath += folderList[i];
            }
            return("> " + projectTitle + @"\" + folderPath);
        }
Ejemplo n.º 9
0
        protected void btnAgree_Click(object sender, EventArgs e)
        {
            int oldResponsibleUserId = _ticketEntity.ResponsibleUser;

            _ticketEntity.Status          = TicketsState.Estimation_Approved;
            _ticketEntity.ModifiedBy      = UserInfo.UserID;
            _ticketEntity.ModifiedOn      = DateTime.Now;
            _ticketEntity.ResponsibleUser = int.Parse(ddlResponsibleUser.SelectedValue);

            ProjectsEntity projectEntity = projApp.Get(_ticketEntity.ProjectID);

            bool result = ticketApp.UpdateTickets(_ticketEntity, true, projectEntity.PMID);

            //sent email to responsible user 2017/10/23
            if (oldResponsibleUserId != _ticketEntity.ResponsibleUser)
            {
                ticketApp.SendEmailToResponsibile(_ticketEntity, UserInfo);
            }
            if (result)
            {
                Redirect(EmptyPopPageUrl, false, true);
            }
            else
            {
                ShowFailMessageToClient(ticketApp.BrokenRuleMessages);
            }
        }
Ejemplo n.º 10
0
        private void SendEmailForUploading(int projectId, int userId, string fileDescription, string filePath)
        {
            if (projectId == 0)
            {
                return;
            }
            UserApplication    userApp     = new UserApplication();
            ProjectApplication projectApp  = new ProjectApplication();
            UsersEntity        usersEntity = userApp.GetUser(userId);

            //发邮件的角色必须是Client或PM
            if (usersEntity.Role != RolesEnum.CLIENT && usersEntity.Role != RolesEnum.PM && usersEntity.Status == Status.Active.ToString().ToUpper())
            {
                return;
            }

            ProjectsEntity projectEntity = projectApp.Get(projectId);
            IEmailSender   smtpClient    = new SmtpClientEmailSender(new TextFileLogger());

            //邮件参数初始化
            string contentTemplete = GetEmailTemplate("SendEmailToCilentAndPMWhenUploading.txt").Trim();

            if (!string.IsNullOrEmpty(contentTemplete))
            {
                contentTemplete = contentTemplete.Replace("[UploadUser]", usersEntity.FirstName)
                                  .Replace("[ProjectTitle]", projectEntity.Title)
                                  .Replace("[DateTime]", DateTime.Now.ToString("MM/dd/yyyy HH:mm"))
                                  .Replace("[FileDescription]", fileDescription)
                                  .Replace("[FilePath]", filePath);
            }
            string to      = string.Empty;
            string subject = string.Format("Notice - {0} uploaded a file or some files ", usersEntity.FirstName);

            List <int> userIdList = projectApp.GetActiveUserIdByProjectId(projectId);

            if (userIdList != null && userIdList.Count > 0)
            {
                userIdList.RemoveAll(o => o == userId);
                foreach (int item in userIdList)
                {
                    var userItem = userApp.GetUser(item);
                    if (userItem.Role == RolesEnum.CLIENT || userItem.Role == RolesEnum.PM)
                    {
                        to = userItem.Email;
                        if (!string.IsNullOrEmpty(contentTemplete))
                        {
                            string content = contentTemplete.Replace("[FirstName]", userItem.FirstName)
                                             .Replace("[LastName]", userItem.LastName);
                            smtpClient.SendMail(to, subject, content, false, MailPriority.Normal);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Expires     = -1;
            try
            {
                string FolderName = "";

                string pid = context.Request["pid"];//get project id

                ProjectsEntity entity = projectApp.Get(Convert.ToInt32(pid));

                if (null != entity)
                {
                    FolderName = entity.ProjectID.ToString();
                }
                else
                {
                    context.Response.StatusCode        = 500;
                    context.Response.StatusDescription = "ss";
                    return;
                }

                HttpPostedFile postedFile = context.Request.Files["Filedata"];

                string savepath = "";
                string tempPath = "";
                tempPath = System.Configuration.ConfigurationManager.AppSettings["FolderPath"];
                savepath = context.Server.MapPath(tempPath) + FolderName;
                string filename   = postedFile.FileName;
                string sExtension = Path.GetExtension(filename);

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

                string sNewFileName = FolderName + filename;//DateTime.Now.ToString("yyyyMMddhhmmsfff");
                if (File.Exists(savepath + @"\" + sNewFileName))
                {
                    context.Response.Write("0");
                    return;
                }
                postedFile.SaveAs(savepath + @"\" + sNewFileName);
                context.Response.Write(tempPath + sNewFileName);
                context.Response.StatusCode = 200;
            }
            catch (Exception ex)
            {
                context.Response.Write("Error: " + ex.Message);
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();

                this.WorkRequestID = QS("id", 0).ToString();
                decimal hour = app.GetWorkRequestHours(Convert.ToInt32(this.WorkRequestID));

                string link = @"<a href='/sunnet/Reports/TimeSheet.aspx?WID=" + this.WorkRequestID + "'>Total Hours:"
                              + hour + "</a>";
                lblHour.Text        = link;
                lblProjectName.Text = proApp.Get(Convert.ToInt32(this.ProjectID)).Title;
            }
        }
Ejemplo n.º 13
0
        private void InitControls()
        {
            InitPM();
            InitCompany();

            int            id    = QS("id", 0);
            ProjectsEntity model = projApp.Get(id);

            if (model == null)
            {
                this.ShowFailMessageToClient(projApp.BrokenRuleMessages, true);
            }
            else
            {
                chkBillable.Checked       = model.Billable;
                chkBugNeedApprove.Checked = model.BugNeedApproved;
                ddlCompany.SelectedValue  = model.CompanyID.ToString();
                txtDesc.Text              = model.Description;
                txtEndDate.Text           = model.EndDate.ToString("MM/dd/yyyy");
                txtFreeHour.Text          = model.FreeHour.ToString();
                ltlFreeHour.Text          = model.FreeHour.ToString();
                chkIsOverFreeTime.Checked = model.IsOverFreeTime;
                chkIsOverFreeTime.Text    = chkIsOverFreeTime.Checked ? "Yes" : "No";
                if (UserInfo.Role == RolesEnum.Sales)
                {
                    ltlFreeHour.Visible = false;
                }
                else
                {
                    txtFreeHour.Visible = false;
                }
                //model.IsOverFreeTime = false;
                ddlPM.SelectedValue           = model.PMID.ToString();
                ddlPriority.SelectedValue     = model.Priority;
                txtProjectCode.Text           = model.ProjectCode;
                chkRequestNeedApprove.Checked = model.RequestNeedApproved;
                txtStartDate.Text             = model.StartDate.ToString("MM/dd/yyyy");
                ddlStatus.SelectedValue       = model.Status.ToString();
                txtTestUrl.Text      = model.TestLinkURL;
                txtTestPassword.Text = model.TestPassword;
                txtTestUserName.Text = model.TestUserName;
                txtTitle.Text        = model.Title;

                InitFiles();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int userID    = QS("user", 0);
            int projectID = QS("project", 0);

            if (userID == 0 || projectID == 0)
            {
                this.Alert("Current Page get an error,please check your argument!", "/Sunnet/Reports/Consuming.aspx");
            }
            UserApplication userApp = new UserApplication();

            this.SelectedUser = userApp.GetUser(userID);
            ProjectApplication projApp = new ProjectApplication();

            this.SelectedProject = projApp.Get(projectID);

            DateTime startDate = DateTime.MinValue;
            DateTime endDate   = DateTime.MinValue;

            DateTime.TryParse(Request.QueryString["startdate"], out startDate);
            DateTime.TryParse(Request.QueryString["enddate"], out endDate);

            TimeSheetApplication tsApp = new TimeSheetApplication();
            DataTable            dt    = tsApp.GetSheetDateByProjectUser(projectID, userID, startDate, endDate);

            if (dt != null && dt.Rows.Count > 0)
            {
                StringBuilder dates = new StringBuilder();
                foreach (DataRow dr in dt.Rows)
                {
                    dates.Append(Convert.ToDateTime(dr[0].ToString()).ToString("yyyy-MM-dd"));
                    dates.Append(",");
                }
                this.DateQueue = dates.ToString().TrimEnd(",".ToCharArray());
            }
            else
            {
                this.Alert("There is no records ", "/Sunnet/Reports/Consuming.aspx");
            }
        }
Ejemplo n.º 15
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ((Pop)this.Master).Width = 800;
     tsApp = new TimeSheetApplication();
     if (!IsPostBack)
     {
         string             headStr   = "";
         ProjectApplication projApp   = new ProjectApplication();
         TicketsApplication ticketApp = new TicketsApplication();
         ProjectsEntity     project   = projApp.Get(QS("project", 0));
         TicketsEntity      ticket    = ticketApp.GetTickets(QS("ticket", 0));
         if (project != null)
         {
             headStr += project.Title;
         }
         if (ticket != null)
         {
             headStr += " - " + ticket.Title;
         }
         litHead.Text = headStr;
         InitControl();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int userID    = QS("user", 0);
            int projectID = QS("project", 0);

            if (userID == 0 || projectID == 0)
            {
                this.Alert("Current Page get an error,please check your argument!", "/Report/Consuming.aspx?viewmodel=detailmodel");
            }
            UserApplication userApp = new UserApplication();

            this.SelectedUser = userApp.GetUser(userID);
            ProjectApplication projApp = new ProjectApplication();

            this.SelectedProject = projApp.Get(projectID);

            DateTime startDate = DateTime.MinValue;
            DateTime endDate   = DateTime.MinValue;

            DateTime.TryParse(Request.QueryString["startdate"], out startDate);
            DateTime.TryParse(Request.QueryString["enddate"], out endDate);

            TimeSheetApplication tsApp = new TimeSheetApplication();
            DataTable            dt    = tsApp.GetSheetDateByProjectUser(projectID, userID, startDate, endDate);

            if (dt != null && dt.Rows.Count > 0)
            {
                this.rptDateView.DataSource = dt;
                this.rptDateView.DataBind();
            }
            else
            {
                ShowFailMessageToClient("There is no records ");
            }
            litUserName.Text   = SelectedUser.FirstName + " " + SelectedUser.LastName;
            litTotalhours.Text = totalHours.ToString("#0.00") + " h";
        }
Ejemplo n.º 17
0
        protected string GetUsersHtml(RolesEnum role)
        {
            StringBuilder htmls = new StringBuilder();
            GetProjectIdAndUserIDResponse response     = ticketApp.GetProjectIdAndUserID(QS("tid", 0));
            List <ProjectUsersEntity>     projectUsers = projectApp.GetProjectSunnetUserList(response.ProjectId);
            ProjectsEntity projectsEntity = projectApp.Get(response.ProjectId);

            if (projectUsers != null && projectUsers.Count > 0)
            {
                bool isHasUser = false;
                foreach (ProjectUsersEntity projectUser in projectUsers)
                {
                    UsersEntity user = userApp.GetUser(projectUser.UserID);
                    if (user != null && user.Status.Trim() != "INACTIVE")
                    {
                        if (user.Role != RolesEnum.CLIENT && user.Role == role)
                        {
                            if (ticketEntity.CreatedBy != user.UserID)
                            {
                                htmls.AppendFormat("<li userid='{0}' data-role=" + (int)MapRoleToTicketUserType(role) + ">{1}</li>", user.ID, user.FirstName);
                            }
                            else
                            {
                                htmls.AppendFormat("<li userid='{0}' data-isCreate='true' data-role=" + (int)MapRoleToTicketUserType(role) + ">{1}</li>", user.ID, user.FirstName);
                            }
                            isHasUser = true;
                        }
                    }
                }
                if (!isHasUser)
                {
                    htmls.AppendFormat("<li style='{0}'></li>", "visibility:hidden;");
                }
            }
            return(htmls.ToString());
        }
Ejemplo n.º 18
0
        public void ProcessRequest(HttpContext context)
        {
            HttpResponse response  = context.Response;
            HttpRequest  request   = context.Request;
            int          projectID = QS(request.QueryString["projectID"], 0);

            if (projectID != 0)
            {
                ProjectApplication projectApplication = new ProjectApplication();

                List <UsersEntity> clientUsers = projectApplication.GetPojectClientUsers(projectID, projectApplication.Get(projectID).CompanyID);

                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.Append("[");
                foreach (UsersEntity user in clientUsers)
                {
                    stringBuilder.Append("{");
                    stringBuilder.AppendFormat("\"name\":\"{0}\",\"value\":\"{1}\"", user.FirstAndLastName,
                                               user.UserID);
                    stringBuilder.Append("},");
                }
                response.Write(stringBuilder.ToString().TrimEnd(',') + "]");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }

                #region get value

                String action   = context.Request["action"];
                String desc     = (context.Request["desc"]).NoHTML();
                bool   ckIsSave = "no" == context.Request["ckIsSave"] ? false : true;
                int    tid      = Convert.ToInt32(context.Request["tid"]);

                #endregion

                #region declare

                int result = 0;

                TicketsEntity entity = new TicketsEntity();

                TicketsEntity Originalentity = ticketAPP.GetTickets(tid);

                bool Update = true;

                #endregion

                if (action == "cRequest")
                {
                    if (ckIsSave)
                    {
                        #region add

                        entity.ProjectID       = Originalentity.ProjectID;
                        entity.CompanyID       = Originalentity.CompanyID;
                        entity.Priority        = Originalentity.Priority;
                        entity.TicketType      = TicketsType.Request;
                        entity.Title           = Originalentity.Title;
                        entity.URL             = Originalentity.URL;
                        entity.FullDescription = Originalentity.TicketCode + ":" + Originalentity.FullDescription +
                                                 string.Format(Environment.NewLine +
                                                               "==================================" +
                                                               Environment.NewLine +
                                                               "Convert Reason:{0}", desc.TrimStart());
                        entity.CreatedBy     = Originalentity.CreatedBy;
                        entity.CreatedOn     = DateTime.Now;
                        entity.ModifiedOn    = DateTime.Now;
                        entity.Status        = TicketsState.Submitted;
                        entity.IsEstimates   = Originalentity.IsEstimates;
                        entity.TicketCode    = "R";
                        entity.IsInternal    = false;
                        entity.ModifiedBy    = 0;
                        entity.PublishDate   = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                        entity.ConvertDelete = CovertDeleteState.Normal;
                        entity.StartDate     = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                        entity.DeliveryDate  = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                        entity.Source        = userApp.GetUser(IdentityContext.UserID).Role;
                        result = ticketAPP.AddTickets(entity);

                        if (result > 0)
                        {
                            TicketUsersEntity ticketUserEntity = new TicketUsersEntity();
                            ticketUserEntity.Type     = TicketUsersType.PM;
                            ticketUserEntity.TicketID = result;
                            ProjectsEntity projectEntity = projectApp.Get(entity.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}",
                                                                entity.ProjectID, result, DateTime.Now));
                            }
                            ticketUserEntity.Type     = TicketUsersType.Create;
                            ticketUserEntity.TicketID = result;
                            ticketUserEntity.UserID   = Originalentity.CreatedBy;
                            ticketAPP.AddTicketUser(ticketUserEntity);
                        }
                        #endregion

                        #region add relation

                        TicketsRelationDTO dtoEntity = new TicketsRelationDTO();

                        AddTicketsRelationRequest request = new AddTicketsRelationRequest();

                        dtoEntity.RTID = Convert.ToInt32(result);

                        dtoEntity.TID = Convert.ToInt32(tid);

                        dtoEntity.CreatedBy = Originalentity.CreatedBy;

                        request.dto = dtoEntity;

                        trApp.AddTR(request);

                        #endregion

                        #region history
                        TicketHistorysEntity historEntity = new TicketHistorysEntity();
                        historEntity.ModifiedBy  = IdentityContext.UserID;
                        historEntity.ModifiedOn  = DateTime.Now.Date;
                        historEntity.TicketID    = Originalentity.TicketID;
                        historEntity.Description = entity.FullDescription = Originalentity.TicketCode + ":" + Originalentity.FullDescription +
                                                                            string.Format(Environment.NewLine +
                                                                                          "==================================" +
                                                                                          Environment.NewLine +
                                                                                          "Convert Reason:{0}" +
                                                                                          Environment.NewLine +
                                                                                          "Convert By:{1}"
                                                                                          , desc.TrimStart()
                                                                                          , userApp.GetLastNameFirstName(IdentityContext.UserID)
                                                                                          );
                        ticketAPP.AddTicketHistory(historEntity);
                        #endregion

                        #region update

                        Originalentity.ConvertDelete = CovertDeleteState.ConvertToHistory;
                        Originalentity.ModifiedOn    = DateTime.Now;
                        Originalentity.ModifiedBy    = IdentityContext.UserID;

                        Update = ticketAPP.UpdateTickets(Originalentity);

                        #endregion
                    }
                    else
                    {
                        #region add

                        entity.ProjectID       = Originalentity.ProjectID;
                        entity.CompanyID       = Originalentity.CompanyID;
                        entity.Priority        = Originalentity.Priority;
                        entity.TicketType      = TicketsType.Request;
                        entity.Title           = Originalentity.Title;
                        entity.URL             = Originalentity.URL;
                        entity.FullDescription = Originalentity.TicketCode + ":" + Originalentity.FullDescription +
                                                 string.Format(Environment.NewLine +
                                                               "==================================" +
                                                               Environment.NewLine +
                                                               "Convert Reason:{0}", desc.TrimStart());
                        entity.CreatedBy     = Originalentity.CreatedBy;
                        entity.CreatedOn     = DateTime.Now;
                        entity.ModifiedOn    = DateTime.Now;
                        entity.Status        = TicketsState.Submitted;
                        entity.IsEstimates   = Originalentity.IsEstimates;
                        entity.TicketCode    = "R";
                        entity.IsInternal    = false;
                        entity.ModifiedBy    = 0;
                        entity.PublishDate   = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                        entity.ConvertDelete = CovertDeleteState.Normal;
                        entity.StartDate     = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                        entity.DeliveryDate  = UtilFactory.Helpers.CommonHelper.GetDefaultMinDate();
                        entity.Source        = userApp.GetUser(IdentityContext.UserID).Role;
                        result = ticketAPP.AddTickets(entity);

                        if (result > 0)
                        {
                            TicketUsersEntity ticketUserEntity = new TicketUsersEntity();
                            ticketUserEntity.Type     = TicketUsersType.PM;
                            ticketUserEntity.TicketID = result;
                            ProjectsEntity projectEntity = projectApp.Get(entity.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}",
                                                                entity.ProjectID, result, DateTime.Now));
                            }
                            ticketUserEntity.Type     = TicketUsersType.Create;
                            ticketUserEntity.TicketID = result;
                            ticketUserEntity.UserID   = Originalentity.CreatedBy;
                            ticketAPP.AddTicketUser(ticketUserEntity);
                        }

                        #endregion

                        #region history
                        TicketHistorysEntity historEntity = new TicketHistorysEntity();
                        historEntity.ModifiedBy  = IdentityContext.UserID;
                        historEntity.ModifiedOn  = DateTime.Now.Date;
                        historEntity.TicketID    = Originalentity.TicketID;
                        historEntity.Description = entity.FullDescription = Originalentity.TicketCode + ":" + Originalentity.FullDescription +
                                                                            string.Format(Environment.NewLine +
                                                                                          "==================================" +
                                                                                          Environment.NewLine +
                                                                                          "Convert Reason:{0}" +
                                                                                          Environment.NewLine +
                                                                                          "Convert By:{1}"
                                                                                          , desc.TrimStart()
                                                                                          , userApp.GetLastNameFirstName(IdentityContext.UserID)
                                                                                          );
                        ticketAPP.AddTicketHistory(historEntity);
                        #endregion

                        #region add relation

                        TicketsRelationDTO dtoEntity = new TicketsRelationDTO();

                        AddTicketsRelationRequest request = new AddTicketsRelationRequest();

                        dtoEntity.RTID = Convert.ToInt32(result);

                        dtoEntity.TID = Convert.ToInt32(tid);

                        dtoEntity.CreatedBy = Originalentity.CreatedBy;

                        request.dto = dtoEntity;

                        trApp.AddTR(request);

                        #endregion

                        #region update

                        Originalentity.Status        = TicketsState.Cancelled;
                        Originalentity.ConvertDelete = CovertDeleteState.ForeverDelete;
                        Originalentity.ModifiedOn    = DateTime.Now;

                        Originalentity.ModifiedBy = IdentityContext.UserID;
                        Update = ticketAPP.UpdateTickets(Originalentity);

                        #endregion
                    }
                }
                if (Update)
                {
                    context.Response.Write("Update Status Success!");
                }
                else
                {
                    context.Response.Write("Update Status Fail!");
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("para error!");
                WebLogAgent.Write(string.Format("Error Ashx:DoConverReasonHandler.ashx Messages:\r\n{0}", ex));
                return;
            }
        }
Ejemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int userID    = QS("user", 0);
            int projectID = QS("project", 0);

            if (userID == 0 || projectID == 0)
            {
                this.Alert("Current Page get an error,please check your argument!", "/Pto/Pto.aspx?viewmodel=detailmodel");
            }
            UserApplication userApp = new UserApplication();

            this.SelectedUser = userApp.GetUser(userID);
            ProjectApplication projApp = new ProjectApplication();

            this.SelectedProject = projApp.Get(projectID);

            //DateTime startDate = DateTime.MinValue;
            //DateTime endDate = DateTime.MinValue;
            //DateTime.TryParse(Request.QueryString["startdate"], out startDate);
            //DateTime.TryParse(Request.QueryString["enddate"], out endDate);

            DateTime StartDate;
            DateTime EndDate;

            if (!DateTime.TryParse(Request.QueryString["year"], out StartDate))
            {
                StartDate = new DateTime(1753, 1, 1);
                EndDate   = new DateTime(2200, 1, 1);;
            }
            else
            {
                EndDate = StartDate.AddYears(1).AddDays(-1);
            }
            _eventsApplication = new EventsApplication();
            DataTable           evdt         = _eventsApplication.GetPtoByProjectUser(projectID, userID, StartDate, EndDate);
            IList <PtoUserView> eventPtolist = ModelConvertHelper <PtoUserView> .ConvertToModel(evdt);

            List <PtoUserDetailView> ptoUserDetailViews = new List <PtoUserDetailView>();

            if (eventPtolist != null && eventPtolist.Count > 0)
            {
                foreach (var t in eventPtolist)
                {
                    PtoUserDetailView ptoUserDetailView = new PtoUserDetailView
                    {
                        Title   = t.Title,
                        Name    = t.Name,
                        Details = t.Details
                    };
                    double hours = 0;
                    if (t.Office == "CN")
                    {
                        #region
                        if (t.AllDay)
                        {
                            if (t.ToDay.Date == t.FromDay.Date)
                            {
                                hours += 8;
                            }
                            else
                            {
                                var days = t.ToDay.Day - t.FromDay.Day + 1;
                                hours = hours + days * 8;
                            }
                            ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(8).AddMinutes(30);
                            ptoUserDetailView.ToDay   = t.ToDay.Date.AddHours(17).AddMinutes(30);
                        }
                        if (!t.AllDay)
                        {
                            var fromTime = t.FromTime.Split(':');
                            var toTime   = t.ToTime.Split(':');
                            DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                            dtFormat.ShortDatePattern = "HH:mm";
                            var fromTimeHour    = Int32.Parse(fromTime[0]);
                            var fromtimeMinutes = Int32.Parse(fromTime[1]);
                            var toTimeHour      = Int32.Parse(toTime[0]);
                            var toTimeMinutes   = Int32.Parse(toTime[1]);
                            var fromTimeDate    = Convert.ToDateTime(t.FromTime, dtFormat);
                            var toTimeDate      = Convert.ToDateTime(t.ToTime, dtFormat);
                            var workTime        = Convert.ToDateTime("8:30", dtFormat);
                            var restTimeBegin   = Convert.ToDateTime("12:30", dtFormat);
                            var restTimeEnd     = Convert.ToDateTime("13:30", dtFormat);
                            var closeTime       = Convert.ToDateTime("17:30", dtFormat);
                            if (t.FromTimeType == 2)
                            {
                                if (fromTimeHour <= 5)
                                {
                                    fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12);
                                }
                            }
                            if (t.FromTimeType == 1)
                            {
                                if (fromTimeHour == 12)
                                {
                                    fromTimeDate = workTime;
                                }
                            }
                            if (t.ToTimeType == 2)
                            {
                                if (toTimeHour <= 5)
                                {
                                    toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12);
                                }
                                if (5 < toTimeHour && toTimeHour < 12)
                                {
                                    toTimeDate = closeTime;
                                }
                            }
                            if (toTimeDate < restTimeBegin)
                            {
                                hours = hours + (toTimeDate - fromTimeDate).TotalHours;
                            }
                            if (toTimeDate > restTimeEnd)
                            {
                                hours = hours + (restTimeBegin - fromTimeDate).TotalHours;
                                hours = hours + (toTimeDate - restTimeEnd).TotalHours;
                            }
                            if (t.FromTimeType == 1)
                            {
                                ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddMinutes(fromtimeMinutes);
                            }
                            else
                            {
                                if (fromTimeHour <= 5)
                                {
                                    ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes);
                                }
                            }
                            if (t.ToTimeType == 1)
                            {
                                ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddMinutes(toTimeMinutes);
                            }
                            else
                            {
                                if (toTimeHour <= 5)
                                {
                                    ptoUserDetailView.ToDay =
                                        t.ToDay.Date.AddHours(toTimeHour).AddHours(12).AddMinutes(toTimeMinutes);
                                }
                                if (toTimeHour > 5 && toTimeHour < 12)
                                {
                                    ptoUserDetailView.ToDay = closeTime;
                                }
                                if (toTimeHour == 12)
                                {
                                    ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(12).AddMinutes(toTimeMinutes);
                                }
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        var workTimes  = _eventsApplication.GetWorkTime(t.UserID);
                        var worksViews = workTimes.Select(k => new WorkTimeView
                        {
                            FromTime     = k.FromTime,
                            ToTime       = k.ToTime,
                            FromTimeType = k.FromTimeType,
                            ToTimeType   = k.ToTimeType
                        }).OrderBy(c => c.FromDate).ToList();
                        if (!worksViews.Any())
                        {
                            #region
                            if (t.AllDay)
                            {
                                if (t.ToDay.Date == t.FromDay.Date)
                                {
                                    hours += 8;
                                }
                                else
                                {
                                    var days = t.ToDay.Day - t.FromDay.Day + 1;
                                    hours = hours + days * 8;
                                }
                                ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(8).AddMinutes(30);
                                ptoUserDetailView.ToDay   = t.ToDay.Date.AddHours(17).AddMinutes(30);
                            }
                            if (!t.AllDay)
                            {
                                var fromTime = t.FromTime.Split(':');
                                var toTime   = t.ToTime.Split(':');
                                DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                                dtFormat.ShortDatePattern = "HH:mm";
                                var fromTimeHour    = Int32.Parse(fromTime[0]);
                                var fromtimeMinutes = Int32.Parse(fromTime[1]);
                                var toTimeHour      = Int32.Parse(toTime[0]);
                                var toTimeMinutes   = Int32.Parse(toTime[1]);
                                var fromTimeDate    = Convert.ToDateTime(t.FromTime, dtFormat);
                                var toTimeDate      = Convert.ToDateTime(t.ToTime, dtFormat);
                                var workTime        = Convert.ToDateTime("8:30", dtFormat);
                                var restTimeBegin   = Convert.ToDateTime("12:30", dtFormat);
                                var restTimeEnd     = Convert.ToDateTime("13:30", dtFormat);
                                var closeTime       = Convert.ToDateTime("17:30", dtFormat);
                                if (t.FromTimeType == 2)
                                {
                                    if (fromTimeHour <= 5)
                                    {
                                        fromTimeDate = Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12);
                                    }
                                }
                                if (t.FromTimeType == 1)
                                {
                                    if (fromTimeHour == 12)
                                    {
                                        fromTimeDate = workTime;
                                    }
                                }
                                if (t.ToTimeType == 2)
                                {
                                    if (toTimeHour <= 5)
                                    {
                                        toTimeDate = Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12);
                                    }
                                    if (5 < toTimeHour && toTimeHour < 12)
                                    {
                                        toTimeDate = closeTime;
                                    }
                                }
                                if (toTimeDate < restTimeBegin)
                                {
                                    hours = hours + (toTimeDate - fromTimeDate).TotalHours;
                                }
                                if (toTimeDate > restTimeEnd)
                                {
                                    hours = hours + (restTimeBegin - fromTimeDate).TotalHours;
                                    hours = hours + (toTimeDate - restTimeEnd).TotalHours;
                                }
                                if (t.FromTimeType == 1)
                                {
                                    ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddMinutes(fromtimeMinutes);
                                }
                                else
                                {
                                    if (fromTimeHour <= 5)
                                    {
                                        ptoUserDetailView.FromDay = t.FromDay.Date.AddHours(fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes);
                                    }
                                }
                                if (t.ToTimeType == 1)
                                {
                                    ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(toTimeHour).AddMinutes(toTimeMinutes);
                                }
                                else
                                {
                                    if (toTimeHour <= 5)
                                    {
                                        ptoUserDetailView.ToDay =
                                            t.ToDay.Date.AddHours(toTimeHour).AddHours(12).AddMinutes(toTimeMinutes);
                                    }
                                    if (toTimeHour > 5 && toTimeHour < 12)
                                    {
                                        ptoUserDetailView.ToDay = closeTime;
                                    }
                                    if (toTimeHour == 12)
                                    {
                                        ptoUserDetailView.ToDay = t.ToDay.Date.AddHours(12).AddMinutes(toTimeMinutes);
                                    }
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            var mindate = worksViews.Min(x => x.FromDate);
                            var maxdate = worksViews.Max(x => x.ToDate);
                            #region
                            if (t.AllDay)
                            {
                                if (t.ToDay.Date == t.FromDay.Date)
                                {
                                    hours += 8;
                                }
                                else
                                {
                                    var days = t.ToDay.Day - t.FromDay.Day + 1;
                                    hours = hours + days * 8;
                                }
                                ptoUserDetailView.FromDay = mindate;
                                ptoUserDetailView.ToDay   = maxdate;
                            }
                            else
                            {
                                #region
                                DateTimeFormatInfo dtFormat = new DateTimeFormatInfo
                                {
                                    ShortDatePattern = "HH:mm"
                                };
                                var fromTime        = t.FromTime.Split(':');
                                var toTime          = t.ToTime.Split(':');
                                var fromTimeHour    = Int32.Parse(fromTime[0]);
                                var fromtimeMinutes = Int32.Parse(fromTime[1]);
                                var toTimeHour      = Int32.Parse(toTime[0]);
                                var toTimeMinutes   = Int32.Parse(toTime[1]);
                                var fromTimeDate    = Convert.ToDateTime(t.FromTime, dtFormat);
                                var toTimeDate      = Convert.ToDateTime(t.ToTime, dtFormat);

                                foreach (var g in worksViews)
                                {
                                    var workTime  = g.FromDate;
                                    var closeTime = g.ToDate;
                                    switch (t.FromTimeType)
                                    {
                                    case 1:
                                        fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime("00:" + fromtimeMinutes, dtFormat) : Convert.ToDateTime(t.FromTime, dtFormat);
                                        break;

                                    case 2:
                                        fromTimeDate = fromTimeHour == 12 ? Convert.ToDateTime(t.FromTime, dtFormat) : Convert.ToDateTime(t.FromTime, dtFormat).AddHours(12);
                                        break;
                                    }
                                    switch (t.ToTimeType)
                                    {
                                    case 1:
                                        toTimeDate = toTimeHour == 12 ? Convert.ToDateTime("00:" + toTimeMinutes, dtFormat) : Convert.ToDateTime(t.ToTime, dtFormat);
                                        break;

                                    case 2:
                                        toTimeDate = toTimeHour == 12 ? Convert.ToDateTime(t.ToTime, dtFormat) : Convert.ToDateTime(t.ToTime, dtFormat).AddHours(12);
                                        break;
                                    }
                                    if (fromTimeDate <= workTime && closeTime <= toTimeDate)
                                    {
                                        if ((closeTime - workTime).TotalHours < 0)
                                        {
                                            continue;
                                        }
                                        hours = hours + (closeTime - workTime).TotalHours;
                                    }
                                    if (fromTimeDate <= workTime && closeTime > toTimeDate)
                                    {
                                        if ((toTimeDate - workTime).TotalHours < 0)
                                        {
                                            continue;
                                        }
                                        hours = hours + (toTimeDate - workTime).TotalHours;
                                    }
                                    if (fromTimeDate > workTime && closeTime <= toTimeDate)
                                    {
                                        if ((closeTime - fromTimeDate).TotalHours < 0)
                                        {
                                            continue;
                                        }
                                        hours = hours + (closeTime - fromTimeDate).TotalHours;
                                    }
                                    if (fromTimeDate > workTime && closeTime > toTimeDate)
                                    {
                                        if ((toTimeDate - fromTimeDate).TotalHours < 0)
                                        {
                                            continue;
                                        }
                                        hours = hours + (toTimeDate - fromTimeDate).TotalHours;
                                    }
                                }
                                ptoUserDetailView.FromDay = t.FromTimeType == 1 ? t.FromDay.Date.AddHours(fromTimeHour == 12 ? 0 : fromTimeHour).AddMinutes(fromtimeMinutes) : t.FromDay.Date.AddHours(fromTimeHour == 12 ? 0 : fromTimeHour).AddHours(12).AddMinutes(fromtimeMinutes);
                                ptoUserDetailView.ToDay   = t.ToTimeType == 1 ? t.ToDay.Date.AddHours(toTimeHour == 12 ? 0 : toTimeHour).AddMinutes(toTimeMinutes) : t.ToDay.Date.AddHours(toTimeHour == 12 ? 0 : toTimeHour).AddHours(12).AddMinutes(toTimeMinutes);
                                #endregion
                            }
                            #endregion
                        }
                    }
                    ptoUserDetailView.Hours = hours;
                    ptoUserDetailViews.Add(ptoUserDetailView);
                }
                this.ptoDetail.DataSource = ptoUserDetailViews;
                this.ptoDetail.DataBind();
            }
            else
            {
                ShowFailMessageToClient("There is no records ");
            }
            litUserName.Text = SelectedUser.FirstName + " " + SelectedUser.LastName;
            if (ptoUserDetailViews.Any())
            {
                foreach (var t in ptoUserDetailViews)
                {
                    _totalHours += t.Hours;
                }
            }
            litTotalhours.Text = _totalHours.ToString("#0.00") + " h";
        }
Ejemplo n.º 21
0
        private void CreateAssignUserList()
        {
            GetProjectIdAndUserIDResponse response     = ticketApp.GetProjectIdAndUserID(ticketID);
            List <ProjectUsersEntity>     projectUsers = projApp.GetProjectSunnetUserList(response.ProjectId)
                                                         .Distinct(new CompareProjectUser())
                                                         .ToList <ProjectUsersEntity>();

            if (UserInfo.Role == RolesEnum.Leader)
            {
                dvUS.Style.Add("visibility", "hidden");
                dvUS.Style.Add("overflow", "auto");
                dvUS.Style.Add("width", "1px");
                dvUS.Style.Add("height", "1px");
            }

            List <TicketUsersEntity> ticketUsers    = ticketApp.GetListUsersByTicketId(ticketID);
            TicketsEntity            ticketEntity   = ticketApp.GetTickets(ticketID);
            ProjectsEntity           projectsEntity = projApp.Get(response.ProjectId);

            if (projectUsers != null && projectUsers.Count() > 0)
            {
                foreach (ProjectUsersEntity projectUser in projectUsers)
                {
                    UsersEntity user = userApp.GetUser(projectUser.UserID);
                    if (user != null && user.Status.Trim() != "INACTIVE")
                    {
                        if (user.Role != RolesEnum.CLIENT)
                        {
                            // 去掉“隐藏ticket的创建者和project的pm” lyq 20140808
                            //bool isTicketCreateUser = (ticketEntity.CreatedBy == user.UserID || user.UserID == projectsEntity.PMID);
                            bool isTicketCreateUser = false;
                            bool isChecked          = ticketUsers.Find(r => r.UserID == user.UserID) != null;
                            switch (user.Role)
                            {
                            case RolesEnum.Supervisor:
                            case RolesEnum.Sales:
                            case RolesEnum.PM:
                            {
                                this.ulUS.Controls.Add(GetUserLi(user, isTicketCreateUser, isChecked, true));
                                break;
                            }

                            case RolesEnum.Leader:
                            case RolesEnum.DEV:
                            case RolesEnum.Contactor:
                            {
                                this.ulDev.Controls.Add(GetUserLi(user, isTicketCreateUser, isChecked));
                                break;
                            }

                            case RolesEnum.QA:
                            {
                                this.ulQA.Controls.Add(GetUserLi(user, isTicketCreateUser, isChecked));
                                break;
                            }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
        private void AddFile(int tid, int pId, int i)
        {
            HttpContext context = HttpContext.Current;

            string image     = "";
            string DeleteImg = "";

            if (i == 0)
            {
                image     = this.AddTicket1.File;
                DeleteImg = this.AddTicket1.DeleteFile;
            }
            else if (i == 1)
            {
                image     = this.AddTicket2.File;
                DeleteImg = this.AddTicket2.DeleteFile;
            }
            else
            {
                image     = this.AddTicket3.File;
                DeleteImg = this.AddTicket3.DeleteFile;
            }
            string imageList     = AnalysisString(image, 1);
            string imageSizeList = AnalysisString(image, 2);
            string deleteImglist = AnalysisString(DeleteImg, 1);

            ProjectsEntity pentity = projectApp.Get(Convert.ToInt32(pId));



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

            string sNewFileName = "";

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

            string[] listStringName = imageList.Split(',');
            string[] listStringSize = imageSizeList.Split(',');
            string[] listdelImage   = deleteImglist.Split(',');

            foreach (string Name in listStringName)
            {
                fileEntity = new FilesEntity();
                string sExtension = Path.GetExtension(Name).Replace(".", "").Trim();
                foreach (string Size in listStringSize)
                {
                    if (listdelImage.Contains(Name))
                    {
                        continue;
                    }
                    sNewFileName           = FolderName + Name;
                    fileEntity.ContentType = "." + sExtension.ToLower();
                    fileEntity.CreatedBy   = UserInfo.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;
                    fileEntity.FeedbackId  = 0;
                    fileEntity.SourceType  = (int)FileSourceType.Ticket;
                    fileEntity.ThumbPath   = context.Server.MapPath(tempPath) + FolderName + sNewFileName;;//
                    fileEntity.CreatedOn   = DateTime.Now.Date;
                    fileEntity.CompanyID   = IdentityContext.CompanyID;
                    int responseResult = fileApp.AddFile(fileEntity);
                    if (responseResult <= 0)
                    {
                        HasFileMsG = false;
                        stringErrorMsg.Add(fileEntity.FileTitle);
                    }
                    break;
                }
            }
        }
Ejemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            projApp = new ProjectApplication();

            if (!Page.IsPostBack)
            {
                int         id          = QS("ID", 0);
                int         canEdit     = QS("c", 0);
                EventEntity eventEntity = new EventsApplication().GetEventInfo(id);
                ltrlName.Text     = eventEntity.Name;
                ltrlDetail.Text   = eventEntity.Details;
                ltrlWhere.Text    = eventEntity.Where;
                chkAllDay.Checked = eventEntity.AllDay;
                chkAllDay.Enabled = false;
                string fromTime = string.Empty;
                string toTime   = string.Empty;

                if (!chkAllDay.Checked)
                {
                    fromTime = eventEntity.FromDayString + " " + eventEntity.FromTime + " " + (eventEntity.FromTimeType == 1 ? "AM" : "PM");
                    toTime   = eventEntity.ToDayString + " " + eventEntity.ToTime + " " + (eventEntity.ToTimeType == 1 ? "AM" : "PM");
                }
                else
                {
                    fromTime = eventEntity.FromDayString;
                    toTime   = eventEntity.ToDayString;
                }
                ltrlFrom.Text    = fromTime;
                ltrlTo.Text      = toTime;
                ltrlAlert.Text   = eventEntity.Alert.GetName <AlertType>();
                imgIcon.ImageUrl = eventEntity.IconPath;
                if (eventEntity.ProjectID != -1)
                {
                    ProjectsEntity projectsEntity = projApp.Get(eventEntity.ProjectID);
                    ltrlProject.Text = projectsEntity.Title;
                }
                else
                {
                    ltrlProject.Text = string.Empty;
                }
                litCreated.Text = new App.UserApplication().GetUser(eventEntity.CreatedBy).GetClientUserName(UserInfo);

                List <EventInviteEntity> list = new App.EventsApplication().GetEventInvites(eventEntity.ID);
                UsersEntity userEntity;
                foreach (EventInviteEntity tmpItem in list)
                {
                    if (tmpItem.UserID > 0)
                    {
                        userEntity        = new App.UserApplication().GetUser(tmpItem.UserID);
                        tmpItem.FirstName = userEntity.FirstName;
                        tmpItem.LastName  = userEntity.LastName;
                    }
                }

                if (eventEntity.ProjectID.ToString() == Config.HRProjectID)
                {
                    chkOff.Checked = eventEntity.IsOff;
                }
                else
                {
                    div_off.Attributes.Add("style", "display:none");
                }

                rptInvite.DataSource = list.OrderBy(r => r.LastName);
                rptInvite.DataBind();
            }
            ((Pop)(this.Master)).Width = 425;
        }
        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;
            }
        }
Ejemplo n.º 25
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //保存状态。
            //如果需要估时则保存估时
            bool result = true;

            if (IsETA)
            {
                decimal etahours = 0;
                if (decimal.TryParse(txtBoxExtimationHours.Text, out etahours))
                {
                    _ticketEntity.InitialTime = etahours;
                }
            }
            if (!result)
            {
                ShowFailMessageToClient(ticketApp.BrokenRuleMessages);
                return;
            }
            var currentState = ddlStatus.SelectedValue.ToEnum <TicketsState>();

            _ticketEntity.Status     = currentState;
            _ticketEntity.ModifiedBy = UserInfo.UserID;
            _ticketEntity.ModifiedOn = DateTime.Now;
            int            oldResponsibleUserId = _ticketEntity.ResponsibleUser;
            ProjectsEntity projectEntity        = projectApp.Get(_ticketEntity.ProjectID);

            _ticketEntity.ResponsibleUser = int.Parse(ddlResponsibleUser.SelectedValue);

            result = ticketApp.UpdateTickets(_ticketEntity);
            if (result)
            {
                //sent email to responsible user 2017/10/23
                if (oldResponsibleUserId != _ticketEntity.ResponsibleUser)
                {
                    ticketApp.SendEmailToResponsibile(_ticketEntity, UserInfo);
                }
            }
            if (!result)
            {
                ShowFailMessageToClient(ticketApp.BrokenRuleMessages);
                return;
            }
            if (!IsETA && (currentState == TicketsState.Tested_Fail_On_Local || currentState == TicketsState.Tested_Fail_On_Client))
            {
                FilesEntity        fileEntity       = new FilesEntity();
                HttpFileCollection files            = Request.Files;
                string             fileuploadErrMsg = string.Empty;
                for (int i = 0; i < files.Count; i++)
                {
                    if (files[i].ContentLength > 0 || txtDescription.Text.Trim().Length > 0 && IsValidFile(files[i].FileName))
                    {
                        FeedBacksEntity feedbacksEntity = GetFeedbacksEntity();
                        feedbacksEntity.ID = fbAPP.AddFeedBacks(feedbacksEntity);
                        result             = feedbacksEntity.ID > 0;
                        if (!result)
                        {
                            ShowFailMessageToClient(fbAPP.BrokenRuleMessages);
                            return;
                        }
                        if (files[i].ContentLength > 0 && IsValidFile(files[i].FileName))
                        {
                            if (!InsertFile(files[i], _ticketEntity.ProjectID, feedbacksEntity.IsPublic,
                                            feedbacksEntity.ID))
                            {
                                fileuploadErrMsg += files[i].FileName + " Upload failed.";
                                result            = false;
                            }
                        }
                    }
                }
                if (!result)
                {
                    ShowFailMessageToClient(fileuploadErrMsg);
                    return;
                }
            }
            if (result)
            {
                Redirect(EmptyPopPageUrl, false, true);
            }
            else
            {
                ShowFailMessageToClient(ticketApp.BrokenRuleMessages);
            }
        }
Ejemplo n.º 26
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;
            }
        }