Exemplo n.º 1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(ContactId.GetHashCode() * 27 * ContactDetailId.GetHashCode());
     }
 }
        protected override bool InternalExecute(ProcessExecutingContext context)
        {
            if (!ContactId.IsEmpty() && string.IsNullOrEmpty(SearchCriteria))
            {
                var entitySchemaManager = UserConnection.EntitySchemaManager;
                EntitySchemaQuery query = new EntitySchemaQuery(entitySchemaManager, "Contact");
                query.AddColumn("Name");
                var contact = (Terrasoft.Configuration.Contact)query.GetEntity(UserConnection, ContactId);
                if (contact != null)
                {
                    SearchCriteria = contact.Name.Trim();
                }
            }
            SocialNetwork socialNetwork = 0;
            var           netwoks       = SocialNetworks.Split('|');

            if (netwoks == null || netwoks.Length == 0)
            {
                socialNetwork = SocialNetwork.All;
            }
            foreach (var netwok in netwoks)
            {
                socialNetwork = socialNetwork | (SocialNetwork)Enum.Parse(typeof(SocialNetwork), netwok, true);
            }
            SocialCommutator commutator = new SocialCommutator(UserConnection, socialNetwork);

            Users = commutator.FindUsers(SearchCriteria);
            return(true);
        }
Exemplo n.º 3
0
        // /// <summary>
        // /// Returns the string presentation of the object
        // /// </summary>
        // /// <returns>String presentation of the object</returns>
        // public override string ToString()
        // {
        //  var sb = new StringBuilder();

        //  sb.Append("class User {\n");
        //  sb.Append("  Id: ").Append(ContactId).Append("\n");
        //  sb.Append("  GivenName: ").Append(GivenName).Append("\n");
        //  sb.Append("  Surname: ").Append(Surname).Append("\n");
        //  sb.Append("  Active: ").Append(Active).Append("\n");
        //  sb.Append("  Initials: ").Append(Initials).Append("\n");
        //  sb.Append("  Email: ").Append(Email).Append("\n");
        //  sb.Append("  SmUserId: ").Append(SmUserId).Append("\n");
        //  sb.Append("  Guid: ").Append(AccountId).Append("\n");
        //  sb.Append("  SmAuthorizationDirectory: ").Append(UserType).Append("\n");
        //  sb.Append("  UserRoles: ").Append(UserRoles).Append("\n");
        //  sb.Append("}\n");

        //  return sb.ToString();
        // }

        // /// <summary>
        // /// Returns the JSON string presentation of the object
        // /// </summary>
        // /// <returns>JSON string presentation of the object</returns>
        // public string ToJson()
        // {
        //  return JsonConvert.SerializeObject(this, Formatting.Indented);
        // }

        // /// <summary>
        // /// Returns true if objects are equal
        // /// </summary>
        // /// <param name="obj">Object to be compared</param>
        // /// <returns>Boolean</returns>
        // public override bool Equals(object obj)
        // {
        //  if (obj is null) { return false; }
        //  if (ReferenceEquals(this, obj)) { return true; }
        //  return obj.GetType() == GetType() && Equals((User)obj);
        // }

        /// <summary>
        /// Returns true if User instances are equal
        /// </summary>
        /// <param name="other">Instance of User to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(User other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((
                       ContactId == other.ContactId ||
                       ContactId.Equals(other.ContactId)
                       ) &&
                   (
                       GivenName == other.GivenName ||
                       GivenName != null &&
                       GivenName.Equals(other.GivenName)
                   ) &&
                   (
                       Surname == other.Surname ||
                       Surname != null &&
                       Surname.Equals(other.Surname)
                   ) &&
                   (
                       Active == other.Active ||
                       Active.Equals(other.Active)
                   ) &&
                   (
                       Initials == other.Initials ||
                       Initials != null &&
                       Initials.Equals(other.Initials)
                   ) &&
                   (
                       Email == other.Email ||
                       Email != null &&
                       Email.Equals(other.Email)
                   ) &&
                   (
                       SmUserId == other.SmUserId ||
                       SmUserId != null &&
                       SmUserId.Equals(other.SmUserId)
                   ) &&
                   (
                       AccountId == other.AccountId ||
                       AccountId != null &&
                       AccountId.Equals(other.AccountId)
                   ) &&
                   (
                       UserType == other.UserType ||
                       UserType != null &&
                       UserType.Equals(other.UserType)
                   ) &&
                   (
                       UserRoles == other.UserRoles ||
                       UserRoles != null &&
                       UserRoles.SequenceEqual(other.UserRoles)
                   ));
        }
Exemplo n.º 4
0
        protected void StartBodyContact(ContactId contactId, string contactType)
        {
            if (contactId.IsNull)
            {
                return;
            }
            Contact contact;

            using (Ambient.DbSession.Activate())
            {
                contact = OrderingRepositories.Contact.Get(contactId);
            }
            StartBodyDetail(contactType, contact.ContactName);
            if (!string.IsNullOrEmpty(contact.PhoneNumber))
            {
                StartBodyDetail("", contact.PhoneNumber);
            }
            if (!string.IsNullOrEmpty(contact.CellNumber))
            {
                StartBodyDetail("", contact.CellNumber + " (cell)");
            }
            if (!string.IsNullOrEmpty(contact.FaxNumber))
            {
                StartBodyDetail("", contact.FaxNumber + " (fax)");
            }
            if (!string.IsNullOrEmpty(contact.EmailAddress))
            {
                StartBodyDetail("", contact.EmailAddress);
            }
        }
Exemplo n.º 5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(ContactId.GetHashCode() * 27 * PartyId.GetHashCode());
     }
 }
Exemplo n.º 6
0
 public Contact()
 {
     Name          = new Name2();
     ContactId     = new ContactId();
     FolderId      = new FolderId2();
     Title         = new Title();
     ContactMethod = new List <ContactMethod>();
 }
        public ViewResult Details(int id)
        {
            var contactId = new ContactId
            {
                Id = id
            };

            return(User.IsInRole(RoleName.CanManageContacts) ? View(contactId) : View("ReadOnlyDetails", contactId));
        }
 /// <summary>
 /// <see cref="System.Object.Equals(object)"/>
 /// </summary>
 public bool Equals(EnrichContactItem obj)
 {
     if (obj == null)
     {
         return(false);
     }
     return(EnrchTextDataId.Equals(obj.EnrchTextDataId) &&
            ContactId.Equals(obj.ContactId) && JsonData.Equals(obj.JsonData));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked             // Overflow is fine, just wrap
            {
                int hash = 41;

                // Suitable nullity checks
                hash = hash * 59 + ContactId.GetHashCode();

                if (GivenName != null)
                {
                    hash = hash * 59 + GivenName.GetHashCode();
                }

                if (Surname != null)
                {
                    hash = hash * 59 + Surname.GetHashCode();
                }

                hash = hash * 59 + Active.GetHashCode();

                if (Initials != null)
                {
                    hash = hash * 59 + Initials.GetHashCode();
                }

                if (Email != null)
                {
                    hash = hash * 59 + Email.GetHashCode();
                }

                if (SmUserId != null)
                {
                    hash = hash * 59 + SmUserId.GetHashCode();
                }

                if (AccountId != null)
                {
                    hash = hash * 59 + AccountId.GetHashCode();
                }

                if (UserType != null)
                {
                    hash = hash * 59 + UserType.GetHashCode();
                }

                if (UserRoles != null)
                {
                    hash = hash * 59 + UserRoles.GetHashCode();
                }


                return(hash);
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = ContactId.GetHashCode();
         hashCode = (hashCode * 397) ^ (Description != null ? Description.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (TelephoneNumber != null ? TelephoneNumber.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 11
0
        public Contact GetById(ContactId contactId)
        {
            using var db = _dbContext.GetDatabase();
            var collection = db.GetCollection <DalContact>();

            collection.EnsureIndex(x => x.Id);
            return(collection.Query()
                   .Where(x => x.Id == contactId.Value)
                   .FirstOrDefault()
                   .ToDomain());
        }
Exemplo n.º 12
0
        public string ContactIdAsString()
        {
            string toReturn = "{unknown}";

            if (ContactId != null)
            {
                toReturn = ContactId.ToString();
            }

            return(toReturn);
        }
        /// <summary>
        /// <see cref="System.Object.Equals(object)"/>
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            EnrichContactItem objToCompare = obj as EnrichContactItem;

            if (objToCompare == null)
            {
                return(false);
            }
            return(EnrchTextDataId.Equals(objToCompare.EnrchTextDataId) && ContactId.Equals(objToCompare.ContactId) &&
                   JsonData.Equals(objToCompare.JsonData));
        }
Exemplo n.º 14
0
        public override int GetHashCode()
        {
            int result = 29;

            result = result * 13 + ContactId.GetHashCode();

            if (RelatedContactID.HasValue)
            {
                result = result * 13 + RelatedContactID.Value.GetHashCode();
            }
            else if (RelatedUserID.HasValue)
            {
                result = result * 13 + RelatedUserID.Value.GetHashCode();
            }

            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Execute a cycle of basic operations.
        /// </summary>
        /// <param name="cache">
        /// The target cache.
        /// </param>
        public virtual void Execute(INamedCache cache)
        {
            Contact   contact   = createContact();
            ContactId contactId = new ContactId(contact.FirstName,
                                                contact.LastName);

            Console.WriteLine("------BasicExample begins------");
            // associate a ContactId with a Contact in the cache
            cache.Add(contactId, contact);

            // retrieve the Contact associated with a ContactId from the cache
            contact = (Contact)cache[contactId];

            // remove mapping of ContactId to Contact from the cache.
            cache.Remove(contactId);
            Console.WriteLine("------BasicExample completed------");
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Gets the point states using the specified state 1
        /// </summary>
        /// <param name="state1">The state</param>
        /// <param name="state2">The state</param>
        /// <param name="manifold1">The manifold</param>
        /// <param name="manifold2">The manifold</param>
        public static void GetPointStates(out FixedArray2 <PointState> state1, out FixedArray2 <PointState> state2,
                                          ref Manifold manifold1, ref Manifold manifold2)
        {
            state1 = new FixedArray2 <PointState>();
            state2 = new FixedArray2 <PointState>();

            for (int i = 0; i < Settings.MaxManifoldPoints; ++i)
            {
                state1[i] = PointState.Null;
                state2[i] = PointState.Null;
            }

            // Detect persists and removes.
            for (int i = 0; i < manifold1.PointCount; ++i)
            {
                ContactId id = manifold1.Points[i].Id;

                state1[i] = PointState.Remove;

                for (int j = 0; j < manifold2.PointCount; ++j)
                {
                    if (manifold2.Points[j].Id.Key == id.Key)
                    {
                        state1[i] = PointState.Persist;
                        break;
                    }
                }
            }

            // Detect persists and adds.
            for (int i = 0; i < manifold2.PointCount; ++i)
            {
                ContactId id = manifold2.Points[i].Id;

                state2[i] = PointState.Add;

                for (int j = 0; j < manifold1.PointCount; ++j)
                {
                    if (manifold1.Points[j].Id.Key == id.Key)
                    {
                        state2[i] = PointState.Persist;
                        break;
                    }
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Read a single contact from the supplied stream.
        /// </summary>
        /// <param name="reader">
        /// The stream containing contacts.
        /// </param>
        /// <returns>
        /// The contact or null upon reaching end of stream.
        /// </returns>
        public Contact ReadContact(StreamReader reader)
        {
            string sRecord = reader.ReadLine();

            if (sRecord == null)
            {
                return(null);
            }

            // parse record
            char[]    chSeparators = { ',' };
            string[]  asPart       = sRecord.Split(chSeparators);
            int       ofPart       = 0;
            string    sFirstName   = asPart[ofPart++];
            string    sLastName    = asPart[ofPart++];
            DateTime  dtBirth      = DateTime.Parse(asPart[ofPart++]);
            ContactId id           = new ContactId(sFirstName, sLastName);
            Address   addrHome     = new Address(
                /*streetline1*/ asPart[ofPart++],
                /*streetline2*/ asPart[ofPart++],
                /*city*/ asPart[ofPart++],
                /*state*/ asPart[ofPart++],
                /*zip*/ asPart[ofPart++],
                /*country*/ asPart[ofPart++]);
            Address addrWork = new Address(
                /*streetline1*/ asPart[ofPart++],
                /*streetline2*/ asPart[ofPart++],
                /*city*/ asPart[ofPart++],
                /*state*/ asPart[ofPart++],
                /*zip*/ asPart[ofPart++],
                /*country*/ asPart[ofPart++]);
            IDictionary dictTelNum = new ListDictionary();

            for (int c = asPart.Length - 1; ofPart < c;)
            {
                dictTelNum.Add(/*type*/ asPart[ofPart++], new PhoneNumber(
                                   /*access code*/ Convert.ToInt16(asPart[ofPart++]),
                                   /*country code*/ Convert.ToInt16(asPart[ofPart++]),
                                   /*area code*/ Convert.ToInt16(asPart[ofPart++]),
                                   /*local num*/ Convert.ToInt64(asPart[ofPart++])));
            }

            return(new Contact(sFirstName, sLastName, addrHome, addrWork,
                               dictTelNum, dtBirth));
        }
    private void LeadChanges()
    {
        bool isLead = (!String.IsNullOrEmpty(_CurrentActivity.LeadId) && !(_CurrentActivity.LeadId.Trim() == ""));

        if (isLead)
        {
            Contact_lz.Text = GetLocalResourceObject("Lead").ToString();
            Account_lz.Text = GetLocalResourceObject("Company").ToString();
            AccountId.Text  = _CurrentActivity.AccountName;
            ContactId.Text  = _CurrentActivity.LeadName;
            ContactId.SetLookupEntity(typeof(Lead));
            ContactId.LookupEntityName     = "Lead";
            ContactId.LookupEntityTypeName = "Sage.SalesLogix.Entities.Lead, Sage.SalesLogix.Entities";
            ContactId.LookupResultValue    = _CurrentActivity.LeadId;
            AccountId.EnableHyperLinking   = false;
            OpportunitySpan.Visible        = false;
        }
    }
Exemplo n.º 19
0
        public IDictionary <string, object> ToDictionary()
        {
            var dict = new Dictionary <string, object>
            {
                { "PointOfContactId", ContactId.ToString() },
                { "FullName", FullName },
                { "CommunicationsChannel", (int)ContactConfirmationMethod.Value },
                { "TelephoneNumber", TelephoneNumber },
                { "EmailAddress", EmailAddress }
            };

            var addressDictionary = Address?.ToNonIdAndDateDictionary();

            if (addressDictionary != null)
            {
                foreach (var item in addressDictionary)
                {
                    dict.Add(item.Key, item.Value);
                }
            }

            return(dict);
        }
Exemplo n.º 20
0
 public string getId()
 {
     return(ContactId.ToString());
 }
Exemplo n.º 21
0
        //Get group idwise contact count
        public static int GetGroupIdWiseContactsCount(int GroupId, string Search)
        {
            List <GroupContactDTO> GroupContactDTOList = new List <GroupContactDTO>();
            List <ContactDTO>      ContactDTOList      = new List <ContactDTO>();
            List <Contact>         ContactList         = new List <Contact>();

            int ClientId = 0;

            if (GroupId != 0)
            {
                ClientId = GroupService.GetById(GroupId).ClientID;
            }

            try
            {
                UnitOfWork uow = new UnitOfWork();
                IEnumerable <GroupContact> GroupContact = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == GroupId);


                if (GroupContact != null)
                {
                    //foreach (var item in GroupContact)
                    //{
                    //    Contact Contact = new Contact();
                    //    Contact = uow.ContactRepo.GetById(item.ContactId);
                    //    ContactList.Add(Contact);
                    //}

                    if (Search != "" && Search != null)
                    {
                        List <ContactDTO> ContactDTOSearchList = new List <ContactDTO>();

                        bool IsDate = CommonService.IsDate(Search);
                        if (IsDate != true)
                        {
                            // string search
                            string ContactIdString = ContactService.GetContactIdarrayByName(Search, ClientId);
                            IQueryable <GroupContact> GroupContactSearch = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == GroupId && (ContactIdString != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdString.Contains(ContactId.ToString()))) : false)).AsQueryable();

                            if (GroupContactSearch != null)
                            {
                                //List<Contact> ContactListSearch = new List<Contact>();
                                //foreach (var item in GroupContactSearch)
                                //{
                                //    Contact Contact = new Contact();
                                //    Contact = uow.ContactRepo.GetById(item.ContactId);
                                //    ContactListSearch.Add(Contact);
                                //}

                                //IQueryable<Contact> Contactsearch = ContactListSearch.Where(e => (e.Email != null ? (e.Email.ToLower().Contains(Search.ToLower())) : false) || e.MobileNumber.Contains(Search) || (e.Name != null ? (e.Name.ToLower().Contains(Search.ToLower())) : false) || (e.FirstName != null ? (e.FirstName.ToLower().Contains(Search.ToLower())) : false) || (e.LastName != null ? (e.LastName.ToLower().Contains(Search.ToLower())) : false) || (e.AnniversaryDate.ToString() != null ? (Convert.ToDateTime(e.AnniversaryDate).ToString("dd-MMM-yyyy").ToLower().Contains(Search.ToLower())) : false) || (e.BirthDate.ToString() != null ? (Convert.ToDateTime(e.BirthDate).ToString("dd-MMM-yyyy").ToLower().Contains(Search.ToLower())) : false)).AsQueryable();//.OrderBy(e => e.Name);

                                //if (Contactsearch != null)
                                //{
                                //    foreach (var item in Contactsearch)
                                //    {
                                //        ContactDTOSearchList.Add(Transform.ContactToDTO(item));
                                //    }

                                //}
                                return(GroupContactSearch.Count());// ContactDTOSearchList.Skip(skip).Take(take).ToList();
                            }
                            return(GroupContactSearch.Count());
                        }
                        else
                        {
                            //date wise search
                            string ContactIdString = ContactService.GetContactIdarrayByName(Search, ClientId);

                            IQueryable <GroupContact> GroupContactSearch = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == GroupId && (ContactIdString != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdString.Contains(ContactId.ToString()))) : false)).AsQueryable();

                            if (GroupContactSearch != null)
                            {
                                //List<Contact> ContactListSearch = new List<Contact>();
                                //foreach (var item in GroupContactSearch)
                                //{
                                //    Contact Contact = new Contact();
                                //    Contact = uow.ContactRepo.GetById(item.ContactId);
                                //    ContactListSearch.Add(Contact);
                                //}


                                //DateTime date = Convert.ToDateTime(Search);
                                //IQueryable<Contact> Contactsearch = ContactListSearch.Where(e => e.AnniversaryDate >= date && e.AnniversaryDate < date.AddDays(1) || e.BirthDate >= date && e.BirthDate < date.AddDays(1)).AsQueryable();//.OrderBy(e => e.Name);

                                //if (Contactsearch != null)
                                //{
                                //    foreach (var item in Contactsearch)
                                //    {
                                //        ContactDTOSearchList.Add(Transform.ContactToDTO(item));

                                //    }
                                //}
                                return(GroupContactSearch.Count());// ContactDTOSearchList.Skip(skip).Take(take).ToList();
                            }
                            return(GroupContactSearch.Count());
                        }
                    }



                    return(GroupContact.Count());// ContactDTOList.Skip(skip).Take(take).ToList();
                }
                return(GroupContact.Count());
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 22
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            try
            {
                EntityReference Template        = DocumentTemplateId.Get(executionContext);
                EntityReference Contact         = ContactId.Get(executionContext);
                Boolean         Logging         = EnableLogging.Get(executionContext);
                string          LicenseFilePath = LicenseFile.Get(executionContext);
                if (Logging)
                {
                    Log("Workflow Executed");
                }
                IWorkflowContext            context           = executionContext.GetExtension <IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory    = executionContext.GetExtension <IOrganizationServiceFactory>();
                IOrganizationService        service           = serviceFactory.CreateOrganizationService(context.UserId);
                QueryExpression             RetrieveNoteQuery = new QueryExpression("annotation");
                RetrieveNoteQuery.ColumnSet = new ColumnSet(new string[] { "subject", "documentbody" });
                RetrieveNoteQuery.Criteria.AddCondition(new ConditionExpression("objectid", ConditionOperator.Equal, Template.Id));
                if (Logging)
                {
                    Log("Executing Query to retrieve Template Attachment");
                }
                EntityCollection Notes = service.RetrieveMultiple(RetrieveNoteQuery);
                if (Logging)
                {
                    Log("Attachment Retrieved Successfully");
                }
                if (Notes.Entities.Count > 0)
                {
                    Entity Note     = Notes[0];
                    string FileName = "";
                    if (Note.Contains("subject"))
                    {
                        FileName = Note["subject"].ToString();
                    }
                    if (Note.Contains("documentbody"))
                    {
                        if (Logging)
                        {
                            Log("Attachment Read Successfully");
                        }
                        byte[]       DocumentBody = Convert.FromBase64String(Note["documentbody"].ToString());
                        MemoryStream fileStream   = new MemoryStream(DocumentBody);
                        try
                        {
                            if (Logging)
                            {
                                Log("Enable Licensing");
                            }
                            if (LicenseFilePath != "" && File.Exists(LicenseFilePath))
                            {
                                Aspose.Words.License Lic = new License();
                                Lic.SetLicense(LicenseFilePath);
                                if (Logging)
                                {
                                    Log("License Set");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Log("Error while applying license: " + ex.Message);
                        }
                        if (Logging)
                        {
                            Log("Reading Document in Aspose.Words");
                        }
                        Document doc    = new Document(fileStream);
                        string[] fields = doc.MailMerge.GetFieldNames();
                        if (Logging)
                        {
                            Log("Getting list of fields");
                        }
                        Entity contact = service.Retrieve("contact", Contact.Id, new ColumnSet(fields));
                        if (Logging)
                        {
                            Log("Retrieved Contact entity");
                        }
                        if (contact != null)
                        {
                            string[] values = new string[fields.Length];
                            for (int i = 0; i < fields.Length; i++)
                            {
                                if (contact.Contains(fields[i]))
                                {
                                    if (contact[fields[i]].GetType() == typeof(OptionSetValue))
                                    {
                                        values[i] = contact.FormattedValues[fields[i]].ToString();
                                    }
                                    else if (contact[fields[i]].GetType() == typeof(EntityReference))
                                    {
                                        values[i] = ((EntityReference)contact[fields[i]]).Name;
                                    }
                                    else
                                    {
                                        values[i] = contact[fields[i]].ToString();
                                    }
                                }
                                else
                                {
                                    values[i] = "";
                                }
                            }
                            if (Logging)
                            {
                                Log("Executing Mail Merge");
                            }
                            doc.MailMerge.Execute(fields, values);
                            MemoryStream UpdateDoc = new MemoryStream();
                            if (Logging)
                            {
                                Log("Saving Document");
                            }
                            doc.Save(UpdateDoc, SaveFormat.Docx);
                            byte[] byteData = UpdateDoc.ToArray();

                            // Encode the data using base64.
                            string encodedData = System.Convert.ToBase64String(byteData);

                            if (Logging)
                            {
                                Log("Creating Attachment");
                            }
                            Entity NewNote = new Entity("annotation");
                            // Im going to add Note to entity
                            NewNote.Attributes.Add("objectid", new EntityReference("contact", Contact.Id));
                            NewNote.Attributes.Add("subject", FileName);

                            // Set EncodedData to Document Body
                            NewNote.Attributes.Add("documentbody", encodedData);

                            // Set the type of attachment
                            NewNote.Attributes.Add("mimetype", @"application\ms-word");
                            NewNote.Attributes.Add("notetext", "Document Created using template");

                            // Set the File Name
                            NewNote.Attributes.Add("filename", FileName);
                            service.Create(NewNote);
                            if (Logging)
                            {
                                Log("Successfull");
                            }
                        }
                    }
                }
                if (Logging)
                {
                    Log("Workflow Executed Successfully");
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message);
            }
        }
Exemplo n.º 23
0
 public override int GetHashCode()
 {
     return(Tenant.GetHashCode() ^ User.GetHashCode() ^ ContactId.GetHashCode() ^ Data.GetHashCode() ^
            Type.GetHashCode() ^ IsPrimary.GetHashCode());
 }
        protected override void Execute(CodeActivityContext executionContext)
        {
            try
            {
                EntityReference FirstAttachment  = FirstAttachmentId.Get(executionContext);
                EntityReference SecondAttachment = SecondAttachmentId.Get(executionContext);
                EntityReference Contact          = ContactId.Get(executionContext);
                string          Option           = OutputOption.Get(executionContext);
                Boolean         Logging          = EnableLogging.Get(executionContext);
                string          LicenseFilePath  = LicenseFile.Get(executionContext);

                if (Logging)
                {
                    Log("Workflow Executed");
                }

                // Create a CRM Service in Workflow.
                IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
                IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

                if (Logging)
                {
                    Log("Executing Query to retrieve First Attachment");
                }

                Entity FirstNote = service.Retrieve("annotation", FirstAttachment.Id, new ColumnSet(new string[] { "subject", "documentbody" }));

                if (Logging)
                {
                    Log("First Attachment Retrieved Successfully");
                }
                if (Logging)
                {
                    Log("Executing Query to retrieve Second Attachment");
                }

                Entity SecondNote = service.Retrieve("annotation", SecondAttachment.Id, new ColumnSet(new string[] { "subject", "documentbody" }));

                if (Logging)
                {
                    Log("Second Attachment Retrieved Successfully");
                }

                MemoryStream fileStream1 = null, fileStream2 = null;
                string       FileName1 = "";
                string       FileName2 = "";
                if (FirstNote != null && FirstNote.Contains("documentbody"))
                {
                    byte[] DocumentBody = Convert.FromBase64String(FirstNote["documentbody"].ToString());
                    fileStream1 = new MemoryStream(DocumentBody);
                    if (FirstNote.Contains("filename"))
                    {
                        FileName1 = FirstNote["filename"].ToString();
                    }
                }
                if (SecondNote != null && SecondNote.Contains("documentbody"))
                {
                    byte[] DocumentBody = Convert.FromBase64String(SecondNote["documentbody"].ToString());
                    fileStream2 = new MemoryStream(DocumentBody);
                    if (SecondNote.Contains("filename"))
                    {
                        FileName2 = SecondNote["filename"].ToString();
                    }
                }
                try
                {
                    if (Logging)
                    {
                        Log("Enable Licensing");
                    }

                    if (LicenseFilePath != "" && File.Exists(LicenseFilePath))
                    {
                        Aspose.Words.License Lic = new License();
                        Lic.SetLicense(LicenseFilePath);
                        if (Logging)
                        {
                            Log("License Set");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log("Error while applying license: " + ex.Message);
                }

                if (Logging)
                {
                    Log("Merging Documents");
                }

                Document doc1 = new Document(fileStream1);
                Document doc2 = new Document(fileStream2);
                doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);

                if (Logging)
                {
                    Log("Merging Complete");
                }

                MemoryStream UpdateDoc = new MemoryStream();

                if (Logging)
                {
                    Log("Saving Document");
                }

                doc1.Save(UpdateDoc, SaveFormat.Docx);
                byte[] byteData = UpdateDoc.ToArray();

                // Encode the data using base64.
                string encodedData = System.Convert.ToBase64String(byteData);

                if (Logging)
                {
                    Log("Creating Attachment");
                }

                Entity NewNote = new Entity("annotation");

                // Add a note to the entity.
                NewNote.Attributes.Add("objectid", new EntityReference("contact", Contact.Id));

                // Set EncodedData to Document Body.
                NewNote.Attributes.Add("documentbody", encodedData);

                // Set the type of attachment.
                NewNote.Attributes.Add("mimetype", @"application\ms-word");
                NewNote.Attributes.Add("notetext", "Document Created using template");

                if (Option == "0")
                {
                    NewNote.Id = FirstNote.Id;
                    NewNote.Attributes.Add("subject", FileName1);
                    NewNote.Attributes.Add("filename", FileName1);
                    service.Update(NewNote);
                }
                else if (Option == "1")
                {
                    NewNote.Id = SecondNote.Id;
                    NewNote.Attributes.Add("subject", FileName2);
                    NewNote.Attributes.Add("filename", FileName2);
                    service.Update(NewNote);
                }
                else
                {
                    NewNote.Attributes.Add("subject", "Aspose .Net Document Merger");
                    NewNote.Attributes.Add("filename", "Aspose .Net Document Merger.docx");
                    service.Create(NewNote);
                }
                if (Logging)
                {
                    Log("Successfull");
                }
            }
            catch (Exception ex)
            {
                Log(ex.Message);
            }
        }
Exemplo n.º 25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.btnPreWarn.OnClientClick = string.Format("return previewEmailTemplate('{0}');", this.ddlWarningEmail.ClientID);
                this.btnPreOverdue.OnClientClick = string.Format("return previewEmailTemplate('{0}');", this.ddlOverdueEmail.ClientID);
                this.btnPreComple.OnClientClick = string.Format("return previewEmailTemplate('{0}');", this.ddlComleEmail.ClientID);

                // bind email template
                BLL.Template_Email emailTpltManager = new BLL.Template_Email();

                DataTable dtEmailTplts = emailTpltManager.GetEmailTemplate("");
                this.ddlWarningEmail.DataValueField = "TemplEmailId";
                this.ddlWarningEmail.DataTextField = "Name";
                this.ddlWarningEmail.DataSource = dtEmailTplts;
                this.ddlWarningEmail.DataBind();
                this.ddlWarningEmail.Items.Insert(0, new ListItem("--select an email template--", "0"));

                this.ddlOverdueEmail.DataValueField = "TemplEmailId";
                this.ddlOverdueEmail.DataTextField = "Name";
                this.ddlOverdueEmail.DataSource = dtEmailTplts;
                this.ddlOverdueEmail.DataBind();
                this.ddlOverdueEmail.Items.Insert(0, new ListItem("--select an email template--", "0"));

                this.ddlComleEmail.DataValueField = "TemplEmailId";
                this.ddlComleEmail.DataTextField = "Name";
                this.ddlComleEmail.DataSource = dtEmailTplts;
                this.ddlComleEmail.DataBind();
                this.ddlComleEmail.Items.Insert(0, new ListItem("--select an email template--", "0"));

                BindTaskOwner();

                if ("0" == Mode)
                {
                    BLL.Prospect prospectManager = new BLL.Prospect();
                    Model.Prospect currProspect = prospectManager.GetModel(ContactId.GetValueOrDefault(0));
                    if (null == currProspect)
                    {
                        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid3", "alert('Invalid query string.');window.close();", true);
                        return;
                    }
                    // set prospect's officer as task owner
                    ListItem listItem = this.ddlOwner.Items.FindByValue(currProspect.Loanofficer.GetValueOrDefault(0).ToString());
                    if (null != listItem)
                        listItem.Selected = true;
                    
                    this.btnDelete.Enabled = false;
                    this.btnClone.Enabled = false;

                    int nContactId = -1;
                    if (!int.TryParse(Request.QueryString["ContactId"], out nContactId))
                        nContactId = -1;
                    Model.Contacts contact = contactsManager.GetModel(nContactId);
                    if (null != contact)
                        this.lblClient.Text = string.Format("{0}, {1} {2}", contact.LastName, contact.FirstName, contact.MiddleName);
                    else
                    {
                        PageCommon.AlertMsg(this, "Invalid contact id!");
                        ClientFun("closewindow", "closeBox(false, false);");
                    }
                }
                else if ("1" == Mode)
                {
                    if (!ProspectTaskId.HasValue)
                    {
                        // if no ProspectTaskId,thorw exception
                        LPLog.LogMessage(LogType.Logerror, "Invalid client task id");
                        throw new Exception("Invalid client task id");
                    }
                    else
                    {
                        Model.ProspectTasks pt = ptManager.GetModel(ProspectTaskId.Value);
                        if (null == pt)
                        {
                            LPLog.LogMessage(LogType.Logerror, string.Format("Cannot find the task with ID:{0}", ProspectTaskId.Value));
                        }
                        else
                        {
                            if (pt.Completed.HasValue)
                            {
                                this.btnSave.Enabled = false;
                                this.btnDelete.Enabled = false;
                            }
                            Model.Contacts contact = contactsManager.GetModel(pt.ContactId);
                            if (null != contact)
                                this.lblClient.Text = string.Format("{0}, {1} {2}", contact.LastName, contact.FirstName, contact.MiddleName);
                            this.tbTaskName.Text = pt.TaskName;
                            this.ckbEnabled.Checked = pt.Enabled;
                            this.tbDesc.Text = pt.Desc;
                            ListItem listTaskItem = this.ddlOwner.Items.FindByValue(pt.OwnerId.GetValueOrDefault(0).ToString());
                            if (null != listTaskItem)
                                listTaskItem.Selected = true;
                            this.ddlOwner.SelectedIndex = pt.OwnerId.GetValueOrDefault();
                            if (pt.Due.HasValue)
                                this.tbDue.Text = pt.Due.Value.ToString("MM/dd/yyyy");

                            ListItem listItem = this.ddlWarningEmail.Items.FindByValue(pt.WarningEmailTemplId.GetValueOrDefault().ToString());
                            if (null != listItem)
                                listItem.Selected = true;

                            listItem = this.ddlOverdueEmail.Items.FindByValue(pt.OverdueEmailTemplId.GetValueOrDefault().ToString());
                            if (null != listItem)
                                listItem.Selected = true;

                            listItem = this.ddlComleEmail.Items.FindByValue(pt.CompletionEmailTemplid.GetValueOrDefault().ToString());
                            if (null != listItem)
                                listItem.Selected = true;
                        }
                    }
                }
            }
        }
 /// <summary>
 /// <see cref="System.Object.GetHashCode()"/>
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return((EnrchTextDataId + ContactId.ToString() + JsonData).GetHashCode());
 }
Exemplo n.º 27
0
 public override int GetHashCode()
 {
     return(ContactId.GetHashCode());
 }
Exemplo n.º 28
0
        public string contactIdString()
        {
            string id = ContactId.ToString();

            return(id);
        }
Exemplo n.º 29
0
 /// <summary>
 ///   Returns a <see cref = "T:System.String"></see> that represents the current <see cref = "T:System.Object"></see>.
 /// </summary>
 /// <returns>
 ///   A <see cref = "T:System.String"></see> that represents the current <see cref = "T:System.Object"></see>.
 /// </returns>
 public override string ToString()
 {
     return(ContactId.ToString());
 }
Exemplo n.º 30
0
        //Get contact present list as per group id
        public static List <ContactDTO> GetGroupIdWisePresentContacts(PagingInfo pagingInfo)
        {
            List <GroupContactDTO> GroupContactDTOList = new List <GroupContactDTO>();
            List <ContactDTO>      ContactDTOList      = new List <ContactDTO>();
            List <Contact>         ContactList         = new List <Contact>();

            int ClientId = 0;

            if (pagingInfo.GroupId != 0)
            {
                ClientId = GroupService.GetById(pagingInfo.GroupId).ClientID;
            }

            try
            {
                int skip = (pagingInfo.Page - 1) * pagingInfo.ItemsPerPage;
                int take = pagingInfo.ItemsPerPage;

                // string search
                //string ContactIdStringall = ContactService.GetContactIdarrayByName(pagingInfo.Search, ClientId);

                UnitOfWork uow = new UnitOfWork();
                IQueryable <GroupContact> GroupContact = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId).AsQueryable(); //&& (ContactIdStringall != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdStringall.Contains(ContactId.ToString()))) : false)
                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);
                GroupContact = GroupContact.Skip(skip).Take(take);
                if (GroupContact != null)
                {
                    foreach (var item in GroupContact)
                    {
                        Contact Contact = new Contact();
                        Contact = uow.ContactRepo.GetById(item.ContactId);
                        ContactList.Add(Contact);
                        //ContactDTO ContactDTO = new ContactDTO();
                        //ContactDTO = ContactService.GetById(item.ContactId);
                        //ContactDTOList.Add(ContactDTO);
                    }

                    if (ContactList != null)
                    {
                        if (pagingInfo.Search != "" && pagingInfo.Search != null)
                        {
                            List <ContactDTO> ContactDTOSearchList = new List <ContactDTO>();

                            bool IsDate = CommonService.IsDate(pagingInfo.Search);
                            if (IsDate != true)
                            {
                                // string search
                                string ContactIdString = ContactService.GetContactIdarrayByName(pagingInfo.Search, ClientId);
                                IQueryable <GroupContact> GroupContactSearch = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId && (ContactIdString != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdString.Contains(ContactId.ToString()))) : false)).AsQueryable();
                                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);
                                GroupContactSearch = GroupContactSearch.Skip(skip).Take(take);
                                if (GroupContactSearch != null)
                                {
                                    List <Contact> ContactListSearch = new List <Contact>();
                                    foreach (var item in GroupContactSearch)
                                    {
                                        Contact Contact = new Contact();
                                        Contact = uow.ContactRepo.GetById(item.ContactId);
                                        ContactListSearch.Add(Contact);
                                    }

                                    IQueryable <Contact> Contactsearch = ContactListSearch.Where(e => (e.Email != null ? (e.Email.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || e.MobileNumber.Contains(pagingInfo.Search) || (e.Name != null ? (e.Name.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.FirstName != null ? (e.FirstName.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.LastName != null ? (e.LastName.ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.AnniversaryDate.ToString() != null ? (Convert.ToDateTime(e.AnniversaryDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false) || (e.BirthDate.ToString() != null ? (Convert.ToDateTime(e.BirthDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false)).AsQueryable();//.OrderBy(e => e.Name);
                                    Contactsearch = PagingService.Sorting <Contact>(Contactsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                    Contactsearch = Contactsearch.Skip(skip).Take(take);
                                    if (Contactsearch != null)
                                    {
                                        foreach (var item in Contactsearch)
                                        {
                                            ContactDTOSearchList.Add(Transform.ContactToDTO(item));
                                        }
                                    }
                                    return(ContactDTOSearchList.Skip(skip).Take(take).ToList());
                                }
                            }
                            else
                            {
                                //date wise search
                                string ContactIdString = ContactService.GetContactIdarrayByName(pagingInfo.Search, ClientId);

                                IQueryable <GroupContact> GroupContactSearch = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == pagingInfo.GroupId && (ContactIdString != null ? (e.ContactId.ToString().Split(',').Any(ContactId => ContactIdString.Contains(ContactId.ToString()))) : false)).AsQueryable();
                                //GroupContact = PagingService.Sorting<GroupContact>(GroupContact, pagingInfo.SortBy, pagingInfo.Reverse);
                                GroupContactSearch = GroupContactSearch.Skip(skip).Take(take);
                                if (GroupContactSearch != null)
                                {
                                    List <Contact> ContactListSearch = new List <Contact>();
                                    foreach (var item in GroupContactSearch)
                                    {
                                        Contact Contact = new Contact();
                                        Contact = uow.ContactRepo.GetById(item.ContactId);
                                        ContactListSearch.Add(Contact);
                                    }


                                    DateTime             date          = Convert.ToDateTime(pagingInfo.Search);
                                    IQueryable <Contact> Contactsearch = ContactListSearch.Where(e => e.AnniversaryDate >= date && e.AnniversaryDate < date.AddDays(1) || e.BirthDate >= date && e.BirthDate < date.AddDays(1)).AsQueryable();//.OrderBy(e => e.Name);
                                    Contactsearch = PagingService.Sorting <Contact>(Contactsearch, pagingInfo.SortBy, pagingInfo.Reverse);
                                    Contactsearch = Contactsearch.Skip(skip).Take(take);
                                    if (Contactsearch != null)
                                    {
                                        foreach (var item in Contactsearch)
                                        {
                                            ContactDTOSearchList.Add(Transform.ContactToDTO(item));
                                        }
                                    }
                                    return(ContactDTOSearchList.Skip(skip).Take(take).ToList());
                                }
                            }
                        }

                        //ContactList = ContactList.Skip(skip).Take(take).ToList();
                        foreach (var item in ContactList)
                        {
                            ContactDTOList.Add(Transform.ContactToDTO(item));
                        }
                    }


                    return(ContactDTOList);// ContactDTOList.Skip(skip).Take(take).ToList();
                }


                return(ContactDTOList.Skip(skip).Take(take).ToList());
            }
            catch (Exception)
            {
                throw;
            }
        }