示例#1
0
 public void LoadAsync(UserAccount userAccount)
 {
     mStoreUserDirectory = mStoreBaseDirectory + @"\" + userAccount.Username;
     mUserAccount = userAccount;
     ThreadStart st = new ThreadStart(LoadContactsBookFunction);
     mLoadContactsBookThread = new Thread(st);
     // start the thread
     mLoadContactsBookThread.Start();
 }
示例#2
0
        public RPhoneBook(UserAccount userAccount, bool storeOnline)
        {
            _userAccount = userAccount;
            _contactList = Persistence;
            _storeOnline = storeOnline;

        }
示例#3
0
        public void Load(UserAccount userAccount)
        {
            mUserAccount = userAccount;

            #region Local Store
            if (UseLocalStore)
            {
                try
                {
                    XmlSerializer xser = new XmlSerializer(typeof(NTContact[]));
                    StreamReader sr = new StreamReader(mStoreUserDirectory + mStoreFilename);
                    NTContact[] contacts = (NTContact[])xser.Deserialize(sr);
                    sr.Close();
                    lock (this)
                    {
                        foreach (NTContact contact in contacts)
                        {
                            contact.NTContactStore = NTContactStoreType.Local;
                            if (!this.Contains(contact) && contact.NTDeleted != "true") this.Add(contact);
                        }
                    }
                }
                catch (Exception ex)
                {
#if (TRACE)
                    Console.WriteLine("Load Contacts Book | Local Store : Failed - " + ex.Message);
#endif
                }
            }
            #endregion

#if !(REMWAVE_LITE)
            #region Server Store
            if (UseServerStore)
            {
                try
                {
                    Remwave.Client.RSIFeaturesWS.RSIService ss = new Remwave.Client.RSIFeaturesWS.RSIService();
                    XmlSerializer xser = new XmlSerializer(typeof(NTContact[]));

                    string sout = ss.servicePhonebookGet(mUserAccount.Username, mUserAccount.Password, mProperties, null);
#if (TRACE)
                    Console.WriteLine("PHONEBOOK-GET: " + userAccount.Username + " Done");
#endif

                    StringReader sr = new StringReader(sout);
                    NTContact[] ntc = (NTContact[])xser.Deserialize(sr);
                    sr.Close();
                    lock (this)
                    {
                        foreach (NTContact contact in ntc)
                        {
                            contact.NTContactStore = NTContactStoreType.Server;
                            if (!this.Contains(contact)) this.Add(contact);
                        }
                    }

                }
                catch (Exception ex)
                {
#if (TRACE)
                    Console.WriteLine("Load Contacts Book | Server Store : Failed - " + ex.Message);
#endif
                }

            }
            #endregion

            #region Outlook Store
            if (UseOutlookStore)
            {

                Outlook.Application oApp = new Outlook.Application();
                Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
                Outlook.MAPIFolder oContactsFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

                try
                {
                    string filter = "[MessageClass] = \"IPM.Contact\"";
                    Outlook.Items oContactItems = oContactsFolder.Items.Restrict(filter);
                    lock (this)
                    {
                        foreach (Outlook.ContactItem item in oContactItems)
                        {
                            try
                            {
                                NTContact contact = NTTranslator((Outlook.ContactItem)item);
                                contact.NTContactStore = NTContactStoreType.Outlook;
                                if (!this.Contains(contact)) this.Add(contact);
                            }
                            catch (Exception ex)
                            {
#if (TRACE)
                                Console.WriteLine("Load : UseOutlookStore - " + ex.Message);
#endif
                            }
                        }
                    }
                    oContactItems = null;
                }
                catch (Exception ex)
                {
#if (TRACE)
                    Console.WriteLine("Load Contacts Book | Outlook Store : Failed - " + ex.Message);
#endif
                }

                oApp = null;
                oNS = null;

            }
            #endregion
#endif
            OnUpdateCompleted(this, new EventArgs());
        }
示例#4
0
        public WEBPhoneBook(UserAccount myUserAccount)
        {
            userAccount = myUserAccount;
            contactList = Persistence;

        }