예제 #1
0
        /// <summary>
        /// Gets the list of the avatar timestamp on the file system for the user's provided contacts.
        /// </summary>
        /// <param name="contacts">A string containing the ',' separated contacts.</param>
        /// <returns>A list containing user's contacts avatar timestamp.</returns>
        public List <ContactAvatarTimestamp> GetContactsAvatarTimestamp(string contacts)
        {
            char[]       delimeter       = new[] { ',' };
            ulong        avatarTimestamp = 0;
            NeeoFileInfo fileInfo        = null;
            List <ContactAvatarTimestamp> contactlList = new List <ContactAvatarTimestamp>();
            var contactsArray = contacts.Split(delimeter);

            if (contactsArray.Length > 0)
            {
                for (int i = 0; i < contactsArray.Length; i++)
                {
                    contactsArray[i] = contactsArray[i].Trim();
                    NeeoUser               contact                = new NeeoUser(contactsArray[i]);
                    AvatarState            avatarState            = contact.GetAvatarState(0, out avatarTimestamp, out fileInfo);
                    ContactAvatarTimestamp contactAvatarTimestamp = new ContactAvatarTimestamp()
                    {
                        Ph = contactsArray[i],
                        Ts = avatarTimestamp
                    };
                    contactlList.Add(contactAvatarTimestamp);
                    avatarTimestamp = 0;
                    fileInfo        = null;
                }
            }
            return(contactlList);
        }
예제 #2
0
        /// <summary>
        /// Gets the list of the avatar timestamp on the file system for the user's provided contacts.
        /// </summary>
        /// <param name="contacts">A string containing the ',' separated contacts.</param>
        /// <returns>A list containing user's contacts avatar timestamp.</returns>
        public List <ContactStatus> GetContactsAvatarTimestamp(SyncData syncData)
        {
            List <ContactStatus> contactList = new List <ContactStatus>();

            if (syncData.ContactsList.Count > 0)
            {
                foreach (var contact in syncData.ContactsList)
                {
                    ulong        avatarTimestamp = 0;
                    NeeoFileInfo avatarInfo      = null;
                    var          user            = new NeeoUser(contact.PhoneNumber);
                    user.GetAvatarState(0, out avatarTimestamp, out avatarInfo);
                    var contactStatus = new ContactStatus()
                    {
                        Contact         = contact,
                        AvatarTimestamp = avatarTimestamp
                    };
                    contactList.Add(contactStatus);
                }
            }
            return(contactList);
        }
예제 #3
0
        /// <summary>
        /// Gets the contacts state in the user roster for the provided contacts.
        /// </summary>
        /// <param name="contacts">An array of contacts whose state has to be checked in the user roster.</param>
        /// <param name="isUpdatedAppCall">A bool if true tells to use the updated code; otherwise false.</param>
        /// <returns>A list containing the current state of the provided contacts.</returns>
        public List <ContactStatus> GetContactsState(SyncData syncData)
        {
            const string invalidUser    = "******";
            const string notExists      = "0";
            const string exists         = "1";
            const string delimeter      = ",";
            string       contactsString = null;

            contactsString = string.Join(delimeter, syncData.ContactsList.Where(x => x.PhoneNumber != null).Select(x => x.PhoneNumber.Trim()));
            var ContactList     = new List <ContactStatus>();
            var dtContactStatus = new DataTable();
            var dbManager       = new DbManager();

            dtContactStatus = dbManager.GetContactsExistanceAndRosterStatus(_userID, contactsString, delimeter);

            if (dtContactStatus.Rows.Count > 0)
            {
                foreach (DataRow dr in dtContactStatus.Rows)
                {
                    if (!syncData.Filtered)
                    {
                        switch (dr["ContactRosterInfo"].ToString())
                        {
                        case invalidUser:
                        case notExists:
                        case exists:
                            var contactStatus = new ContactStatus();
                            contactStatus.Contact = new Common.Models.Contact()
                            {
                                PhoneNumber = dr["contact"].ToString()
                            };
                            contactStatus.IsNeeoUser          = Convert.ToBoolean(dr["isNeeoUser"]);
                            contactStatus.IsAlreadySubscribed = Convert.ToInt16(dr["contactRosterInfo"]);
                            ContactList.Add(contactStatus);
                            break;

                        default:
                            UserService.UnSubContact(_userID, dr["contactRosterInfo"].ToString(),
                                                     (RosterSubscription)dr["contactSubState"]);
                            break;
                        }
                    }
                    else
                    {
                        switch (dr["ContactRosterInfo"].ToString())
                        {
                        case invalidUser:
                        case notExists:
                        case exists:
                            if (Convert.ToBoolean(dr["isNeeoUser"]))
                            {
                                ulong        avatarTimestamp = 0;
                                NeeoFileInfo avatarInfo      = null;
                                var          contactStatus   = new ContactStatus();
                                contactStatus.Contact = new Common.Models.Contact()
                                {
                                    PhoneNumber = dr["contact"].ToString()
                                };
                                var user = new NeeoUser(contactStatus.Contact.PhoneNumber);
                                user.GetAvatarState(0, out avatarTimestamp, out avatarInfo);
                                contactStatus.AvatarTimestamp     = avatarTimestamp;
                                contactStatus.IsAlreadySubscribed = Convert.ToInt16(dr["contactRosterInfo"]);
                                ContactList.Add(contactStatus);
                            }
                            break;

                        default:
                            UserService.UnSubContact(_userID, dr["contactRosterInfo"].ToString(),
                                                     (RosterSubscription)dr["contactSubState"]);
                            break;
                        }
                    }
                }
            }
            LogManager.CurrentInstance.InfoLogger.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "User ID : " + _userID + "- Contact List :" + JsonConvert.SerializeObject(ContactList));
            return(ContactList);
        }
예제 #4
0
        /// <summary>
        /// Gets the contacts state in the user roster for the provided contacts.
        /// </summary>
        /// <param name="contacts">An array of contacts whose state has to be checked in the user roster.</param>
        /// <param name="isUpdatedAppCall">A bool if true tells to use the updated code; otherwise false.</param>
        /// <returns>A list containing the current state of the provided contacts.</returns>
        public List <ContactDetails> GetContactsRosterState(Contact[] contacts, bool isUpdatedAppCall, bool getAll)
        {
            const string invalidUser    = "******";
            const string notExists      = "0";
            const string exists         = "1";
            const string delimeter      = ",";
            string       contactsString = null;

            if (isUpdatedAppCall)
            {
                contactsString = string.Join(delimeter, contacts.Where(x => x.Ph != null).Select(x => x.Ph.Trim()));
            }
            else
            {
                contactsString = string.Join(delimeter, contacts.Where(x => x.ContactPhoneNumber != null).Select(x => x.ContactPhoneNumber.Trim()));
            }

            List <ContactDetails> lstContact      = new List <ContactDetails>();
            DataTable             dtContactStatus = new DataTable();
            DbManager             db = new DbManager();

            dtContactStatus = db.GetContactsExistanceAndRosterStatus(_userID, contactsString, delimeter);

            if (dtContactStatus.Rows.Count > 0)
            {
                foreach (DataRow dr in dtContactStatus.Rows)
                {
                    if (getAll)
                    {
                        switch (dr["ContactRosterInfo"].ToString())
                        {
                        case invalidUser:
                            ContactDetails contact = new ContactDetails();
                            contact.ContactPhoneNumber  = dr["contact"].ToString();
                            contact.IsNeeoUser          = Convert.ToBoolean(dr["isNeeoUser"]);
                            contact.AvatarState         = (ushort)AvatarState.NotExist;
                            contact.IsAlreadySubscribed = Convert.ToInt16(dr["contactRosterInfo"]);
                            lstContact.Add(contact);
                            break;

                        case notExists:
                        case exists:
                            ulong        avatarTimestamp = 0;
                            NeeoFileInfo avatarInfo      = null;
                            contact = new ContactDetails();
                            contact.ContactPhoneNumber = dr["contact"].ToString();
                            contact.IsNeeoUser         = Convert.ToBoolean(dr["isNeeoUser"]);
                            NeeoUser contactUser = new NeeoUser(contact.ContactPhoneNumber);
                            contact.AvatarState         = (ushort)contactUser.GetAvatarState(0, out avatarTimestamp, out avatarInfo);
                            contact.AvatarTimestamp     = avatarTimestamp;
                            contact.IsAlreadySubscribed = Convert.ToInt16(dr["contactRosterInfo"]);
                            lstContact.Add(contact);
                            break;

                        default:
                            UserService.UnSubContact(_userID, dr["contactRosterInfo"].ToString(),
                                                     (RosterSubscription)dr["contactSubState"]);
                            break;
                        }
                    }
                    else
                    {
                        switch (dr["ContactRosterInfo"].ToString())
                        {
                        case invalidUser:
                        case notExists:
                            //Do nothing
                            break;

                        case exists:
                            ulong          avatarTimestamp = 0;
                            NeeoFileInfo   avatarInfo      = null;
                            ContactDetails contact         = new ContactDetails();
                            contact.ContactPhoneNumber = dr["contact"].ToString();
                            NeeoUser contactUser = new NeeoUser(contact.ContactPhoneNumber);
                            contact.AvatarState         = (ushort)contactUser.GetAvatarState(0, out avatarTimestamp, out avatarInfo);
                            contact.AvatarTimestamp     = avatarTimestamp;
                            contact.IsAlreadySubscribed = Convert.ToInt16(dr["contactRosterInfo"]);
                            lstContact.Add(contact);
                            break;

                        default:
                            UserService.UnSubContact(_userID, dr["contactRosterInfo"].ToString(),
                                                     (RosterSubscription)dr["contactSubState"]);
                            break;
                        }
                    }
                }
            }
            LogManager.CurrentInstance.InfoLogger.LogInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "User ID : " + _userID + "- Contact List :" + JsonConvert.SerializeObject(lstContact));
            return(lstContact);
        }