/// <summary> /// 用户登录 /// </summary> /// <param name="icommon"></param> /// <param name="mobile"></param> /// <param name="pwdcode"></param> /// <param name="wxopenid"></param> /// <returns></returns> public static Wlniao.ApiResult <String> Login(xCommon icommon, String mobile, String pwdcode, String wxopenid = "") { return(icommon.Get <String>("app", "login" , new KeyValuePair <string, string>("mobile", mobile) , new KeyValuePair <string, string>("pwdcode", pwdcode) , new KeyValuePair <string, string>("wxopenid", wxopenid))); }
/// <summary> /// 获取钉钉AccessToken /// </summary> /// <param name="com"></param> /// <returns></returns> public static Wlniao.ApiResult <String> GetToken(xCommon com) { if (com == null) { return(null); } return(com.Get <String>("app", "dingtalk_token")); }
/// <summary> /// 获取用户账号 /// </summary> /// <param name="xcommon"></param> /// <param name="sid"></param> /// <returns></returns> public static String GetUid(xCommon xcommon, String sid) { if (string.IsNullOrEmpty(sid) || xcommon == null) { return(""); } var user = Get(xcommon, sid, "sid"); return(user == null ? "" : user.account); }
/// <summary> /// 获取机构列表 /// </summary> /// <param name="icommon"></param> /// <returns></returns> public static List <Organ> GetList(xCommon icommon) { var rlt = icommon.Get <List <Organ> >("app", "getorganlist"); if (rlt.success && rlt.data != null) { return(rlt.data); } return(new List <Organ>()); }
/// <summary> /// 钉钉待办任务更新 /// </summary> /// <param name="com"></param> /// <param name="userid"></param> /// <param name="record_id"></param> /// <returns></returns> public static Wlniao.ApiResult <String> WorkrecordUpdate(xCommon com, String userid, String record_id) { if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(record_id) || com == null) { return(null); } var json = Newtonsoft.Json.JsonConvert.SerializeObject(new { userid, record_id }); return(com.Post <String>("app", "dingtalk_workrecord_update", json)); }
/// <summary> /// 根据用户权限获取机构列表 /// </summary> /// <param name="icommon"></param> /// <param name="sid"></param> /// <returns></returns> public static List <Organ> GetList(xCommon icommon, String sid) { var rlt = icommon.Get <List <Organ> >("app", "getorganlist", new KeyValuePair <string, string>("sid", sid)); if (rlt.success && rlt.data != null) { return(rlt.data); } return(new List <Organ>()); }
/// <summary> /// 根据类型获取枚举列表 /// </summary> /// <param name="icommon"></param> /// <param name="parent"></param> /// <returns></returns> public static List <Enum> GetList(xCommon icommon, String parent) { var rlt = icommon.Get <List <Enum> >("app", "getenumlist", new KeyValuePair <string, string>("parent", parent)); if (rlt.success && rlt.data != null) { return(rlt.data); } return(new List <Enum>()); }
/// <summary> /// 获取一个用户信息 /// </summary> /// <param name="xcommon"></param> /// <param name="key"></param> /// <param name="by"></param> /// <returns></returns> public static User Get(xCommon xcommon, String key, String by = "sid") { if (string.IsNullOrEmpty(key) || xcommon == null) { return(null); } var rlt = xcommon.Get <User>("app", "getaccount", new KeyValuePair <string, string>(by, key)); if (rlt.success) { return(rlt.data); } return(null); }
/// <summary> /// 获取一个枚举类型 /// </summary> /// <param name="icommon"></param> /// <param name="key"></param> /// <returns></returns> public static Enum Get(xCommon icommon, String key) { if (string.IsNullOrEmpty(key) || icommon == null) { return(null); } var rlt = icommon.Get <Enum>("app", "getenum", new KeyValuePair <string, string>("key", key)); if (rlt.success) { return(rlt.data); } return(null); }
/// <summary> /// 获取一个机构信息 /// </summary> /// <param name="icommon"></param> /// <param name="id"></param> /// <returns></returns> public static String GetName(xCommon icommon, String id) { if (string.IsNullOrEmpty(id) || icommon == null) { return(""); } var rlt = icommon.Get <Organ>("app", "getorgan", new KeyValuePair <string, string>("id", id)); if (rlt.success) { return(rlt.data.name); } return(""); }
/// <summary> /// 获取一个账号信息 /// </summary> /// <param name="com"></param> /// <param name="key"></param> /// <param name="by"></param> /// <returns></returns> public static Account Get(xCommon com, String key, String by = "sid") { if (string.IsNullOrEmpty(key) || com == null) { return(null); } var rlt = com.Get <Account>("app", "getaccount", new KeyValuePair <string, string>(by, key)); if (rlt.success) { return(rlt.data); } return(null); }
/// <summary> /// 钉钉待办任务推送 /// </summary> /// <param name="com"></param> /// <param name="to">Sid或手机号</param> /// <param name="title"></param> /// <param name="url"></param> /// <param name="exdata"></param> /// <returns></returns> public static Wlniao.ApiResult <String> WorkrecordAdd(xCommon com, String to, String title, String url, List <FormItemVo> exdata) { if (string.IsNullOrEmpty(to) || com == null) { return(null); } var json = Newtonsoft.Json.JsonConvert.SerializeObject(new { by = Wlniao.strUtil.IsMobile(to) ? "mobile" : "sid", exdata = Newtonsoft.Json.JsonConvert.SerializeObject(exdata), mobile = to, sid = to, title, url }); return(com.Post <String>("app", "dingtalk_workrecord_add", json)); }
/// <summary> /// /// </summary> /// <param name="com"></param> /// <param name="key"></param> public WSession(xCommon com, String key) { this.key = key; if (com != null && !string.IsNullOrEmpty(key)) { var jsonStr = com.Get("app", "wsession", new KeyValuePair <string, string>("key", key)); var jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(jsonStr); if (jsonObj.success.ToString().ToLower() == "true") { this.sid = jsonObj.sid; this.wkey = jsonObj.wkey; this.name = jsonObj.name; this.account = jsonObj.account; this.platform = jsonObj.platform; this.platformId = jsonObj.platformId; this.login = true; } } }
/// <summary> /// 页面加载前事件 /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { #region 解析请求Session var key = ""; var xhost = GetCookies("xhost"); if (Request.Query.Keys.Contains("xhost")) { xhost = GetRequestNoSecurity("xhost"); Response.Cookies.Append("xhost", xhost); } com = xCommon.Create(xhost); if (Request.Query.Keys.Contains("wsession")) { key = GetRequestNoSecurity("wsession"); Response.Cookies.Append("wsession", key); } else { key = GetCookies("wsession"); } wsession = new WSession(com, key); if (wsession.login) { ViewBag.iHost = string.IsNullOrEmpty(xhost) ? "" : (xhost.IndexOf("://") > 0 ? xhost : "//" + xhost); base.OnActionExecuting(filterContext); } else { errorMsg = "您的访问已失效,请重新登录"; if (com != null && !string.IsNullOrEmpty(com.Message)) { errorMsg = com.Message; } var errorPage = new ContentResult(); errorPage.ContentType = "text/html;charset=utf-8"; errorPage.Content = errorHtml.Replace("{{errorMsg}}", errorMsg).Replace("{{errorTitle}}", errorTitle).Replace("{{errorIcon}}", errorIcon); filterContext.Result = errorPage; } #endregion }
/// <summary> /// 获取一个账号信息 /// </summary> /// <param name="com"></param> /// <param name="sid"></param> /// <returns></returns> public static String GetName(xCommon com, String sid) { if (string.IsNullOrEmpty(sid) || com == null) { return(""); } var val = Wlniao.Cache.Get("sidname-" + com.Host + "-" + sid); if (string.IsNullOrEmpty(val)) { var rlt = com.Get <Account>("app", "getaccount", new KeyValuePair <string, string>("sid", sid)); if (rlt.success && !string.IsNullOrEmpty(rlt.data.name)) { val = rlt.data.name; Wlniao.Cache.Set("sidname-" + com.Host + "-" + sid, val, 3600); } else { val = ""; } } return(val); }
/// <summary> /// 获取一个枚举类型 /// </summary> /// <param name="icommon"></param> /// <param name="key"></param> /// <returns></returns> public static String GetName(xCommon icommon, String key) { if (string.IsNullOrEmpty(key) || icommon == null) { return(""); } var val = Wlniao.Cache.Get("enumname-" + icommon.Host + "-" + key); if (string.IsNullOrEmpty(val)) { var rlt = icommon.Get <Enum>("app", "getenum", new KeyValuePair <string, string>("key", key)); if (rlt.success && !string.IsNullOrEmpty(rlt.data.label)) { val = rlt.data.label; Wlniao.Cache.Set("enumname-" + icommon.Host + "-" + key, val, 3600); } else { val = key; } } return(val); }
/// <summary> /// 获取用户姓名 /// </summary> /// <param name="xcommon"></param> /// <param name="sid"></param> /// <returns></returns> public static String GetName(xCommon xcommon, String sid) { if (string.IsNullOrEmpty(sid) || xcommon == null) { return(""); } var val = Wlniao.Cache.Get("username-" + xcommon.Host + "-" + sid); if (string.IsNullOrEmpty(val)) { var user = Get(xcommon, sid, "sid"); if (user != null && !string.IsNullOrEmpty(user.name)) { val = user.name; Wlniao.Cache.Set("username-" + xcommon.Host + "-" + sid, val, 3600); } else { val = ""; } } return(val); }
/// <summary> /// 根据微信OpenId获取 /// </summary> /// <param name="xcommon"></param> /// <param name="wxopenid"></param> /// <returns></returns> public static User GetByOpenId(xCommon xcommon, String wxopenid) { return(Get(xcommon, wxopenid, "wxopenid")); }
/// <summary> /// 根据微信OpenId获取 /// </summary> /// <param name="com"></param> /// <param name="wxopenid"></param> /// <returns></returns> public static Account GetByOpenId(xCommon com, String wxopenid) { return(Get(com, wxopenid, "wxopenid")); }
/// <summary> /// 根据手机号获取 /// </summary> /// <param name="xcommon"></param> /// <param name="mobile"></param> /// <returns></returns> public static User GetByMobile(xCommon xcommon, String mobile) { return(Get(xcommon, mobile, "mobile")); }