Example #1
0
        public byte[] UpdateMsis(bool is64bit)
        {
            var expectedClient = new ServiceVersion().Get(1).LatestClientVersion;

            if (string.IsNullOrEmpty(expectedClient))
            {
                Logger.Error("Cannot Create MSI.  Unknown Expected Toec Version");
                return(null);
            }


            var type              = is64bit ? "-x64.msi" : "-x86.msi";
            var basePath          = Path.Combine(HttpContext.Current.Server.MapPath("~"), "private", "agent");
            var stockFileFullPath = Path.Combine(basePath, $"Toec-{expectedClient}{type}");

            if (!File.Exists(stockFileFullPath))
            {
                Logger.Debug("Cannot Create MSI.  Could Not Locate Stock MSI");
                return(null);
            }

            var ca = new ServiceCertificate().GetCAPublic();

            if (ca == null)
            {
                Logger.Debug("Cannot Create MSI.  Certificate Chain Must First Be Created. ");
                return(null);
            }

            var newVersion         = expectedClient.Split('.');
            var v                  = string.Join(".", newVersion.Take(newVersion.Length - 1));
            var outputFileName     = $"Toec-{v}{type}";
            var outputFileFullPath = Path.Combine(basePath, outputFileName);

            try
            {
                File.Delete(outputFileFullPath);
            }
            catch { //ignored
            }

            try
            {
                File.Copy(stockFileFullPath, outputFileFullPath);
            }
            catch (Exception ex)
            {
                Logger.Error("Could Not Create MSI.");
                Logger.Error(ex.Message);
                return(null);
            }

            Stream   stream     = new MemoryStream(ca);
            Database database   = null;
            View     serverKey  = null;
            View     thumbprint = null;
            View     comServers = null;
            View     cert       = null;
            Record   rec        = null;

            GetMsiArgs();
            using (database = new Database(outputFileFullPath, DatabaseOpenMode.Transact))
            {
                try
                {
                    serverKey = database.OpenView(String.Format("INSERT INTO Property (Property, Value) VALUES ('{0}', '{1}')", "SERVER_KEY", _serverKey));
                    serverKey.Execute();
                    serverKey.Close();

                    comServers = database.OpenView(String.Format("INSERT INTO Property (Property, Value) VALUES ('{0}', '{1}')", "COM_SERVERS", _comServers));
                    comServers.Execute();
                    comServers.Close();

                    thumbprint = database.OpenView(String.Format("INSERT INTO Property (Property, Value) VALUES ('{0}', '{1}')", "CA_THUMBPRINT", _thumbprint));
                    thumbprint.Execute();
                    thumbprint.Close();

                    cert = database.OpenView("UPDATE `Binary` SET `Data` = ? WHERE `Name` = 'ToemsCA.Binary'");
                    rec  = new Record(1);
                    rec.SetStream(1, stream);
                    cert.Execute(rec);
                    cert.Close();

                    database.Commit();
                }
                catch (Exception ex)
                {
                    Logger.Error("Could Not Create Msi.");
                    Logger.Error(ex.Message);
                    return(null);
                }
                finally
                {
                    if (rec != null)
                    {
                        rec.Close();
                    }
                    if (serverKey != null)
                    {
                        serverKey.Close();
                    }
                    if (thumbprint != null)
                    {
                        thumbprint.Close();
                    }
                    if (comServers != null)
                    {
                        comServers.Close();
                    }
                    if (cert != null)
                    {
                        cert.Close();
                    }
                    if (database != null)
                    {
                        database.Close();
                    }
                }
            }

            var file = File.ReadAllBytes(outputFileFullPath);

            return(file);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventGridPublisherClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public EventGridPublisherClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TextAnalyticsClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public TextAnalyticsClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version;
     this.ConfigureLogging();
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SecretClientOptions"/> class.
        /// class.
        /// </summary>
        /// <param name="version">
        /// The <see cref="ServiceVersion"/> of the service API used when
        /// making requests.
        /// </param>
        public SecretClientOptions(ServiceVersion version = ServiceVersion.V7_0)
        {
            Version = version;

            this.ConfigureLogging();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public KeyClientOptions(ServiceVersion version = ServiceVersion.V7_0)
 {
     Version = version;
 }
            protected override async Task <IExecutionResponse> OnExecute(IExecutionContext context, ServiceVersionCreationRequest request)
            {
                var dbContext     = context.DbContext();
                var versionString = request.ServiceVersion.ToFullString();

                var service = await dbContext.Services
                              .FirstOrDefaultAsync(s => s.ServiceId == request.ServiceId,
                                                   context.CancellationToken)
                              .ConfigureAwait(false);

                var timeProvider = context.Services.GetRequiredService <ITimeProvider>();

                if (service == null)
                {
                    return(NotFound());
                }

                // Check if we already have the same version:
                var existingVersion =
                    await dbContext.ServiceVersions.
                    Where(s => s.Version == versionString && s.ServiceId == service.Id)
                    .FirstOrDefaultAsync(context.CancellationToken).ConfigureAwait(false);

                if (existingVersion != null)
                {
                    return(Conflict());
                }

                var newVersion = new ServiceVersion()
                {
                    CacheTime          = request.Input.CacheTime,
                    CreatedAt          = timeProvider.UtcNow,
                    StatusAggregation  = request.Input.StatusAggregation.ToEntity <StatusAggregationConfiguration>(),
                    StatusCheck        = request.Input.StatusCheck.ToEntity <StatusCheckConfiguration>(),
                    InstanceRetirement = request.Input.InstanceRetirement.ToEntity <InstanceRetirementConfiguration>(),
                    InstanceRouting    = request.Input.InstanceRouting.ToEntity <InstanceRoutingConfiguration>(),
                    Notification       = request.Input.Notification.ToEntity <NotificationConfiguration>(),
                    Orchestration      = request.Input.Orchestration.ToEntity <OrchestrationConfiguration>(),
                    ServiceId          = service.Id,
                    Service            = service,
                    Version            = versionString,
                    VersionOrder       = -1,
                };

                var newDependencies = request.Input.Dependencies.Select(d => new ServiceDependency()
                {
                    ServiceId          = service.ServiceId,
                    ServiceVersion     = newVersion,
                    VersionRequirement = d.VersionRequirement.ToNormalizedString()
                }).ToList();

                var newEndpoints = request.Input.Endpoints.Select(e => new ServiceEndpoint()
                {
                    ServiceVersion = newVersion,
                    Port           = WellKnownProtocols.ResolveProtocolPort(e.Protocol, e.Port),
                    Protocol       = WellKnownProtocols.ResolveProtocolId(e.Port, e.Protocol)
                }).ToList();

                newVersion.ServiceDependencies = newDependencies;
                newVersion.ServiceEndpoints    = newEndpoints;

                dbContext.ServiceVersions.Add(newVersion);

                await dbContext.SaveChangesAsync(context.CancellationToken).ConfigureAwait(false);

                await ApplyOrdering(dbContext, service.Id, context.CancellationToken).ConfigureAwait(false);

                return(Created(new
                {
                    serviceId = request.ServiceId,
                    serviceVersion = request.ServiceVersion
                }, model: newVersion.ToOutput()));
            }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KeyVaultAccessControlClientOptions"/> class.
        /// class.
        /// </summary>
        /// <param name="version">
        /// The <see cref="ServiceVersion"/> of the service API used when
        /// making requests.
        /// </param>
        public KeyVaultAccessControlClientOptions(ServiceVersion version = LatestVersion)
        {
            Version = version;

            this.ConfigureLogging();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="IotHubServiceClientOptions"/>
 /// class.
 /// </summary>
 public IotHubServiceClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public CryptographyClientOptions(ServiceVersion version = ServiceVersion.V7_0)
 {
     Version = version;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TimeSeriesInsightsClientOptions"/>.
 /// </summary>
 public TimeSeriesInsightsClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version;
 }
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModelsRepositoryClientOptions"/> class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public ModelsRepositoryClientOptions(
     ServiceVersion version = LatestVersion)
 {
     Version = version;
 }
Example #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceBusManagementClientOptions"/> class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public ServiceBusManagementClientOptions(ServiceVersion version = ServiceVersion.V2017_04)
 {
     Version = version;
 }
Example #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MetricsQueryClientOptions"/> class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public MetricsQueryClientOptions(ServiceVersion version = LatestVersion)
 {
     _version = version;
 }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public ConfigurationClientOptions(ServiceVersion version = LatestVersion)
 {
     this.Version = version;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CertificateClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public CertificateClientOptions(ServiceVersion version = ServiceVersion.V7_0)
 {
     Version = version;
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public QueueClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version;
     this.Initialize();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ServiceBusAdministrationClientOptions"/> class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public ServiceBusAdministrationClientOptions(ServiceVersion version = ServiceVersion.V2017_04)
 {
     Version = version;
 }
 /// <summary>
 /// </summary>
 /// <param name="version"></param>
 public FormRecognizerClientOptions(ServiceVersion version = LatestVersion)
 {
     _version = version;
 }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// An optional <see cref="ServiceVersion"/> to specify the version of
 /// the REST API to use.  For more, see
 /// <see href="https://docs.microsoft.com/azure/search/search-api-versions" />.
 ///
 /// If not provided, the <paramref name="version"/> will default to the
 /// latest supported by this client library.  It is recommended that
 /// application authors allow the version to float to the latest and
 /// library authors pin to a specific version.
 /// </param>
 /// <exception cref="ArgumentOutOfRangeException">
 /// Thrown when the <paramref name="version"/> is not supported by this
 /// client library.
 /// </exception>
 public SearchClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version.Validate();
     AddLoggingHeaders();
     AddLoggingQueryParameters();
 }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShareClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public ShareClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version == ServiceVersion.V2019_02_02 ? version : throw Errors.VersionNotSupported(nameof(version));
     this.Initialize();
     AddHeadersAndQueryParameters();
 }
Example #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public ConfigurationClientOptions(ServiceVersion version = ServiceVersion.Default)
 {
     Version = version;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public BlobClientOptions(ServiceVersion version = LatestVersion)
 {
     this.Version = version;
     this.Initialize();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueClientOptions"/>
 /// class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="QueueClientOptions.ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public SpecializedQueueClientOptions(ServiceVersion version = LatestVersion) : base(version)
 {
 }
Example #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CertificateClientOptions"/>
        /// class.
        /// </summary>
        /// <param name="version">
        /// The <see cref="ServiceVersion"/> of the service API used when
        /// making requests.
        /// </param>
        public CertificateClientOptions(ServiceVersion version = LatestVersion)
        {
            Version = version;

            this.ConfigureLogging();
        }
Example #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LogsQueryClientOptions"/> class.
        /// </summary>
        /// <param name="version">
        /// The <see cref="ServiceVersion"/> of the service API used when
        /// making requests.
        /// </param>
        public LogsQueryClientOptions(ServiceVersion version = LatestVersion)
        {
            _version = version;

            Diagnostics.LoggedHeaderNames.Add(HttpHeader.Names.Prefer);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CryptographyClientOptions"/> class.
        /// class.
        /// </summary>
        /// <param name="version">
        /// The <see cref="ServiceVersion"/> of the service API used when
        /// making requests.
        /// </param>
        public CryptographyClientOptions(ServiceVersion version = LatestVersion)
        {
            Version = version;

            this.ConfigureLogging();
        }
 public TestClientOptionsMultipleParameters(string otherParameter = "some default value", ServiceVersion version = ServiceVersion.D)
 {
     OtherParameter = otherParameter;
     Version        = version;
 }
Example #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LogsClientOptions"/> class.
 /// </summary>
 /// <param name="version">
 /// The <see cref="ServiceVersion"/> of the service API used when
 /// making requests.
 /// </param>
 public LogsClientOptions(ServiceVersion version = LatestVersion)
 {
     _version = version;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FormRecognizerClientOptions"/> class.
 /// </summary>
 /// <param name="version">The version of the service to send requests to.</param>
 public FormRecognizerClientOptions(ServiceVersion version = LatestVersion)
 {
     Version = version;
     AddLoggedHeadersAndQueryParameters();
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SecretClientOptions"/> class.
        /// class.
        /// </summary>
        /// <param name="version">
        /// The <see cref="ServiceVersion"/> of the service API used when
        /// making requests.
        /// </param>
        public SecretClientOptions(ServiceVersion version = LatestVersion)
        {
            Version = version;

            this.ConfigureLogging();
        }