Пример #1
0
        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);
            }
        }