protected void Page_Load(object sender, EventArgs e) { string openIdType = "hishop.plugins.openid.alipay.alipayservice"; OpenIdSettingInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType); if (openIdSettings != null) { string value = base.Request.QueryString["alipaytoken"]; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; xmlDocument.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings)); SortedDictionary <string, string> sortedDictionary = new SortedDictionary <string, string>(); sortedDictionary.Add("service", "user.logistics.address.query"); sortedDictionary.Add("partner", xmlDocument.FirstChild.SelectSingleNode("Partner").InnerText); sortedDictionary.Add("_input_charset", "utf-8"); sortedDictionary.Add("return_url", Globals.FullPath("openid/LogisticsAddress_url")); sortedDictionary.Add("token", value); Dictionary <string, string> dictionary = OpenIdFunction.FilterPara(sortedDictionary); string value2 = OpenIdFunction.BuildMysign(dictionary, xmlDocument.FirstChild.SelectSingleNode("Key").InnerText, "MD5", "utf-8"); dictionary.Add("sign", value2); dictionary.Add("sign_type", "MD5"); StringBuilder stringBuilder = new StringBuilder(); foreach (KeyValuePair <string, string> item in dictionary) { stringBuilder.Append(OpenIdFunction.CreateField(item.Key, item.Value)); } sortedDictionary.Clear(); dictionary.Clear(); OpenIdFunction.Submit(OpenIdFunction.CreateForm(stringBuilder.ToString(), "https://mapi.alipay.com/gateway.do?_input_charset=utf-8")); } }
protected void Page_Load(object sender, EventArgs e) { string openIdType = "hishop.plugins.openid.alipay.alipayservice"; OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType); if (openIdSettings != null) { string str2 = base.Request.QueryString["alipaytoken"]; XmlDocument document = new XmlDocument(); document.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings)); SortedDictionary <string, string> dicArrayPre = new SortedDictionary <string, string>(); dicArrayPre.Add("service", "user.logistics.address.query"); dicArrayPre.Add("partner", document.FirstChild.SelectSingleNode("Partner").InnerText); dicArrayPre.Add("_input_charset", "utf-8"); dicArrayPre.Add("return_url", Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("LogisticsAddress_url"))); dicArrayPre.Add("token", str2); Dictionary <string, string> dicArray = OpenIdFunction.FilterPara(dicArrayPre); string str3 = OpenIdFunction.BuildMysign(dicArray, document.FirstChild.SelectSingleNode("Key").InnerText, "MD5", "utf-8"); dicArray.Add("sign", str3); dicArray.Add("sign_type", "MD5"); StringBuilder builder = new StringBuilder(); foreach (KeyValuePair <string, string> pair in dicArray) { builder.Append(OpenIdFunction.CreateField(pair.Key, pair.Value)); } dicArrayPre.Clear(); dicArray.Clear(); OpenIdFunction.Submit(OpenIdFunction.CreateForm(builder.ToString(), "https://mapi.alipay.com/gateway.do?_input_charset=utf-8")); } }
protected void Page_Load(object sender, System.EventArgs e) { string openIdType = "Ecdev.plugins.openid.alipay.alipayservice"; OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType); if (openIdSettings == null) { return; } string value = base.Request.QueryString["alipaytoken"]; System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument(); xmlDocument.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings)); System.Collections.Generic.SortedDictionary <string, string> sortedDictionary = new System.Collections.Generic.SortedDictionary <string, string>(); sortedDictionary.Add("service", "user.logistics.address.query"); sortedDictionary.Add("partner", xmlDocument.FirstChild.SelectSingleNode("Partner").InnerText); sortedDictionary.Add("_input_charset", "utf-8"); sortedDictionary.Add("return_url", Globals.FullPath(Globals.GetSiteUrls().UrlData.FormatUrl("LogisticsAddress_url"))); sortedDictionary.Add("token", value); System.Collections.Generic.Dictionary <string, string> dictionary = OpenIdFunction.FilterPara(sortedDictionary); string value2 = OpenIdFunction.BuildMysign(dictionary, xmlDocument.FirstChild.SelectSingleNode("Key").InnerText, "MD5", "utf-8"); dictionary.Add("sign", value2); dictionary.Add("sign_type", "MD5"); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); foreach (System.Collections.Generic.KeyValuePair <string, string> current in dictionary) { stringBuilder.Append(OpenIdFunction.CreateField(current.Key, current.Value)); } sortedDictionary.Clear(); dictionary.Clear(); OpenIdFunction.Submit(OpenIdFunction.CreateForm(stringBuilder.ToString(), "https://mapi.alipay.com/gateway.do?_input_charset=utf-8")); }
protected void Page_Load(object sender, EventArgs e) { openIdType = base.Request.QueryString["t"]; if (string.IsNullOrEmpty(openIdType) || (openIdType.Trim().Length == 0)) { base.GotoResourceNotFound(); } PluginItem pluginItem = OpenIdPlugins.Instance().GetPluginItem(openIdType); if (pluginItem == null) { base.GotoResourceNotFound(); } if (!Page.IsPostBack) { txtName.Text = pluginItem.DisplayName; lblDisplayName.Text = pluginItem.DisplayName; txtSelectedName.Value = openIdType; OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType); if (openIdSettings != null) { ConfigData data = new ConfigData(Cryptographer.Decrypt(openIdSettings.Settings)); txtConfigData.Value = data.SettingsXml; txtName.Text = openIdSettings.Name; fcContent.Text = openIdSettings.Description; } } }
private void grdConfigedItems_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e) { string openIdType = this.grdConfigedItems.DataKeys[e.RowIndex]["FullName"].ToString(); OpenIdHelper.DeleteSettings(openIdType); this.BindData(); }
public async Task <HttpResponseMessage> GetTicket([FromUri] string code) { if (string.IsNullOrEmpty(code)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, Error.LackInfo)); } string openid = await OpenIdHelper.GetOpenIdAsync(code); //string openid = "o5dhF1EKpj54qs6-GNoYtLPUSUOA"; if (string.IsNullOrEmpty(openid)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, Error.LackInfo)); } EmployeeMap employeeMap = new EmployeeMap(); employeeMap.OpenId = openid; employeeMap.Code = code; string sql = @"select * from Employee where OpenId = @OpenId"; try { using (IDbConnection connection = new SqlConnection(DBHelper.GetConnectionString())) { var employeeMaps = connection.Query <EmployeeMap>(sql, employeeMap); if (employeeMaps == null || employeeMaps.Count() <= 0) { return(Request.CreateResponse(HttpStatusCode.NotFound, Error.NotFound)); } sql = @"select top 1 * from AccessToken order by ExpireTime desc"; var tickets = connection.Query <AccessToken>(sql); if (tickets == null || tickets.Count() <= 0) { return(Request.CreateResponse(HttpStatusCode.NotFound, Error.NotFound)); } string noncestr = ConfigurationManager.AppSettings["noncestr"].ToString(); string timestamp = ConfigurationManager.AppSettings["timestamp"].ToString(); string url = HttpContext.Current.Request.UrlReferrer.AbsoluteUri; string ticket = tickets.ToList()[0].Ticket; string signature = Sha1Helper.SHA1Encrypt($"jsapi_ticket={ticket}&noncestr={noncestr}×tamp={timestamp}&url={url}"); JObject result = new JObject(); result["sig"] = signature; result["openid"] = openid; return(Request.CreateResponse(HttpStatusCode.OK, result)); //HttpContext.Current.Response.Write(result); //HttpContext.Current.Response.End(); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, Error.Server)); } }
protected void grdEmptyListNew_ItemCommand(object source, RepeaterCommandEventArgs e) { HiddenField hiddenField = e.Item.FindControl("hfFullName") as HiddenField; string commandName = e.CommandName; if (commandName == "Delete") { string value = hiddenField.Value; OpenIdHelper.DeleteSettings(value); this.BindData(); } }
private void btnSave_Click(object sender, EventArgs e) { ConfigData data; if (ValidateValues(out data)) { OpenIdSettingsInfo settings = new OpenIdSettingsInfo(); settings.Name = txtName.Text.Trim(); settings.Description = fcContent.Text; settings.OpenIdType = openIdType; settings.Settings = Cryptographer.Encrypt(data.SettingsXml); OpenIdHelper.SaveSettings(settings); Response.Redirect("openidservices.aspx"); } }
private void BindEmptyList() { PluginItemCollection emptyItems = OpenIdHelper.GetEmptyItems(); if (emptyItems != null && emptyItems.Count > 0) { this.grdEmptyList.DataSource = emptyItems.Items; this.grdEmptyList.DataBind(); this.pnlEmptyList.Visible = true; this.pnlEmptyNote.Visible = false; return; } this.pnlEmptyList.Visible = false; this.pnlEmptyNote.Visible = true; }
private void BindConfigedList() { PluginItemCollection configedItems = OpenIdHelper.GetConfigedItems(); if (configedItems != null && configedItems.Count > 0) { this.grdConfigedItems.DataSource = configedItems.Items; this.grdConfigedItems.DataBind(); this.pnlConfigedList.Visible = true; this.pnlConfigedNote.Visible = false; return; } this.pnlConfigedList.Visible = false; this.pnlConfigedNote.Visible = true; }
private void btnSave_Click(object sender, EventArgs e) { ConfigData data; if (this.ValidateValues(out data)) { OpenIdSettingsInfo info2 = new OpenIdSettingsInfo(); info2.Name = this.txtName.Text.Trim(); info2.Description = this.fcContent.Text; info2.OpenIdType = this.openIdType; info2.Settings = HiCryptographer.Encrypt(data.SettingsXml); OpenIdSettingsInfo settings = info2; OpenIdHelper.SaveSettings(settings); base.Response.Redirect("openidservices.aspx"); } }
private void BindEmptyList() { PluginItemCollection emptyItems = OpenIdHelper.GetEmptyItems(); if ((emptyItems != null) && (emptyItems.Count > 0)) { grdEmptyList.DataSource = emptyItems.Items; grdEmptyList.DataBind(); pnlEmptyList.Visible = true; pnlEmptyNote.Visible = false; } else { pnlEmptyList.Visible = false; pnlEmptyNote.Visible = true; } }
private void BindConfigedList() { PluginItemCollection configedItems = OpenIdHelper.GetConfigedItems(); if ((configedItems != null) && (configedItems.Count > 0)) { grdConfigedItems.DataSource = configedItems.Items; grdConfigedItems.DataBind(); pnlConfigedList.Visible = true; pnlConfigedNote.Visible = false; } else { pnlConfigedList.Visible = false; pnlConfigedNote.Visible = true; } }
private void btnSave_Click(object sender, EventArgs e) { ConfigData configData = default(ConfigData); if (this.ValidateValues(out configData)) { OpenIdSettingInfo settings = new OpenIdSettingInfo { Name = this.txtName.Text.Trim(), Description = this.fcContent.Text, OpenIdType = this.openIdType, Settings = HiCryptographer.Encrypt(configData.SettingsXml) }; OpenIdHelper.SaveSettings(settings); base.Response.Redirect("openidservices.aspx"); } }
public async Task <HttpResponseMessage> GetContacts([FromUri] string code) { if (string.IsNullOrEmpty(code)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, Error.LackInfo)); } string openid = await OpenIdHelper.GetOpenIdAsync(code); //string openid = "o5dhF1EKpj54qs6-GNoYtLPUSUOA"; if (string.IsNullOrEmpty(code)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, Error.LackInfo)); } string sql = $"select * from Employee where OpenId='{openid}'"; try { using (IDbConnection connection = new SqlConnection(DBHelper.GetConnectionString())) { var employees = connection.Query <Employee>(sql); if (employees == null || employees.Count() == 0) { sql = $"insert EmployeeMap(OpenId, Code) values('{openid}', '{code}')"; connection.Execute(sql); return(Request.CreateResponse(HttpStatusCode.NotFound, Error.NotBound)); } sql = $"select * from Contact where OpenId='{openid}'"; var contacts = connection.Query <Contact>(sql); if (contacts != null && contacts.Count() > 0) { return(Request.CreateResponse(HttpStatusCode.OK, contacts)); } else { return(Request.CreateResponse(HttpStatusCode.OK, employees.ToList()[0].OpenId)); } } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, Error.Server)); } }
public void ConfigureAuth(IAppBuilder app) { //ApplicationDbContext db = new ApplicationDbContext(); app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new CookieAuthenticationOptions()); //Authentication settings if (!string.IsNullOrEmpty(AzureADSettings.TenantId)) { OpenIdHelper.UseWithAzureAD(app); } else { OpenIdHelper.UseWithADFS(app); } }
public async Task <HttpResponseMessage> GetPacket([FromUri] string code) { if (string.IsNullOrEmpty(code)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, Error.LackInfo)); } string openid = await OpenIdHelper.GetOpenIdAsync(code); //string openid = "o5dhF1EKpj54qs6-GNoYtLPUSUOA"; if (string.IsNullOrEmpty(openid)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, Error.LackInfo)); } string sql = $"select * from Employee where OpenId='{openid}'"; try { using (IDbConnection connection = new SqlConnection(DBHelper.GetConnectionString())) { var employees = connection.Query <Employee>(sql); if (employees == null || employees.Count() == 0) { sql = $"insert EmployeeMap(OpenId, Code) values('{openid}', '{code}')"; connection.Execute(sql); return(Request.CreateResponse(HttpStatusCode.NotFound, Error.NotBound)); } sql = $"select Orders.* from Orders left join Contact on Orders.Call =Contact.Call where Contact.openid= '{openid}' order by Orders.InputTime desc"; var orders = connection.Query <Order>(sql); return(Request.CreateResponse(HttpStatusCode.OK, orders)); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, Error.Server)); } }
// GET: /<controller>/ public async Task <IActionResult> Index() { AuthenticationResult result = null; List <TodoItem> itemList = new List <TodoItem>(); ViewBag.Backend = BackendUrl; try { var authContext = OpenIdHelper.GetAuthenticationContext(Configuration, HttpContext, UserObjectID); result = await OpenIdHelper.GetAuthenticationResult(Configuration, authContext, UserObjectID); // // Retrieve the user's To Do List. // var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, BackendUrl + "/api/todolist"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken); request.Headers.Add("Ocp-Apim-Subscription-Key", ApimSubscriptionKey); HttpResponseMessage response = await client.SendAsync(request); // // Return the To Do List in the view. // if (response.IsSuccessStatusCode) { var responseElements = new List <Dictionary <String, String> >(); var settings = new JsonSerializerSettings(); var responseString = await response.Content.ReadAsStringAsync(); responseElements = JsonConvert.DeserializeObject <List <Dictionary <String, String> > >(responseString, settings); foreach (Dictionary <String, String> responseElement in responseElements) { itemList.Add(new TodoItem { Title = responseElement["title"], Owner = responseElement["owner"] }); } return(View(itemList)); } else { // // If the call failed with access denied, then drop the current access token from the cache, // if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { ClearTokens(authContext); } ViewBag.ErrorMessage = $"UnexpectedError: {response.StatusCode}"; itemList.Add(new TodoItem { Title = "(No items in list)" }); return(View(itemList)); } } catch (Exception ee) { if (HttpContext.Request.Query["reauth"] == "True") { // // Send an OpenID Connect sign-in request to get a new set of tokens. // If the user still has a valid session with Azure AD, they will not be prompted for their credentials. // The OpenID Connect middleware will return to this controller after the sign-in response has been handled. // return(new ChallengeResult(OpenIdConnectDefaults.AuthenticationScheme)); } // // The user needs to re-authorize. Show them a message to that effect. // itemList.Add(new TodoItem { Title = "(Sign-in required to view to do list.)" }); ViewBag.ErrorMessage = "AuthorizationRequired"; return(View(itemList)); } }
public async Task <ActionResult> Index(string item) { if (ModelState.IsValid) { // // Retrieve the user's tenantID and access token since they are parameters used to call the To Do service. // AuthenticationResult result = null; List <TodoItem> itemList = new List <TodoItem>(); try { var authContext = OpenIdHelper.GetAuthenticationContext(Configuration, HttpContext, UserObjectID); result = await OpenIdHelper.GetAuthenticationResult(Configuration, authContext, UserObjectID); // Forms encode todo item, to POST to the todo list web api. HttpContent content = new StringContent(JsonConvert.SerializeObject(new { Title = item }), System.Text.Encoding.UTF8, "application/json"); // // Add the item to user's To Do List. // HttpClient client = new HttpClient(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, BackendUrl + "/api/todolist"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", result.AccessToken); request.Headers.Add("Ocp-Apim-Subscription-Key", ApimSubscriptionKey); request.Content = content; HttpResponseMessage response = await client.SendAsync(request); // // Return the To Do List in the view. // if (response.IsSuccessStatusCode) { return(RedirectToAction("Index")); } else { // // If the call failed with access denied, then drop the current access token from the cache, // and show the user an error indicating they might need to sign-in again. // if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { ClearTokens(authContext); ViewBag.ErrorMessage = "UnexpectedError"; var newItem = new TodoItem { Title = "(No items in list)" }; itemList.Add(newItem); return(View(newItem)); } } } catch (Exception ee) { // // The user needs to re-authorize. Show them a message to that effect. // itemList.Add(new TodoItem { Title = "(No items in list)" }); ViewBag.ErrorMessage = "AuthorizationRequired"; return(View(itemList)); } // // If the call failed for any other reason, show the user an error. // return(View("Error")); } return(View("Error")); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { IdentityModelEventSource.ShowPII = true; services.AddControllers(); Initializer.RegisterServices(services); services.AddLogging(); services.AddAuthentication(o => { o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { IssuerSigningKeyResolver = (s, securityToken, identifier, parameters) => { var json = OpenIdHelper.GetJwks(parameters); var keys = JsonConvert.DeserializeObject <JsonWebKeySet>(json).Keys; return((IEnumerable <SecurityKey>)keys); }, ValidIssuer = Configuration["Authentication:Cognito:Authority"], ValidateIssuerSigningKey = true, ValidateIssuer = false, ValidateLifetime = true, ValidateAudience = false }; options.IncludeErrorDetails = true; options.SaveToken = true; options.Authority = Configuration["Authentication:Cognito:Authority"]; options.RequireHttpsMetadata = true; }) .AddOpenIdConnect(options => { options.Authority = Configuration["Authentication:Cognito:Authority"]; options.RequireHttpsMetadata = false; options.ClientId = Configuration["Authentication:Cognito:ClientId"]; options.Scope.Add("mycookin/api"); }); ; services.AddAuthorization(options => { options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser() .Build(); }); services.AddSwaggerGen(c => { c.SwaggerDoc(ApiVersion, new OpenApiInfo { Title = "MyCookin", Version = ApiVersion }); c.OperationFilter <AddAuthHeaderOperationFilter>(); c.AddSecurityDefinition("bearer", //Name the security scheme new OpenApiSecurityScheme { Flows = new OpenApiOAuthFlows { ClientCredentials = new OpenApiOAuthFlow { TokenUrl = new Uri("https://auth.mycookin.com/oauth2/token"), Scopes = new Dictionary <string, string> { { "mycookin/api", "Access API" } }, AuthorizationUrl = new Uri("https://auth.mycookin.com/oauth2/authorize") } }, Type = SecuritySchemeType.OAuth2, OpenIdConnectUrl = new Uri( "https://cognito-idp.eu-west-1.amazonaws.com/eu-west-1_Zrq7io2kN/.well-known/openid-configuration"), BearerFormat = "JWT", In = ParameterLocation.Header, Scheme = "bearer" }); }); services.AddOptions(); services.AddSingleton(Log.Logger); }
private void grdConfigedItems_RowDeleting(object sender, GridViewDeleteEventArgs e) { OpenIdHelper.DeleteSettings(this.grdConfigedItems.DataKeys[e.RowIndex]["FullName"].ToString()); this.BindData(); }
protected void Page_Load(object sender, EventArgs e) { int num = 0; SortedDictionary <string, string> requestPost = this.GetRequestPost(); if (requestPost.Count > 0) { string openIdType = "hishop.plugins.openid.alipay.alipayservice"; OpenIdSettingsInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType); if (openIdSettings == null) { base.Response.Write("登录失败,没有找到对应的插件配置信息。"); return; } XmlDocument document = new XmlDocument(); document.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings)); AliPayNotify notify = new AliPayNotify(requestPost, base.Request.Form["notify_id"], document.FirstChild.SelectSingleNode("Partner").InnerText, document.FirstChild.SelectSingleNode("Key").InnerText); string responseTxt = notify.ResponseTxt; string str3 = base.Request.Form["sign"]; string mysign = notify.Mysign; if ((responseTxt == "true") && (str3 == mysign)) { string str5 = base.Request.Form["receive_address"]; if (!string.IsNullOrEmpty(str5)) { XmlDocument document2 = new XmlDocument(); document2.LoadXml(str5); ShippingAddressInfo shippingAddress = new ShippingAddressInfo(); shippingAddress.UserId = HiContext.Current.User.UserId; if ((document2.SelectSingleNode("/receiveAddress/address") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/address").InnerText)) { shippingAddress.Address = Globals.HtmlEncode(document2.SelectSingleNode("/receiveAddress/address").InnerText); } if ((document2.SelectSingleNode("/receiveAddress/fullname") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/fullname").InnerText)) { shippingAddress.ShipTo = Globals.HtmlEncode(document2.SelectSingleNode("/receiveAddress/fullname").InnerText); } if ((document2.SelectSingleNode("/receiveAddress/post") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/post").InnerText)) { shippingAddress.Zipcode = document2.SelectSingleNode("/receiveAddress/post").InnerText; } if ((document2.SelectSingleNode("/receiveAddress/mobile_phone") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText)) { shippingAddress.CellPhone = document2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText; } if ((document2.SelectSingleNode("/receiveAddress/phone") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/phone").InnerText)) { shippingAddress.TelPhone = document2.SelectSingleNode("/receiveAddress/phone").InnerText; } string innerText = string.Empty; string str7 = string.Empty; string str8 = string.Empty; if ((document2.SelectSingleNode("/receiveAddress/area") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/area").InnerText)) { innerText = document2.SelectSingleNode("/receiveAddress/area").InnerText; } if ((document2.SelectSingleNode("/receiveAddress/city") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/city").InnerText)) { str7 = document2.SelectSingleNode("/receiveAddress/city").InnerText; } if ((document2.SelectSingleNode("/receiveAddress/prov") != null) && !string.IsNullOrEmpty(document2.SelectSingleNode("/receiveAddress/prov").InnerText)) { str8 = document2.SelectSingleNode("/receiveAddress/prov").InnerText; } if ((string.IsNullOrEmpty(innerText) && string.IsNullOrEmpty(str7)) && string.IsNullOrEmpty(str8)) { shippingAddress.RegionId = 0; } else { shippingAddress.RegionId = RegionHelper.GetRegionId(innerText, str7, str8); } SiteSettings siteSettings = HiContext.Current.SiteSettings; if (PersonalHelper.GetShippingAddressCount(HiContext.Current.User.UserId) < HiContext.Current.Config.ShippingAddressQuantity) { num = PersonalHelper.AddShippingAddress(shippingAddress); } } } } this.Page.Response.Redirect(Globals.ApplicationPath + "/SubmmitOrder.aspx?shippingId=" + num); }
protected void Page_Load(object sender, EventArgs e) { int num = 0; SortedDictionary <string, string> requestPost = this.GetRequestPost(); if (requestPost.Count > 0) { string openIdType = "hishop.plugins.openid.alipay.alipayservice"; OpenIdSettingInfo openIdSettings = OpenIdHelper.GetOpenIdSettings(openIdType); if (openIdSettings == null) { base.Response.Write("登录失败,没有找到对应的插件配置信息。"); return; } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.XmlResolver = null; xmlDocument.LoadXml(HiCryptographer.Decrypt(openIdSettings.Settings)); AliPayNotify aliPayNotify = new AliPayNotify(requestPost, base.Request.Form["notify_id"], xmlDocument.FirstChild.SelectSingleNode("Partner").InnerText, xmlDocument.FirstChild.SelectSingleNode("Key").InnerText); string responseTxt = aliPayNotify.ResponseTxt; string a = base.Request.Form["sign"]; string mysign = aliPayNotify.Mysign; if (responseTxt == "true" && a == mysign) { string text = base.Request.Form["receive_address"]; if (!string.IsNullOrEmpty(text)) { XmlDocument xmlDocument2 = new XmlDocument(); xmlDocument.XmlResolver = null; xmlDocument2.LoadXml(text); ShippingAddressInfo shippingAddressInfo = new ShippingAddressInfo(); shippingAddressInfo.UserId = HiContext.Current.UserId; if (xmlDocument2.SelectSingleNode("/receiveAddress/address") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/address").InnerText)) { shippingAddressInfo.Address = Globals.HtmlEncode(xmlDocument2.SelectSingleNode("/receiveAddress/address").InnerText); } if (xmlDocument2.SelectSingleNode("/receiveAddress/fullname") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/fullname").InnerText)) { shippingAddressInfo.ShipTo = Globals.HtmlEncode(xmlDocument2.SelectSingleNode("/receiveAddress/fullname").InnerText); } if (xmlDocument2.SelectSingleNode("/receiveAddress/post") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/post").InnerText)) { shippingAddressInfo.Zipcode = xmlDocument2.SelectSingleNode("/receiveAddress/post").InnerText; } if (xmlDocument2.SelectSingleNode("/receiveAddress/mobile_phone") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText)) { shippingAddressInfo.CellPhone = xmlDocument2.SelectSingleNode("/receiveAddress/mobile_phone").InnerText; } if (xmlDocument2.SelectSingleNode("/receiveAddress/phone") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/phone").InnerText)) { shippingAddressInfo.TelPhone = xmlDocument2.SelectSingleNode("/receiveAddress/phone").InnerText; } string text2 = string.Empty; string text3 = string.Empty; string text4 = string.Empty; if (xmlDocument2.SelectSingleNode("/receiveAddress/area") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/area").InnerText)) { text2 = xmlDocument2.SelectSingleNode("/receiveAddress/area").InnerText; } if (xmlDocument2.SelectSingleNode("/receiveAddress/city") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/city").InnerText)) { text3 = xmlDocument2.SelectSingleNode("/receiveAddress/city").InnerText; } if (xmlDocument2.SelectSingleNode("/receiveAddress/prov") != null && !string.IsNullOrEmpty(xmlDocument2.SelectSingleNode("/receiveAddress/prov").InnerText)) { text4 = xmlDocument2.SelectSingleNode("/receiveAddress/prov").InnerText; } if (string.IsNullOrEmpty(text2) && string.IsNullOrEmpty(text3) && string.IsNullOrEmpty(text4)) { shippingAddressInfo.RegionId = 0; } else { shippingAddressInfo.RegionId = RegionHelper.GetRegionId(text2, text3, text4); } SiteSettings siteSettings = HiContext.Current.SiteSettings; if (MemberProcessor.GetShippingAddressCount(HiContext.Current.UserId) < HiContext.Current.Config.ShippingAddressQuantity) { shippingAddressInfo.FullRegionPath = RegionHelper.GetFullPath(shippingAddressInfo.RegionId, true); num = MemberProcessor.AddShippingAddress(shippingAddressInfo); } } } } this.Page.Response.Redirect("/SubmmitOrder.aspx?shippingId=" + num); }