Exemplo n.º 1
0
        /// <summary>
        /// Synchronizes the specified system's details with the configured <c>Snipe.It</c>
        /// system.
        /// </summary>
        private void SyncHostNameDetails(string hostName)
        {
            // Single Device.
            SnipeItApi snipe =
                SnipeApiExtensions.CreateClient(
                    ConfigurationManager.AppSettings["Snipe:ApiAddress"],
                    ConfigurationManager.AppSettings["Snipe:ApiToken"]);

            if (!String.IsNullOrWhiteSpace(hostName))
            {
                Console.WriteLine($"Retrieving asset details for {hostName}");
                try
                {
                    var asset      = AssetDescriptor.Create(hostName);
                    var components = ComponentDescriptor.Create(hostName);
                    try
                    {
                        Console.WriteLine($"Synchronizing asset details for {hostName}");
                        // The current version of the SnipeSharp API has mapping issues causing the response not de serializing.
                        snipe.SyncAssetWithCompoments(asset, components);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Failed to sync asset details for {hostName}");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Failed to retrieve asset details for {hostName}");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Synchronizes the specified system's details with the configured <c>Snipe.It</c>
        /// system.
        /// </summary>
        private void SyncHostNameDetails(string hostName)
        {
            // Single Device.
            SnipeItApi snipe =
                SnipeApiExtensions.CreateClient(
                    snipeApiUrl,
                    snipeApiToken);

            if (!String.IsNullOrWhiteSpace(hostName))
            {
                Log.Information($"Retrieving asset details for {hostName}");
                try
                {
                    var asset      = AssetDescriptor.Create(hostName);
                    var components = ComponentDescriptor.Create(hostName);
                    try
                    {
                        Log.Information($"Synchronizing asset details for {hostName}");
                        // The current version of the SnipeSharp API has mapping issues causing the response not de serializing.
                        snipe.SyncAssetWithCompoments(asset, components);
                    }
                    catch (Exception ex)
                    {
                        Log.Error($"Failed to sync asset details for {hostName}");
                        Log.Error(ex.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Log.Error($"Failed to retrieve asset details for {hostName}");
                    Log.Error(ex.ToString());
                }
            }
        }