Example #1
0
        public void GetRegisteredPhoneNumbers(List<string> userPhoneNumbers, Action<List<YapperChat.Models.ContactGroup<YapperChat.Models.UserModel>>> callback)
        {
            List<ContactGroup<UserModel>> tempItems = null;
            if (this.Users != null)
            {
                tempItems = new List<ContactGroup<UserModel>>();
                var groups = new Dictionary<char, ContactGroup<UserModel>>();

                foreach (var user in this.Users)
                {
                    char firstLetter = char.ToLower(user.Name[0]);

                    // show # for numbers
                    if (firstLetter >= '0' && firstLetter <= '9')
                    {
                        firstLetter = '#';
                    }

                    // create group for letter if it doesn't exist
                    if (!groups.ContainsKey(firstLetter))
                    {
                        var group = new ContactGroup<UserModel>(firstLetter);
                        tempItems.Add(group);
                        groups[firstLetter] = group;
                    }

                    // create a contact for item and add it to the relevant
                    groups[firstLetter].Add(user);
                }
            }

            callback(tempItems);
        }
Example #2
0
 void IContactGroupService.Create(ContactGroup contactGroup)
 {
     _repository.Add(contactGroup);
     if (this._log.IsInfoEnabled)
     {
         this._log.InfoFormat("新增联系人组#{0}|{1}|{2}", contactGroup.ID, contactGroup.Name, contactGroup.AddressBookId);
     }
 }
Example #3
0
 public ContactGroup GetGroup(string name)
 {
     ContactGroup g = Groups.FirstOrDefault(x => x.Name == name);
     if (g == null)
     {
         g = new ContactGroup(name);
         Persistence.Session.Save(g);
         Persistence.Session.Flush();
         Groups.Add(g);
     }
     return g;
 }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     var contactGroup = new ContactGroup();
     contactGroup.Name = txtName.Text;
     contactGroup.OwnerId = Convert.ToInt32(Session["uid"]);
     contactGroup.IsDelete = false;
     contactGroup.CreatedOn = DateTime.Now;
     _dbScheduler.ContactGroups.InsertOnSubmit(contactGroup);
     _dbScheduler.SubmitChanges();
     txtName.Text = "";
     BindGroup();
 }
Example #5
0
        public void CreateContactGroup()
        {
            var personalAddressBook = this.CreatePersonalAddressBook();
            var contactGroup = new ContactGroup(personalAddressBook, "Contact Group1");

            Assert.AreNotEqual(DateTime.MinValue, contactGroup.CreateTime);

            this._contactGroupService.Create(contactGroup);
            Assert.Greater(contactGroup.ID, 0);

            this.Evict(contactGroup);

            var contactGroup2 = this._contactGroupService.GetContactGroup(contactGroup.ID) as ContactGroup;

            Assert.AreEqual(contactGroup.Name, contactGroup2.Name);
            Assert.AreEqual(contactGroup.AddressBookId, personalAddressBook.ID);
            Assert.AreEqual(FormatTime(contactGroup.CreateTime), FormatTime(contactGroup2.CreateTime));
        }
Example #6
0
        public void GetContactGroups()
        {
            var personalAddressBook = this.CreatePersonalAddressBook();
            var contactGroup1 = new ContactGroup(personalAddressBook, "Contact Group1");
            var contactGroup2 = new ContactGroup(personalAddressBook, "Contact Group1");
            var contactGroup3 = new ContactGroup(personalAddressBook, "Contact Group1");

            this._contactGroupService.Create(contactGroup1);
            this._contactGroupService.Create(contactGroup2);
            this._contactGroupService.Create(contactGroup3);

            this.Evict(contactGroup1);
            this.Evict(contactGroup2);
            this.Evict(contactGroup3);

            var contactGroups = this._contactGroupService.GetContactGroups(personalAddressBook);

            Assert.AreEqual(3, contactGroups.Count());
        }
Example #7
0
        public void DeleteContactGroup()
        {
            var personalAddressBook = this.CreatePersonalAddressBook();
            var contactGroup = new ContactGroup(personalAddressBook, "Contact Group1");

            Assert.AreNotEqual(DateTime.MinValue, contactGroup.CreateTime);

            this._contactGroupService.Create(contactGroup);
            Assert.Greater(contactGroup.ID, 0);

            this.Evict(contactGroup);

            var contactGroup2 = this._contactGroupService.GetContactGroup(contactGroup.ID) as ContactGroup;

            this._contactGroupService.Delete(contactGroup2);

            this.Evict(contactGroup2);

            var contactGroup3 = this._contactGroupService.GetContactGroup(contactGroup2.ID) as ContactGroup;

            Assert.IsNull(contactGroup3);
        }
Example #8
0
        public static ObservableSortedList<ContactGroup<UserModel>> GroupUsers(IList<UserModel> users)
        {
            ObservableSortedList<ContactGroup<UserModel>> groups = new ObservableSortedList<ContactGroup<UserModel>>();
            var groupsDict = new Dictionary<char, ContactGroup<UserModel>>();

            foreach (UserModel user in users)
            {

                if (user.UserType == UserType.Group)
                {
                    if (!user.Name.Contains("(G)"))
                    {
                        user.Name += " (G)";
                    }
                }

                char firstLetter = char.ToLower(user.Name[0]);

                // show # for numbers
                if (firstLetter >= '0' && firstLetter <= '9')
                {
                    firstLetter = '#';
                }

                // create group for letter if it doesn't exist
                if (!groupsDict.ContainsKey(firstLetter))
                {
                    var group = new ContactGroup<UserModel>(firstLetter);
                    groups.Add(group);
                    groupsDict[firstLetter] = group;
                }

                // create a contact for item and add it to the relevant
                groupsDict[firstLetter].Add(user);
            }

            return groups;
        }
Example #9
0
        public IList <ContactPerson> UpdateContactUpdateTimeByGroup(string groupID, string updateTime)
        {
            int updateCount = 0;

            IList <ContactPerson> contactPersons = (from aa in contactPersonRepository.Table
                                                    join bb in contactGroupSubRepository.Table on aa.ObjectID equals bb.ContactPersonObjectID
                                                    where bb.ContactGroupID == groupID
                                                    select aa).ToList();

            foreach (ContactPerson contactPerson in contactPersons)
            {
                contactPerson.UpdateTime = updateTime;
            }

            updateCount = contactPersonRepository.BatchUpdate(contactPersons);

            ContactGroup contactGroup = contactGroupRepository.Table.Where(t => t.GroupObjectID == groupID).FirstOrDefault();

            contactGroup.UpdateTime = updateTime;

            contactGroupRepository.Update(contactGroup);

            return(contactPersons);
        }
Example #10
0
 public ContactGroup Update(ContactGroup item)
 {
     return(ContactGroups.Update(item));
 }
Example #11
0
        //Contructs the Initial GroupMembership after a refresh/
        public void ConstructGroupMemberships(Contact contact)
        {
            var toggleGroupsToAdd = new List <GroupMembershipViewModel>();

            //First add the Toggle Groups
            foreach (var tG in AppCore.Settings.ToggleGroups.OrderBy(tG => tG))
            {
                ContactGroup          contactGroup = AppCore.Model.ContactGroups.ValueOrDefault(tG);
                ContactGroupViewModel contactGroupViewModel;
                if (contactGroup == null)
                {
                    contactGroupViewModel = new ContactGroupViewModel()
                    {
                        Name = tG, CannotBeDeleted = false
                    }
                }
                ;                                                                                                                     //If group is not found in Model, this means the group just exists in th toggle settings. Id must be null.
                else
                {
                    contactGroupViewModel = new ContactGroupViewModel(contactGroup);
                }
                toggleGroupsToAdd.Add(new GroupMembershipViewModel()
                {
                    MembershipLinkId        = null, //This means the contact has not joined this group yet
                    ContactGroup            = contactGroupViewModel,
                    Joined                  = false,
                    GroupMembershipChipType = GroupMembershipChipType.Group,
                    Contact                 = this
                });
            }

            //Then add the other groups which the contact has joined
            var groupsToAdd = new List <GroupMembershipViewModel>();

            foreach (var groupMembership in contact.GroupMemberships)
            {
                var gMVM = toggleGroupsToAdd.FirstOrDefault(g => g.ContactGroup.Name == groupMembership.GroupName);
                if (gMVM != null)
                {
                    gMVM.Joined = true;
                }
                else
                {
                    if (!AppCore.Model.ContactGroups.TryGetValue(groupMembership.GroupName, out ContactGroup contactGroup))
                    {
                        contactGroup = new ContactGroup(groupMembership.GroupName, false, new List <GroupGoogleAccounts>());
                    }
                    groupsToAdd.Add(new GroupMembershipViewModel()
                    {
                        MembershipLinkId        = groupMembership.MembershipLinkId,
                        ContactGroup            = new ContactGroupViewModel(contactGroup),
                        Joined                  = true,
                        GroupMembershipChipType = GroupMembershipChipType.Group,
                        Contact                 = this
                    });
                }
            }

            //Finally add the remaining groups not joined by the contact
            foreach (ContactGroup contactGroup in AppCore.Model.ContactGroups.Where(g => !toggleGroupsToAdd.Any(tG => tG.ContactGroup.Name == g.Key) && !groupsToAdd.Any(g2 => g2.ContactGroup.Name == g.Key)).Select(e => e.Value))
            {
                groupsToAdd.Add(new GroupMembershipViewModel()
                {
                    Contact                 = this,
                    ContactGroup            = new ContactGroupViewModel(contactGroup),
                    GroupMembershipChipType = GroupMembershipChipType.Group,
                    Joined = false
                });
            }
            var groupsToAddSorted = groupsToAdd.OrderBy(g => g.ContactGroup.Name);

            toggleGroupsToAdd.AddRange(groupsToAddSorted);
            this.GroupMemberships.Clear();
            this.GroupMemberships.AddRange(toggleGroupsToAdd);
        }
 partial void DeleteContactGroup(ContactGroup instance);
Example #13
0
 void IContactGroupService.Update(ContactGroup contactGroup)
 {
     _repository.Update(contactGroup);
 }
Example #14
0
        /**
         * List, add, or delete Contacts.
         *
         * @param mySession
         *	Populated session object.
         * @param pstn
         *  Properly formatted phone number of the target PSTN Contact.
         * @param displayName
         *  Display name of the target PSTN Contact (used by add <em>only</em>).
         * @param commandOpt
         *  Command string, which must be one of:
         *  <ul>
         *    <li>{@link #ADD_CONTACT}</li>
         *    <li>{@link #DELETE_CONTACT}</li>
         *    <li>{@link #LIST_CONTACTS}</li>
         *  </ul>
         *
         * @since 1.0
         */
        static void doPstnContact(MySession mySession, String pstn, String displayName, String commandOpt)
        {
            // Verify that our command option is valid -- something our invoker should have already done!
            if ((!(commandOpt.Equals(LIST_CONTACTS))) && (!(commandOpt.Equals(ADD_CONTACT))) &&
                (!(commandOpt.Equals(DELETE_CONTACT))))
            {
                // We shouldn't get here -- the invoker should have already validated the command.
                MySession.myConsole.printf("%s: Unrecognized command option: %s%n", mySession.myTutorialTag, commandOpt);
                return;
            }

            int contactIdx;

            Skype.NormalizeIdentityResponse nrmlResponse = null;

            ContactGroup soContactGroup = mySession.mySkype.getHardwiredContactGroup(ContactGroup.Type.SKYPEOUT_BUDDIES);

            Contact[] soContactList = soContactGroup.getContacts();
            int       contactCount  = soContactList.Length;

            // Handle list operations...
            if (commandOpt.Equals(LIST_CONTACTS))
            {
                // Make sure there's something to list!
                if (contactCount == 0)
                {
                    MySession.myConsole.printf("%s: There are no PSTN contacts.%n", mySession.myTutorialTag);
                    return;
                }
                MySession.myConsole.printf("%s: Current list of PSTN contacts:%n", mySession.myTutorialTag);
                for (contactIdx = 0; contactIdx < contactCount; contactIdx++)
                {
                    MySession.myConsole.printf("%s: %d. %s (%s)%n", mySession.myTutorialTag, (contactIdx + 1),
                                               soContactList[contactIdx].getPstnNumber(),
                                               soContactList[contactIdx].getDisplayName());
                }
                return;
            }

            //Handle add & delete operations...
            String contactPstn;
            bool   contactAlreadyListed = false;

            // Ensure that the pstn argument contains a valid contact identity
            nrmlResponse = getNormalizationStr(pstn);
            if (nrmlResponse.result != Skype.NormalizeResult.IDENTITY_OK)
            {
                MySession.myConsole.printf("%s: Cannot normalize pstn %s using %s%n",
                                           mySession.myTutorialTag, pstn,
                                           mySession.mySkype.getIsoCountryInfo().countryPrefixList[0]);
                return;
            }

            // Check whether the PSTN contact already exists, which is relevant to both
            // adding and removing contacts. In current wrapper version, the only way to do this
            // is to loop over a contact group.
            for (contactIdx = 0; contactIdx < contactCount; contactIdx++)
            {
                contactPstn = soContactList[contactIdx].getPstnNumber();
                if (contactPstn.Equals(nrmlResponse.normalized))
                {
                    contactAlreadyListed = true;
                }
            }

            // Handle adding a Contact. The Contact must not exist in that group!
            if (commandOpt.Equals(ADD_CONTACT))
            {
                if (contactAlreadyListed)
                {
                    MySession.myConsole.printf("%s: Error: %s already present in ContactGroup.%n",
                                               mySession.myTutorialTag, nrmlResponse.normalized);
                    return;
                }
                MySession.myConsole.printf("%s: Adding PSTN Contact...%n", mySession.myTutorialTag);
                Contact newContact = mySession.mySkype.getContact(nrmlResponse.normalized);
                if ((newContact != null) && (soContactGroup.canAddContact(newContact)))
                {
                    newContact.giveDisplayName(displayName);
                    soContactGroup.addContact(newContact);
                    MySession.myConsole.printf("%s: Contact %s (%s) added.%n",
                                               mySession.myTutorialTag, nrmlResponse.normalized, displayName);
                }
                else
                {
                    ContactGroup.Type soContactGroupType = soContactGroup.getType();
                    MySession.myConsole.printf("%s: Cannot add Contact %s (%s) to ContactGroup %s (\"%s\") using AddContact():%n",
                                               mySession.myTutorialTag, nrmlResponse.normalized, displayName,
                                               soContactGroupType.toString(),
                                               soContactGroup.getGivenDisplayName());
                    if (newContact == null)
                    {
                        MySession.myConsole.println("\tCould not create new Contact (normalized PSTN likely invalid)");
                    }
                    else if (!(soContactGroup.canAddContact(newContact)))
                    {
                        MySession.myConsole.println("\tCannot add Contacts to target ContactGroup");
                    }
                    else
                    {
                        MySession.myConsole.println("\tReason unknown?!?%n");
                    }
                }
                return;
            }

            // Handle deleting a Contact. The Contact must exist in that group!
            if (!contactAlreadyListed)
            {
                MySession.myConsole.printf("%s: PSTN Contact %s not present in ContactGroup.%n",
                                           mySession.myTutorialTag, nrmlResponse.normalized);
                return;
            }

            MySession.myConsole.printf("%s: Removing PSTN Contact...%n", mySession.myTutorialTag);
            Contact removableContact = mySession.mySkype.getContact(nrmlResponse.normalized);

            if ((removableContact != null) && (soContactGroup.canRemoveContact()))
            {
                String removableDisplayName = removableContact.getDisplayName();
                soContactGroup.removeContact(removableContact);
                // Can't include any Contact-specific identifying information in the message that we haven't already
                // extracted since RemoveContact leaves the target Contact instance in an undefined (mostly nulled-out) state!
                MySession.myConsole.printf("%s: Removed PSTN Contact %s (\"%s\").%n",
                                           mySession.myTutorialTag, nrmlResponse.normalized, removableDisplayName);
            }
            else
            {
                ContactGroup.Type soContactGroupType = soContactGroup.getType();
                MySession.myConsole.printf("%s: Cannot remove Contact %s from ContactGroup %s (\"%s\") using RemoveContact():%n",
                                           mySession.myTutorialTag, nrmlResponse.normalized,
                                           soContactGroupType.toString(),
                                           soContactGroup.getGivenDisplayName());
                if (removableContact == null)
                {
                    MySession.myConsole.println("\tCould not remove Contact (normalized PSTN likely invalid)");
                }
                else if (!(soContactGroup.canRemoveContact()))
                {
                    MySession.myConsole.println("\tCannot remove Contacts from target ContactGroup");
                }
                else
                {
                    MySession.myConsole.println("\tReason unknown?!?%n");
                }
            }

            return;
        }
 public static IList <string> GetPersons(ISession session, ContactGroup contactGroup)
 {
     return(session.CreateSQLQuery("select Name from contacts.persons where ContactGroupId = :contactGroupId")
            .SetParameter("contactGroupId", contactGroup.Id)
            .List <string>());
 }
        public async Task Run <T>() where T : class
        {
            string field  = _task.PriorityField;
            var    client = new HttpClient();

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            var result = await client.GetAsync(_task.Url);

            if (result.IsSuccessStatusCode)
            {
                var message = await result.Content.ReadAsStringAsync();

                var messageAsObject       = JsonSerializer.Deserialize <Dictionary <string, object> >(message);
                var status                = "Failed";
                var conditionalExpression = false;
                messageAsObject.TryGetValue(field, out object value);
                if (int.TryParse(value.ToString(), out int intValue))
                {
                    conditionalExpression = GetExpressionInt(int.Parse(_task.ConditionalExpression[1]), _task.ConditionalExpression[0])
                                            .Compile()(intValue);
                }
                else
                {
                    conditionalExpression = GetExpressionString(_task.ConditionalExpression[1], _task.ConditionalExpression[0])
                                            .Compile()(value.ToString());
                }


                if (conditionalExpression)
                {
                    status = "Successful";
                    var task = _dataContext.ReoccurringJob.FirstOrDefault(e => e.Id == _task.Id);
                    task.AlertSent = false;
                    _dataContext.SaveChanges();
                }
                else if (_task.AlertSent == false)
                {
                    ContactGroup group = _dataContext.ContactGroups
                                         .Include(e => e.Contacts)
                                         .ThenInclude(e => e.User)
                                         .ThenInclude(e => e.ContactInfo)
                                         .FirstOrDefault(e => e.Id == _task.ContactGroup_Id);

                    System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                    foreach (var contact in group.Contacts)
                    {
                        mail.To.Add(contact.User.ContactInfo.Email);
                    }
                    mail.From            = new MailAddress("*****@*****.**", "24x7 System Monitoring", System.Text.Encoding.UTF8);
                    mail.Subject         = "Task " + _task.Name + " has failed";
                    mail.SubjectEncoding = System.Text.Encoding.UTF8;
                    mail.Body            = "We found a error occuring in the " + _task.Name + " task at " + DateTime.UtcNow.ToString() + ". Please log on to check the error";
                    mail.BodyEncoding    = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml      = true;
                    mail.Priority        = MailPriority.High;
                    SmtpClient smtp_client = new SmtpClient();
                    smtp_client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Plant123");
                    smtp_client.Port        = 587;
                    smtp_client.Host        = "smtp.gmail.com";
                    smtp_client.EnableSsl   = true;
                    try
                    {
                        smtp_client.Send(mail);
                    }
                    catch (Exception)
                    {
                    }

                    var task = _dataContext.ReoccurringJob.FirstOrDefault(e => e.Id == _task.Id);
                    task.AlertSent = true;
                    _dataContext.SaveChanges();
                }

                try
                {
                    CurrentJobResult current_job = _dataContext.CurrentJobResults.FirstOrDefault(job => job.ReoccurringJobId == _task.Id);

                    if (current_job != null)
                    {
                        current_job.Date   = DateTime.Now;
                        current_job.Status = status;
                    }
                    else
                    {
                        _dataContext.CurrentJobResults.Add(new CurrentJobResult
                        {
                            Date             = DateTime.Now,
                            ReoccurringJobId = _task.Id,
                            Name             = _task.Name,
                            Status           = status,
                        });
                    }

                    _dataContext.JobHistories.Add(new JobHistory
                    {
                        Date             = DateTime.Now,
                        ReoccurringJobId = _task.Id,
                        Name             = _task.Name,
                        Status           = status,
                    });
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                _dataContext.SaveChanges();
            }
        }
        private string HandleMMSUAInfo(ContactData contactData, IContactPersonService contactPersonService)
        {
            try
            {
                int           temp          = 0;
                ContactPerson contactPerson = contactPersonService.FindContactPerson(contactData.ObjectID);

                if (contactPerson == null)
                {
                    CommonVariables.LogTool.Log("ContactPerson " + contactData.ObjectID + " can not find");
                    return(string.Empty);
                }

                if (contactData.DataType == 0)
                {
                    contactPerson.ContactName = contactData.ContactName;
                    contactPerson.ImageSrc    = contactData.ImageSrc;
                    contactPerson.LatestTime  = contactData.LatestTime;
                    if (contactData.UpdateTime.CompareTo(contactPerson.UpdateTime) > 0)
                    {
                        contactPerson.UpdateTime = contactData.UpdateTime;
                    }
                    contactPersonService.UpdateContactPerson(contactPerson);
                }


                if (contactData.DataType == 1)
                {
                    ContactPersonList contactPersonList = contactPersonService.FindContactPersonList(contactData.ObjectID, contactData.DestinationObjectID);
                    if (contactPersonList == null)
                    {
                        contactPersonList = new ContactPersonList();
                        contactPersonList.DestinationObjectID = contactData.DestinationObjectID;
                        contactPersonList.IsDelete            = contactData.IsDelete;
                        contactPersonList.ObjectID            = contactData.ObjectID;
                        contactPersonList.UpdateTime          = contactData.UpdateTime;
                        contactPersonService.InsertContactPersonList(contactPersonList);
                    }
                    else
                    {
                        contactPersonList.IsDelete   = contactData.IsDelete;
                        contactPersonList.UpdateTime = contactData.UpdateTime;
                        contactPersonService.UpdateContactPersonList(contactPersonList);
                    }

                    if (contactPersonList.UpdateTime.CompareTo(contactPerson.UpdateTime) > 0)
                    {
                        contactPerson.UpdateTime = contactPersonList.UpdateTime;
                        contactPersonService.UpdateContactPerson(contactPerson);
                    }
                }
                else if (contactData.DataType == 2)
                {
                    ContactGroup contactGroup = contactPersonService.FindContactGroup(contactData.GroupObjectID);
                    if (contactGroup == null)
                    {
                        contactGroup               = new ContactGroup();
                        contactGroup.GroupName     = contactData.GroupName;
                        contactGroup.GroupObjectID = contactData.GroupObjectID;
                        contactGroup.IsDelete      = contactData.IsDelete;
                        contactGroup.UpdateTime    = contactData.UpdateTime;
                        contactPersonService.InsertNewGroup(contactGroup);
                    }
                    else
                    {
                        contactGroup.GroupName  = contactData.GroupName;
                        contactGroup.IsDelete   = contactData.IsDelete;
                        contactGroup.UpdateTime = contactData.UpdateTime;
                        contactPersonService.UpdateContactGroup(contactGroup);
                    }

                    if (contactGroup.UpdateTime.CompareTo(contactPerson.UpdateTime) > 0)
                    {
                        contactPerson.UpdateTime = contactGroup.UpdateTime;
                        contactPersonService.UpdateContactPerson(contactPerson);
                    }
                }
                else if (contactData.DataType == 3)
                {
                    ContactGroupSub contactGroupSub = contactPersonService.FindContactGroupSub(contactData.ContactGroupID, contactData.ContactPersonObjectID);
                    if (contactGroupSub == null)
                    {
                        contactGroupSub = new ContactGroupSub();
                        contactGroupSub.ContactGroupID        = contactData.ContactGroupID;
                        contactGroupSub.ContactPersonObjectID = contactData.ContactPersonObjectID;
                        contactGroupSub.IsDelete   = contactData.IsDelete;
                        contactGroupSub.UpdateTime = contactData.UpdateTime;
                        contactPersonService.InsertContactGroupSub(contactGroupSub);
                    }
                    else
                    {
                        contactGroupSub.IsDelete   = contactData.IsDelete;
                        contactGroupSub.UpdateTime = contactData.UpdateTime;
                        contactPersonService.UpdateContactGroupSub(contactGroupSub);
                    }

                    if (contactGroupSub.UpdateTime.CompareTo(contactPerson.UpdateTime) > 0)
                    {
                        contactPerson.UpdateTime = contactGroupSub.UpdateTime;
                        contactPersonService.UpdateContactPerson(contactPerson);
                    }
                }
                return(contactData.ContactDataID);
            }
            catch (Exception ex)
            {
                CommonVariables.LogTool.Log("get UAInfo " + ex.Message + ex.StackTrace);
                return(string.Empty);
            }
        }
Example #18
0
 public Task <ContactGroup> CreateAsync(ContactGroup item)
 {
     return(ContactGroups.CreateAsync(item));
 }
Example #19
0
 /**
  * SkypeListener Override.
  *
  * @since 1.0
  *
  * @see com.skype.api.SkypeListener#onNewCustomContactGroup(com.skype.api.Skype, com.skype.api.ContactGroup)
  */
 public void onNewCustomContactGroup(Skype obj, ContactGroup group)
 {
     Log.d("Tutorial", "onNewCustomContactGroup(" + group + ")");
 }
Example #20
0
        public bool CreateFile(object objectToMap)
        {
            try
            {
                string env          = string.Empty;
                string baseFilePath = string.Empty;
                string objectFoler  = string.Empty;
                string fullPath     = string.Empty;
                string sRaw         = string.Empty;

                // Check platform and env path.
                env = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? Constants.AppSettings.LinuxFilePath.ToLower() : Constants.AppSettings.WindowsFilePath.ToLower();

                // get the setting base on env.
                List <Setting> settings = new List <Setting>();
                settings = _applicationDbContext.Settings.ToList();

                // get the base path.
                baseFilePath = settings.Where(c => c.Key.ToLower() == env).FirstOrDefault().Value;


                // build out the output path.
                if (objectToMap is Contact)
                {
                    Contact contact = objectToMap as Contact;
                    objectFoler = settings.Where(c => c.Key.ToLower() == Constants.AppSettings.ContactsFilePath.ToLower()).FirstOrDefault().Value;
                    fullPath    = Path.Combine(baseFilePath, objectFoler, string.Format("{0}.cfg", contact.Name));
                    // read the template
                    sRaw = File.ReadAllText(Path.Combine(_env.WebRootPath, "Templates/contactTemplate.cfg"));

                    // replace vars.
                    sRaw = sRaw.Replace("$NAME", contact.Name).Replace("$ALIAS", contact.Alias).Replace("$EMAIL", contact.EmailAddress);
                }
                else if (objectToMap is ContactGroup)
                {
                    ContactGroup contactGroup = objectToMap as ContactGroup;
                    objectFoler = settings.Where(c => c.Key.ToLower() == Constants.AppSettings.ContactGroupsFilePath.ToLower()).FirstOrDefault().Value;
                    fullPath    = Path.Combine(baseFilePath, objectFoler, string.Format("{0}.cfg", contactGroup.GroupName));
                    // read the template
                    sRaw = File.ReadAllText(Path.Combine(_env.WebRootPath, "Templates/contactGroupTemplate.cfg"));

                    // replace vars.
                    sRaw = sRaw.Replace("$GROUPNAME", contactGroup.GroupName).Replace("$ALIAS", contactGroup.Alias).Replace("$MEMBERS", contactGroup.Members);
                }
                else if (objectToMap is Host)
                {
                    Host host = objectToMap as Host;
                    objectFoler = settings.Where(c => c.Key.ToLower() == Constants.AppSettings.ServerFilePath.ToLower()).FirstOrDefault().Value;
                    fullPath    = Path.Combine(baseFilePath, objectFoler, string.Format("{0}.cfg", host.HostName));
                    // read the template
                    sRaw = File.ReadAllText(Path.Combine(_env.WebRootPath, "Templates/hostTemplate.cfg"));

                    // replace vars.
                    sRaw = sRaw.Replace("$HOST", host.HostName).Replace("$ALIAS", host.Alias).Replace("$IPADDRESS", host.IpAddress);
                }
                else if (objectToMap is HostGroup)
                {
                    HostGroup host = objectToMap as HostGroup;
                    objectFoler = settings.Where(c => c.Key.ToLower() == Constants.AppSettings.HostGroupsFilePath.ToLower()).FirstOrDefault().Value;
                    fullPath    = Path.Combine(baseFilePath, objectFoler, string.Format("{0}.cfg", host.GroupName));
                    // read the template
                    sRaw = File.ReadAllText(Path.Combine(_env.WebRootPath, "Templates/hostGroupTemplate.cfg"));

                    // replace vars.
                    sRaw = sRaw.Replace("$GROUPNAME", host.GroupName).Replace("$ALIAS", host.Alias).Replace("$MEMBERS", host.Members);
                }
                else
                {
                    // not any of our defined types, get out
                    return(false);
                }

                // check if contact file exists, if it does delete it and recreate it.
                if (File.Exists(fullPath))
                {
                    File.Delete(fullPath);
                }

                //check if dir exists
                if (!Directory.Exists(Path.Combine(baseFilePath, objectFoler)))
                {
                    Directory.CreateDirectory(Path.Combine(baseFilePath, objectFoler));
                }
                // create file.
                using (StreamWriter file = new StreamWriter(File.Create(fullPath)))
                {
                    file.Write(sRaw);
                }

                return(true);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error:");
                return(false);
            }
        }
Example #21
0
        public void UpdateContactGroup()
        {
            var personalAddressBook = this.CreatePersonalAddressBook();
            var contactGroup = new ContactGroup(personalAddressBook, "Contact Group1");

            Assert.AreNotEqual(DateTime.MinValue, contactGroup.CreateTime);

            this._contactGroupService.Create(contactGroup);
            Assert.Greater(contactGroup.ID, 0);

            this.Evict(contactGroup);

            var contactGroup2 = this._contactGroupService.GetContactGroup(contactGroup.ID) as ContactGroup;

            Assert.AreEqual(contactGroup.Name, contactGroup2.Name);
            Assert.AreEqual(contactGroup.AddressBookId, personalAddressBook.ID);
            Assert.AreEqual(FormatTime(contactGroup.CreateTime), FormatTime(contactGroup2.CreateTime));

            contactGroup2.SetName(contactGroup.Name + "_updated");

            this._contactGroupService.Update(contactGroup2);
            this.Evict(contactGroup2);
            var contactGroup3 = this._contactGroupService.GetContactGroup(contactGroup2.ID) as ContactGroup;

            Assert.AreEqual(contactGroup2.Name, contactGroup3.Name);

            var contact1 = CreateContact(personalAddressBook);
            var contact2 = CreateContact(personalAddressBook);
            contactGroup3.AddContact(contact1);
            contactGroup3.AddContact(contact2);

            this._contactGroupService.Update(contactGroup3);
            this.Evict(contactGroup3);
            var contactGroup4 = this._contactGroupService.GetContactGroup(contactGroup3.ID) as ContactGroup;
            Assert.AreEqual(2, contactGroup4.Contacts.Count());

            contactGroup4.RemoveContact(contact2);

            this._contactGroupService.Update(contactGroup4);
            this.Evict(contactGroup4);
            var contactGroup5 = this._contactGroupService.GetContactGroup(contactGroup4.ID) as ContactGroup;
            Assert.AreEqual(1, contactGroup5.Contacts.Count());
        }
Example #22
0
        private void AddGroup(GroupModel group)
        {
            if (this.Contains(group))
            {
                return;
            }

            char firstLetter = char.ToLower(group.Name[0]);

            // show # for numbers
            if (firstLetter >= '0' && firstLetter <= '9')
            {
                firstLetter = '#';
            }

            bool found = false;
            foreach (ContactGroup<GroupModel> alphaGroup in this.groups)
            {
                // create group for letter if it doesn't exist
                if (alphaGroup.FirstLetter == firstLetter)
                {
                    found = true;
                    alphaGroup.Add(group);
                }
            }

            if (!found)
            {
                var alphaGroup = new ContactGroup<GroupModel>(firstLetter);
                this.groups.Add(alphaGroup);

                // create a contact for item and add it to the relevant
                alphaGroup.Add(group);
            }
        }
 partial void UpdateContactGroup(ContactGroup instance);
Example #24
0
        private string HandleMMSVerifyUAAddGroup(string data, MMSListenerToken token)
        {
            ClientAddGroup model = CommonVariables.serializer.Deserialize <ClientAddGroup>(data.Remove(0, CommonFlag.F_MMSVerifyUAAddGroup.Length));


            if (model != null && !string.IsNullOrEmpty(model.ObjectID))
            {
                ContactData     contactData     = new ContactData();
                ContactGroupSub contactGroupSub = token.ContactPersonService.FindContactGroupSub(model.ObjectID, model.GroupObjectID);
                if (contactGroupSub == null)
                {
                    ContactPerson contactPerson = token.ContactPersonService.FindContactPerson(model.ObjectID);
                    if (contactPerson != null)
                    {
                        ContactGroup contactGroup = token.ContactPersonService.FindContactGroup(model.GroupObjectID);
                        if (contactGroup != null)
                        {
                            contactGroupSub = new ContactGroupSub();
                            contactGroupSub.ContactGroupID        = contactGroup.GroupObjectID;
                            contactGroupSub.ContactPersonObjectID = model.ObjectID;
                            contactGroupSub.UpdateTime            = DateTime.Now.ToString(CommonFlag.F_DateTimeFormat);

                            if (token.ContactPersonService.InsertContactGroupSub(contactGroupSub) == 1)
                            {
                                token.ContactPersonService.UpdateContactUpdateTimeByGroup(contactGroup.GroupObjectID, contactGroupSub.UpdateTime);

                                ClientModel clientStatusModel = new ClientModel();

                                clientStatusModel.MCS_IP   = model.MCS_IP;
                                clientStatusModel.MCS_Port = model.MCS_Port;
                                clientStatusModel.ObjectID = model.ObjectID;

                                string mcs_UpdateTime = CommonVariables.SyncSocketClientIntance.SendMsg(clientStatusModel.MCS_IP, clientStatusModel.MCS_Port,
                                                                                                        CommonFlag.F_MCSReceiveMMSUAUpdateTime + CommonVariables.serializer.Serialize(clientStatusModel));

                                if (string.IsNullOrEmpty(mcs_UpdateTime))
                                {
                                    return(string.Empty);
                                }

                                IList <ContactData> contactDatas = CommonVariables.UAInfoContorl.PreparContactData(clientStatusModel.ObjectID, mcs_UpdateTime);

                                foreach (ContactData _contactData in contactDatas)
                                {
                                    CommonVariables.SyncSocketClientIntance.SendMsg(clientStatusModel.MCS_IP, clientStatusModel.MCS_Port,
                                                                                    CommonFlag.F_MCSReceiveUAInfo + CommonVariables.serializer.Serialize(_contactData));
                                }

                                contactGroup              = token.ContactPersonService.FindContactGroup(model.GroupObjectID);
                                contactData.GroupName     = contactGroup.GroupName;
                                contactData.GroupObjectID = contactGroup.GroupObjectID;
                                contactData.IsDelete      = contactGroup.IsDelete;
                                contactData.UpdateTime    = contactGroup.UpdateTime;
                                contactData.DataType      = 2;
                            }
                            else
                            {
                                return(string.Empty);
                            }
                        }
                        else
                        {
                            return(string.Empty);
                        }
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    ContactGroup contactGroup = token.ContactPersonService.FindContactGroup(contactGroupSub.ContactGroupID);
                    contactData.GroupName     = contactGroup.GroupName;
                    contactData.GroupObjectID = contactGroup.GroupObjectID;
                    contactData.IsDelete      = contactGroup.IsDelete;
                    contactData.DataType      = 2;
                }
                return(CommonVariables.serializer.Serialize(contactData));
            }

            return(string.Empty);
        }
Example #25
0
 public void AddShape(ShapeData shape, ContactGroup contact)
 {
     transformable.AddShape(shape, contact);
 }
Example #26
0
 public void AddShape(ShapeData shape, ContactGroup group)
 {
     transformable.AddShape(shape, group);
 }
Example #27
0
        public PurchaseBuilder()
        {
            _accountService                  = new AccountService(new AccountRepository(), new AccountValidator());
            _barringService                  = new BarringService(new BarringRepository(), new BarringValidator());
            _barringOrderService             = new BarringOrderService(new BarringOrderRepository(), new BarringOrderValidator());
            _barringOrderDetailService       = new BarringOrderDetailService(new BarringOrderDetailRepository(), new BarringOrderDetailValidator());
            _cashBankAdjustmentService       = new CashBankAdjustmentService(new CashBankAdjustmentRepository(), new CashBankAdjustmentValidator());
            _cashBankMutationService         = new CashBankMutationService(new CashBankMutationRepository(), new CashBankMutationValidator());
            _cashBankService                 = new CashBankService(new CashBankRepository(), new CashBankValidator());
            _cashMutationService             = new CashMutationService(new CashMutationRepository(), new CashMutationValidator());
            _closingService                  = new ClosingService(new ClosingRepository(), new ClosingValidator());
            _coreBuilderService              = new CoreBuilderService(new CoreBuilderRepository(), new CoreBuilderValidator());
            _coreIdentificationDetailService = new CoreIdentificationDetailService(new CoreIdentificationDetailRepository(), new CoreIdentificationDetailValidator());
            _coreIdentificationService       = new CoreIdentificationService(new CoreIdentificationRepository(), new CoreIdentificationValidator());
            _contactService                  = new ContactService(new ContactRepository(), new ContactValidator());
            _deliveryOrderService            = new DeliveryOrderService(new DeliveryOrderRepository(), new DeliveryOrderValidator());
            _deliveryOrderDetailService      = new DeliveryOrderDetailService(new DeliveryOrderDetailRepository(), new DeliveryOrderDetailValidator());
            _generalLedgerJournalService     = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator());
            _itemService                          = new ItemService(new ItemRepository(), new ItemValidator());
            _itemTypeService                      = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator());
            _machineService                       = new MachineService(new MachineRepository(), new MachineValidator());
            _payableService                       = new PayableService(new PayableRepository(), new PayableValidator());
            _paymentVoucherDetailService          = new PaymentVoucherDetailService(new PaymentVoucherDetailRepository(), new PaymentVoucherDetailValidator());
            _paymentVoucherService                = new PaymentVoucherService(new PaymentVoucherRepository(), new PaymentVoucherValidator());
            _purchaseInvoiceDetailService         = new PurchaseInvoiceDetailService(new PurchaseInvoiceDetailRepository(), new PurchaseInvoiceDetailValidator());
            _purchaseInvoiceService               = new PurchaseInvoiceService(new PurchaseInvoiceRepository(), new PurchaseInvoiceValidator());
            _purchaseOrderService                 = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator());
            _purchaseOrderDetailService           = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator());
            _purchaseReceivalService              = new PurchaseReceivalService(new PurchaseReceivalRepository(), new PurchaseReceivalValidator());
            _purchaseReceivalDetailService        = new PurchaseReceivalDetailService(new PurchaseReceivalDetailRepository(), new PurchaseReceivalDetailValidator());
            _receivableService                    = new ReceivableService(new ReceivableRepository(), new ReceivableValidator());
            _receiptVoucherDetailService          = new ReceiptVoucherDetailService(new ReceiptVoucherDetailRepository(), new ReceiptVoucherDetailValidator());
            _receiptVoucherService                = new ReceiptVoucherService(new ReceiptVoucherRepository(), new ReceiptVoucherValidator());
            _recoveryOrderDetailService           = new RecoveryOrderDetailService(new RecoveryOrderDetailRepository(), new RecoveryOrderDetailValidator());
            _recoveryOrderService                 = new RecoveryOrderService(new RecoveryOrderRepository(), new RecoveryOrderValidator());
            _recoveryAccessoryDetailService       = new RecoveryAccessoryDetailService(new RecoveryAccessoryDetailRepository(), new RecoveryAccessoryDetailValidator());
            _rollerBuilderService                 = new RollerBuilderService(new RollerBuilderRepository(), new RollerBuilderValidator());
            _rollerTypeService                    = new RollerTypeService(new RollerTypeRepository(), new RollerTypeValidator());
            _rollerWarehouseMutationDetailService = new RollerWarehouseMutationDetailService(new RollerWarehouseMutationDetailRepository(), new RollerWarehouseMutationDetailValidator());
            _rollerWarehouseMutationService       = new RollerWarehouseMutationService(new RollerWarehouseMutationRepository(), new RollerWarehouseMutationValidator());
            _salesInvoiceDetailService            = new SalesInvoiceDetailService(new SalesInvoiceDetailRepository(), new SalesInvoiceDetailValidator());
            _salesInvoiceService                  = new SalesInvoiceService(new SalesInvoiceRepository(), new SalesInvoiceValidator());
            _salesOrderService                    = new SalesOrderService(new SalesOrderRepository(), new SalesOrderValidator());
            _salesOrderDetailService              = new SalesOrderDetailService(new SalesOrderDetailRepository(), new SalesOrderDetailValidator());
            _stockAdjustmentDetailService         = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator());
            _stockAdjustmentService               = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator());
            _stockMutationService                 = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
            _uomService                          = new UoMService(new UoMRepository(), new UoMValidator());
            _validCombService                    = new ValidCombService(new ValidCombRepository(), new ValidCombValidator());
            _warehouseItemService                = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
            _warehouseService                    = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
            _warehouseMutationOrderService       = new WarehouseMutationOrderService(new WarehouseMutationOrderRepository(), new WarehouseMutationOrderValidator());
            _warehouseMutationOrderDetailService = new WarehouseMutationOrderDetailService(new WarehouseMutationOrderDetailRepository(), new WarehouseMutationOrderDetailValidator());

            _priceMutationService = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator());
            _contactGroupService  = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator());

            typeAccessory    = _itemTypeService.CreateObject("Accessory", "Accessory");
            typeBar          = _itemTypeService.CreateObject("Bar", "Bar");
            typeBarring      = _itemTypeService.CreateObject("Barring", "Barring", true);
            typeBearing      = _itemTypeService.CreateObject("Bearing", "Bearing");
            typeBlanket      = _itemTypeService.CreateObject("Blanket", "Blanket");
            typeChemical     = _itemTypeService.CreateObject("Chemical", "Chemical");
            typeCompound     = _itemTypeService.CreateObject("Compound", "Compound");
            typeConsumable   = _itemTypeService.CreateObject("Consumable", "Consumable");
            typeCore         = _itemTypeService.CreateObject("Core", "Core", true);
            typeGlue         = _itemTypeService.CreateObject("Glue", "Glue");
            typeUnderpacking = _itemTypeService.CreateObject("Underpacking", "Underpacking");
            typeRoller       = _itemTypeService.CreateObject("Roller", "Roller", true);

            typeDamp       = _rollerTypeService.CreateObject("Damp", "Damp");
            typeFoundDT    = _rollerTypeService.CreateObject("Found DT", "Found DT");
            typeInkFormX   = _rollerTypeService.CreateObject("Ink Form X", "Ink Form X");
            typeInkDistD   = _rollerTypeService.CreateObject("Ink Dist D", "Ink Dist D");
            typeInkDistM   = _rollerTypeService.CreateObject("Ink Dist M", "Ink Dist M");
            typeInkDistE   = _rollerTypeService.CreateObject("Ink Dist E", "Ink Dist E");
            typeInkDuctB   = _rollerTypeService.CreateObject("Ink Duct B", "Ink Duct B");
            typeInkDistH   = _rollerTypeService.CreateObject("Ink Dist H", "Ink Dist H");
            typeInkFormW   = _rollerTypeService.CreateObject("Ink Form W", "Ink Form W");
            typeInkDistHQ  = _rollerTypeService.CreateObject("Ink Dist HQ", "Ink Dist HQ");
            typeDampFormDQ = _rollerTypeService.CreateObject("Damp Form DQ", "Damp Form DQ");
            typeInkFormY   = _rollerTypeService.CreateObject("Ink Form Y", "Ink Form Y");

            baseGroup = _contactGroupService.CreateObject(Core.Constants.Constant.GroupType.Base, "Base Group", true);

            if (!_accountService.GetLegacyObjects().Any())
            {
                Asset = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Asset", Code = Constant.AccountCode.Asset, LegacyCode = Constant.AccountLegacyCode.Asset, Level = 1, Group = Constant.AccountGroup.Asset, IsLegacy = true
                }, _accountService);
                CashBank = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "CashBank", Code = Constant.AccountCode.CashBank, LegacyCode = Constant.AccountLegacyCode.CashBank, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                }, _accountService);
                AccountReceivable = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Account Receivable", IsLeaf = true, Code = Constant.AccountCode.AccountReceivable, LegacyCode = Constant.AccountLegacyCode.AccountReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                }, _accountService);
                GBCHReceivable = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "GBCH Receivable", IsLeaf = true, Code = Constant.AccountCode.GBCHReceivable, LegacyCode = Constant.AccountLegacyCode.GBCHReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                }, _accountService);
                Inventory = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Inventory", IsLeaf = true, Code = Constant.AccountCode.Inventory, LegacyCode = Constant.AccountLegacyCode.Inventory, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                }, _accountService);

                Expense = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Expense", Code = Constant.AccountCode.Expense, LegacyCode = Constant.AccountLegacyCode.Expense, Level = 1, Group = Constant.AccountGroup.Expense, IsLegacy = true
                }, _accountService);
                CashBankAdjustmentExpense = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "CashBank Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.CashBankAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.CashBankAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                }, _accountService);
                COGS = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Cost Of Goods Sold", IsLeaf = true, Code = Constant.AccountCode.COGS, LegacyCode = Constant.AccountLegacyCode.COGS, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                }, _accountService);
                Discount = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Discount", IsLeaf = true, Code = Constant.AccountCode.Discount, LegacyCode = Constant.AccountLegacyCode.Discount, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                }, _accountService);
                SalesAllowance = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Sales Allowance", IsLeaf = true, Code = Constant.AccountCode.SalesAllowance, LegacyCode = Constant.AccountLegacyCode.SalesAllowance, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                }, _accountService);
                StockAdjustmentExpense = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Stock Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.StockAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.StockAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                }, _accountService);

                Liability = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Liability", Code = Constant.AccountCode.Liability, LegacyCode = Constant.AccountLegacyCode.Liability, Level = 1, Group = Constant.AccountGroup.Liability, IsLegacy = true
                }, _accountService);
                AccountPayable = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Account Payable", IsLeaf = true, Code = Constant.AccountCode.AccountPayable, LegacyCode = Constant.AccountLegacyCode.AccountPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                }, _accountService);
                GBCHPayable = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "GBCH Payable", IsLeaf = true, Code = Constant.AccountCode.GBCHPayable, LegacyCode = Constant.AccountLegacyCode.GBCHPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                }, _accountService);
                GoodsPendingClearance = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Goods Pending Clearance", IsLeaf = true, Code = Constant.AccountCode.GoodsPendingClearance, LegacyCode = Constant.AccountLegacyCode.GoodsPendingClearance, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                }, _accountService);

                Equity = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Equity", Code = Constant.AccountCode.Equity, LegacyCode = Constant.AccountLegacyCode.Equity, Level = 1, Group = Constant.AccountGroup.Equity, IsLegacy = true
                }, _accountService);
                OwnersEquity = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Owners Equity", Code = Constant.AccountCode.OwnersEquity, LegacyCode = Constant.AccountLegacyCode.OwnersEquity, Level = 2, Group = Constant.AccountGroup.Equity, ParentId = Equity.Id, IsLegacy = true
                }, _accountService);
                EquityAdjustment = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Equity Adjustment", IsLeaf = true, Code = Constant.AccountCode.EquityAdjustment, LegacyCode = Constant.AccountLegacyCode.EquityAdjustment, Level = 3, Group = Constant.AccountGroup.Equity, ParentId = OwnersEquity.Id, IsLegacy = true
                }, _accountService);

                Revenue = _accountService.CreateLegacyObject(new Account()
                {
                    Name = "Revenue", IsLeaf = true, Code = Constant.AccountCode.Revenue, LegacyCode = Constant.AccountLegacyCode.Revenue, Level = 1, Group = Constant.AccountGroup.Revenue, IsLegacy = true
                }, _accountService);
            }
        }
Example #28
0
        void groupitemprice_validation()
        {
            it["validates_groupitemprice"] = () =>
            {
                d.groupItemPrice1.Errors.Count().should_be(0);
            };

            it["groupitemprice_with_no_price"] = () =>
            {
                GroupItemPrice groupitemprice2 = new GroupItemPrice()
                {
                    Price          = 0,
                    ItemId         = d.item.Id,
                    ContactGroupId = d.baseGroup.Id
                };
                groupitemprice2 = d._groupItemPriceService.CreateObject(groupitemprice2, d._contactGroupService, d._itemService, d._priceMutationService);
                groupitemprice2.Errors.Count().should_not_be(0);
            };

            it["groupitemprice_with_no_itemid"] = () =>
            {
                GroupItemPrice groupitemprice2 = new GroupItemPrice()
                {
                    Price          = 1000,
                    ContactGroupId = d.baseGroup.Id
                };
                groupitemprice2 = d._groupItemPriceService.CreateObject(groupitemprice2, d._contactGroupService, d._itemService, d._priceMutationService);
                groupitemprice2.Errors.Count().should_not_be(0);
            };

            it["groupitemprice_with_no_groupid"] = () =>
            {
                GroupItemPrice groupitemprice2 = new GroupItemPrice()
                {
                    Price  = 1000,
                    ItemId = d.item.Id
                };
                groupitemprice2 = d._groupItemPriceService.CreateObject(groupitemprice2, d._contactGroupService, d._itemService, d._priceMutationService);
                groupitemprice2.Errors.Count().should_not_be(0);
            };

            it["groupitemprice_with_same_idcombination"] = () =>
            {
                GroupItemPrice groupitemprice2 = new GroupItemPrice()
                {
                    Price          = 2000,
                    ItemId         = d.item.Id,
                    ContactGroupId = d.baseGroup.Id
                };
                groupitemprice2 = d._groupItemPriceService.CreateObject(groupitemprice2, d._contactGroupService, d._itemService, d._priceMutationService);
                groupitemprice2.Errors.Count().should_not_be(0);
            };

            context["when creating groupitemprice"] = () =>
            {
                before = () =>
                {
                };

                it["should create PriceMutation"] = () =>
                {
                    d._priceMutationService.GetObjectById(d.groupItemPrice1.PriceMutationId).should_not_be_null();
                };

                it["should have 1 active PriceMutation"] = () =>
                {
                    d._priceMutationService.GetObjectsByIsActive(true, d.groupItemPrice1.ItemId, /*d.groupItemPrice1.ContactGroupId,*/ 0).Count().should_be(1);
                };
            };

            it["update_with_zero_price"] = () =>
            {
                d.groupItemPrice1.Price = 0;
                d.groupItemPrice1       = d._groupItemPriceService.UpdateObject(d.groupItemPrice1, d.groupItemPrice1.ContactGroupId, d.groupItemPrice1.ItemId, d._itemService, d._priceMutationService);
                d.groupItemPrice1.Errors.Count().should_not_be(0);
            };

            it["update_with_active_price"] = () =>
            {
                PriceMutation pricemutation1 = d._priceMutationService.GetObjectsByIsActive(true, d.item.Id /*, d.baseGroup.Id*/, 0).FirstOrDefault();
                d.groupItemPrice1.Price = pricemutation1.Amount;
                d.groupItemPrice1       = d._groupItemPriceService.UpdateObject(d.groupItemPrice1, d.groupItemPrice1.ContactGroupId, d.groupItemPrice1.ItemId, d._itemService, d._priceMutationService);
                d.groupItemPrice1.Errors.Count().should_not_be(0);
            };

            it["update_with_different_itemid"] = () =>
            {
                Item item = new Item()
                {
                    ItemTypeId = d._itemTypeService.GetObjectByName("Accessory").Id,
                    Sku        = "ABC1002",
                    Name       = "CBA",
                    Category   = "ABC123",
                    UoMId      = d.Pcs.Id
                };
                item = d._itemService.CreateObject(item, d._uomService, d._itemTypeService, d._warehouseItemService, d._warehouseService, d._priceMutationService, d._contactGroupService);

                int oldGroupId = d.groupItemPrice1.ContactGroupId;
                int oldItemId  = d.groupItemPrice1.ItemId;
                d.groupItemPrice1.ItemId = item.Id;
                GroupItemPrice oldone = d._groupItemPriceService.GetObjectById(d.groupItemPrice1.Id); // TODO : Check why oldone.ItemId have the same new value with d.groupItemPrice1.ItemId
                d.groupItemPrice1 = d._groupItemPriceService.UpdateObject(d.groupItemPrice1, oldGroupId, oldItemId, d._itemService, d._priceMutationService);
                d.groupItemPrice1.Errors.Count().should_not_be(0);
            };

            it["update_with_different_groupid"] = () =>
            {
                ContactGroup contactgroup = d._contactGroupService.CreateObject("Admin", "Administrators");

                int oldGroupId = d.groupItemPrice1.ContactGroupId;
                int oldItemId  = d.groupItemPrice1.ItemId;
                d.groupItemPrice1.ContactGroupId = contactgroup.Id;
                d.groupItemPrice1 = d._groupItemPriceService.UpdateObject(d.groupItemPrice1, oldGroupId, oldItemId, d._itemService, d._priceMutationService);
                d.groupItemPrice1.Errors.Count().should_not_be(0);
            };
        }
Example #29
0
        /// <summary>
        /// Загрузить адресную книгу из файла
        /// </summary>
        public bool Load(string fileName, out string errMsg)
        {
            try
            {
                // очистка адресной книги
                ContactGroups.Clear();

                // загрузка адресной книги
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);

                XmlNodeList contactGroupNodes = xmlDoc.DocumentElement.SelectNodes("ContactGroup");

                foreach (XmlElement contactGroupElem in contactGroupNodes)
                {
                    ContactGroup contactGroup = new ContactGroup(contactGroupElem.GetAttribute("name"));
                    contactGroup.Parent = this;

                    XmlNodeList contactNodes = contactGroupElem.SelectNodes("Contact");
                    foreach (XmlElement contactElem in contactNodes)
                    {
                        Contact contact = new Contact(contactElem.GetAttribute("name"));
                        contact.Parent = contactGroup;

                        XmlNodeList phoneNumberNodes = contactElem.SelectNodes("PhoneNumber");
                        foreach (XmlElement phoneNumberElem in phoneNumberNodes)
                        {
                            contact.ContactRecords.Add(
                                new PhoneNumber(phoneNumberElem.InnerText)
                            {
                                Parent = contact
                            });
                        }

                        XmlNodeList emailNodes = contactElem.SelectNodes("Email");
                        foreach (XmlElement emailElem in emailNodes)
                        {
                            contact.ContactRecords.Add(
                                new Email(emailElem.InnerText)
                            {
                                Parent = contact
                            });
                        }

                        contact.ContactRecords.Sort();
                        contactGroup.Contacts.Add(contact);
                    }

                    contactGroup.Contacts.Sort();
                    ContactGroups.Add(contactGroup);
                }

                ContactGroups.Sort();

                errMsg = "";
                return(true);
            }
            catch (Exception ex)
            {
                errMsg = AbPhrases.LoadAddressBookError + ":" + Environment.NewLine + ex.Message;
                return(false);
            }
        }
 void INovaAlertConfigService.SaveContactGroup(ContactGroup cg)
 {
     NovaAlertCommon.Instance.SaveGroup(cg);
 }
Example #31
0
        /// <summary>
        /// Read the registered users from the local data base.
        /// </summary>
        public void ReadRegisteredUsersFromDB()
        {
            List<UserModel> dbUserList = DataSync.Instance.GetUsers();

            if (dbUserList.Count == 0)
            {
                return;
            }

            if (this.RegisteredUsers == null)
            {
                this.RegisteredUsers = new ObservableSortedList<ContactGroup<UserModel>>();
            }

            var groups = new Dictionary<char, ContactGroup<UserModel>>();

            foreach (UserModel user in dbUserList)
            {
                if (!this.userIdUserMap.ContainsKey(user.Id))
                {
                    this.userIdUserMap.Add(user.Id, user);
                }

                if (this.Contains(user))
                {
                    continue;
                }

                if (user.UserType == UserType.Group)
                {
                    if (!user.Name.Contains("(G)"))
                    {
                        user.Name += " (G)";
                    }
                }

                this.userPhoneNumbers.Add(user.PhoneNumber);
                char firstLetter = char.ToLower(user.Name[0]);

                // show # for numbers
                if (firstLetter >= '0' && firstLetter <= '9')
                {
                    firstLetter = '#';
                }

                // create group for letter if it doesn't exist
                if (!groups.ContainsKey(firstLetter))
                {
                    var group = new ContactGroup<UserModel>(firstLetter);
                    this.RegisteredUsers.Add(group);
                    groups[firstLetter] = group;
                }

                // create a contact for item and add it to the relevant
                groups[firstLetter].Add(user);
            }

            this.isLoading = false;
        }
Example #32
0
 void IContactGroupService.Delete(ContactGroup contactGroup)
 {
     _repository.Remove(contactGroup);
     if (this._log.IsInfoEnabled)
     {
         this._log.InfoFormat("删除联系人组#{0}", contactGroup.ID);
     }
 }
Example #33
0
        void before_each()
        {
            var db = new OffsetPrintingSuppliesEntities();

            using (db)
            {
                db.DeleteAllTables();
                itemService                   = new ItemService(new ItemRepository(), new ItemValidator());
                contactService                = new ContactService(new ContactRepository(), new ContactValidator());
                poService                     = new PurchaseOrderService(new PurchaseOrderRepository(), new PurchaseOrderValidator());
                poDetailService               = new PurchaseOrderDetailService(new PurchaseOrderDetailRepository(), new PurchaseOrderDetailValidator());
                _stockMutationService         = new StockMutationService(new StockMutationRepository(), new StockMutationValidator());
                _itemTypeService              = new ItemTypeService(new ItemTypeRepository(), new ItemTypeValidator());
                _uomService                   = new UoMService(new UoMRepository(), new UoMValidator());
                _warehouseItemService         = new WarehouseItemService(new WarehouseItemRepository(), new WarehouseItemValidator());
                _warehouseService             = new WarehouseService(new WarehouseRepository(), new WarehouseValidator());
                _barringService               = new BarringService(new BarringRepository(), new BarringValidator());
                _itemService                  = new ItemService(new ItemRepository(), new ItemValidator());
                _stockAdjustmentService       = new StockAdjustmentService(new StockAdjustmentRepository(), new StockAdjustmentValidator());
                _stockAdjustmentDetailService = new StockAdjustmentDetailService(new StockAdjustmentDetailRepository(), new StockAdjustmentDetailValidator());
                _accountService               = new AccountService(new AccountRepository(), new AccountValidator());
                _closingService               = new ClosingService(new ClosingRepository(), new ClosingValidator());
                _generalLedgerJournalService  = new GeneralLedgerJournalService(new GeneralLedgerJournalRepository(), new GeneralLedgerJournalValidator());
                _priceMutationService         = new PriceMutationService(new PriceMutationRepository(), new PriceMutationValidator());
                _contactGroupService          = new ContactGroupService(new ContactGroupRepository(), new ContactGroupValidator());

                if (!_accountService.GetLegacyObjects().Any())
                {
                    Asset = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Asset", Code = Constant.AccountCode.Asset, LegacyCode = Constant.AccountLegacyCode.Asset, Level = 1, Group = Constant.AccountGroup.Asset, IsLegacy = true
                    }, _accountService);
                    CashBank = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "CashBank", Code = Constant.AccountCode.CashBank, LegacyCode = Constant.AccountLegacyCode.CashBank, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);
                    AccountReceivable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Account Receivable", IsLeaf = true, Code = Constant.AccountCode.AccountReceivable, LegacyCode = Constant.AccountLegacyCode.AccountReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);
                    GBCHReceivable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "GBCH Receivable", IsLeaf = true, Code = Constant.AccountCode.GBCHReceivable, LegacyCode = Constant.AccountLegacyCode.GBCHReceivable, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);
                    Inventory = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Inventory", IsLeaf = true, Code = Constant.AccountCode.Inventory, LegacyCode = Constant.AccountLegacyCode.Inventory, Level = 2, Group = Constant.AccountGroup.Asset, ParentId = Asset.Id, IsLegacy = true
                    }, _accountService);

                    Expense = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Expense", Code = Constant.AccountCode.Expense, LegacyCode = Constant.AccountLegacyCode.Expense, Level = 1, Group = Constant.AccountGroup.Expense, IsLegacy = true
                    }, _accountService);
                    CashBankAdjustmentExpense = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "CashBank Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.CashBankAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.CashBankAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    COGS = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Cost Of Goods Sold", IsLeaf = true, Code = Constant.AccountCode.COGS, LegacyCode = Constant.AccountLegacyCode.COGS, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    Discount = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Discount", IsLeaf = true, Code = Constant.AccountCode.Discount, LegacyCode = Constant.AccountLegacyCode.Discount, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    SalesAllowance = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Sales Allowance", IsLeaf = true, Code = Constant.AccountCode.SalesAllowance, LegacyCode = Constant.AccountLegacyCode.SalesAllowance, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);
                    StockAdjustmentExpense = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Stock Adjustment Expense", IsLeaf = true, Code = Constant.AccountCode.StockAdjustmentExpense, LegacyCode = Constant.AccountLegacyCode.StockAdjustmentExpense, Level = 2, Group = Constant.AccountGroup.Expense, ParentId = Expense.Id, IsLegacy = true
                    }, _accountService);

                    Liability = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Liability", Code = Constant.AccountCode.Liability, LegacyCode = Constant.AccountLegacyCode.Liability, Level = 1, Group = Constant.AccountGroup.Liability, IsLegacy = true
                    }, _accountService);
                    AccountPayable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Account Payable", IsLeaf = true, Code = Constant.AccountCode.AccountPayable, LegacyCode = Constant.AccountLegacyCode.AccountPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                    }, _accountService);
                    GBCHPayable = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "GBCH Payable", IsLeaf = true, Code = Constant.AccountCode.GBCHPayable, LegacyCode = Constant.AccountLegacyCode.GBCHPayable, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                    }, _accountService);
                    GoodsPendingClearance = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Goods Pending Clearance", IsLeaf = true, Code = Constant.AccountCode.GoodsPendingClearance, LegacyCode = Constant.AccountLegacyCode.GoodsPendingClearance, Level = 2, Group = Constant.AccountGroup.Liability, ParentId = Liability.Id, IsLegacy = true
                    }, _accountService);

                    Equity = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Equity", Code = Constant.AccountCode.Equity, LegacyCode = Constant.AccountLegacyCode.Equity, Level = 1, Group = Constant.AccountGroup.Equity, IsLegacy = true
                    }, _accountService);
                    OwnersEquity = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Owners Equity", Code = Constant.AccountCode.OwnersEquity, LegacyCode = Constant.AccountLegacyCode.OwnersEquity, Level = 2, Group = Constant.AccountGroup.Equity, ParentId = Equity.Id, IsLegacy = true
                    }, _accountService);
                    EquityAdjustment = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Equity Adjustment", IsLeaf = true, Code = Constant.AccountCode.EquityAdjustment, LegacyCode = Constant.AccountLegacyCode.EquityAdjustment, Level = 3, Group = Constant.AccountGroup.Equity, ParentId = OwnersEquity.Id, IsLegacy = true
                    }, _accountService);

                    Revenue = _accountService.CreateLegacyObject(new Account()
                    {
                        Name = "Revenue", IsLeaf = true, Code = Constant.AccountCode.Revenue, LegacyCode = Constant.AccountLegacyCode.Revenue, Level = 1, Group = Constant.AccountGroup.Revenue, IsLegacy = true
                    }, _accountService);
                }

                baseGroup = _contactGroupService.CreateObject(Core.Constants.Constant.GroupType.Base, "Base Group", true);

                Pcs = new UoM()
                {
                    Name = "Pcs"
                };
                _uomService.CreateObject(Pcs);

                contact = new Contact()
                {
                    Name         = "President of Indonesia",
                    Address      = "Istana Negara Jl. Veteran No. 16 Jakarta Pusat",
                    ContactNo    = "021 3863777",
                    PIC          = "Mr. President",
                    PICContactNo = "021 3863777",
                    Email        = "*****@*****.**"
                };
                contact = contactService.CreateObject(contact, _contactGroupService);

                type = _itemTypeService.CreateObject("Item", "Item");

                warehouse = new Warehouse()
                {
                    Name        = "Sentral Solusi Data",
                    Description = "Kali Besar Jakarta",
                    Code        = "LCL"
                };
                warehouse = _warehouseService.CreateObject(warehouse, _warehouseItemService, itemService);

                item1 = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Batik Tulis",
                    Category   = "Item",
                    Sku        = "bt123",
                    UoMId      = Pcs.Id
                };
                itemService.CreateObject(item1, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

                item2 = new Item()
                {
                    ItemTypeId = _itemTypeService.GetObjectByName("Item").Id,
                    Name       = "Buku Gambar",
                    Category   = "Item",
                    Sku        = "bg123",
                    UoMId      = Pcs.Id
                };
                itemService.CreateObject(item2, _uomService, _itemTypeService, _warehouseItemService, _warehouseService, _priceMutationService, _contactGroupService);

                StockAdjustment sa = new StockAdjustment()
                {
                    AdjustmentDate = DateTime.Today, WarehouseId = warehouse.Id, Description = "item adjustment"
                };
                _stockAdjustmentService.CreateObject(sa, _warehouseService);
                StockAdjustmentDetail sadItem1 = new StockAdjustmentDetail()
                {
                    ItemId            = item1.Id,
                    Quantity          = 1000,
                    StockAdjustmentId = sa.Id
                };
                _stockAdjustmentDetailService.CreateObject(sadItem1, _stockAdjustmentService, _itemService, _warehouseItemService);

                StockAdjustmentDetail sadItem2 = new StockAdjustmentDetail()
                {
                    ItemId            = item2.Id,
                    Quantity          = 1000,
                    StockAdjustmentId = sa.Id
                };
                _stockAdjustmentDetailService.CreateObject(sadItem2, _stockAdjustmentService, _itemService, _warehouseItemService);

                _stockAdjustmentService.ConfirmObject(sa, DateTime.Today, _stockAdjustmentDetailService, _stockMutationService,
                                                      _itemService, _barringService, _warehouseItemService, _generalLedgerJournalService,
                                                      _accountService, _closingService);
            }
        }
Example #34
0
 public ContactGroup VCreateObject(ContactGroup contactGroup, IContactGroupService _contactGroupService)
 {
     VHasUniqueName(contactGroup, _contactGroupService);
     return(contactGroup);
 }
        public static bool LoadLvContacts(ExchangeService oExchangeService, ref ListView oListView, FolderTag oFolderTag)
        {
            bool bRet = true;

            // Configure ListView before adding data.
            //oListView.Dock = DockStyle.None;
            oListView.Clear();
            oListView.View      = View.Details;
            oListView.GridLines = true;
            oListView.Dock      = DockStyle.Fill;

            oListView.Columns.Add("Type", 150, HorizontalAlignment.Left);
            oListView.Columns.Add("DisplayName", 150, HorizontalAlignment.Left);
            oListView.Columns.Add("Department", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Manager", 50, HorizontalAlignment.Left);


            oListView.Columns.Add("Business Street", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Business City", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Business State", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Business Zip", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Business CountryOrRegion", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Business Phone", 50, HorizontalAlignment.Left);

            oListView.Columns.Add("Home Street", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Home City", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Home State", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Home Zip", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Home CountryOrRegion", 50, HorizontalAlignment.Left);
            oListView.Columns.Add("Home Phone", 50, HorizontalAlignment.Left);

            FolderId oFolder;

            oFolder = oFolderTag.Id;

            PropertySet oPropSet = new PropertySet(PropertySet.FirstClassProperties);

            oPropSet.Add(ContactSchema.ItemClass);
            oPropSet.Add(ContactSchema.DisplayName);
            oPropSet.Add(ContactSchema.Department);
            oPropSet.Add(ContactSchema.Manager);

            oPropSet.Add(ContactSchema.BusinessAddressStreet);
            oPropSet.Add(ContactSchema.BusinessAddressCity);
            oPropSet.Add(ContactSchema.BusinessAddressState);
            oPropSet.Add(ContactSchema.BusinessAddressPostalCode);
            oPropSet.Add(ContactSchema.BusinessPhone);

            oPropSet.Add(ContactSchema.HomeAddressStreet);
            oPropSet.Add(ContactSchema.HomeAddressCity);
            oPropSet.Add(ContactSchema.HomeAddressState);
            oPropSet.Add(ContactSchema.HomeAddressPostalCode);
            oPropSet.Add(ContactSchema.HomePhone);


            ItemView oView = new ItemView(9999);

            oExchangeService.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
            Folder folder = Folder.Bind(oExchangeService, oFolder, oPropSet);

            folder.Service.ClientRequestId = Guid.NewGuid().ToString();  // Set a new GUID.
            FindItemsResults <Microsoft.Exchange.WebServices.Data.Item> oResults = folder.FindItems(oView);

            ListViewItem oListItem = null;

            //Contact contact = Contact.Bind(service, new ItemId("AAMkA="));
            string sAddress = string.Empty;
            PhysicalAddressEntry oAddress = null;
            string sPhone = string.Empty;

            foreach (Item o in oResults)
            {
                Contact      oContact      = o as Contact;
                ContactGroup oContactGroup = o as ContactGroup;


                if (oContact != null)
                {
                    oListItem = new ListViewItem("Contact", 0);
                    oListItem.SubItems.Add(oContact.DisplayName);
                    oListItem.SubItems.Add(oContact.Department);
                    oListItem.SubItems.Add(oContact.Manager);

                    if (oContact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Business, out oAddress))
                    {
                        oListItem.SubItems.Add(oAddress.Street);
                        oListItem.SubItems.Add(oAddress.City);
                        oListItem.SubItems.Add(oAddress.State);
                        oListItem.SubItems.Add(oAddress.PostalCode);
                        oListItem.SubItems.Add(oAddress.CountryOrRegion);
                        //sAddress = oAddress.Street;
                    }
                    else
                    {
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                    }

                    sPhone = string.Empty;
                    if (oContact.PhoneNumbers.TryGetValue(PhoneNumberKey.BusinessPhone, out sPhone))
                    {
                        oListItem.SubItems.Add(sPhone);
                    }
                    else
                    {
                        oListItem.SubItems.Add("");
                    }

                    if (oContact.PhysicalAddresses.TryGetValue(PhysicalAddressKey.Home, out oAddress))
                    {
                        oListItem.SubItems.Add(oAddress.Street);
                        oListItem.SubItems.Add(oAddress.State);
                        oListItem.SubItems.Add(oAddress.City);
                        oListItem.SubItems.Add(oAddress.PostalCode);
                        oListItem.SubItems.Add(oAddress.CountryOrRegion);
                        sAddress = oAddress.Street;
                    }
                    else
                    {
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                        oListItem.SubItems.Add("");
                    }

                    sPhone = string.Empty;
                    if (oContact.PhoneNumbers.TryGetValue(PhoneNumberKey.HomePhone, out sPhone))
                    {
                        oListItem.SubItems.Add(sPhone);
                    }
                    else
                    {
                        oListItem.SubItems.Add("");
                    }

                    oListItem.Tag = new ItemTag(o.Id, o.ItemClass);
                    oListView.Items.AddRange(new ListViewItem[] { oListItem });

                    oContact      = null;
                    oContactGroup = null;
                    oListItem     = null;
                    oAddress      = null;
                }
            }

            return(bRet);
        }
Example #36
0
 public ContactGroup VUpdateObject(ContactGroup contactGroup, IContactGroupService _contactGroupService)
 {
     VCreateObject(contactGroup, _contactGroupService);
     return(contactGroup);
 }
        public void Search()
        {
            var contacts = new Contacts();

            contacts.SearchCompleted += (s, args) =>
            {
                ObservableSortedList<ContactGroup<ContactItem>> tempItems = new ObservableSortedList<ContactGroup<ContactItem>>();

                var groups = new Dictionary<char, ContactGroup<ContactItem>>();

                foreach (var contact in args.Results)
                {
                    if (!contact.PhoneNumbers.Any(number => number.Kind == PhoneNumberKind.Mobile))
                    {
                        continue;
                    }

                    if (IsContactRegisteredUser(contact))
                    {
                        continue;
                    }

                    char firstLetter = char.ToLower(contact.DisplayName[0]);

                    // show # for numbers
                    if (firstLetter >= '0' && firstLetter <= '9')
                    {
                        firstLetter = '#';
                    }

                    // create group for letter if it doesn't exist
                    if (!groups.ContainsKey(firstLetter))
                    {
                        var group = new ContactGroup<ContactItem>(firstLetter);
                        tempItems.Add(group);
                        groups[firstLetter] = group;
                    }

                    // create a contact for item and add it to the relevant group
                    var contactItem = new ContactItem(contact);
                    groups[firstLetter].Add(contactItem);
                }

                this.items = tempItems;
                Deployment.Current.Dispatcher.BeginInvoke(() => { this.NotifyPropertyChanged("Items"); });
                IsInitialized = true;
                NotifyPropertyChanged("IsContactsEmpty");
                NotifyPropertyChanged("IsContactsNotEmpty");
                NotifyPropertyChanged("IsLoading");
            };

            // get all contacts
            contacts.SearchAsync(null, FilterKind.None, null);
        }
Example #38
0
 public ContactGroup VDeleteObject(ContactGroup contactGroup)
 {
     return(contactGroup);
 }
Example #39
0
 public async Task <ContactGroup> UpdateAsync(ContactGroup item)
 {
     return(await ContactGroups.UpdateAsync(item));
 }
Example #40
0
 public bool ValidCreateObject(ContactGroup contactGroup, IContactGroupService _contactGroupService)
 {
     VCreateObject(contactGroup, _contactGroupService);
     return(isValid(contactGroup));
 }
Example #41
0
        /// <summary>
        /// Download address book from file
        /// </summary>
        public bool Load(string fileName, out string errMsg)
        {
            try {
                // address book cleaning
                ContactGroups.Clear();

                // loading address book
                var xmlDoc = new XmlDocument();
                xmlDoc.Load(fileName);

                var contactGroupNodes = xmlDoc.DocumentElement.SelectNodes("ContactGroup");

                foreach (XmlElement contactGroupElem in contactGroupNodes)
                {
                    var contactGroup = new ContactGroup(contactGroupElem.GetAttribute("name"))
                    {
                        Parent = this
                    };

                    var contactNodes = contactGroupElem.SelectNodes("Contact");
                    foreach (XmlElement contactElem in contactNodes)
                    {
                        var contact = new Contact(contactElem.GetAttribute("name"))
                        {
                            Parent = contactGroup
                        };

                        var phoneNumberNodes = contactElem.SelectNodes("PhoneNumber");
                        foreach (XmlElement phoneNumberElem in phoneNumberNodes)
                        {
                            contact.ContactRecords.Add(
                                new PhoneNumber(phoneNumberElem.InnerText)
                            {
                                Parent = contact
                            });
                        }

                        var emailNodes = contactElem.SelectNodes("Email");
                        foreach (XmlElement emailElem in emailNodes)
                        {
                            contact.ContactRecords.Add(
                                new Email(emailElem.InnerText)
                            {
                                Parent = contact
                            });
                        }

                        contact.ContactRecords.Sort();
                        contactGroup.Contacts.Add(contact);
                    }

                    contactGroup.Contacts.Sort();
                    ContactGroups.Add(contactGroup);
                }

                ContactGroups.Sort();

                errMsg = "";
                return(true);
            } catch (Exception ex) {
                errMsg = AbPhrases.LoadAddressBookError + ":" + Environment.NewLine + ex.Message;
                return(false);
            }
        }
Example #42
0
 public bool ValidUpdateObject(ContactGroup contactGroup, IContactGroupService _contactGroupService)
 {
     contactGroup.Errors.Clear();
     VUpdateObject(contactGroup, _contactGroupService);
     return(isValid(contactGroup));
 }
Example #43
0
 public bool ValidDeleteObject(ContactGroup contactGroup)
 {
     contactGroup.Errors.Clear();
     VDeleteObject(contactGroup);
     return(isValid(contactGroup));
 }
Example #44
0
        public bool isValid(ContactGroup obj)
        {
            bool isValid = !obj.Errors.Any();

            return(isValid);
        }
Example #45
0
 public ContactGroup Create(ContactGroup item)
 {
     return(ContactGroups.Create(item));
 }
Example #46
0
 public ContactGroupConfigureViewModel(ContactGroup contactGroup, bool isToggle) : base(contactGroup)
 {
     this.IsToggle = isToggle;
 }
        public async Task ContactGroups_CreateUpdateAndDelete()
        {
            var client = await GetTestClientAsync();

            var contactGroups = client.ContactGroups;

            foreach (var contactType in Enums.GetValues <ContactType>())
            {
                var groupType  = contactType == ContactType.Business ? ContactGroupType.Public : ContactGroupType.Private;
                var groupAdded = new ContactGroup("ABC", contactType, groupType)
                {
                    Description = "123"
                };
                var groups = await contactGroups.GetGroupsAsync(contactType, groupType);

                var existingGroup = groups.FirstOrDefault(g => g.Name == groupAdded.Name);
                if (existingGroup != null)
                {
                    await contactGroups.DeleteGroupAsync(existingGroup.Id);
                }
                var groupId = await contactGroups.CreateGroupAsync(groupAdded, true);

                try
                {
                    Assert.AreEqual(groupId, groupAdded.Id);
                    Assert.IsNotNull(groupAdded.CreatedDate);
                    groups = await contactGroups.GetGroupsAsync(contactType, groupType);

                    Assert.IsNotNull(groups);
                    Assert.IsTrue(groups.Count > 0);
                    var foundGroup = groups.FirstOrDefault(g => g.Id == groupId);
                    Assert.IsNotNull(foundGroup);
                    Assert.AreEqual(groupAdded.ContactType.Value, foundGroup.ContactType.Value);
                    Assert.AreEqual(groupAdded.Name, foundGroup.Name);
                    Assert.AreEqual(groupAdded.GroupType.Value, foundGroup.GroupType.Value);
                    var retrievedGroup = await contactGroups.GetGroupAsync(groupId);

                    Assert.IsNotNull(retrievedGroup);
                    Assert.AreEqual(groupAdded.ContactType.Value, retrievedGroup.ContactType.Value);
                    Assert.AreEqual(groupAdded.Name, retrievedGroup.Name);
                    Assert.AreEqual(groupAdded.GroupType.Value, retrievedGroup.GroupType.Value);

                    groupAdded    = new ContactGroup(groupId, "DEF", contactType, groupType);
                    existingGroup = groups.FirstOrDefault(g => g.Name == groupAdded.Name);
                    if (existingGroup != null)
                    {
                        await contactGroups.DeleteGroupAsync(existingGroup.Id);
                    }
                    await contactGroups.UpdateGroupAsync(groupAdded);

                    retrievedGroup = await contactGroups.GetGroupAsync(groupId);

                    Assert.IsNotNull(retrievedGroup);
                    Assert.AreEqual(groupAdded.ContactType.Value, retrievedGroup.ContactType.Value);
                    Assert.AreEqual(groupAdded.Name, retrievedGroup.Name);
                    Assert.AreEqual(groupAdded.GroupType.Value, retrievedGroup.GroupType.Value);
                }
                finally
                {
                    await contactGroups.DeleteGroupAsync(groupId);
                }
            }
        }
 partial void InsertContactGroup(ContactGroup instance);