public void SetAzureServiceProjectTestsLocationValid()
        {
            string[] locations = { "West US", "East US", "East Asia", "North Europe" };
            foreach (string item in locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    mockCommandRuntime = new MockCommandRuntime();
                    setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                    settings.Save(paths.Settings);

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    Assert.AreEqual<string>(item, settings.Location);
                    ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                    Assert.AreEqual<string>(item, settings.Location);
                }
            }
        }
示例#2
0
        public void TestInitialValues()
        {
            var settings = new ServiceSettings();

            Assert.IsTrue(settings.ServiceUpdateCore);
            Assert.AreEqual(Defines.PackagesDefaultSourceRepositoryUri, settings.PackagesDefaultSourceRepositoryUri);
        }
        public void ServiceSettingsTest()
        {


            ServiceSettings settings = new ServiceSettings();
            AzureAssert.AreEqualServiceSettings(string.Empty, string.Empty, string.Empty, string.Empty, settings);
        }
示例#4
0
 public static void AreEqualServiceSettings(string location, string slot, string storageAccountName, string subscriptionName, ServiceSettings actual)
 {
     Assert.AreEqual<string>(location, actual.Location);
     Assert.AreEqual<string>(slot, actual.Slot);
     Assert.AreEqual<string>(storageAccountName, actual.StorageServiceName);
     Assert.AreEqual<string>(subscriptionName, actual.Subscription);
 }
        public void TwoParamConstructorSetsPropertiesRight(string serviceName, string displayName)
        {
            var sut = new ServiceSettings(serviceName, displayName);

            var expected = new ServiceSettingResult {ServiceName = serviceName, DisplayName = displayName};

            sut.AsSource().OfLikeness<ServiceSettingResult>().Equals(expected);
        }
 public void SettingsMapper_when_mapping_AutoRefreshAfter()
 {
     var clientSettings = new ServiceSettings
     {
         AutoRefreshAfter = TimeSpan.FromMinutes(new Random().Next(0, 1000))
     };
     var auth0Settings = clientSettings.ToAuth0ClientSettings();
     clientSettings.AutoRefreshAfter.Should().Be(auth0Settings.AutoRefreshAfter);
 }
 public void SettingsMapper_when_mapping_RefreshToken()
 {
     var clientSettings = new ServiceSettings
     {
         Auth0ClientId = "auth0ClientId",
         Auth0RefreshToken = "auth0RefreshToken"
     };
     var auth0Settings = clientSettings.ToAuth0ClientSettings();
     clientSettings.Auth0ClientId.Should().Be(auth0Settings.Auth0ClientId);
     clientSettings.Auth0RefreshToken.Should().Be(auth0Settings.Auth0RefreshToken);
 }
示例#8
0
        public void TestServiceSettingsOverridePackagesDefaultSourceRepositoryUri()
        {
            var settings = new ServiceSettings(new List<String>() {
                "-PackagesDefaultSourceRepositoryUri",
                "localhost"
            });

            Assert.IsTrue(settings.ServiceUpdateCore);
            Assert.AreEqual(Defines.DefaultServicePollingTimeout, settings.ServicePollingTimeout);
            Assert.AreEqual("localhost", settings.PackagesDefaultSourceRepositoryUri);
        }
示例#9
0
        public void TestServiceSettingsOverrideServiceUpdateCore()
        {
            var settings = new ServiceSettings(new List<String>() {
                "-ServiceUpdateCore",
                "false"
            });

            Assert.IsFalse(settings.ServiceUpdateCore);
            Assert.AreEqual(Defines.DefaultServicePollingTimeout, settings.ServicePollingTimeout);
            Assert.AreEqual(Defines.PackagesDefaultSourceRepositoryUri, settings.PackagesDefaultSourceRepositoryUri);
        }
 public void TestInitialize()
 {
     GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
     service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
     service.CreateVirtualCloudPackage();
     packagePath = service.Paths.CloudPackage;
     configPath = service.Paths.CloudConfiguration;
     settings = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
     WindowsAzureProfile.Instance = new WindowsAzureProfile(new Mock<IProfileStore>().Object);
     WindowsAzureProfile.Instance.ImportPublishSettings(Data.ValidPublishSettings.First());
 }
示例#11
0
        public static void AreEqualPublishContext(ServiceSettings settings, string configPath, string deploymentName, string label, string packagePath, string subscriptionId, PublishContext actual)
        {
            AreEqualServiceSettings(settings, actual.ServiceSettings);
            Assert.AreEqual<string>(configPath, actual.ConfigPath);
            Assert.AreEqual<string>(deploymentName, actual.DeploymentName);
            Assert.AreEqual<string>(label, actual.ServiceName);
            Assert.AreEqual<string>(packagePath, actual.PackagePath);
            Assert.AreEqual<string>(subscriptionId, actual.SubscriptionId);

            Assert.IsTrue(File.Exists(actual.ConfigPath));
            Assert.IsTrue(File.Exists(actual.PackagePath));
        }
示例#12
0
文件: Service.cs 项目: DM-TOR/nhin-d
        public Service()
        {   
            InitializeContainer();

            ILogger logger = Log.For(this);

            m_settings = new ServiceSettings();
            logger.Info("Starting Service");

            m_store = new ConfigStore(m_settings.StoreConnectString, m_settings.QueryTimeout);
            logger.Info("Service Started Successfully");
        }
示例#13
0
文件: Service.cs 项目: DM-TOR/nhin-d
        public Service()
        {   
            InitializeContainer();

            m_logger = Log.For(this);
            m_settings = new ServiceSettings();

            m_logger.Info("Starting Service");
            
            this.InitStore();
            
            m_logger.Info("Service Started Successfully");
        }
        public void SetAzureServiceProjectTestsLocationInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows<ArgumentException>(() => new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess("MyHome", null, null, null, paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Location"));
            }
        }
 public void SettingsMapper_when_mapping_UsernamePassword()
 {
     var clientSettings = new ServiceSettings
     {
         Auth0ClientId = "auth0ClientId",
         Auth0Password = "******",
         Auth0User = "******"
     };
     var auth0Settings = clientSettings.ToAuth0ClientSettings();
     clientSettings.Auth0ClientId.Should().Be(auth0Settings.Auth0ClientId);
     clientSettings.Auth0Password.Should().Be(auth0Settings.Auth0Password);
     clientSettings.Auth0User.Should().Be(auth0Settings.Auth0Username);
 }
        public void SetAzureServiceProjectTestsLocationEmptyFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows<ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(string.Empty, null, null, paths.Settings), string.Format(Resources.InvalidOrEmptyArgumentMessage, "Location"));
            }
        }
示例#17
0
        protected JResult DoSettingsTest(ServiceSettings s, OnResolveSettings resolveSettings, OnAssertSettingsValidateRun postAction, string[] cmd)
        {
            Func<string, ExecutionElement, ExecutionElement> resolve =
            (dir, e) =>
              {
            var ret = e.SClone();
            ret.Program = Path.Combine(dir, e.Program);
            ret.WorkDir = e.WorkDir == null ? dir : Path.Combine(dir, e.WorkDir);

            if (ret.Termination != null)
            {
              if (ret.Termination.Timeout == null) ret.Termination.Timeout = "2";
              if (ret.Termination.Execution != null)
              {
                var se = ret.Termination.Execution;
                se.Program = Path.Combine(dir, se.Program);
                se.WorkDir = se.WorkDir == null ? ret.WorkDir : Path.Combine(dir, se.WorkDir);
              }
            } else
            {
              ret.Termination = new TerminationElement
                                  {
                                    Timeout = "2"
                                  };
            }

            resolveSettings(dir, ret);
            return ret;
              };

              return TempFilesHolder.WithTempDirectory(
            dir =>
              {
            var ee = resolve(dir, s.Execution);
            if (!File.Exists(ee.Program))
            {
              File.WriteAllText(ee.Program, "mock");
            }

            if (ee.Termination != null && ee.Termination.Execution != null && !File.Exists(ee.Termination.Execution.Program))
            {
              File.WriteAllText(ee.Termination.Execution.Program, "smock");
            }

            var r = ExecuteWithSettings(s, dir, cmd);
            postAction(r, s, ee, dir);
            return r;
              });
        }
示例#18
0
        public SP3DDataLayer(AdapterSettings settings)
            : base(settings)
        {
            ServiceSettings servcieSettings = new ServiceSettings();
              _settings.AppendSettings(servcieSettings);

              if (settings["DataLayerPath"] != null)
            _dataPath = settings["DataLayerPath"];
              else
            _dataPath = settings["AppDataPath"];

              _scope = _settings["ProjectName"] + "." + _settings["ApplicationName"];
              _settings["BinaryPath"] = @".\Bin\";

              _configurationPath = string.Format("{0}Configuration.{1}.xml", _dataPath, _scope);
              projectNameSpace = "org.iringtools.adapter.datalayer.proj_" + _scope;
              //"org.iringtools.adapter.datalayer.proj_12345_000.ABC"

              _dictionaryPath = string.Format("{0}DataDictionary.{1}.xml", _dataPath, _scope);
        }
        private void InitializeData()
        {
            ServiceSettings settings;

            Data = new Dictionary<ServiceSettingsState, ServiceSettings>();
            Data.Add(ServiceSettingsState.Default, new ServiceSettings());
            
            settings = new ServiceSettings();
            settings.Location = "South Central US";
            settings.Slot = DeploymentSlotType.Production;
            settings.StorageServiceName = "mystore";
            settings.Subscription = "TestSubscription2";
            Data.Add(ServiceSettingsState.Sample1, settings);

            settings = new ServiceSettings();
            settings.Location = "South Central US";
            settings.Slot = DeploymentSlotType.Production;
            settings.StorageServiceName = "mystore";
            settings.Subscription = "Does not exist subscription";
            Data.Add(ServiceSettingsState.DoesNotExistSubscription, settings);
        }
        public void SetAzureServiceProjectTestsLocationValid()
        {
            foreach (KeyValuePair<Location, string> item in Microsoft.WindowsAzure.Management.CloudService.Model.ArgumentConstants.Locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);

                    new SetAzureServiceProjectCommand().SetAzureServiceProjectProcess(item.Value, null, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    settings = ServiceSettings.Load(paths.Settings);
                    Assert.AreEqual<string>(item.Value, settings.Location);
                }
            }
        }
        private void InitializeData()
        {
            ServiceSettings settings;

            Data = new Dictionary<ServiceSettingsState, ServiceSettings>();
            Data.Add(ServiceSettingsState.Default, new ServiceSettings());

            settings = new ServiceSettings();
            settings.Location = ArgumentConstants.Locations[Location.SouthCentralUS];
            settings.Slot = ArgumentConstants.Slots[Slot.Production];
            settings.StorageAccountName = "mystore";
            settings.Subscription = "TestSubscription2";
            Data.Add(ServiceSettingsState.Sample1, settings);

            settings = new ServiceSettings();
            settings.Location = ArgumentConstants.Locations[Location.SouthCentralUS];
            settings.Slot = ArgumentConstants.Slots[Slot.Production];
            settings.StorageAccountName = "mystore";
            settings.Subscription = "Does not exist subscription";
            Data.Add(ServiceSettingsState.DoesNotExistSubscription, settings);
        }
        public void SetAzureServiceProjectTestsSubscriptionValid()
        {
            foreach (string item in Data.ValidSubscriptionName)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    settings.Save(paths.Settings);
                    setServiceProjectCmdlet.PassThru = false;

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, null, null, item, paths.Settings);

                    // Assert subscription is changed
                    //
                    Assert.AreEqual<string>(item, settings.Subscription);
                    Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count);
                }
            }
        }
        public void SetAzureServiceProjectTestsLocationValid()
        {
            foreach (KeyValuePair<LocationName, string> item in ArgumentConstants.Locations)
            {
                using (FileSystemHelper files = new FileSystemHelper(this))
                {
                    // Create new empty settings file
                    //
                    ServicePathInfo paths = new ServicePathInfo(files.RootPath);
                    ServiceSettings settings = new ServiceSettings();
                    mockCommandRuntime = new MockCommandRuntime();
                    setServiceProjectCmdlet.CommandRuntime = mockCommandRuntime;
                    settings.Save(paths.Settings);

                    settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(item.Value, null, null, null, paths.Settings);

                    // Assert location is changed
                    //
                    Assert.AreEqual<string>(item.Value, settings.Location);
                    ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                    Assert.AreEqual<string>(item.Value, settings.Location);
                }
            }
        }
 public DoctorController(IOptions <ServiceSettings> serviceSettings)
 {
     _serviceSettings = serviceSettings.Value;
 }
示例#25
0
 public FeedbackController(IOptions <ServiceSettings> serviceSettings)
 {
     _serviceSettings = serviceSettings.Value;
 }
示例#26
0
 public RequestPerformanceBehaviour(IOptions <ServiceSettings> serviceSettingsAccesor, ILogger <TRequest> logger)
 {
     _logger          = logger;
     _serviceSettings = serviceSettingsAccesor.Value;
 }
 public ControllerBase(string entityName, Func <dynamic, object> selectListItemFunc)
 {
     _repository         = new RestServiceClient(ServiceSettings.GetRestEndpointForEntity(entityName));;
     _selectListItemFunc = selectListItemFunc;
 }
示例#28
0
        private void InitializeScheduler()
        {
            _cronObjectList  = new List <CronObject>();
            _serviceSettings = new ServiceSettings("");
            _serviceLogger   = new Logging.TaskLogging();
            if (!_serviceSettings.EnableScheduler)
            {
                _serviceLogger.CreateLogRecord("Shceduller start forbidden by ServiceSettings.enableScheduler");
                return;
            }

            foreach (var type in Tasks.TasksEnumerator.GetTaskEnumertor())
            {
                var task = Activator.CreateInstance(type) as TaskBase;
                foreach (var group in new SettingsGroupsCollection(task.TaskSettings))
                {
                    if (!(bool)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameEnable(task, group)))
                    {
                        continue;
                    }
                    try
                    {
                        _cronObjectList.Add(CreateCronObject(type, group, (string)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameShedule(task, group))));
                    }
                    catch (Exception e)
                    {
                        _serviceLogger.CreateLogRecord(e);
                    }
                }
            }
        }
示例#29
0
文件: SqlQuery.cs 项目: TNOCS/csTouch
 public override XElement ToXml(ServiceSettings settings)
 {
     return new XElement("SqlQuery",
         new XAttribute("name", Name),
         new XAttribute("layer", Layer),
         new XAttribute("isEnabled", IsEnabled),
         new XAttribute("updateType", UpdateType),
         new XAttribute("poiTypeId", PoiTypeId), // TODO featureTypeId?
         new XAttribute("connection", ConnectionString),
         new XAttribute("id", Id),
         new XElement("Query", Query),
         Options == null ? null :
         new XElement("Options",
             new XAttribute("controlInputParameterIndex", Options.ControlInputParameterIndex),
             new XAttribute("desiredResultFormula", Options.DesiredResultFormula),
             new XAttribute("desiredResultLabel", Options.DesiredResultLabel),
             new XAttribute("desiredAccuracyInputParameterIndex", Options.DesiredAccuracyInputParameterIndex),
             new XAttribute("maxTriesInputParameterIndex", Options.MaxTriesInputParameterIndex),
             new XAttribute("actualResultOutputParameterIndex", Options.ActualResultOutputParameterIndex),
             new XAttribute("relationship", Options.Relationship)),
         new XElement("Inputs", from input in InputParameters
                                select new XElement("Input",
                                    new XAttribute("type", input.Type),
                                    string.IsNullOrEmpty(input.LabelName) ? null : new XAttribute("labelName", input.LabelName))),
         new XElement("Outputs", from output in OutputParameters
                                 select new XElement("Output",
                                     new XAttribute("name", output.Name),
                                     new XAttribute("type", output.OutputType)
                                     ))
             );
 }
示例#30
0
 public static void AreEqualServiceSettings(ServiceSettings expected, ServiceSettings actual)
 {
     AreEqualServiceSettings(expected.Location, expected.Slot, expected.StorageServiceName, expected.Subscription, actual);
 }
示例#31
0
 public EventSourcingController(IOptions <ServiceSettings> serviceSettings)
 {
     _serviceSettings = serviceSettings.Value;
 }
示例#32
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            #region Mongodb serializers
            BsonSerializer.RegisterSerializer(new GuidSerializer(BsonType.String));
            BsonSerializer.RegisterSerializer(new DateTimeOffsetSerializer(BsonType.String));
            #endregion

            // Deserealization config file into memory object.
            _serviceSettings = Configuration.GetSection(nameof(ServiceSettings)).Get <ServiceSettings>();

            // Register type or object and make sure that only one instance is available
            services.AddSingleton(serviceProvider =>
            {
                var mongoDbSettings = Configuration.GetSection(nameof(MongoDbSettings)).Get <MongoDbSettings>();
                var mongoClient     = new MongoClient(mongoDbSettings.ConnectionString);

                return(mongoClient.GetDatabase(_serviceSettings.ServiceName));
            });


            services.AddControllers(options => {
                options.SuppressAsyncSuffixInActionNames = false;
            });

            #region RabbitMQ (MassTransit)
            services.AddMassTransitWithRabbitMq(_serviceSettings.ServiceName);
            #endregion

            #region Data contexts
            services.AddScoped <IMongoContext <GameItem> >(x => new MongoContext <GameItem>(_serviceSettings.ServiceName, x.GetService <IMongoDatabase>(), new List <GameItem>
            {
                new GameItem
                {
                    Id          = Guid.NewGuid(),
                    Name        = "Potion",
                    Description = "Restores a small amount of  HP",
                    Price       = 5,
                    CreatedDate = DateTimeOffset.UtcNow
                },
                new GameItem
                {
                    Id          = Guid.NewGuid(),
                    Name        = "Antidote",
                    Description = "Cures poison",
                    Price       = 7,
                    CreatedDate = DateTimeOffset.UtcNow
                },
                new GameItem
                {
                    Id          = Guid.NewGuid(),
                    Name        = "Bronze sword",
                    Description = "Deals a small amout of damage",
                    Price       = 20,
                    CreatedDate = DateTimeOffset.UtcNow
                },
            }));
            #endregion

            #region Data repositories
            services.AddScoped <IMongoRepository <GameItem>, MongoRepository <GameItem> >();
            #endregion


            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "GameCatalog.API", Version = "v1"
                });
            });
        }
        public void TestInitialize()
        {
            Management.Extensions.CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();

            serviceName = Path.GetRandomFileName();
            GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
            service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
            service.CreateVirtualCloudPackage();
            packagePath = service.Paths.CloudPackage;
            configPath = service.Paths.CloudConfiguration;
            settings = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
            mockCommandRuntime = new MockCommandRuntime();
            importCmdlet = new ImportAzurePublishSettingsCommand();
            importCmdlet.CommandRuntime = mockCommandRuntime;
            importCmdlet.ImportSubscriptionFile(Data.ValidPublishSettings.First(), null);
        }
示例#34
0
 private void Cron_OnCronTrigger(CronObject cronObject)
 {
     if (cronObject == null)
     {
         return;
     }
     // ReSharper disable once AssignNullToNotNullAttribute
     try
     {
         var cronObjectHelper = (CronObjectHelper)cronObject.Object;
         var task             = Activator.CreateInstance(cronObjectHelper.TaskType) as TaskBase;
         task?.ExecuteTask(cronObjectHelper.GroupName,
                           (bool)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameReport(task, cronObjectHelper.GroupName)),
                           (int)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameSendReportInterval(task, cronObjectHelper.GroupName)) * 60,
                           (System.Diagnostics.EventLogEntryType)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameReportInformationLevel(task, cronObjectHelper.GroupName)),
                           (uint)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameMaxErrorCount(task, cronObjectHelper.GroupName)));
     }
     catch (Exception e) { _serviceLogger.CreateLogRecord(e); }
 }
        public void SetAzureServiceProjectTestsSlotTestsInvalidFail()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);

                Testing.AssertThrows<ArgumentException>(() => setServiceProjectCmdlet.SetAzureServiceProjectProcess(null, "MyHome", null, paths.Settings), string.Format(Resources.InvalidServiceSettingElement, "Slot"));
            }
        }
示例#36
0
        public static void OpenTunnelPingListener()
        {
            if (TunnelValidatorRunning)
            {
                CloseTunnelPingListener();
            }

            ServiceSettings serviceSettings = SettingsHelper.GetSettings();

            if (TunnelHelper.CurrentTunnelStatus == TunnelStatuses.Started && serviceSettings.EnableTunnelValidation)
            {
                TunnelPingHelper.TunnelValidatorLastPingSuccessful = false;

                _validationListener = new TcpListener(IPAddress.Any, serviceSettings.TunnelValidationRemotePort);

                Task.Factory.StartNew(() =>
                {
                    TunnelPingHelper.TunnelValidatorRunning = true;

                    _validationListener.Start();

                    try
                    {
                        while (true)
                        {
                            TcpClient tcpClient;

                            try
                            {
                                tcpClient = _validationListener.AcceptTcpClient();
                            }
                            catch (SocketException ex)
                            {
                                if (ex.SocketErrorCode == SocketError.Interrupted)
                                {
                                    TunnelPingHelper.TunnelValidatorRunning = false;
                                    break;
                                }
                                else
                                {
                                    throw;
                                }
                            }

                            Task.Factory.StartNew(() =>
                            {
                                try
                                {
                                    NetworkStream clientStream = tcpClient.GetStream();
                                    byte[] message             = new byte[32];
                                    string validationString    = "";

                                    while (true)
                                    {
                                        int bytesRead = clientStream.Read(message, 0, 32);

                                        if (bytesRead == 0)
                                        {
                                            break;
                                        }

                                        ASCIIEncoding encoding = new ASCIIEncoding();
                                        string str             = encoding.GetString(message, 0, bytesRead);

                                        validationString += str;

                                        if (validationString == "-111-")
                                        {
                                            const string sendString = "-222-";
                                            byte[] sendData         = Encoding.ASCII.GetBytes(sendString);
                                            clientStream.Write(sendData, 0, sendData.Length);

                                            break;
                                        }
                                        else if (validationString.Length > 5)
                                        {
                                            break;
                                        }
                                    }

                                    tcpClient.Close();
                                }
                                catch (Exception ex)
                                {
                                    WcfServerHelper.BroadcastRemoteCallback((x) => x.EventToLog("Tunnel Validation Exception (1): " + ex.Message + " ::: " + ex.StackTrace, DateTime.Now));
                                    HandleFailedTunnelPing();
                                }
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        WcfServerHelper.BroadcastRemoteCallback((x) => x.EventToLog("Tunnel Validation Exception (2): " + ex.Message + " ::: " + ex.StackTrace, DateTime.Now));
                        HandleFailedTunnelPing();
                    }
                }, TaskCreationOptions.LongRunning);

                _pingTunnelTimer           = new System.Timers.Timer();
                _pingTunnelTimer.Interval  = serviceSettings.TunnelValidationPingInterval * 1000;
                _pingTunnelTimer.AutoReset = true;
                _pingTunnelTimer.Elapsed  += _pingTunnelTimer_Elapsed;

                Thread.Sleep(1200);
                SendTunnelPing();

                _pingTunnelTimer.Start();
            }
        }
        public async static Task <SaveImageThumbnailResult> SaveImageThumbnail(idCatalogItem catalogItem, IDImagerDB db, IDImagerThumbsDB dbThumbs,
                                                                               List <string> types, ServiceSettings serviceSettings)
        {
            SaveImageThumbnailResult result = new SaveImageThumbnailResult();
            Stream imageStream = null;
            String filePath    = null;

            try
            {
                filePath    = GetImageFilePath(catalogItem, serviceSettings.FilePathReplace);
                imageStream = GetImageFileStream(filePath);

                foreach (String type in types)
                {
                    int imageWidth;
                    int imageHeight;

                    if (type.Equals("T"))
                    {
                        imageWidth  = 160;
                        imageHeight = 120;
                    }
                    else
                    {
                        imageWidth  = serviceSettings.MThumbmailWidth;
                        imageHeight = serviceSettings.MThumbnailHeight;
                    }

                    XmpRecipeContainer xmpRecipeContainer = null;
                    if (type.Equals("T") || type.Equals("R"))
                    {
                        if (catalogItem.idHasRecipe > 0)
                        {
                            XDocument recipeXDocument = await GetRecipeXDocument(db, catalogItem);

                            xmpRecipeContainer = XmpRecipeHelper.ParseXmlRecepie(recipeXDocument);
                        }
                    }

                    MemoryStream       resizedImageStream = new MemoryStream();
                    MagickReadSettings magickReadSettings = null;

                    if (Enum.TryParse <MagickFormat>(catalogItem.idFileType, true, out MagickFormat magickFormat))
                    {
                        magickReadSettings = new MagickReadSettings {
                            Format = magickFormat
                        };
                    }

                    imageStream.Position = 0;

                    MagickImage image = new MagickImage(imageStream, magickReadSettings)
                    {
                        Format = MagickFormat.Jpeg,
                    };

                    image.Resize(imageWidth, imageHeight);

                    if (xmpRecipeContainer != null)
                    {
                        XmpRecipeHelper.ApplyXmpRecipe(xmpRecipeContainer, image);
                    }

                    image.Write(resizedImageStream);
                    resizedImageStream.Position = 0;

                    bool boolThumbExists = await dbThumbs.idThumbs
                                           .AnyAsync(x => x.ImageGUID == catalogItem.GUID && x.idType == type);

                    if (!boolThumbExists)
                    {
                        idThumbs newThumb = new idThumbs
                        {
                            GUID      = Guid.NewGuid().ToString().ToUpper(),
                            ImageGUID = catalogItem.GUID,
                            idThumb   = StreamToByteArray(resizedImageStream),
                            idType    = type
                        };

                        dbThumbs.idThumbs.Add(newThumb);
                    }

                    result.ImageStreams.Add(resizedImageStream);
                }

                if (imageStream != null)
                {
                    imageStream.Close();
                }
                await dbThumbs.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                if (imageStream != null)
                {
                    imageStream.Close();
                }
                result.Exceptions.Add(new Exception(String.Format("Error generating thumbnail for imageGUID {0} file {1}", catalogItem.GUID, filePath), ex));
            }

            return(result);
        }
示例#38
0
        public void ServiceSettingsTest()
        {
            ServiceSettings settings = new ServiceSettings();

            AzureAssert.AreEqualServiceSettings(string.Empty, string.Empty, string.Empty, string.Empty, settings);
        }
示例#39
0
 public TextToSpeechService(ServiceSettings serviceSettings)
 {
     this._serviceSettings = serviceSettings;
 }
 public NotificationService(HttpClient client, IOptions <ServiceSettings> serviceOptions)
 {
     _serviceSettings    = serviceOptions?.Value ?? throw new ArgumentNullException(nameof(serviceOptions));
     _client             = client ?? throw new ArgumentNullException(nameof(client));
     _client.BaseAddress = new Uri(_serviceSettings.NotificationService);
 }
示例#41
0
        public static void AzureServiceExists(string serviceRootPath, string scaffoldFilePath, string serviceName, ServiceSettings settings = null, WebRoleInfo[] webRoles = null, WorkerRoleInfo[] workerRoles = null, string webScaff = null, string workerScaff = null, RoleInfo[] roles = null)
        {
            ServiceComponents components = new ServiceComponents(new ServicePathInfo(serviceRootPath));

            ScaffoldingExists(serviceRootPath, scaffoldFilePath);

            if (webRoles != null)
            {
                for (int i = 0; i < webRoles.Length; i++)
                {
                    ScaffoldingExists(Path.Combine(serviceRootPath, webRoles[i].Name), webScaff);
                }
            }

            if (workerRoles != null)
            {
                for (int i = 0; i < workerRoles.Length; i++)
                {
                    ScaffoldingExists(Path.Combine(serviceRootPath, workerRoles[i].Name), workerScaff);
                }
            }

            AreEqualServiceConfiguration(components.LocalConfig, serviceName, roles);
            AreEqualServiceConfiguration(components.CloudConfig, serviceName, roles);
            IsValidServiceDefinition(components.Definition, serviceName, webRoles, workerRoles);
            AreEqualServiceSettings(settings ?? new ServiceSettings(), components.Settings);
        }
示例#42
0
 public SpreadsheetService()
 {
     _client = ServiceSettings.ServiceStartSettings();
 }
示例#43
0
 public UserService(HttpClient client, IOptions <ServiceSettings> serviceSettingsOptions)
 {
     _serviceSettings    = serviceSettingsOptions.Value;
     _client             = client;
     _client.BaseAddress = new Uri(_serviceSettings.UserService);
 }
示例#44
0
 public FileHandler(ServiceSettings serviceSettings)
 {
     _serviceSettings = serviceSettings;
 }
示例#45
0
 protected override void AssertServiceParameters(ServiceSettings s, JResult r, ExecutionElement ee)
 {
 }
        public void SetAzureServiceProjectTestsUnknownLocation()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                // Create new empty settings file
                //
                PowerShellProjectPathInfo paths = new PowerShellProjectPathInfo(files.RootPath);
                ServiceSettings settings = new ServiceSettings();
                settings.Save(paths.Settings);
                string unknownLocation = "Unknown Location";

                settings = setServiceProjectCmdlet.SetAzureServiceProjectProcess(unknownLocation, null, null, paths.Settings);

                // Assert location is changed
                //
                Assert.AreEqual<string>(unknownLocation, settings.Location);
                ServiceSettings actualOutput = mockCommandRuntime.OutputPipeline[0] as ServiceSettings;
                Assert.AreEqual<string>(unknownLocation, settings.Location);
            }
        }
示例#47
0
 private void StartShceduler()
 {
     System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
     _serviceSettings = new ServiceSettings("");
     _cronObjectList.ForEach(x => x.Start());
 }
示例#48
0
 public UserService(EntityContext repository, HttpClient httpClient, IOptions <ServiceSettings> options)
 {
     _repository = repository;
     _httpClient = httpClient;
     _settings   = options.Value;
 }