protected void InitProjectList()
        {
            SearchProjectsRequest request;

            if (isClient)
            {
                request = new SearchProjectsRequest(SearchProjectsType.AllExceptAssigned
                                                    , true, hidOrderBy.Value, hidOrderDirection.Value);
                request.UserID = UserToEdit.UserID;
            }
            else
            {
                request = new SearchProjectsRequest(SearchProjectsType.CompanyExceptAssigned
                                                    , true, hidOrderBy.Value, hidOrderDirection.Value);
                request.CompanyID = UserToEdit.CompanyID;
                request.UserID    = UserToEdit.UserID;
            }
            request.Keywords    = txtKeyWord.Text.Trim();
            request.CurrentPage = anpProjects.CurrentPageIndex;
            request.PageCount   = anpProjects.PageSize;
            request.UserID      = UserToEdit.UserID;
            SearchProjectsResponse response = new ProjectApplication().SearchProjects(request);

            rptProjects.DataSource = response.ResultList;
            rptProjects.DataBind();
            anpProjects.RecordCount = response.ResultCount;
            if (anpProjects.RecordCount > 0)
            {
                trNoRecords.Visible = false;
            }
        }
Exemplo n.º 2
0
        protected void InitProjectList()
        {
            SearchProjectsRequest request;

            if (!isClient)
            {
                request = new SearchProjectsRequest(SearchProjectsType.AllExceptAssigned
                                                    , true, "ProjectCode", "ASC");
                request.UserID = UserToEdit.UserID;
            }
            else
            {
                request = new SearchProjectsRequest(SearchProjectsType.CompanyExceptAssigned
                                                    , true, DefaultOrderBy, DefaultDirection);
                request.CompanyID = UserToEdit.CompanyID;
                request.UserID    = UserToEdit.UserID;
            }
            request.Keywords    = txtKeyword.Text.Trim();
            request.CurrentPage = CurrentPageIndex;
            request.PageCount   = ProjectPage.PageSize;
            request.UserID      = UserToEdit.UserID;
            SearchProjectsResponse  response   = new ProjectApplication().SearchProjects(request);
            List <ProjectDetailDTO> ResultList = response.ResultList;

            if (ResultList != null && ResultList.Count > 0)
            {
                // ResultList.RemoveAll(r => r.Status == (int)ProjectStatus.Cancelled || r.Status == (int)ProjectStatus.Completed);
                rptProjects.DataSource = ResultList;
                rptProjects.DataBind();
                ProjectPage.RecordCount = response.ResultCount;
                trNoProjects.Visible    = false;
            }
        }
Exemplo n.º 3
0
        public SearchProjectsResponse SearchProjects(SearchProjectsRequest request)
        {
            this.ClearBrokenRuleMessages();
            SearchProjectsResponse response = mgr.SearchProjects(request);

            this.AddBrokenRuleMessages(mgr.BrokenRuleMessages);
            return(response);
        }
Exemplo n.º 4
0
        private string ShowProjectName(int tid)
        {
            SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.SingleInstance, false, " Title ", " ASC ");

            request.ProjectID = tid;

            SearchProjectsResponse reponse = proApp.SearchProjects(request);

            return(null != reponse ? reponse.ResultList[0].Title : "");
        }
Exemplo n.º 5
0
        public SearchProjectsResponse SearchProjects(SearchProjectsRequest request)
        {
            this.ClearBrokenRuleMessages();
            SearchProjectsResponse response = projResp.SearchProjects(request);

            if (response == null)
            {
                this.AddBrokenRuleMessage();
            }
            return(projResp.SearchProjects(request));
        }
Exemplo n.º 6
0
        protected void tm_ddlCompany_SelectedIndexChanged(object sender, EventArgs e)
        {
            SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.Company, false, " Title ", " ASC ");

            request.CompanyID = int.Parse(this.tm_ddlCompany.SelectedValue);
            SearchProjectsResponse response = proApp.SearchProjects(request);

            if (response.ResultList != null || response.ResultList.Count > 0)
            {
                this.tm_ddlProject.DataSource = response.ResultList;
                this.tm_ddlProject.DataBind();
                //this.tm_ddlProject.SelectItem("0");
            }
        }
Exemplo n.º 7
0
 public List <ProjectDetailDTO> GetAllProjects()
 {
     if (cache[CACHE_PROJECTLIST_KEY] == null)
     {
         SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.All, false, "Title", "ASC");
         this.ClearBrokenRuleMessages();
         SearchProjectsResponse response = projResp.SearchProjects(request);
         if (response.ResultList == null)
         {
             this.AddBrokenRuleMessage();
             return(null);
         }
         cache[CACHE_PROJECTLIST_KEY] = response.ResultList;
     }
     return(cache[CACHE_PROJECTLIST_KEY] as List <ProjectDetailDTO>);
 }
Exemplo n.º 8
0
        private void InitControl()
        {
            SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.List, true, hidOrderBy.Value, hidOrderDirection.Value);

            request.Keywords = txtKeyword.Text;

            request.CurrentPage = anpProjects.CurrentPageIndex;
            request.PageCount   = anpProjects.PageSize;
            request.CompanyID   = int.Parse(ddlCompany.SelectedValue);
            SearchProjectsResponse response = projApp.SearchProjects(request);

            rptProjects.DataSource = response.ResultList;
            rptProjects.DataBind();

            anpProjects.RecordCount = response.ResultCount;
            //ltlTotal.Text = request.RecordCount.ToString();
        }
Exemplo n.º 9
0
        private void BindProject()
        {
            ProjectApplication proApp = new ProjectApplication();

            if (ddlCompanies.SelectedValue == "0")
            {
                List <ProjectDetailDTO> list = proApp.GetAllProjects();
                list.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ID", "All", "0");
            }
            else
            {
                SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.List, false, "Title", "ASC");
                request.CompanyID = int.Parse(ddlCompanies.SelectedValue);
                SearchProjectsResponse response = proApp.SearchProjects(request);
                response.ResultList.BindDropdown <ProjectDetailDTO>(ddlProject, "Title", "ID", "All", "0");
            }
        }
Exemplo n.º 10
0
        protected void InitProjectList()
        {
            SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.ListByUserID
                                                                      , true, hidOrderBy.Value, hidOrderDirection.Value);

            request.CurrentPage = anpProjects.CurrentPageIndex;
            request.PageCount   = anpProjects.PageSize;
            request.UserID      = UserToEdit.UserID;
            SearchProjectsResponse response = new ProjectApplication().SearchProjects(request);

            rptProjects.DataSource = response.ResultList;
            rptProjects.DataBind();

            anpProjects.RecordCount = response.ResultCount;
            if (anpProjects.RecordCount > 0)
            {
                trNoRecords.Visible = false;
            }
        }
Exemplo n.º 11
0
        private void InitControl()
        {
            SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.List, true, OrderBy, OrderDirection);

            request.Keywords = QS("keywork");

            request.CurrentPage = CurrentPageIndex;
            request.PageCount   = anpWaitting.PageSize;
            request.CompanyID   = int.Parse(ddlCompany.SelectedValue);
            SearchProjectsResponse response = projApp.SearchProjects(request);

            rptProjects.DataSource = response.ResultList;
            rptProjects.DataBind();
            anpWaitting.RecordCount = response.ResultCount;
            if (response.ResultCount == 0)
            {
                this.trNoTickets.Visible = true;
            }
        }
Exemplo n.º 12
0
        private void InitProjects()
        {
            ProjectApplication    projApp = new ProjectApplication();
            SearchProjectsRequest request = new SearchProjectsRequest(SearchProjectsType.Company, false, " Title ", " ASC ");

            request.CompanyID = CompanyID;

            SearchProjectsResponse response = projApp.SearchProjects(request);

            if (response.ResultList == null || response.ResultList.Count <= 0)
            {
                trNoProject.Visible = true;
            }
            else
            {
                rptProjects.DataSource = response.ResultList;
                rptProjects.DataBind();
                trNoProject.Visible = false;
            }
        }
Exemplo n.º 13
0
        public List <ProjectDetailDTO> GetUserProjects(UsersEntity user)
        {
            List <ProjectDetailDTO> list;
            List <ProjectDetailDTO> all = GetAllProjects();

            switch (user.Role)
            {
            case RolesEnum.ADMIN:
                list = all;
                break;

            case RolesEnum.CLIENT:
                list = all.FindAll(p => p.CompanyID == user.CompanyID);
                List <int> listProjectId = projResp.GetProjectIdByClientID(user.UserID);
                if (listProjectId.Count == 0)
                {
                    list = new List <ProjectDetailDTO>();
                }
                list = list.FindAll(r => listProjectId.Contains(r.ID));
                break;

            case RolesEnum.PM:
                SearchProjectsRequest requestUserPM = new SearchProjectsRequest(SearchProjectsType.ListByUserID, false, "Title", "ASC");
                requestUserPM.UserID = user.ID;
                list = this.SearchProjects(requestUserPM).ResultList;
                if (list.Count > 0)
                {
                    list = list.Distinct <ProjectDetailDTO>(new ProjectCompare()).OrderBy(r => r.Title.Trim()).ToList <ProjectDetailDTO>();
                }
                break;

            default:
                SearchProjectsRequest requestUser = new SearchProjectsRequest(SearchProjectsType.ListByUserID, false, "Title", "ASC");
                requestUser.UserID = user.ID;
                list = this.SearchProjects(requestUser).ResultList;
                break;
            }
            return(list);
        }
        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;
            }
        }
        public SearchProjectsResponse SearchProjects(SearchProjectsRequest request)
        {
            int start = request.CurrentPage * request.PageCount + 1 - request.PageCount;
            int end   = request.CurrentPage * request.PageCount;

            string        strSelCount        = " SELECT COUNT(1)  FROM  Projects p";
            string        strOrderby         = string.Format(" ({0}) {1} ", request.OrderExpression, request.OrderDirection);
            string        strSelAttrs        = @" SELECT p.*, (SELECT UserName FROM Users WHERE UserID =P.ModifiedBy) AS ModifiedByUserName, 
                                                (SELECT UserName FROM Users WHERE UserID =P.CreatedBy) AS CreatedByUserName,
                                                (SELECT UserName FROM Users WHERE UserID =P.PMID) AS PMUserName,
                                                (SELECT FirstName FROM Users WHERE UserID =P.PMID) AS PMFirstName,
                                                (SELECT LastName FROM Users WHERE UserID =P.PMID) AS PMLastName,
                                                (select  CompanyName from   Companys where  ComID=p.CompanyID ) as CompanyName  
                                    FROM   Projects p  ";
            string        strSelAttrsOrderBy = string.Format(@" Order BY {0}  ", strOrderby);
            string        strSelPageModel    = string.Format(@"SELECT * FROM(
                                                SELECT ROW_NUMBER() OVER(
                                                Order BY {0}) as  INDEX_ID,p.* , (SELECT UserName FROM Users WHERE UserID =P.ModifiedBy) AS ModifiedByUserName, 
                                                                                    (SELECT UserName FROM Users WHERE UserID =P.CreatedBy) AS CreatedByUserName,
                                                                                    (SELECT UserName FROM Users WHERE UserID =P.PMID) AS PMUserName ,
                                                                                    (SELECT FirstName FROM Users WHERE UserID =P.PMID) AS PMFirstName,
                                                                                    (SELECT LastName FROM Users WHERE UserID =P.PMID) AS PMLastName,
                                                                                    (select  CompanyName from   Companys where  ComID=p.CompanyID ) as CompanyName  
                                                FROM   Projects p   ", strOrderby);
            string        strWherePageModel  = @") NEW_TB  WHERE INDEX_ID BETWEEN @Strat AND  @End;";
            StringBuilder strWhere           = new StringBuilder();

            strWhere.Append(" WHERE 1=1 ");
            switch (request.SearchType)
            {
            case SearchProjectsType.All:
                break;

            case SearchProjectsType.AllExceptAssigned:
                strWhere.Append(" AND  p.[ProjectID] not in (Select ProjectID from ProjectUsers pu where pu.UserID=@UserID)");
                strWhere.Append(" AND (p.Title LIKE @Keywords OR p.ProjectCode LIKE @Keywords )");
                break;

            case SearchProjectsType.List:
                strWhere.Append(" AND (p.Title LIKE @Keywords OR p.ProjectCode LIKE @Keywords )");
                if (request.CompanyID != 0)
                {
                    strWhere.Append(" AND CompanyID=@CompanyID");
                }
                break;

            case SearchProjectsType.Company:
                if (request.CompanyID != 0)
                {
                    strWhere.Append(" AND  p.[CompanyID] = @CompanyID");
                }
                strWhere.Append(" AND (p.Title LIKE @Keywords OR p.ProjectCode LIKE @Keywords )");
                break;

            case SearchProjectsType.CompanyExceptAssigned:
                if (request.CompanyID != 0)
                {
                    strWhere.Append(" AND  p.[CompanyID] = @CompanyID");
                }
                strWhere.Append(" AND (p.Title LIKE @Keywords OR p.ProjectCode LIKE @Keywords )");
                strWhere.Append(" AND  p.[ProjectID] not in (Select ProjectID from ProjectUsers pu where pu.UserID=@UserID)");
                break;

            case SearchProjectsType.SingleInstance:
                strWhere.Append(" AND  p.[ProjectID] = @ProjectID");
                break;

            case SearchProjectsType.ListByUserID:
                strWhere.Append(" AND  p.[ProjectID] in (Select ProjectID from ProjectUsers pu where pu.UserID=@UserID)");
                break;

            case SearchProjectsType.Ticket:
                strWhere.Append(" AND  p.[ProjectID] IN (SELECT   [ProjectID] FROM [Tickets] WHERE [TicketID]=@TicketID)");
                break;

            default: break;
            }

            StringBuilder strSql = new StringBuilder();

            if (request.IsPageModel)
            {
                strSql.Append(strSelCount);
                strSql.Append(strWhere);
                strSql.Append(";");
                strSql.Append(strSelPageModel);
                strSql.Append(strWhere);
                strSql.Append(strWherePageModel);
            }
            else
            {
                strSql.Append(strSelAttrs);
                strSql.Append(strWhere);
                strSql.Append(strSelAttrsOrderBy);
                strSql.Append(";");
            }
            List <ProjectDetailDTO> list;
            SearchProjectsResponse  response = new SearchProjectsResponse();
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "UserID", DbType.Int32, request.UserID);
                    db.AddInParameter(dbCommand, "TicketID", DbType.Int32, request.TicketID);
                    db.AddInParameter(dbCommand, "ProjectID", DbType.Int32, request.ProjectID);
                    db.AddInParameter(dbCommand, "CompanyID", DbType.Int32, request.CompanyID);
                    db.AddInParameter(dbCommand, "Keywords", DbType.String, string.Format("%{0}%", request.Keywords.FilterSqlString()));
                    db.AddInParameter(dbCommand, "Strat", DbType.Int32, start);
                    db.AddInParameter(dbCommand, "End", DbType.Int32, end);

                    using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                    {
                        list = new List <ProjectDetailDTO>();
                        if (request.IsPageModel)
                        {
                            if (dataReader.Read())
                            {
                                response.ResultCount = dataReader.GetInt32(0);
                                dataReader.NextResult();
                            }
                        }
                        while (dataReader.Read())
                        {
                            list.Add(ProjectDetailDTO.ReaderBind(dataReader));
                        }
                        response.ResultList = list;
                    }
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(),
                                                    base.FormatParameters(dbCommand.Parameters),
                                                    ex.Message));
                }
            }
            return(response);
        }