EpecLocationModel SearchResidentByPhone(string phone) { EpecLocationModel el = null; DataTable data = null; StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM RESIDENT r"); sql.Append(" JOIN EPEC_LOCATION el ON el.Location_Def = r.Location_Ref"); sql.AppendFormat(" WHERE (r.s_phone_1 IS NOT NULL AND r.s_phone_1 = '{0}')", phone); sql.AppendFormat(" OR (r.s_phone_2 IS NOT NULL AND r.s_phone_2 = '{0}')", phone); try { data = _provider.GetData(sql.ToString(), null); LogInfo(string.Format("Running: {0}", sql.ToString())); } catch (Exception e) { LogError(e); } if (data != null && data.Rows.Count > 0) { var row = data.Rows[0]; el = new EpecLocationModel(row); LogInfo(string.Format("Searching Resident for phone {0}", phone)); } return(el); }
EpecLocationModel SearchHomeByPhone(string phone) { EpecLocationModel el = null; DataTable data = null; StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM EPEC_LOCATION"); sql.AppendFormat(" WHERE (equip_phone IS NOT NULL and equip_phone = '{0}')", phone); sql.AppendFormat(" or(other_phone is not null and other_phone = '{0}')", phone); try { data = _provider.GetData(sql.ToString(), null); LogInfo(string.Format("Running: {0}", sql.ToString())); } catch (Exception e) { LogError(e); } if (data != null && data.Rows.Count > 0) { var row = data.Rows[0]; el = new EpecLocationModel(row); LogInfo(string.Format("Searching Home for phone {0}", phone)); } return(el); }
public bool SearchExistingUnit(CellDeviceModel model) { // 20190604 - Search Epec/Resident for the phone and equipId // Fields: e.equip_phone,e.other_phone,r.phone_1,r.phone_2, r.phone_3 // Fields: e.equip_id EpecLocationModel el = null; //1. check the unit first el = SearchHomeByUnit(model.UNIT_ID); if (el != null) { return(true); } //2. search epec for phone el = SearchHomeByPhone(model.MDN); if (el != null) { return(true); } //3 Search resident phone fields el = SearchResidentByPhone(model.MDN); if (el != null) { return(true); } return(false); }
EpecLocationModel SearchHomeByUnit(long unitId) { EpecLocationModel el = null; DataTable data = null; StringBuilder sql = new StringBuilder(); sql.AppendFormat("SELECT * FROM EPEC_LOCATION WHERE EQUIP_ID = {0}", unitId); try { data = _provider.GetData(sql.ToString(), null); LogInfo(string.Format("Running: {0}", sql.ToString())); } catch (Exception e) { LogError(e); } if (data != null && data.Rows.Count > 0) { try { var row = data.Rows[0]; el = new EpecLocationModel(row); LogInfo(string.Format("Creating entity for unit {0}", unitId)); } catch { } } return(el); }
public EpecLocationModel GetHomeByWorkPhone(string phone) { EpecLocationModel el = null; DataTable data = null; StringBuilder sql = new StringBuilder(); sql.Append("SELECT * FROM EPEC_LOCATION el "); sql.Append("JOIN RESIDENT r ON r.LOCATION_REF = el.LOCATION_DEF "); sql.AppendFormat("WHERE el.OTHER_PHONE = '{0}' ", phone); sql.Append("ORDER BY r.PRIORITY ASC"); try { data = _provider.GetData(sql.ToString(), null); LogInfo(string.Format("Running: {0}", sql.ToString())); } catch (Exception e) { LogError(e); } if (data != null) { var row = data.Rows[0]; el = new EpecLocationModel(row); LogInfo(string.Format("Creating entity for phone {0}", phone)); } return(el); }
static void ProcessPhoneNumber(EpecLocationModel home, string phoneNumber, string aneltoAPIUserName) { var model = new AneltoSubscriberUpdateRequest(); try { model.ani = AppConfigurationHelper.StripPhoneNumberField ? home.OTHER_PHONE.Remove(0, 1) : home.OTHER_PHONE; var resident = home.Residents.OrderBy(r => r.PRIORITY).First(); model.firstname = resident.FIRST_NAME; model.lastname = resident.LAST_NAME; model.address = home.ADDRESS_STREET; model.address1 = home.ADDRESS_AREA; model.city = home.ADDRESS_TOWN; model.state = home.ADDRESS_COUNTY; model.zip = home.ADDRESS_POSTCODE; AneltoAPI api = new AneltoAPI(aneltoAPIUserName, AppConfigurationHelper.AneltoAPIPassword); var response = api.SubscriberCreateUpdate(model); log.LogMessage(LogMessageType.INFO, string.Format("Sent to Anelto with resposne {0} for phone number {1}. Data: {2}", response, phoneNumber, model.ToJson())); } catch (Exception ex) { log.LogMessage(LogMessageType.ERROR, string.Format("Failed to send to Anelto API for phone {0}. DATA: {1}. ERROR: {2}", phoneNumber, model.ToJson(), ex.Message)); } // get the latest signal from the event table for the phone number string url = string.Empty; try { var strip = AppConfigurationHelper.StripPhoneNumberField ? phoneNumber.Remove(0, 1) : phoneNumber; url = EventService.Instance.GetUrlBy(strip); } catch (Exception ex) { log.LogMessage(LogMessageType.ERROR, string.Format("Failed to get URL from Event database. ERROR: {0}", ex.Message)); } if (!string.IsNullOrEmpty(url)) { log.LogMessage(LogMessageType.INFO, string.Format("Found url from event table for {0}", url)); try { Process.Start("chrome.exe", url); log.LogMessage(LogMessageType.INFO, string.Format("Opening chrome browser for url {0}", url)); } catch { using (WebBrowser browser = new WebBrowser()) { browser.Navigate(url, "_blank", null, null); } } } }