示例#1
0
        public ActionResult SaveWaitWork(int status = 1)
        {
            var           user    = ERCHTMS.Code.OperatorProvider.Provider.Current();
            DepartmentBLL deptBll = new DepartmentBLL();
            int           count   = deptBll.ExecuteSql(string.Format("begin\r\ndelete from BIS_USERWAIWORK where userid='{1}';\r\ninsert into BIS_USERWAIWORK(id,userid,status) values('{0}','{1}',1);\r\n end\r\ncommit;", Guid.NewGuid().ToString(), user.UserId));

            return(count > 0?Success("操作成功"):Error("操作失败"));
        }
示例#2
0
        public void SendMessage(string chkId)
        {
            List <string> lstIds  = new List <string>();
            MessageBLL    msgBll  = new MessageBLL();
            DepartmentBLL deptBll = new DepartmentBLL();
            DataTable     dt      = deptBll.GetDataTable(string.Format("select id, account,realname,ItemName,PlanDate,Measures from jt_checkitems a right join base_user u on a.dutyuserid=u.userid where a.checkid='{0}' and a.issend=0 and RealityDate is null", chkId));

            foreach (DataRow dr in dt.Rows)
            {
                string        account  = dr["account"].ToString();
                string        userName = dr["realname"].ToString();
                string        content  = string.Format("您有一条检查问题为“{0}”需要整改,请在{1}之前按“{2}”要求进行整改。", dr["ItemName"], dr["PlanDate"], dr["Measures"]);
                MessageEntity msg      = new MessageEntity
                {
                    Title        = "您有一条检查问题需要整改",
                    Category     = "其它",
                    Content      = content,
                    UserId       = account,
                    UserName     = userName,
                    Status       = "",
                    Url          = string.Format("/SaftyCheck/JTSafetyCheck/Form?keyValue={0}&action=show", chkId),
                    SendUser     = "******",
                    SendUserName = "******",
                    RecId        = chkId
                };
                bool result = msgBll.SaveForm("", msg);
                if (result)
                {
                    lstIds.Add(dr["id"].ToString());
                }
            }
            if (lstIds.Count > 0)
            {
                deptBll.ExecuteSql(string.Format("update jt_checkitems set issend=1 where id in('{0}')", string.Join("','", lstIds)));
            }
        }
示例#3
0
        public object SyncTrainRecord([FromBody] JObject json)
        {
            try
            {
                string        res           = json.Value <string>("json");
                dynamic       dyData        = JsonConvert.DeserializeObject <ExpandoObject>(res);
                List <object> list          = dyData.data;
                DepartmentBLL departmentBLL = new DepartmentBLL();
                StringBuilder sb            = new StringBuilder("begin  \r\n");
                if (dyData.type == 3)//培训人员
                {
                    foreach (object obj in list)
                    {
                        dynamic dy       = obj;
                        string  idCard   = dy.idCard;//证件号
                        bool    isDelete = dy.isDelete;
                        string  number   = departmentBLL.GetDataTable(string.Format("select count(1) from PX_TRAINRECORD where idcard='{0}'", idCard)).Rows[0][0].ToString();
                        if (number != "0" || isDelete)
                        {
                            sb.AppendFormat("delete from PX_TRAINRECORD where idcard='{0}'; \r\n", idCard);
                        }
                        string userName  = dy.userName;  //姓名
                        string postName  = dy.postName;  //岗位
                        string workType  = dy.workType;  //工种
                        string unitName  = dy.unitName;  //单位名称
                        double hours     = dy.hours;     //培训学时
                        long   passScore = dy.passScore; //合格分
                        double score     = dy.score;     //成绩
                        string deviceNo  = dy.deviceNo;  //设备编号
                        string unitId    = dy.unitId;
                        string deptId    = dy.deptId;
                        string projectId = dy.projectId;


                        string sql = string.Format("insert into PX_TRAINRECORD(id,USERNAME,IDCARD,UNITNAME,UNITID,DEPTID,POSTNAME,WORKTYPE,PROJECTID,SCORE,PASSSCORE,DEVICENO,account) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{2}'); \r\n", Guid.NewGuid().ToString(), userName, idCard, unitName, unitId, deptId, postName, workType, projectId, score, passScore, deviceNo);
                        sb.AppendFormat(sql);
                    }
                }
                if (dyData.type == 2) //培训项目
                {
                    foreach (object obj in list)
                    {
                        dynamic dy        = obj;
                        string  projectId = dy.projectId;//ID
                        bool    isDelete  = dy.isDelete;
                        string  number    = departmentBLL.GetDataTable(string.Format("select count(1) from PX_TRAINPROJECT where id='{0}'", projectId)).Rows[0][0].ToString();
                        if (number != "0" || isDelete)
                        {
                            sb.AppendFormat("delete from PX_TRAINPROJECT where id='{0}'; \r\n", projectId);
                        }
                        string projectName = dy.projectName; //培训项目名称
                        string startTime   = dy.startTime;   //培训开始时间
                        string endTime     = dy.endTime;     //培训结束时间
                        double hours       = dy.hours;       //培训学时
                        string trainType   = dy.trainType;   //培训类型

                        string sql = string.Format("insert into PX_TRAINPROJECT(id,PROJECTNAME,STARTTIME,ENDTIME,TRAINTYPE,HOURS) values('{0}','{1}','{2}','{3}','{4}','{5}'); \r\n", projectId, projectName, startTime, endTime, trainType, hours);
                        sb.AppendFormat(sql);
                    }
                }

                sb.Append("commit;\r\n end;");
                int count = departmentBLL.ExecuteSql(sb.ToString());
                return(new { code = 0, message = "操作成功", data = res });
            }
            catch (Exception ex)
            {
                return(new { code = 1, message = ex.Message });
            }
        }
示例#4
0
        public object GetAllIdCardsFormHik()
        {
            string logPath = HttpContext.Current.Server.MapPath("~/logs/menjin/");

            try
            {
                //设置推送的参数(由海康提供)
                HttpUtillib.SetPlatformInfo(Config.GetValue("appKey"), Config.GetValue("appSecret"), Config.GetValue("appIP"), int.Parse(Config.GetValue("appPort")), bool.Parse(Config.GetValue("isHttps")));
                //根据身份证号获取海康人员信息
                byte[]  bytes = HttpUtillib.HttpPost("/artemis/api/resource/v2/person/personList", Newtonsoft.Json.JsonConvert.SerializeObject(new { pageSize = 1000, pageNo = 1 }), 300);
                string  data  = System.Text.Encoding.UTF8.GetString(bytes);//获取调用结果
                dynamic dy    = JsonConvert.DeserializeObject <ExpandoObject>(data);
                //如果调用成功
                List <string> lstIdCards = new List <string>();
                if (dy.code == "0")
                {
                    StringBuilder sbSql = new StringBuilder("begin\r\n");
                    deptBll.ExecuteSql("delete from tmp_idcards");
                    List <object> lstUsers = dy.data.list;
                    long          total    = dy.data.total;
                    if (total <= 1000)
                    {
                        foreach (object obj in lstUsers)
                        {
                            dy = obj;
                            long certType = dy.certificateType;
                            if (certType == 111)
                            {
                                sbSql.AppendFormat("insert into tmp_idcards(idcard) values('{0}');\r\n", dy.certificateNo);
                                lstIdCards.Add(dy.certificateNo);
                            }
                        }
                    }
                    else
                    {
                        int page = 2;
                        //分页设置,因接口最多支持1000个查询条件
                        int totalCount = int.Parse(total.ToString());
                        if (totalCount % 1000 == 0)
                        {
                            page = totalCount / 1000;
                        }
                        else
                        {
                            page = totalCount / 1000 + 1;
                        }
                        for (int i = 2; i <= page; i++)
                        {
                            bytes = HttpUtillib.HttpPost("/artemis/api/resource/v2/person/personList", Newtonsoft.Json.JsonConvert.SerializeObject(new { pageSize = 1000, pageNo = i }), 300);
                            data  = System.Text.Encoding.UTF8.GetString(bytes);//获取调用结果
                            dy    = JsonConvert.DeserializeObject <ExpandoObject>(data);
                            if (dy.code == "0")
                            {
                                lstUsers = dy.data.list;
                                foreach (object obj in lstUsers)
                                {
                                    dy = obj;
                                    long certType = dy.certificateType;
                                    if (certType == 111)
                                    {
                                        sbSql.AppendFormat("insert into tmp_idcards(idcard) values('{0}');\r\n", dy.certificateNo);
                                        lstIdCards.Add(dy.certificateNo);
                                    }
                                }
                            }
                        }
                    }
                    sbSql.Append("commit;\r\n end;");
                    if (lstIdCards.Count > 0)
                    {
                        deptBll.ExecuteSql(sbSql.ToString());
                    }
                    System.IO.File.AppendAllText(logPath + $"{DateTime.Now.ToString("yyyyMMdd")}.txt", $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}:查询到的用户身份证件号:{lstIdCards.ToJson()}。SQL:{sbSql.ToString()}\n\n");
                }
                return(new { code = 0, message = "操作成功", data = string.Join(",", lstIdCards) });
            }
            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 });
            }
        }
示例#5
0
 /// <summary>
 /// 新增或修改人员证书
 /// </summary>
 /// <param name="userId"></param>
 /// <returns></returns>
 public object SaveUserCert()
 {
     try
     {
         string  res = HttpContext.Current.Request["json"];
         dynamic dy  = JsonConvert.DeserializeObject <ExpandoObject>(res);
         string  id  = "";
         //var keys = HttpContext.Current.Request.Form.AllKeys;
         //Hashtable ht = new Hashtable();
         //foreach(string key in keys)
         //{
         //    ht.Add(key, HttpContext.Current.Request.Form[key]);
         //}
         var content            = Newtonsoft.Json.JsonConvert.SerializeObject(dy.data);
         CertificateEntity cert = Newtonsoft.Json.JsonConvert.DeserializeObject <CertificateEntity>(content);
         if (string.IsNullOrWhiteSpace(cert.Id))
         {
             id = Guid.NewGuid().ToString();
         }
         else
         {
             id = cert.Id;
         }
         string path   = itemBll.GetItemValue("imgPath");
         string remark = "";
         if (!string.IsNullOrWhiteSpace(cert.Remark))
         {
             remark      = cert.Remark;
             cert.Remark = "";
         }
         bool        result      = certificatebll.SaveForm(id, cert);
         FileInfoBLL fileInfoBLL = new FileInfoBLL();
         if (result)
         {
             HttpFileCollection files = HttpContext.Current.Request.Files;
             for (int i = 0; i < files.AllKeys.Length; i++)
             {
                 HttpPostedFile file = files[i];
                 //获取文件完整文件名(包含绝对路径)
                 //文件存放路径格式:/Resource/ResourceFile/{userId}{data}/{guid}.{后缀名}
                 string fileGuid       = Guid.NewGuid().ToString();
                 long   filesize       = file.ContentLength;
                 string FileEextension = Path.GetExtension(file.FileName);
                 string uploadDate     = DateTime.Now.ToString("yyyyMMdd");
                 string virtualPath    = string.Format("~/Resource/cert/{0}/{1}{2}", uploadDate, fileGuid, FileEextension);
                 string virtualPath1   = string.Format("\\Resource\\cert\\{0}\\{1}{2}", uploadDate, fileGuid, FileEextension);
                 string fullFileName   = path + virtualPath1;
                 //创建文件夹
                 string path1 = Path.GetDirectoryName(fullFileName);
                 Directory.CreateDirectory(path1);
                 FileInfoEntity fileInfoEntity = new FileInfoEntity();
                 if (!System.IO.File.Exists(fullFileName))
                 {
                     //保存文件
                     file.SaveAs(fullFileName);
                 }
                 //文件信息写入数据库
                 fileInfoEntity.FileId         = fileGuid;
                 fileInfoEntity.RecId          = id; //关联ID
                 fileInfoEntity.FolderId       = "cert";
                 fileInfoEntity.FileName       = file.FileName;
                 fileInfoEntity.FilePath       = virtualPath;
                 fileInfoEntity.FileSize       = filesize.ToString();
                 fileInfoEntity.FileExtensions = FileEextension;
                 fileInfoEntity.FileType       = FileEextension.Replace(".", "");
                 fileInfoBLL.SaveForm("", fileInfoEntity);
             }
             if (!string.IsNullOrWhiteSpace(remark))
             {
                 deptBll.ExecuteSql(string.Format("delete from base_fileinfo where recid='{0}' and fileid in('{1}')", id, remark.Replace(",", "','")));
             }
             return(new { code = 0, info = "操作成功", data = cert });
         }
         else
         {
             return(new { code = 1, info = "操作失败" });
         }
     }
     catch (Exception ex)
     {
         return(new { code = 1, info = ex.Message });
     }
 }