예제 #1
0
        /// <summary>
        /// returns a hashtable with all key/value pairs for this request
        /// </summary>
        /// <param name="keyAttribute">the key attribute used for the hash key (name, sp_id, rei_id, etc)</param>
        /// <param name="includeOrder">true if the order fields should be included</param>
        /// <param name="includeBlankValues">true if blank values should be included</param>
        /// <returns>Hashtable</returns>
        public Hashtable GetTranslatedHashTable(string keyAttribute, bool includeOrder, bool includeBlankValues)
        {
            Hashtable ht = new Hashtable();

            if (keyAttribute.Equals("name"))
            {
                // this is faster because the reponse has the name attribute included
                ht = XmlForm.GetResponseHashtable(this.Xml);
            }
            else
            {
                // this is slower because we need the definition to translate
                ht = XmlForm.GetTranslatedHashtable(this.RequestType.GetDefDocument(), this.GetResponse(), keyAttribute, includeBlankValues);
            }

            // if the order should be included, include it - unless this is
            // the default change code, which contains all of the details of the order
            if (includeOrder && this.RequestTypeCode != Affinity.RequestType.DefaultChangeCode)
            {
                Hashtable oht = this.Order.GetTranslatedHashTable(keyAttribute, includeBlankValues);
                foreach (string key in oht.Keys)
                {
                    if (ht.ContainsKey(key))
                    {
                        if (ht[key].ToString() == oht[key].ToString() || oht[key].ToString() == "")
                        {
                            // we are inserting the exact same value twice, or else a previous value
                            // was entered but the new value is blank.  either way, this will just
                            // clutter up the export, so we will ignore the new value
                        }
                        else if (ht[key].ToString() == "")
                        {
                            // the key exists, but is empty so don't prepend the comma
                            ht[key] = oht[key];
                        }
                        else
                        {
                            ht[key] = ht[key].ToString() + ", " + oht[key];
                        }
                    }
                    else
                    {
                        ht.Add(key, oht[key]);
                    }
                }
            }
            return(ht);
        }
예제 #2
0
        /// <summary>
        /// returns a hashtable with all the keys equal to the order fields
        /// </summary>
        /// <param name="keyAttribute"></param>
        /// <returns></returns>
        public Hashtable GetTranslatedHashTable(string keyAttribute, bool includeBlankValues)
        {
            Hashtable ht = new Hashtable();

            if (keyAttribute.Equals("name"))
            {
                // this is faster because the reponse has the name attribute included
                ht = XmlForm.GetResponseHashtable(this.GetResponse());
            }
            else
            {
                // this is slower because we need the definition to translate
                Affinity.RequestType rt = new Affinity.RequestType(this.phreezer);
                rt.Load(Affinity.RequestType.DefaultChangeCode);

                ht = XmlForm.GetTranslatedHashtable(
                    rt.GetDefDocument(),
                    this.GetResponse(),
                    keyAttribute,
                    includeBlankValues);
            }

            return(ht);
        }
예제 #3
0
 /// <summary>
 /// Given a reponse xml document, returns a Hashtable with all the responses
 /// as the values.  The key is determined by the attribute parameter.  For
 /// example this could be "name" "sp_id" or "rei_id"
 /// </summary>
 /// <param name="def">Request Definition</param>
 /// <param name="doc">Request Responses</param>
 /// <param name="keyAttribute"></param>
 /// <returns>Hashtable</returns>
 public static Hashtable GetTranslatedHashtable(XmlDocument def, XmlDocument doc, string keyAttribute)
 {
     return(XmlForm.GetTranslatedHashtable(def, doc, keyAttribute, false));
 }