protected AtLeastOnceDeliveryReceiveActor(PersistenceSettings.AtLeastOnceDeliverySettings settings)
            : base()
        {
            _atLeastOnceDeliverySemantic = new AtLeastOnceDeliverySemantic(Context, settings);
            _atLeastOnceDeliverySemantic.Init();

        }
示例#2
0
        public void ManualResumptionActivity_Execute_SuspensionID_IsNullOrWhiteSpace_FailWithMessage()
        {
            //------------Setup for test--------------------------
            var workflowName       = "workflowName";
            var url                = "http://localhost:3142/secure/WorkflowResume";
            var resourceId         = Guid.NewGuid();
            var nextNodeId         = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env                = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = workflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            var manualResumptionActivity = new ManualResumptionActivity(config, new Mock <IPersistenceExecution>().Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = false,
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, dataObject.Environment.AllErrors.Count);
            var errors = dataObject.Environment.AllErrors.ToList();

            Assert.AreEqual("Failed", manualResumptionActivity.Response);
            Assert.AreEqual(errors[0], "<InnerError>SuspensionID must not be null or empty.</InnerError>");
        }
        public void PersistenceSettings_Get_Settings()
        {
            const string expectedDashboardHostname = @"http://localhost";
            const string expectedDashboardPort     = @"5001";
            const string expectedDashboardName     = @"HangfireDashboard";

            //arrange
            var mockIFile = new Mock <IFile>();

            mockIFile.Setup(o => o.Exists(It.IsAny <string>())).Returns(false);
            var mockDirectory = new Mock <IDirectory>();

            var hangfireSettings = new PersistenceSettings("some path", mockIFile.Object, mockDirectory.Object);

            hangfireSettings.PersistenceScheduler = "Hangfire";
            hangfireSettings.Enable                   = true;
            hangfireSettings.EncryptDataSource        = false;
            hangfireSettings.PrepareSchemaIfNecessary = true;
            hangfireSettings.ServerName               = "LocalServer";
            hangfireSettings.DashboardHostname        = expectedDashboardHostname;
            hangfireSettings.DashboardPort            = expectedDashboardPort;
            hangfireSettings.DashboardName            = expectedDashboardName;
            hangfireSettings.PersistenceDataSource    = new NamedGuidWithEncryptedPayload();
            var result = hangfireSettings.Get();

            Assert.IsNotNull(result);
            Assert.AreEqual(expectedDashboardHostname, result.DashboardHostname);
            Assert.AreEqual(expectedDashboardName, result.DashboardName);
            Assert.AreEqual(expectedDashboardPort, result.DashboardPort);
            Assert.AreEqual("Hangfire", result.PersistenceScheduler);
            Assert.AreEqual(new NamedGuidWithEncryptedPayload(), hangfireSettings.PersistenceDataSource);
            Assert.AreEqual(false, result.EncryptDataSource);
            Assert.AreEqual(true, result.PrepareSchemaIfNecessary);
            Assert.AreEqual(true, result.Enable);
        }
示例#4
0
 public Implementation(IHangfireContext hangfireContext, ConfigImpl configImpl, PersistenceSettings persistenceSettings, IBuilderSerializer deserializer, IEventWaitHandle waitHandle)
     : this(hangfireContext, configImpl)
 {
     _persistence             = persistenceSettings;
     _deserializer            = deserializer;
     _eventWaitHandlerFactory = waitHandle;
 }
示例#5
0
 private void InitializeVariables()
 {
     m_jsonEncrypter = new JsonEncryption();
     m_dataStoreHash = new Dictionary <string, DataStore>();
     m_settings      = PersistenceSettings.GetPersistenceSettings();
     m_prefabManager = new PrefabManager(m_settings);
 }
        private void Awake()
        {
            var settings = PersistenceSettings.GetPersistenceSettings();

            m_persistenceSettings = settings;
            serializedObject      = new SerializedObject(settings);
        }
示例#7
0
 public ApplicationSettings()
 {
     Hosting           = new HostingSettings();
     ServiceBus        = new ServiceBusSettings();
     InteropServiceBus = new ServiceBusSettings();
     Logging           = new LoggingSettings();
     Persistence       = new PersistenceSettings();
 }
        public PluginInfo Initialise(IntPtr apiInterfacePtr)
        {
            try
            {
                _mbApiInterface = new MusicBeeApiInterface();
                _mbApiInterface.Initialise(apiInterfacePtr);
                _about.PluginInfoVersion = PluginInfoVersion;
                _about.Name              = MusicBeeExporterConstants.Name;
                _about.Description       = MusicBeeExporterConstants.Description;
                _about.Author            = MusicBeeExporterConstants.Author;
                _about.TargetApplication =
                    MusicBeeExporterConstants
                    .TargetApplication;
                _about.Type                 = PluginType.General;
                _about.VersionMajor         = MusicBeeExporterConstants.VersionMajor;
                _about.VersionMinor         = MusicBeeExporterConstants.VersionMinor;
                _about.Revision             = MusicBeeExporterConstants.Revision;
                _about.MinInterfaceVersion  = MinInterfaceVersion;
                _about.MinApiRevision       = MinApiRevision;
                _about.ReceiveNotifications =
                    ReceiveNotificationFlags.PlayerEvents | ReceiveNotificationFlags.TagEvents;
                _about.ConfigurationPanelHeight =
                    MusicBeeExporterConstants.ConfigurationPanelHeight;

                // Initialize the plugin after music bee api interface is initialized and the PersistentStoragePath is accessible
                IPersistenceSettings persistenceSettings = new PersistenceSettings
                {
                    MusicBeeAllocatedStoragePath = _mbApiInterface.Setting_GetPersistentStoragePath()
                };


                // Create Plugin Storage folder
                Directory.CreateDirectory(persistenceSettings.PluginStorageDirectory);

                _repo = new Persistence(persistenceSettings);

                // Load exporter settings if it exists, otherwise create a new settings file.
                var settingJson = _repo.LoadPluginSettings();

                if (!string.IsNullOrWhiteSpace(settingJson))
                {
                    _pluginSettings = JsonConvert.DeserializeObject <MusicBeeExporterSettings>(settingJson);
                }
                else
                {
                    _pluginSettings = new MusicBeeExporterSettings(persistenceSettings);
                    _repo.SavePluginSettings(_pluginSettings);
                }

                CreateMenuItem();
            }
            catch (Exception ex)
            {
                UIHelper.DisplayExceptionDialog(ex);
            }

            return(_about);
        }
 private void Awake()
 {
     m_persistenceSettings  = PersistenceSettings.GetPersistenceSettings();
     m_persistentGameObject = (PersistentGameObject)target;
     if (String.IsNullOrEmpty(m_persistentGameObject.ObjectId))
     {
         m_persistentGameObject.ObjectId = m_persistentGameObject.gameObject.name + "_" + Guid.NewGuid();
     }
 }
        public static void ClearSaveFile()
        {
            var settings = PersistenceSettings.GetPersistenceSettings();

            if (File.Exists(settings.FilePath))
            {
                File.Delete(settings.FilePath);
            }
        }
示例#11
0
        public void HangfireServer_Program_ConnectionString_Exists()
        {
            var args = new Args
            {
                ShowConsole = true,
            };

            var implConfig = SetupHangfireImplementationConfigs(out var mockWriter, out var mockPauseHelper, out var mockExecutionLogPublisher);

            var dbSource = new DbSource
            {
                ConnectionString = "connectionString",
            };
            var compressedExecuteMessage = new CompressedExecuteMessage();
            var serializeToJsonString    = dbSource.SerializeToJsonString(new DefaultSerializationBinder());

            compressedExecuteMessage.SetMessage(serializeToJsonString);

            var mockSerializer = new Mock <IBuilderSerializer>();

            var mockFile            = new Mock <IFile>();
            var mockDirectory       = new Mock <IDirectory>();
            var persistenceSettings = new PersistenceSettings("some path", mockFile.Object, mockDirectory.Object)
            {
                Enable = false,
                PersistenceDataSource = new NamedGuidWithEncryptedPayload
                {
                    Name = "Data Source", Value = Guid.Empty, Payload = serializeToJsonString
                },
            };

            mockSerializer.Setup(o => o.Deserialize <DbSource>(persistenceSettings.PersistenceDataSource.Payload)).Returns(dbSource).Verifiable();
            var mockContext = new HangfireContext(args);

            var mockEventWaitHandle = new Mock <IEventWaitHandle>();

            mockEventWaitHandle.Setup(o => o.New()).Verifiable();
            mockEventWaitHandle.Setup(o => o.WaitOne()).Verifiable();

            var item = new Implementation(mockContext, implConfig, persistenceSettings, mockSerializer.Object, mockEventWaitHandle.Object);

            item.Run();

            mockWriter.Verify(o => o.WriteLine("Starting Hangfire server..."), Times.Once);
            mockExecutionLogPublisher.Verify(o => o.Info("Starting Hangfire server..."), Times.Once);
            mockSerializer.Verify(o => o.Deserialize <DbSource>(persistenceSettings.PersistenceDataSource.Payload), Times.Once);
            mockWriter.Verify(o => o.WriteLine("Hangfire dashboard started..."), Times.Once);
            mockExecutionLogPublisher.Verify(o => o.Info("Hangfire dashboard started..."), Times.Once);
            mockWriter.Verify(o => o.WriteLine("Hangfire server started..."), Times.Once);
            mockExecutionLogPublisher.Verify(o => o.Info("Hangfire server started..."), Times.Once);
            mockPauseHelper.Verify(o => o.Pause(), Times.Never);

            mockEventWaitHandle.Verify(o => o.New(), Times.Never);
            mockEventWaitHandle.Verify(o => o.WaitOne(), Times.Never);
        }
示例#12
0
 public ManualResumptionActivity(PersistenceSettings config, IPersistenceExecution resumeExecution)
 {
     DisplayName      = "Manual Resumption";
     OverrideDataFunc = new ActivityFunc <string, bool>
     {
         DisplayName = "Data Action",
         Argument    = new DelegateInArgument <string>($"explicitData_{DateTime.Now:yyyyMMddhhmmss}"),
     };
     _persistenceEnabled = config.Enable;
     _scheduler          = resumeExecution;
 }
 public SuspendExecutionActivity(PersistenceSettings config, IPersistenceExecution suspendExecution)
 {
     DisplayName  = "Suspend Execution";
     SaveDataFunc = new ActivityFunc <string, bool>
     {
         DisplayName = "Data Action",
         Argument    = new DelegateInArgument <string>($"explicitData_{DateTime.Now:yyyyMMddhhmmss}"),
     };
     _persistenceEnabled = config.Enable;
     _scheduler          = suspendExecution;
 }
        public static bool OnOpenAsset(int instanceId, int line)
        {
            PersistenceSettings persistenceSettings = EditorUtility.InstanceIDToObject(instanceId) as PersistenceSettings;

            if (persistenceSettings != null)
            {
                OpenSettingsWindow();
                return(true);
            }

            return(false);
        }
示例#15
0
        public void ManualResumptionActivity_Execute_PersistenceNotConfigured_FailWithMessage()
        {
            //------------Setup for test--------------------------
            var resourceId         = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var mockStateNotifier  = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var env = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);
            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = "workflowName",
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = "url",
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };
            var config = new PersistenceSettings
            {
                Enable = false
            };

            var manualResumptionActivity = new ManualResumptionActivity(config, new Mock <IPersistenceExecution>().Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = false,
                SuspensionId           = "321"
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, dataObject.Environment.AllErrors.Count);
            var errors = dataObject.Environment.AllErrors.ToList();

            Assert.AreEqual("Failed", manualResumptionActivity.Response);
            Assert.AreEqual(errors[0], "<InnerError>Could not find persistence config. Please configure in Persistence Settings.</InnerError>");
        }
示例#16
0
        public CandlesPersistenceManager(
            ICandlesPersistenceQueue persistenceQueue,
            IHealthService healthService,
            ILog log,
            PersistenceSettings settings) :
            base(nameof(CandlesPersistenceManager), (int)TimeSpan.FromSeconds(5).TotalMilliseconds, log)
        {
            _persistenceQueue = persistenceQueue;
            _healthService    = healthService;
            _settings         = settings;

            _lastDispatchMoment = DateTime.MinValue;
        }
        public static void OpenSaveFolder()
        {
            var settings = PersistenceSettings.GetPersistenceSettings();
            ProcessStartInfo startInformation = new ProcessStartInfo();

            if (!Directory.Exists(settings.FileFolder))
            {
                Directory.CreateDirectory(settings.FileFolder);
            }

            startInformation.FileName = settings.FileFolder;
            Process.Start(startInformation);
        }
        public CandlesPersistenceQueue(
            ICandlesHistoryRepository repository,
            ILogFactory logFactory,
            IHealthService healthService,
            PersistenceSettings settings) :

            base(logFactory, nameof(CandlesPersistenceQueue))
        {
            _repository        = repository;
            _log               = logFactory.CreateLog(this);
            _healthService     = healthService;
            _settings          = settings;
            _candlesToDispatch = new ConcurrentQueue <ICandle>();
        }
示例#19
0
        public CandlesPersistenceManager(
            ICandlesPersistenceQueue persistenceQueue,
            IHealthService healthService,
            ILogFactory logFactory,
            PersistenceSettings settings) :

            base(TimeSpan.FromSeconds(5), logFactory, nameof(CandlesPersistenceManager))
        {
            _persistenceQueue = persistenceQueue;
            _healthService    = healthService;
            _settings         = settings;

            _lastDispatchMoment = DateTime.MinValue;
        }
示例#20
0
        public CandlesPersistenceQueue(
            ICandlesHistoryRepository repository,
            ILog log,
            IHealthService healthService,
            PersistenceSettings settings) :

            base(nameof(CandlesPersistenceQueue), log)
        {
            _repository        = repository;
            _log               = log;
            _healthService     = healthService;
            _settings          = settings;
            _candlesToDispatch = new ConcurrentQueue <ICandle>();
        }
示例#21
0
        public RavenDbContext(IOptionsMonitor <PersistenceSettings> settings)
        {
            _persistenceSettings = settings.CurrentValue;

            _localStore = new DocumentStore()
            {
                Database = _persistenceSettings.DatabaseName,
                Urls     = _persistenceSettings.Urls
            };

            _localStore.Initialize();

            EnsureDatabaseIsCreated();
        }
示例#22
0
        /// <summary>
        /// The AddPersistence
        /// </summary>
        /// <param name="services">The services<see cref="IServiceCollection"/></param>
        /// <param name="configuration">The configuration<see cref="IConfiguration"/></param>
        /// <returns>The <see cref="IServiceCollection"/></returns>
        public static IServiceCollection AddPersistence(
            this IServiceCollection services,
            IConfiguration configuration)
        {
            bool useFake = configuration.GetValue <bool>("PersistenceModule:UseFake");

            var persistenceSettings = new PersistenceSettings {
                SqlDbConnectionString   = configuration.GetValue <string>("ConnectionStrings:SqlDb"),
                NoSqlDbConnectionString = configuration.GetValue <string>("ConnectionStrings:EmbeddedDb")
            };

            services.AddSingleton <PersistenceSettings>(persistenceSettings);
            services.AddDbContext <SqlDataContext>(x => x.UseSqlServer(persistenceSettings.SqlDbConnectionString));
            services.AddScoped <IUserRepository, Infrastructure.SqlServerDataAccess.Repositories.UserRepository>();

            return(services);
        }
示例#23
0
        public void PersistenceSettings_SaveIfNotExists()
        {
            var mockIFile = new Mock <IFile>();

            mockIFile.Setup(o => o.Exists(It.IsAny <string>())).Returns(false).Verifiable();
            mockIFile.Setup(o => o.WriteAllText(PersistenceSettings.SettingsPath, It.IsAny <string>()));
            var mockDirectory = new Mock <IDirectory>();

            mockDirectory.Setup(o => o.CreateIfNotExists(Path.GetDirectoryName(PersistenceSettings.SettingsPath))).Returns(PersistenceSettings.SettingsPath);

            //act
            var settings = new PersistenceSettings("some path", mockIFile.Object, mockDirectory.Object);

            settings.SaveIfNotExists();

            //assert
            mockIFile.Verify();
            mockDirectory.Verify();
        }
示例#24
0
        public void HangfireServer_Program_ConnectionString_Payload_Empty_WaitOne()
        {
            var args = new Args
            {
                ShowConsole = false,
            };

            var implConfig = SetupHangfireImplementationConfigs(out var mockWriter, out var mockPauseHelper, out var mockExecutionLogPublisher);

            var mockFile      = new Mock <IFile>();
            var mockDirectory = new Mock <IDirectory>();

            var persistenceSettings = new PersistenceSettings("", mockFile.Object, mockDirectory.Object);
            var mockContext         = new HangfireContext(args);

            var mockEventWaitHandle = new Mock <IEventWaitHandle>();

            mockEventWaitHandle.Setup(o => o.New()).Verifiable();
            mockEventWaitHandle.Setup(o => o.WaitOne()).Verifiable();

            var item = new Implementation(mockContext, implConfig, persistenceSettings, new Mock <IBuilderSerializer>().Object, mockEventWaitHandle.Object);

            item.Run();
            item.WaitForExit();

            mockWriter.Verify(o => o.WriteLine("Starting Hangfire server..."), Times.Once);
            mockExecutionLogPublisher.Verify(o => o.Info("Starting Hangfire server..."), Times.Once);
            mockWriter.Verify(o => o.WriteLine("Fatal Error: Could not find persistence config file. Hangfire server is unable to start."), Times.Once);
            mockExecutionLogPublisher.Verify(o => o.Error("Fatal Error: Could not find persistence config file. Hangfire server is unable to start."), Times.Once);
            mockWriter.Verify(o => o.Write("Press any key to exit..."), Times.Once);
            mockPauseHelper.Verify(o => o.Pause(), Times.Never);
            mockWriter.Verify(o => o.WriteLine("Hangfire dashboard started..."), Times.Never);
            mockExecutionLogPublisher.Verify(o => o.Info("Hangfire dashboard started..."), Times.Never);
            mockWriter.Verify(o => o.WriteLine("Hangfire server started..."), Times.Never);
            mockExecutionLogPublisher.Verify(o => o.Info("Hangfire server started..."), Times.Never);

            mockEventWaitHandle.Verify(o => o.New(), Times.Never);
            mockEventWaitHandle.Verify(o => o.WaitOne(), Times.Once);
        }
示例#25
0
        public void SuspendExecutionActivity_Execute_ServiceTestExecution_Success()
        {
            //------------Setup for test--------------------------
            var workflowName = "workflowName";
            var url = "http://localhost:3142/secure/WorkflowResume";
            var resourceId = Guid.NewGuid();
            var nextNodeId = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env = CreateExecutionEnvironment();
            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock<IStateNotifier>();
            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny<IDev2Activity>()));

            var environmentId = Guid.Empty;
            var mockPrincipal = new Mock<ClaimsPrincipal>();
            mockPrincipal.Setup(o => o.Identity).Returns(WindowsIdentity.GetCurrent());
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName = workflowName,
                ResourceID = resourceId,
                WorkflowInstanceId = workflowInstanceId,
                WebUrl = url,
                ServerID = Guid.NewGuid(),
                ExecutingUser = mockPrincipal.Object,
                IsDebug = true,
                EnvironmentID = environmentId,
                Environment = env,
                IsRemoteInvokeOverridden = false,
                DataList = new StringBuilder(CurrentDl),
                IsServiceTestExecution = true
            };

            var mockActivity = new Mock<IDev2Activity>();
            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var dev2Activities = new List<IDev2Activity> {mockActivity.Object};
            var activity = CreateWorkflow();
            var activityFunction = new ActivityFunc<string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler = activity,
            };
            var config = new PersistenceSettings
            {
                Enable = true
            };
            var expectedSuspendId = Guid.NewGuid().ToString();
            const enSuspendOption suspendOption = enSuspendOption.SuspendForSeconds;
            var mockSuspendExecution = new Mock<IPersistenceExecution>();
            mockSuspendExecution.Setup(o =>
                o.CreateAndScheduleJob(suspendOption, It.IsAny<string>(),
                    It.IsAny<Dictionary<string, StringBuilder>>())).Returns(expectedSuspendId);

            var suspendExecutionActivity = new SuspendExecutionActivity(config, mockSuspendExecution.Object)
            {
                SuspendOption = suspendOption,
                PersistValue = "20",
                AllowManualResumption = true,
                SaveDataFunc = activityFunction,
                Result = "[[SuspendID]]",
                NextNodes = dev2Activities
            };

            suspendExecutionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            suspendExecutionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, env.Errors.Count);
            Assert.AreEqual(expectedSuspendId, suspendExecutionActivity.Response);
            Assert.IsFalse(dataObject.StopExecution, "this will Stop Execution for the whole workflow, which is not ideal for the problem we are resolving");
            Assert.IsFalse(dataObject.IsDebugNested);
            Assert.AreEqual(0, dataObject.ForEachNestingLevel);
        }
示例#26
0
        public void SuspendExecutionActivity_Execute_PersistenceNotConfigured_FailWithMessage()
        {
            //------------Setup for test--------------------------
            var workflowName = "workflowName";
            var url = "http://localhost:3142/secure/WorkflowResume";
            var resourceId = Guid.NewGuid();
            var nextNodeId = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env = CreateExecutionEnvironment();
            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock<IStateNotifier>();
            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny<IDev2Activity>()));

            var environmentId = Guid.Empty;
            User = new Mock<IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName = workflowName,
                ResourceID = resourceId,
                WorkflowInstanceId = workflowInstanceId,
                WebUrl = url,
                ServerID = Guid.NewGuid(),
                ExecutingUser = User,
                IsDebug = true,
                EnvironmentID = environmentId,
                Environment = env,
                IsRemoteInvokeOverridden = false,
                DataList = new StringBuilder(CurrentDl),
                IsServiceTestExecution = true
            };

            var mockActivity = new Mock<IDev2Activity>();
            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var dev2Activities = new List<IDev2Activity> {mockActivity.Object};
            var activity = CreateWorkflow();
            var activityFunction = new ActivityFunc<string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler = activity,
            };
            var suspendUntil = DateTime.Now.AddDays(1);
            var config = new PersistenceSettings
            {
                Enable = false
            };
            var suspendExecutionActivity = new SuspendExecutionActivity(config, new Mock<IPersistenceExecution>().Object)
            {
                SuspendOption = enSuspendOption.SuspendUntil,
                PersistValue = suspendUntil.ToString(),
                AllowManualResumption = true,
                SaveDataFunc = activityFunction,
                Result = "[[SuspendID]]",
                NextNodes = dev2Activities
            };

            suspendExecutionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            suspendExecutionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            suspendExecutionActivity.Execute(dataObject, 0);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, env.AllErrors.Count);
            var errors = env.AllErrors.ToList();
            Assert.AreEqual(ErrorResource.PersistenceSettingsNoConfigured, errors[0]);
        }
示例#27
0
        public void SuspendExecutionActivity_Execute_EncryptData_False()
        {
            //------------Setup for test--------------------------
            var workflowName = "workflowName";
            var url = "http://localhost:3142/secure/WorkflowResume";
            var resourceId = Guid.NewGuid();
            var nextNodeId = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env = CreateExecutionEnvironment();
            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock<IStateNotifier>();
            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny<IDev2Activity>()));

            var environmentId = Guid.Empty;
            var mockPrincipal = new Mock<ClaimsPrincipal>();
            mockPrincipal.Setup(o => o.Identity).Returns(WindowsIdentity.GetCurrent());
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName = workflowName,
                ResourceID = resourceId,
                WorkflowInstanceId = workflowInstanceId,
                WebUrl = url,
                ServerID = Guid.NewGuid(),
                ExecutingUser = mockPrincipal.Object,
                IsDebug = true,
                EnvironmentID = environmentId,
                Environment = env,
                IsRemoteInvokeOverridden = false,
                DataList = new StringBuilder(CurrentDl),
                IsServiceTestExecution = true
            };

            var mockActivity = new Mock<IDev2Activity>();
            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var dev2Activities = new List<IDev2Activity> {mockActivity.Object};
            var activity = CreateWorkflow();
            var activityFunction = new ActivityFunc<string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler = activity,
            };
            var suspendUntil = DateTime.Now.AddDays(1);
            var config = new PersistenceSettings
            {
                Enable = true
            };

            var currentEnvironment = dataObject.Environment.ToJson();
            var values = new Dictionary<string, StringBuilder>
            {
                {"resourceID", new StringBuilder(dataObject.ResourceID.ToString())},
                {"environment", new StringBuilder(currentEnvironment)},
                {"startActivityId", new StringBuilder(nextNodeId.ToString())},
                {"versionNumber", new StringBuilder(dataObject.VersionNumber.ToString())},
                {"currentuserprincipal", new StringBuilder(WindowsIdentity.GetCurrent().Name)}
            };

            var mockSuspendExecution = new Mock<IPersistenceExecution>();
            mockSuspendExecution.Setup(o => o.CreateAndScheduleJob(enSuspendOption.SuspendUntil, suspendUntil.ToString(), values)).Verifiable();
            var suspendExecutionActivity = new SuspendExecutionActivity(config, mockSuspendExecution.Object)
            {
                SuspendOption = enSuspendOption.SuspendUntil,
                PersistValue = suspendUntil.ToString(),
                AllowManualResumption = true,
                EncryptData = false,
                SaveDataFunc = activityFunction,
                //Result = "[[SuspendID]]",
                NextNodes = dev2Activities
            };

            suspendExecutionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            suspendExecutionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, env.Errors.Count);
            GetScalarValueFromEnvironment(env, "SuspendID", out string suspendId, out string error);
            Assert.AreEqual(suspendId, suspendExecutionActivity.Response);
            //TODO: We need to improve on this verify to validate that the environment is not encrypted. Verify fails for unknown mismatch
            mockSuspendExecution.Verify(o => o.CreateAndScheduleJob(enSuspendOption.SuspendUntil, suspendUntil.ToString(), It.IsAny<Dictionary<string, StringBuilder>>()), Times.Once);
        }
示例#28
0
        public void SuspendExecutionActivity_Execute_SuspendForSeconds_SaveSuspendIDIntoEnv_Success()
        {
            //------------Setup for test--------------------------
            var workflowName = "workflowName";
            var url = "http://localhost:3142/secure/WorkflowResume";
            var resourceId = Guid.NewGuid();
            var nextNodeId = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env = CreateExecutionEnvironment();
            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock<IStateNotifier>();
            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny<IDev2Activity>()));

            var environmentId = Guid.Empty;
            User = GlobalConstants.GenericPrincipal;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName = workflowName,
                ResourceID = resourceId,
                WorkflowInstanceId = workflowInstanceId,
                WebUrl = url,
                ServerID = Guid.NewGuid(),
                ExecutingUser = User,
                IsDebug = true,
                EnvironmentID = environmentId,
                Environment = env,
                IsRemoteInvokeOverridden = false,
                DataList = new StringBuilder(CurrentDl),
                IsServiceTestExecution = true
            };

            var mockActivity = new Mock<IDev2Activity>();
            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var dev2Activities = new List<IDev2Activity> {mockActivity.Object};
            var activity = CreateWorkflow();
            var activityFunction = new ActivityFunc<string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler = activity,
            };
            var config = new PersistenceSettings
            {
                Enable = true
            };
            var suspendExecutionActivity = new SuspendExecutionActivity(config, new Mock<IPersistenceExecution>().Object)
            {
                SuspendOption = enSuspendOption.SuspendForSeconds,
                PersistValue = "20",
                AllowManualResumption = true,
                SaveDataFunc = activityFunction,
                //Result = "[[SuspendID]]",
                NextNodes = dev2Activities
            };

            suspendExecutionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            suspendExecutionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, env.Errors.Count);
            GetScalarValueFromEnvironment(env, "SuspendID", out string suspendId, out string error);
            Assert.AreEqual(suspendId, suspendExecutionActivity.Response);
        }
示例#29
0
        public void SuspendExecutionActivity_Execute_Empty_SuspendOptionValue()
        {
            //------------Setup for test--------------------------
            var workflowName = "workflowName";
            var url = "http://localhost:3142/secure/WorkflowResume";
            var resourceId = Guid.NewGuid();
            var nextNodeId = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env = CreateExecutionEnvironment();
            env.Assign("[[UUID]]", "public", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock<IStateNotifier>();
            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny<IDev2Activity>()));

            var environmentId = Guid.Empty;
            var mockPrincipal = new Mock<ClaimsPrincipal>();
            mockPrincipal.Setup(o => o.Identity).Returns(WindowsIdentity.GetCurrent());
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName = workflowName,
                ResourceID = resourceId,
                WorkflowInstanceId = workflowInstanceId,
                WebUrl = url,
                ServerID = Guid.NewGuid(),
                ExecutingUser = mockPrincipal.Object,
                IsDebug = true,
                EnvironmentID = environmentId,
                Environment = env,
                IsRemoteInvokeOverridden = false,
                DataList = new StringBuilder(CurrentDl),
                IsServiceTestExecution = true
            };

            var mockActivity = new Mock<IDev2Activity>();
            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var dev2Activities = new List<IDev2Activity> {mockActivity.Object};
            var activity = CreateWorkflow();
            var activityFunction = new ActivityFunc<string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler = activity,
            };

            var config = new PersistenceSettings
            {
                Enable = true
            };

            var suspendExecutionActivity =
                new SuspendExecutionActivity(config, new Mock<IPersistenceExecution>().Object)
                {
                    SuspendOption = enSuspendOption.SuspendUntil,
                    PersistValue = string.Empty,
                    AllowManualResumption = true,
                    SaveDataFunc = activityFunction,
                    NextNodes = dev2Activities,
                };

            suspendExecutionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            suspendExecutionActivity.Execute(dataObject, 0);
            Assert.AreEqual(null, suspendExecutionActivity.Response);
            Assert.AreEqual(1, env.Errors.Count());
            var errors = env.Errors.ToList();
            Assert.AreEqual("Suspend option Date value must not be null or empty.", errors[0]);
        }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlDataContext"/> class.
 /// </summary>
 /// <param name="options">The options<see cref="DbContextOptions{SqlDataContext}"/></param>
 public SqlDataContext(DbContextOptions <SqlDataContext> options, PersistenceSettings persistenceSettings) : base(options)
 {
     _persistenceSettings = persistenceSettings;
 }
 protected AtLeastOnceDeliveryActor(PersistenceSettings.AtLeastOnceDeliverySettings settings)
 {
     _atLeastOnceDeliverySemantic = new AtLeastOnceDeliverySemantic(Context, settings);
 }
示例#32
0
        public void ManualResumptionActivity_Execute_OverrideInputVariables_NonVariableInput_True_Success()
        {
            //------------Setup for test--------------------------
            var activity         = CreateWorkflowNoVariable();
            var activityFunction = new ActivityFunc <string, bool>
            {
                DisplayName = activity.DisplayName,
                Handler     = activity,
            };
            var workflowName       = "workflowName";
            var url                = "http://localhost:3142/secure/WorkflowResume";
            var resourceId         = Guid.NewGuid();
            var nextNodeId         = Guid.NewGuid();
            var workflowInstanceId = Guid.NewGuid();
            var env                = CreateExecutionEnvironment();

            env.Assign("[[UUID]]", "1234", 0);
            env.Assign("[[JourneyName]]", "whatever", 0);

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            var environmentId = Guid.Empty;

            User = new Mock <IPrincipal>().Object;
            var dataObject = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServiceName              = workflowName,
                ResourceID               = resourceId,
                WorkflowInstanceId       = workflowInstanceId,
                WebUrl                   = url,
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentId,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            var mockActivity = new Mock <IDev2Activity>();

            mockActivity.Setup(o => o.UniqueID).Returns(nextNodeId.ToString());
            var config = new PersistenceSettings
            {
                Enable = true
            };
            var suspensionId           = "321";
            var overrideInputVariables = true;
            var overrideEnvironment    = env.ToJson();
            var mockResumeJob          = new Mock <IPersistenceExecution>();

            mockResumeJob.Setup(o => o.ResumeJob(dataObject, suspensionId, overrideInputVariables, overrideEnvironment)).Verifiable();
            var manualResumptionActivity = new ManualResumptionActivity(config, mockResumeJob.Object)
            {
                Response = "[[result]]",
                OverrideInputVariables = overrideInputVariables,
                SuspensionId           = suspensionId,
                OverrideDataFunc       = activityFunction,
            };

            manualResumptionActivity.SetStateNotifier(mockStateNotifier.Object);
            //------------Execute Test---------------------------
            manualResumptionActivity.Execute(dataObject, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(0, dataObject.Environment.AllErrors.Count);
            mockResumeJob.Verify(o => o.ResumeJob(dataObject, suspensionId, overrideInputVariables, overrideEnvironment), Times.Once);
        }