GetProviderBySearch() public method

public GetProviderBySearch ( string name, int classID, string queue ) : DataRow
name string
classID int
queue string
return System.Data.DataRow
Example #1
0
        /// <summary>
        /// Upsert provider.
        /// </summary>
        /// <param name="queue">The queue.</param>
        /// <param name="providerXML">The provider XML.</param>
        /// <returns></returns>
        public bool UpSertProvider(string queue, string providerXML)
        {
            StringWriter decodedXML = new StringWriter();
            // Decode the encoded string.
            HttpUtility.HtmlDecode(providerXML, decodedXML);

            bool success = false;
            DataTable pTable = new DataTable();
            Atul_v1Data adb = new Atul_v1Data();
            pTable = adb.GetProviders();

            XmlDocument pXML = new XmlDocument();
            pXML.LoadXml(decodedXML.ToString());

            XmlNodeList submittedProviders = pXML.SelectNodes(@"//endpoint/provider");
            foreach (XmlNode xn in submittedProviders)
            {
                int ModifiedBy = -1;
                string xmlproviderName = xn["name"].InnerText;
                string xmlclassid = xn["classid"].InnerText;

                string xmlDescription = xn["description"].InnerText;
                //To insert or update, that is the question. We'll add the queue check in when the db gets sorted.
                DataRow providerRow = adb.GetProviderBySearch(xmlproviderName, Convert.ToInt32(xmlclassid), queue);
                string ServiceProviderXML = xn.OuterXml;
                if (providerRow != null)
                {
                    long AtulServiceProviderID = Convert.ToInt64(providerRow["AtulServiceProviderID"]);
                    int AtulServiceProviderClassID = Convert.ToInt32(Convert.ToInt32(xmlclassid));
                    success = adb.UpdateProvider(AtulServiceProviderID, xmlproviderName, xmlDescription, AtulServiceProviderClassID, queue, ModifiedBy, ServiceProviderXML);
                }
                else
                {
                    //insert provider
                    success = adb.InsertProvider(xmlproviderName, xmlDescription, Convert.ToInt32(xmlclassid), queue, ModifiedBy, ServiceProviderXML);
                }
            }
            return success;
        }