Пример #1
0
        public Pendo pendoAPI(string SearchEvent)
        {
            Pendo model = new Pendo();

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            string endpoint = ConfigurationManager.AppSettings["PendoAPI"];

            model = GetValues(SearchEvent);

            var httpWebRequest = (HttpWebRequest)WebRequest.Create(endpoint);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            httpWebRequest.Headers.Add("x-pendo-integration-key", "dc22d69f-97ca-4288-52a4-00fe566b48d2");

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(model, Formatting.None, new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });
                streamWriter.Write(json);
                streamWriter.Flush();
                streamWriter.Close();
            }
            try
            {
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var   result      = streamReader.ReadToEnd();
                    var   serializer  = new JavaScriptSerializer();
                    Pendo objResponse = serializer.Deserialize <Pendo>(result);
                    return(objResponse);
                }
            }
            catch (WebException ex)
            {
                using (var stream = ex.Response.GetResponseStream())
                    using (var streamReader = new StreamReader(stream))
                    {
                        var result = streamReader.ReadToEnd();
                        if (result != null)
                        {
                            var   serializer  = new JavaScriptSerializer();
                            Pendo objResponse = JsonConvert.DeserializeObject <Pendo>(result);
                            return(objResponse);
                        }
                    }
            }
            return(null);
        }
Пример #2
0
        //Get data depends on searching criteria
        public ActionResult Index(SearchModel objmodel)
        {
            Helper.CompanyName = Convert.ToString(objmodel.CompanyName);
            Helper.Address     = Convert.ToString(objmodel.Address);
            Helper.City        = Convert.ToString(objmodel.City);
            Helper.State       = Convert.ToString(objmodel.State);
            Helper.PhoneNbr    = Convert.ToString(objmodel.PhoneNbr);
            Helper.Zip         = Convert.ToString(objmodel.Zip);
            Helper.Address1    = Convert.ToString(objmodel.Address2);
            //List<MatchEntity> matches = new List<MatchEntity>();
            MainMatchEntity objmainMatchEntity = new MainMatchEntity();
            //if (objmodel.CompanyName != null && objmodel.Country != null)
            //{
            CommonSearchData common = new CommonSearchData();

            //use common method for get data
            objmainMatchEntity = common.LoadData(objmodel.CompanyName, objmodel.Address, objmodel.Address2, objmodel.City, objmodel.State, objmodel.Country, objmodel.Zip, objmodel.PhoneNbr, objmodel.ExcludeNonHeadQuarters, objmodel.ExcludeNonMarketable, objmodel.ExcludeOutofBusiness, objmodel.ExcludeUndeliverable, objmodel.ExcludeUnreachable, objmodel.Language, null, this.CurrentClient.ApplicationDBConnectionString, null);

            #region Tracking Events Configuration-Pendo API
            Pendo model = new Pendo();
            model.properties = new Properties();
            model.context    = new Context();
            Utility.PendoAPI api = new Utility.PendoAPI();
            // call Pendo API
            model = api.pendoAPI(PendoEvents.SearchData.ToString());
            #endregion

            if (objmainMatchEntity.lstMatches == null)
            {
                objmainMatchEntity.lstMatches = new List <MatchEntity>();
            }
            SessionHelper.SearchMatch = JsonConvert.SerializeObject(objmainMatchEntity.lstMatches);
            SessionHelper.SearchModel = JsonConvert.SerializeObject(objmodel);
            if (Request.IsAjaxRequest())
            {
                ViewBag.SearchedRegNum  = "";
                ViewBag.SearchedWebsite = "";
                return(PartialView("_Index", objmainMatchEntity));
            }
            else
            {
                Tuple <MainMatchEntity, SearchModel> tuple = new Tuple <MainMatchEntity, SearchModel>(objmainMatchEntity, objmodel);
                return(PartialView("Index", tuple));
            }
        }
Пример #3
0
        public Pendo GetValues(string SearchEvent)
        {
            Pendo model = new Pendo();

            model.properties = new Properties();
            model.context    = new Context();

            model.type                   = "track";
            model.@event                 = SearchEvent;
            model.visitorId              = Helper.oUser.EmailAddress;
            model.accountId              = System.Web.HttpContext.Current.Request.Url.Authority;
            model.timestamp              = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
            model.properties.plan        = "";
            model.properties.accountType = "";
            model.context.ip             = Dns.GetHostByName(Dns.GetHostName()).AddressList[0].ToString();
            model.context.userAgent      = System.Web.HttpContext.Current.Request.UserAgent;
            model.context.url            = System.Web.HttpContext.Current.Request.Url.ToString();
            model.context.title          = new System.Uri(System.Web.HttpContext.Current.Request.Url.ToString()).AbsolutePath.Replace("/", "");
            return(model);
        }