GetKey() public method

public GetKey ( int index ) : String
index int
return String
Beispiel #1
0
        public static BootstrapperOptions ParseArgumentsAndConfigurations(IEnumerable<string> arguments, NameValueCollection appSettings, IDictionary envVariables)
        {
            var options = new BootstrapperOptions();

            var commandArgs = arguments.ToList();

            if (commandArgs.Contains(CommandArgs.PreferNuget) || appSettings.GetKey(AppSettingKeys.PreferNugetAppSettingsKey).ToLowerSafe() == "true")
            {
                options.PreferNuget = true;
                commandArgs.Remove(CommandArgs.PreferNuget);
            }
            if (commandArgs.Contains(CommandArgs.ForceNuget) || appSettings.GetKey(AppSettingKeys.ForceNugetAppSettingsKey).ToLowerSafe() == "true")
            {
                options.ForceNuget = true;
                commandArgs.Remove(CommandArgs.ForceNuget);
            }
            if (commandArgs.Contains(CommandArgs.Silent))
            {
                options.Silent = true;
                commandArgs.Remove(CommandArgs.Silent);
            }
            if (commandArgs.Contains(CommandArgs.Help))
            {
                options.ShowHelp = true;
                commandArgs.Remove(CommandArgs.Help);
            }

            commandArgs = EvaluateDownloadOptions(options.DownloadArguments, commandArgs, appSettings, envVariables).ToList();

            options.UnprocessedCommandArgs = commandArgs;
            return options;
        }
        public void CustomHashProviderDataTest()
        {
            try
            {
                string name = "testName2";
                Type type = typeof(CustomHashProviderNodeFixture);
                NameValueCollection attributes = new NameValueCollection();
                attributes.Add("test", "value");

                CustomHashProviderData data = new CustomHashProviderData();
                data.Name = name;
                data.Type = type;
                data.Attributes.Add(attributes.GetKey(0), attributes[attributes.GetKey(0)]);

                CustomHashProviderNode node = new CustomHashProviderNode(data);
                ApplicationNode.AddNode(node);
                Assert.AreEqual(name, node.Name);
                Assert.AreEqual(type, node.Type);

                Assert.AreEqual(attributes.AllKeys[0], node.Attributes[0].Key);
                Assert.AreEqual(attributes.Get(0), node.Attributes[0].Value);
            }
            finally
            {
                File.Delete("KeyedHashKey.file");
            }
        }
Beispiel #3
0
        /// <summary>
        /// 将键值集合转换成get url字符串
        /// </summary>
        /// <param name="Palist">键值集合</param>
        /// <param name="key">需要排除的key值</param>
        /// <returns>返回返回string字符串(格式:a=a&b=b&c=c)</returns>
        public static string GetStrNvNotKey(System.Collections.Specialized.NameValueCollection Palist, string key)
        {
            string str = "";

            if (string.IsNullOrEmpty(key))
            {
                for (int i = 0; i < Palist.Count; i++)
                {
                    str += Palist.GetKey(i) + "=" + Palist.Get(i) + "&";
                }
            }
            else
            {
                for (int k = 0; k < Palist.Count; k++)
                {
                    if (Palist.GetKey(k) != key)
                    {
                        str += Palist.GetKey(k) + "=" + Palist.Get(k) + "&";
                    }
                }
            }
            str = str.Substring(0, str.Length - 1);

            return(str);
        }
        public void CustomCacheStorageNodeTest()
        {
            string name = "testName1";
            Type type = typeof(CustomCacheStorageData);
            NameValueCollection attributes = new NameValueCollection();
            attributes.Add("test", "value");

            CustomCacheStorageNode node = new CustomCacheStorageNode();
            ApplicationNode.AddNode(node);
            Assert.AreEqual("Cache Storage", node.Name);

            node.Type = type;
            node.Name = name;
            node.Attributes.Add( new EditableKeyValue(attributes.GetKey(0), attributes[attributes.GetKey(0)]));

            Assert.AreEqual(attributes[0], node.Attributes[0].Value);
            Assert.AreEqual(type, node.Type);
            Assert.AreEqual(name, node.Name);

            CustomCacheStorageData nodeData = (CustomCacheStorageData)node.CacheStorageData;
            Assert.AreEqual(name, nodeData.Name);
            Assert.AreEqual(type, nodeData.Type);
            Assert.AreEqual(attributes.AllKeys[0], nodeData.Attributes.AllKeys[0]);
            Assert.AreEqual(attributes.Get(0), nodeData.Attributes.Get(0));

        }
        public void CustomSymmetricCryptoProviderNodeTest()
        {
            Type type = typeof(CustomSymmetricCryptoProviderNodeFixture);
            string name = "some name";
            NameValueCollection attributes = new NameValueCollection();
            attributes.Add("Test", "Value");

            CustomSymmetricCryptoProviderNode node = new CustomSymmetricCryptoProviderNode();
            ApplicationNode.AddNode(node);
            Assert.AreEqual("Custom Symmetric Cryptography Provider", node.Name);

            node.Name = name;
            node.Type = type;
            node.Attributes.Add(new EditableKeyValue(attributes.GetKey(0), attributes[attributes.GetKey(0)]));

            Assert.AreEqual(attributes[0], node.Attributes[0].Value);
            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.Type);

            CustomSymmetricCryptoProviderData data = (CustomSymmetricCryptoProviderData)node.SymmetricCryptoProviderData;
            Assert.AreEqual(name, data.Name);
            Assert.AreEqual(type, data.Type);
            Assert.AreEqual(attributes.AllKeys[0], data.Attributes.AllKeys[0]);
            Assert.AreEqual(attributes.Get(0), data.Attributes.Get(0));
        }
        private static void CreateJavaScriptEventObject(StringBuilder scriptCode, NameValueCollection eventObjectProperties)
        {
            if (eventObjectProperties == null) return;

            for (var index = 0; index < eventObjectProperties.Count; index++)
            {
                if (eventObjectProperties.GetKey(index) == "charCode") continue;

                scriptCode.Append("newEvt.");
                scriptCode.Append(eventObjectProperties.GetKey(index));
                scriptCode.Append(" = ");
                scriptCode.Append(eventObjectProperties.GetValues(index)[0]);
                scriptCode.Append(";");
            }
        }
Beispiel #7
0
 public void PostMethod(string url, NameValueCollection prms)
 {
     string req = "";
     for (int i = 0; i < prms.Count; i++)
     {
         if (i == 0)
             req += prms.GetKey(i) + "=" + Utility.URLEncode(prms.GetValues(i).GetValue(0).ToString());
         else
             req += "&" + prms.GetKey(i) + "=" + Utility.URLEncode(prms.GetValues(i).GetValue(0).ToString());
     }
     if (authObject != null)
         this.Navigate(url, null, ASCIIEncoding.ASCII.GetBytes(req), (string)authObject);
     else
         this.Navigate(url, null, ASCIIEncoding.ASCII.GetBytes(req), null);
 }
Beispiel #8
0
        public static string CreateURI(string strScheme, string strHost, string strPath, NameValueCollection queryColl)
        {
            bool bFirst = true;
             string strURI = strScheme + "://" + strHost + "/";
             if (!String.IsNullOrEmpty(strPath))
            strURI += strPath;

             string strQuery = String.Empty;
             if (queryColl != null)
             {
            for (int i = 0; i < queryColl.Count; i++)
            {
               if (!bFirst)
                  strQuery += "&";
               else
                  bFirst = false;

               strQuery += queryColl.GetKey(i) + "=" + HttpUtility.UrlEncode(queryColl.Get(i));
            }
             }

             if (strQuery != String.Empty)
            strURI += "?" + strQuery;

             return strURI;
        }
Beispiel #9
0
 private void SetUrlParams(NameValueCollection getCollection)
 {
     if (this.rdSignView.Checked)
     {
         try
         {
             getCollection.Add(SecuritySignHelper.PartnerId, this.txtPartner.Text.Trim());
         }
         catch
         {
             getCollection[SecuritySignHelper.PartnerId] = this.txtPartner.Text.Trim();
         }
         try
         {
             getCollection.Add(SecuritySignHelper.ApiSign, this.txtSign.Text.Trim());
         }
         catch
         {
             getCollection[SecuritySignHelper.ApiSign] = this.txtSign.Text.Trim();
         }
     }
     StringBuilder tmp = new StringBuilder();
     for (int i = 0; i < getCollection.Count; i++)
     {
         tmp.Append('&');
         tmp.Append(getCollection.GetKey(i));
         tmp.Append('=');
         tmp.Append(getCollection[i]);
     }
     tmp.Remove(0, 1);
     this.txtUrlParams.Text = tmp.ToString();
 }
Beispiel #10
0
        /// <summary>
        /// Posts the supplied data to specified url.
        /// </summary>
        /// <param name="url">The url to post to.</param>
        /// <param name="values">The values to post.</param>
        /// <returns>a string containing the result of the post.</returns>
        public static string DoHttpPost(string url, NameValueCollection values)
        {
            StringBuilder postData = new StringBuilder();
            for (int i = 0; i < values.Count; i++)
            {
                EncodeAndAddItem(ref postData, values.GetKey(i), values[i]);
            }
            HttpWebRequest request = null;
            Uri uri = new Uri(url);
            request = (HttpWebRequest) WebRequest.Create(uri);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = postData.Length;
            using (Stream writeStream = request.GetRequestStream())
            {
                UTF8Encoding encoding = new UTF8Encoding();
                byte[] bytes = encoding.GetBytes(postData.ToString());
                writeStream.Write(bytes, 0, bytes.Length);
            }

            string result = string.Empty;
            using (HttpWebResponse response = (HttpWebResponse) request.GetResponse())
            {
                using (Stream responseStream = response.GetResponseStream())
                {
                    using (StreamReader readStream = new StreamReader(responseStream, Encoding.UTF8))
                    {
                        result = readStream.ReadToEnd();
                    }
                }
            }
            return result;
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "GenericServicesProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Generic Service Host Provider");
            }

            base.Initialize(name, config);

            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException("Unrecognized attribute: " + attr);
                }
            }
        }
        public override void Initialize(string name, NameValueCollection attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException("attributes");
            }
            if (string.IsNullOrEmpty(name))
            {
                name = "MvcSitemapProvider";
            }

            if (string.IsNullOrEmpty(attributes["description"]))
            {
                attributes.Remove("description");
                attributes.Add("description", "MVC site map provider");
            }
            base.Initialize(name,attributes);

           
            if (attributes.Count > 0)
            {
                string attr = attributes.GetKey(0);
                if (!string.IsNullOrEmpty(attr))
                    throw new ProviderException(string.Format(
                      "Unrecognized attribute: {0}", attr));
            }
        }
Beispiel #13
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "SenseNetPersonalizationProvider";
            }

            if (String.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SenseNet Personalization Provider");
            }

            base.Initialize(name, config);

            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException("Unrecognized attribute: " + attr);
                }
            }
        }
        // MembershipProvider Methods
        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "AtlassianMembershipProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "Atlassian web service membership provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            using (IUnityContainer container = new UnityContainer()
                .LoadConfiguration())
            {
                service = container.Resolve<IProjectsService>();
            }

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException("Unrecognized attribute: " + attr);
            }
        }
Beispiel #15
0
    public override string ArgName(int kind, int ix)
    {
        string a = "";

        switch (kind)
        {
        case QueryString:
            var c = Ctx.Request.QueryString;
            if (ix < c.Count)
            {
                a = c.GetKey(ix);
            }
            break;

        case FormString:
            if (Form != null && ix < Form.Count)
            {
                a = Form.GetKey(ix);
            }
            break;

        case Cookie:
            if (ix < CookieNames.Count)
            {
                a = CookieNames[ix];
            }
            break;
        }
        return(a == null ? "" : a);
    }
        /// <summary>
        /// Initializes the provider with the property values specified in the application's configuration file. This method is not intended to be used directly from your code
        /// </summary>
        /// <param name="name">The name of the provider instance to initialize</param>
        /// <param name="config">A NameValueCollection that contains the names and values of configuration options for the provider.</param>
        public override void Initialize(string name, NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            base.Initialize(name, config);

            string connectionStringName = config["connectionStringName"];
            if (String.IsNullOrEmpty(connectionStringName))
                throw new ProviderException("Connection name not specified");
            this._sqlConnectionString = NopSqlDataHelper.GetConnectionString(connectionStringName);
            if ((this._sqlConnectionString == null) || (this._sqlConnectionString.Length < 1))
            {
                throw new ProviderException(string.Format("Connection string not found. {0}", connectionStringName));
            }
            config.Remove("connectionStringName");

            if (config.Count > 0)
            {
                string key = config.GetKey(0);
                if (!string.IsNullOrEmpty(key))
                {
                    throw new ProviderException(string.Format("Provider unrecognized attribute. {0}", new object[] { key }));
                }
            }
        }
        public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
                throw new ArgumentNullException("config");

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
                name = "ClassroomProvider";

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "SQL Account provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);
         
            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                    throw new ProviderException
                        ("Unrecognized attribute: " + attr);
            }
        }
Beispiel #18
0
 static void Main(string[] args)
 {
     // Create an empty NameValueCollection and add multiple values for each key.
     NameValueCollection nvCol = new NameValueCollection();
     nvCol.Add("Minnesota", "St. Paul");
     nvCol.Add("Minnesota", "Minneapolis");
     nvCol.Add("Minnesota", "Rochester");
     nvCol.Add("Florida", "Miami");
     nvCol.Add("Florida", "Orlando");
     nvCol.Add("Arizona", "Pheonix");
     nvCol.Add("Arizona", "Tucson");
     // Get the key at index position 0 (Minnesota).
     string key = nvCol.GetKey(0);
     Console.WriteLine("Key 0: {0}", key);
     // Remove the entry for Minnesota by its key.
     nvCol.Remove(key);
     // Get the values for Florida as a string array.
     foreach (string val in nvCol.GetValues("Florida"))
     {
         Console.WriteLine("A value for 'Florida': {0}", val);
     }
     // Iterate through the entries (Florida and Arizona) in the NameValueCollection.
     foreach (string k in nvCol)
     {
         // Get the values for an entry as a comma-separated list.
         Console.WriteLine("Key: {0} Values: {1}", k, nvCol.Get(k));
     }
 }
Beispiel #19
0
        public ActionResult AddSubmit(String ParentID)
        {
            if (BaoMat.ChoPhepLamViec(User.Identity.Name, "KT_TuDien", "Edit") == false)
            {
                return RedirectToAction("Index", "PermitionMessage");
            }
            NameValueCollection arrLoi = new NameValueCollection();
            String iID_MaTaiKhoanGoc = Convert.ToString(Request.Form[ParentID + "_iID_MaTaiKhoanGoc"]);
            if ((iID_MaTaiKhoanGoc == "" || iID_MaTaiKhoanGoc == Convert.ToString(Guid.Empty)))
            {
                arrLoi.Add("err_iID_MaTaiKhoan", "Bạn phải chọn tài khoản gốc");
            }
            if (arrLoi.Count > 0)
            {
                for (int i = 0; i <= arrLoi.Count - 1; i++)
                {
                    ModelState.AddModelError(ParentID + "_" + arrLoi.GetKey(i), arrLoi[i]);
                }

                return RedirectToAction("Index", "TuDien");
            }
            else
            {
                return RedirectToAction("Edit", "TuDien", new { iID_MaTaiKhoanGoc = iID_MaTaiKhoanGoc });
            }
        }
        public override void Initialize(string name, NameValueCollection config){
            if (String.IsNullOrEmpty(name))
                name = "WindowsTokenProvider";
            if (string.IsNullOrEmpty(config["description"])) {
                config.Remove("description");
                config.Add("description", SR.GetString(SR.RoleWindowsTokenProvider_description));
            }
            base.Initialize(name, config);

            if (config == null)
               throw new ArgumentNullException("config");
            _AppName = config["applicationName"];
            if (string.IsNullOrEmpty(_AppName))
                _AppName = SecUtility.GetDefaultAppName();

            if( _AppName.Length > 256 )
            {
                throw new ProviderException(SR.GetString(SR.Provider_application_name_too_long));
            }

            config.Remove("applicationName");
            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                    throw new ProviderException(SR.GetString(SR.Provider_unrecognized_attribute, attribUnrecognized));
            }
        }
Beispiel #21
0
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("Config is null");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "UmbracoSiteMapProvider";
            }

            if (!String.IsNullOrEmpty(config["defaultDescriptionAlias"]))
            {
                m_defaultDescriptionAlias = config["defaultDescriptionAlias"].ToString();
                config.Remove("defaultDescriptionAlias");
            }
            if (config["securityTrimmingEnabled"] != null)
            {
                m_enableSecurityTrimming = bool.Parse(config["securityTrimmingEnabled"]);
            }

            base.Initialize(name, config);

            // Throw an exception if unrecognized attributes remain
            if (config.Count > 0)
            {
                string attr = config.GetKey(0);
                if (!String.IsNullOrEmpty(attr))
                {
                    throw new ProviderException
                              (String.Format("Unrecognized attribute: {0}", attr));
                }
            }
        }
Beispiel #22
0
        public virtual MARC.HI.EHRS.CR.Messaging.FHIR.Util.DataUtil.ClientRegistryFhirQuery ParseQuery(System.Collections.Specialized.NameValueCollection parameters, List <Everest.Connectors.IResultDetail> dtls)
        {
            MARC.HI.EHRS.CR.Messaging.FHIR.Util.DataUtil.ClientRegistryFhirQuery retVal = new Util.DataUtil.ClientRegistryFhirQuery();
            retVal.ActualParameters   = new System.Collections.Specialized.NameValueCollection();
            retVal.MinimumDegreeMatch = 0.8f;
            int  page      = 0;
            bool hasFormat = false;

            for (int i = 0; i < parameters.Count; i++)
            {
                try
                {
                    switch (parameters.GetKey(i))
                    {
                    case "stateid":
                    case "_stateid":
                        try
                        {
                            retVal.QueryId = Guid.Parse(parameters.GetValues(i)[0]);
                            retVal.ActualParameters.Add("stateid", retVal.QueryId.ToString());
                        }
                        catch (Exception e)
                        {
                            dtls.Add(new ResultDetail(ResultDetailType.Error, "State identifiers must be issued from the registry and must be a valid GUID", null, e));
                        }
                        break;

                    case "count":
                    case "_count":      // TODO: CP
                        retVal.Quantity = Int32.Parse(parameters.GetValues(i)[0]);
                        retVal.ActualParameters.Add("count", retVal.Quantity.ToString());
                        break;

                    case "page":
                    case "_page":
                        page = Int32.Parse(parameters.GetValues(i)[0]);
                        retVal.ActualParameters.Add("page", page.ToString());
                        break;

                    case "_format":
                        hasFormat = true;
                        //retVal.ActualParameters.Add("_format", parameters.GetValues(i)[0]);
                        break;
                    }
                }
                catch (Exception e)
                {
                    Trace.TraceError(e.ToString());
                    dtls.Add(new ResultDetail(ResultDetailType.Error, e.Message, e));
                }
            }

            //if (!hasFormat)
            //    throw new InvalidOperationException("Missing _format parameter");

            retVal.Start = page * retVal.Quantity;

            return(retVal);
        }
		IDataProvider IDataProviderFactory.GetDataProvider(NameValueCollection attributes)
		{
			for (var i = 0; i < attributes.Count; i++)
				if (attributes.GetKey(i) == "assemblyName")
					OracleTools.AssemblyName = attributes.Get(i);

			return new OracleDataProvider();
		}
Beispiel #24
0
        IDataProvider IDataProviderFactory.GetDataProvider(NameValueCollection attributes)
        {
            for (var i = 0; i < attributes.Count; i++)
                if (attributes.GetKey(i) == "assemblyName")
                    AssemblyName = attributes.Get(i);

            return _sybaseDataProvider;
        }
        public void CustomSymmetricCryptoProviderDataTest()
        {
            Type type = typeof(CustomSymmetricCryptoProviderNodeFixture);
            string name = "some name";
            NameValueCollection attributes = new NameValueCollection();
            attributes.Add("test", "value");

            CustomSymmetricCryptoProviderData data = new CustomSymmetricCryptoProviderData();
            data.Name = name;
            data.Type = type;
            data.Attributes.Add(attributes.GetKey(0), attributes[attributes.GetKey(0)]);

            CustomSymmetricCryptoProviderNode node = new CustomSymmetricCryptoProviderNode(data);
            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.Type);
            Assert.AreEqual(attributes.AllKeys[0], node.Attributes[0].Key);
            Assert.AreEqual(attributes.Get(0), node.Attributes[0].Value);
        }
 public void Parse(NameValueCollection parameters)
 {
     for (var i = 0; i < parameters.Count; ++i)
     {
         var name = parameters.GetKey(i).ToLower();
         var value = parameters.Get(i);
         ParseParameter(name, value);
     }
 }
        public ActionResult EditSubmit(String ParentID, String MaPhanHe_TrangThaiDuyet_Xem)
        {
            if (BaoMat.ChoPhepLamViec(User.Identity.Name, "NS_PhanHe_TrangThaiDuyet_NhomNguoiDung", "Edit") == false || !HamChung.CoQuyenXemTheoMenu(Request.Url.AbsolutePath, User.Identity.Name))
            {
                return RedirectToAction("Index", "PermitionMessage");
            }
            NameValueCollection arrLoi = new NameValueCollection();
            String MaPhanHe = Convert.ToString(Request.Form[ParentID + "_iID_MaPhanHe"]);
            String MaNhomNguoiDung = Convert.ToString(Request.Form[ParentID + "_iID_MaNhomNguoiDung"]);
            String MaTrangThaiDuyet = Convert.ToString(Request.Form[ParentID + "_iID_MaTrangThaiDuyet"]);
            if (MaPhanHe == Convert.ToString(Guid.Empty) || MaPhanHe == "-1")
            {
                arrLoi.Add("err_iID_MaPhanHe", "Bạn chưa chọn phân hệ");
            }
            if (MaNhomNguoiDung == Convert.ToString(Guid.Empty) || MaNhomNguoiDung == "")
            {
                arrLoi.Add("err_iID_MaNhomNguoiDung", "Bạn chưa chọn nhóm người dùng");
            }

            //if (MaTrangThaiDuyet == Convert.ToString(Guid.Empty) || MaTrangThaiDuyet == "-1")
            //{
            //    arrLoi.Add("err_iID_MaTrangThaiDuyet", "Bạn chưa chọn trạng thái duyệt");
            //}
            if (arrLoi.Count > 0)
            {
                for (int i = 0; i <= arrLoi.Count - 1; i++)
                {
                    ModelState.AddModelError(ParentID + "_" + arrLoi.GetKey(i), arrLoi[i]);
                }
                ViewData["iID_MaPhanHe_TrangThaiDuyet_Xem"] = MaPhanHe_TrangThaiDuyet_Xem;
                return View(sViewPath + "PhanHe_TrangThaiDuyet_NhomNguoiDung_Edit.aspx");
            }
            else
            {
                String sMaTrangThaiDuyet = Request.Form[ParentID + "_iID_MaTrangThaiDuyet"];
                String[] arrMaTrangThaiDuyet = sMaTrangThaiDuyet.Split(',');
                String SQL = "DELETE NS_PhanHe_TrangThaiDuyet_NhomNguoiDung WHERE iID_MaPhanHe=@iID_MaPhanHe AND iID_MaNhomNguoiDung=@iID_MaNhomNguoiDung";
                SqlCommand cmd = new SqlCommand(SQL);
                cmd.Parameters.AddWithValue("@iID_MaPhanHe", MaPhanHe);
                cmd.Parameters.AddWithValue("@iID_MaNhomNguoiDung", MaNhomNguoiDung);
                Connection.UpdateDatabase(cmd);
                cmd.Dispose();
                for (int i = 0; i < arrMaTrangThaiDuyet.Length; i++)
                {
                    Bang bang = new Bang("NS_PhanHe_TrangThaiDuyet_NhomNguoiDung");
                    bang.MaNguoiDungSua = User.Identity.Name;
                    bang.IPSua = Request.UserHostAddress;
                    bang.DuLieuMoi = true;
                    bang.CmdParams.Parameters.AddWithValue("@iID_MaPhanHe",MaPhanHe);
                    bang.CmdParams.Parameters.AddWithValue("@iID_MaNhomNguoiDung", MaNhomNguoiDung);
                    bang.CmdParams.Parameters.AddWithValue("@iID_MaTrangThaiDuyet", arrMaTrangThaiDuyet[i]);
                    bang.Save();
                }

                return RedirectToAction("Edit", "PhanHe_TrangThaiDuyet_NhomNguoiDung", new { MaPhanHe = MaPhanHe, MaNhomNguoiDung = MaNhomNguoiDung });
            }
        }
 public static Dictionary<string, string> ToDictionary(NameValueCollection nvc)
 {
     var map = new Dictionary<string, string>();
     for (var i = 0; i < nvc.Count; i++)
     {
         map[nvc.GetKey(i)] = nvc.Get(i);
     }
     return map;
 }
        public PortletModuleDataCollection(PortletInfo owner, NameValueCollection properties)
        {
            for(int i = 0; i < properties.Count; i++)
                base.Add(
                    properties.GetKey(i),
                    properties[i]
                    );

            this._owner = owner;
        }
        public CommunityPropertyCollection(CommunityInfo owner, NameValueCollection properties)
        {
            for(int i = 0; i < properties.Count; i++)
                base.Add(
                    properties.GetKey(i),
                    properties[i]
                    );

            this._owner = owner;
        }
        static IEnumerable<KeyValuePair<string, string>> GetOrderedForm(NameValueCollection form)
        {
            Dictionary<string, string> formDictionary = new Dictionary<string, string>();

            for (int i = 0; i < form.Count; i++)
                formDictionary.Add(form.GetKey(i), form.Get(i));

            var orderedList = formDictionary.OrderBy(x => x.Key);

            return orderedList;
        }
Beispiel #32
0
        public static Dictionary <string, string> getUrlParam(this string query, HttpContextBase httpContext)
        {
            System.Collections.Specialized.NameValueCollection coll = System.Web.HttpUtility.ParseQueryString(httpContext.Request.UrlReferrer.Query);
            Dictionary <string, string> keyValuePair = new Dictionary <string, string>();

            for (int i = 0; i < coll.Count; i++)
            {
                keyValuePair.Add(coll.GetKey(i), coll.Get(i));
            }
            return(keyValuePair);
        }
 internal static void CheckUnrecognizedAttributes(NameValueCollection config, string providerName)
 {
     if (config.Count > 0)
     {
         string key = config.GetKey(0);
         if (!string.IsNullOrEmpty(key))
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Unexpected_provider_attribute", new object[] { key, providerName }));
         }
     }
 }
		/// <summary>
		/// Adds the second dictionary to the first. If a key occurs in both dictionaries, the value of the second dictionary is taken.
		/// </summary>
		public static void Append(this NameValueCollection nameValueCollection1, NameValueCollection nameValueCollection2)
		{
			if (nameValueCollection1 == null)
				throw new ArgumentNullException("first");

			if (nameValueCollection2 != null)
			{
				for (int i = 0; i < nameValueCollection2.Count; i++)
					nameValueCollection1.Set(nameValueCollection2.GetKey(i), nameValueCollection2.Get(i));
			}
		}
Beispiel #35
0
        /// <summary>
        /// Query data from the client registry
        /// </summary>
        public SVC.Messaging.FHIR.FhirQueryResult Query(System.Collections.Specialized.NameValueCollection parameters)
        {
            FhirQueryResult result = new FhirQueryResult();

            result.Details = new List <IResultDetail>();

            // Get query parameters
            var resourceProcessor = FhirMessageProcessorUtil.GetMessageProcessor(this.ResourceName);

            // Process incoming request

            NameValueCollection goodParameters = new NameValueCollection();

            for (int i = 0; i < parameters.Count; i++)
            {
                for (int v = 0; v < parameters.GetValues(i).Length; v++)
                {
                    if (!String.IsNullOrEmpty(parameters.GetValues(i)[v]))
                    {
                        goodParameters.Add(parameters.GetKey(i), MessageUtil.Escape(parameters.GetValues(i)[v]));
                    }
                }
            }
            parameters = goodParameters;

            var queryObject = resourceProcessor.ParseQuery(goodParameters, result.Details);

            result.Query = queryObject;

            // sanity check
#if !DEBUG
            if (result.Query.ActualParameters.Count == 0)
            {
                result.Outcome = ResultCode.Rejected;
                result.Details.Add(new ValidationResultDetail(ResultDetailType.Error, ApplicationContext.LocalizationService.GetString("MSGE077"), null, null));
            }
            else
#endif
            if (result.Details.Exists(o => o.Type == ResultDetailType.Error))
            {
                result.Outcome = ResultCode.Error;
                result.Details.Add(new ResultDetail(ResultDetailType.Error, ApplicationContext.LocalizationService.GetString("MSGE00A"), null, null));
            }
            else if (queryObject.Filter == null || result.Outcome != ResultCode.Accepted)
            {
                throw new InvalidOperationException("Could not process query parameters!");
            }
            else
            {
                result = DataUtil.Query(queryObject, result.Details);
            }

            return(result);
        }
Beispiel #36
0
        public static List<NameValuePair> GetPairs(NameValueCollection nvc)
        {
            var result = new List<NameValuePair>();
            if (nvc == null) return null;

            for (int i = 0; i < nvc.Count; i++)
            {
                result.Add(new NameValuePair { Name = nvc.GetKey(i), Value = nvc.Get(i) });
            }
            return result;
        }
        public void CustomCacheStorageDataTest()
        {
            string name = "testName2";
            Type type = typeof(CacheStorageNodeFixture);
            NameValueCollection attributes = new NameValueCollection();
            attributes.Add("test", "value");

            CustomCacheStorageData data = new CustomCacheStorageData();
            data.Name = name;
            data.Type = type;
            data.Attributes.Add(attributes.GetKey(0), attributes[attributes.GetKey(0)]);

            CustomCacheStorageNode node = new CustomCacheStorageNode(data);
            ApplicationNode.AddNode(node);
            Assert.AreEqual(name, node.Name);
            Assert.AreEqual(type, node.Type);

            Assert.AreEqual(attributes.AllKeys[0], node.Attributes[0].Key);
            Assert.AreEqual(attributes.Get(0), node.Attributes[0].Value);
        }
Beispiel #38
0
        /// <summary>
        /// 根据NameValueCollection键值集合组装url字符串
        /// </summary>
        /// <param name="st">NameValueCollection键值集合</param>
        /// <returns>返回返回string字符串(格式:a=a&b=b&c=c)</returns>
        public static string GetStrNV(System.Collections.Specialized.NameValueCollection nv)
        {
            string str = string.Empty;

            for (int i = 0; i < nv.Count; i++)
            {
                str += nv.GetKey(i) + "=" + nv.Get(i) + "&";
            }
            str = str.Substring(0, str.Length - 1);
            return(str);
        }
    public override string ArgName(int kind, int ix)
    {
        string a = null;

        switch (kind)
        {
        case QueryString: a = Ctx.Request.QueryString.GetKey(ix); break;

        case FormString: a = Form == null ? null : Form.GetKey(ix); break;
        }
        return(a == null ? "" : a);
    }
Beispiel #40
0
    public static string rq(string keyName)
    {
        string sRetValue = "";
        string sKeyname  = keyName.ToLower();

        System.Web.HttpRequest r = System.Web.HttpContext.Current.Request;
        System.Collections.Specialized.NameValueCollection n = r.QueryString;
        if (n.HasKeys())
        {
            for (int i = 0; i < n.Count; i++)
            {
                if (n.GetKey(i) != null)
                {
                    string key = n.GetKey(i).ToLower();
                    if (key == sKeyname)
                    {
                        sRetValue = n.Get(i);
                        break;
                    }
                }
            }
        }
        return(sRetValue);
    }
    public override string[][] GetUnknownRequestHeaders()
    {
        string[][] unknownRequestHeaders;
        System.Collections.Specialized.NameValueCollection headers = _context.Request.Headers;
        int             count       = headers.Count;
        List <string[]> headerPairs = new List <string[]>(count);

        for (int i = 0; i < count; i++)
        {
            string headerName = headers.GetKey(i);
            if (GetKnownRequestHeaderIndex(headerName) == -1)
            {
                string headerValue = headers.Get(i);
                headerPairs.Add(new string[] { headerName, headerValue });
            }
        }
        unknownRequestHeaders = headerPairs.ToArray();
        return(unknownRequestHeaders);
    }
        /// <summary>
        /// 生成QueryString
        /// </summary>
        /// <param name="args">键值对</param>
        /// <param name="encoding">URL编码</param>
        /// <returns>生成的QueryString</returns>
        public static string GenerateQueryString(System.Collections.Specialized.NameValueCollection args, Encoding encoding)
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < args.Count; i++)
            {
                string key = args.GetKey(i);
                key = ((key != null) && (key.Length > 0)) ? (HttpUtility.UrlEncode(key, encoding) + "=") : "";

                string[] values = args.GetValues(i);


                if (i > 0)
                {
                    builder.Append("&");
                }

                if (values.Length == 0)
                {
                    builder.Append(key);
                }
                else
                {
                    for (int j = 0; j < values.Length; j++)
                    {
                        if (j > 0)
                        {
                            builder.Append("&");
                        }

                        builder.Append(key);
                        builder.Append(HttpUtility.UrlEncode(values[j], encoding));
                    }
                }
            }

            return(builder.ToString());
        }
Beispiel #43
0
        //
        // Misc public APIs
        //

        /// <include file='doc\NameValueCollection.uex' path='docs/doc[@for="NameValueCollection.Add"]/*' />
        /// <devdoc>
        /// <para>Copies the entries in the specified <see cref='System.Collections.Specialized.NameValueCollection'/> to the current <see cref='System.Collections.Specialized.NameValueCollection'/>.</para>
        /// </devdoc>
        public void Add(NameValueCollection c)
        {
            InvalidateCachedArrays();

            int n = c.Count;

            for (int i = 0; i < n; i++)
            {
                String   key    = c.GetKey(i);
                String[] values = c.GetValues(i);

                if (values != null)
                {
                    for (int j = 0; j < values.Length; j++)
                    {
                        Add(key, values[j]);
                    }
                }
                else
                {
                    Add(key, null);
                }
            }
        }
        public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (String.IsNullOrEmpty(name))
            {
                name = "HHMembershipProvider";
            }

            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "HHOnline Membership Provider");
            }

            // Initialize base class
            base.Initialize(name, config);

            // Get values from config
            enablePasswordRetrieval    = GetBooleanValue(config, "enablePasswordRetrieval", false);
            enablePasswordReset        = GetBooleanValue(config, "enablePasswordReset", true);
            requiresQuestionAndAnswer  = GetBooleanValue(config, "requiresQuestionAndAnswer", true);
            requiresUniqueEmail        = GetBooleanValue(config, "requiresUniqueEmail", true);
            maxInvalidPasswordAttempts = GetIntValue(config, "maxInvalidPasswordAttempts", 5, false, 0);
            passwordAttemptWindow      = GetIntValue(config, "passwordAttemptWindow", 10, false, 0);
            minRequiredPasswordLength  = GetIntValue(config, "minRequiredPasswordLength", 7, false, 128);

            // Get hash algorhithm
            hashAlgorithmType = config["hashAlgorithmType"];
            if (String.IsNullOrEmpty(hashAlgorithmType))
            {
                hashAlgorithmType = "SHA1";
            }

            // Get password validation Regular Expression
            passwordStrengthRegularExpression = config["passwordStrengthRegularExpression"];
            if (passwordStrengthRegularExpression != null)
            {
                passwordStrengthRegularExpression = passwordStrengthRegularExpression.Trim();
                if (passwordStrengthRegularExpression.Length != 0)
                {
                    try
                    {
                        Regex regex = new Regex(passwordStrengthRegularExpression);
                    }
                    catch (ArgumentException e)
                    {
                        throw new ProviderException(e.Message, e);
                    }
                }
            }
            else
            {
                passwordStrengthRegularExpression = string.Empty;
            }


            if (applicationName.Length > 255)
            {
                throw new ProviderException("Provider application name is too long, max length is 255.");
            }


            // Get password format
            string strTemp = config["passwordFormat"];

            if (strTemp == null)
            {
                strTemp = "Hashed";
            }
            switch (strTemp)
            {
            case "Clear":
                passwordFormat = MembershipPasswordFormat.Clear;
                break;

            case "Encrypted":
                passwordFormat = MembershipPasswordFormat.Encrypted;
                break;

            case "Hashed":
                passwordFormat = MembershipPasswordFormat.Hashed;
                break;

            default:
                throw new ProviderException("Bad password format");
            }

            if (passwordFormat == MembershipPasswordFormat.Hashed && enablePasswordRetrieval)
            {
                throw new ProviderException("Provider cannot retrieve hashed password");
            }

            // Clean up config
            config.Remove("enablePasswordRetrieval");
            config.Remove("enablePasswordReset");
            config.Remove("requiresQuestionAndAnswer");
            config.Remove("applicationName");
            config.Remove("requiresUniqueEmail");
            config.Remove("maxInvalidPasswordAttempts");
            config.Remove("passwordAttemptWindow");
            config.Remove("passwordFormat");
            config.Remove("name");
            config.Remove("description");
            config.Remove("minRequiredPasswordLength");
            config.Remove("passwordStrengthRegularExpression");
            config.Remove("hashAlgorithmType");

            if (config.Count > 0)
            {
                string attribUnrecognized = config.GetKey(0);
                if (!String.IsNullOrEmpty(attribUnrecognized))
                {
                    throw new ProviderException("Provider unrecognized attribute: " + attribUnrecognized);
                }
            }
        }
Beispiel #45
0
        private void _QueryParameter(string reqString)
        {
            string boundary = GetBoundary(reqString);

            if (string.IsNullOrEmpty(boundary))
            {
                JavaScriptSerializer serializer = null;
                try
                {
                    serializer = new JavaScriptSerializer()
                    {
                        MaxJsonLength = int.MaxValue
                    };
                    this.Parameter = new Dictionary <string, object>();
                    this.Parameter = serializer.Deserialize <Dictionary <string, object> >(reqString);
                    try
                    {
                        if (this.Parameter.ContainsKey(FILE_PARAM_NAME))
                        {
                            this.Files = new List <FileParameter>();
                            foreach (Dictionary <string, object> files in (this.Parameter[FILE_PARAM_NAME] as System.Collections.ArrayList))
                            {
                                this.Files.Add(new FileParameter(files["NAME"].ToString(), files["FULLNAME"].ToString()));
                            }
                        }
                    }
                    catch { }
                    return;
                }
                catch { }
                try
                {
                    serializer = new JavaScriptSerializer()
                    {
                        MaxJsonLength = int.MaxValue
                    };
                    this.Parameter = new Dictionary <string, object>();
                    this.Parameter = serializer.Deserialize <Dictionary <string, object> >(reqString);
                    try
                    {
                        if (this.Parameter.ContainsKey(FILE_PARAM_NAME))
                        {
                            this.Files = new List <FileParameter>();
                            foreach (Dictionary <string, object> files in (this.Parameter[FILE_PARAM_NAME] as System.Collections.ArrayList))
                            {
                                this.Files.Add(new FileParameter(files["NAME"].ToString(), files["FULLNAME"].ToString()));
                            }
                        }
                    }
                    catch { }
                    return;
                }
                catch { }
                try
                {
                    this.Parameter = new Dictionary <string, object>();
                    System.Collections.Specialized.NameValueCollection nameValueCollect = HttpUtility.ParseQueryString(reqString);
                    for (int i = 0; i < nameValueCollect.Count; i++)
                    {
                        try
                        {
                            if (nameValueCollect[i].StartsWith("[") && nameValueCollect[i].EndsWith("]"))
                            {
                                this.Parameter.Add(nameValueCollect.GetKey(i), serializer.Deserialize <List <Dictionary <string, object> > >(nameValueCollect[i]));
                            }
                            else if (nameValueCollect[i].StartsWith("{") && nameValueCollect[i].EndsWith("}"))
                            {
                                this.Parameter.Add(nameValueCollect.GetKey(i), serializer.Deserialize <Dictionary <string, object> >(nameValueCollect[i]));
                            }
                            else
                            {
                                this.Parameter.Add(nameValueCollect.GetKey(i), nameValueCollect[i]);
                            }
                        }
                        catch
                        {
                            this.Parameter.Add(nameValueCollect.GetKey(i), nameValueCollect[i]);
                        }
                    }
                    return;
                }
                catch { }
            }
            else
            {
                try
                {
                    this.Parameter = new Dictionary <string, object>();
                    for (int i = reqString.IndexOf(boundary) + boundary.Length; i < reqString.Length; i = reqString.IndexOf(boundary, i) > -1 ? reqString.IndexOf(boundary, i) + boundary.Length : reqString.Length)
                    {
                        string paramName        = string.Empty;
                        string paramContentType = string.Empty;
                        string paramFileName    = string.Empty;
                        object paramValue       = null;

                        string formData = string.Empty;
                        try
                        {
                            formData = reqString.Substring(i, reqString.IndexOf(boundary, i) - i);
                        }
                        catch
                        {
                            formData = reqString.Substring(i);
                        }
                        string[] readFormdata = System.Text.RegularExpressions.Regex.Split(formData, "\r\n\r\n").Where(s => !string.IsNullOrEmpty(s.Trim())).ToArray();
                        if (readFormdata.Length < 2)
                        {
                            continue;
                        }
                        foreach (string readLine in System.Text.RegularExpressions.Regex.Split(readFormdata[0], "\r\n").Where(s => !string.IsNullOrEmpty(s.Trim())))
                        {
                            if (readLine.StartsWith("Content-Disposition"))
                            {
                                foreach (string pName in readLine.Split(';').Select(s => s.Trim()))
                                {
                                    if (pName.StartsWith("name"))
                                    {
                                        paramName = pName.Trim().Replace("name=", "").Substring(1);
                                        paramName = paramName.Substring(0, paramName.Length - 1);
                                    }
                                    else if (pName.StartsWith("filename"))
                                    {
                                        paramFileName = pName.Trim().Replace("filename=", "").Substring(1);
                                        paramFileName = paramFileName.Substring(0, paramFileName.Length - 1);
                                    }
                                }
                            }
                            else if (readLine.StartsWith("Content-Type"))
                            {
                                paramContentType = readLine.Trim().Replace("Content-Type: ", "");
                            }
                        }
                        paramValue = readFormdata[1].Substring(0, readFormdata[1].LastIndexOf("\r\n"));
                        if (string.IsNullOrEmpty(paramName))
                        {
                            continue;
                        }
                        if (string.IsNullOrEmpty(paramFileName))
                        {
                            this.Parameter.Add(paramName, paramValue);
                        }
                        else
                        {
                            if (!this.Parameter.ContainsKey(FILE_PARAM_NAME))
                            {
                                this.Parameter.Add(FILE_PARAM_NAME, new List <Dictionary <string, object> >());
                            }
                            List <Dictionary <string, object> > fileList = this.Parameter[FILE_PARAM_NAME] as List <Dictionary <string, object> >;
                            fileList.Add(new Dictionary <string, object>()
                            {
                                { "NAME", paramFileName },
                                { "CONTENT_TYPE", paramContentType },
                                //{"CONTENT",System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(paramValue.ToString())) }
                                { "FULLNAME", paramContentType }
                            });
                        }
                    }

                    return;
                }
                catch { }
            }
        }