示例#1
0
    public void GetCurrentUserContactAndCompanyNames(out string contactName, out string companyName)
    {
        companyName = contactName = string.Empty;

        var contact             = new Terrasoft.Configuration.Contact(UserConnection);
        var account             = new Terrasoft.Configuration.Account(UserConnection);
        var contactEntitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
        var contactEntitySchemaPrimaryColumnName = contactEntitySchema.GetPrimaryColumnName();
        var contactEntitySchemaPrimaryColumn     = contactEntitySchema.Columns.GetByName(contactEntitySchemaPrimaryColumnName);
        var accountEntitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Account");
        var accountEntitySchemaPrimaryColumnName = accountEntitySchema.GetPrimaryColumnName();
        var accountEntitySchemaPrimaryColumn     = accountEntitySchema.Columns.GetByName(accountEntitySchemaPrimaryColumnName);

        var nameColumnsToFetch = new EntitySchemaColumn[] {
            contactEntitySchema.Columns.GetByName("Name")
        };
        var nameAccountColumnsToFetch = new EntitySchemaColumn[] {
            contactEntitySchema.Columns.GetByName("Name"),
            contactEntitySchema.Columns.GetByName("Account")
        };
        var currentUserContactUId = UserConnection.CurrentUser.ContactId;

        if (contact.FetchFromDB(contactEntitySchemaPrimaryColumn, currentUserContactUId, nameAccountColumnsToFetch))
        {
            contactName = contact.Name;
            var currentUserCompanyUId = contact.AccountId;
            if (account.FetchFromDB(accountEntitySchemaPrimaryColumn, currentUserCompanyUId, nameColumnsToFetch))
            {
                companyName = account.Name;
            }
        }
    }
示例#2
0
        private bool ActualizeContactScriptTaskExecute(ProcessExecutingContext context)
        {
            Dictionary <string, string> contactValues = Json.Deserialize <Dictionary <string, string> >(Get <string>("ClaimData"));
            UserConnection userConnection             = Get <UserConnection>("UserConnection");
            var            contact = new Terrasoft.Configuration.Contact(userConnection);
            string         contactId;

            if (!contactValues.TryGetValue(contact.Schema.GetPrimaryColumnName(), out contactId))
            {
                return(true);
            }
            if (contact.FetchFromDB(new Guid(contactId)))
            {
                UpdateContact(contact, contactValues);
                string isNewRecord;
                if (contactValues.TryGetValue("IsNewRecord", out isNewRecord) &&
                    isNewRecord.Equals("true", StringComparison.InvariantCultureIgnoreCase))
                {
                    EntitySchema schema = userConnection.EntitySchemaManager.GetInstanceByName("Contact");
                    var          userId = new Guid(contactValues["SysAdminUnitId"]);
                    userConnection.DBSecurityEngine.AddDefRights(contact.Id, userId, contact.Id, schema);
                }
            }
            return(true);
        }
示例#3
0
    public Guid GetContactAccountUId(Guid contactUId)
    {
        var accountUId          = Guid.Empty;
        var contact             = new Terrasoft.Configuration.Contact(UserConnection);
        var contactEntitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("Contact");
        var contactEntitySchemaPrimaryColumnName = contactEntitySchema.GetPrimaryColumnName();
        var contactEntitySchemaPrimaryColumn     = contactEntitySchema.Columns.GetByName(contactEntitySchemaPrimaryColumnName);
        var columnsToFetch = new EntitySchemaColumn[] {
            contactEntitySchema.Columns.GetByName("Account")
        };

        if (contact.FetchFromDB(contactEntitySchemaPrimaryColumn, contactUId, columnsToFetch))
        {
            accountUId = contact.AccountId;
        }
        return(accountUId);
    }
 public Contact(Terrasoft.Configuration.Contact source)
     : base(source)
 {
     this.CopyEntityLookupProperties(source);
 }