public InvokeResult PushJuDouMsg(JudouDevice judouDevice) { InvokeResult result = new InvokeResult { Success = true }; if (!string.IsNullOrEmpty(judouDevice.RemoteUrl)) { try { HttpAdapter.postSyncAsJSON(judouDevice.RemoteUrl, judouDevice.ToStringObjectDictionary(), (ret, res) => { if (string.IsNullOrEmpty((string)ret)) { result.Success = false; result.ErrorMessage = (string)ret; } }); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.ToString(); } } return(result); }
private void OnIgnoreReminderInfo(WorkOrderReminderInfo item) { //string url = item.AccessPoint.Replace("http://115.236.175.110:17001/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Pub/ReminderService/IgnoreReminder"; HttpAdapter.postAsyncAsJSON(item.AccessPoint + "/Pub/ReminderService/IgnoreReminder", new { ResponseAppType = "00001", ObjectType = "Merchant", ObjectKey = item.StationId, SourceTable = "Oca_ServiceWorkOrder", SourceColumn = "WorkOrderId", SourceType = item.SourceType, SourceKey = item.SourceKey }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = item.StationId }.ToStringObjectDictionary(), (ret, res) => { }); }
private void SendMsg() { string content = rtxtInputBox.Text.Trim(); if (content == "") { MessageBoxAdapter.ShowInfo("发送内容不能为空,请重新输入"); rtxtInputBox.Text = ""; return; } string openId = this.Name; string url = TheMotherWin.WeiXinOfServiceOnlineInovkeAddress + "/api/share/v1/SendWXMessage"; string payLoad = new WXRequestTextMessage { touser = openId, msgtype = WXRequestMessageType.text.ToString(), text = new WXTextMessageWrapper { content = content } }.ToJson(); HttpAdapter.postAsyncStr(url, payLoad, (ret1, res1) => { webBrowser.Document.InvokeScript("sendMsg", new object[] { content }); rtxtInputBox.Text = ""; }, (he) => { MessageBoxAdapter.ShowInfo("发送失败:" + he.Message); }); }
public InvokeResult IpccRECManage(RECData recdata) { InvokeResult result = new InvokeResult { Success = true }; if (!string.IsNullOrEmpty(recdata.RemoteUrl)) { try { HttpAdapter.postSyncAsJSON(recdata.RemoteUrl, recdata.ToStringObjectDictionary(), (ret, res) => { if (!string.IsNullOrEmpty((string)ret)) { result.Success = false; result.ErrorMessage = (string)ret; } }); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.ToString(); } } return(result); }
/// <summary> /// Constructor. Here, we initialize all class' properties using default values. /// </summary> public CoExpRepository(IHostingEnvironment hostingEnvironment) { _adapter = new HttpAdapter(); ProductionEnv = "https://rytenlab.com/rytenlab_api/Coexp/"; TestEnv = "https://rytenlab.com/api_test/"; PrivateEnv = "https://rytenlab.com/api_private/"; DockerEnv = "http://rcoexp:8800/"; PostData = null; if (hostingEnvironment.EnvironmentName == "Production") { coexpURL = ProductionEnv; } else if (hostingEnvironment.EnvironmentName == "Development") { coexpURL = TestEnv; } else if (hostingEnvironment.EnvironmentName == "Docker") { coexpURL = DockerEnv; } else if (hostingEnvironment.EnvironmentName == "Private") { coexpURL = PrivateEnv; } }
private void FetchAccessPoints(Action success) { sendReminderUrl = INIAdapter.ReadValue(Common.INI_SECTION_WEB, Common.INI_KEY_SEND_REMINDER_POINT, Common.INI_FILE_PATH); strRunMode = INIAdapter.ReadValue(Common.INI_SECTION_SYSTEM, Common.INI_KEY_RUN_MODE, Common.INI_FILE_PATH); string authEndPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_END_POINT, Common.CFG_FILE_PATH); //异步认证 byte runMode = byte.Parse(strRunMode);//测试1 正式0 HttpAdapter.postAsyncAsJSON(authEndPoint, new { RunMode = runMode }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { foreach (var accessPoint in ret.ret.AccessPoints) { accessPointParts.Add(new AccessPointPart { ObjectId = accessPoint.ObjectId.ToString(), Url = accessPoint.Url.ToString() }); } if (success != null) { success(); } } else { MessageBoxAdapter.ShowError(ret.ErrorMessage); } }); }
public Stream IpccSpeechTemplateList(SpeechTemplate speechtemplate) { InvokeResult <string> result = new InvokeResult <string> { Success = true }; if (!string.IsNullOrEmpty(speechtemplate.RemoteUrl)) { try { HttpAdapter.postSyncAsJSON(speechtemplate.RemoteUrl, new { orgNo = speechtemplate.OrgCode }.ToStringObjectDictionary(), (ret, res) => { if (speechtemplate.RetType == "json") { result.ret = JsonConvert.DeserializeObject(ret).ToString(); } else { result.ret = ret.ToString(); } }); } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.ToString(); } } byte[] resultBytes = Encoding.UTF8.GetBytes(result.ToJson()); WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return(new MemoryStream(resultBytes)); }
private void btnOk_Click(object sender, EventArgs e) { string authEndPoint = formatEndPoint(txtAuthEndPoint.Text.Trim()); string smsEndPoint = formatEndPoint(txtSmsEndPoint.Text.Trim()); string ismgEndPoint = formatEndPoint(txtISMGEndPoint.Text.Trim()); string connectUrl = authEndPoint + "/"; HttpAdapter.optionsAsyncTo(connectUrl, new { ApplicationId = "CS001" }.ToStringObjectDictionary(), (ret, res) => { if (ret != "ok") { MessageBoxAdapter.ShowError("无效的认证节点"); return; } if (SectionSettingsSave != null) { SectionSettingsSave(this, new SectionSettingsSaveEventArgs { AuthEndPoint = authEndPoint, SmsEndPoint = smsEndPoint, IsmgEndPoint = ismgEndPoint }); } this.DialogResult = DialogResult.OK; this.UIInvoke(() => { this.Close(); }); }); }
public static void Load(dynamic gov) { UserName = gov.UserName; CityId = gov.CityId; CityCode = gov.CityCode; CityName = gov.CityName; Area1 = gov.Area1; AreaCode1 = gov.AreaCode1; AreaName1 = gov.AreaName1; AccessPoint = gov.AccessPoint; AccessOfProvice = gov.AccessOfProvice; DataPointOfManage = gov.DataPointOfManage; AuthorizedModules = new List <dynamic>(); for (int i = 0; i < gov.AuthorizedModules.Count; i++) { AuthorizedModules.Add(gov.AuthorizedModules[i]); } HttpAdapter.getSyncTo(GovVar.DataPointOfManage + "/Sys/DatabaseConnectService/GetConnectId/" + GovVar.CityCode, (ret, res) => { if ((bool)ret.Success && ret.rows.Count > 0) { ConnectId = ret.rows[0].ConnectId.Value; } }); }
private void FetchBookMeal(Button btn) { string mealType = btn.Name.Substring(btn.Name.Length - 5); string setMealId = btn.Tag as string; HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PAFetchBookMeal", new { OldManId = _OldManId.ToGuid(), MealType = mealType, SetMealId = setMealId, OperatedBy = Data.UserId }.ToStringObjectDictionary(), new { PACode = SettingsVar.BindingPACode, ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { MessageBoxAdapter.ShowInfo("领取配餐成功"); BookMealInfo bookMealInfo = Data.BookMeals.Single(item => item.OldManId == _OldManId && item.MealType == mealType && item.SetMealId == setMealId); bookMealInfo.FetchFlag = "1"; if (Common.isInExhibition) { btn.ForeColor = SystemColors.ControlText; btn.Enabled = true; btn.Text = "循环使用"; } else { btn.ForeColor = SystemColors.ControlLight; btn.Enabled = false; btn.Text = "确认领餐"; } } else { MessageBoxAdapter.ShowError((string)ret.ErrorMessage); } }); }
private void getData() { if (residentBaseInfos == null) { residentBaseInfos = new List <ResidentBaseInfo>(); } else { residentBaseInfos.Clear(); } StringObjectDictionary param = new { OrderByClause = " OperatedOn desc ", AreaIdSub = "", KeyWord = "", PageNo = 1, PageSize = 30 }.ToStringObjectDictionary(); HttpAdapter.postSyncAsJSON(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/GetResidentBaseInfo", param, (ret, res) => { if ((bool)ret.Success) { foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); ResidentBaseInfo dtItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <ResidentBaseInfo>(); residentBaseInfos.Add(dtItem); } } }); }
private void btnOK_Click(object sender, EventArgs e) { if (!CheckExtNo()) { return; } string transfer_num = rbExt.Checked ? txtTransferExtNo.Text.Trim() : e0571.web.core.Utils.TypeConverter.ChangeString((cbTransferQueues.SelectedItem as ListItem).Value); string urlToTransfer = TheMotherWin.getIPCCInterface4EComm("transfer", new Dictionary <string, string> { { "ext_no", EnvironmentVar.ExtCode }, { "transfer_num", transfer_num } }); HttpAdapter.getAsyncTo(urlToTransfer, (result0, response0) => { Console.WriteLine(string.Format("################### transfer {0}:{1}", transfer_num, result0)); if (result0 == "+OK") { BeginInvoke(new Action(() => { this.Close(); })); } else { MessageBoxAdapter.ShowDebug(result0); } }); }
private void SubmitData() { if (item != null) { new Action(() => { int doStatus = int.Parse(item.StringObjectDictionary.DoStatus); if (doStatus == 0) { //响应工单 if (MessageBoxAdapter.ShowConfirm("您确定要响应工单吗") == System.Windows.Forms.DialogResult.OK) { //string url = AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/ResponseWorkOrder"; string url = AccessPoint + "/Oca/WorkOrderService/ResponseWorkOrder"; HttpAdapter.postSyncAsJSON(url, new { WorkOrderId = Guid.Parse(WorkOrderId) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { LastError = null; } else { LastError = ret.ErrorMessage; } }); } else { LastError = Common.ERROR_USER_CANCEL; } } }).BeginInvoke(new AsyncCallback((ar) => { //AsyncResult result = (AsyncResult)ar; this.UIInvoke(() => { xLoadingPanel.Stop(); if (!string.IsNullOrEmpty(LastError)) { if (LastError != Common.ERROR_USER_CANCEL) { MessageBoxAdapter.ShowError(LastError); } } else { this.DialogResult = DialogResult.OK; this.Close(); } }); }), null); xLoadingPanel.Start(); } }
private void btn_ok_Click(object sender, EventArgs e) { string authEndPoint = formatEndPoint(txtAuthEndPoint.Text.Trim()); string authSmsEndPoint = formatEndPoint(txtAuthSmsEndPoint.Text.Trim()); string smsEndPoint = formatEndPoint(txtSmsEndPoint.Text.Trim()); string showError = ""; showError = txt_SpCode.Text.Trim(); if (string.IsNullOrEmpty(showError)) { MessageBoxAdapter.ShowError("企业编号不能为空!"); return; } showError = txt_LoginName.Text.Trim(); if (string.IsNullOrEmpty(showError)) { MessageBoxAdapter.ShowError("用户名不能为空!"); return; } showError = txt_Password.Text.Trim(); if (string.IsNullOrEmpty(showError)) { MessageBoxAdapter.ShowError("密码不能为空!"); return; } string txtSmsSetting = "SpCode=" + txt_SpCode.Text.Trim() + "&LoginName=" + txt_LoginName.Text.Trim() + "&Password="******"/"; HttpAdapter.optionsAsyncTo(connectUrl, new { ApplicationId = "CS001" }.ToStringObjectDictionary(), (ret, res) => { if (ret != "ok") { MessageBoxAdapter.ShowError("无效的认证节点"); return; } if (SectionSettingsSave != null) { SectionSettingsSave(this, new SectionSettingsSaveEventArgs { AuthEndPoint = authEndPoint, AuthSmsEndPoint = authSmsEndPoint, SmsEndPoint = smsEndPoint, TxtSmsSetting = txtSmsSetting, }); } this.DialogResult = DialogResult.OK; this.UIInvoke(() => { this.Close(); }); }); }
private void DoLogin(string userName, string password) { // btnOk.Enabled = false; lblMsg.Text = "登录中"; _tickTimer = new System.Timers.Timer(1 * 200); _tickTimer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object source, System.Timers.ElapsedEventArgs ee) { BeginInvoke(new Action(() => { if (lblMsg.Text.IndexOf(".") == -1) { lblMsg.Text += "."; } else if (lblMsg.Text.IndexOf(".") + 5 == lblMsg.Text.Length) { lblMsg.Text = lblMsg.Text.Substring(0, lblMsg.Text.Length - 5); } else { lblMsg.Text += "."; } })); }); //到达时间的时候执行事件; _tickTimer.AutoReset = true; //设置是执行一次(false)还是一直执行(true); _tickTimer.Enabled = true; //是否执行System.Timers.Timer.Elapsed事件; HttpAdapter.postAsyncAsJSON(authEndPoint + "/AuthenticateMerchant", new AuthMerchantParam { StationCode = userName, PasswordHash = MD5Provider.Generate(password) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) => { //MessageBoxAdapter.ShowDebug(_MonitorId.ToString()); //dynamic ret = new { Error = "", Success = false }; //ret = JsonConvert.DeserializeObject(result); MerchantVar.Load(userName, ret.ret); if ((bool)ret.Success) { INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, userName, Common.INI_FILE_PATH); this.DialogResult = DialogResult.OK; this.Close(); } else { lblMsg.Text = ret.ErrorMessage; this.UIInvoke(() => { btnOk.Enabled = true; }); } _tickTimer.Enabled = false; _tickTimer = null; }); }
private void _DeleteWXButtonsToWeiXin(Action success, Action <int, string> fail) { string deleteCustomMenuUrl1 = string.Format(GlobalManager.TheWeiXinAPIOfV1[GlobalManager.APIGETKey_Cmu_DeleteCustomMenu], GlobalManager.TheServiceAccount.AccessToken); HttpAdapter.getSyncTo(deleteCustomMenuUrl1, (ret1, res1) => { int errCode1 = int.Parse(ret1.errcode.ToString()); string errMsg1 = ret1.errmsg.ToString(); if (errCode1 == 0) { if (success != null) { success(); } } else if (errCode1 == 42001 || errCode1 == 41001) { if (_RefreshAccessToken()) { string deleteCustomMenuUrl2 = string.Format(GlobalManager.TheWeiXinAPIOfV1[GlobalManager.APIGETKey_Cmu_DeleteCustomMenu], GlobalManager.TheServiceAccount.AccessToken); HttpAdapter.getSyncTo(deleteCustomMenuUrl2, (ret2, res2) => { int errCode2 = int.Parse(ret2.errcode.ToString()); string errMsg2 = ret2.errmsg.ToString(); if (errCode2 == 0) { if (success != null) { success(); } } else { if (fail != null) { fail(errCode2, errMsg2); } } }); } else { if (fail != null) { fail(GlobalManager.ERR_RefreshAccessTokenFaild, "刷新AccessToken失败"); } } } else { if (fail != null) { fail(errCode1, errMsg1); } } }); }
private void FetchData() { if (!isFetchingData) { if (datas == null) { datas = new List <WorkOrderInfo>(); } else { datas.Clear(); } new Action(() => { isFetchingData = true; if (MerchantVar.CurrentMerchant.AuthNodeInfos.Count > 0) { foreach (var nodeInfo in MerchantVar.CurrentMerchant.AuthNodeInfos) { //string url = nodeInfo.AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/GetWorkOrderToResponse"; string url = nodeInfo.AccessPoint + "/Oca/WorkOrderService/GetWorkOrderToResponse"; HttpAdapter.getSyncTo(url, null, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = nodeInfo.StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); WorkOrderInfo dataItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <WorkOrderInfo>(); dataItem.DoStatusName = WorkOrderInfo.getDoStatusName(int.Parse(item.StringObjectDictionary.DoStatus)); dataItem.AccessPoint = nodeInfo.AccessPoint; dataItem.StationId = nodeInfo.StationId; datas.Add(dataItem); } } }); } } }).BeginInvoke(new AsyncCallback((ar) => { //AsyncResult result = (AsyncResult)ar; this.UIInvoke(() => { xLoadingPanel.Stop(); xSource.DataSource = datas; xSource.ResetBindings(false); }); isFetchingData = false; }), null); xLoadingPanel.Start(); } }
private void frmLogin_Load(object sender, EventArgs e) { lblProductName.Text = Properties.Settings.Default.ProductName; lblProductVersionComment.Text = Properties.Settings.Default.ProductVersionComment; authEndPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_END_POINT, Common.CFG_FILE_PATH); authDataPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_DATA_POINT, Common.CFG_FILE_PATH); strUserNameSinceLast = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, Common.INI_FILE_PATH); strObjectIdSinceLast = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_OBJECT_ID_SINCE_LAST, Common.INI_FILE_PATH); strObjectNameSinceLast = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_OBJECT_NAME_SINCE_LAST, Common.INI_FILE_PATH); strRunMode = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_RUN_MODE, Common.INI_FILE_PATH); string strDeployNodeObjects = INIAdapter.ReadValue(Common.INI_SECTION_DATA, Common.INI_KEY_DEPLOY_NODE_OBJECTS, Common.INI_FILE_PATH); if (strDeployNodeObjects == "") { btnOk.Enabled = false; //远程获取deployNodeObjects ThreadAdapter.DoOnceTask(() => { HttpAdapter.getSyncTo(authDataPoint + "/GetDeployNodeObjects", (ret, res) => { if ((bool)ret.Success) { strDeployNodeObjects = JsonConvert.SerializeObject(ret.rows); INIAdapter.WriteValue(Common.INI_SECTION_DATA, Common.INI_KEY_DEPLOY_NODE_OBJECTS, strDeployNodeObjects, Common.INI_FILE_PATH); this.UIInvoke(() => { btnOk.Enabled = true; }); BindDeployNodeObjects(strDeployNodeObjects); } else { this.UIInvoke(() => { btnOk.Enabled = true; }); } }); }); } else { BindDeployNodeObjects(strDeployNodeObjects); } if (strRunMode == "") { strRunMode = "0"; } if (!string.IsNullOrEmpty(strUserNameSinceLast)) { txtUserName.Text = strUserNameSinceLast; } }
//更新短信状体 private void UpdateSmsSendStatus(StringObjectDictionary sod, string url, string token, string nodeId, int itype) { HttpAdapter.postSyncAsJSON(url + "/Pub/SmsSendService/Update2", sod, new { ApplicationId = "CS001", Token = token, NodeId = nodeId }.ToStringObjectDictionary(), (ret, res) => { this.Invoke(new Action <int, string, bool>((p1, p2, p3) => { lb_Send.Items.Add((itype == 1 ? "[回执]" : "") + (string.IsNullOrEmpty(p2) ? "" : "[" + p2 + "] ") + "更新数据库短信状态:" + (p3 == true ? "成功" : "失败")); }), new object[] { itype, (string)sod["Mobiles"], (bool)ret.Success }); }); }
private void ButtonDisconnectAll_Click(object sender, RoutedEventArgs e) { HttpAdapter ha = new HttpAdapter(); ha.Destination = "https://its.pku.edu.cn/cas/login"; ha.cc = _cookie; ha.ProcessHttp(PKUGW_WP.paraCombination("USERNAME_DOSSTONED", "PWDOSSTONED", PKUGW_WP.莫名其妙的字符串, PKUGW_WP.LoginType.free), 20); ha.Destination = "https://its.pku.edu.cn/netportal/ipgwcloseall"; ha.ProcessHttp("sid=348"); }
public static dynamic getDictionaryItemList(string dictionaryItem) { string url = GovVar.DataPointOfManage + "/Share/AjaxData/GetDictionaryItem/" + dictionaryItem; dynamic dyDictionaryItem = null; HttpAdapter.getSyncTo(url, (ret, res) => { dyDictionaryItem = ret; }); return(dyDictionaryItem); }
//public static ArrayList getStreetAndCommunityInArea(string parentId, int levels) //{ // string url = GovVar.DataPointOfManage + "/Share/AjaxData/GetStreetAndCommunityInArea/" + parentId; // ArrayList arrList=new ArrayList(); // HttpAdapter.getSyncTo(url, (ret, res) => // { // foreach (var row in ret) { // if (row.Levels.Value == levels) { // arrList.Add(row); // } // } // }); // return arrList; //} public static dynamic getStreetAndCommunity(string parentId) { string url = GovVar.DataPointOfManage + "/Share/AjaxData/GetStreetAndCommunityInArea/" + parentId; dynamic dyStreetAndCommunity = null; HttpAdapter.getSyncTo(url, (ret, res) => { dyStreetAndCommunity = ret; }); return(dyStreetAndCommunity); }
public void Subscribe_Does_Not_Set_Api_Token_Header_If_Token_Source_Is_specified() { var token = "3314-2222-4420_any_text"; var tokenSource = Substitute.For <IApiTokenSource>(); tokenSource.GetToken().Returns(token); _adapter = new HttpAdapter <Profile>(_defaultAddress, _serializer, _messageSerializer, tokenSource); _adapter.Subscribe(2020); Assert.IsFalse(_requests.First().Headers.AllKeys.Contains("Api-Token")); }
public void Post_Sets_Api_Token_Header_If_Token_Source_Is_specified() { var token = "3314-2222-4420_any_text"; var tokenSource = Substitute.For <IApiTokenSource>(); tokenSource.GetToken().Returns(token); _adapter = new HttpAdapter <Profile>(_defaultAddress, _serializer, _messageSerializer, tokenSource); _adapter.Pull(); Assert.That(_requests.First().Headers["Api-Token"], Is.EqualTo(token)); }
//针对变化的格式 private void _RefreshWXUserInfo(string openId, Action <dynamic> success, Action <int, string> fail) { string getInfoOfNormalAccountUrl1 = string.Format(GlobalManager.TheWeiXinAPIOfV1[GlobalManager.APIGETKey_Meb_GetInfoOfNormalAccount], GlobalManager.TheServiceAccount.AccessToken, openId); HttpAdapter.getSyncTo(getInfoOfNormalAccountUrl1, (ret1, res1) => { if (ret1.errcode == null) { if (success != null) { success(ret1); } } else { int errCode = int.Parse(ret1.errcode.ToString()); string errMsg = ret1.errmsg.ToString(); if (errCode == 42001 || errCode == 41001) { //AccessToken过期或缺失 if (_RefreshAccessToken()) { string getInfoOfNormalAccountUrl2 = string.Format(GlobalManager.TheWeiXinAPIOfV1[GlobalManager.APIGETKey_Meb_GetInfoOfNormalAccount], GlobalManager.TheServiceAccount.AccessToken, openId); HttpAdapter.getSyncTo(getInfoOfNormalAccountUrl2, (ret2, res2) => { if (ret2.errcode == null) { if (success != null) { success(ret2); } } }); } else { if (fail != null) { fail(GlobalManager.ERR_RefreshAccessTokenFaild, "刷新AccessToken失败"); } } } else { if (fail != null) { fail(errCode, errMsg); } } } }); }
private bool _RefreshAccessToken() { string accessTokenUrl = string.Format(GlobalManager.TheWeiXinAPIOfV1[GlobalManager.APIGETKey_Bas_GetAccessToken], GlobalManager.TheServiceAccount.AppId, GlobalManager.TheServiceAccount.AppSecret); HttpAdapter.getSyncTo(accessTokenUrl, (ret, res) => { GlobalManager.TheServiceAccount.AccessToken = ret.access_token; BuilderFactory.DefaultBulder(GlobalManager.getConnectString()).Update <ServiceAccount>(new ServiceAccount { AccountCode = GlobalManager.TheServiceAccount.AccountCode, AccessToken = ret.access_token }); }); return(true); }
private void creatTreeData() { String url = GovVar.DataPointOfManage + "/Share/TreeDataService/fetchTreeData"; StringObjectDictionary _treeParam = new { TreeCode = "01$01$02", OrderByClause = "OrderNo asc", TreeParams = "{\"DictionaryId\":\"00005\" , \"ItemId\":\"" + GovVar.Area1 + "\"}" }.ToStringObjectDictionary(); HttpAdapter.postSyncAsJSON(url, _treeParam, (ret, res) => { TreeNode treeNode = new TreeNode(); foreach (var row in ret) { if (row.pId.Value == "_") { string areaId = row.id.Value.ToString(); //辖区绑定,作为一级层次 treeNode.Text = row.name.Value.ToString(); treeNode.Name = areaId; //街道绑定 ,作为二级层次 foreach (var row_s in ret) { if (row_s.pId.Value.ToString() == areaId) { string streetId = row_s.id.Value.ToString(); TreeNode tn_s = new TreeNode(); tn_s.Text = row_s.name.Value.ToString(); tn_s.Name = streetId; treeNode.Nodes.Add(tn_s); //社区绑定 ,作为三级层次 foreach (var row_c in ret) { if (row_c.pId.Value.ToString() == streetId) { TreeNode tn_c = new TreeNode(); tn_c.Text = row_c.name.Value.ToString(); tn_c.Name = row_c.id.Value.ToString(); tn_s.Nodes.Add(tn_c); } } } } break; } } this.tvAreaInfo.Nodes.Add(treeNode); if (tvAreaInfo.Nodes.Count > 0) { tvAreaInfo.Nodes[0].Expand(); } }); }
public Stream QueueMemberList(IpccQueue ipccQueue) { InvokeResult <string> result = new InvokeResult <string> { Success = true }; if (!string.IsNullOrEmpty(ipccQueue.RemoteUrl)) { IList <StringObjectDictionary> queueMembers = new List <StringObjectDictionary>(); if (ipccQueue.QueueNames != null && ipccQueue.QueueNames.Count > 0) { try { foreach (string item in ipccQueue.QueueNames) { HttpAdapter.getSyncTo(ipccQueue.RemoteUrl + item, (ret, res) => { dynamic agent = JsonConvert.DeserializeObject(ret); if (agent.success == "true" && agent.data != null) { foreach (var key in agent.data) { queueMembers.Add(new { queueName = item, uuid = key.uuid, cid_number = key.cid_number, cid_name = key.cid_name, join_time = key.join_time }.ToStringObjectDictionary()); } } }); } if (queueMembers.Count > 0) { result.ret = JsonConvert.SerializeObject(queueMembers); } else { result.ret = ""; } } catch (Exception ex) { result.Success = false; result.ErrorMessage = ex.ToString(); } } } byte[] resultBytes = Encoding.UTF8.GetBytes(result.ToJson()); WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return(new MemoryStream(resultBytes)); }
public Stream GetRemoteDataAsJSONP(string remoteUrl, string callback) { InvokeResult <string> result = new InvokeResult <string> { Success = true }; HttpAdapter.getSyncTo(remoteUrl, (ret, res) => { result.ret = JsonConvert.DeserializeObject(ret).ToString(); }); byte[] resultBytes = Encoding.UTF8.GetBytes(callback + "(" + result.ToJson() + ")"); WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return(new MemoryStream(resultBytes)); }
public Stream GetOpenIdByOAuth2AsJSONP(string code, string callback) { InvokeResult <string> result = new InvokeResult <string> { Success = true }; string accessTokenUrl = string.Format(GlobalManager.TheWeiXinAPIOfV1[GlobalManager.APIGETKey_OAuth2_GetAccessToken], GlobalManager.TheServiceAccount.AppId, GlobalManager.TheServiceAccount.AppSecret, code); HttpAdapter.getSyncTo(accessTokenUrl, (ret, res) => { result.ret = JsonConvert.DeserializeObject(ret).openid.ToString(); }); byte[] resultBytes = Encoding.UTF8.GetBytes(callback + "(" + result.ToJson() + ")"); WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8"; return(new MemoryStream(resultBytes)); }