public void AddMFavorite(string resID) { string sql = "select * from YZSysFavorites where uid='" + YZAuthHelper.LoginUserAccount + "' and resid='" + resID + "' and resType='App'"; if (!DBUtil_APP.Exists(sql)) { string sql3 = "select max(ORDERINDEX) from YZSysFavorites where uid='" + YZAuthHelper.LoginUserAccount + "' and resType='App'"; int ORDERINDEX = Convert.ToInt32(DBUtil_APP.GetSingle(sql3)) + 1; string sql2 = string.Format(@"INSERT INTO [YZSysFavorites] ( [UID] ,[RESTYPE] ,[RESID] ,[DATE] ,[COMMENTS] ,[ORDERINDEX] ) VALUES ('{0}' ,'{1}' ,'{2}' ,'{3}' ,'{4}' ,'{5}')", YZAuthHelper.LoginUserAccount, "App", resID, DateTime.Now.ToString(), "", ORDERINDEX); DBUtil_APP.ExecuteSqlWithGoUseTran(sql2); } }
/// <summary> ///获取父级ID /// </summary> /// <returns></returns> public static string GETParentID(string id) { if (id == "1") { return("1"); } else { string sql = @"select DDID from APP_ORGSYNC_DEPTBPM2DD WHERE OUID='" + id + "';"; return(Convert.ToString(DBUtil_APP.GetSingle(sql))); } }
/// <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 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 virtual JObject DingTalkLogin(HttpContext context) { YZRequest request = new YZRequest(context); string code = request.GetString("code"); string corpId = request.GetString("corpId"); string appSecret = request.GetString("appSecret"); string lang = request.GetString("lang", "zh-chs"); string accesstoken = DingTalkManager.Instance.GetAccessToken(corpId, appSecret); string uid = DingTalkManager.Instance.TryGetUserIdFromCode(accesstoken, code); string regularAccount = null; string linsql = ""; using (IYZAppAdminProvider applogin = IYZAppAdminProviderManager.DefaultProvider) { YZAppAdmin.LoginModule lm = applogin.LoadLogin(); linsql = lm.DdLinkSql; } if (!string.IsNullOrEmpty(linsql)) { string sql = string.Format(linsql, uid); uid = Convert.ToString(DBUtil_APP.GetSingle(sql)); } using (BPMConnection cn = new BPMConnection()) { cn.WebOpenAnonymous(); if (!User.IsAccountExist(cn, uid, ref regularAccount)) { throw new Exception(String.Format("当前钉钉登录用户{0},不是有效的BPM账号!", uid)); } YZAuthHelper.SetAuthCookie(regularAccount); } YZAuthHelper.SetLangSession(YZCultureInfoParse.Parse(lang, YZCultureInfoParse.DefauleCultureInfo).LCID); JObject rv = this.GenLoginResult(regularAccount, false); return(rv); }
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); } }
protected void Page_Load(object sender, EventArgs e) { string code = this.Request.Params["code"]; string app = this.Request.Params["app"]; string linsql = ""; using (IYZAppAdminProvider applogin = IYZAppAdminProviderManager.DefaultProvider) { YZAppAdmin.LoginModule lm = applogin.LoadLogin(); if (lm.WxLogin != "1") { this.Response.Clear(); this.Response.Write("<script>alert('未开启微信登陆')</script>"); return; } wechat.corpId = lm.WxId; wechat.agentId = lm.WxAgentId; wechat.secret = lm.WxSecret; linsql = lm.WxLinkSql; } if (String.IsNullOrEmpty(app)) { app = "main"; } if (String.IsNullOrEmpty(code)) { YZUrlBuilder uri = new YZUrlBuilder("https://open.weixin.qq.com/connect/oauth2/authorize"); uri.QueryString["appid"] = wechat.corpId; uri.QueryString["response_type"] = "code"; uri.QueryString["redirect_uri"] = this.Request.Url.ToString(); uri.QueryString["scope"] = "SCOPE"; uri.QueryString["state"] = "STATE#wechat_redirect"; this.Response.Redirect(uri.ToString()); } else { try { JObject jApp = jApps[app] as JObject; string accesstoken = WeChatManager.Instance.GetAccessToken(wechat.corpId, wechat.secret); string userid = WeChatManager.Instance.TryGetUserIdFromCode(accesstoken, code); string ticket = WeChatManager.Instance.GetJSapiTicket(accesstoken); string timeStamp = WeChatManager.Instance.GetTimeStamp(); string nonceStr = YZSecurityHelper.SecurityKey; string url = this.Request.Url.ToString(); string signature = WeChatManager.Instance.GenSigurate(nonceStr, timeStamp, ticket, url); if (String.IsNullOrEmpty(userid)) { throw new Exception("非企业号用户!"); } if (!string.IsNullOrEmpty(linsql)) { string sql = string.Format(linsql, userid); userid = Convert.ToString(DBUtil_APP.GetSingle(sql)); } using (BPMConnection cn = new BPMConnection()) { cn.WebOpenAnonymous(); string regularAccount = null; if (!BPM.Client.User.IsAccountExist(cn, userid, ref regularAccount)) { throw new Exception(String.Format("当前企业号登录用户{0},不是有效的BPM账号!", userid)); } YZAuthHelper.SetAuthCookie(regularAccount); this.Title = (string)jApp["title"]; JObject jAppResult = new JObject(); jAppResult["app"] = app; jAppResult["agentId"] = wechat.agentId; jAppResult["secret"] = wechat.secret; jAppResult["title"] = jApp["title"]; jAppResult["corpId"] = corpId; jAppResult["timeStamp"] = timeStamp; jAppResult["nonceStr"] = nonceStr; jAppResult["signature"] = signature; jAppResult["jsApiList"] = jApp["jsApiList"]; jAppResult["xclass"] = jApp["xclass"]; JObject jConfig = jApp["config"] == null ? new JObject() : JObject.FromObject(jApp["config"]); jAppResult["config"] = jConfig; foreach (string key in this.Request.QueryString.Keys) { jConfig[key] = this.Request.QueryString[key]; } this._litApp.Text = jAppResult.ToString(Formatting.Indented, YZJsonHelper.Converters); } } catch (Exception exp) { if (exp.Message.Contains("query?e=40029")) { YZUrlBuilder uri = new YZUrlBuilder("https://open.weixin.qq.com/connect/oauth2/authorize"); uri.QueryString["appid"] = wechat.corpId; uri.QueryString["response_type"] = "code"; string url = this.Request.Url.ToString(); int code2 = url.IndexOf("code"); url = url.Substring(0, code2 - 1); uri.QueryString["redirect_uri"] = url; uri.QueryString["scope"] = "SCOPE"; uri.QueryString["state"] = "STATE#wechat_redirect"; this.Response.Redirect(uri.ToString()); } else { this.Response.Redirect("~/YZSoft/assist/AspxError/default.aspx?err=" + HttpUtility.UrlEncode(exp.Message)); } } } }