Пример #1
0
        public EntityFieldDef AddEntityFieldDef(Guid entityDefId, string fieldName, string caption, DataTypes dataType, int length)
        {
            if (RequestContext.Current.TenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }
            if (entityDefId == Guid.Empty)
            {
                throw new ArgumentNullException("entityDefId");
            }
            if (string.IsNullOrEmpty(fieldName))
            {
                throw new ArgumentNullException("fieldName");
            }
            EntityFieldDef result = null;

            try
            {
                DataModelContext.Initialize(RequestContext.Current.TenantId);
                result = MetadataLogic.AddEntityFieldDef(entityDefId, fieldName, caption, dataType, length);
            }
            finally
            {
                DataModelContext.Clear();
            }
            return(result);
        }
Пример #2
0
    /// <summary>
    /// Initializes the page.
    /// </summary>
    /// <remarks>This method runs on the first load of the page, and does NOT
    /// run on postbacks. If you want to run a method on PostBacks, override the
    /// Page_Load event</remarks>
    protected override void InitializePage()
    {
        base.InitializePage();

        var individualMetadata = MetadataLogic.DescribeObject(msIndividual.CLASS_NAME);

        CRMLogic.InitPickList(individualMetadata.Fields.FirstOrDefault(f => f.Name == msIndividual.FIELDS.Prefix), tbPrefix);
        CRMLogic.InitPickList(individualMetadata.Fields.FirstOrDefault(f => f.Name == msIndividual.FIELDS.Suffix), tbSuffix);

        setProfileImage(img, targetObject);
        bindObjectToPage();
    }
Пример #3
0
    protected override void InitializeTargetObject()
    {
        base.InitializeTargetObject();
        targetForm = LoadObjectFromAPI <msCustomObjectPortalForm>(ContextID);
        if (targetForm == null)
        {
            GoToMissingRecordPage();
        }

        string entityID = null;

        if (ConciergeAPI.CurrentEntity != null)
        {
            entityID = ConciergeAPI.CurrentEntity.ID;
        }

        using (var api = GetServiceAPIProxy())
            targetFormManifest = api.DescribePortalForm(targetForm.ID, entityID).ResultValue;

        // MS-5922 - only check this on initial load so that it will not fail on completion of creation of last allowed instance
        if (!IsPostBack)
        {
            if (!targetFormManifest.CanCreate)
            {
                GoTo("/AccessDenied.aspx");
            }
        }

        if (ConciergeAPI.CurrentEntity == null && !targetForm.AllowAnonymousSubmissions)  // we need them to go through registration
        {
            GoTo("~/profile/CreateAccount_BasicInfo.aspx?t=PortalForm&formID=" + targetForm.ID);
            return;
        }

        // ok, so we allow anonymous submissions here
        // MS-5360
        if (string.IsNullOrWhiteSpace(CurrentFormID.Value))
        {
            targetInstance          = MetadataLogic.CreateNewObject(targetFormManifest.UnderlyingObjectName);
            targetInstance["Owner"] = entityID;
        }
        else
        {
            targetInstance = APIExtensions.LoadObjectFromAPI(CurrentFormID.Value);
        }
    }
Пример #4
0
        public EntityDef[] GetEntityDefs()
        {
            if (RequestContext.Current.TenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }

            EntityDef[] result = null;
            try
            {
                DataModelContext.Initialize(RequestContext.Current.TenantId);
                result = MetadataLogic.GetEntityDefs();
            }
            finally
            {
                DataModelContext.Clear();
            }
            return(result);
        }
Пример #5
0
        public void UpdateEntityDef(Guid entityDefId, string caption)
        {
            if (RequestContext.Current.TenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }
            if (entityDefId == Guid.Empty)
            {
                throw new ArgumentNullException("entityDefId");
            }

            try
            {
                DataModelContext.Initialize(RequestContext.Current.TenantId);
                MetadataLogic.UpdateEntityDef(entityDefId, caption);
            }
            finally
            {
                DataModelContext.Clear();
            }
        }
Пример #6
0
        public void DeleteEntityFieldDef(Guid fieldDefId)
        {
            if (RequestContext.Current.TenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }

            if (fieldDefId == Guid.Empty)
            {
                throw new ArgumentNullException("fieldDefId");
            }
            try
            {
                DataModelContext.Initialize(RequestContext.Current.TenantId);
                MetadataLogic.DeleteEntityFieldDef(fieldDefId);
            }
            finally
            {
                DataModelContext.Clear();
            }
        }
Пример #7
0
        public EntityDef GetEnityDefByName(string name)
        {
            if (RequestContext.Current.TenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }
            EntityDef result = null;

            try
            {
                DataModelContext.Initialize(RequestContext.Current.TenantId);
                result = MetadataLogic.GetEnityDefByName(name);
            }
            finally
            {
                DataModelContext.Clear();
            }
            return(result);
        }
Пример #8
0
        public EntityFieldDef GetFieldDefById(Guid fieldId)
        {
            if (RequestContext.Current.TenantId == Guid.Empty)
            {
                throw new ArgumentNullException("tenantId");
            }
            if (fieldId == Guid.Empty)
            {
                throw new ArgumentNullException("fieldId");
            }
            EntityFieldDef result = null;

            try
            {
                DataModelContext.Initialize(RequestContext.Current.TenantId);
                result = MetadataLogic.GetFieldDefById(fieldId);
            }
            finally
            {
                DataModelContext.Clear();
            }
            return(result);
        }
Пример #9
0
    protected T CreateNewObject <T>() where T : msAggregate, new()
    {
        var instance = new T();

        return(MetadataLogic.CreateNewObject(instance.ClassType).ConvertTo <T>());
    }