コード例 #1
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);
        }
    }
コード例 #2
0
    protected T CreateNewObject <T>() where T : msAggregate, new()
    {
        var instance = new T();

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