/// <summary> /// 获取应用数据 /// </summary> /// <param name="type">类别</param> /// <returns></returns> public List <ApplistItem> GetMApplist(string type) { List <ApplistItem> AP = new List <ApplistItem>(); string sql = ""; string appid = YZApp.App.GetAllAppId(""); if (string.IsNullOrEmpty(type)) { sql = " select VIEWTYPE,MAX(sort) as SORT from App_Index where Enable=1 and ID IN (" + appid + @") group by VIEWTYPE order by sort"; } else { sql = " select VIEWTYPE,MAX(sort) as SORT from App_Index where Enable=1 and ID IN (" + appid + @") and ViewType='" + type + "' group by VIEWTYPE order by sort"; } DataTable dt = DBUtil_APP.Query(sql).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { string GroupName = Convert.ToString(dt.Rows[i][0]); ApplistItem apl = new ApplistItem(); apl.GroupName = GroupName; List <AppItem> atl = new List <AppItem>(); string sql2 = " select AppName,AppUrl,Badge,Icon,IconColor,IconSize,Type,ID from App_Index where Enable=1 and ID IN (" + appid + @") and VIEWTYPE='" + GroupName + "' order by sort"; DataTable dt2 = DBUtil_APP.Query(sql2).Tables[0]; for (int j = 0; j < dt2.Rows.Count; j++) { AppItem at = new AppItem(); at.AppName = Convert.ToString(dt2.Rows[j][0]); //应用名称 at.AppUrl = Convert.ToString(dt2.Rows[j][1]); //应用路径 string Badgesql = Convert.ToString(dt2.Rows[j][2]); //角标sql if (Badgesql == "0" || Badgesql == "") { at.Badge = 0; } else { SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@Account", YZAuthHelper.LoginUserAccount) }; at.Badge = Convert.ToInt32(DBUtil_APP.GetSingle(Badgesql, paras)); } at.Icon = Convert.ToString(dt2.Rows[j][3]); //图标名称 at.IconColor = Convert.ToString(dt2.Rows[j][4]); //图标颜色 at.IconSize = Convert.ToString(dt2.Rows[j][5]); //图标大小 at.Type = Convert.ToString(dt2.Rows[j][6]); //图标类别 at.Json = Convert.ToString(DBUtil_APP.GetSingle("select JSON from APP_APPINFO where PID='" + Convert.ToString(dt2.Rows[j][7]) + "'")); atl.Add(at); } apl.App = atl; AP.Add(apl); } return(AP); }
public PushNoticeModule LoadNotice() { string sql = "select * from APP_NOTICE_CONFIG "; DataTable dt = DBUtil_APP.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { return(YZApp.DataTableToModel.ToSingleModel <PushNoticeModule>(dt)); } else { return(new PushNoticeModule()); } }
public OrgSyncInfoModule LoadOrgSyncConfig() { string sql = "select * from APP_ORGSYNC "; DataTable dt = DBUtil_APP.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { return(YZApp.DataTableToModel.ToSingleModel <OrgSyncInfoModule>(dt)); } else { return(new OrgSyncInfoModule()); } }
public LoginModule LoadLogin() { string sql = "select * from APP_LOGIN_CONFIG "; DataTable dt = DBUtil_APP.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { return(YZApp.DataTableToModel.ToSingleModel <LoginModule>(dt)); } else { return(new LoginModule()); } }
/// <summary> /// 读取应用 /// </summary> /// <param name="type">类别</param> public List <AppModule> GetApplist(string type) { string sql = ""; if (string.IsNullOrEmpty(type)) { sql = "select * from App_Index order by sort"; } else { sql = "select * from App_Index where ViewType='" + type + "' order by sort"; } DataTable dt = DBUtil_APP.Query(sql).Tables[0]; return(YZApp.DataTableToModel.ToListModel <AppModule>(dt)); }
/// <summary> /// 获取部门数据源 /// </summary> /// <param name="ParentOUID">根目录</param> /// <returns></returns> public static DataTable OUData() { DataTable dt = new DataTable(); try { string SQL = System.Web.HttpUtility.HtmlDecode(m.WxOuSql); dt = DBUtil_APP.Query(SQL).Tables[0]; } catch (Exception ex) { Res("获取部门数据源失败," + ex.Message); } return(dt); }
public static string GetAllAppId(string sid) { string appid = ""; if (string.IsNullOrEmpty(sid)) { using (BPMConnection cn = new BPMConnection()) { cn.WebOpen(); object[] groups = OrgManager.GetGroups(cn, YZAuthHelper.LoginUserAccount); ArrayList al = (ArrayList)JSON.Decode(JsonConvert.SerializeObject(groups)); for (int i = 0; i < al.Count; i++) { Hashtable ht = (Hashtable)al[i]; string sids = Convert.ToString(ht["SID"]); DataTable dt = DBUtil_APP.Query("select APPID from APP_APPAUTH where sid=" + sids + "").Tables[0]; for (int j = 0; j < dt.Rows.Count; j++) { appid += "'" + dt.Rows[j][0] + "',"; } } DataTable dtt = DBUtil_APP.Query("select APPID from APP_APPAUTH where sid='S_GS_90674E5E-AC3C-4032-9EDF-7477F2247542'").Tables[0]; for (int j = 0; j < dtt.Rows.Count; j++) { appid += "'" + dtt.Rows[j][0] + "',"; } } } else { DataTable dt = DBUtil_APP.Query("select APPID from APP_APPAUTH where sid=" + sid + "").Tables[0]; for (int j = 0; j < dt.Rows.Count; j++) { appid += "'" + dt.Rows[j][0] + "',"; } } if (!string.IsNullOrEmpty(appid)) { return(appid.Trim(',')); } else { return("'-1'"); } }
public List <SearchAppModule> SearchMApplist(string kwd) { string sql = ""; string appid = YZApp.App.GetAllAppId(""); if (string.IsNullOrEmpty(kwd)) { sql = @"select *,case when resID is not null then 'true' else 'false' end as Favorited from App_Index A LEFT JOIN YZSysFavorites B ON A.AppName=B.resID and resType='App' and uid='" + YZAuthHelper.LoginUserAccount + @"' LEFT JOIN APP_APPINFO C ON A.ID=C.PID where Enable=1 and A.ID IN (" + appid + @") and AppName is not null ORDER BY a.Sort"; } else { sql = @"select *,case when resID is not null then 'true' else 'false' end as Favorited from App_Index A LEFT JOIN YZSysFavorites B ON A.AppName=B.resID and resType='App' and uid='" + YZAuthHelper.LoginUserAccount + @"' LEFT JOIN APP_APPINFO C ON A.ID=C.PID where AppName like '%" + kwd + @"%' and Enable=1 and A.ID IN (" + appid + @") and AppName is not null ORDER BY a.Sort"; } DataTable dt = DBUtil_APP.Query(sql).Tables[0]; return(YZApp.DataTableToModel.ToListModel <SearchAppModule>(dt)); }
public List <AppModule> GetMFavorite() { string appid = YZApp.App.GetAllAppId(""); string sql = "select * from YZSysFavorites A LEFT JOIN App_Index B ON A.resID=B.AppName LEFT JOIN APP_APPINFO C ON B.ID=C.PID where Enable=1 and B.ID IN (" + appid + @") and resType='App' and a.uid='" + YZAuthHelper.LoginUserAccount + "' and AppName is not null ORDER BY orderIndex"; DataTable dt = DBUtil_APP.Query(sql).Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { int Badge = 0; string Badgesql = Convert.ToString(dt.Rows[i]["BADGE"]);//角标sql if (Badgesql != "0" && Badgesql != "") { SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@Account", YZAuthHelper.LoginUserAccount) }; Badge = Convert.ToInt32(DBUtil_APP.GetSingle(Badgesql, paras)); } dt.Rows[i]["BADGE"] = Badge; } return(YZApp.DataTableToModel.ToListModel <AppModule>(dt)); }
public AppInfoModule LoadAppInfo(string pid) { string sql = @"select * from APP_APPINFO where PID='" + pid + "' "; if (DBUtil_APP.Exists("select count(*) from APP_APPINFO where PID='" + pid + "' ")) { DataTable dt = DBUtil_APP.Query(sql).Tables[0]; if (dt.Rows.Count > 0) { return(YZApp.DataTableToModel.ToSingleModel <AppInfoModule>(dt)); } else { return(new AppInfoModule()); } } else { return(new AppInfoModule()); } }
public void Send(string address, string title, string message, JToken jtExtra, NotifyAttachmentCollection attachments) { try { string path = "Server.config"; XmlDocument xmlDocument = new XmlDocument(); MemoryStream inStream = new MemoryStream(File.ReadAllBytes(path)); xmlDocument.Load(inStream); XmlNode xmlNode = xmlDocument.SelectSingleNode("//database"); string innerText = xmlNode.SelectSingleNode("Server").InnerText; string innerText2 = xmlNode.SelectSingleNode("Database").InnerText; string innerText3 = xmlNode.SelectSingleNode("Uid").InnerText; string innerText4 = xmlNode.SelectSingleNode("Password").InnerText; string connectionString = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3}", new object[] { innerText, innerText2, innerText3, innerText4 }); DBUtil_APP.connectionString = connectionString; string sql = "Select DDID,DDAGENTID,DDSECRET,DDPUSHURL,DDLINKSQL from APP_NOTICE_CONFIG"; DataTable dt = DBUtil_APP.Query(sql).Tables[0]; if (dt.Rows.Count == 0) { throw new Exception("钉钉推送参数为空!"); } string CropId = Convert.ToString(dt.Rows[0][0]); string Secret = Convert.ToString(dt.Rows[0][2]); string AgentId = Convert.ToString(dt.Rows[0][1]); //string EMIPSiteUrl = Convert.ToString(dt.Rows[0][3]); string accessToken = DingTalkManager.Instance.GetAccessToken(CropId, Secret); WebClient webClient = new WebClient(); webClient.Encoding = Encoding.UTF8; webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json"); webClient.Headers.Add(HttpRequestHeader.KeepAlive, "false"); UrlBuilder urlBuilder = new UrlBuilder("https://oapi.dingtalk.com/message/send"); urlBuilder.QueryString["access_token"] = accessToken; JObject jObject = jtExtra as JObject; object o; string DDLINKSQL = Convert.ToString(dt.Rows[0][4]); if (!string.IsNullOrEmpty(DDLINKSQL)) { string sql2 = string.Format(DDLINKSQL, address); address = Convert.ToString(DBUtil_APP.GetSingle(sql2)); } if (string.IsNullOrEmpty(Server.EMIPSiteUrl) || jObject == null) { o = new { touser = address, toparty = "", agentid = AgentId, msgtype = "text", text = new { content = (title + "\n" + message).Replace("<br/>", "\n") } }; } else { if (string.IsNullOrEmpty(title)) { throw new Exception("title不能为null、不能为空字符串"); } if (string.IsNullOrEmpty(message)) { throw new Exception("message不能为null、不能为空字符串"); } if (string.IsNullOrEmpty(Server.EMIPSiteUrl)) { throw new BPMException(BPMExceptionType.MissEMIPSiteUrlSetting, new object[0]); } UrlBuilder urlBuilder2 = new UrlBuilder(Server.EMIPSiteUrl + "dingtalk.aspx"); string a = (string)jObject["Type"]; if (!(a == "Task.Process")) { if (a == "Task.Read") { urlBuilder2.QueryString["app"] = "openTask"; urlBuilder2.QueryString["tid"] = ((int)jObject["TaskID"]).ToString(); } } else { urlBuilder2.QueryString["app"] = "process"; urlBuilder2.QueryString["pid"] = ((int)jObject["StepID"]).ToString(); } o = new { touser = address, toparty = "", totag = "", msgtype = "action_card", agentid = AgentId, action_card = new { title = title, markdown = "### " + title + " \n" + message.Replace("<br/>", " \n"), single_title = "查看详情", single_url = urlBuilder2.ToString() } }; } JObject jObject2 = JObject.FromObject(o); byte[] bytes = webClient.UploadData(urlBuilder.ToString(), "POST", Encoding.UTF8.GetBytes(jObject2.ToString())); JObject jObject3 = JObject.Parse(Encoding.UTF8.GetString(bytes)); if ((int)jObject3["errcode"] != 0) { throw new Exception((string)jObject3["errmsg"]); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 获取人员数据源 /// </summary> /// <returns></returns> public static DataTable GetUserData() { string sql = UserSQL; return(DBUtil_APP.Query(sql).Tables[0]); }
/// <summary> /// 获取部门数据源 /// </summary> /// <returns></returns> public static DataTable GetDepData() { string sql = DeptSQL; return(DBUtil_APP.Query(sql).Tables[0]); }