/// <summary> /// Executes a self-registration event. This occurs when an end-user sends a special /// self-register code to the server /// </summary> /// <remarks> /// Self-registration eliminates the need for one person to sit in front of a server all /// day long entering SMS phone numbers for the possibly hundreds of contact tracing staff /// that are being hired /// </remarks> /// <param name="phoneNumber">The phone number of the person attempting to register their phone</param> /// <returns>bool; whether the self-register was successful</returns> public bool ExecuteSmsSelfRegister(string phoneNumber) { bool registered = SmsModule.ExecuteSmsSelfRegister(phoneNumber); try { if (registered) { this.SaveSettings(); } } catch (Exception) { return(false); } return(registered); }
/// <summary> /// Checks to see if a given phone number is in the list of authorized numbers /// </summary> /// <param name="phoneNumber">The phone number to validate</param> /// <returns>bool; whether this phone number is in the list of senders</returns> /// <remarks>Be careful using this method because it will return true if a number is in the list, and /// does not check for the type of update being requested. This method is intended to identify people, e.g. /// to see if a sender is recognized or not; not necessarily to tell if the sender is authorized.</remarks> public bool IsUserInList(string phoneNumber) { return(SmsModule.IsUserInList(phoneNumber)); }
/// <summary> /// Checks to see if a given phone number is an authorized sender /// </summary> /// <param name="phoneNumber">The phone number to validate</param> /// <param name="updateType">The kind of update the sender is attempting</param> /// <returns>bool; whether this phone number is an authorized sender</returns> public bool IsUserAuthorized(string phoneNumber, int updateType) { return(SmsModule.IsUserAuthorized(phoneNumber, updateType)); }
/// <summary> /// Constructor with file path /// </summary> /// <param name="filePath">The file path to the location of the PRJ file</param> public VhfProject(string filePath) : base(filePath) { XDocument doc = XDocument.Load(filePath); XElement root = doc.Root; XElement isVhf = root.Element("IsVHF"); XElement isLab = root.Element("IsLabProject"); XElement outbreakDate = root.Element("OutbreakDate"); XElement outbreakName = root.Element("OutbreakName"); XElement culture = root.Element("Culture"); XElement smsModule = root.Element("SmsModule"); MacAddress = Core.Common.GetMacAddress(); IsVHF = bool.Parse(isVhf.Value); IsLabProject = bool.Parse(isLab.Value); OutbreakDate = new DateTime(long.Parse(outbreakDate.Value)); OutbreakName = outbreakName.Value; if (culture == null) { Culture = String.Empty; //throw new InvalidOperationException("Project's culture settings cannot be null."); // probably don't need an exception here since we're moving to database-based culture checking } else { Culture = culture.Value; } SmsModule = new SmsModule(); // setup SMS module if (smsModule != null) { XElement readReceipts = smsModule.Element("SendsReadReceipts"); if (readReceipts != null) { SmsModule.SendsReadReceipts = bool.Parse(readReceipts.Value); } XElement startupCommands = smsModule.Element("StartupCommands"); if (startupCommands != null) { SmsModule.StartupCommands = startupCommands.Value; } XElement authCode = smsModule.Element("SelfRegistrationCode"); if (authCode != null) { SmsModule.SelfRegistrationCode = authCode.Value; } XElement allowSelfReg = smsModule.Element("AllowsSelfRegistration"); if (allowSelfReg != null) { SmsModule.AllowsSelfRegistration = bool.Parse(allowSelfReg.Value); } XElement pollRate = smsModule.Element("PollRate"); if (pollRate != null) { SmsModule.PollRate = int.Parse(pollRate.Value); } XElement authorizedSenders = smsModule.Element("AuthorizedSmsSenders"); if (authorizedSenders != null) { SmsModule.AuthorizedSmsSenders.Clear(); var query = (from xml in authorizedSenders.Descendants() select xml); foreach (XElement element in query) { if (element.Name.ToString().Equals("AuthorizedSmsSender", StringComparison.OrdinalIgnoreCase)) { string phoneNumber = element.Element("PhoneNumber").Value; SmsSenderInfo sender = new SmsSenderInfo(phoneNumber); sender.Name = element.Element("Name").Value; sender.CanAddUpdateCases = bool.Parse(element.Element("CanAddUpdateCases").Value); sender.CanAddUpdateContacts = bool.Parse(element.Element("CanAddUpdateContacts").Value); sender.CanAddUpdateLabResults = bool.Parse(element.Element("CanAddUpdateLabResults").Value); SmsModule.AuthorizedSmsSenders.Add(sender); } } } } IDbDriver db = this.CollectedData.GetDatabase(); bool connected = db.TestConnection(); if (connected) { Query selectQuery = db.CreateQuery("SELECT * FROM [metaViews]"); DataTable dt = db.Select(selectQuery); foreach (DataRow row in dt.Rows) { if (row["Name"].ToString().Equals(Core.Constants.CASE_FORM_NAME)) { CaseFormId = int.Parse(row["ViewId"].ToString()); } else if (row["Name"].ToString().Equals(Core.Constants.CONTACT_FORM_NAME)) { ContactFormId = int.Parse(row["ViewId"].ToString()); } } } else { throw new InvalidOperationException("No connection to database detected."); } }