示例#1
0
        public void InsertEntry(int pPersonID, string pOperatorName, string pPhone, int pCountryID)
        {
            try
            {
                CountryEN personCountry = topupDAL.GetCountryByID(pCountryID);
                string    operatorBrand = pOperatorName + " " + personCountry.Name;

                OperatorEN operatorFound = topupDAL.GetOperatorByBrand(pCountryID, operatorBrand);

                if (operatorFound != null)
                {
                    RangeAzureSearch item = new RangeAzureSearch();
                    item.country_code = (operatorFound.ISO2Code != String.Empty) ? operatorFound.ISO2Code : "";
                    item.mnc          = (operatorFound.Mnc != String.Empty) ? operatorFound.Mnc : "";
                    item.mcc          = "706";
                    item.mno_id       = Convert.ToString(operatorFound.OperatorID);
                    item.term_end     = pPhone;
                    item.term_init    = pPhone;
                    item.term_id      = Guid.NewGuid().ToString();

                    AzureSearchValue        azureValue = new AzureSearchValue();
                    List <RangeAzureSearch> values     = new List <RangeAzureSearch>();
                    values.Add(item);
                    azureValue.value = values;

                    InsertValueIntoAzureSearch(azureValue);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLogger.LogError("AzureSearch: " + ex.Message);
            }
        }
示例#2
0
        public bool ComparePhoneNumber(string pMsisdn, string pOperatorName, int pPersonID, int pPersonCountryID)
        {
            bool   isTheSame           = false;
            string countryOperatorName = string.Empty;

            string url = "https://gpstermsearch.search.windows.net/indexes/gpsterms/docs?search=*&$filter= term_init  eq '" + pMsisdn + "' &api-version=2015-02-28";

            HttpWebResponse response = null;
            HttpWebRequest  request  = (HttpWebRequest)HttpWebRequest.Create(url);

            request.Method      = "GET";
            request.ContentType = "application/json";
            request.Headers.Add("api-key", Values.AzureSearchApiKey);

            string jsonResult;

            try
            {
                response = (HttpWebResponse)request.GetResponse();
                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    jsonResult = sr.ReadToEnd();
                }

                AzureSearchValue searchValue  = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize <AzureSearchValue>(jsonResult);
                string           currentMnoID = searchValue.value[0].mno_id;


                CountryEN personCountry = topupDAL.GetCountryByID(pPersonCountryID);
                countryOperatorName = pOperatorName + " " + personCountry;


                OperatorEN operatorFound = topupDAL.GetOperatorByBrand(pPersonCountryID, countryOperatorName);

                if (operatorFound != null)
                {
                    isTheSame = (String.Equals(currentMnoID, operatorFound.OperatorID)) ? true : false;

                    if (!isTheSame)
                    {
                        UpdateCurrentPhone(searchValue.value[0].term_id, Convert.ToString(operatorFound.OperatorID));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                EventViewerLogger.LogError("AzureSearch: " + ex.Message);
            }

            return(isTheSame);
        }