public override string GetVideoUrl(VideoInfo video) { CookieContainer newCc = new CookieContainer(); foreach (Cookie c in cc.GetCookies(new Uri(@"https://www.filmon.com/"))) { newCc.Add(c); } NameValueCollection headers = new NameValueCollection(); headers.Add("Accept", "*/*"); headers.Add("User-Agent", userAgent); headers.Add("X-Requested-With", "XMLHttpRequest"); string webdata = GetWebData(video.VideoUrl, (string)video.Other, newCc, headers: headers); JToken jt = JObject.Parse(webdata) as JToken; JArray streams = jt.Value<JArray>("streams"); video.PlaybackOptions = new Dictionary<string, string>(); foreach (JToken stream in streams) { string serverUrl = stream.Value<string>("url"); RtmpUrl res = new RtmpUrl(serverUrl); res.Live = true; res.PlayPath = stream.Value<string>("name"); int p = serverUrl.IndexOf("live/?id"); res.App = serverUrl.Substring(p); video.PlaybackOptions.Add(stream.Value<string>("quality"), res.ToString()); } return video.PlaybackOptions.First().Value; }
public ActionResult API() { Stream filestream = null; if (Request.Files.Count > 0) { filestream = Request.Files[0].InputStream; } var pars = new NameValueCollection(); pars.Add(Request.Params); if (Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase)) { var parsKeys = pars.AllKeys; foreach (var key in Request.Form.AllKeys) { if (!parsKeys.Contains(key)) { pars.Add(Request.Form); } } } var res = getRuntime.DesignerAPI(pars, filestream, true); if (pars["operation"].ToLower() == "downloadscheme") { return File(Encoding.UTF8.GetBytes(res), "text/xml", "Scheme.xml"); } return Content(res); }
private void AccountPropertiesDialog_FormClosing( object sender, FormClosingEventArgs e ) { if( ctx == null || DialogResult != DialogResult.OK ) { return; } if( string.IsNullOrEmpty( textBox1.Text ) ) { MessageBox.Show( "Du måste ange ett namn" ); } _account = new Account { Name = textBox1.Text }; if( account != null ) { _account.ID = account.ID; } foreach( Control c in panel1.Controls ) { CheckBox cb = c as CheckBox; if( cb == null || !cb.Checked ) { continue; } User u = (User)cb.Tag; _account.PermittedUsers.Add( u.ID ); } NameValueCollection values = new NameValueCollection(); values.Add( "Name", _account.Name ); values.Add( "ID", _account.ID ); foreach( int uid in _account.PermittedUsers ) { values.Add( "userid", uid ); } _account = ctx.ServiceCaller.PostData<Account>( string.Format( "{0}/AccountService/Save", ctx.ServiceBaseURL ), values ); }
public async Task Valid_Code_Request() { var client = await _clients.FindClientByIdAsync("codeclient"); var store = new InMemoryAuthorizationCodeStore(); var code = new AuthorizationCode { Client = client, RedirectUri = "https://server/cb", RequestedScopes = new List<Scope> { new Scope { Name = "openid" } } }; await store.StoreAsync("valid", code); var validator = Factory.CreateTokenRequestValidator( authorizationCodeStore: store); var parameters = new NameValueCollection(); parameters.Add(Constants.TokenRequest.GrantType, Constants.GrantTypes.AuthorizationCode); parameters.Add(Constants.TokenRequest.Code, "valid"); parameters.Add(Constants.TokenRequest.RedirectUri, "https://server/cb"); var result = await validator.ValidateRequestAsync(parameters, client); result.IsError.Should().BeFalse(); }
public string SerializeParameters(string valueSeparator, string parameterSeparator) { System.Collections.Specialized.NameValueCollection nvc = new System.Collections.Specialized.NameValueCollection(); nvc.Add("id", new ID(Current.Context.ReportItem.Id).ToString()); foreach (var item in Current.Context.ReportItem.Scanners) { foreach (var p in item.Parameters) { nvc.Add(string.Concat(item.Id, valueSeparator, p.Name), p.Value); } } foreach (var item in Current.Context.ReportItem.Filters) { foreach (var p in item.Parameters) { nvc.Add(string.Concat(item.Id, valueSeparator, p.Name), p.Value); } } foreach (var item in Current.Context.ReportItem.Viewers) { foreach (var p in item.Parameters) { nvc.Add(string.Concat(item.Id, valueSeparator, p.Name), p.Value); } } return(Sitecore.StringUtil.NameValuesToString(nvc, parameterSeparator)); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("userName", this.txtUserName.Text); nameValueCollection.Add("shipTo", this.txtShipTo.Text); nameValueCollection.Add("dateStart", this.calendarStartDate.SelectedDate.ToString()); nameValueCollection.Add("dateEnd", this.calendarEndDate.SelectedDate.ToString()); nameValueCollection.Add("orderId", this.txtOrderId.Text); nameValueCollection.Add("siteId", ((int)this.sitesDropDownList.SelectedValue).ToString()); nameValueCollection.Add("orderSource", ((int)(OrderSource)System.Enum.Parse(typeof(OrderSource), this.ddlOrderSource.SelectedValue)).ToString()); nameValueCollection.Add("productName", this.txtProductName.Text); if (this.ddlSupplier.SelectedValue.HasValue) { nameValueCollection.Add("supplierId", this.ddlSupplier.SelectedValue.Value.ToString()); } //{ // "siteId", // ((int)this.sitesDropDownList.SelectedValue).ToString() // } if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString(System.Globalization.CultureInfo.InvariantCulture)); } base.ReloadPage(nameValueCollection); }
public Hashtable PostCanvasSISImport(string filename, string extension) { if(!validateSettings()){ // TODO I know null isn't the best response for this return type but if the settings aren't valid it shouldn't // work. What is a better return type? return null; }else{ string url = @"https://" + sub_domain + ".instructure.com/api/v1/accounts/"+account_id+"/sis_imports.json"; NameValueCollection nvc = new NameValueCollection(); nvc.Add("import_type","instructure_csv"); nvc.Add("access_token",access_token); nvc.Add("extension",extension); WebClient client = new WebClient(); client.QueryString = nvc; client.Headers.Add("Content-Type","application/x-www-form-urlencoded"); byte[] fileContents = System.IO.File.ReadAllBytes(filename); byte[] responseBinary = client.UploadData(url,"POST",fileContents); string response = Encoding.UTF8.GetString(responseBinary); Console.WriteLine("response: " + response); // return response; Hashtable json_response = returnJson(response); json_response["raw_response"] = response; return json_response; } }
private void RunIsoInBochs(string iso, string harddisk) { if (!File.Exists(harddisk)) { throw new FileNotFoundException("Harddisk file not found!", harddisk); } var xBochsConfig = Path.Combine(mBaseWorkingDirectory, "Kernel.bochsrc"); var xParams = new NameValueCollection(); xParams.Add("ISOFile", iso); xParams.Add(BuildPropertyNames.VisualStudioDebugPortString, "Pipe: Cosmos\\Serial"); xParams.Add(BuildPropertyNames.EnableBochsDebugString, RunWithGDB.ToString()); var xDebugConnector = new DebugConnectorPipeServer(DebugConnectorPipeServer.DefaultCosmosPipeName); InitializeDebugConnector(xDebugConnector); var xBochs = new Bochs(xParams, RunWithGDB, new FileInfo(xBochsConfig), harddisk); xBochs.OnShutDown = (a, b) => { }; xBochs.RedirectOutput = false; xBochs.LogError = s => OutputHandler.LogDebugMessage(s); xBochs.LogOutput = s => OutputHandler.LogDebugMessage(s); HandleRunning(xDebugConnector, xBochs); }
public static bool CallTaggingAPI(string tenant_id, string ts_invoice_no) { using (WebClient client = new WebClient()) { try { Globals.Log($"POST to {Globals.TAGGINGAPI}"); Globals.Log($"POST value1 {Globals.PARAM1}={Globals.ParamValue1}"); Globals.Log($"POST value2 {Globals.PARAM2}={Globals.ParamValue2}"); var reqparm = new System.Collections.Specialized.NameValueCollection(); reqparm.Add(Globals.PARAM1, tenant_id); reqparm.Add(Globals.PARAM2, ts_invoice_no); byte[] responsebytes = client.UploadValues(Globals.TAGGINGAPI, "POST", reqparm); string responsebody = Encoding.UTF8.GetString(responsebytes); //Globals.Log(responsebody); if (responsebody.Contains(Globals.APISUCCESS)) { return(true); } else { return(false); } } catch (Exception ex) { Globals.Log($"APIERR:{ex.Message}"); } return(false); } }
/// <summary> /// Has WSS parse the site vs. file/folder portion of a URL. /// </summary> /// <param name="uri"></param> /// <returns></returns> public WebUrl UrlToWebUrl(string url) { WebUrl webUrl = new WebUrl(); Uri aUri = new Uri(url); System.Collections.Specialized.NameValueCollection methodData = new System.Collections.Specialized.NameValueCollection(); methodData.Add("method", "url to web url"); methodData.Add("url", aUri.AbsolutePath); methodData.Add("flags", "0"); HttpWebRequest req = StartWebRequest(GetVtiRPC(aUri.AbsoluteUri), methodData); System.IO.Stream reqStream = req.GetRequestStream(); reqStream.Flush(); reqStream.Close(); string response = GetResponseString((HttpWebResponse)req.GetResponse()); string internalError = this.CheckForInternalErrorMessage(response); if (internalError != string.Empty) { throw new FrontPageRPCException(internalError, url); } else { webUrl.SiteUrl = aUri.GetLeftPart(System.UriPartial.Authority) + GetReturnValue(response, "webUrl"); webUrl.FileUrl = System.Web.HttpUtility.UrlDecode(GetReturnValue(response, "fileUrl")); } return(webUrl); }
/// <summary> /// Retrieves document meta-information. /// </summary> /// <param name="documentUrl"></param> /// <returns></returns> public DocumentInfo GetDocumentMetaInfo(string documentUrl) { try { WebUrl webUrl = UrlToWebUrl(documentUrl); System.Collections.Specialized.NameValueCollection methodData = new System.Collections.Specialized.NameValueCollection(); methodData.Add("method", "getDocsMetaInfo:" + GetServerExtensionsVersion(webUrl.SiteUrl)); methodData.Add("service_name", ""); methodData.Add("listHiddenDocs", "true"); methodData.Add("listLinkInfo", "true"); methodData.Add("url_list", "[" + webUrl.FileUrl + "]"); HttpWebRequest req = StartWebRequest(GetAuthorURL(webUrl.SiteUrl), methodData); System.IO.Stream reqStream = req.GetRequestStream(); reqStream.Flush(); reqStream.Close(); HttpWebResponse response = (HttpWebResponse)req.GetResponse(); System.IO.Stream responseStream = response.GetResponseStream(); System.IO.StreamReader sr = new StreamReader(responseStream); string responseData = sr.ReadToEnd(); DocumentInfo docInfo = ParseMetaInformationResponse(responseData); return(docInfo); } catch (Exception e) { throw new FrontPageRPCException("SetDocumentMetaInfo failed", documentUrl, e); } }
// Web Resource Access Protocol v0.9 compatible endpoint for issuing SWT tokens public ActionResult Wrap() { string name = Request.Form["wrap_name"]; string password = Request.Form["wrap_password"]; string scope = Request.Form["wrap_scope"]; string signingKey = "8YMtduGa+9B8MpSEIESXI0wuzvyspxJ1TGhSDlDvjSY="; if ((name == "robblackwell") && (password == "MyPassword") && (scope == "http://www.robblackwell.org.uk/")) { NameValueCollection claims = new NameValueCollection(); claims.Add("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", "robblackwell"); claims.Add("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "http://localhost:50865/"); SimpleWebToken swt = new SimpleWebToken("http://localhost:50865/", "http://www.robblackwell.org.uk/", 1331740071, claims); swt.Sign(signingKey); return Content( "wrap_access_token=" + swt.ToUrlEncodedString() + "&wrap_access_token_expires_in=600", "application/xml"); } else { Response.StatusCode = 401; // Unauthorized return null; } }
protected override NameValueCollection GetSubmittedValues() { NameValueCollection values = new NameValueCollection(); values.Add("LMDP_Spi", Profile.Login); values.Add("LMDP_Password", Profile.Password); return values; }
/// <summary> /// 查询商品数据 /// </summary> /// <param name="isSearch"></param> private void ReloadProductOnSales(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("poNumber", Globals.UrlEncode(this.txtPONumber.Text.Trim())); nameValueCollection.Add("hsInOut", Globals.UrlEncode(this.txtHSInOut.Text.Trim())); nameValueCollection.Add("supplierId", ddlSupplier.SelectedValue.ToString()); nameValueCollection.Add("pageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("startDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("endDate", this.calendarEndDate.SelectedDate.Value.ToString()); } nameValueCollection.Add("Status", this.ddlStatus.SelectedValue.ToString()); nameValueCollection.Add("QPStatus", this.ddlQPStatus.SelectedValue.ToString()); nameValueCollection.Add("CIStatus", this.ddlCIStatus.SelectedValue.ToString()); base.ReloadPage(nameValueCollection, false); }
public static NameValueCollection ToNameValueCollection(this object obj, object obj2 = null, bool overwrite = true) { var nv = new System.Collections.Specialized.NameValueCollection(); if (obj == null) { return(nv); } PropertyInfo[] properties = obj.GetType().GetProperties(); foreach (PropertyInfo p in properties) { nv.Add(p.Name, string.Format("{0}", p.GetValue(obj))); } if (obj2 != null) { PropertyInfo[] properties2 = obj2.GetType().GetProperties(); foreach (PropertyInfo p in properties2) { if (nv[p.Name] == null) { nv.Add(p.Name, string.Format("{0}", p.GetValue(obj2))); } else if (overwrite) { nv[p.Name] = string.Format("{0}", p.GetValue(obj2)); } } } return(nv); }
private static void SendInstallData(string error) { try { using (var client = new WebClient()) { var data = new NameValueCollection(); data.Add("error", error); data.Add("computername", SystemInformation.ComputerName); using (var mgmt = new ManagementClass("Win32_OperatingSystem")) { try { foreach (ManagementObject mgmtObj in mgmt.GetInstances()) { // Just get first value. data.Add("os", mgmtObj["Caption"].ToString().Trim()); break; } } catch { } var result = System.Text.Encoding.Default.GetString(client.UploadValues("http://www.filmkhoj.com/api/install", data)); } } } catch { } }
/// <summary> /// Explicitly refreshes the Google Auth Token. Usually not necessary. /// </summary> public void RefreshGoogleAuthToken() { string authUrl = "https://www.google.com/accounts/ClientLogin"; var data = new NameValueCollection(); data.Add("Email", this.androidSettings.SenderID); data.Add("Passwd", this.androidSettings.Password); data.Add("accountType", "GOOGLE_OR_HOSTED"); data.Add("service", "ac2dm"); data.Add("source", this.androidSettings.ApplicationID); var wc = new WebClient(); try { var authStr = Encoding.ASCII.GetString(wc.UploadValues(authUrl, data)); //Only care about the Auth= part at the end if (authStr.Contains("Auth=")) googleAuthToken = authStr.Substring(authStr.IndexOf("Auth=") + 5); else throw new GoogleLoginAuthorizationException("Missing Auth Token"); } catch (WebException ex) { var result = "Unknown Error"; try { result = (new System.IO.StreamReader(ex.Response.GetResponseStream())).ReadToEnd(); } catch { } throw new GoogleLoginAuthorizationException(result); } }
private string GetOutput(string res, string file_name) { try { WebClient client = new WebClient(); NameValueCollection form = new NameValueCollection(); form.Add("login", Properties.Settings.Default.login); form.Add("token", Properties.Settings.Default.api); form.Add(String.Format("file_ext[{0}]", file_name), Path.GetExtension(file_name)); form.Add(String.Format("file_name[{0}]", file_name),file_name ); form.Add(String.Format("file_contents[{0}]", file_name), res); byte[] responseData = client.UploadValues(API_URL, form); String s = Encoding.UTF8.GetString(responseData); System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex("\"repo\":\"(\\d+)\""); System.Text.RegularExpressions.Match m = r.Match(s); if(m.Success){ return String.Format("<script src=\"http://gist.github.com/{0}.js\"></script>", m.Groups[1].Value); } return null; } catch (Exception webEx) { Console.WriteLine(webEx.ToString()); } return null; }
public void CanNotSetInvalidFilter() { var query = new NameValueCollection(); query.Add("filter", "Robert'); drop table students; --"); // http://xkcd.com/327 query.Add("filtervalue", "::1"); new LogQuery(query); }
public void SchemaCheck() { for (int i = 0; i <= SchemaManager.Version; i++) { DropAllTables(); MySQLMembershipProvider provider = new MySQLMembershipProvider(); NameValueCollection config = new NameValueCollection(); config.Add("connectionStringName", "LocalMySqlServer"); config.Add("applicationName", "/"); config.Add("passwordFormat", "Clear"); if (i > 0) for (int x = 1; x <= i; x++) LoadSchema(x); try { provider.Initialize(null, config); if (i < SchemaManager.Version) Assert.Fail("Should have failed"); } catch (ProviderException) { if (i == SchemaManager.Version) Assert.Fail("This should not have failed"); } } }
public void Handling_namevaluecollection_forced_encryption_should_work() { /* Arrange */ var crypto = A.Fake<ICryptoProvider>(); A.CallTo(() => crypto.Encrypt(A<string>.Ignored)).ReturnsLazily(h => Convert.ToBase64String(Encoding.UTF8.GetBytes(h.Arguments[0].ToString()))); A.CallTo(() => crypto.Decrypt(A<string>.Ignored)).ReturnsLazily(h => Encoding.UTF8.GetString(Convert.FromBase64String(h.Arguments[0].ToString()))); A.CallTo(() => crypto.IsEncrypted(A<string>.Ignored)).Returns(true); var nv = new NameValueCollection(); nv.Add("PlainOne", "PlainTextOne"); nv.Add("PlainTwo", "PlainTextTwo"); var handler = new NameValueExtendedSectionHandler(); /* Act */ var node = handler.WriteSection("TestSection", nv, crypto, true); var result = handler.ReadSection(node, crypto, true) as NameValueSettings; var val1 = result.Get("PlainOne", null); var val2 = result.Get("PlainTwo", null); var allEncrypted = result.IsEncrypted("PlainOne") && result.IsEncrypted("PlainTwo"); /* Assert */ val1.Should().Be("PlainTextOne"); val2.Should().Be("PlainTextTwo"); allEncrypted.Should().BeTrue(); }
public static int GetReply(int chatID, string text, int replyToMessageID = -1, bool selective = false, string answerKeyboard = "") { string postURL = Roboto.Settings.telegramAPIURL + Roboto.Settings.telegramAPIKey + "/sendMessage"; var pairs = new NameValueCollection(); pairs.Add("chat_id", chatID.ToString()); pairs.Add("text", text); if (answerKeyboard == "") { pairs.Add("reply_markup","{\"force_reply\":true,\"selective\":" + selective.ToString().ToLower() + "}"); } else { pairs.Add("reply_markup" ,"{" + answerKeyboard + "}"); } if (replyToMessageID != -1) { pairs.Add("reply_to_message_id", replyToMessageID.ToString()); } //TODO - should URLEncode the text. try { JObject response = sendPOST(postURL,pairs); int messageID = response.SelectToken("result.message_id").Value<int>(); return messageID; } catch (WebException e) { Console.WriteLine("Couldnt send message to " + chatID.ToString() + " because " + e.ToString()); return -1; } //get the message ID }
public void ToQueryString() { var Collection = new NameValueCollection(); Collection.Add("A", "1"); Collection.Add("B", "2"); Assert.Equal("?A=1&B=2", Collection.ToQueryString()); }
public void UploadCaptha(Stream streamImage) { var up = new Uploading(); byte[] res; using (var stream = streamImage) { var files = new[] { new UploadFile { Name = "file", Filename = "captcha", ContentType = "image/jpeg", Stream = stream } }; var values = new NameValueCollection(); values.Add("method", "post"); values.Add("key", key); res = up.UploadFiles("http://antigate.com/in.php", files, values, ""); } string resText = ByteArrayToString(res); indexCaptha = InfoPage.GetDatafromText(resText, "\\d+"); }
public static void runUpload( ) { if (Properties.Settings.Default.firstrun) return; NameValueCollection postdata = new NameValueCollection(); postdata.Add("u", Properties.Settings.Default.username); postdata.Add("p", Properties.Settings.Default.password); if (!Clipboard.ContainsImage() && !Clipboard.ContainsText()) { nscrot.balloonText("No image or URL in clipboard!", 2); return; } if (!Clipboard.ContainsText()) { Image scrt = Clipboard.GetImage(); System.Threading.Thread upld = new System.Threading.Thread(( ) => { nscrot.uploadScreenshot(postdata, scrt); }); upld.SetApartmentState(System.Threading.ApartmentState.STA); upld.Start(); } else { string lURL = Clipboard.GetText(); System.Threading.Thread shrt = new System.Threading.Thread(( ) => { nscrot.shorten(lURL); }); shrt.SetApartmentState(System.Threading.ApartmentState.STA); shrt.Start(); } }
private void ReSearchProducts() { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection { { "productName", Globals.UrlEncode(this.txtSearchText.Text.Trim()) }, { "productCode", Globals.UrlEncode(Globals.HtmlEncode(this.txtSKU.Text.Trim())) }, { "pageSize", this.pager.PageSize.ToString() } }; if (this.dropLines.SelectedValue.HasValue) { nameValueCollection.Add("lineId", this.dropLines.SelectedValue.ToString()); } nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("startDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("endDate", this.calendarEndDate.SelectedDate.Value.ToString()); } base.ReloadPage(nameValueCollection); }
public override int Run(string[] remainingArguments) { using(var client = new WebClient()) { var postParameters = new NameValueCollection(); postParameters.Add("client_id", client_id); postParameters.Add("client_secret", client_secret); postParameters.Add("grant_type", "client_credentials"); var authResult = client.UploadValues("https://api.cheezburger.com/oauth/access_token", "POST", postParameters); var authResultText = new StreamReader(new MemoryStream(authResult), Encoding.UTF8).ReadToEnd(); var deserializedAuthResult = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(authResultText, new { access_token = "string", expires_in = 123, refresh_token = "string" }); var result = client.DownloadString("https://api.cheezburger.com/v1/ohai?access_token=" + deserializedAuthResult.access_token); Console.WriteLine(result); } return 0; }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var collection = new NameValueCollection(); while (reader.Read()) { if (reader.TokenType == JsonToken.EndObject) break; var key = (string)reader.Value; if (reader.Read() == false) throw new InvalidOperationException("Expected PropertyName, got " + reader.TokenType); if (reader.TokenType == JsonToken.StartArray) { var values = serializer.Deserialize<string[]>(reader); foreach (var value in values) { collection.Add(key, value); } } else { collection.Add(key, reader.Value.ToString()); } } return collection; }
public static NameValueCollection ConvertFromObject(object anonymous) { var nvc = new NameValueCollection(); var dict = new RouteValueDictionary(anonymous); foreach (var kvp in dict) { if (kvp.Value == null) { throw new NullReferenceException(kvp.Key); } if (kvp.Value.GetType().Name.Contains("Anonymous")) { var prefix = kvp.Key + "."; foreach (var innerkvp in new RouteValueDictionary(kvp.Value)) { nvc.Add(prefix + innerkvp.Key, innerkvp.Value.ToString()); } } else { nvc.Add(kvp.Key, kvp.Value.ToString()); } } return nvc; }
public void SetUp() { var config = new NameValueCollection(); config.Add("applicationName", "IntegrationTests"); config.Add("ldapServer", LdapServerInConfig); var ldapProvider = new LdapRoleProvider(); ldapProvider.Initialize("IntegrationTests", config); var enabledField = typeof(Roles).GetField("s_Enabled", BindingFlags.NonPublic | BindingFlags.Static); enabledField.SetValue(typeof(Roles), true); var initialized = typeof(Roles).GetField("s_Initialized", BindingFlags.NonPublic | BindingFlags.Static); initialized.SetValue(typeof(Roles), true); var providers = new RoleProviderCollection(); var readOnlyField = typeof(Roles).GetField("s_Providers", BindingFlags.NonPublic | BindingFlags.Static); readOnlyField.SetValue(typeof(Roles), providers); providers.Add(ldapProvider); var registeredProvider = Roles.Providers["IntegrationTests"]; Assert.IsNotNull(registeredProvider); provider = registeredProvider; }
public async Task Unknown_Grant_Type() { var client = await _clients.FindClientByIdAsync("codeclient"); var store = new InMemoryAuthorizationCodeStore(); var code = new AuthorizationCode { Client = client, IsOpenId = true, RedirectUri = new Uri("https://server/cb"), }; await store.StoreAsync("valid", code); var validator = Factory.CreateTokenValidator( authorizationCodeStore: store); var parameters = new NameValueCollection(); parameters.Add(Constants.TokenRequest.GrantType, "unknown"); parameters.Add(Constants.TokenRequest.Code, "valid"); parameters.Add(Constants.TokenRequest.RedirectUri, "https://server/cb"); var result = await validator.ValidateRequestAsync(parameters, client); Assert.IsTrue(result.IsError); Assert.AreEqual(Constants.TokenErrors.UnsupportedGrantType, result.Error); }
public Int32 Save(PortalChildColumnContent item, out ErrorEntity ErrInfo) { NameValueCollection where = new NameValueCollection(); where.Add("FChildColumnId", item.FChildColumnId.ToString()); Delete(where, out ErrInfo); if (ErrInfo.ErrorCode == RespCode.Success) { NameValueCollection parameters = new NameValueCollection(); parameters.Add("FChildColumnId", item.FChildColumnId.ToString()); parameters.Add("FCCContentText", item.FCCContentText); parameters.Add("FSEOTitle", item.FSEOTitle); parameters.Add("FSEOKeyWord", item.FSEOKeyWord); parameters.Add("FSEODescription", item.FSEODescription); Insert(parameters, out ErrInfo); if (ErrInfo.ErrorCode == RespCode.Success) { return 1; } else { return -1; } } else { return -1; } }
private void ReloadOrders(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("OrderId", this.txtOrderId.Text); nameValueCollection.Add("ShipTo", this.txtShopTo.Text); nameValueCollection.Add("PageSize", this.pager.PageSize.ToString()); nameValueCollection.Add("OrderStatus", this.lblStatus.Text); if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("StartDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("EndDate", this.calendarEndDate.SelectedDate.Value.ToString()); } if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["GroupBuyId"])) { nameValueCollection.Add("GroupBuyId", this.Page.Request.QueryString["GroupBuyId"]); } nameValueCollection.Add("StoreName", this.txtShopName.Text.Trim()); nameValueCollection.Add("DeleteBeforeState", this.ddrOrderStatus.SelectedValue); base.ReloadPage(nameValueCollection); }
public static void GitList(string hostname, string username, string password) { string sessionurl = "https://" + hostname + "/api/v3/session"; NameValueCollection values = new NameValueCollection(); values.Add("login", username); values.Add("password", password); string private_token = GetData(sessionurl, values).private_token; int page = 1; bool found; do { string projectsurl = "https://" + hostname + "/api/v3/projects?private_token=" + private_token + "&page=" + page; found = false; var results = GetData(projectsurl); foreach (var result in results) { Console.WriteLine(result.http_url_to_repo); found = true; } page++; } while (found); }
/// <summary> /// Overriding the Execute method that Sitecore calls. /// </summary> /// <param name = "context"></param> public override void Execute(CommandContext context) { if (context.Parameters["id"] == null || string.IsNullOrEmpty(context.Parameters["id"])) { return; } //only use on authoring environment Item currentItem = Sitecore.Context.ContentDatabase.GetItem(context.Parameters["id"]); if (currentItem == null) { return; } NameValueCollection nv = new NameValueCollection(); nv.Add("id", context.Parameters["id"]); Item item = Sitecore.Context.ContentDatabase.GetItem(context.Parameters["id"]); if (item.IsNull()) { return; } if (context.Parameters["fieldid"] != null) { nv.Add("fieldid", context.Parameters["fieldid"]); } nv.Add("la", item.Language.ToString()); nv.Add("vs", item.Version.ToString()); Sitecore.Context.ClientPage.Start(this, "ItemComparerForm", nv); }
public static void fun() { Console.WriteLine("检索文件"); Console.WriteLine("路径是:" + str); if (!str.EndsWith("\\")) { str += "\\"; } IList<FileInfo> lst = GetFiles(str); Console.WriteLine(string.Format("检索到{0}个文件", lst.Count)); foreach (var item in lst) { Uri url = new Uri(System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]); IList<HttpPost.UploadFile> files = new List<HttpPost.UploadFile>() { new HttpPost.UploadFile { ContentType = item.Extension, Data = System.IO.File.ReadAllBytes(item.FullName), Filename = item.Name, Name = item.FullName } }; NameValueCollection collection = new NameValueCollection(); collection.Add("filepath", GetServicePath(item.FullName)); collection.Add("type", item.Extension); collection.Add("name", item.Name); Console.WriteLine(string.Format("开始上传文件:{0}", item.FullName)); if (HttpPost.Post(url, files, collection)) { Console.WriteLine("文件上传完毕"); item.Delete(); Console.WriteLine("本地文件清楚完毕"); } } Console.WriteLine("本次任务执行完毕"); isUsing = true; }
public JsonResult ListAdvice(string title, string state, string language, string isvalid, int pagenumber, int pagesize) { NameValueCollection nvc = new NameValueCollection(); if (!string.IsNullOrEmpty(title)) { nvc.Add("title", title); } if (!string.IsNullOrEmpty(state)) { nvc.Add("state", state); } if (!string.IsNullOrEmpty(language)) { nvc.Add("language", language); } if (!string.IsNullOrEmpty(isvalid)) { nvc.Add("isvalid", isvalid); } NameValueCollection orderby = new NameValueCollection(); orderby.Add("title", "asc"); PageResult<AdviceInfo> pr = AdviceService.ListByCondition(nvc, orderby, pagenumber, pagesize); return Json(new JsonResultHelper(true, new JsonDataGridHelper<AdviceInfo>(pr.Data, pr.TotalRecords))); }
private NameValueCollection GetMessageAsNameValueCollection(PushoverMessage message) { var postData = new NameValueCollection() { {"token", _config.ApiToken}, {"user", message.User}, {"message", message.Message}, {"priority", message.Priority.ToString("D")}, {"sound", message.Sound.ToString("G").ToLower()} }; if (!string.IsNullOrWhiteSpace(message.Device)) postData.Add("device", message.Device); if (!string.IsNullOrWhiteSpace(message.Title)) postData.Add("title", message.Title); if (!string.IsNullOrWhiteSpace(message.Url)) postData.Add("url", message.Url); if (!string.IsNullOrWhiteSpace(message.UrlTitle)) postData.Add("url_title", message.UrlTitle); if (!string.IsNullOrWhiteSpace(message.TimeStamp)) postData.Add("timestamp", message.TimeStamp); return postData; }
public string InitiateTransaction(System.Collections.Specialized.NameValueCollection PostData, bool GetGateWayList = false) { PostData.Add("store_id", this.Store_ID); PostData.Add("store_passwd", this.Store_Pass); string response = this.SendPost(PostData); try { SSLCommerzInitResponse resp = JsonConvert.DeserializeObject <SSLCommerzInitResponse>(response); if (resp.status == "SUCCESS") { if (GetGateWayList) { // We will work on it! } else { return(resp.GatewayPageURL.ToString()); } } else { throw new Exception("Unable to get data from SSLCommerz. Please contact your manager!"); } } catch (Exception e) { throw new Exception(e.Message.ToString()); } return(response); }
private void ReSearchProducts() { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection { { "productName", Globals.UrlEncode(this.txtSearchText.Text.Trim()) }, { "productCode", Globals.UrlEncode(Globals.HtmlEncode(this.txtSKU.Text.Trim())) }, { "pageSize", this.pager.PageSize.ToString() }, { "includeOnSales", this.chkOnSales.Checked.ToString() }, { "includeUnSales", this.chkUnSales.Checked.ToString() }, { "includeInStock", this.chkInStock.Checked.ToString() }, { "isMakeTaobao", this.dpTaoBao.SelectedValue } }; if (this.dropCategories.SelectedValue.HasValue) { nameValueCollection.Add("categoryId", this.dropCategories.SelectedValue.ToString()); } if (this.dropLines.SelectedValue.HasValue) { nameValueCollection.Add("lineId", this.dropLines.SelectedValue.ToString()); } nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("startDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("endDate", this.calendarEndDate.SelectedDate.Value.ToString()); } base.ReloadPage(nameValueCollection); }
public bool RegisterUser(string username, string email, string password) { var data = new System.Collections.Specialized.NameValueCollection(); data.Add("username", username); data.Add("email", email); data.Add("password", password); return(!WebCommunication("register", data).error); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("dateStart", this.calendarStart.SelectedDate.ToString()); nameValueCollection.Add("dateEnd", this.calendarEnd.SelectedDate.ToString()); base.ReloadPage(nameValueCollection); }
public bool DeleteFriend(string username, string friendUsername) { var data = new System.Collections.Specialized.NameValueCollection(); data.Add("username", username); data.Add("friend_username", friendUsername); return(!WebCommunication("delete_friend", data).error); }
private static System.Collections.Specialized.NameValueCollection CreateNVCollection() { var n = new System.Collections.Specialized.NameValueCollection(); n.Add("new1", "value1"); n.Add("item2", null); n.Add("item3", "value3"); n.Add("item3", "value3"); return(n); }
private void statusList_SelectedIndexChanged(object sender, System.EventArgs e) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("MessageStatus", ((int)this.statusList.SelectedValue).ToString()); if (!string.IsNullOrEmpty(base.Request.QueryString["IsRead"])) { nameValueCollection.Add("IsRead", base.Request.QueryString["IsRead"]); } base.ReloadPage(nameValueCollection); }
private void ReloadProductOnSales(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("productName", Globals.UrlEncode(this.txtSearchText.Text.Trim())); if (this.dropCategories.SelectedValue.HasValue) { nameValueCollection.Add("categoryId", this.dropCategories.SelectedValue.ToString()); } if (this.dropLines.SelectedValue.HasValue) { nameValueCollection.Add("lineId", this.dropLines.SelectedValue.ToString()); } if (!string.IsNullOrEmpty(this.dpispub.SelectedValue)) { nameValueCollection.Add("ismaketaobao", this.dpispub.SelectedValue.ToString()); } nameValueCollection.Add("productCode", Globals.UrlEncode(Globals.HtmlEncode(this.txtSKU.Text.Trim()))); nameValueCollection.Add("pageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("startDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("endDate", this.calendarEndDate.SelectedDate.Value.ToString()); } base.ReloadPage(nameValueCollection); }
private void ReloadManagerLogs(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("OperationUserName", this.dropOperationUserNames.SelectedValue); if (this.lastDay > 0) { nameValueCollection.Add("FromDate", this.FromDate); nameValueCollection.Add("ToDate", this.ToDate); } else { if (this.calFromDate.SelectedDate.HasValue) { nameValueCollection.Add("FromDate", this.calFromDate.SelectedDate.Value.ToString("yyyy-MM-dd")); } if (this.calToDate.SelectedDate.HasValue) { nameValueCollection.Add("ToDate", this.calToDate.SelectedDate.Value.ToString("yyyy-MM-dd")); } } if (!isSearch) { nameValueCollection.Add("PageIndex", this.pager.PageIndex.ToString()); } nameValueCollection.Add("SortOrder", SortAction.Desc.ToString()); nameValueCollection.Add("PageSize", this.pager.PageSize.ToString()); nameValueCollection.Add("lastDay", this.lastDay.ToString()); base.ReloadPage(nameValueCollection); }
private void ReloadRefunds(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("OrderId", this.txtOrderId.Text); nameValueCollection.Add("PageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (!string.IsNullOrEmpty(this.Page.Request.QueryString["GroupBuyId"])) { nameValueCollection.Add("GroupBuyId", this.Page.Request.QueryString["GroupBuyId"]); } if (!string.IsNullOrEmpty(this.ddlHandleStatus.SelectedValue)) { nameValueCollection.Add("HandleStatus", this.ddlHandleStatus.SelectedValue); } if (this.ddlSupplier.SelectedIndex > 0) { nameValueCollection.Add("SupplierId", this.ddlSupplier.SelectedValue.ToString()); } nameValueCollection.Add("StartTime", this.calendarStartDate.Text); nameValueCollection.Add("EndtTime", this.calendarEndDate.Text); nameValueCollection.Add("Operator", this.txtHandler.Text); base.ReloadPage(nameValueCollection); }
private void ReloadProductOnSales(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("productName", Globals.UrlEncode(this.txtSearchText.Text.Trim())); if (this.dropCategories.SelectedValue.HasValue) { nameValueCollection.Add("categoryId", this.dropCategories.SelectedValue.ToString()); } nameValueCollection.Add("productCode", Globals.UrlEncode(Globals.HtmlEncode(this.txtSKU.Text.Trim()))); nameValueCollection.Add("pageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (this.dropBrandList.SelectedValue.HasValue) { nameValueCollection.Add("brandId", this.dropBrandList.SelectedValue.ToString()); } if (this.dropType.SelectedValue.HasValue) { nameValueCollection.Add("typeId", this.dropType.SelectedValue.ToString()); } if (this.ddlImportSourceType.SelectedValue.HasValue) { nameValueCollection.Add("importSourceId", this.ddlImportSourceType.SelectedValue.ToString()); } if (this.ddlSupplier.SelectedValue.HasValue) { nameValueCollection.Add("supplierId", this.ddlSupplier.SelectedValue.ToString()); } base.ReloadPage(nameValueCollection); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("searchKey", Globals.UrlEncode(this.txtSearchText.Text.Trim())); if (this.dropCategories.SelectedValue.HasValue) { nameValueCollection.Add("categoryId", this.dropCategories.SelectedValue.ToString()); } if (this.dropType.SelectedValue.HasValue) { nameValueCollection.Add("typeId", this.dropType.SelectedValue.ToString()); } if (this.dropBrandList.SelectedValue.HasValue) { nameValueCollection.Add("brandId", this.dropBrandList.SelectedValue.ToString()); } nameValueCollection.Add("pageSize", this.pager.PageSize.ToString(System.Globalization.CultureInfo.InvariantCulture)); if (!string.IsNullOrEmpty(this.txtSKU.Text.Trim())) { nameValueCollection.Add("productCode", this.txtSKU.Text.Trim()); } if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString(System.Globalization.CultureInfo.InvariantCulture)); } if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("startDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("endDate", this.calendarEndDate.SelectedDate.Value.ToString()); } base.ReloadPage(nameValueCollection); }
public static void logUserAccess() { NameValueCollection values = Configurator.GetConfig("globals"); string APIServiceActive = values["APIServiceActive"] ?? "False"; if (APIServiceActive != "True") { //don't do anything return; } //log the user, client, institution, machine name, ip address, etc. to the Registration Server database //by doing a RESTful POST with all relevant info string APIPostUserLogURL = values["APIPostUserLogURL"] ?? "None"; if (APIPostUserLogURL == "None") { return; } try { using (TimedWebClient client = new TimedWebClient(5000)) //wait at most 5 seconds for a response { System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection(); RiskApps3.Model.MetaData.User u = RiskApps3.Controllers.SessionManager.Instance.ActiveUser; reqparm.Add("user_login", u.User_userLogin); reqparm.Add("user_fullname", u.User_userFullName); reqparm.Add("ntUser", getNTUser()); reqparm.Add("machine_name", Environment.MachineName); reqparm.Add("os_version", Environment.OSVersion.ToString()); //Add other desired params here // even something like this works: // reqparm.Add("param1", "<any> kinds & of = ? strings"); // //params must be compatible with node service code (currently 'hello.js'), sp_3_Insert_UserLog, and tblUserLog byte[] responsebytes = client.UploadValues(APIPostUserLogURL, "POST", reqparm); string responsebody = Encoding.UTF8.GetString(responsebytes); //Console.WriteLine(responsebody); //TODO: Verify response is as expected if (!responsebody.Contains("HRA registration server got your data!")) { Logger.Instance.WriteToLog("[RegistrationService] at URL " + APIPostUserLogURL + " did not send the standard expected response."); return; } } } catch (Exception e) { Logger.Instance.WriteToLog("[RegistrationService] could not connect to URL " + APIPostUserLogURL + ":\n\t" + e.Message); return; } }
private void ReloadProductOnSales(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("shareId", this.shareId.ToString()); nameValueCollection.Add("productName", Globals.UrlEncode(this.txtSearchText.Text.Trim())); if (this.dropCategories.SelectedValue.HasValue) { nameValueCollection.Add("categoryId", this.dropCategories.SelectedValue.ToString()); } nameValueCollection.Add("pageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (this.dropBrandList.SelectedValue.HasValue) { nameValueCollection.Add("brandId", this.dropBrandList.SelectedValue.ToString()); } if (this.dropTagList.SelectedValue.HasValue) { nameValueCollection.Add("tagId", this.dropTagList.SelectedValue.ToString()); } if (this.dropType.SelectedValue.HasValue) { nameValueCollection.Add("typeId", this.dropType.SelectedValue.ToString()); } nameValueCollection.Add("isAlert", this.chkIsAlert.Checked.ToString()); base.ReloadPage(nameValueCollection); }
private void ReloadProductOnSales(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("productName", Globals.UrlEncode(this.txtSearchText.Text.Trim())); if (this.dropCategories.SelectedValue.HasValue) { nameValueCollection.Add("categoryId", this.dropCategories.SelectedValue.ToString()); } nameValueCollection.Add("productCode", Globals.UrlEncode(Globals.HtmlEncode(this.txtSKU.Text.Trim()))); nameValueCollection.Add("pageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } if (this.calendarStartDate.SelectedDate.HasValue) { nameValueCollection.Add("startDate", this.calendarStartDate.SelectedDate.Value.ToString()); } if (this.calendarEndDate.SelectedDate.HasValue) { nameValueCollection.Add("endDate", this.calendarEndDate.SelectedDate.Value.ToString()); } if (this.dropBrandList.SelectedValue.HasValue) { nameValueCollection.Add("brandId", this.dropBrandList.SelectedValue.ToString()); } nameValueCollection.Add("SaleStatus", "2"); base.ReloadPage(nameValueCollection); }
private void ReloadHelpList(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); if (!isSearch) { nameValueCollection.Add("PageIndex", this.pager.PageIndex.ToString()); } nameValueCollection.Add("PageSize", this.pager.PageSize.ToString()); nameValueCollection.Add("SortOrder", SortAction.Desc.ToString()); base.ReloadPage(nameValueCollection); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("searchKey", this.txtSearchText.Text); nameValueCollection.Add("pageSize", "10"); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString(System.Globalization.CultureInfo.InvariantCulture)); } base.ReloadPage(nameValueCollection); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("dateStart", this.calendarStartDate.SelectedDate.ToString()); nameValueCollection.Add("dateEnd", this.calendarEndDate.SelectedDate.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString(System.Globalization.CultureInfo.InvariantCulture)); } base.ReloadPage(nameValueCollection); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("startTime", this.calendarStart.SelectedDate.ToString()); nameValueCollection.Add("endTime", this.calendarEnd.SelectedDate.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } base.ReloadPage(nameValueCollection); }
private void ReloadGiftsList(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("GiftName", Globals.HtmlEncode(this.txtSearchText.Text.Trim())); nameValueCollection.Add("pageSize", this.hrefPageSize.SelectedSize.ToString()); if (!isSearch) { nameValueCollection.Add("PageIndex", this.pager.PageIndex.ToString()); } base.ReloadPage(nameValueCollection); }
private void ReBind(bool isSearch) { System.Collections.Specialized.NameValueCollection nameValueCollection = new System.Collections.Specialized.NameValueCollection(); nameValueCollection.Add("searchKey", this.txtUserName.Text); nameValueCollection.Add("realName", this.txtRealName.Text); nameValueCollection.Add("pageSize", this.pager.PageSize.ToString()); if (!isSearch) { nameValueCollection.Add("pageIndex", this.pager.PageIndex.ToString()); } base.ReloadPage(nameValueCollection); }
public void CanAddQueryParametersFromNameValueCollectionWithRepeatedKeys() { // Arrange Uri url1 = new Uri("http://dr.dk"); Uri url2 = new Uri("http://dr.dk?x=john&y=wide"); NameValueCollection p = new NameValueCollection(); p["x"] = "1"; p.Add("y", "hello"); p.Add("y", "world"); // Act url1 = url1.AddQueryParameters(p); url2 = url2.AddQueryParameters(p); // Assert NameValueCollection pcoll1 = HttpUtility.ParseQueryString(url1.Query); NameValueCollection pcoll2 = HttpUtility.ParseQueryString(url2.Query); Assert.AreEqual(2, pcoll1.Count); Assert.AreEqual("1", pcoll1["x"]); Assert.AreEqual("hello,world", pcoll1["y"]); Assert.AreEqual(2, pcoll2.Count); Assert.AreEqual("john,1", pcoll2["x"]); Assert.AreEqual("wide,hello,world", pcoll2["y"]); }