Beispiel #1
0
        public static void CreateApplicationDocumentLocation(this IDynamicsClient _dynamicsClient, MicrosoftDynamicsCRMadoxioApplication application, string folderName, string name)
        {
            // now create a document location to link them.
            var parentDocumentLibraryReference = _dynamicsClient.GetDocumentLocationReferenceByRelativeURL("adoxio_application");

            var regardingobjectId = _dynamicsClient.GetEntityURI("adoxio_applications", application.AdoxioApplicationid);

            // Create the SharePointDocumentLocation entity
            var mdcsdl = new MicrosoftDynamicsCRMsharepointdocumentlocation
            {
                RegardingobjectidAdoxioApplicationODataBind             = regardingobjectId,
                ParentsiteorlocationSharepointdocumentlocationODataBind = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", parentDocumentLibraryReference),
                Relativeurl = folderName,
                Description = "Application Files",
                Name        = name
            };

            var sharepointdocumentlocationid = _dynamicsClient.DocumentLocationExistsWithCleanup(mdcsdl);

            if (sharepointdocumentlocationid == null)
            {
                sharepointdocumentlocationid = _dynamicsClient.CreateDocumentLocation(mdcsdl);

                var sharePointLocationData = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", sharepointdocumentlocationid);

                var oDataId = new Odataid
                {
                    OdataidProperty = sharePointLocationData
                };
                try
                {
                    _dynamicsClient.Applications.AddReference(application.AdoxioApplicationid, "adoxio_application_SharePointDocumentLocations", oDataId);
                }
                catch (HttpOperationException odee)
                {
                    Log.Error(odee, "Error adding reference to SharepointDocumentLocation");
                }
            }
        }