private bool ModifyGroup(int identity, string modifiedBy, byte[] recipientsArray, int amountOfRecipients) { _logger.Info($"Method for modifying SMS recipients group with ID: {identity} started."); try { SMSrecipientsGroupDefinition definition = _realm.All <SMSrecipientsGroupDefinition>().Single(x => x.Identity == identity); using (var trans = _realm.BeginWrite()) { definition.ModifiedBy = modifiedBy; definition.RecipientsArray = recipientsArray; definition.AmountOfRecipients = amountOfRecipients; trans.Commit(); } _logger.Info($"Modifying SMS recipients group with ID = {identity} successfull."); return(true); } catch (Exception ex) { _logger.Error($"Error while trying to modify existing SMS recipients group with ID: {identity}. Exception: {ex.Message}."); return(false); } }
private List <byte> GetRecipientsIDList() { //create reader instance SMSrecipientsGroupReader reader = new SMSrecipientsGroupReader(_realmProvider); //get definition of SMS group SMSrecipientsGroupDefinition alarmGroupDefinition = reader.GetDetailedGroupDefinitionFromDB(_SMSgroupID); //return list of recipients IDs return(alarmGroupDefinition.RecipientsArray.ToList()); }
private void ChangeHeadingProperties() { _logger.Info($"Populating heading data with information of specific recipients group."); if (SelectedShortGroup != null) { SMSrecipientsGroupDefinition definition = _originalRecipientsGroups.Single(x => x.Identity == SelectedShortGroup.Identity); CreatedBy = definition.CreatedBy; ModifiedBy = definition.ModifiedBy; AmountOfreceivers = definition.AmountOfRecipients; PopulateSMSRecipipentsOnSingleGroupListView(definition.Identity); } else { CreatedBy = "-----"; ModifiedBy = "-----"; AmountOfreceivers = 0; GroupRecipientsList.Clear(); } }
private void ExecuteDeletionFromGroupsAlgorithm(int identity) { List <SMSrecipientsGroupDefinition> groups = GetAllGroups(); foreach (var item in groups) { //if this particular group contains the deleted receiver if (item.RecipientsArray.Contains((byte)identity)) { _logger.Info($"Found new SMS recipients group with recipient of DI: {identity}. Group ID: {item.Identity}."); //get original group SMSrecipientsGroupDefinition definition = _realm.All <SMSrecipientsGroupDefinition>().Single(x => x.Identity == item.Identity); //generating new recipients list List <byte> newRecipientsList = new List <byte>(); foreach (var item2 in definition.RecipientsArray) { //add new if identity is not equal to the deleted one if (item2 != (byte)identity) { newRecipientsList.Add(item2); } } _logger.Info($"Deleting SMS recipient from Group of ID: {item.Identity}."); //saving changes to DB using (var trans = _realm.BeginWrite()) { definition.RecipientsArray = newRecipientsList.ToArray(); definition.AmountOfRecipients = newRecipientsList.Count; trans.Commit(); } } } }
public bool DeleteSMSrecipientsGroup(int identity) { _logger.Info($"Method for deleting SMS recipients group with ID: {identity} from DB, fired."); try { SMSrecipientsGroupDefinition definition = _realm.All <SMSrecipientsGroupDefinition>().Single(x => x.Identity == identity); using (var trans = _realm.BeginWrite()) { _realm.Remove(definition); trans.Commit(); } _logger.Info($"Deletion of SMS recipients group with ID: {identity} successfull."); return(true); } catch (Exception ex) { _logger.Error($"Error while trying to delete existing SMS recipients group with ID: {identity}, from DB: {ex.Message}."); return(false); } }