Esempio n. 1
0
        public JsonResult GetMyProjectList(MvcAdapter.QueryBuilder qb)
        {
            qb.SortField = "DefaultType";
            qb.SortOrder = "desc";
            var state = ProjectCommoneState.Finish.ToString() + "," +
                        ProjectCommoneState.Pause.ToString() + "," +
                        ProjectCommoneState.Terminate.ToString();
            //当前用户参与的项目
            string sql = @"select * from (select S_I_ProjectInfo.*, S_I_UserDefaultProjectInfo.ID as DefaultType from S_I_UserDefaultProjectInfo with(nolock)
                    inner join S_I_ProjectInfo with(nolock) on S_I_UserDefaultProjectInfo.ProjectInfoID=S_I_ProjectInfo.ID
                    where S_I_UserDefaultProjectInfo.UserID='" + CurrentUserInfo.UserID + "' ";

            sql = sql + " union all select *,'2' as DefaultType from S_I_ProjectInfo with(nolock) where ID in (select ProjectInfoID from S_W_RBS with(nolock) where UserID='" + CurrentUserInfo.UserID + "') and State not in ('" + state.Replace(",", "','") + "') and ID not in (select ProjectInfoID from S_I_UserDefaultProjectInfo with(nolock) where UserID='" + CurrentUserInfo.UserID + "')) a ";

            var dt   = this.SqlHelper.ExecuteDataTable(sql, qb);
            var json = JsonHelper.ToJson(dt);
            List <S_I_ProjectInfo> list = JsonHelper.ToObject <List <S_I_ProjectInfo> >(json);
            var prjIDs = string.Join(",", list.Select(c => c.ID.ToString()));

            var rbsList = (from rbs in entities.Set <S_W_RBS>().Where(p => p.UserID == Formula.FormulaHelper.UserID && prjIDs.IndexOf(p.ProjectInfoID) >= 0)
                           select rbs).ToList();
            var wbsSql  = "select * from S_W_WBS with(nolock) where ProjectInfoID in ('" + prjIDs.Replace(",", "','") + "')";
            var wbsList = this.SqlHelper.ExecuteList <S_W_WBS>(wbsSql);

            var phaseDt = Project.Logic.BaseConfigFO.GetWBSEnum(WBSNodeType.Phase);

            List <ProjectInfo> prjList = new List <ProjectInfo>();

            var showAllMajor = true;

            if (!string.IsNullOrEmpty(GetQueryString("ShowAllMajor")))
            {
                showAllMajor = GetQueryString("ShowAllMajor").ToLower() == "true";
            }
            foreach (S_I_ProjectInfo item in list)
            {
                var majorType      = WBSNodeType.Major.ToString();
                var majorCodes     = string.Join(",", wbsList.Where(d => d.ProjectInfoID == item.ID && d.WBSType == majorType).Select(d => d.MajorCode).Distinct());
                var joinMajorCodes = string.Join(",", rbsList.Where(p => p.ProjectInfoID == item.ID && p.MajorValue != "" && p.MajorValue != null).Select(p => p.MajorValue).Distinct());
                prjList.Add(new ProjectInfo
                {
                    ID             = item.ID,
                    Name           = item.Name,
                    Code           = item.Code,
                    PlanStartDate  = item.PlanStartDate == null ? "" : item.PlanStartDate.Value.ToShortDateString(),
                    ChargeUserName = item.ChargeUserName,
                    Phase          = GetEnum(phaseDt, item.PhaseValue),
                    Status         = EnumBaseHelper.GetEnumDescription(typeof(ProjectCommoneState), item.State),
                    Role           = string.Join(",", rbsList.Where(p => p.ProjectInfoID == item.ID).Select(c => c.RoleName.ToString()).Distinct()),
                    //haveMonitorPort = rbsList.Exists(p => p.ProjectInfoID == item.ID && p.WBSType == "Project" && string.IsNullOrEmpty(p.MajorValue)),
                    //haveDesignPort = string.IsNullOrEmpty(majorCodes) ? false : true,
                    Major = showAllMajor ? majorCodes : joinMajorCodes,
                });
            }

            GridData data = new GridData(prjList);

            data.total = qb.TotolCount;
            return(Json(data));
        }
Esempio n. 2
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            var mpid   = GetQueryString("MpID");
            var result = entities.Set <MpMediaVoice>().Where(c => c.MpID == mpid && c.IsDelete == 0).WhereToGridData(qb);

            return(Json(result));
        }
Esempio n. 3
0
        public JsonResult GetRelationList(MvcAdapter.QueryBuilder qb)
        {
            //流程定义增加子公司权限
            if (System.Configuration.ConfigurationManager.AppSettings["CorpAuthEnabled"].ToLower() == "true" &&
                Request["listType"] == "subCompany")
            {
                qb.Add("CompanyID", QueryMethod.Like, FormulaHelper.GetUserInfo().UserCompanyID);
            }

            GridData data;
            string   categoryID = Request["NodeFullID"];

            if (string.IsNullOrEmpty(categoryID))
            {
                data       = new GridData(entities.Set <S_WF_DefFlow>().Where(qb).Select(c => new { ID = c.ID, Code = c.Code, Name = c.Name, ConnName = c.ConnName, TableName = c.TableName, Description = c.Description, AlreadyReleased = c.AlreadyReleased, ModifyTime = c.ModifyTime }));
                data.total = qb.TotolCount;
            }
            else
            {
                categoryID = categoryID.Split('.').Last();
                SQLHelper baseSqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Base);
                string    sql           = string.Format("select ID from S_M_Category where ID='{0}' or ParentID='{0}'", categoryID);
                var       dt            = baseSqlHelper.ExecuteDataTable(sql);
                string    ids           = string.Join(",", dt.AsEnumerable().Select(c => c["ID"].ToString()).ToArray());
                qb.Add("CategoryID", QueryMethod.In, ids);
                data       = new GridData(entities.Set <S_WF_DefFlow>().Where(qb).Select(c => new { ID = c.ID, Code = c.Code, Name = c.Name, ConnName = c.ConnName, TableName = c.TableName, Description = c.Description, AlreadyReleased = c.AlreadyReleased, ModifyTime = c.ModifyTime }));
                data.total = qb.TotolCount;
            }


            return(Json(data));
        }
Esempio n. 4
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            string sql = @"select ID as HRUserID,Name as UserName,Code as UserCode,Sex,DeptID,DeptName,JoinCompanyDate,UserID,IsDeleted
from T_Employee where UserID is not null and UserID <> ''";

            var item       = qb.Items.FirstOrDefault(c => c.Field == "BelongYear");
            var belongYear = DateTime.Now.Year;

            if (item != null)
            {
                belongYear = Convert.ToInt32(item.Value);
                qb.Items.Remove(item);
            }

            var resourceDt = this.SqlHelper.ExecuteDataTable("select * from S_W_UserUnitPrice order by StartDate desc");
            var list       = resourceDt.AsEnumerable();
            var dt         = this.SqlHelper.ExecuteDataTable(sql, qb);
            var result     = FormulaHelper.DataTableToListDic(this.SqlHelper.ExecuteDataTable(sql, qb));

            foreach (var dic in result)
            {
                for (int i = 1; i <= 12; i++)
                {
                    var priceRow = list.FirstOrDefault(c => c["HRUserID"].ToString() == dic.GetValue("HRUserID") && Convert.ToInt32(c["BelongMonth"]) == i &&
                                                       Convert.ToInt32(c["BelongYear"]) == belongYear);
                    if (priceRow == null)
                    {
                        var date = new DateTime(belongYear, i, 1);
                        priceRow = list.FirstOrDefault(c => Convert.ToDateTime(c["StartDate"]) <= date &&
                                                       c["HRUserID"].ToString() == dic.GetValue("HRUserID"));
                        if (priceRow == null)
                        {
                            dic.SetValue("UnitPrice_" + i.ToString(), 0);
                        }
                        else
                        {
                            dic.SetValue("UnitPrice_" + i.ToString(), priceRow["UnitPrice"]);
                            dic.SetValue("ResourceCode_" + i.ToString(), priceRow["ResourceCode"]);
                        }
                    }
                    else
                    {
                        dic.SetValue("UnitPrice_" + i.ToString(), priceRow["UnitPrice"]);
                        dic.SetValue("ResourceCode_" + i.ToString(), priceRow["ResourceCode"]);
                    }
                }
                var maxVersionRow = list.FirstOrDefault(c => c["HRUserID"].ToString() == dic.GetValue("HRUserID"));
                if (maxVersionRow != null)
                {
                    dic.SetValue("ModifyUser", maxVersionRow["ModifyUser"]);
                    dic.SetValue("ModifyDate", maxVersionRow["ModifyDate"]);
                    dic.SetValue("ResourceCode", maxVersionRow["ResourceCode"]);
                }
                dic.SetValue("BelongYear", belongYear);
            }
            var gridData = new GridData(result);

            gridData.total = qb.TotolCount;
            return(Json(gridData));
        }
Esempio n. 5
0
        public JsonResult GetWordList(MvcAdapter.QueryBuilder qb)
        {
            SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Base);
            string    sql       = "select * from S_UI_Word";

            if (!string.IsNullOrEmpty(Request["CategoryID"]))
            {
                sql += string.Format(" where CategoryID='{0}'", Request["CategoryID"]);
            }


            DataTable dt = sqlHelper.ExecuteDataTable(sql, qb);

            dt.Columns.Add("HasWord");
            foreach (DataRow row in dt.Rows)
            {
                string tmplName = row["Code"].ToString() + ".docx";
                if (!string.IsNullOrEmpty(tmplName))
                {
                    string path = HttpContext.Server.MapPath("/") + "WordTemplate/" + tmplName;
                    if (System.IO.File.Exists(path))
                    {
                        row["HasWord"] = "1";
                    }
                }
            }
            GridData data = new GridData(dt);

            data.total = qb.TotolCount;
            return(Json(data));
        }
Esempio n. 6
0
        public JsonResult GetSendList(MvcAdapter.QueryBuilder qb, string attachment)
        {
            string userID = FormulaHelper.UserID;
            IQueryable <S_S_MsgBody> query  = entities.Set <S_S_MsgBody>().Where(c => c.SenderID == userID && c.IsDeleted == "0");
            List <S_S_MsgReceiver>   recAll = entities.Set <S_S_MsgReceiver>().ToList();

            foreach (var item in query.ToArray())
            {
                string[] ids   = item.ReceiverIDs.Split(',');
                string[] names = item.ReceiverNames.Split(',');
                for (int i = 0; i < ids.Length; i++)
                {
                    string id       = ids[i];
                    var    receiver = recAll.Where(c => c.MsgBodyID == item.ID && c.UserID == id).FirstOrDefault();
                    if (receiver != null && (!string.IsNullOrEmpty(receiver.FirstViewTime.ToString()) || Convert.ToInt32(receiver.IsDeleted) == 1))
                    {
                        names[i] = string.Format("<font style='color:#3c8dbc;' title='{0}'>{1}</font>",
                                                 string.IsNullOrEmpty(receiver.FirstViewTime.ToString()) ? ((DateTime)receiver.DeleteTime).ToString("yyyy年MM月dd日 HH:mm:ss") : ((DateTime)receiver.FirstViewTime).ToString("yyyy年MM月dd日 HH:mm:ss"), names[i]);
                    }
                }
                item.ReceiverNames = string.Join(",", names);
            }
            if (attachment == "T")
            {
                query = query.Where(c => !string.IsNullOrEmpty(c.AttachFileIDs));
            }
            return(Json(query.WhereToGridData(qb)));
        }
Esempio n. 7
0
        private List <Event> GetPersonalSchedules(MvcAdapter.QueryBuilder qb)
        {
            string userID = FormulaHelper.GetUserInfo().UserID;
            IQueryable <S_H_Calendar> query = entities.Set <S_H_Calendar>().Where(c => c.CreateUserID == userID);
            List <S_H_Calendar>       list  = query.Where(qb).ToList();

            return(SchedulesToEvents(list));
        }
Esempio n. 8
0
        public JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            if (qb.SortField == "ID")
            {
                qb.SortField = "MajorValue";
            }

            var projectInfoID = GetQueryString("ProjectInfoID");
            var projectInfo   = this.GetEntityByID <S_I_ProjectInfo>(projectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到指定的项目。");
            }
            Dictionary <string, object> data = new Dictionary <string, object>();
            string sql       = @"select * from S_W_TaskWork where ProjectInfoID='" + projectInfoID + "'";
            var    TaskWorks = this.BusinessEntities.Set <S_W_TaskWork>().Where(a => a.ProjectInfoID == projectInfoID).WhereToGridData(qb);

            qb.Items.RemoveWhere(d => d.Field != "MajorValue");
            var     sumSchemed   = this.BusinessEntities.Set <S_W_TaskWork>().Where(a => a.ProjectInfoID == projectInfoID).Where(qb).Sum(a => a.Workload);
            decimal?sumWorkload  = 0;
            decimal?sumPublished = 0;
            decimal?sumFinished  = 0;
            var     code         = CBSCategoryType.Product.ToString();

            if (qb.Items.Count != 0)
            {
                code = qb.Items[0].Value.ToString();
            }

            var cbs = this.BusinessEntities.Set <S_C_CBS>().Where(a => a.Code == code && a.ProjectInfoID == projectInfoID);

            sumWorkload  = cbs.Sum(a => a.Quantity);
            sumPublished = cbs.Sum(a => a.SummaryBudgetQuantity);
            sumFinished  = cbs.Sum(a => a.SummaryCostQuantity);

            var obsUsers = projectInfo.S_W_OBSUser.Select(a => new { Major = a.MajorValue, RoleCode = a.RoleCode, UserID = a.UserID, UserName = a.UserName }).ToList();

            if (code != CBSCategoryType.Product.ToString())
            {
                obsUsers = obsUsers.Where(a => a.Major == code).ToList();
            }

            data.Add("data", TaskWorks.data);
            data.Add("total", qb.TotolCount);
            data.Add("sumData", TaskWorks.sumData);
            data.Add("avgData", TaskWorks.avgData);
            data.Add("sumWorkload", sumWorkload == null ? 0 : sumWorkload);
            data.Add("sumSchemed", sumSchemed == null ? 0 : sumSchemed);
            data.Add("sumPublished", sumPublished == null ? 0 : sumPublished);
            data.Add("sumFinished", sumFinished == null ? 0 : sumFinished);
            data.Add("obsUsers", obsUsers);
            return(Json(data));
        }
Esempio n. 9
0
        public JsonResult GetSendList(MvcAdapter.QueryBuilder qb, string attachment)
        {
            string userID = FormulaHelper.UserID;
            IQueryable <S_S_MsgBody> query = entities.Set <S_S_MsgBody>().Where(c => c.SenderID == userID && c.IsDeleted == "0");

            if (attachment == "T")
            {
                query = query.Where(c => !string.IsNullOrEmpty(c.AttachFileIDs));
            }
            return(Json(query.WhereToGridData(qb)));
        }
Esempio n. 10
0
        public JsonResult GetFormList(MvcAdapter.QueryBuilder qb)
        {
            if (!string.IsNullOrEmpty(Request["CategoryID"]))
            {
                qb.Add("CategoryID", QueryMethod.Equal, Request["CategoryID"]);
            }
            var      list = entities.Set <S_UI_Form>().Where(qb).Select(c => new { ID = c.ID, Code = c.Code, Name = c.Name, ConnName = c.ConnName, TableName = c.TableName, ModifyTime = c.ModifyTime, Category = c.Category });
            GridData data = new GridData(list);

            data.total = qb.TotolCount;

            return(Json(data));
        }
Esempio n. 11
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            string catalogId = this.Request["CatalogId"];
            IQueryable <S_I_PublicInformation> query = entities.Set <S_I_PublicInformation>().Where(c => string.IsNullOrEmpty(c.DeptDoorId));

            if (!string.IsNullOrEmpty(catalogId))
            {
                query = query.Where(c => c.CatalogId == catalogId);
            }
            GridData grid = query.WhereToGridData(qb);

            return(Json(grid));
        }
Esempio n. 12
0
        public JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            string sqlBase = "select id,starttime, endtime , title,description , '' as url,'' as width,'' as height,'Schedule' as \"type\",'' as FormInstanceID from S_H_Calendar where CreateUserID = '{0}' ";
            string userID  = FormulaHelper.GetUserInfo().UserID;

            sqlBase = string.Format(sqlBase, userID);
            SQLHelper baseSqlHelper = SQLHelper.CreateSqlHelper("Base");
            var       dt            = baseSqlHelper.ExecuteDataTable(sqlBase, qb);
            var       gridData      = new GridData(dt);

            gridData.total = qb.TotolCount;
            return(Json(gridData, JsonRequestBehavior.AllowGet));
        }
Esempio n. 13
0
        public JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            if (!string.IsNullOrEmpty(Request["CategoryID"]))
            {
                string categoryID = Request["CategoryID"];
                var    arr        = entities.Set <S_M_Category>().Where(c => c.ID == categoryID || c.ParentID == categoryID).Select(c => c.ID).ToArray();
                string ids        = string.Join(",", arr);
                qb.Add("CategoryID", QueryMethod.In, ids);
            }
            var      list = entities.Set <S_UI_FreePivot>().Where(qb).Select(c => new { ID = c.ID, Code = c.Code, Name = c.Name, ConnName = c.ConnName, ModifyTime = c.ModifyTime, Description = c.Description });
            GridData data = new GridData(list);

            data.total = qb.TotolCount;

            return(Json(data));
        }
Esempio n. 14
0
        public JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            string sqlBase = @"
select ID as id,StartTime as start,[EndTime] as endtime,Title as title,Description as [description]
	,'' as url,'' as width,'' as height,'Schedule' as [type],'' as FormInstanceID
from S_H_Calendar
where CreateUserID = '{0}'

";
            string userID  = FormulaHelper.GetUserInfo().UserID;

            sqlBase = string.Format(sqlBase, userID);
            SQLHelper baseSqlHelper = SQLHelper.CreateSqlHelper("Base");
            GridData  gridData      = baseSqlHelper.ExecuteGridData(sqlBase, qb);

            return(Json(gridData, JsonRequestBehavior.AllowGet));
        }
Esempio n. 15
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            var groupInfoID = Request["GroupInfoID"];
            var group       = this.GetEntityByID <S_I_ProjectGroup>(groupInfoID);

            if (group == null)
            {
                throw new Formula.Exceptions.BusinessException("未能获得指定工程信息");
            }
            string sql = @"select * from S_I_ProjectInfo where GroupRootID='{0}'";

            sql = string.Format(sql, groupInfoID);
            SQLHelper shProject = SQLHelper.CreateSqlHelper(ConnEnum.Project);
            GridData  data      = shProject.ExecuteGridData(sql, qb);

            return(Json(data));
        }
Esempio n. 16
0
        public JsonResult GetPerformanceList(MvcAdapter.QueryBuilder qb)
        {
            var userID = this.GetQueryString("UserID");
            var sql    = string.Format(@"select * from (
select  sp.*,ProjectRole=stuff((select distinct ','+ProjectRole
							FROM (select ProjectInfoID,ChargeUser,MajorPrinciple,Designer,Collactor,Auditor,Approver 
								from S_P_Performance pf left join S_P_Performance_JoinPeople pfj 
								on pf.ID=pfj.S_P_PerformanceID) tmp
							unpivot(UserIDs FOR ProjectRole in(ChargeUser,MajorPrinciple,Designer,Collactor,Auditor,Approver))AS up
							where UserIDs like '%{0}%'
							and ProjectInfoID=sp.ProjectInfoID
						for xml path('')) ,1,1,'') 
from S_P_Performance sp) tmp
where ProjectRole!='' and ProjectRole is not null", userID);

            var dt = this.SqlHelper.ExecuteGridData(sql, qb);

            return(Json(dt));
        }
Esempio n. 17
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            var whereStr     = "";
            var projectClass = this.GetQueryString("ProjectClass");
            var phaseName    = this.GetQueryString("PhaseName");
            var projectLevel = this.GetQueryString("ProjectLevel");

            if (!string.IsNullOrEmpty(projectClass))
            {
                whereStr += " and ProjectClass='" + projectClass + "' ";
            }
            if (!string.IsNullOrEmpty(phaseName))
            {
                whereStr += " and PhaseName='" + phaseName + "' ";
            }
            if (!string.IsNullOrEmpty(projectLevel))
            {
                whereStr += " and ProjectLevel='" + projectLevel + "' ";
            }


            var sql = string.Format(@"select distinct emp.ID,emp.Name,emp.Code,emp.PositionalTitles,emp.Educational,emp.EngageMajor,emp.UserID
	,QualificationName=stuff((select distinct ','+QualificationName 
						from T_EmployeeQualification 
						where EmployeeID=emp.ID 
						for xml path('')) ,1,1,'') 
	,JobNames=stuff((select distinct ','+JobName 
			from T_EmployeeJob 
			where EmployeeID=emp.ID
			and IsDeleted=0
			for xml path('')) ,1,1,'')
from T_Employee emp
left join S_P_Performance_JoinPeople pfj
	on emp.UserID=pfj.MajorPrinciple
left join S_P_Performance pf
	on pf.ID=pfj.S_P_PerformanceID
where emp.IsDeleted=0 {0}", whereStr);

            var db = this.SqlHelper.ExecuteGridData(sql, qb);

            return(Json(db));
        }
Esempio n. 18
0
        public JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            if (!string.IsNullOrEmpty(Request["CategoryID"]))
            {
                string categoryID = Request["CategoryID"];
                var    arr        = entities.Set <S_M_Category>().Where(c => c.ID == categoryID || c.ParentID == categoryID).Select(c => c.ID).ToArray();
                string ids        = string.Join(",", arr);
                qb.Add("CategoryID", QueryMethod.In, ids);
            }

            //列表定义增加子公司权限
            if (System.Configuration.ConfigurationManager.AppSettings["CorpAuthEnabled"].ToLower() == "true" &&
                Request["listType"] == "subCompany")
            {
                qb.Add("CompanyID", QueryMethod.Equal, FormulaHelper.GetUserInfo().AdminCompanyID);
            }

            var      list = entities.Set <S_UI_List>().Where(qb).Select(c => new { ID = c.ID, Code = c.Code, Name = c.Name, ConnName = c.ConnName, SQL = c.SQL, ModifyTime = c.ModifyTime, CompanyName = c.CompanyName });
            GridData data = new GridData(list);

            data.total = qb.TotolCount;

            return(Json(data));
        }
        public JsonResult GetFlowExecList(string id, MvcAdapter.QueryBuilder qb)
        {
            if (string.IsNullOrEmpty(id))
            {
                return(Json("[]"));
            }
            var    LGID = FormulaHelper.GetCurrentLGID();
            string sql  = string.Format(sqlFlowExecList, id, LGID);

            SQLHelper sqlHelper = SQLHelper.CreateSqlHelper("Workflow");

            DataTable dt = sqlHelper.ExecuteDataTable(sql);

            if (dt.Rows.Count == 0)
            {
                return(Json(dt));
            }

            string insDefFlowID = dt.Rows[0]["InsDefFlowID"].ToString();

            sql = string.Format("select ID,Name from S_WF_InsDefRouting where InsDefFlowID='{0}'", insDefFlowID);
            DataTable dtRouting = sqlHelper.ExecuteDataTable(sql, qb);

            dt.Columns.Add("UseTime");
            dt.Columns.Add("TaskUserDept");

            var userService = FormulaHelper.GetService <IUserService>();

            foreach (DataRow row in dt.Rows)
            {
                string ExecRoutingIDs = row["ExecRoutingIDs"].ToString().Trim(',');
                if (!string.IsNullOrEmpty(ExecRoutingIDs) && row["ExecRoutingName"].ToString() == "")
                {
                    row["ExecRoutingName"] = dtRouting.AsEnumerable().SingleOrDefault(c => c["ID"].ToString() == ExecRoutingIDs.Split(',').LastOrDefault())["Name"];
                }
                //处理打回和直送操作的名称
                if (string.IsNullOrEmpty(ExecRoutingIDs) && row["ExecRoutingName"].ToString() == "" && row["ExecTime"].ToString() != "")
                {
                    if (row["Type"].ToString() == TaskExecType.Normal.ToString() || row["Type"].ToString() == TaskExecType.Delegate.ToString())
                    {
                        if (row["DoBackRoutingID"].ToString() != "")
                        {
                            row["ExecRoutingName"] = "驳回";
                        }
                        if (row["OnlyDoBack"].ToString() == "1")
                        {
                            row["ExecRoutingName"] = "送驳回人";
                        }
                    }
                    else if (row["Type"].ToString() == TaskExecType.Circulate.ToString())
                    {
                        row["ExecRoutingName"] = "阅毕";
                    }
                    else if (row["Type"].ToString() == TaskExecType.Ask.ToString())
                    {
                        row["ExecRoutingName"] = "阅毕";
                    }
                }

                string CreateTime = row["CreateTime"].ToString();
                string ExecTime   = row["ExecTime"].ToString();
                if (!string.IsNullOrEmpty(ExecTime))
                {
                    if (!string.IsNullOrEmpty(row["ApprovalInMobile"].ToString()))
                    {
                        switch (row["ApprovalInMobile"].ToString())
                        {
                        case "1":
                            row["ApprovalInMobile"] = "";
                            break;

                        case "2":
                            row["ApprovalInMobile"] = "钉钉";
                            break;

                        case "3":
                            row["ApprovalInMobile"] = "移动通";
                            break;

                        case "5":
                            row["ApprovalInMobile"] = "微信";
                            break;

                        default:
                            row["ApprovalInMobile"] = "PC";
                            break;
                        }
                    }
                    else
                    {
                        row["ApprovalInMobile"] = "PC";
                    }
                    var span = DateTime.Parse(ExecTime) - DateTime.Parse(CreateTime);
                    row["UseTime"] = string.Format("{0}小时{1}分", span.Days * 24 + span.Hours, span.Minutes == 0 ? 1 : span.Minutes);
                }
                if (row["TaskUserID"].ToString() != "")
                {
                    var ogUser = userService.GetUserInfoByID(row["TaskUserID"].ToString());
                    if (ogUser != null)
                    {
                        row["TaskUserDept"] = ogUser.UserOrgName;
                    }
                }
                else
                {
                    row["TaskUserName"] = "";
                    row["ExecUserName"] = "";
                }
                //操作意见取最新回复
                var    entities    = FormulaHelper.GetEntities <BaseEntities>();
                string routingID   = row["ID"].ToString();
                string execComment = row["ExecComment"].ToString();
                var    msgBody     = entities.Set <S_S_MsgBody>().Where(c => c.FlowMsgID == routingID).OrderByDescending(c => c.SendTime);
                if (msgBody.Count() > 0)
                {
                    execComment = msgBody.First().Content;
                }
                row["ExecComment"] = execComment;
            }

            return(Json(dt));
        }
Esempio n. 20
0
        public JsonResult GetWordList(MvcAdapter.QueryBuilder qb)
        {
            if (!string.IsNullOrEmpty(Request["CategoryID"]))
            {
                string categoryID = Request["CategoryID"];
                var    arr        = entities.Set <S_M_Category>().Where(c => c.ID == categoryID || c.ParentID == categoryID).Select(c => c.ID).ToArray();
                string ids        = string.Join(",", arr);
                qb.Add("CategoryID", QueryMethod.In, ids);
            }

            //word定义增加子公司权限
            if (System.Configuration.ConfigurationManager.AppSettings["CorpAuthEnabled"].ToLower() == "true" &&
                Request["listType"] == "subCompany")
            {
                qb.Add("CompanyID", QueryMethod.Like, FormulaHelper.GetUserInfo().AdminCompanyID);
            }

            SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Base);
            //            string sql = @"
            //select * from(
            //select S_UI_Word.*,HasForm=case when S_UI_Form.Code is null then '0' else '1' end,S_UI_Form.ID FormID
            //from S_UI_Word left join S_UI_Form on S_UI_Word.Code=S_UI_Form.Code where S_UI_Word.VersionEndDate is null
            //) tb1
            //";
            string sql = "select * from S_UI_Word where VersionEndDate is null";

            DataTable dt = sqlHelper.ExecuteDataTable(sql, qb);

            //是否存在word模板标识
            dt.Columns.Add("HasWord");
            foreach (DataRow row in dt.Rows)
            {
                var    versionNum = row["VersionNum"].ToString();
                string tmplName   = row["Code"].ToString() + ".docx";
                if (!string.IsNullOrEmpty(tmplName))
                {
                    string newTmplName = row["Code"].ToString() + "_" + versionNum + ".docx";
                    string path        = HttpContext.Server.MapPath("/") + "WordTemplate/" + tmplName;
                    string newPath     = HttpContext.Server.MapPath("/") + "WordTemplate/" + newTmplName;
                    if (System.IO.File.Exists(path) || System.IO.File.Exists(newPath))
                    {
                        row["HasWord"] = "1";
                    }
                }
            }

            //设置版本数量
            dt.Columns.Add("VersionCount");
            sql = string.Format("select Code,VersionCount=COUNT(1) from S_UI_Word where Code in('{0}') group by Code ", string.Join("','", dt.AsEnumerable().Select(c => c["Code"].ToString())));
            var dtVersionCount = sqlHelper.ExecuteDataTable(sql);

            foreach (DataRow row in dt.Rows)
            {
                row["VersionCount"] = dtVersionCount.AsEnumerable().SingleOrDefault(c => c["Code"].ToString() == row["Code"].ToString())["VersionCount"];
            }

            //设置是否有对应表单定义
            dt.Columns.Add("HasForm");
            sql = string.Format("select Code,VersionCount=COUNT(1) from S_UI_Form where Code in('{0}') group by Code ", string.Join("','", dt.AsEnumerable().Select(c => c["Code"].ToString())));
            var dtVersionFormCount = sqlHelper.ExecuteDataTable(sql);

            foreach (DataRow row in dt.Rows)
            {
                if (dtVersionFormCount.AsEnumerable().Count(c => c["Code"].ToString() == row["Code"].ToString()) > 0)
                {
                    row["HasForm"] = 1;
                }
                else
                {
                    row["HasForm"] = 0;
                }
            }


            GridData data = new GridData(dt);

            data.total = qb.TotolCount;
            return(Json(data));
        }
Esempio n. 21
0
        public JsonResult GetListView(MvcAdapter.QueryBuilder qb, string catalogKey)
        {
            SQLHelper sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Base);

            try
            {
                List <S_I_PublicInformCatalog> listCatalog = entities.Set <S_I_PublicInformCatalog>().Where(c => c.CatalogKey == catalogKey).ToList();
                if (listCatalog.Count > 0)
                {
                    string          whereReceiveRoleId = "";
                    string          catalogID          = listCatalog[0].ID;
                    Config.UserInfo ui           = Formula.FormulaHelper.GetUserInfo();
                    string          userID       = ui.UserID;
                    string[]        arrOrgFullID = ui.UserFullOrgIDs.Replace(",", ".").Split('.').Distinct().ToArray();

                    //处理接收角色
                    IUserService userService = FormulaHelper.GetService <IUserService>();
                    var          roleIds     = userService.GetRolesForUser(userID, "").Split(',');

                    foreach (var roleId in roleIds)
                    {
                        whereReceiveRoleId += string.Format(" or ReceiveRoleId like '%{0}%'", roleId);
                    }


                    if (Config.Constant.IsOracleDb)
                    {
                        string whereReceiveDeptId = string.Empty;
                        for (int i = 0; i < arrOrgFullID.Length; i++)
                        {
                            whereReceiveDeptId += "INSTR(ReceiveDeptId,'" + arrOrgFullID[i] + "',1,1) > 0";
                            if (i < arrOrgFullID.Length - 1)
                            {
                                whereReceiveDeptId += " or ";
                            }
                        }
                        string   whereSql = " and ((nvl(ReceiveUserId,'empty') = 'empty' and nvl(ReceiveDeptId,'empty') = 'empty'  and nvl(ReceiveRoleId,'empty') = 'empty' ) or (nvl(ReceiveUserId,'empty') <> 'empty' and INSTR(ReceiveUserId,'" + userID + "',1,1) > 0) or (nvl(ReceiveDeptId,'empty') <> 'empty' and (" + whereReceiveDeptId + "))" + whereReceiveRoleId + ") ";
                        GridData gridData = sqlHelper.ExecuteGridData(@"
select ID
      ,CatalogId
      ,Title
      ,Content
      ,Attachments
      ,ReceiveDeptId
      ,ReceiveDeptName
      ,ReceiveUserId
      ,ReceiveUserName
      ,ExpiresTime
      ,ReadCount
      ,IsTop
      ,CreateTime
      ,CreateUserName
      ,CreateUserID 
      ,Urgency
      ,Important
    from S_I_PublicInformation where CatalogId = '" + catalogID + "' and (DeptDoorId is null or DeptDoorId='') and (ExpiresTime is null or to_char(ExpiresTime,'yyyy-MM-dd') >= '" + DateTime.Now.ToString("yyyy-MM-dd") + "') " + whereSql + " ORDER BY IsTop DESC, CreateTime DESC", qb);
                        return(Json(gridData));
                    }
                    else
                    {
                        string whereReceiveDeptId = string.Empty;
                        for (int i = 0; i < arrOrgFullID.Length; i++)
                        {
                            whereReceiveDeptId += "charindex('" + arrOrgFullID[i] + "',ReceiveDeptId) > 0";
                            if (i < arrOrgFullID.Length - 1)
                            {
                                whereReceiveDeptId += " or ";
                            }
                        }
                        string   whereSql = " and ((isnull(ReceiveUserId,'') = '' and isnull(ReceiveDeptId,'') = ''  and isnull(ReceiveRoleId,'') = '') or (isnull(ReceiveUserId,'') <> '' and charindex('" + userID + "',ReceiveUserId) > 0) or (isnull(ReceiveDeptId,'') <> '' and (" + whereReceiveDeptId + "))" + whereReceiveRoleId + ") ";
                        GridData gridData = sqlHelper.ExecuteGridData("select * from S_I_PublicInformation with(nolock) where CatalogId = '" + catalogID + "' and isnull(DeptDoorId,'') = '' and (ExpiresTime is null or ExpiresTime >= convert(datetime,convert(varchar(10),getdate(),120))) " + whereSql + " ORDER BY Important DESC,Urgency DESC, CreateTime DESC", qb);
                        return(Json(gridData));
                    }

                    //IQueryable<S_I_PublicInformation> query = entities.Set<S_I_PublicInformation>().OrderByDescending(c => c.IsTop).OrderByDescending(c => c.CreateTime).Where(c => c.CatalogId == catalogID && (c.ExpiresTime == null || c.ExpiresTime >= DateTime.Today) && ((string.IsNullOrEmpty(c.ReceiveUserId) && string.IsNullOrEmpty(c.ReceiveDeptId)) || (!string.IsNullOrEmpty(c.ReceiveUserId) && c.ReceiveUserId.IndexOf(userID) > -1) || (!string.IsNullOrEmpty(c.ReceiveDeptId) && c.ReceiveDeptId.IndexOf(orgID) > -1)));
                    //GridData gridData = query.WhereToGridData(qb)
                }
                else
                {
                    List <S_I_PublicInformation> list = new List <S_I_PublicInformation>();
                    GridData gridData = new GridData(list);
                    gridData.total = list.Count;
                    return(Json(gridData));
                }
            }
            catch (Exception)
            {
                GridData gridData = sqlHelper.ExecuteGridData(@"select a.*,b.CatalogKey,b.CatalogName,IsPublic from S_I_PublicInformation a with(nolock) left join S_I_PublicInformCatalog b with(nolock) 
                        on a.CatalogId = b.id where b.CatalogKey='" + catalogKey + "' and b.IsPublic='1'", qb);
                return(Json(gridData));
            }
        }
Esempio n. 22
0
        public JsonResult GetViewList(MvcAdapter.QueryBuilder qb)
        {
            var           queryTabData = this.Request["queryTabData"];
            var           tabData = JsonHelper.ToList(queryTabData);
            string        majorStr = string.Empty, businessTypeStr = string.Empty, aptitudeLevelStr = string.Empty;
            List <string> majors = new List <string>(), businessTypes = new List <string>(), aptitudeLevels = new List <string>();

            foreach (var item in tabData)
            {
                if (item.GetValue("queryfield") == "AptitudeLevel")
                {
                    aptitudeLevelStr = item.GetValue("value");
                }
                else if (item.GetValue("queryfield") == "ProjectClass")
                {
                    businessTypeStr = item.GetValue("value");
                }
                else if (item.GetValue("queryfield") == "EngageMajor")
                {
                    majorStr = item.GetValue("value");
                }
            }
            var aptitudeLevelCnd = qb.Items.FirstOrDefault(d => d.Field == "AptitudeLevel");

            if (aptitudeLevelCnd != null)
            {
                if (string.IsNullOrEmpty(aptitudeLevelStr))
                {
                    aptitudeLevelStr = aptitudeLevelCnd.Value.ToString();
                }
                qb.Items.Remove(aptitudeLevelCnd);
            }
            var businessTypeCnd = qb.Items.FirstOrDefault(d => d.Field == "ProjectClass");

            if (businessTypeCnd != null)
            {
                if (string.IsNullOrEmpty(businessTypeStr))
                {
                    businessTypeStr = businessTypeCnd.Value.ToString();
                }
                qb.Items.Remove(businessTypeCnd);
            }
            var majorCnd = qb.Items.FirstOrDefault(d => d.Field == "EngageMajor");

            if (majorCnd != null)
            {
                if (string.IsNullOrEmpty(majorStr))
                {
                    majorStr = majorCnd.Value.ToString();
                }
                qb.Items.Remove(majorCnd);
            }
            if (!string.IsNullOrEmpty(aptitudeLevelStr))
            {
                aptitudeLevels = aptitudeLevelStr.Split(',').ToList();
            }
            if (!string.IsNullOrEmpty(businessTypeStr))
            {
                businessTypes = businessTypeStr.Split(',').ToList();
            }
            if (!string.IsNullOrEmpty(majorStr))
            {
                majors = majorStr.Split(',').ToList();
            }

            var sql      = @"
select '' as ID,* from(
select distinct AptitudeLevel,ProjectClass,Major
from S_D_UserAptitude
inner join T_Employee on S_D_UserAptitude.HREmployeeID = T_Employee.ID
where Major is not null and Major <> '' and Major <> 'Project' {0}) as dt";
            var whereStr = "";

            if (!string.IsNullOrEmpty(aptitudeLevelStr))
            {
                whereStr += " and AptitudeLevel in ('" + aptitudeLevelStr.Replace(",", "','") + "')";
            }
            if (!string.IsNullOrEmpty(businessTypeStr))
            {
                whereStr += " and ProjectClass in ('" + businessTypeStr.Replace(",", "','") + "')";
            }
            if (!string.IsNullOrEmpty(majorStr))
            {
                whereStr += " and Major in ('" + majorStr.Replace(",", "','") + "')";
            }
            var aputitudeEnums = EnumBaseHelper.GetEnumTable("HR.UserAptitude");
            var dt             = this.SqlHelper.ExecuteDataTable("select S_D_UserAptitude.* from S_D_UserAptitude inner join T_Employee on S_D_UserAptitude.HREmployeeID = T_Employee.ID and IsDeleted = '0'");

            var result      = this.SqlHelper.ExecuteDataTable(string.Format(sql, whereStr), qb);
            var aptEnumList = new List <string>();

            foreach (DataRow item in aputitudeEnums.Rows)
            {
                result.Columns.Add(item["value"].ToString());
                aptEnumList.Add(item["value"].ToString());
            }

            foreach (DataRow row in result.Rows)
            {
                var aptitudeLevel = row["AptitudeLevel"].ToString();
                var businessType  = row["ProjectClass"].ToString();
                var major         = row["Major"].ToString();
                foreach (var aptEnum in aptEnumList)
                {
                    var users = dt.AsEnumerable().Where(a =>
                                                        a["AptitudeLevel"].ToString() == aptitudeLevel &&
                                                        a["ProjectClass"].ToString() == businessType &&
                                                        a["Major"].ToString() == major &&
                                                        a["Position"].ToString() == aptEnum).ToArray();

                    row[aptEnum] = string.Join(",", users.Select(a => a["UserName"].ToString()));
                }
            }
            GridData gridData = new GridData(result);

            gridData.total = qb.TotolCount;
            return(Json(gridData));
        }
Esempio n. 23
0
        public virtual JsonResult MoveNode(string tmplCode, string listIDs, string moveType, MvcAdapter.QueryBuilder qb)
        {
            var listDef = entities.Set <S_UI_List>().SingleOrDefault(c => c.Code == tmplCode);

            if (listDef == null)
            {
                throw new Exception(string.Format("编号为:“{0}”的列表不存在", tmplCode));
            }
            var layoutGrid  = JsonHelper.ToObject(listDef.LayoutGrid);
            var parentField = layoutGrid.GetValue("parentField");
            var ids         = listIDs.Split(',');

            if (!string.IsNullOrEmpty(parentField))
            {
                if (ids.Count() > 0)
                {
                    listIDs = listIDs.Replace(",", "','");
                    SQLHelper sqlHeler  = SQLHelper.CreateSqlHelper(listDef.ConnName);
                    string    tableName = listDef.TableNames.Split(',')[0];
                    Dictionary <string, string> dics = new Dictionary <string, string>();
                    if (moveType == "left") //向左移动
                    {
                        string sql   = string.Format(@"select * from (select ID,{0} from {1} where ID in (
	                    select {0} from {1} where ID in ('{2}'))
                        union all
                        select ID,{0} from {1} where ID in ('{2}')) a group by ID,{0}", parentField, tableName, listIDs);
                        var    table = sqlHeler.ExecuteDataTable(sql);
                        foreach (var id in ids)
                        {
                            var dr = table.Select(string.Format(" ID='{0}'", id));
                            if (dr.Count() > 0)
                            {
                                var parentID = Convert.ToString(dr.First()[parentField]);
                                if (!string.IsNullOrEmpty(parentID))
                                {
                                    var parent = table.Select(string.Format(" ID='{0}'", parentID));
                                    if (parent.Count() > 0)
                                    {
                                        dics.Add(id, Convert.ToString(parent.First()[parentField]));
                                    }
                                }
                            }
                        }
                    }
                    else if (moveType == "right")
                    { //向右移动
                        if (ids.Count() > 0)
                        {
                            #region 处理数据
                            List <Hierarchy> cacheLevel = new List <Hierarchy>();
                            var listData = Request["ListData"];
                            if (!string.IsNullOrEmpty(listData))
                            {
                                var datas = JsonHelper.ToList(listData);
                                foreach (var item in datas)
                                {
                                    cacheLevel.Add(new Hierarchy()
                                    {
                                        ID       = item.GetValue("ID"),
                                        ParentID = item.GetValue(parentField)
                                    });
                                }
                            }
                            #endregion
                            if (cacheLevel.Count() > 0)
                            {
                                var selObjs = cacheLevel.Where(c => ids.Contains(c.ID)).ToList(); //选择的数据
                                if (selObjs.Count > 0)
                                {
                                    Dictionary <string, List <Hierarchy> > dic = new Dictionary <string, List <Hierarchy> >();
                                    if (selObjs.Count > 0) //选择的数据根据层级放到Dictionary中
                                    {
                                        for (int i = 0; i < selObjs.Count; i++)
                                        {
                                            var single = dic.Where(c => c.Key.Contains(selObjs[i].ParentID));
                                            if (single.Count() <= 0 || single.First().Value == null)
                                            {
                                                var obj = selObjs[i];
                                                List <Hierarchy> list = new List <Hierarchy>();
                                                list.Add(obj);
                                                dic.Add(obj.ParentID, list);
                                            }
                                            else
                                            {
                                                single.First().Value.Add(selObjs[i]);
                                            }
                                        }
                                    }
                                    if (dic.Count > 0)
                                    {
                                        foreach (var item in dic)
                                        {
                                            if (item.Value != null)
                                            {
                                                var prvNodeID = "";
                                                foreach (var obj in item.Value)
                                                {
                                                    var objID = obj.ID; //默认的ID
                                                    for (int i = 0; i < cacheLevel.Count; i++)
                                                    {
                                                        if (cacheLevel[i].ID == objID)
                                                        {
                                                            if (i > 0)
                                                            {
                                                                var pid     = obj.ParentID;
                                                                var parents = cacheLevel.Where(c => c.ParentID == pid).ToList();
                                                                if (parents.Count() > 0)
                                                                {
                                                                    for (int j = 0; j < parents.Count(); j++)
                                                                    {
                                                                        if (parents[j].ID == objID)
                                                                        {
                                                                            if (j > 0)
                                                                            {
                                                                                objID = parents[j - 1].ID;
                                                                                for (int index = 0; index < item.Value.Count; index++)
                                                                                {
                                                                                    if (item.Value[index].ID == obj.ID)
                                                                                    {
                                                                                        if (index > 0 && item.Value[index - 1].ID == objID && !string.IsNullOrEmpty(prvNodeID))
                                                                                        {
                                                                                            objID = prvNodeID;
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                objID = "";
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                break;
                                                            }
                                                        }
                                                    }
                                                    prvNodeID = objID;
                                                    if (!string.IsNullOrEmpty(objID) && obj.ID != objID)
                                                    {
                                                        dics.Add(obj.ID, objID);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ids.Length < 2)
                        {
                            throw new BusinessException("必须选择两条及以上记录,选择的第一条为父级!");
                        }
                        #region 处理数据
                        List <Hierarchy> cacheLevel = new List <Hierarchy>();
                        var listData = Request["ListData"];
                        if (!string.IsNullOrEmpty(listData))
                        {
                            var datas = JsonHelper.ToList(listData);
                            foreach (var item in datas)
                            {
                                cacheLevel.Add(new Hierarchy()
                                {
                                    ID       = item.GetValue("ID"),
                                    ParentID = item.GetValue(parentField)
                                });
                            }
                        }
                        #endregion
                        for (int i = 0; i < ids.Length; i++)
                        {
                            if (i != 0)
                            {
                                bool isSubNode = false;
                                var  datas     = cacheLevel.Where(c => ids.Contains(c.ID)).ToList();
                                var  first     = datas.SingleOrDefault(c => c.ID == ids[0]);
                                foreach (var item in datas)
                                {
                                    if (first != null && item.ID == first.ParentID)
                                    {
                                        isSubNode = true;
                                        break;
                                    }
                                }
                                if (!isSubNode)
                                {
                                    dics.Add(ids[i], ids[0]);
                                }
                                else
                                {
                                    throw new BusinessException("请注意上下级关系,上级节点不能移动到下级节点!");
                                }
                            }
                        }
                    }

                    if (dics.Count > 0)
                    {
                        List <string> upList = new List <string>();
                        foreach (var item in dics)
                        {
                            upList.Add(string.Format("update {0} set {1}='{2}' where ID='{3}'", tableName, parentField, item.Value, item.Key));
                        }
                        sqlHeler.ExecuteNonQuery(string.Join(@" 
                        ", upList.ToArray()));
                    }
                }
            }

            return(Json(""));
        }
Esempio n. 24
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            var           enumService = FormulaHelper.GetService <IEnumService>();
            var           queryTabData = this.Request["queryTabData"];
            var           tabData = JsonHelper.ToList(queryTabData);
            string        major = string.Empty, businessType = string.Empty;
            List <string> majors = new List <string>(), businessTypes = new List <string>();

            foreach (var item in tabData)
            {
                if (item.GetValue("queryfield") == "EngageMajor")
                {
                    major = item.GetValue("value");
                }
                else if (item.GetValue("queryfield") == "ProjectClass")
                {
                    businessType = item.GetValue("value");
                }
            }
            var majorCnd = qb.Items.FirstOrDefault(d => d.Field == "EngageMajor");

            if (majorCnd != null)
            {
                if (string.IsNullOrEmpty(major))
                {
                    major = majorCnd.Value.ToString();
                }
                qb.Items.Remove(majorCnd);
            }
            var businessTypeCnd = qb.Items.FirstOrDefault(d => d.Field == "ProjectClass");

            if (businessTypeCnd != null)
            {
                if (string.IsNullOrEmpty(businessType))
                {
                    businessType = businessTypeCnd.Value.ToString();
                }
                qb.Items.Remove(businessTypeCnd);
            }
            if (!string.IsNullOrEmpty(major))
            {
                majors = major.Split(',').ToList();
            }
            if (!string.IsNullOrEmpty(businessType))
            {
                businessTypes = businessType.Split(',').ToList();
            }

            var whereSqlList = new List <string>();
            var employeeSql  = "select ID,UserID,Name,EngageMajor,DeptID,DeptName,'" + major + "' as Major,'" + businessType + "' as ProjectClass from T_Employee where UserID is not null and UserID <> '' and IsDeleted = '0'";

            foreach (var item in majors)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    whereSqlList.Add("','+EngageMajor+',' like '%," + item + ",%'");
                }
            }
            if (whereSqlList.Count > 0)
            {
                employeeSql += " and (" + string.Join(" or ", whereSqlList) + ")";
            }
            var employeeDt  = this.SqlHelper.ExecuteDataTable(employeeSql, qb);
            var aptitudeSql = "select * from S_D_UserAptitude where 1=1";

            if (!string.IsNullOrEmpty(major))
            {
                aptitudeSql += " and Major in ('" + major.Replace(",", "','") + "')";
            }
            if (!string.IsNullOrEmpty(businessType))
            {
                aptitudeSql += "and ProjectClass in ('" + businessType.Replace(",", "','") + "')";
            }
            var aptitudeList = this.SqlHelper.ExecuteList <S_D_UserAptitude>(aptitudeSql);

            var aputitudeEnums = EnumBaseHelper.GetEnumTable("HR.UserAptitude");
            var aptEnumList    = new List <string>();

            foreach (DataRow item in aputitudeEnums.Rows)
            {
                employeeDt.Columns.Add(item["value"].ToString());
                employeeDt.Columns.Add(item["value"].ToString() + "Title");
                aptEnumList.Add(item["value"].ToString());
            }

            var numInTheory = majors.Count() * businessTypes.Count();

            foreach (DataRow user in employeeDt.Rows)
            {
                var aptitudes = aptitudeList.Where(a => a.UserID == user["UserID"].ToString());
                if (!string.IsNullOrEmpty(major))
                {
                    aptitudes = aptitudes.Where(a => majors.Contains(a.Major));
                }
                if (!string.IsNullOrEmpty(businessType))
                {
                    aptitudes = aptitudes.Where(a => businessTypes.Contains(a.ProjectClass));
                }
                foreach (var aptEnum in aptEnumList)
                {
                    var aptitudeLevels = aptitudes.Where(a => a.Position == aptEnum).OrderBy(a => a.ProjectClass).ThenBy(a => a.Major);
                    var levels         = aptitudeLevels.Select(a => a.AptitudeLevel).Distinct();
                    if (aptitudeLevels.Count() > 0)
                    {
                        if (levels.Count() == 1 && aptitudeLevels.Count() == numInTheory)
                        {
                            user[aptEnum] = levels.FirstOrDefault();
                        }
                        else
                        {
                            user[aptEnum] = "multi";
                            var titleList = aptitudeLevels.Select(a => "{" + a.ProjectClass + "}-{" + a.Major + "}:{" + a.AptitudeLevel + "}");
                            user[aptEnum + "Title"] = string.Join("\n", titleList);
                            if (titleList.Count() != numInTheory)
                            {
                                user[aptEnum + "Title"] += "\n其他:无";
                            }
                        }
                    }
                }
            }
            GridData gridData = new GridData(employeeDt);

            gridData.total = qb.TotolCount;
            return(Json(gridData));
        }
Esempio n. 25
0
        public override JsonResult GetList(MvcAdapter.QueryBuilder qb)
        {
            string sql = @"select * from (
select S_M_EnumItem.Code as ResourceCode,S_M_EnumItem.Name as ResourceName,S_M_EnumItem.SortIndex
from dbo.S_M_EnumItem
left join dbo.S_M_EnumDef on S_M_EnumItem.EnumDefID=S_M_EnumDef.ID
where S_M_EnumDef.Code='HR.ResourceLevel') tableInfo";

            var priceSQL   = "select * from S_W_ResourcePrice";
            var item       = qb.Items.FirstOrDefault(c => c.Field == "BelongYear");
            var belongYear = DateTime.Now.Year;

            if (item != null)
            {
                belongYear = Convert.ToInt32(item.Value);
                qb.Items.Remove(item);
            }
            priceSQL += " order by StartDate desc";

            var resourceDt = this.SqlHelper.ExecuteDataTable(priceSQL);
            var list       = resourceDt.AsEnumerable();
            var db         = SQLHelper.CreateSqlHelper(ConnEnum.Base);
            var result     = FormulaHelper.DataTableToListDic(db.ExecuteDataTable(sql, qb));

            foreach (var dic in result)
            {
                for (int i = 1; i <= 12; i++)
                {
                    var priceRow = list.FirstOrDefault(c => c["ResourceCode"].ToString() == dic.GetValue("ResourceCode") &&
                                                       Convert.ToInt32(c["BelongMonth"]) == i && Convert.ToInt32(c["BelongYear"]) == belongYear);
                    if (priceRow == null)
                    {
                        var date = new DateTime(belongYear, i, 1);
                        priceRow = list.FirstOrDefault(c => Convert.ToDateTime(c["StartDate"]) <= date &&
                                                       c["ResourceCode"].ToString() == dic.GetValue("ResourceCode"));
                        if (priceRow == null)
                        {
                            dic.SetValue("UnitPrice_" + i.ToString(), 0);
                        }
                        else
                        {
                            dic.SetValue("UnitPrice_" + i.ToString(), priceRow["UnitPrice"]);
                        }
                    }
                    else
                    {
                        dic.SetValue("UnitPrice_" + i.ToString(), priceRow["UnitPrice"]);
                    }
                }
                var maxVersionRow = list.FirstOrDefault(c => c["ResourceCode"].ToString() == dic.GetValue("ResourceCode"));
                if (maxVersionRow != null)
                {
                    dic.SetValue("ModifyUser", maxVersionRow["ModifyUser"]);
                    dic.SetValue("ModifyDate", maxVersionRow["ModifyDate"]);
                    dic.SetValue("Postion", maxVersionRow["Postion"]);
                }
                dic.SetValue("BelongYear", belongYear);
            }
            var gridData = new GridData(result);

            gridData.total = qb.TotolCount;
            return(Json(gridData));
        }