Пример #1
0
        public ActionResult GetTrainProjects()
        {
            try
            {
                Operator user = OperatorProvider.Provider.Current();
                if (user == null)
                {
                    return(Error("身份票据已过期!"));
                }
                DepartmentEntity dept = deptBll.GetEntity(user.OrganizeId);
                WebClient        wc   = new WebClient();
                wc.Credentials = CredentialCache.DefaultCredentials;
                Dictionary <string, string> dict = new Dictionary <string, string>();
                dict.Add("companyId", dept.InnerPhone);

                string apiUrl = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("TrainApiAddress", "Train");
                wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
                string data   = Newtonsoft.Json.JsonConvert.SerializeObject(dict);
                string result = wc.UploadString(apiUrl + "/api/api/trainRecord/queryProjectList", "POST", data);
                return(Content(result));
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
Пример #2
0
        public ActionResult EHSIndex()
        {
            var user = ERCHTMS.Code.OperatorProvider.Provider.Current();

            string url = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("TrainWebUrl");

            ViewData["Url"] = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.Account);
            return(View());
        }
Пример #3
0
        public ActionResult GetFileDowUrl(string keyValue, string type)
        {
            try
            {
                if (dataItemDetailBLL.GetItemValue("flag") == "1")
                {
                    type = "0";
                }
                if (type == "0")
                {
                    DataTable fie = fileInfoBLL.GetFiles(keyValue);
                    if (fie != null && fie.Rows.Count > 0)
                    {
                        string path = fie.Rows[0]["FileName"].ToString();
                        return(ToJsonResult(path));
                    }
                    return(ToJsonResult(0));
                }
                else
                {
                    string fid = string.Empty;
                    if (keyValue.Contains('.'))
                    {
                        fid = keyValue;
                    }
                    else
                    {
                        //fast文件
                        //根据法规ID获取FID(带后缀)
                        string    sql = string.Format(@"select t.var_fid from ex_attachment t where t.id 
in(select attachment_id from ex_law_attachment t where t.law_id='{0}' and t.law_type='01')", keyValue);
                        DataTable dt  = seb.SelectData(sql);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            fid = dt.Rows[0][0].ToString();
                        }
                        else
                        {
                            return(ToJsonResult(0));
                        }
                    }
                    var    di          = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL();
                    long   expiresLong = DateTime.Now.Ticks / 1000 + 180;
                    string expires     = expiresLong.ToString();
                    string token       = Md5Helper.MD5(di.GetItemValue("userKey", "Resource") + expires, 32);
                    string url         = string.Format(di.GetItemValue("FileDowUrl", "Resource"), fid, di.GetItemValue("user", "Resource"), expires, token);
                    return(ToJsonResult(url));
                }
            }
            catch (Exception)
            {
                return(ToJsonResult(0));
            }
        }
Пример #4
0
 /// <summary>
 /// 同步培训平台人员素质意识值
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="fileName"></param>
 public dynamic UpdatePoint(string userAccount)
 {
     try
     {
         var       trainserviceurl = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("TrainServiceUrl");
         WebClient wc = new WebClient();
         wc.Credentials = CredentialCache.DefaultCredentials;
         //发送请求到web api并获取返回值,默认为post方式
         System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection();
         string queryJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
         {
             Business    = "GetQualityObj",
             userAccount = userAccount
         });
         nc.Add("json", queryJson);
         byte[] arr = wc.UploadValues(new Uri(trainserviceurl), nc);
         return(JsonConvert.DeserializeObject <ExpandoObject>(System.Text.Encoding.Default.GetString(arr)));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
 public ActionResult PeopleForm()
 {
     var isldap = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("IsOpenPassword");
     return View();
 }
Пример #6
0
        public object SyncUsers(int pfrom, string orgId = "")
        {
            string logPath = HttpContext.Current.Server.MapPath("~/logs/menjin/");

            try
            {
                string                    accounts = HttpContext.Current.Request["accounts"]; //需要推送的用户账号
                List <object>             lstUsers = new List <object>();                     //用户存储要推送的用户集合
                StringBuilder             sbSql    = new StringBuilder();                     //Sql语句
                byte[]                    bytes;
                Dictionary <long, string> dict = new Dictionary <long, string>();             //临时存储培训平台推送的用户信息
                if (pfrom == 0)                                                               //培训平台
                {
                    string    sql     = string.Format("select userid, u.realname,u.gender,u.identifyid,u.email,u.mobile,u.birthday,u.encode,account from base_user u where u.account in ('{0}') or newaccount in ('{0}')", accounts.Replace(",", "','"));
                    DataTable dtUsers = deptBll.GetDataTable(sql);
                    int       j       = 0;
                    System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:查询到的用户信息:{dtUsers.ToJson()}。\n\n");
                    foreach (DataRow dr in dtUsers.Rows)
                    {
                        string account  = dr["account"].ToString();    //用户id
                        string userId   = dr["userid"].ToString();     //用户id
                        string userName = dr["realname"].ToString();   //姓名
                        string sex      = dr["gender"].ToString();     //性别
                        string idCard   = dr["identifyid"].ToString(); //身份证号
                        string email    = dr["email"].ToString();      //邮箱
                        string mobile   = dr["mobile"].ToString();     //手机号
                        string birthday = dr["birthday"].ToString();   //生日
                        string encode   = dr["encode"].ToString();     //工号

                        //转换生日格式
                        if (!string.IsNullOrWhiteSpace(birthday))
                        {
                            DateTime time;
                            bool     flag = DateTime.TryParse(birthday, out time);
                            if (flag)
                            {
                                birthday = time.ToString("yyyy-MM-dd");
                            }
                            else
                            {
                                birthday = "";
                            }
                        }
                        //转换性别
                        int gender   = 0;
                        int certType = 111;//表示身份证类型
                        if (sex.Length > 0)
                        {
                            gender = sex == "男" ? 1 : 2;
                        }
                        //构造需要推送的用户参数
                        lstUsers.Add(new
                        {
                            clientId        = j,
                            personId        = userId,
                            personName      = userName,
                            gender          = gender,
                            certificateType = certType,
                            certificateNo   = idCard,
                            orgIndexCode    = "a10d1bf0-c9d5-4b0b-82c3-abd624a79f76",
                            jobNo           = encode,
                            email           = email,
                            phoneNo         = mobile,
                            birthday        = birthday
                        });
                        j++;
                        dict.Add(j, account);
                    }
                }
                if (pfrom == 1)//工具箱
                {
                    //查询需要推送的用户
                    DataTable dtUsers = deptBll.GetDataTable(string.Format("select id,username,idcard from PX_TRAINRECORD t where account in('{0}')", accounts.Replace(",", "','")));
                    int       j       = 0;
                    System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:查询到的用户信息:{dtUsers.ToJson()}。\n\n");
                    foreach (DataRow dr in dtUsers.Rows)
                    {
                        int    gender   = 0;                              //性别,0:未知,1:男,2:女
                        string id       = dr["id"].ToString();            //主键ID
                        string userName = dr["username"].ToString().Trim();
                        string idCard   = dr["idcard"].ToString().Trim(); //证件号
                        int    len      = idCard.Length;
                        int    certType = 414;                            //护照类型
                        if (len == 15 || len == 18)
                        {
                            certType = 111; //身份证类型
                            string ch = idCard.Substring(len - 2, 1);
                            int    i;
                            bool   result = int.TryParse(ch, out i);
                            if (result)
                            {
                                if (i % 2 == 0)
                                {
                                    gender = 2;
                                }
                                else
                                {
                                    gender = 1;
                                }
                            }
                        }
                        //构造需要推送的用户参数
                        lstUsers.Add(new {
                            clientId        = j,
                            personId        = id,
                            personName      = userName,
                            gender          = gender,
                            certificateType = certType,
                            certificateNo   = idCard,
                            orgIndexCode    = "a10d1bf0-c9d5-4b0b-82c3-abd624a79f76"
                        });
                        j++;
                    }
                }
                string usersData = Newtonsoft.Json.JsonConvert.SerializeObject(lstUsers);
                System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:Api地址:/artemis/api/resource/v1/person/batch/add,推送的数据:{usersData}。\n\n");
                //设置推送的参数(由海康提供)
                HttpUtillib.SetPlatformInfo(Config.GetValue("appKey"), Config.GetValue("appSecret"), Config.GetValue("appIP"), int.Parse(Config.GetValue("appPort")), bool.Parse(Config.GetValue("isHttps")));
                //开始推送数据
                bytes = HttpUtillib.HttpPost("/artemis/api/resource/v1/person/batch/add", usersData, 300);
                string data = System.Text.Encoding.UTF8.GetString(bytes);//获取调用结果
                System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:海康门禁服务返回的结果:{data}。\n\n");
                dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(data);
                //如果调用成功
                if (dy.code == "0")
                {
                    //获取海康门禁推送成功的记录
                    List <object> lstSuccess = dy.data.successes;
                    int           count      = lstSuccess.Count;
                    if (count > 0)
                    {
                        System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:调用海康门禁推送人员接口成功,成功记录数{count}\n\n");

                        List <string> lstUserIds = new List <string>();
                        foreach (object obj in lstSuccess)
                        {
                            dynamic dy1 = obj;
                            if (pfrom == 1)
                            {
                                string personId = dy1.personId;
                                if (!lstUserIds.Contains(personId))
                                {
                                    lstUserIds.Add(personId);
                                }
                            }
                            if (pfrom == 0)
                            {
                                long clientId = dy1.clientId;
                                if (!dict.ContainsKey(clientId))
                                {
                                    lstUserIds.Add(dict[clientId]);
                                }
                            }
                        }
                        //把推送成功的记录插入推送历史记录表
                        if (lstUserIds.Count > 0)
                        {
                            //根据推送结果查询成功的用户信息
                            sbSql.AppendFormat("insert into px_pushrecord(id,username,account,idcard,unitname,deptname,postname,worktype,score,datatype,deviceno,projectid,time) select id,username,account,idcard,unitname,deptname,postname,worktype,score,{1},deviceno,projectid,'{2}' from PX_TRAINRECORD where id in('{0}')", string.Join(",", lstUserIds).Replace(",", "','"), pfrom, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                        if (pfrom == 0)
                        {
                            if (lstUserIds.Count > 0)
                            {
                                System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:开始准备获取培训平台人员培训记录\n\n");
                                DepartmentEntity dept = deptBll.GetEntity(orgId);
                                WebClient        wc   = new WebClient();
                                wc.Credentials = CredentialCache.DefaultCredentials;
                                Dictionary <string, string> dictData = new Dictionary <string, string>();
                                dictData.Add("companyId", dept.InnerPhone);
                                dictData.Add("pageIndex", "1");
                                dictData.Add("pageSize", "1000");
                                dictData.Add("userAccounts", string.Join(",", lstUserIds).Replace(",", "','"));
                                dictData.Add("type", "1");
                                wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
                                wc.Encoding = Encoding.UTF8;
                                string apiUrl  = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("TrainApiAddress", "Train");
                                string dicData = Newtonsoft.Json.JsonConvert.SerializeObject(dictData);
                                System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"Api地址:{apiUrl}/api/api/trainRecord/queryTrainList,给培训平台推送的数据:{dicData}。\n\n");
                                string result = wc.UploadString(apiUrl + "/api/api/trainRecord/queryTrainList", "POST", dicData);

                                System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:培训平台返回的结果:{result}。\n\n");
                                dynamic dyData = JsonConvert.DeserializeObject <ExpandoObject>(result);
                                if (dyData.meta.success)
                                {
                                    sbSql.Append("begin  \r\n");
                                    List <object> lstTrainUsers = dyData.data.trainList;
                                    foreach (object obj in lstTrainUsers)
                                    {
                                        dyData = obj;
                                        string id        = Guid.NewGuid().ToString();
                                        string userName  = dyData.userName;
                                        string sex       = dyData.sex == "1" ? "男" : "女";
                                        string account   = dyData.userAccount;
                                        string idCard    = dyData.idNumber;
                                        string unitName  = dyData.companyName;
                                        string deptName  = dyData.deptName;
                                        string postName  = dyData.category;
                                        string workType  = dyData.station;
                                        string score     = dyData.examScore;
                                        string projectId = dyData.projectId;
                                        sbSql.AppendFormat("insert into PX_PUSHRECORD(id,username,account,sex,idcard,unitname,deptname,postname,worktype,score,projectid,time) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'); \r\n", Guid.NewGuid().ToString(), userName, account, sex, idCard, unitName, deptName, postName, workType, score, projectId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                                    }
                                    sbSql.Append("commit;\r\n end;");

                                    System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:执行的SQL语句:{sbSql.ToString()}。\n\n");
                                }
                            }
                        }
                        //插入记录到推送记录表
                        if (sbSql.Length > 0)
                        {
                            deptBll.ExecuteSql(sbSql.ToString());
                        }
                    }
                    if (dy.data.failures.Count > 0)
                    {
                        System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:海康门禁推送人员接口有失败的记录。\n\n");

                        return(new { code = 1, message = "推送失败的数据:" + Newtonsoft.Json.JsonConvert.SerializeObject(dy.data.failures), data = dy.data });
                    }
                    else
                    {
                        return(new { code = 0, message = dy.msg, data = dy.data });
                    }
                }
                else
                {
                    return(new { code = 1, message = dy.msg, data = data });
                }
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:异常信息:{ex.Message}。\n\n");
                return(new { code = 1, message = ex.Message });
            }
        }
Пример #7
0
        public ActionResult GetFileUrl(string keyValue)
        {
            try
            {
                if (dataItemDetailBLL.GetItemValue("flag") == "1")
                {
                    DataTable fie = fileInfoBLL.GetFiles(keyValue);
                    if (fie != null && fie.Rows.Count > 0)
                    {
                        string   path = fie.Rows[0]["FilePath"].ToString();
                        string[] str  = path.Split('/');
                        if (str[str.Length - 1].EndsWith(".pdf"))
                        {
                            return(ToJsonResult(path));
                        }
                        else
                        {
                            path = Server.MapPath(path);
                            string str1     = "~/Resource/Temp/" + str[str.Length - 1].Replace("docx", "pdf").Replace("doc", "pdf");
                            string savePath = Server.MapPath(str1);
                            if (!System.IO.File.Exists(savePath))
                            {
                                System.IO.File.Copy(path, savePath);
                                Aspose.Words.Document doc = new Aspose.Words.Document(savePath);
                                doc.Save(savePath, Aspose.Words.SaveFormat.Pdf);
                            }
                            return(ToJsonResult(str1));
                        }
                    }
                    return(ToJsonResult(0));
                }
                else
                {
                    string fid = string.Empty;
                    if (keyValue.Contains('.'))
                    {
                        fid = keyValue;
                    }
                    else
                    {
                        //根据法规ID获取FID(带后缀)
                        string    sql = string.Format(@"select t.var_fid from ex_attachment t where t.id 
in(select attachment_id from ex_law_attachment t where t.law_id='{0}' and t.law_type='01')", keyValue);
                        DataTable dt  = seb.SelectData(sql);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            fid = dt.Rows[0][0].ToString();
                        }
                        else
                        {
                            return(ToJsonResult(0));
                        }
                    }
                    var    di          = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL();
                    long   expiresLong = DateTime.Now.Ticks / 1000 + 180;
                    string expires     = expiresLong.ToString();
                    string token       = Md5Helper.MD5(di.GetItemValue("antiStealLink.key", "Resource") + fid + expires, 32);
                    string url         = string.Format(di.GetItemValue("LawWebUrl", "Resource"), di.GetItemValue("appId", "Resource"), fid, expires, token);
                    return(ToJsonResult(url));
                }
            }
            catch (Exception)
            {
                return(ToJsonResult(0));
            }
        }
Пример #8
0
        //[WebMethod(Description="新增人员信息")]
        public string createEmployee(SyncUserInfo userInfo)
        {
            try
            {
                string    str   = ReturnCode(0);
                DataTable table = deptBll.GetDataTable(string.Format("select userid from base_user where upper(account)='{0}'", userInfo.uid.ToUpper()));
                if (table.Rows.Count > 0)
                {
                    if (!string.IsNullOrEmpty(userInfo.displayName))
                    {
                        str = this.updateEmployee(userInfo.uid, userInfo.displayName);
                    }
                    if (str != this.ReturnCode(0))
                    {
                        return(str);
                    }
                    if (!string.IsNullOrEmpty(userInfo.email))
                    {
                        str = this.updateEmployeEmail(userInfo.uid, userInfo.email);
                    }
                    if (str != this.ReturnCode(0))
                    {
                        return(str);
                    }
                    if (!string.IsNullOrEmpty(userInfo.password))
                    {
                        str = this.updateEmployeePassword(userInfo.uid, userInfo.password);
                    }
                    str = this.enableOrNotEmployee(userInfo, 1);

                    str = this.UpdateAccountType(userInfo.uid.ToUpper());
                }
                else
                {
                    try
                    {
                        string enCode   = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("hrdl", "FactoryEncode"); //查询电厂编码
                        string orgId    = "";                                                                                         //电厂ID
                        string orgCode  = "";                                                                                         //电厂编码
                        string deptId   = "";                                                                                         //部门Id
                        string deptCode = "";                                                                                         //部门编码
                        if (!string.IsNullOrEmpty(enCode))
                        {
                            DepartmentEntity dept = deptBll.GetEntityByCode(enCode);//获取电厂信息
                            if (dept != null)
                            {
                                orgId   = dept.DepartmentId;
                                orgCode = enCode;
                                //判断是否存在临时人员的部门节点,不存在则新建
                                DataTable dtDept = deptBll.GetDataTable(string.Format("select DepartmentId,encode from BASE_DEPARTMENT where parentid='{0}' and fullname='临时人员' and Nature='部门'", orgId));
                                if (dtDept.Rows.Count > 0)
                                {
                                    deptId   = dtDept.Rows[0][0].ToString();
                                    deptCode = dtDept.Rows[0][1].ToString();
                                }
                                else
                                {
                                    //新建临时人员的部门节点
                                    dept = new DepartmentEntity
                                    {
                                        FullName    = "临时人员",
                                        ParentId    = orgId,
                                        Nature      = "部门",
                                        Description = "临时人员",
                                        IsOrg       = 0,
                                        Industry    = "电力"
                                    };
                                    deptBll.SaveForm("", dept);
                                    deptId   = dept.DepartmentId;
                                    deptCode = dept.EnCode;
                                }
                                dtDept.Dispose();
                            }
                        }
                        //新增的人员直接挂在临时人员的部门节点,后期由电厂管理员手动调整人完善员信息
                        ERCHTMS.Entity.BaseManage.UserEntity user = new Entity.BaseManage.UserEntity();
                        user.UserId         = Guid.NewGuid().ToString();
                        user.RealName       = userInfo.displayName;
                        user.Account        = userInfo.uid;
                        user.Email          = userInfo.email;
                        user.Password       = userInfo.password;
                        user.DepartmentId   = deptId;
                        user.DepartmentCode = deptCode;
                        user.OrganizeCode   = orgCode;
                        user.OrganizeId     = orgId;
                        user.RoleId         = "2a878044-06e9-4fe4-89f0-ba7bd5a1bde6";
                        user.RoleName       = "普通用户";
                        user.IsPresence     = "1";
                        user.AccountType    = "1";
                        user.Mobile         = userInfo.mobile;
                        user.EnCode         = userInfo.empno;
                        //user.WeChat = userInfo.deptId;
                        //user.OICQ = userInfo.password;
                        new ERCHTMS.Busines.BaseManage.UserBLL().SaveForm("", user, 1);
                        return(this.ReturnCode(0));
                    }
                    catch (Exception ex)
                    {
                        LdapDataLog(Newtonsoft.Json.JsonConvert.SerializeObject(ex), 4);
                        return(this.ReturnCode(11));
                    }
                }
                return(str);
            }
            catch (Exception ex)
            {
                LdapDataLog(Newtonsoft.Json.JsonConvert.SerializeObject(ex), 4);
                return(this.ReturnCode(10));
            }
        }
Пример #9
0
        /// <summary>
        /// 获取功能数据
        /// </summary>
        /// <returns></returns>
        private object GetModuleData()
        {
            var bzweb      = string.Empty;
            var appSetting = ConfigurationManager.AppSettings["bzweb"];

            if (appSetting != null)
            {
                bzweb = appSetting.ToString();
            }

            var user = ERCHTMS.Code.OperatorProvider.Provider.Current();
            List <ModuleEntity> list      = new List <ModuleEntity>();
            DataTable           dtModules = new DepartmentBLL().GetDataTable(string.Format("select moduleid from BASE_APPSETTINGASSOCIATION t where t.deptid='{0}' and PALTFORMTYPE=3", user.OrganizeId));

            if (dtModules.Rows.Count > 0)
            {
                string[] mIds = dtModules.AsEnumerable().Select(d => d.Field <string>("moduleid")).ToArray();
                list = moduleBLL.GetListBySql(string.Format("select * from base_module t where moduleid in('{0}') order by sortcode asc", string.Join(",", mIds).Replace(",", "','"))).ToList();
            }
            else
            {
                list = authorizeBLL.GetModuleList(SystemInfo.CurrentUserId).ToList();
            }
            var              di  = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL();
            string           val = new DataItemDetailBLL().GetItemValue("TrainSyncWay"); //对接方式,0:账号,1:身份证,不配置默认为账号
            string           way = new DataItemDetailBLL().GetItemValue("WhatWay");      //对接平台 0:.net培训平台 1:java培训平台
            DepartmentEntity org = new DepartmentBLL().GetEntity(user.OrganizeId);

            foreach (ModuleEntity entity in list)
            {
                if (!string.IsNullOrEmpty(entity.UrlAddress))
                {
                    if (!string.IsNullOrEmpty(bzweb))
                    {
                        entity.UrlAddress = entity.UrlAddress.Replace("{bzweb}", bzweb);
                    }
                    if (entity.EnCode == "SafetyTrain")
                    {
                        string url = di.GetItemValue("TrainWebUrl");
                        if (!string.IsNullOrEmpty(url))
                        {
                            if (way == "1")
                            {
                                UserEntity ue      = new UserBLL().GetEntity(user.UserId);
                                string     account = string.IsNullOrWhiteSpace(ue.NewAccount) ? user.Account : ue.NewAccount;
                                entity.UrlAddress = url + "?account=" + account + "&psw=" + Md5Helper.MD5(account, 32).ToLower() + "&companyId=" + org.InnerPhone;
                            }
                            else
                            {
                                if (string.IsNullOrWhiteSpace(user.IdentifyID))
                                {
                                    entity.UrlAddress = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.Account);
                                }
                                else
                                {
                                    if (!string.IsNullOrWhiteSpace(val))
                                    {
                                        if (val == "0")
                                        {
                                            entity.UrlAddress = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.Account);
                                        }
                                        else
                                        {
                                            entity.UrlAddress = url + "?tokenId=" + BSFramework.Util.DESEncrypt.EncryptString(user.IdentifyID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        string bzUrl = di.GetItemValue("bzWebUrl");
                        if (!string.IsNullOrWhiteSpace(bzUrl))
                        {
                            if (entity.UrlAddress.ToLower().StartsWith("http://") && entity.UrlAddress.ToLower().Contains(bzUrl.ToLower()))
                            {
                                string args = args = BSFramework.Util.DESEncrypt.Encrypt(string.Concat(user.Account, "^" + entity.UrlAddress + "^", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "^DLBZ"));
                                entity.UrlAddress = bzUrl + "login/signin?args=" + args;
                            }
                        }

                        if (entity.EnCode == "TaskSchedulerManager")
                        {
                            entity.UrlAddress += "?args=" + BSFramework.Util.DESEncrypt.Encrypt("admin|1", "!2#3@1YV");
                        }
                    }
                }
            }
            return(list);
        }
Пример #10
0
        public ActionResult ExportData(string queryJson)
        {
            try
            {
                string     isHrdl     = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("IsOpenPassword");
                Pagination pagination = new Pagination();
                pagination.page = 1;
                pagination.rows = 1000000000;
                var watch = CommonHelper.TimerStart();
                pagination.conditionJson = " 1=1 ";
                pagination.sidx          = "applydate desc,applycode"; //排序字段
                pagination.sord          = "desc";                     //排序方式

                LifthoistSearchModel search = null;
                if (!string.IsNullOrEmpty(queryJson))
                {
                    search = JsonConvert.DeserializeObject <LifthoistSearchModel>(queryJson);
                }
                else
                {
                    search = new LifthoistSearchModel();
                }

                #region 数据权限
                Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                if (!user.IsSystem)
                {
                    //根据当前用户对模块的权限获取记录
                    string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "a.createuserdeptcode", "a.createuserorgcode");
                    if (!string.IsNullOrEmpty(where))
                    {
                        pagination.conditionJson += " and " + where;
                    }
                }
                #endregion
                //查凭吊证
                DataTable dt    = null;
                string    title = "";
                if (search.pagetype == "1")
                {
                    title = "准吊证申请";
                    dt    = lifthoistcertbll.GetList(pagination, search);
                }
                else
                {
                    title = "起重吊装作业申请";
                    dt    = lifthoistjobbll.GetList(pagination, search);
                }
                DataTable exportTable = dt;
                DataTable excelTable  = new DataTable();
                excelTable.Columns.Add(new DataColumn("auditstate"));
                excelTable.Columns.Add(new DataColumn("applycodestr"));
                if (search.pagetype != "1")
                {
                    excelTable.Columns.Add(new DataColumn("qualitytype"));
                }
                excelTable.Columns.Add(new DataColumn("toolname"));
                excelTable.Columns.Add(new DataColumn("worktime"));
                excelTable.Columns.Add(new DataColumn("constructionunitname"));
                excelTable.Columns.Add(new DataColumn("applyusername"));
                excelTable.Columns.Add(new DataColumn("applydate"));
                excelTable.Columns.Add(new DataColumn("flowdeptname"));
                excelTable.Columns.Add(new DataColumn("flowname"));

                foreach (DataRow item in dt.Rows)
                {
                    DataRow newDr      = excelTable.NewRow();
                    string  auditstate = item["auditstate"].ToString();
                    if (auditstate == "0")
                    {
                        auditstate = "申请中";
                    }
                    else if (auditstate == "1")
                    {
                        auditstate = "审核(批)中";
                    }
                    else if (auditstate == "2")
                    {
                        auditstate = "审核(批)通过";
                    }
                    newDr["auditstate"]   = auditstate;
                    newDr["applycodestr"] = item["applycodestr"];

                    if (search.pagetype != "1")
                    {
                        string qualitytype = item["qualitytype"].ToString();
                        if (qualitytype == "0")
                        {
                            qualitytype = "30T以下";
                        }
                        else if (qualitytype == "1")
                        {
                            qualitytype = "30T以上";
                        }
                        else
                        {
                            qualitytype = "2台起重设备共同起吊3T及以上";
                        }
                        newDr["qualitytype"] = qualitytype;
                    }
                    newDr["auditstate"] = auditstate;
                    newDr["toolname"]   = item["toolname"];

                    DateTime workstartdate, workenddate, applydate;
                    DateTime.TryParse(item["workstartdate"].ToString(), out workstartdate);
                    DateTime.TryParse(item["workenddate"].ToString(), out workenddate);
                    DateTime.TryParse(item["applydate"].ToString(), out applydate);

                    string worktime = string.Empty;
                    if (workstartdate.ToString("yyyy-MM-dd HH:mm") != "0001-01-01 00:00")
                    {
                        worktime += workstartdate.ToString("yyyy-MM-dd HH:mm");
                    }
                    if (workenddate.ToString("yyyy-MM-dd HH:mm") != "0001-01-01 00:00")
                    {
                        worktime += " - " + workenddate.ToString("yyyy-MM-dd HH:mm");
                    }
                    newDr["worktime"]             = worktime;
                    newDr["constructionunitname"] = item["constructionunitname"];
                    newDr["applyusername"]        = item["applyusername"];

                    string adate = string.Empty;
                    if (applydate.ToString("yyyy-MM-dd HH:mm") != "0001-01-01 00:00")
                    {
                        adate = applydate.ToString("yyyy-MM-dd HH:mm");
                    }
                    newDr["applydate"]    = adate;
                    newDr["flowdeptname"] = item["flowdeptname"];
                    newDr["flowname"]     = item["flowname"];

                    excelTable.Rows.Add(newDr);
                }
                //设置导出格式
                ExcelConfig excelconfig = new ExcelConfig();
                excelconfig.Title           = title;
                excelconfig.TitleFont       = "微软雅黑";
                excelconfig.TitlePoint      = 16;
                excelconfig.FileName        = title + ".xls";
                excelconfig.IsAllSizeColumn = true;
                List <ColumnEntity> listColumnEntity = new List <ColumnEntity>();
                excelconfig.ColumnEntity = listColumnEntity;
                ColumnEntity columnentity = new ColumnEntity();
                //需跟数据源列顺序保持一致
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "auditstate", ExcelColumn = "作业许可状态", Width = 20
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "applycodestr", ExcelColumn = "申请编号", Width = 20
                });
                if (search.pagetype != "1")
                {
                    excelconfig.ColumnEntity.Add(new ColumnEntity()
                    {
                        Column = "qualitytype", ExcelColumn = "起吊质量描述", Width = 20
                    });
                }
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "toolname", ExcelColumn = "吊装工具名称", Width = 15
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "worktime", ExcelColumn = isHrdl == "true" ? "作业时间" : "计划作业时间", Width = 20
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "constructionunitname", ExcelColumn = "作业单位", Width = 20
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "applyusername", ExcelColumn = "申请人", Width = 40
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "applydate", ExcelColumn = "申请时间", Width = 20
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "flowdeptname", ExcelColumn = "审核/批部门", Width = 20
                });
                excelconfig.ColumnEntity.Add(new ColumnEntity()
                {
                    Column = "flowname", ExcelColumn = "审核/批流程", Width = 20
                });
                //调用导出方法
                ExcelHelper.ExcelDownload(excelTable, excelconfig);
            }
            catch (Exception ex)
            {
            }
            return(Success("导出成功。"));
        }
Пример #11
0
        public ActionResult GetListJson(Pagination pagination, string queryJson)
        {
            try
            {
                var watch = CommonHelper.TimerStart();
                pagination.conditionJson = " 1=1 ";

                LifthoistSearchModel search = null;
                if (!string.IsNullOrEmpty(queryJson))
                {
                    search = JsonConvert.DeserializeObject <LifthoistSearchModel>(queryJson);
                }
                else
                {
                    search = new LifthoistSearchModel();
                }

                #region 数据权限
                Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current();
                if (!user.IsSystem)
                {
                    string isAllDataRange = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetEnableItemValue("HighRiskWorkDataRange"); //特殊标记,高风险作业模块是否看全厂数据
                    if (!string.IsNullOrWhiteSpace(isAllDataRange))
                    {
                        pagination.conditionJson += " and a.createuserorgcode='" + user.OrganizeCode + "'";
                    }
                    else
                    {
                        //根据当前用户对模块的权限获取记录
                        string where = new AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value, "a.createuserdeptcode", "a.createuserorgcode");
                        if (!string.IsNullOrEmpty(where))
                        {
                            pagination.conditionJson += " and " + where;
                        }
                    }
                }
                #endregion
                //查凭吊证
                DataTable dt = null;
                if (search.pagetype == "1")
                {
                    dt = lifthoistcertbll.GetList(pagination, search);
                }
                else
                {
                    dt = lifthoistjobbll.GetList(pagination, search);
                }
                var jsonData = new
                {
                    rows     = dt,
                    total    = pagination.total,
                    page     = pagination.page,
                    records  = pagination.records,
                    costtime = CommonHelper.TimerEnd(watch)
                };
                return(ToJsonResult(jsonData));
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
Пример #12
0
        /// <summary>
        /// 获取人员培训记录(来自培训平台)
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="queryJson"></param>
        /// <returns></returns>
        public ActionResult GetTrainUsersPageList(Pagination pagination, string queryJson)
        {
            Operator user = OperatorProvider.Provider.Current();

            if (user == null)
            {
                return(Error("身份票据已过期!"));
            }
            DepartmentEntity dept = deptBll.GetEntity(user.OrganizeId);

            if (dept == null)
            {
                return(Error("当前用户部门不存在!"));
            }
            if (string.IsNullOrWhiteSpace(dept.InnerPhone))
            {
                return(Error("当前机构未配置培训平台单位ID!"));
            }
            var watch = CommonHelper.TimerStart();

            DataTable dtUsers = deptBll.GetDataTable(string.Format("select account from PX_PUSHRECORD where datatype=0 union select account from HIK_USERRELATION t"));
            WebClient wc      = new WebClient();

            wc.Credentials = CredentialCache.DefaultCredentials;
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("companyId", dept.InnerPhone);
            dict.Add("pageIndex", pagination.page.ToString());
            dict.Add("pageSize", pagination.rows.ToString());
            if (dtUsers.Rows.Count > 0)
            {
                string accounts = string.Join(",", dtUsers.AsEnumerable().Select(t => t.Field <string>("account")).ToArray());
                dict.Add("userAccounts", accounts);
                dict.Add("type", "2");
            }
            if (!string.IsNullOrWhiteSpace(queryJson))
            {
                var queryParam = queryJson.ToJObject();
                if (!queryParam["deptId"].IsEmpty())
                {
                    string deptId = queryParam["deptId"].ToString();
                    dept = deptBll.GetEntity(deptId);
                    if (dept != null)
                    {
                        if (!string.IsNullOrWhiteSpace(dept.DeptKey))
                        {
                            deptId = dept.DeptKey.Split('|')[0];
                        }
                        dict.Add("deptId", deptId);
                    }
                }
                if (!queryParam["projectId"].IsEmpty())
                {
                    string projectId = queryParam["projectId"].ToString();
                    dict.Add("projectIds", projectId);
                }
                if (!queryParam["keyword"].IsEmpty() && !queryParam["condition"].IsEmpty())
                {
                    string keyword   = queryParam["keyword"].ToString().Trim();
                    string condition = queryParam["condition"].ToString();
                    dict.Add(condition, keyword);
                }
            }
            string apiUrl = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("TrainApiAddress", "Train");

            wc.Encoding = Encoding.UTF8;
            wc.Headers.Add("Content-Type", "application/json;charset=UTF-8");
            string  data   = Newtonsoft.Json.JsonConvert.SerializeObject(dict);
            string  result = wc.UploadString(apiUrl + "/api/api/trainRecord/queryTrainList", "POST", data);
            dynamic dyData = JsonConvert.DeserializeObject <ExpandoObject>(result);

            if (dyData.meta.success)
            {
                int  page       = 0;
                long total      = dyData.data.count;
                int  totalCount = int.Parse(total.ToString());

                List <string> lstIdCards = deptBll.GetDataTable("select idcard from tmp_idcards").AsEnumerable().Select(t => t.Field <string>("idcard")).ToList();
                List <object> lstData    = dyData.data.trainList;
                for (int j = 0; j < lstData.Count; j++)
                {
                    dynamic row    = lstData[j];
                    string  idCard = row.idNumber;
                    if (!string.IsNullOrWhiteSpace(idCard) && lstIdCards.Contains(idCard))
                    {
                        lstData.RemoveAt(j);
                        totalCount--;
                    }
                }
                if (totalCount % 1000 == 0)
                {
                    page = totalCount / pagination.rows;
                }
                else
                {
                    page = totalCount / pagination.rows + 1;
                }
                var JsonData = new
                {
                    rows     = lstData,
                    total    = page,
                    page     = pagination.page,
                    records  = totalCount,
                    costtime = CommonHelper.TimerEnd(watch)
                };
                return(Content(JsonData.ToJson()));
            }
            return(Content(result));
        }