コード例 #1
0
ファイル: Associations.cs プロジェクト: Anupam750/Act.Samples
        /// <summary>
        /// Creates a new association between two contacts
        /// </summary>
        /// <remarks>
        /// Creating an association between two entities
        /// This sample creates a new association between two contacts.
        /// The sample shows the following tasks:
        /// - Retrieve the appropriate AssocaitionManager for a Contact to Contact association
        /// - Two methods of setting detailed information for the Association
        /// - Persisting the association to the database
        /// </remarks>
        private Association CreateAssociation(Contact contactOne, Contact contactTwo)
        {
            //Log into the framework and retrieve the correct AssociationManager
            ActFramework ACTFM = new ActFramework();

            ACTFM.LogOn("C:\\Documents and Settings\\Administrator\\My Documents\\ACT\\Act for Win 8\\Databases\\Act8Demo.pad", "Chris Huffman", "");

            Framework.MutableEntities.MutableEntity company = null;
            Framework.MetaData.Entity opportunity           = null;
            AssociationManager        associationManager    = ACTFM.Associations.GetAssociationManager(company, opportunity);

            //Create the assocaition
            Association association = associationManager.CreateAssociation(contactOne, contactTwo);

            //First means of setting association information
            association.Fields[Framework.Associations.StandardField.Details] = "Association Details";

            //Second meand of setting association information
            AssociationFieldDescriptor field = associationManager.GetFieldDescriptor(Framework.Associations.StandardField.Entity1Role);

            field.SetValue(association, "First entities role in this assocaition");

            //Persist the association to the database.
            association.Update();

            return(association);
        }
コード例 #2
0
ファイル: Associations.cs プロジェクト: Anupam750/Act.Samples
        /// <summary>
        /// Retrieves an entity list of contacts associated with a given contact
        /// and updates the associaton information.
        /// </summary>
        /// <remarks>
        /// Retrieving a list of associated entities(EntityList) and update association details
        /// This sample demonstrates the use of an AssociationFieldDescriptor to interact with other entities in the Act! framework.Currently supported entities are Opportunities, Companies, Groups and Contacts.
        /// </remarks>
        private void UpdateAssociatons2(Contact contact, string newRole)
        {
            //Log into the framework and retrieve the correct AssociationManager
            ActFramework ACTFM = new ActFramework();

            ACTFM.LogOn("C:\\Documents and Settings\\Administrator\\My Documents\\ACT\\Act for Win 8\\Databases\\Act8Demo.pad", "Chris Huffman", "");
            AssociationManager associationManager = ACTFM.Associations.GetAssociationManager("Group", "Opportunity");

            //Retrieve the entity list.
            Act.Framework.Entities.EntityList entityList = associationManager.GetAssociatedEntities(null, contact);
            //Retrieve the field descriptor
            AssociationFieldDescriptor roleField = associationManager.GetFieldDescriptor(Framework.Associations.StandardField.Entity1Role);

            //Enumerate each entity and update the role details.
            foreach (Act.Framework.Entities.Entity entity in entityList)
            {
                roleField.SetValue(entity, newRole);
                ((IUpdateableEntity)entity).Update();
            }
        }