public static void CreateLicenceDocumentLocation(this IDynamicsClient _dynamicsClient, MicrosoftDynamicsCRMadoxioLicences licenceEntity, string folderName, string name) { // set the parent document library. var parentDocumentLibraryReference = _dynamicsClient.GetDocumentLocationReferenceByRelativeURL("adoxio_licences"); var licenceUri = _dynamicsClient.GetEntityURI("adoxio_licenceses", licenceEntity.AdoxioLicencesid); // now create a document location to link them. // Create the SharePointDocumentLocation entity var mdcsdl = new MicrosoftDynamicsCRMsharepointdocumentlocation { RegardingobjectIdEventODataBind = licenceUri, ParentsiteorlocationSharepointdocumentlocationODataBind = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", parentDocumentLibraryReference), Relativeurl = folderName, Description = "Licence Files", Name = name }; var sharepointdocumentlocationid = _dynamicsClient.DocumentLocationExistsWithCleanup(mdcsdl); if (sharepointdocumentlocationid == null) { try { mdcsdl = _dynamicsClient.Sharepointdocumentlocations.Create(mdcsdl); } catch (HttpOperationException odee) { Log.Error(odee, "Error creating SharepointDocumentLocation"); mdcsdl = null; } if (mdcsdl != null) { var sharePointLocationData = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", mdcsdl.Sharepointdocumentlocationid); var oDataId = new Odataid { OdataidProperty = sharePointLocationData }; try { _dynamicsClient.Licenceses.AddReference(licenceEntity.AdoxioLicencesid, "adoxio_licences_SharePointDocumentLocations", oDataId); } catch (HttpOperationException odee) { Log.Error(odee, "Error adding reference to SharepointDocumentLocation"); } } } }
private static void CreateContactDocumentLocation(this IDynamicsClient _dynamicsClient, MicrosoftDynamicsCRMcontact contact, string folderName, string name) { var parentDocumentLibraryReference = _dynamicsClient.GetDocumentLocationReferenceByRelativeURL("contact"); var contactUri = _dynamicsClient.GetEntityURI("contacts", contact.Contactid); // now create a document location to link them. // Create the SharePointDocumentLocation entity var mdcsdl = new MicrosoftDynamicsCRMsharepointdocumentlocation { RegardingobjectIdContactODataBind = contactUri, ParentsiteorlocationSharepointdocumentlocationODataBind = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", parentDocumentLibraryReference), Relativeurl = folderName, Description = "Contact Files", Name = name }; var sharepointdocumentlocationid = _dynamicsClient.DocumentLocationExistsWithCleanup(mdcsdl); if (sharepointdocumentlocationid == null) { try { mdcsdl = _dynamicsClient.Sharepointdocumentlocations.Create(mdcsdl); } catch (HttpOperationException odee) { Log.Error(odee, "Error creating SharepointDocumentLocation"); mdcsdl = null; } if (mdcsdl != null) { var sharePointLocationData = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", mdcsdl.Sharepointdocumentlocationid); var oDataId = new Odataid { OdataidProperty = sharePointLocationData }; try { _dynamicsClient.Contacts.AddReference(contact.Contactid, "adoxio_application_SharePointDocumentLocations", oDataId); } catch (HttpOperationException odee) { Log.Error(odee, "Error adding reference to SharepointDocumentLocation"); } } } }
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"); } } }