Ejemplo n.º 1
0
        private void AssignUsers(string userids, bool isClient)
        {
            string[] users = userids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            int      id    = QS("id", 0);

            if (projApp.RemoveAllUsers(id, isClient))
            {
                List <BrokenRuleMessage> listmsgs = new List <BrokenRuleMessage>();
                foreach (string user in users)
                {
                    ProjectUsersEntity model = ProjectsFactory.CreateProjectUser(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());
                    model.ProjectID = id;
                    model.UserID    = int.Parse(user);
                    model.ISClient  = QueryISClient(user);
                    model.ISClient  = isClient;
                    if (projApp.AssignUserToProject(model) < 0)
                    {
                        RecordMsg(listmsgs, projApp.BrokenRuleMessages);
                    }
                }
                if (listmsgs.Count > 0)
                {
                    this.ShowFailMessageToClient();
                }
                else
                {
                    if (!isClient)
                    {
                        InitSunnetUsers();
                    }
                    this.ShowSuccessMessageToClient(false, false);
                }
            }
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }
                string   isClient      = context.Request["isClient"];
                string   projectIdList = context.Request["checkboxList"];
                int      uid           = int.Parse(context.Request["uid"]);
                string[] projectIds    = projectIdList.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                //这里原本传的是project的Id而我只需要保证弹出的窗口中没有已选择的project就ok了

                List <BrokenRuleMessage> listmsgs = new List <BrokenRuleMessage>();
                foreach (string projectId in projectIds)
                {
                    ProjectUsersEntity model = ProjectsFactory.CreateProjectUser(IdentityContext.UserID
                                                                                 , ObjectFactory.GetInstance <ISystemDateTime>());
                    model.ProjectID = int.Parse(projectId);
                    model.UserID    = uid;
                    model.ISClient  = Boolean.Parse(isClient);
                    if (projApp.AssignUserToProject(model) < 0)
                    {
                        RecordMsg(listmsgs, projApp.BrokenRuleMessages);
                    }
                }
                if (listmsgs.Count > 0)
                {
                    context.Response.Write("Assign Fail!");
                }
                else
                {
                    context.Response.Write("The project has been assigned.");
                }
            }
            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;
            }
        }
Ejemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;

            if (!CheckInput(out msg))
            {
                this.ShowMessageToClient(msg, 2, false, false);
                return;
            }
            ProjectsEntity model = GetEntity();

            int id = projApp.Insert(model);

            if (id > 0)
            {
                ProjectUsersEntity projectUsersEntity = new ProjectUsersEntity();
                projectUsersEntity.ISClient  = false;
                projectUsersEntity.CreatedBy = UserInfo.UserID;
                projectUsersEntity.CreatedOn = DateTime.Now;
                projectUsersEntity.ProjectID = id;
                projectUsersEntity.RoleID    = (int)RolesEnum.PM;
                projectUsersEntity.UserID    = model.PMID;
                int result = projApp.AssignUserToProject(projectUsersEntity);
                if (result > 0)
                {
                    this.ShowSuccessMessageToClient();
                }
                else
                {
                    this.ShowFailMessageToClient(projApp.BrokenRuleMessages);
                }
            }
            else
            {
                this.ShowFailMessageToClient(projApp.BrokenRuleMessages);
            }
        }
Ejemplo n.º 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;

            if (!CheckInput(out msg))
            {
                this.ShowMessageToClient(msg, 2, false, false);
                return;
            }
            ProjectsEntity model = GetEntity();

            int id = projApp.Insert(model);

            if (id > 0)
            {
                ProjectUsersEntity projectUsersEntity = new ProjectUsersEntity();
                projectUsersEntity.ISClient  = false;
                projectUsersEntity.CreatedBy = UserInfo.UserID;
                projectUsersEntity.CreatedOn = DateTime.Now;
                projectUsersEntity.ProjectID = id;
                projectUsersEntity.UserID    = model.PMID;
                int result = projApp.AssignUserToProject(projectUsersEntity);
                if (result > 0)
                {
                    Redirect(string.Format("EditProject.aspx?ID={0}&returnurl={1}", id, Server.UrlEncode("/Admin/Projects/Projects.aspx")));
                }
                else
                {
                    this.ShowFailMessageToClient(projApp.BrokenRuleMessages);
                }
            }
            else
            {
                this.ShowFailMessageToClient(projApp.BrokenRuleMessages);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                if (IdentityContext.UserID <= 0)
                {
                    return;
                }
                string   isClient      = context.Request["isClient"];
                string   projectIdList = context.Request["checkboxList"];
                int      uid           = int.Parse(context.Request["uid"]);
                string[] projectIds    = projectIdList.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                #region 获取已经分配了的project
                SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.ListByUserID
                                                                          , false, "projectId", "ASC");
                request.UserID = uid;
                SearchProjectsResponse projectList = new ProjectApplication().SearchProjects(request);
                for (int i = 0; i < projectIds.Length; i++)
                {
                    int projectId = 0;
                    int.TryParse(projectIds[i], out projectId);
                    ProjectDetailDTO project = projectList.ResultList.Find(t => t.ProjectID == projectId);
                    if (project != null && project.ProjectID != 0)
                    {
                        context.Response.Write("some of the selected projects have been assigned to this user!");
                        return;
                    }
                }

                #endregion

                List <BrokenRuleMessage> listmsgs = new List <BrokenRuleMessage>();
                foreach (string projectId in projectIds)
                {
                    ProjectUsersEntity model = ProjectsFactory.CreateProjectUser(IdentityContext.UserID
                                                                                 , ObjectFactory.GetInstance <ISystemDateTime>());
                    model.ProjectID = int.Parse(projectId);
                    model.UserID    = uid;
                    model.ISClient  = Boolean.Parse(isClient);

                    if (projApp.AssignUserToProject(model) < 0)
                    {
                        RecordMsg(listmsgs, projApp.BrokenRuleMessages);
                    }
                }
                if (listmsgs.Count > 0)
                {
                    context.Response.Write("Assign Fail!");
                }
                else
                {
                    context.Response.Write("The project has been assigned.");
                }
            }
            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;
            }
        }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (IdentityContext.UserID <= 0)
            {
                return;
            }
            UsersEntity userEntity = userApp.GetUser(IdentityContext.UserID);

            if (userEntity == null ||
                (userEntity.Role != RolesEnum.ADMIN && userEntity.Role != RolesEnum.PM))
            {
                context.Response.Write("Not authority");
                return;
            }

            string project = context.Request.Form["projectId"];
            int    projectId;

            if (!int.TryParse(project, out projectId))
            {
                context.Response.Write("Parameter errors.");
                return;
            }

            string optionType = context.Request.Form["type"] + "";

            optionType = optionType.ToLower();
            if (string.IsNullOrEmpty(optionType.Trim()) ||
                (optionType != "add" && optionType != "del"))
            {
                context.Response.Write("Parameter errors.");
                return;
            }

            string user = context.Request.Form["UserId"];
            int    userId;

            if (!int.TryParse(user, out userId))
            {
                context.Response.Write("Parameter errors.");
                return;
            }

            if (optionType == "del")
            {
                proApp.DeleteProjectUser(projectId, userId);
            }
            else
            {
                string client = context.Request.Form["client"] + "";
                if (string.IsNullOrEmpty(client) ||
                    (client != "sunnet" && client != "client"))
                {
                    context.Response.Write("Parameter errors.");
                    return;
                }

                UsersEntity assentUserEntity = userApp.GetUser(userId);
                if (assentUserEntity == null)
                {
                    context.Response.Write("Parameter errors.");
                    return;
                }
                ProjectUsersEntity projectuserEntity = new ProjectUsersEntity()
                {
                    ProjectID = projectId,
                    UserID    = userId,
                    ISClient  = client.Equals("client", StringComparison.CurrentCultureIgnoreCase)
                };
                proApp.AssignUserToProject(projectuserEntity);
            }
        }