/// <summary> /// 缓存双控对接Safety平台token /// </summary> /// <returns></returns> public string GetSafetyToken() { try { string cachevalue = CacheFactory.Cache().GetCache <string>("Safety_Token"); if (string.IsNullOrEmpty(cachevalue)) { string token = ""; var appID = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("SafetyAppID"); var secret = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("SafetySecret"); var dataExchangeUrl = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("GetTokenUrl"); string url = dataExchangeUrl + "appid=" + appID + "&secret=" + secret; WebClient wc = new WebClient(); wc.Credentials = CredentialCache.DefaultCredentials; wc.Headers.Add("Content-Type", "text/json; charset=utf-8"); wc.Encoding = Encoding.UTF8; //发送请求到web api并获取返回值,默认为post方式 string data = wc.DownloadString(new Uri(url)); dynamic objectToken = Newtonsoft.Json.JsonConvert.DeserializeObject(data); token = objectToken.token; CacheFactory.Cache().WriteCache(token, "Safety_Token", DateTime.Now.AddSeconds(7000)); return(token); } else { return(cachevalue); } } catch (Exception e) { return(""); } }
public ActionResult GetFilePath(string recId, string filename) { var data = fileInfoBLL.GetEntity(recId, filename); if (data != null) { string url = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("imgUrl"); return(Success(data.FilePath, url + data.FilePath.Replace("~", ""))); } else { return(Error("获取文件信息失败")); } }
public void ExportDetails(string keyValue) { try { var IsHrdl = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("IsOpenPassword"); if (IsHrdl == "true") { ExportHrdlTemp(keyValue); } else { ExportCommonTemp(keyValue); } } catch (Exception) { throw; } }
public ActionResult Mark() { string path = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("imgUrl"); Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); //获取电厂区域图 DataTable dtFiles = new ERCHTMS.Busines.PublicInfoManage.FileInfoBLL().GetFiles(user.OrganizeId); if (dtFiles.Rows.Count > 0) { string imgUrl = dtFiles.Rows[0]["filepath"].ToString(); imgUrl = imgUrl.Replace("~", ""); imgUrl = path + imgUrl; ViewBag.MapImage = imgUrl; } else { ViewBag.MapImage = ""; } return(View()); }
public ActionResult GetSafetyValue(string keyValue) { try { string point = ""; string token = new TokenCache().GetToken(); if (!string.IsNullOrEmpty(token)) { string environmentalUrl = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetItemValue("EnvironmentalUrl"); string url = environmentalUrl + token; WebClient wc = new WebClient(); wc.Credentials = CredentialCache.DefaultCredentials; //wc.Headers.Add("Content-Type", "text/json; charset=utf-8"); wc.Encoding = Encoding.GetEncoding("GB2312"); System.Collections.Specialized.NameValueCollection nc = new System.Collections.Specialized.NameValueCollection(); nc.Add("pointID", keyValue); byte[] bytes = wc.UploadValues(new Uri(url), "POST", nc); var data = Encoding.UTF8.GetString(bytes); XmlDocument xml = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(data); if (xml.ChildNodes.Count > 0) { foreach (dynamic xmlChildNode in xml.ChildNodes) { if (xmlChildNode.Name == "soap:Envelope") { point = xmlChildNode.InnerText; } } } return(ToJsonResult(new { code = 0, message = "获取数据成功", point = point })); } else { return(ToJsonResult(new { code = -1, message = "token失效", point = "" })); } } catch (Exception e) { return(ToJsonResult(new { code = -1, message = e.Message, point = "" })); } }
public ActionResult GetPageListJson(Pagination pagination, string queryJson) { try { var watch = CommonHelper.TimerStart(); pagination.p_kid = "t.id"; pagination.p_fields = @"t.createuserid, t.createdate,t.changetype,t.projectname,t.changename,t.workunittype,t.projectid, t.applyunit,t.applychangetime,t.returntime, t.applyunitid,t.applypeople,t.applypeopleid, t.applytime, t.workunit,t.workunitid,t.applyno, t.iscommit,t.isaccepover,t.isapplyover,t.acceppeople, t.flowdept,t.nodename,t.nodeid,t.isaccpcommit,t.createuserdeptcode, t.flowrole,t.flowdeptname,t.flowrolename,t.flowremark,t.specialtytype,t.accspecialtytype,'' as approveuserid,b.outtransferuseraccount,b.intransferuseraccount,'' as approveuseraccount, case when t.iscommit=0 then 0 when t.iscommit=1 and t.isapplyover=0 then 1 when t.iscommit=1 and t.isapplyover=2 then 2 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=0 and t.isaccepover=0 then 3 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=0 then 4 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=2 then 5 when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=1 then 6 else 7 end currstate, case when t.iscommit=0 then '变动申请中' when t.iscommit=1 and t.isapplyover=0 then '变动审核(批)中' when t.iscommit=1 and t.isapplyover=2 then '变动审核(批)未通过' when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=0 and t.isaccepover=0 then '变动审核(批)通过待验收' when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=0 then '验收审核中' when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=2 then '验收审核(批)未通过' when t.iscommit=1 and t.isapplyover=1 and isaccpcommit=1 and t.isaccepover=1 then '验收审核(批)通过' else '' end resultstate"; pagination.p_tablename = @" bis_safetychange t left join (select recid,flowid,outtransferuseraccount,intransferuseraccount,row_number() over(partition by recid,flowid order by createdate desc) as num from BIS_TRANSFERRECORD where disable=0) b on t.id=b.recid and t.nodeid=b.flowid and b.num=1"; //pagination.sidx = "t.createdate";//排序字段 //pagination.sord = "desc";//排序方式 pagination.conditionJson = "1=1"; Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); if (!user.IsSystem) { string authType = new AuthorizeBLL().GetOperAuthorzeType(user, HttpContext.Request.Cookies["currentmoduleId"].Value, "search"); if (!string.IsNullOrEmpty(authType)) { string isAllDataRange = new ERCHTMS.Busines.SystemManage.DataItemDetailBLL().GetEnableItemValue("HighRiskWorkDataRange"); //特殊标记,高风险作业模块是否看全厂数据 if (!string.IsNullOrEmpty(isAllDataRange)) { pagination.conditionJson += " and t.createuserorgcode='" + user.OrganizeCode + "'"; } else { switch (authType) { case "1": pagination.conditionJson += " and applypeopleid='" + user.UserId + "'"; break; case "2": pagination.conditionJson += " and workunitcode='" + user.DeptCode + "'"; break; case "3": //本子部门 pagination.conditionJson += string.Format(" and ((workunitcode in(select encode from base_department where encode like '{0}%')) or (projectid in(select id from epg_outsouringengineer a where a.engineerletdeptid = '{1}')))", user.DeptCode, user.DeptId); break; case "4": pagination.conditionJson += " and t.createuserorgcode='" + user.OrganizeCode + "'"; break; } } } else { pagination.conditionJson += " and 0=1"; } } DataTable data = safetychangebll.GetPageList(pagination, queryJson); for (int i = 0; i < data.Rows.Count; i++) { string executedept = string.Empty; highriskcommonapplybll.GetExecutedept(data.Rows[i]["workunittype"].ToString(), data.Rows[i]["workunitid"].ToString(), data.Rows[i]["projectid"].ToString(), out executedept); //获取执行部门 string createdetpid = departmentbll.GetEntityByCode(data.Rows[i]["createuserdeptcode"].ToString()).IsEmpty() ? "" : departmentbll.GetEntityByCode(data.Rows[i]["createuserdeptcode"].ToString()).DepartmentId; //获取创建部门 string outsouringengineerdept = string.Empty; highriskcommonapplybll.GetOutsouringengineerDept(data.Rows[i]["workunitid"].ToString(), out outsouringengineerdept); string str = manypowercheckbll.GetApproveUserAccount(data.Rows[i]["nodeid"].ToString(), data.Rows[i]["id"].ToString(), "", data.Rows[i]["specialtytype"].ToString(), executedept, outsouringengineerdept, createdetpid, "", ""); data.Rows[i]["approveuseraccount"] = str; } var jsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch) }; return(ToJsonResult(jsonData)); } catch (System.Exception ex) { return(Error(ex.ToString())); } }
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; #region 数据权限 Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); //查看范围数据权限 /** * 1.作业单位及子部门(下级) * 2.本人创建的作业 * 3.发包部门管辖的外包单位 * 4.外包单位只能看本单位的 * */ string authType = new AuthorizeBLL().GetOperAuthorzeType(user, HttpContext.Request.Cookies["currentmoduleId"].Value, "search"); #endregion var data = firewaterbll.GetList(pagination, queryJson, authType, user); DataTable excelTable = new DataTable(); excelTable.Columns.Add(new DataColumn("applystatestr")); excelTable.Columns.Add(new DataColumn("applynumber")); excelTable.Columns.Add(new DataColumn("workdepttypestr")); excelTable.Columns.Add(new DataColumn("workplace")); excelTable.Columns.Add(new DataColumn("worktime")); excelTable.Columns.Add(new DataColumn("workdeptname")); excelTable.Columns.Add(new DataColumn("applyusername")); excelTable.Columns.Add(new DataColumn("applytime")); foreach (DataRow item in data.Rows) { int state = 0; int.TryParse(item["applystate"].ToString(), out state); int workdepttype = 0; int.TryParse(item["workdepttype"].ToString(), out workdepttype); DataRow newDr = excelTable.NewRow(); //搭设申请、拆除申请作业状态 if (state == 0) { newDr["applystatestr"] = "申请中"; } if (state == 1) { newDr["applystatestr"] = "审核(批)中"; } if (state == 2) { newDr["applystatestr"] = "审核(批)未通过"; } if (state == 3) { newDr["applystatestr"] = "审核(批)通过"; } if (workdepttype == 0) { newDr["workdepttypestr"] = "单位内部"; } else { newDr["workdepttypestr"] = "外包单位"; } newDr["applynumber"] = item["applynumber"]; newDr["workplace"] = item["workplace"]; newDr["workdeptname"] = item["workdeptname"]; DateTime applytime, workstartdate, workenddate; DateTime.TryParse(item["createdate"].ToString(), out applytime); DateTime.TryParse(item["workstarttime"].ToString(), out workstartdate); DateTime.TryParse(item["workendtime"].ToString(), out workenddate); newDr["worktime"] = workstartdate.ToString("yyyy-MM-dd HH:mm") + "-" + workenddate.ToString("yyyy-MM-dd HH:mm"); newDr["applyusername"] = item["applyusername"]; newDr["applytime"] = applytime.ToString("yyyy-MM-dd HH:mm"); excelTable.Rows.Add(newDr); } //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); excelconfig.Title = "消防水使用许可申请信息"; excelconfig.FileName = "消防水使用许可申请信息导出.xls"; excelconfig.TitleFont = "微软雅黑"; excelconfig.TitlePoint = 16; excelconfig.IsAllSizeColumn = true; List <ColumnEntity> listColumnEntity = new List <ColumnEntity>(); excelconfig.ColumnEntity = listColumnEntity; ColumnEntity columnentity = new ColumnEntity(); //需跟数据源列顺序保持一致 excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "applystatestr", ExcelColumn = "许可状态", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "applynumber", ExcelColumn = "申请编号", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "workdepttypestr", ExcelColumn = "使用消防水单位类别", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "workplace", ExcelColumn = "使用消防水地点", Width = 60 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "worktime", ExcelColumn = isHrdl == "true"? "使用消防水时间" : "计划使用消防水时间", Width = 40 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "workdeptname", ExcelColumn = "使用消防水单位", Width = 20 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "applyusername", ExcelColumn = "申请人", Width = 15 }); excelconfig.ColumnEntity.Add(new ColumnEntity() { Column = "applytime", ExcelColumn = "申请时间", Width = 20 }); //调用导出方法 ExcelHelper.ExcelDownload(excelTable, excelconfig); } catch (Exception ex) { } return(Success("导出成功。")); }