Ejemplo n.º 1
0
 /// <summary>
 /// Update entity in sharepointdocumentlocations
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='sharepointdocumentlocationid'>
 /// key: sharepointdocumentlocationid of sharepointdocumentlocation
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 public static void Update(this ISharepointdocumentlocations operations, string sharepointdocumentlocationid, MicrosoftDynamicsCRMsharepointdocumentlocation body)
 {
     operations.UpdateAsync(sharepointdocumentlocationid, body).GetAwaiter().GetResult();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Add new entity to sharepointdocumentlocations
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <MicrosoftDynamicsCRMsharepointdocumentlocation> CreateAsync(this ISharepointdocumentlocations operations, MicrosoftDynamicsCRMsharepointdocumentlocation body, string prefer = "return=representation", CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(body, prefer, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Add new entity to sharepointdocumentlocations
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 /// <param name='customHeaders'>
 /// Headers that will be added to request.
 /// </param>
 public static HttpOperationResponse <MicrosoftDynamicsCRMsharepointdocumentlocation> CreateWithHttpMessages(this ISharepointdocumentlocations operations, MicrosoftDynamicsCRMsharepointdocumentlocation body, string prefer = "return=representation", Dictionary <string, List <string> > customHeaders = null)
 {
     return(operations.CreateWithHttpMessagesAsync(body, prefer, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult());
 }
Ejemplo n.º 4
0
        private async Task CreateFederalReportDocumentLocation(MicrosoftDynamicsCRMadoxioFederalreportexport federalReport, string folderName, string name)
        {
            // now create a document location to link them.

            // Create the SharePointDocumentLocation entity
            MicrosoftDynamicsCRMsharepointdocumentlocation mdcsdl = new MicrosoftDynamicsCRMsharepointdocumentlocation()
            {
                Relativeurl = folderName,
                Description = "Federal Report Files",
                Name        = name
            };


            try
            {
                mdcsdl = _dynamicsClient.Sharepointdocumentlocations.Create(mdcsdl);
            }
            catch (HttpOperationException odee)
            {
                _logger.LogError(odee, "Error creating SharepointDocumentLocation");
                mdcsdl = null;
            }
            if (mdcsdl != null)
            {
                // set the parent document library.
                string parentDocumentLibraryReference = GetDocumentLocationReferenceByRelativeURL("adoxio_federalreportexport", name);

                string exportUri = _dynamicsClient.GetEntityURI("adoxio_federalreportexports", federalReport.AdoxioFederalreportexportid);
                // add a regardingobjectid.
                var patchSharePointDocumentLocationIncident = new MicrosoftDynamicsCRMsharepointdocumentlocation()
                {
                    RegardingobjectIdFederalReportExportODataBind           = exportUri,
                    ParentsiteorlocationSharepointdocumentlocationODataBind = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", parentDocumentLibraryReference),
                    Relativeurl = name,
                    Description = "Federal Report Files",
                };

                try
                {
                    _dynamicsClient.Sharepointdocumentlocations.Update(mdcsdl.Sharepointdocumentlocationid, patchSharePointDocumentLocationIncident);
                }
                catch (HttpOperationException odee)
                {
                    _logger.LogError(odee, "Error adding reference SharepointDocumentLocation to federal report");
                }

                string sharePointLocationData = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", mdcsdl.Sharepointdocumentlocationid);

                Odataid oDataId = new Odataid()
                {
                    OdataidProperty = sharePointLocationData
                };

                try
                {
                    _dynamicsClient.Federalreportexports.AddReference(federalReport.AdoxioFederalreportexportid, "adoxio_federalreportexport_SharePointDocumentLocations", oDataId);
                }
                catch (HttpOperationException odee)
                {
                    _logger.LogError(odee, "Error adding reference to SharepointDocumentLocation");
                }
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Add new entity to sharepointdocumentlocations
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='body'>
 /// New entity
 /// </param>
 /// <param name='prefer'>
 /// Required in order for the service to return a JSON representation of the
 /// object.
 /// </param>
 public static MicrosoftDynamicsCRMsharepointdocumentlocation Create(this ISharepointdocumentlocations operations, MicrosoftDynamicsCRMsharepointdocumentlocation body, string prefer = "return=representation")
 {
     return(operations.CreateAsync(body, prefer).GetAwaiter().GetResult());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Update entity in sharepointdocumentlocations
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='sharepointdocumentlocationid'>
 /// key: sharepointdocumentlocationid of sharepointdocumentlocation
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 /// <param name='customHeaders'>
 /// Headers that will be added to request.
 /// </param>
 public static HttpOperationResponse UpdateWithHttpMessages(this ISharepointdocumentlocations operations, string sharepointdocumentlocationid, MicrosoftDynamicsCRMsharepointdocumentlocation body, Dictionary <string, List <string> > customHeaders = null)
 {
     return(operations.UpdateWithHttpMessagesAsync(sharepointdocumentlocationid, body, customHeaders, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult());
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Update entity in sharepointdocumentlocations
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='sharepointdocumentlocationid'>
 /// key: sharepointdocumentlocationid of sharepointdocumentlocation
 /// </param>
 /// <param name='body'>
 /// New property values
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task UpdateAsync(this ISharepointdocumentlocations operations, string sharepointdocumentlocationid, MicrosoftDynamicsCRMsharepointdocumentlocation body, CancellationToken cancellationToken = default(CancellationToken))
 {
     (await operations.UpdateWithHttpMessagesAsync(sharepointdocumentlocationid, body, null, cancellationToken).ConfigureAwait(false)).Dispose();
 }
Ejemplo n.º 8
0
        private async Task initializeSharepoint(MicrosoftDynamicsCRMadoxioApplication adoxioApplication)
        {
            // create a SharePointDocumentLocation link
            string folderName = GetApplicationFolderName(adoxioApplication);
            string name       = adoxioApplication.AdoxioJobnumber + " Files";
            SharePointFileManager _sharePointFileManager = new SharePointFileManager(_configuration);
            // Create the folder
            bool folderExists = await _sharePointFileManager.FolderExists(ApplicationDocumentUrlTitle, folderName);

            if (!folderExists)
            {
                try
                {
                    await _sharePointFileManager.CreateFolder(ApplicationDocumentUrlTitle, folderName);
                }
                catch (SharePointRestException spre)
                {
                    _logger.LogError(spre, "Error creating Sharepoint Folder");
                    throw spre;
                }
                catch (Exception e)
                {
                    _logger.LogError(e, "Error creating Sharepoint Folder");
                    throw e;
                }
            }

            // Create the SharePointDocumentLocation entity
            MicrosoftDynamicsCRMsharepointdocumentlocation mdcsdl = new MicrosoftDynamicsCRMsharepointdocumentlocation()
            {
                Relativeurl = folderName,
                Description = "Application Files",
                Name        = name
            };


            try
            {
                mdcsdl = _dynamicsClient.Sharepointdocumentlocations.Create(mdcsdl);
            }
            catch (HttpOperationException httpOperationException)
            {
                string mdcsdlId = _dynamicsClient.GetCreatedRecord(httpOperationException, null);
                if (!string.IsNullOrEmpty(mdcsdlId))
                {
                    mdcsdl.Sharepointdocumentlocationid = mdcsdlId;
                }
                else
                {
                    _logger.LogError(httpOperationException, "Error creating SharepointDocumentLocation");
                    mdcsdl = null;
                }
            }
            if (mdcsdl != null)
            {
                // add a regardingobjectid.
                string applicationReference            = _dynamicsClient.GetEntityURI("adoxio_applications", adoxioApplication.AdoxioApplicationid);
                var    patchSharePointDocumentLocation = new MicrosoftDynamicsCRMsharepointdocumentlocation();
                patchSharePointDocumentLocation.RegardingobjectidAdoxioApplicationODataBind = applicationReference;
                // set the parent document library.
                string parentDocumentLibraryReference = GetDocumentLocationReferenceByRelativeURL("adoxio_application");
                patchSharePointDocumentLocation.ParentsiteorlocationSharepointdocumentlocationODataBind = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", parentDocumentLibraryReference);

                try
                {
                    _dynamicsClient.Sharepointdocumentlocations.Update(mdcsdl.Sharepointdocumentlocationid, patchSharePointDocumentLocation);
                }
                catch (HttpOperationException httpOperationException)
                {
                    _logger.LogError(httpOperationException, "Error adding reference SharepointDocumentLocation to application");
                }

                string sharePointLocationData = _dynamicsClient.GetEntityURI("sharepointdocumentlocations", mdcsdl.Sharepointdocumentlocationid);
                // update the sharePointLocationData.
                Odataid oDataId = new Odataid()
                {
                    OdataidProperty = sharePointLocationData
                };
                try
                {
                    _dynamicsClient.Applications.AddReference(adoxioApplication.AdoxioApplicationid, "adoxio_application_SharePointDocumentLocations", oDataId);
                }
                catch (HttpOperationException httpOperationException)
                {
                    _logger.LogError(httpOperationException, "Error adding reference to SharepointDocumentLocation");
                }
            }
        }
        public static string CreateDocumentLocation(this IDynamicsClient _dynamicsClient, MicrosoftDynamicsCRMsharepointdocumentlocation mdcsdl)
        {
            try
            {
                mdcsdl = _dynamicsClient.Sharepointdocumentlocations.Create(mdcsdl);
            }
            catch (HttpOperationException odee)
            {
                Log.Error(odee, "Error creating SharepointDocumentLocation");
                mdcsdl = null;
            }

            return(mdcsdl?.Sharepointdocumentlocationid);
        }
        public static string DocumentLocationExistsWithCleanup(this IDynamicsClient _dynamicsClient, MicrosoftDynamicsCRMsharepointdocumentlocation mdcsdl)
        {
            var relativeUrl = mdcsdl.Relativeurl.Replace("'", "''");
            var filter      = $"relativeurl eq '{relativeUrl}'";
            // start by getting the existing document locations.
            string result = null;

            try
            {
                var locations =
                    _dynamicsClient.Sharepointdocumentlocations.Get(filter: filter).Value.ToList();

                foreach (var location in locations)
                {
                    if (string.IsNullOrEmpty(location._regardingobjectidValue))
                    {
                        Log.Error($"Orphan Sharepointdocumentlocation found.  ID is {location.Sharepointdocumentlocationid}");
                        // it is an invalid document location. cleanup.
                        try
                        {
                            _dynamicsClient.Sharepointdocumentlocations.Delete(location.Sharepointdocumentlocationid);
                        }
                        catch (HttpOperationException odee)
                        {
                        }
                    }
                    else
                    {
                        if (result != null)
                        {
                            Log.Error($"Duplicate Sharepointdocumentlocation found.  ID is {location.Sharepointdocumentlocationid}");
                        }
                        else
                        {
                            result = location.Sharepointdocumentlocationid;
                        }
                    }
                }
            }
            catch (HttpOperationException odee)
            {
                Log.Error(odee, "Error getting SharepointDocumentLocations");
            }

            return(result);
        }