protected void ImportContactsFromHistory(object sender, DirectEventArgs e) { sipAccount = CurrentSession.GetEffectiveSipAccount(); string json = e.ExtraParams["Values"]; List <PhoneBookContact> allAddressBookContacts = new List <PhoneBookContact>(); List <PhoneBookContact> filteredAddressBookContacts = new List <PhoneBookContact>(); JavaScriptSerializer serializer = new JavaScriptSerializer(); allAddressBookContacts = serializer.Deserialize <List <PhoneBookContact> >(json); foreach (var contact in allAddressBookContacts) { if (!string.IsNullOrEmpty(contact.Type) && (contact.Type == "Personal" || contact.Type == "Business")) { contact.SipAccount = sipAccount; filteredAddressBookContacts.Add(contact); } } if (filteredAddressBookContacts.Count > 0) { Global.DATABASE.PhoneBooks.InsertMany(filteredAddressBookContacts); GridsDataManager(true); AddressBookGrid.GetStore().Reload(); ImportContactsFromHistoryGrid.GetStore().Reload(); //Update the session's phonebook dictionary and phonecalls list. UpdateSessionRelatedInformation(); } }
protected void DeleteContactButton_DirectEvent(object sender, DirectEventArgs e) { int contactId; string contactIdString; PhoneBookContact contact; contactIdString = Convert.ToString(HelperFunctions.ReturnEmptyIfNull(this.ContactDetails_ContactID.Value)); if (!string.IsNullOrEmpty(contactIdString)) { contactId = Convert.ToInt32(contactIdString); contact = AddressBookData.Find(item => item.Id == contactId); if (contact != null) { Global.DATABASE.PhoneBooks.Delete(contact); GridsDataManager(true); AddressBookGrid.GetStore().Reload(); ImportContactsFromHistoryGrid.GetStore().Reload(); } //Reset the form fields. ResetFormFields(); //Update the session's phonebook dictionary and phonecalls list. UpdateSessionRelatedInformation(); } }
private void GridsDataManager(bool GetFreshData = false, bool BindData = true) { sipAccount = CurrentSession.GetEffectiveSipAccount(); if (GetFreshData == true) { List <PhoneBookContact> TempHistoryData = new List <PhoneBookContact>(); Dictionary <string, PhoneBookContact> TempAddressBookData = new Dictionary <string, PhoneBookContact>(); TempAddressBookData = Global.DATABASE.PhoneBooks.GetAddressBook(sipAccount); TempHistoryData = Global.DATABASE.TopDestinationNumbers.GetBySipAccount(sipAccount, 200).Select( number => { return(new PhoneBookContact() { DestinationNumber = number.PhoneNumber, DestinationCountry = number.Country }); }) .ToList(); //Always clear the contents of the data containers AddressBookData.Clear(); HistoryDestinationNumbers.Clear(); //Normalize the Address Book Data: Convert it from Dictionary to List. foreach (KeyValuePair <string, PhoneBookContact> entry in TempAddressBookData) { AddressBookData.Add(entry.Value); } //Normalize the History: Remove AddressBooks entries. foreach (PhoneBookContact entry in TempHistoryData) { if (!TempAddressBookData.ContainsKey(entry.DestinationNumber)) { HistoryDestinationNumbers.Add(entry); } } TempHistoryData.Clear(); TempAddressBookData.Clear(); } if (BindData == true) { AddressBookGrid.GetStore().DataSource = AddressBookData; AddressBookGrid.GetStore().DataBind(); ImportContactsFromHistoryGrid.GetStore().DataSource = HistoryDestinationNumbers; ImportContactsFromHistoryGrid.GetStore().DataBind(); } }
protected void UpdateAddressBook_DirectEvent(object sender, DirectEventArgs e) { sipAccount = CurrentSession.GetEffectiveSipAccount(); string json = e.ExtraParams["Values"]; List <PhoneBookContact> recordsToUpate = new List <PhoneBookContact>(); List <PhoneBookContact> filteredContactsForUpdate = new List <PhoneBookContact>(); ChangeRecords <PhoneBookContact> toBeUpdated = new StoreDataHandler(e.ExtraParams["Values"]).BatchObjectData <PhoneBookContact>(); if (toBeUpdated.Updated.Count > 0) { foreach (var contact in toBeUpdated.Updated) { if (!string.IsNullOrEmpty(contact.Type) && (contact.Type == "Personal" || contact.Type == "Business")) { if (!string.IsNullOrEmpty(contact.SipAccount)) { contact.SipAccount = sipAccount; } filteredContactsForUpdate.Add(contact); } } if (filteredContactsForUpdate.Count > 0) { //foreach (var contact in filteredContactsForUpdate) //{ // Global.DATABASE.PhoneBooks.Update(contact); //} Global.DATABASE.PhoneBooks.UpdateMany(filteredContactsForUpdate); GridsDataManager(true); AddressBookGrid.GetStore().Reload(); ImportContactsFromHistoryGrid.GetStore().Reload(); } } if (toBeUpdated.Deleted.Count > 0) { Global.DATABASE.PhoneBooks.DeleteMany(toBeUpdated.Deleted.ToList <PhoneBookContact>()); GridsDataManager(true); AddressBookGrid.GetStore().Reload(); ImportContactsFromHistoryGrid.GetStore().Reload(); } //Update the session's phonebook dictionary and phonecalls list. UpdateSessionRelatedInformation(); }
protected void SaveChangesButton_DirectEvent(object sender, DirectEventArgs e) { int contactId; string contactIdString; bool doesExist; PhoneBookContact contact; contactIdString = Convert.ToString(HelperFunctions.ReturnEmptyIfNull(this.ContactDetails_ContactID.Value)); if (!string.IsNullOrEmpty(contactIdString)) { contactId = Convert.ToInt32(contactIdString); doesExist = AddressBookData.Exists(item => item.Id == contactId); if (doesExist == true) { GetFormFieldsValues(out contact); if (!string.IsNullOrEmpty(contact.SipAccount) && !string.IsNullOrEmpty(contact.Type) && !string.IsNullOrEmpty(contact.DestinationNumber)) { Global.DATABASE.PhoneBooks.Update(contact); GridsDataManager(true); AddressBookGrid.GetStore().Reload(); ImportContactsFromHistoryGrid.GetStore().Reload(); } } //Reset the form fields. ResetFormFields(); //Update the session's phonebook dictionary and phonecalls list. UpdateSessionRelatedInformation(); } }
protected void RejectImportChanges_DirectEvent(object sender, DirectEventArgs e) { ImportContactsFromHistoryGrid.GetStore().RejectChanges(); }
protected void AddressbookTabsPanel_TabChange(object send, DirectEventArgs e) { AddressBookGrid.GetStore().Reload(); ImportContactsFromHistoryGrid.GetStore().Reload(); ImportContactsFromOutlookGrid.GetStore().Reload(); }