|
|
using BP.Cloud.WeXinAPI;
|
|
|
using BP.DA;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Web;
|
|
|
using System.Web.UI;
|
|
|
using System.Web.UI.WebControls;
|
|
|
using BP.WF;
|
|
|
using BP.Sys;
|
|
|
using BP.WF.WeiXin;
|
|
|
using BP.DA;
|
|
|
using BP.Web;
|
|
|
|
|
|
namespace CCFlow.App.Portal
|
|
|
{
|
|
|
|
|
|
public partial class GuideWeiXin : System.Web.UI.Page
|
|
|
{
|
|
|
public string GetVal(string key)
|
|
|
{
|
|
|
string val = this.Request.QueryString[key];
|
|
|
return BP.Tools.DealString.DealStr(val);
|
|
|
}
|
|
|
public void OpenUrlByWeb()
|
|
|
{
|
|
|
// SystemConfig.AppCenterDBCapitalAndSmallLetterModel
|
|
|
Int64 workid = Int64.Parse(this.GetVal("WorkID"));
|
|
|
string empNo = this.GetVal("EmpNo");
|
|
|
BP.WF.GenerWorkFlow gwf = new BP.WF.GenerWorkFlow(workid);
|
|
|
|
|
|
BP.WF.GenerWorkerList gwl = new BP.WF.GenerWorkerList();
|
|
|
var i = gwl.Retrieve(GenerWorkerListAttr.WorkID, workid, GenerWorkerListAttr.FK_Emp, empNo,
|
|
|
GenerWorkerListAttr.IsPass, 0);
|
|
|
if (i == 0)
|
|
|
{
|
|
|
this.Response.Write("<h3>工作已经处理或者已经失效.</h3>");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
BP.Cloud.Emp emp = new BP.Cloud.Emp(gwf.OrgNo + "_" + gwl.FK_Emp);
|
|
|
|
|
|
//执行登录.
|
|
|
BP.Cloud.Dev2Interface.Port_Login(emp);
|
|
|
|
|
|
string url = "";
|
|
|
if (this.IsMobile == false)
|
|
|
url = "/WF/MyFlow.htm?WorkID=" + workid + "&FK_Flow=" + this.GetVal("FK_Flow");
|
|
|
else
|
|
|
url = "/CCMobile/MyFlow.htm?WorkID=" + workid + "&FK_Flow=" + this.GetVal("FK_Flow");
|
|
|
|
|
|
this.Response.Redirect(url, true);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//httppost请求
|
|
|
BP.WF.HttpWebResponseUtility httpWebResponseUtility = new BP.WF.HttpWebResponseUtility();
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
string orgNo = this.GetVal("OrgNo");
|
|
|
if (DataType.IsNullOrEmpty(orgNo) == false)
|
|
|
{
|
|
|
BP.Cloud.Org org = new BP.Cloud.Org(orgNo);
|
|
|
if (org.RegFrom != 1)
|
|
|
{
|
|
|
OpenUrlByWeb();
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#region 构造企业oauth2链接,如果企业需要在打开的网页里面携带用户的身份信息,第一步需要构造如下的链接来获取code参数
|
|
|
// https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect
|
|
|
//员工点击后,页面将跳转至 redirect_uri?code=CODE&state=STATE,企业可根据code参数获得员工的userid。code长度最大为512字节。
|
|
|
|
|
|
string redirect_uri = BP.Cloud.WeXinAPI.Glo.Domain + "App/Portal/DirectWeiXin.aspx";
|
|
|
string doType = this.GetVal("DoType");
|
|
|
if (DataType.IsNullOrEmpty(doType) == false)
|
|
|
{
|
|
|
redirect_uri += "?DoType=" + doType;
|
|
|
redirect_uri += "&WorkID=" + this.GetVal("WorkID");
|
|
|
redirect_uri += "&FK_Flow=" + this.GetVal("FK_Flow");
|
|
|
redirect_uri += "&GUID=" + this.GetVal("GUID");
|
|
|
|
|
|
//if (BP.Difference.SystemConfig.CustomerNo.Equals("ALLMED") == true)
|
|
|
//{
|
|
|
// Int64 workid = Int64.Parse(this.GetVal("WorkID"]);
|
|
|
|
|
|
// string empNo = this.GetVal("EmpNo");
|
|
|
// BP.WF.GenerWorkFlow gwf = new BP.WF.GenerWorkFlow(workid);
|
|
|
|
|
|
// BP.WF.GenerWorkerList gwl = new BP.WF.GenerWorkerList();
|
|
|
// var i = gwl.Retrieve(GenerWorkerListAttr.WorkID, workid, GenerWorkerListAttr.FK_Emp, empNo,
|
|
|
// GenerWorkerListAttr.IsPass, 0);
|
|
|
|
|
|
// if (i == 0)
|
|
|
// {
|
|
|
// this.Response.Write("<h3>工作已经处理或者已经失效.</h3>");
|
|
|
// return;
|
|
|
// }
|
|
|
|
|
|
// BP.Cloud.Emp emp = new BP.Cloud.Emp(gwf.OrgNo + "_" + gwl.FK_Emp);
|
|
|
|
|
|
// //执行登录.
|
|
|
// BP.Cloud.Dev2Interface.Port_Login(emp, false);
|
|
|
// string url = "/WF/MyFlow.htm?WorkID=" + workid + "&FK_Flow=" + this.GetVal("FK_Flow");
|
|
|
// this.Response.Redirect(url, true);
|
|
|
// return;
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
//处理字符串.
|
|
|
redirect_uri = HttpUtility.UrlEncode(redirect_uri);
|
|
|
|
|
|
string oatuth2 = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + BP.Cloud.WeXinAPI.Glo.SuiteID + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_base&state=zA#wechat_redirect";
|
|
|
this.Response.Redirect(oatuth2, true);
|
|
|
/* httpWebResponseUtility.HttpResponseGet(oatuth2);
|
|
|
BP.DA.DataType.ReadURLContext(oatuth2);*/
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
|
|
|
public bool IsMobile
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
bool isMobile = IsMobileUrl(Request.UserAgent);
|
|
|
if (isMobile)
|
|
|
return true;
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public string[] mobileTag = { "iphone", "ios", "ipad", "android", "mobile" };
|
|
|
/// <summary>
|
|
|
/// 判断是否是手机打开
|
|
|
/// </summary>
|
|
|
/// <param name="userAgent">用户浏览器代理信息</param>
|
|
|
/// <returns></returns>
|
|
|
public bool IsMobileUrl(string userAgent)
|
|
|
{
|
|
|
bool result = false;
|
|
|
userAgent = userAgent.ToLower();
|
|
|
foreach (string sTmp in mobileTag)
|
|
|
{
|
|
|
if (userAgent.Contains(sTmp))
|
|
|
{
|
|
|
result = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |