Esempio n. 1
0
        public IList <TUserMessage> UserMessageGetTypeNew(string loginKey, ref ErrorInfo err, int typeId)
        {
            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            GlobalUser gu = Global.GetUser(loginKey);

            using (DBEntities db = new DBEntities())
            {
                var type = db.YL_MESSAGE_TYPE.SingleOrDefault(x => x.ID == typeId);
                if (type == null)
                {
                    err.IsError = true;
                    err.Message = "消息类型不存在";
                    return(null);
                }
                var allEnt = db.YL_USER_MESSAGE.Where(x => x.STATUS == "等待" && x.USER_ID == gu.UserId && x.YL_MESSAGE.MESSAGE_TYPE_ID == typeId).OrderByDescending(x => x.MESSAGE_ID).ToList();

                IList <TUserMessage> allReList = new List <TUserMessage>();
                foreach (var t in allEnt)
                {
                    var tmp = Fun.ClassToCopy <YL_USER_MESSAGE, TUserMessage>(t);
                    tmp.TypeName = t.YL_MESSAGE.YL_MESSAGE_TYPE.NAME;
                    allReList.Add(tmp);
                }
                return(allReList);
            }
        }
Esempio n. 2
0
        public TScript ScriptSingleId(string loginKey, ref ErrorInfo err, int Id)
        {
            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            using (DBEntities db = new DBEntities())
            {
                var ent   = db.YL_SCRIPT.SingleOrDefault(x => x.ID == Id);
                var reEnt = new ProInterface.Models.TScript();
                if (ent != null)
                {
                    reEnt = Fun.ClassToCopy <YL_SCRIPT, ProInterface.Models.TScript>(ent);
                    reEnt.ScriptGroupList = Fun.ClassListToCopy <YL_SCRIPT_GROUP_LIST, ProInterface.Models.SCRIPT_GROUP_LIST>(ent.YL_SCRIPT_GROUP_LIST.OrderBy(x => x.ORDER_INDEX).ToList());
                    foreach (var t in reEnt.ScriptGroupList.ToList())
                    {
                        var cn = db.YL_SCRIPT.SingleOrDefault(x => x.ID == t.SCRIPT_ID);
                        t.CODE = cn.CODE;
                        t.NAME = cn.NAME;
                    }
                    reEnt.ScriptGroupListJosn = JSON.DecodeToStr(reEnt.ScriptGroupList);
                }

                return(reEnt);
            }
        }
Esempio n. 3
0
        public bool ScriptTaskAdd(string loginKey, ref ErrorInfo err, int scriptId, int?groupId = null)
        {
            using (DBEntities db = new DBEntities())
            {
                var ent = db.YL_SCRIPT.SingleOrDefault(x => x.ID == scriptId);

                if (ent.IS_GROUP == 0)
                {
                    var nowRunTaskNum = db.YL_SCRIPT_TASK.Where(x => x.SCRIPT_ID == ent.ID && x.RUN_STATE.Equals("等待")).Count();
                    if (nowRunTaskNum > 0)
                    {
                        err.IsError = true;
                        err.Message = string.Format("当前已经有等待任务【{0}】个", nowRunTaskNum);
                        return(false);
                    }
                    var task = Fun.ClassToCopy <YL_SCRIPT, YL_SCRIPT_TASK>(ent);
                    task.ID        = 0;
                    task.SCRIPT_ID = ent.ID;
                    task.RUN_STATE = "等待";
                    task.DSL_TYPE  = "手工添加";
                    task.GROUP_ID  = groupId;
                    db.YL_SCRIPT_TASK.Add(task);
                    db.SaveChanges();
                }
                else
                {
                    var allList = ent.YL_SCRIPT_GROUP_LIST.OrderBy(x => x.ORDER_INDEX).ToList();
                    if (allList.Count() > 0)
                    {
                        return(ScriptTaskAdd(loginKey, ref err, allList[0].SCRIPT_ID, scriptId));
                    }
                }
                return(true);
            }
        }
Esempio n. 4
0
 public TFlowFlownodeFlow FlowFristNode(string loginKey, ref ErrorInfo err, int flowId, string status)
 {
     using (DBEntities db = new DBEntities())
     {
         var ent   = db.YL_FLOW_FLOWNODE_FLOW.SingleOrDefault(x => x.FLOW_ID == flowId && x.FROM_FLOWNODE_ID == 9999);
         var reEnt = new TFlowFlownodeFlow();
         if (ent != null)
         {
             List <YL_FLOW_FLOWNODE_FLOW> nextNodeArr = db.YL_FLOW_FLOWNODE_FLOW.Where(x => x.FLOW_ID == flowId && x.FROM_FLOWNODE_ID == ent.TO_FLOWNODE_ID && x.STATUS == status).ToList();
             if (string.IsNullOrEmpty(status))
             {
                 nextNodeArr = db.YL_FLOW_FLOWNODE_FLOW.Where(x => x.FLOW_ID == flowId && x.FROM_FLOWNODE_ID == ent.TO_FLOWNODE_ID).ToList();
             }
             else
             {
                 nextNodeArr = db.YL_FLOW_FLOWNODE_FLOW.Where(x => x.FLOW_ID == flowId && x.FROM_FLOWNODE_ID == ent.TO_FLOWNODE_ID && x.STATUS == status).ToList();
             }
             if (nextNodeArr.Count() > 0)
             {
                 var nextNode = nextNodeArr[0];
                 reEnt = Fun.ClassToCopy <YL_FLOW_FLOWNODE_FLOW, TFlowFlownodeFlow>(nextNode);
                 var allNextRole = db.YL_ROLE.Where(x => x.YL_FLOW_FLOWNODE_FLOW.Where(y => y.FROM_FLOWNODE_ID == nextNode.TO_FLOWNODE_ID && y.FLOW_ID == flowId).Count() > 0).ToList();
                 reEnt.AllRoleIDList = allNextRole.Select(x => x.ID).ToList();
                 reEnt.AllRoleStr    = string.Join(",", reEnt.AllRoleIDList);
                 reEnt.HandleUrl     = nextNode.YL_FLOW_FLOWNODE.HANDLE_URL;
                 reEnt.ShowUrl       = nextNode.YL_FLOW_FLOWNODE.SHOW_URL;
                 return(reEnt);
             }
         }
         return(null);
     }
 }
Esempio n. 5
0
        public TRole UserGetRole(string loginKey, ref ErrorInfo err)
        {
            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            GlobalUser gu = Global.GetUser(loginKey);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(null);
            }
            using (DBEntities db = new DBEntities())
            {
                var ent     = db.fa_user.SingleOrDefault(x => x.ID == gu.UserId);
                var allRole = ent.fa_role.ToList();
                if (allRole.Count == 0)
                {
                    return(null);
                }
                var reEnt = Fun.ClassToCopy <fa_role, TRole>(allRole[0]);
                reEnt.RoleConfigs = Fun.ClassListToCopy <fa_role_CONFIG, ROLE_CONFIG>(allRole[0].fa_role_CONFIG.ToList());
                return(reEnt);
            }
        }
Esempio n. 6
0
        public object Login_Save(DBEntities db, string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.LOGIN inEnt, IList <string> allPar)
        {
            if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            var  ent   = db.fa_login.SingleOrDefault(a => a.ID == inEnt.ID);
            bool isAdd = false;

            if (ent == null)
            {
                isAdd  = true;
                ent    = Mapper.Map <LOGIN, fa_login>(inEnt);
                ent.ID = Fun.GetCurrvalSeqID <fa_login>();
            }
            else
            {
                ent = Fun.ClassToCopy <ProInterface.Models.LOGIN, fa_login>(inEnt, ent, allPar);
            }
            if (isAdd)
            {
                ent = db.fa_login.Add(ent);
            }
            GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit);
            return(ent);
        }
Esempio n. 7
0
 /// <summary>
 /// 查询一条
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="whereLambda">条件lambda表达表</param>
 /// <returns>查询一条</returns>
 public ProInterface.Models.LOGIN Login_Single(string loginKey, ref ProInterface.ErrorInfo err, string whereLambda)
 {
     if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         IList <fa_login> content = new List <fa_login>();
         Expression <Func <fa_login, bool> > whereFunc;
         try
         {
             whereFunc = StringToLambda.LambdaParser.Parse <Func <fa_login, bool> >(whereLambda);
         }
         catch
         {
             err.IsError = true;
             err.Message = "条件表态式有误";
             return(null);
         }
         var reEnt = db.fa_login.Where(whereFunc).ToList();
         if (reEnt.Count > 0)
         {
             return(Fun.ClassToCopy <fa_login, ProInterface.Models.LOGIN>(reEnt[0]));
         }
         return(null);
     }
 }
Esempio n. 8
0
        public ProInterface.Models.Api.ApiPagingDataBean BulletinList(ref ErrorInfo err, ProInterface.Models.Api.ApiRequesPageBean inEnt)
        {
            GlobalUser        gu    = Global.GetUser(inEnt.authToken);
            ApiPagingDataBean reEnt = new ApiPagingDataBean();
            int skip = 0;

            if (inEnt.currentPage > 1)
            {
                skip = (inEnt.currentPage - 1) * inEnt.pageSize;
            }
            using (DBEntities db = new DBEntities())
            {
                var tmpEnt  = db.YL_BULLETIN.AsEnumerable();
                var allData = tmpEnt.Where(x => x.IS_SHOW == 1 && x.ISSUE_DATE < DateTime.Now).OrderByDescending(x => x.IS_URGENT).ThenByDescending(x => x.ISSUE_DATE).AsEnumerable();
                allData = allData.Where(x => x.YL_ROLE.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).AsEnumerable();

                ErrorInfo error = new ErrorInfo();
                #region 过虑条件
                foreach (var filter in inEnt.searchKey)
                {
                    if (filter.K == "CREATE_TIME" && filter.T == ">=" && !string.IsNullOrEmpty(filter.V))
                    {
                        DateTime dt1 = DateTime.ParseExact(filter.V, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
                        allData = allData.Where(x => x.CREATE_TIME >= dt1).AsEnumerable();
                    }
                    else if (filter.K == "CREATE_TIME" && filter.T == "<=" && !string.IsNullOrEmpty(filter.V))
                    {
                        DateTime dt2 = DateTime.ParseExact(filter.V, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture);
                        allData = allData.Where(x => x.CREATE_TIME <= dt2).AsEnumerable();
                    }
                    else if (filter.V == "全部")
                    {
                        allData = tmpEnt.Where(x => x.IS_SHOW == 1 && x.ISSUE_DATE < DateTime.Now).OrderByDescending(x => x.IS_URGENT).ThenByDescending(x => x.ISSUE_DATE).AsEnumerable();
                    }
                    else
                    {
                        allData = Fun.GetListWhere <YL_BULLETIN>(allData, filter.K, filter.T, filter.V, ref error);
                    }
                }
                #endregion
                var allList = allData.Skip(skip).Take(inEnt.pageSize).ToList();
                reEnt.currentPage = inEnt.currentPage;
                reEnt.pageSize    = inEnt.pageSize;
                reEnt.totalCount  = allData.Count();
                reEnt.totalPage   = reEnt.totalCount / reEnt.pageSize;
                if (reEnt.totalCount % reEnt.pageSize != 0)
                {
                    reEnt.totalPage++;
                }
                IList <TBulletin> reList = new List <TBulletin>();
                foreach (var t in allList)
                {
                    TBulletin tmp = Fun.ClassToCopy <YL_BULLETIN, TBulletin>(t);
                    tmp.CONTENT = Fun.NoHTML(tmp.CONTENT);
                    reList.Add(tmp);
                }
                reEnt.data = reList;
            }
            return(reEnt);
        }
Esempio n. 9
0
        public DataTable QueryExecute(string loginKey, ref ErrorInfo err, string queryCode, int pageIndex, int pageSize, string orderStr, string whereJsonStr, IList <QueryPara> paraList, ref string sqlStr)
        {
            DataTable  reDt = new DataTable();
            GlobalUser gu   = Global.GetUser(loginKey);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "用户【" + loginKey + "】登录超时,请重新登录";
                return(reDt);
            }
            using (DBEntities db = new DBEntities())
            {
                var              query    = db.YL_QUERY.SingleOrDefault(x => x.CODE == queryCode);
                TQuery           ent      = Fun.ClassToCopy <YL_QUERY, TQuery>(query);
                IList <QueryCfg> cfg      = JSON.EncodeToEntity <IList <QueryCfg> >(query.QUERY_CFG_JSON);
                string           whereStr = "";
                ent.QUERY_CONF = MakeSql(gu, ent.QUERY_CONF, orderStr, whereJsonStr, paraList, ref whereStr, Fun.GetDataBaseType());
                try
                {
                    sqlStr = ent.QUERY_CONF;
                    reDt   = ExecuteSql(ent.QUERY_CONF, pageIndex, pageSize, orderStr, whereStr, query.DB_SERVER_ID.Value, cfg.Select(x => x.FieldName).ToList());
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    return(reDt);
                }
            }
            reDt.TableName = "tables1";
            return(reDt);
        }
Esempio n. 10
0
        public TUser UserSingleId(string loginKey, ref ErrorInfo err, int keyId)
        {
            //if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod())) return null;
            using (DBEntities db = new DBEntities())
            {
                IList <fa_user> content = new List <fa_user>();

                var reEnt = db.fa_user.SingleOrDefault(x => x.ID == keyId);
                if (reEnt != null)
                {
                    var reUser  = Fun.ClassToCopy <fa_user, ProInterface.Models.TUser>(reEnt);
                    var allRole = reEnt.fa_role.ToList();
                    reUser.AllRole = Fun.ClassListToCopy <fa_role, ROLE>(allRole);
                    if (allRole.Count() > 0)
                    {
                        reUser.RoleAllID   = string.Join(",", allRole.Select(x => x.ID));
                        reUser.RoleAllName = string.Join(",", allRole.Select(x => x.NAME));
                    }
                    if (reEnt.fa_district != null)
                    {
                        reUser.DistrictName = reEnt.fa_district.NAME;
                    }
                    var login = db.fa_login.Where(p => p.LOGIN_NAME == reUser.LOGIN_NAME).ToList();
                    if (login.Count() > 0)
                    {
                        reUser.PHONE_NO = login[0].PHONE_NO;
                    }
                    reUser.UserDistrict = string.Join(",", reEnt.fa_district1.Select(x => x.ID));
                    return(reUser);
                }
                return(null);
            }
        }
Esempio n. 11
0
        public FCSingleSeries ChartGetByQueryCodeSingle(string loginKey, ref ErrorInfo err, string queryCode, IList <QueryPara> paraList, ref string reSql)
        {
            GlobalUser gu = Global.GetUser(loginKey);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时,请重新登录";
            }
            FCSingleSeries fc = new FCSingleSeries();

            using (DBEntities db = new DBEntities())
            {
                var    query = db.YL_QUERY.SingleOrDefault(x => x.CODE == queryCode);
                TQuery ent   = Fun.ClassToCopy <YL_QUERY, TQuery>(query);

                string    whereStr = "";
                DataTable reDt     = QueryDataTable(loginKey, ref err, queryCode, null, whereStr, paraList, ref reSql);
                for (int i = 0; i < reDt.Rows.Count; i++)
                {
                    fc.data.Add(new FCSingleSeries_data {
                        label = reDt.Rows[i][0].ToString(), value = reDt.Rows[i][1].ToString()
                    });
                }
            }
            return(fc);
        }
Esempio n. 12
0
 public TBulletin BulletinSingleByTitle(string loginKey, ref ErrorInfo err, string title)
 {
     if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         TBulletin   reEnt = new TBulletin();
         YL_BULLETIN ent   = db.YL_BULLETIN.FirstOrDefault(x => x.TITLE == title);
         if (ent == null)
         {
             reEnt.TITLE      = title;
             reEnt.ISSUE_DATE = DateTime.Now;
             reEnt.IS_SHOW    = 0;
             reEnt.IS_URGENT  = 0;
         }
         else
         {
             reEnt             = Fun.ClassToCopy <YL_BULLETIN, TBulletin>(ent);
             reEnt.AllFiles    = Fun.ClassListToCopy <YL_FILES, FILES>(ent.YL_FILES.ToArray());
             reEnt.AllFilesStr = JSON.DecodeToStr(reEnt.AllFiles);
         }
         return(reEnt);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// 修改系统用户
        /// </summary>
        /// <param name="loginKey">登录凭证</param>
        /// <param name="err">错误信息</param>
        /// <param name="inEnt">实体类</param>
        /// <returns>修改系统用户</returns>
        public bool User_Edit(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.USER inEnt)
        {
            if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(false);
            }
            using (DBEntities db = new DBEntities())
            {
                try
                {
                    var ent = db.fa_user.SingleOrDefault(a => a.ID == inEnt.ID);
                    ent = Fun.ClassToCopy <ProInterface.Models.USER, fa_user>(inEnt, ent);

                    db.SaveChanges();
                    GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit);
                    return(true);
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    err.Excep   = e;
                    return(false);
                }
            }
        }
Esempio n. 14
0
 /// <summary>
 /// 添加系统用户
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="inEnt">实体类</param>
 /// <returns>添加系统用户</returns>
 public object User_Add(string loginKey, ref ProInterface.ErrorInfo err, ProInterface.Models.USER inEnt)
 {
     if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         fa_user reEnt = Fun.ClassToCopy <ProInterface.Models.USER, fa_user>(inEnt);
         reEnt = db.fa_user.Add(reEnt);
         try
         {
             db.SaveChanges();
             GlobalFun.UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add);
             return(reEnt.ID);
         }
         catch (Exception e)
         {
             err.IsError = true;
             err.Message = e.Message;
             err.Excep   = e;
             return(null);
         }
     }
 }
Esempio n. 15
0
 public bool LoginAdd(int appId, LOGIN inEnt)
 {
     using (DBEntities db = new DBEntities())
     {
         var login = db.YL_LOGIN.SingleOrDefault(x => x.LOGIN_NAME == inEnt.LOGIN_NAME);
         var oauth = db.YL_OAUTH.SingleOrDefault(x => x.KEY == appId);
         if (oauth == null)
         {
             return(false);
         }
         if (login == null)
         {
             login    = Fun.ClassToCopy <LOGIN, YL_LOGIN>(inEnt);
             login.ID = Fun.GetSeqID <YL_LOGIN>();
             if (string.IsNullOrEmpty(login.REGION))
             {
                 login.REGION = "1";
             }
             login.YL_OAUTH.Add(oauth);
             db.YL_LOGIN.Add(login);
         }
         else
         {
             if (login.YL_OAUTH.SingleOrDefault(x => x.KEY == appId) == null)
             {
                 login.YL_OAUTH.Add(oauth);
             }
         }
         db.SaveChanges();
         return(true);
     }
 }
Esempio n. 16
0
        public TUser UserGetNow(string loginKey, ref ErrorInfo err)
        {
            if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            GlobalUser gu = Global.GetUser(loginKey);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(null);
            }
            using (DBEntities db = new DBEntities())
            {
                var reEnt = db.fa_user.SingleOrDefault(x => x.ID == gu.UserId);
                if (reEnt != null)
                {
                    var reUser = Fun.ClassToCopy <fa_user, ProInterface.Models.TUser>(reEnt);
                    reUser.RoleAllID   = ",";
                    reUser.RoleAllName = "";
                    foreach (var t in reEnt.fa_role.ToList())
                    {
                        reUser.RoleAllID   += t.ID + ",";
                        reUser.RoleAllName += "," + t.NAME;
                    }
                    if (reUser.RoleAllName.Length > 1)
                    {
                        reUser.RoleAllName = reUser.RoleAllName.Substring(1);
                    }
                    var dis = db.fa_district.SingleOrDefault(x => x.ID == gu.DistrictId);
                    reUser.DistrictName = dis != null?dis.NAME:"";
                    var myDisId   = reEnt.DISTRICT_ID;
                    var changeDis = db.fa_district.Where(x => x.LEVEL_ID == 2 && x.IN_USE == 1 && (x.ID == myDisId || x.PARENT_ID == myDisId)).OrderBy(x => x.ID).ToList();
                    reUser.CanChangeDistrict = Fun.ClassListToCopy <fa_district, DISTRICT>(changeDis);
                    reUser.REMARK            = "";

                    //if (reEnt.fa_user_INFO != null && reEnt.fa_user_INFO.YL_CHANNEL_INFO.Count() > 0)
                    //{
                    //    var allData = db.fa_user.Where(x => x.fa_user_INFO != null && x.DISTRICT_ID == reEnt.DISTRICT_ID && x.fa_role.Where(y => y.ID == 4).Count() > 0).ToList().Select(x => string.Format("渠道经理:{0}({1})  归属:{2}", x.NAME, x.fa_user_INFO.PHONE_NUMBER, x.fa_district.NAME)).ToList();
                    //    if (allData.Count() > 0)
                    //    {
                    //        allData = new List<string> { allData[0] };
                    //    }
                    //    reUser.REMARK = string.Join("<br />", allData);
                    //}
                    //else
                    //{
                    //    reUser.REMARK = "";
                    //}
                    var allModule = db.YL_MODULE.Where(x => x.IS_HIDE == 0 && x.fa_role.Where(y => gu.RoleID.Contains(y.ID)).Count() > 0).ToList();
                    reUser.MyModule = Fun.ClassListToCopy <YL_MODULE, MODULE>(allModule);
                    return(reUser);
                }
                return(null);
            }
        }
Esempio n. 17
0
        public DISTRICT DistrictAdd(string loginKey, ref ErrorInfo err, DISTRICT inEnt)
        {
            using (DBEntities db = new DBEntities())
            {
                YL_DISTRICT reEnt = Fun.ClassToCopy <ProInterface.Models.DISTRICT, YL_DISTRICT>(inEnt);
                #region 计算ID_PATH和Level_ID
                if (reEnt.PARENT_ID == null)
                {
                    reEnt.LEVEL_ID = 1;
                    reEnt.ID_PATH  = ".";
                }
                else
                {
                    var parent = db.YL_DISTRICT.Single(x => x.ID == reEnt.PARENT_ID);
                    if (parent == null)
                    {
                        reEnt.LEVEL_ID = 1;
                        reEnt.ID_PATH  = ".";
                    }
                    else
                    {
                        reEnt.ID_PATH  = parent.ID_PATH + reEnt.PARENT_ID + ".";
                        reEnt.LEVEL_ID = parent.LEVEL_ID + 1;
                    }
                }
                #endregion
                reEnt.ID = Fun.GetSeqID <YL_DISTRICT>();
                #region 计算REGION

                GlobalUser gu = Global.GetUser(loginKey);
                if (gu == null)
                {
                    reEnt.REGION = reEnt.ID.ToString();
                }
                else
                {
                    reEnt.REGION = gu.Region;
                }
                #endregion
                reEnt.CODE   = (string.IsNullOrEmpty(inEnt.CODE)) ? reEnt.ID.ToString() : inEnt.CODE;
                reEnt.IN_USE = 1;
                reEnt        = db.YL_DISTRICT.Add(reEnt);
                try
                {
                    db.SaveChanges();
                    UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Add);
                    return(Fun.ClassToCopy <YL_DISTRICT, DISTRICT>(reEnt));
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    err.Excep   = e;
                    return(null);
                }
            }
        }
Esempio n. 18
0
 public DISTRICT DistrictGetByUser(string loginKey, ref ErrorInfo err)
 {
     using (DBEntities db = new DBEntities())
     {
         GlobalUser gu    = Global.GetUser(loginKey);
         var        reEnt = db.YL_DISTRICT.SingleOrDefault(x => x.ID == gu.DistrictId);
         return(Fun.ClassToCopy <YL_DISTRICT, DISTRICT>(reEnt));
     }
 }
Esempio n. 19
0
        public ProInterface.Models.TBulletin BulletinSingle(string loginKey, ref ErrorInfo err, int?bullID)
        {
            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            using (DBEntities db = new DBEntities())
            {
                TBulletin reEnt = new TBulletin();

                YL_BULLETIN ent = db.YL_BULLETIN.SingleOrDefault(x => x.ID == bullID);
                GlobalUser  gu  = Global.GetUser(loginKey);
                if (ent != null)
                {
                    db.YL_BULLETIN_LOG.Add(new YL_BULLETIN_LOG
                    {
                        BULLETIN_ID = ent.ID,
                        LOOK_TIME   = DateTime.Now,
                        USER_ID     = gu.UserId
                    });
                    db.SaveChanges();
                    reEnt             = Fun.ClassToCopy <YL_BULLETIN, TBulletin>(ent);
                    reEnt.AllFiles    = Fun.ClassListToCopy <YL_FILES, FILES>(ent.YL_FILES.ToArray());
                    reEnt.AllFilesStr = JSON.DecodeToStr(reEnt.AllFiles);
                    reEnt.AllRoleId   = string.Join(",", ent.YL_ROLE.Select(x => x.ID).ToList());
                    var user = db.YL_USER.SingleOrDefault(x => x.ID == ent.USER_ID);
                    if (user != null)
                    {
                        reEnt.DistrictName = user.YL_DISTRICT.NAME;
                    }

                    foreach (var t in ent.YL_BULLETIN_REVIEW.OrderBy(x => x.ADD_TIME).ToList())
                    {
                        var tmp     = Fun.ClassToCopy <YL_BULLETIN_REVIEW, ProInterface.Models.BulletinReview>(t);
                        var userTmp = db.YL_USER.SingleOrDefault(x => x.ID == t.USER_ID);
                        if (userTmp != null)
                        {
                            tmp.UserName    = userTmp.NAME;
                            tmp.DistictName = userTmp.YL_DISTRICT.NAME;
                            tmp.UserPhone   = userTmp.LOGIN_NAME;
                            tmp.UserRole    = string.Join(",", userTmp.YL_ROLE.Select(x => x.NAME).ToList());
                        }
                        reEnt.AllChildrenItem.Add(tmp);
                    }
                }
                else
                {
                    reEnt.IS_URGENT = 1;
                    reEnt.IS_IMPORT = 1;
                    reEnt.IS_SHOW   = 1;
                    reEnt.REGION    = gu.DistrictId.ToString();
                }
                return(reEnt);
            }
        }
Esempio n. 20
0
        public bool QuerySave(string loginKey, ref ErrorInfo err, QUERY inEnt, IList <string> allPar)
        {
            GlobalUser gu = Global.GetUser(loginKey);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(false);
            }

            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(false);
            }


            using (DBEntities db = new DBEntities())
            {
                try
                {
                    var  ent   = db.YL_QUERY.SingleOrDefault(a => a.ID == inEnt.ID);
                    bool isAdd = false;
                    if (ent == null)
                    {
                        isAdd = true;
                        ent   = Fun.ClassToCopy <ProInterface.Models.QUERY, YL_QUERY>(inEnt);
                    }
                    else
                    {
                        //if (!inEnt.QUERY_CONF.Equals(ent.QUERY_CONF))
                        //{
                        //    inEnt.QUERY_CONF = string.Format("--{0}于{1}修改\r\n{2}",gu.UserName,DateTime.Now.ToString(),inEnt.QUERY_CONF);
                        //}

                        ent = Fun.ClassToCopy <ProInterface.Models.QUERY, YL_QUERY>(inEnt, ent, allPar);
                    }

                    if (isAdd)
                    {
                        db.YL_QUERY.Add(ent);
                    }
                    db.SaveChanges();
                    UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit);
                    return(true);
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = Fun.GetExceptionMessage(e);
                    return(false);
                }
            }
        }
Esempio n. 21
0
 public IList <TTaskFlow> TaskGetTreeFlow(string loginKey, ref ErrorInfo err, int taskId)
 {
     using (DBEntities db = new DBEntities())
     {
         var allFlow = db.YL_TASK_FLOW.Where(x => x.TASK_ID == taskId).ToList();
         IList <TTaskFlow> reFlow = new List <TTaskFlow>();
         foreach (var t in allFlow.Where(x => x.PARENT_ID == null).OrderBy(x => x.ID).ToList())
         {
             TTaskFlow tmp = new TTaskFlow();
             tmp = Fun.ClassToCopy <YL_TASK_FLOW, TTaskFlow>(t);
             if (t.IS_HANDLE == 0)
             {
                 tmp.DealRole = "待处理";
             }
             else
             {
                 if (string.IsNullOrEmpty(t.ROLE_ID_STR))
                 {
                     tmp.DealRole = t.DEAL_STATUS;
                 }
                 else
                 {
                     List <int> role = tmp.ROLE_ID_STR.Split(',').Select(x => Convert.ToInt32(x)).ToList();
                     tmp.DealRole = string.Format("分发{0}", string.Join(",", db.YL_ROLE.Where(x => role.Contains(x.ID)).Select(x => x.NAME).ToList()));
                 }
                 var allChildre = db.YL_TASK_FLOW.Where(x => x.PARENT_ID == t.ID).ToList();
                 if (allChildre.Count() == 0)
                 {
                     if (t.YL_TASK_FLOW2 != null)
                     {
                         if (t.YL_TASK_FLOW2.YL_TASK_FLOW_HANDLE.Count() > 0)
                         {
                             var userId  = t.YL_TASK_FLOW2.HANDLE_USER_ID;
                             var userTmp = db.YL_USER.SingleOrDefault(x => x.ID == userId);
                             if (userTmp != null)
                             {
                                 tmp.NextDealUserName = userTmp.NAME;
                             }
                         }
                     }
                 }
                 else
                 {
                     var userIdArr = allChildre.Select(x => x.HANDLE_USER_ID).ToList();
                     tmp.NextDealUserName = string.Join(",", db.YL_USER.Where(x => userIdArr.Contains(x.ID)).Select(x => x.NAME).ToList());
                 }
                 tmp.children = TaskGetTreeFlowChildren(loginKey, ref err, t.ID, allFlow);
             }
             reFlow.Add(tmp);
         }
         return(reFlow);
     }
 }
Esempio n. 22
0
 public FILES FilesSingle(string loginKey, ref ErrorInfo err, int id)
 {
     if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         YL_FILES ent   = db.YL_FILES.SingleOrDefault(x => x.ID == id);
         FILES    reEnt = Fun.ClassToCopy <YL_FILES, FILES>(ent);
         return(reEnt);
     }
 }
Esempio n. 23
0
        public bool BulletinReviewSave(string loginKey, ref ErrorInfo err, BulletinReview inEnt, IList <string> allPar)
        {
            if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(false);
            }

            var gu = Global.GetUser(loginKey);

            if (gu == null)
            {
                err.IsError = true;
                err.Message = "登录超时";
                return(false);
            }
            using (DBEntities db = new DBEntities())
            {
                try
                {
                    var  ent   = db.YL_BULLETIN_REVIEW.SingleOrDefault(a => a.ID == inEnt.ID);
                    bool isAdd = false;
                    if (ent == null)
                    {
                        isAdd           = true;
                        ent             = Fun.ClassToCopy <ProInterface.Models.BulletinReview, YL_BULLETIN_REVIEW>(inEnt);
                        ent.STATUS      = "正常";
                        ent.STATUS_TIME = DateTime.Now;
                        ent.USER_ID     = gu.UserId;
                        ent.ADD_TIME    = DateTime.Now;
                    }
                    else
                    {
                        ent = Fun.ClassToCopy <ProInterface.Models.BulletinReview, YL_BULLETIN_REVIEW>(inEnt, ent, allPar);
                    }

                    if (isAdd)
                    {
                        db.YL_BULLETIN_REVIEW.Add(ent);
                    }
                    db.SaveChanges();
                    UserWriteLog(loginKey, MethodBase.GetCurrentMethod(), StatusType.UserLogType.Edit);
                    return(true);
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                    return(false);
                }
            }
        }
Esempio n. 24
0
        public TRole RoleSingle(string loginKey, ref ErrorInfo err, int id)
        {
            if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
            {
                return(null);
            }
            using (DBEntities db = new DBEntities())
            {
                var        reEnt   = db.fa_role.Where(x => x.ID == id).ToList();
                TRole      tmp     = new TRole();
                IList <KV> allPara = new List <KV>();

                if (reEnt.Count > 0)
                {
                    tmp = Fun.ClassToCopy <fa_role, ProInterface.Models.TRole>(reEnt[0]);
                    tmp.ModuleAllStr = ",";
                    foreach (var t in reEnt[0].fa_module.ToList())
                    {
                        tmp.ModuleAllStr += t.ID + ",";
                    }
                    tmp.RoleConfigs = Fun.ClassListToCopy <fa_role_config, ROLE_CONFIG>(reEnt[0].fa_role_config.ToList());
                }
                //添加
                foreach (var t in allPara)
                {
                    var cfg = tmp.RoleConfigs.SingleOrDefault(x => x.NAME == t.K);
                    if (cfg == null)
                    {
                        tmp.RoleConfigs.Add(new ROLE_CONFIG {
                            NAME = t.K, REMARK = t.V
                        });
                    }
                    else
                    {
                        cfg.REMARK = t.V;
                    }
                }
                //删除
                foreach (var t in tmp.RoleConfigs)
                {
                    if (allPara.SingleOrDefault(x => x.K == t.NAME) == null)
                    {
                        tmp.RoleConfigs.Remove(t);
                    }
                }
                tmp.RoleConfigsStr = JSON.DecodeToStr(tmp.RoleConfigs);
                return(tmp);
            }
        }
Esempio n. 25
0
        public TTaskFlow TaskFlowSingle(int id)
        {
            using (DBEntities db = new DBEntities())
            {
                TTaskFlow reEnt = new TTaskFlow();
                var       ent   = db.YL_TASK_FLOW.SingleOrDefault(x => x.ID == id);
                if (ent == null)
                {
                    return(reEnt);
                }
                reEnt = Fun.ClassToCopy <YL_TASK_FLOW, TTaskFlow>(ent);


                return(reEnt);
            }
        }
Esempio n. 26
0
 public ProInterface.Models.MODULE ModuleSingleCode(string loginKey, ref ProInterface.ErrorInfo err, string code)
 {
     if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         var ent   = db.YL_MODULE.SingleOrDefault(x => x.CODE == code);
         var reEnt = new ProInterface.Models.MODULE();
         if (ent != null)
         {
             reEnt = Fun.ClassToCopy <YL_MODULE, ProInterface.Models.MODULE>(ent);
         }
         return(reEnt);
     }
 }
Esempio n. 27
0
 /// <summary>
 /// 查询一条
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="keyId">主键ID</param>
 /// <returns>查询一条</returns>
 public ProInterface.Models.LOGIN Login_SingleId(string loginKey, ref ProInterface.ErrorInfo err, int keyId)
 {
     if (!GlobalFun.UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         var ent   = db.fa_login.SingleOrDefault(x => x.ID == keyId);
         var reEnt = new ProInterface.Models.LOGIN();
         if (ent != null)
         {
             reEnt = Fun.ClassToCopy <fa_login, ProInterface.Models.LOGIN>(ent);
         }
         return(reEnt);
     }
 }
Esempio n. 28
0
 /// <summary>
 /// 查询一条
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="keyId">主键ID</param>
 /// <returns>查询一条</returns>
 public ProInterface.Models.TASK TaskSingleId(string loginKey, ref ProInterface.ErrorInfo err, int keyId)
 {
     if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         var ent   = db.YL_TASK.SingleOrDefault(x => x.ID == keyId);
         var reEnt = new ProInterface.Models.TASK();
         if (ent != null)
         {
             reEnt = Fun.ClassToCopy <YL_TASK, ProInterface.Models.TASK>(ent);
         }
         return(reEnt);
     }
 }
Esempio n. 29
0
        public int QueryCount(string loginKey, ref ErrorInfo err, string queryCode, string whereJsonStr, IList <QueryPara> paraList, ref string sqlStr)
        {
            using (DBEntities db = new DBEntities())
            {
                var        query    = db.YL_QUERY.SingleOrDefault(x => x.CODE == queryCode);
                TQuery     ent      = Fun.ClassToCopy <YL_QUERY, TQuery>(query);
                GlobalUser gu       = Global.GetUser(loginKey);
                string     whereStr = "";
                ent.QUERY_CONF = MakeSql(gu, ent.QUERY_CONF, null, whereJsonStr, paraList, ref whereStr, Fun.GetDataBaseType());

                string withStr      = "";
                string WithStartStr = "-----WithStart-----";
                string WithEndStr   = "-----WithEnd-----";
                int    WithStartP   = ent.QUERY_CONF.IndexOf(WithStartStr);
                int    WithEndP     = ent.QUERY_CONF.IndexOf(WithEndStr);
                if (WithStartP > -1 && WithEndP > -1 && WithEndP > WithStartP)
                {
                    withStr        = ent.QUERY_CONF.Substring(WithStartStr.Length, WithEndP - WithStartP - WithStartStr.Length);
                    ent.QUERY_CONF = ent.QUERY_CONF.Substring(WithEndP + WithEndStr.Length);
                }



                if (!string.IsNullOrEmpty(whereStr))
                {
                    ent.QUERY_CONF = withStr + "SELECT * FROM ( " + ent.QUERY_CONF + " ) TMP where " + whereStr;
                }
                else
                {
                    ent.QUERY_CONF = withStr + "SELECT * FROM ( " + ent.QUERY_CONF + " ) TMP";
                }
                var reInt = 0;
                try
                {
                    sqlStr = ent.QUERY_CONF;
                    reInt  = ExecuteCount(query.DB_SERVER_ID.Value, ent.QUERY_CONF);
                }
                catch (Exception e)
                {
                    err.IsError = true;
                    err.Message = e.Message;
                }
                return(reInt);
            }
        }
Esempio n. 30
0
 /// <summary>
 /// 查询一条
 /// </summary>
 /// <param name="loginKey">登录凭证</param>
 /// <param name="err">错误信息</param>
 /// <param name="id">条件lambda表达表</param>
 /// <returns>查询一条</returns>
 public ProInterface.Models.TModule ModuleSingleId(string loginKey, ref ProInterface.ErrorInfo err, int id)
 {
     if (!UserCheckFunctioAuthority(loginKey, ref err, MethodBase.GetCurrentMethod()))
     {
         return(null);
     }
     using (DBEntities db = new DBEntities())
     {
         var ent   = db.YL_MODULE.SingleOrDefault(x => x.ID == id);
         var reEnt = new ProInterface.Models.TModule();
         if (ent != null)
         {
             reEnt = Fun.ClassToCopy <YL_MODULE, ProInterface.Models.TModule>(ent);
             reEnt.AllRoleIdArrStr = string.Join(",", ent.YL_ROLE.Select(x => x.ID));
         }
         return(reEnt);
     }
 }