Ejemplo n.º 1
0
 internal static string[] GetValues(System.Collections.Specialized.NameValueCollection data, string key, string prefix)
 {
     string[] value = data.GetValues(key);
     if (string.IsNullOrEmpty(prefix))
         return value;
     if(value.Length ==0)
         value = data.GetValues(prefix + "." + key);
     if (value.Length == 0)
         value = data.GetValues(prefix + "_" + key);
     if (value.Length == 0)
         value = data.GetValues(prefix + key);
     return value;
 }
        private static string GetHttpRequestHeader(System.Net.Http.Headers.HttpHeaders headers, string headerName)
        {
            if (!headers.Contains(headerName))
                return string.Empty;

            return headers.GetValues(headerName).SingleOrDefault();
        }
Ejemplo n.º 3
0
 private string BuildQuery(System.Collections.Specialized.NameValueCollection query)
 {
     string dataField = query.GetValues("sortdatafield")[0];
     string order = query.GetValues("sortorder")[0];
     if (order != "")
     {
         string queryString = ""
         + "  SELECT * FROM Customers "
         + "ORDER BY " + dataField + " " + order;
         return queryString;
     }
     else
     {
         string queryString = "SELECT * FROM Customers";
         return queryString;
     }
 }
 /// <summary>
 /// This method extracts the answers that were posted from a HotDocs interview.
 /// </summary>
 /// <param name="form">The form in which the answers were posted.</param>
 /// <returns>A string of answers.</returns>
 public static string GetAnswers(System.Collections.Specialized.NameValueCollection form)
 {
     // convert from a NameValueCollection (typically from <System.Web.HttpRequest>.Form)
     // to a string.  With HotDocs 2007 SR1 and earlier, this will be plain XML.
     // For HotDocs 2007 SR2 (and later) stateful interviews, this will be Base64-encoded XML.
     // For HotDocs 10.1 (and later) stateless interviews, this will be in the [HDANS] format.
     string[] hdInfoValues = form.GetValues("HDInfo");
     if (hdInfoValues != null && hdInfoValues.Length > 0)
         return string.Join(string.Empty, hdInfoValues);
     else
         return string.Empty;
 }
Ejemplo n.º 5
0
        public static string RequestFormToJsonTree(System.Collections.Specialized.NameValueCollection formdata , string schema)
        {
            JObject jsonschema = JObject.Parse(schema);
            Dictionary<string, object> graph = new Dictionary<string, object>();


            int i;
            String[] data = formdata.AllKeys;
            for (i = 0; i < data.Length; i++)
            {
                string key = data[i];
                string strvalue = formdata.GetValues(i)[0];

                List<string> path = key.Split('.').ToList();

                object value = null;

                string spath = schemapath(path);
                string type = (string)jsonschema.SelectToken(spath);
                try
                {
                    if (type.Equals("boolean"))
                    {
                        value = Boolean.Parse(strvalue);
                    }
                    else if (type.Equals("integer"))
                    {
                        value = Int32.Parse(strvalue);
                    }
                    else if (type.Equals("number"))
                    {
                        value = float.Parse(strvalue);
                    }
                    else
                    {
                        value = (string)strvalue;
                    }
                }
                catch (Exception e)
                {
                    value = (string)strvalue;
                }
                add(graph, path, value);
            }

            Dictionary<string, object> newgraph = makelists(graph);


            return Newtonsoft.Json.JsonConvert.SerializeObject(newgraph);
        }
Ejemplo n.º 6
0
        private string BuildQuery(System.Collections.Specialized.NameValueCollection query)
        {
            var result = query.GetValues("filterslength");
            if (result == null)
                return @"SELECT * FROM Employee";

            var filtersCount = int.Parse(query.GetValues("filterslength")[0]);
            var queryString = @"SELECT * FROM Employee ";
            var tmpDataField = "";
            var tmpFilterOperator = "";
            var where = "";
            if (filtersCount > 0)
            {
                where = " WHERE (";
            }
            for (var i = 0; i < filtersCount; i += 1)
            {
                var filterValue = query.GetValues("filtervalue" + i)[0];
                var filterCondition = query.GetValues("filtercondition" + i)[0];
                var filterDataField = query.GetValues("filterdatafield" + i)[0];
                var filterOperator = query.GetValues("filteroperator" + i)[0];
                if (tmpDataField == "")
                {
                    tmpDataField = filterDataField;
                }
                else if (tmpDataField != filterDataField)
                {
                    where += ") AND (";
                }
                else if (tmpDataField == filterDataField)
                {
                    if (tmpFilterOperator == "")
                    {
                        where += " AND ";
                    }
                    else
                    {
                        where += " OR ";
                    }
                }
                // build the "WHERE" clause depending on the filter's condition, value and datafield.
                where += this.GetFilterCondition(filterCondition, filterDataField, filterValue);
                if (i == filtersCount - 1)
                {
                    where += ")";
                }
                tmpFilterOperator = filterOperator;
                tmpDataField = filterDataField;
            }
            queryString += where;
            return queryString;
        }
Ejemplo n.º 7
0
        bool IPostBackDataHandler.LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            if (!base.IsEnabled)
            {
                return false;
            }
            string textBoxKey = String.Format("{0}${1}", postDataKey, "TB");
            string listBoxKey = postDataKey;
            string[] textArray = postCollection.GetValues(textBoxKey);
            string[] valueArray = postCollection.GetValues(listBoxKey);

            this.EnsureDataBound();

            if (textArray != null && valueArray != null)
            {
                bool returnValue = false;
                this.ValidateEvent(listBoxKey, valueArray[0]);
                string text = textArray[0];
                int num1 = this.FindByValueInternal(valueArray[0], false);
                if (this.SelectedIndex != num1)
                {
                    base.SetPostDataSelection(num1);
                    returnValue = true;
                }
                if (this.Text != text)
                {
                    this.Text = text;
                    returnValue = true;
                }
                if (!TextExists(text, false))
                {
                    base.SetPostDataSelection(-1);
                }

                return returnValue;
            }
            return false;
        }
Ejemplo n.º 8
0
		/// <summary>
		/// Determines whether the NameValueCollection contains a specific value.
		/// </summary>
		/// <param name="d">The dictionary to check for the value.</param>
		/// <param name="obj">The object to locate in the SortedList.</param>
		/// <returns>Returns true if the value is contained in the NameValueCollection, false otherwise.</returns>
		public static bool ContainsValue(System.Collections.Specialized.NameValueCollection d, System.Object obj)
		{
			bool contained = false;
			System.Type type = d.GetType();

			for (int i = 0; i < d.Count && !contained ; i++)
			{
				System.String [] values = d.GetValues(i);
				if (values != null) 
				{
					foreach (System.String val in values)
					{
						if (val.Equals(obj))
						{
							contained = true;
							break;
						}
					}
				}
			}
			return contained;
		}		
Ejemplo n.º 9
0
        internal void SaveRequestHeaders(System.Collections.Specialized.NameValueCollection nameValueCollection)
        {
            // user-agent:fox
            // cookie;id=5
            //cooki=user=ger;date=15
            StringS h = new StringS();
            foreach (string key in nameValueCollection.AllKeys)
            {
                h.id = key.Trim();
                string[] values = nameValueCollection.GetValues(key);
                if (values.Length < 1)
                    continue;

                    if (h.id.ToLower() == "cookie")
                    {
                        this.ParseCookie(values[0]);
                        continue;
                    }
                    this.AddRequestHeader(h);
            }
        }
Ejemplo n.º 10
0
        //return error XElement
        //return null for success
        private bool handleUrlRequest(System.Collections.Specialized.NameValueCollection queryString, out String path, out String from, out String count)
        {
            //set default
            path = null;
            from = null;
            count = null;

            String[] keys = queryString.AllKeys;
            if (keys.Length == 0)
                return false;

            for (int i = 0; i < keys.Length; i++)
            {
                String[] values = queryString.GetValues(keys[i]);
                switch (keys[i])
                {
                    case "path":
                        path = values[0];
                        break;
                    case "from":
                        from = values[0];
                        break;
                    case "count":
                        count = values[0];
                        break;
                }
            }
            return true;
        }
Ejemplo n.º 11
0
        private XElement handleStoreSampleStoreEventCommon(System.Collections.Specialized.NameValueCollection queryString,
            out String timestamp, out String deviceName, out String dataItemName, out String value, out String workPieceId, out String partId, out String code, out String severity, out String nativecode, out String state)
        {
            timestamp = null;
            deviceName = null;
            dataItemName = null;
            value = null;
            workPieceId = null;
            partId = null;
            code = null;
            severity = null;
            nativecode = null;
            state = null;

            //// Get names of all keys into a string array.
            String[] keys = queryString.AllKeys;
            for (int i = 0; i < keys.Length; i++)
            {
                String[] values = queryString.GetValues(keys[i]);
                switch (keys[i])
                {
                    case "timestamp":
                        timestamp = values[0];
                        break;
                    case "deviceName":
                        deviceName = values[0];
                        break;
                    case "dataItemName":
                        dataItemName = values[0];
                        break;
                    case "value":
                        value = values[0];
                        break;
                    case "workPieceId":
                        workPieceId = values[0];
                        break;
                    case "partId":
                        partId = values[0];
                        break;
                    case "code":
                        code = values[0];
                        break;
                    case "severity":
                        severity = values[0];
                        break;
                    case "nativecode":
                        nativecode = values[0];
                        break;
                    case "state":
                        state = values[0];
                        break;
                }

            }

            if (timestamp == null)
                return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The timestamp is missing.");
            else if (deviceName == null)
                return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The deviceName is missing.");
            else if (dataItemName == null)
                return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The dataItemName is missing.");
            else if (value == null)
                return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The value is missing.");
            else
                return null; //success
        }
Ejemplo n.º 12
0
        private string BuildQuery(System.Collections.Specialized.NameValueCollection query)
        {
            string dataField = query.GetValues("sortdatafield")[0];
            string order = query.GetValues("sortorder")[0];
            int pagenum = Convert.ToInt32(query.GetValues("pagenum")[0]);
            int pagesize = Convert.ToInt32(query.GetValues("pagesize")[0]);
            string queryString = "";

            if (order != "")
            {
                queryString = " SELECT ROW_NUMBER() OVER (ORDER BY " + query.GetValues("sortdatafield")[0] + " " + query.GetValues("sortorder")[0].ToUpper() + ") as row, N.title, N.textbody, T.TagName, N.TimeCreated, N.TimeUpdated, N.NoteId, T.TagID FROM notes N INNER JOIN noteTag NT ON NT.NoteId = N.NoteId INNER JOIN tags T ON T.TagID = NT.TagID";
            }
            else
            {
                queryString = " SELECT ROW_NUMBER() OVER (ORDER BY  N.NoteId desc ) as row, N.title, N.textbody, T.TagName, N.TimeCreated, N.TimeUpdated, N.NoteId, T.TagID FROM notes N INNER JOIN noteTag NT ON NT.NoteId = N.NoteId INNER JOIN tags T ON T.TagID = NT.TagID";
            }
            return queryString;
        }
Ejemplo n.º 13
0
 public static Header[] ToHeaders(System.Collections.Specialized.NameValueCollection headers)
 {
     return headers.AllKeys.Select(k => new Header(k, headers.GetValues(k))).ToArray();
 }
Ejemplo n.º 14
0
        private XElement handleStoreSampleStoreEventCommon(System.Collections.Specialized.NameValueCollection queryString,
            out String timestamp, out String dataItemId, out String condition, out String value,out String code, out String nativeCode )
        {
            timestamp = null;

            dataItemId = null;
            condition = null;
            value = null;
            code = null;
            nativeCode = null;

            // Get names of all keys into a string array.
            String[] keys = queryString.AllKeys;
            for (int i = 0; i < keys.Length; i++)
            {
                String[] values = queryString.GetValues(keys[i]);
                switch (keys[i])
                {
                    case "timestamp":
                        timestamp = values[0];
                        break;

                    case "dataItemId":
                        dataItemId = values[0];
                        break;
                    case "condition":
                        condition = values[0];
                        break;
                    case "value":
                        value = values[0];
                        break;
                    case "code":
                        code = values[0];
                        break;
                    case "nativeCode":
                        nativeCode = values[0];
                        break;

                }
            }
            if (timestamp == null)
                // return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The timestamp is missing.");
                timestamp = Util.GetDateTime();
            //else if (deviceName == null)
               // return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The deviceName is missing.");
            if (dataItemId ==null)
                return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The dataItemId is missing.");
            //else if (value == null)
              //  return MachineAPIError.createError(MachineAPIError.UNRECOGNIZEDDATA, "The value is missing.");
            else
                return null; //success
        }
Ejemplo n.º 15
0
        //private void AfterDataBind()
        //{
        //    //// 必须重新计算模拟数的数据
        //    //mustReCalculateSimulateTreeData = true;
        //}

        #endregion

        #region IPostBackDataHandler Members

        /// <summary>
        /// 处理回发数据
        /// </summary>
        /// <param name="postDataKey">回发数据键</param>
        /// <param name="postCollection">回发数据集</param>
        /// <returns>回发数据是否改变</returns>
        public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
        {
            // 如果下拉列表被禁用,则postText为null。由于Enabled只能在服务器端被改变,所以被禁用时,不处理回发数据即可
            if (!Enabled)
            {
                return false;
            }

            // 如果下拉列表没有任何项,则不会触发数据改变事件
            if (Items.Count == 0)
            {
                return false;
            }


            string postText = postCollection[postDataKey];

            if (EnableMultiSelect)
            {
                string[] postValues = postCollection.GetValues(SelectedValueHiddenFieldID);
                if (postValues == null)
                {
                    postValues = new string[0];
                }
                if (!StringUtil.CompareStringArray(postValues, SelectedValueArray))
                {
                    SelectedValueArray = postValues;
                    FState.BackupPostDataProperty("SelectedValueArray");
                    return true;
                }

            }
            else
            {
                string postValue = postCollection[SelectedValueHiddenFieldID];

                ListItem item = Items.FindByValue(postValue);
                if (item != null && item.Text == postText)
                {
                    // 本次选中的是下拉项
                    if (SelectedValue != postValue)
                    {
                        SelectedValue = postValue;
                        FState.BackupPostDataProperty("SelectedValue");
                        return true;
                    }
                }
                else
                {
                    //// 本次是用户输入的值
                    //if (Text != postText)
                    //{
                    SelectedValue = null;
                    FState.BackupPostDataProperty("SelectedValue");

                    Text = postText;
                    FState.BackupPostDataProperty("Text");
                    return true;
                    //}
                }
            }


            return false;
        }