Example #1
0
        public Task <Deployment> Save(ProcessDefinitionDeployer deployer)
        {
            try
            {
                IDeploymentBuilder deployment = this.repositoryService
                                                .CreateDeployment()
                                                .DisableDuplicateStartForm();

                deployment.DisableBpmnValidation();
                deployment.DisableSchemaValidation();
                deployment.EnableDuplicateFiltering();

                string resourceName = deployer.Name.EndsWith("bpmn", StringComparison.OrdinalIgnoreCase) ? deployer.Name : $"{deployer.Name}.bpmn";

                IDeployment dep = deployment.Name(deployer.Name)
                                  .Category(deployer.Category)
                                  .Key(deployer.Key)
                                  .TenantId(deployer.TenantId)
                                  .BusinessKey(deployer.BusinessKey)
                                  .BusinessPath(deployer.BusinessPath)
                                  .StartForm(deployer.StartForm, deployer.BpmnXML)
                                  .AddString(resourceName, deployer.BpmnXML)
                                  .Save();

                return(Task.FromResult <Deployment>(deploymentConverter.From(dep)));
            }
            catch (StartFormUniqueException ex)
            {
                throw new Http400Exception(new Http400
                {
                    Code    = "startFormUniqueException",
                    Message = ex.Message
                }, ex);
            }
        }
 public DashboardWindow(IMission mission, IDeployment deployment)
 {
     InitializeComponent();
     Mission = mission;
     Deployment = deployment;
     deviceManager = (Application.Current as App).DeviceManager;
     if (deployment.Devices.Count > 0)
     {
         deviceManager.ActiveDevice = deployment.Devices[0];
         deviceManager.ActiveDevice.MessageReceived += ActiveDeviceMessageReceived;
     }
     controllerAxisChangedHandler = ControllerAxisChanged;
     controllerConnectionChangedHandler = ControllerConnectionChanged;
     bitmapFrameCapturedHandler = VideoDisplayWindowBitmapFrameCaptured;
     this.Title = String.Format("Dashboard - {0} > {1}", mission.Name, deployment.DateTime.ToString());
     YawOffsetSlider.ValueChanged += YawOffsetSliderValueChanged;
     PitchOffsetSlider.ValueChanged += PitchOffsetSliderValueChanged;
     FinRangeSlider.ValueChanged += FinRangeSliderValueChanged;
     TopFinOffsetSlider.ValueChanged += TopFinOffsetSliderValueChanged;
     RightFinOffsetSlider.ValueChanged += RightFinOffsetSliderValueChanged;
     BottomFinOffsetSlider.ValueChanged += BottomFinOffsetSliderValueChanged;
     LeftFinOffsetSlider.ValueChanged += LeftFinOffsetSliderValueChanged;
     illuminationSlider.ValueChanged += IlluminationSliderValueChanged;
     focusSlider.ValueChanged += focusSliderValueChanged;
     buoyancySlider.ValueChanged += buoyancySliderValueChanged;
 }
        void PublishToJira(string token, DeploymentEventType eventType, IDeployment deployment)
        {
            var envSettings =
                deploymentEnvironmentSettingsProvider
                .GetSettings <DeploymentEnvironmentSettingsMetadataProvider.JiraDeploymentEnvironmentSettings>(
                    JiraConfigurationStore.SingletonId, deployment.EnvironmentId) ?? new DeploymentEnvironmentSettingsMetadataProvider.JiraDeploymentEnvironmentSettings();
            var serverUri = serverConfigurationStore.GetServerUri()?.TrimEnd('/');

            if (string.IsNullOrWhiteSpace(serverUri))
            {
                log.Warn("To use Jira integration you must have the Octopus server's external url configured (see the Configuration/Nodes page)");
                return;
            }

            var project = projectStore.Get(deployment.ProjectId);
            var deploymentEnvironment = deploymentEnvironmentStore.Get(deployment.EnvironmentId);
            var release    = releaseStore.Get(deployment.ReleaseId);
            var serverTask = serverTaskStore.Get(deployment.TaskId);

            var data = new OctopusJiraPayloadData
            {
                InstallationId  = installationIdProvider.GetInstallationId().ToString(),
                BaseHostUrl     = store.GetBaseUrl(),
                DeploymentsInfo = new JiraPayloadData
                {
                    Deployments = new[]
 public Deployment(IDeployment deployment)
 {
     Id            = deployment.Id;
     ReleaseId     = deployment.ReleaseId;
     EnvironmentId = deployment.EnvironmentId;
     DeployedAt    = deployment.DeployedAt;
 }
Example #5
0
 public DashboardWindow(IMission mission, IDeployment deployment)
 {
     InitializeComponent();
     Mission       = mission;
     Deployment    = deployment;
     deviceManager = (Application.Current as App).DeviceManager;
     if (deployment.Devices.Count > 0)
     {
         deviceManager.ActiveDevice = deployment.Devices[0];
         deviceManager.ActiveDevice.MessageReceived += ActiveDeviceMessageReceived;
     }
     controllerAxisChangedHandler       = ControllerAxisChanged;
     controllerConnectionChangedHandler = ControllerConnectionChanged;
     bitmapFrameCapturedHandler         = VideoDisplayWindowBitmapFrameCaptured;
     this.Title = String.Format("Dashboard - {0} > {1}", mission.Name, deployment.DateTime.ToString());
     YawOffsetSlider.ValueChanged       += YawOffsetSliderValueChanged;
     PitchOffsetSlider.ValueChanged     += PitchOffsetSliderValueChanged;
     FinRangeSlider.ValueChanged        += FinRangeSliderValueChanged;
     TopFinOffsetSlider.ValueChanged    += TopFinOffsetSliderValueChanged;
     RightFinOffsetSlider.ValueChanged  += RightFinOffsetSliderValueChanged;
     BottomFinOffsetSlider.ValueChanged += BottomFinOffsetSliderValueChanged;
     LeftFinOffsetSlider.ValueChanged   += LeftFinOffsetSliderValueChanged;
     illuminationSlider.ValueChanged    += IlluminationSliderValueChanged;
     focusSlider.ValueChanged           += focusSliderValueChanged;
     buoyancySlider.ValueChanged        += buoyancySliderValueChanged;
 }
        public VideoDisplayWindow(IMission mission, IDeployment deployment)
        {
            InitializeComponent();

            Mission = mission;
            Deployment = deployment;
            Title = String.Format("Video - {0} > {1}", mission.Name, deployment.DateTime.ToString());

            var app = Application.Current as App;
            if (app == null)
            {
                throw new Exception("Something has gone arye!");
            }

            triggerStateChangedHandler = new TriggerStateChangedHandler(ControllerTriggerStateChanged);
            buttonStateChangedHandler = new ButtonStateChangedHandler(ControllerButtonStateChanged);

            deviceManager = (Application.Current as App).DeviceManager;
            if (deployment.Devices.Count > 0)
            {
                deviceManager.ActiveDevice = deployment.Devices[0];
                deviceManager.ActiveDevice.MessageReceived += new DeviceMessageHandler(ActiveDeviceMessageReceived);
            }

            headsUpDisplay.YawOffset = Settings.Default.YawOffset;
            this.Dispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate
            {
                if (deployment.Devices.Count > 0)
                {
                    IDevice device = deployment.Devices[0];
                    device.FrameReady += DeviceFrameReady;
                    device.Open();
                    try
                    {
                        IDevice activeDevice = deviceManager.ActiveDevice;
                        deviceManager.ActiveDevice.StartVideoCapture(1000);
                        activeDevice.FinRange = Settings.Default.FinRange;
                        activeDevice.TopFinOffset = Settings.Default.TopFinOffset;
                        activeDevice.RightFinOffset = Settings.Default.RightFinOffset;
                        activeDevice.BottomFinOffset = Settings.Default.BottomFinOffset;
                        activeDevice.LeftFinOffset = Settings.Default.LeftFinOffset;
                        activeDevice.CTD = true;

                    }
                    catch (Exception ex)
                    {
                        StringBuilder message = new StringBuilder(ex.ToString());
                        Exception inner = ex.InnerException;
                        while (inner != null)
                        {
                            message.AppendLine(inner.ToString());
                            inner = inner.InnerException;
                        }
                        MessageBox.Show(message.ToString(), "Error Initializing Capture:" + ex.Message);
                        this.Close();
                    }
                }
                return null;
            }), null);
        }
Example #7
0
        public VideoDisplayWindow(IMission mission, IDeployment deployment)
        {
            InitializeComponent();

            Mission    = mission;
            Deployment = deployment;
            Title      = String.Format("Video - {0} > {1}", mission.Name, deployment.DateTime.ToString());

            var app = Application.Current as App;

            if (app == null)
            {
                throw new Exception("Something has gone arye!");
            }

            triggerStateChangedHandler = new TriggerStateChangedHandler(ControllerTriggerStateChanged);
            buttonStateChangedHandler  = new ButtonStateChangedHandler(ControllerButtonStateChanged);

            deviceManager = (Application.Current as App).DeviceManager;
            if (deployment.Devices.Count > 0)
            {
                deviceManager.ActiveDevice = deployment.Devices[0];
                deviceManager.ActiveDevice.MessageReceived += new DeviceMessageHandler(ActiveDeviceMessageReceived);
            }

            headsUpDisplay.YawOffset = Settings.Default.YawOffset;
            this.Dispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate
            {
                if (deployment.Devices.Count > 0)
                {
                    IDevice device     = deployment.Devices[0];
                    device.FrameReady += DeviceFrameReady;
                    device.Open();
                    try
                    {
                        IDevice activeDevice = deviceManager.ActiveDevice;
                        deviceManager.ActiveDevice.StartVideoCapture(1000);
                        activeDevice.FinRange        = Settings.Default.FinRange;
                        activeDevice.TopFinOffset    = Settings.Default.TopFinOffset;
                        activeDevice.RightFinOffset  = Settings.Default.RightFinOffset;
                        activeDevice.BottomFinOffset = Settings.Default.BottomFinOffset;
                        activeDevice.LeftFinOffset   = Settings.Default.LeftFinOffset;
                        activeDevice.CTD             = true;
                    }
                    catch (Exception ex)
                    {
                        StringBuilder message = new StringBuilder(ex.ToString());
                        Exception inner       = ex.InnerException;
                        while (inner != null)
                        {
                            message.AppendLine(inner.ToString());
                            inner = inner.InnerException;
                        }
                        MessageBox.Show(message.ToString(), "Error Initializing Capture:" + ex.Message);
                        this.Close();
                    }
                }
                return(null);
            }), null);
        }
Example #8
0
        public virtual void testSerializeFileVariable()
        {
            IBpmnModelInstance modelInstance = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process").StartEvent().UserTask().EndEvent().Done();
            IDeployment        deployment    = repositoryService.CreateDeployment().AddModelInstance("process.bpmn", modelInstance).Deploy();
            IVariableMap       variables     = ESS.FW.Bpm.Engine.Variable.Variables.CreateVariables();
            string             filename      = "test.Txt";
            string             type          = "text/plain";
            IFileValue         fileValue     = ESS.FW.Bpm.Engine.Variable.Variables.FileValue(filename).File(File.Open(filename, FileMode.OpenOrCreate)).Encoding("UTF-8").MimeType(type).Create();

            // IFileValue fileValue = Variable.Variables.FileValue(filename).File("ABC".GetBytes()).Encoding("UTF-8").MimeType(type).Create();
            variables.Add("file", fileValue);
            runtimeService.StartProcessInstanceByKey("process", variables);
            ITask             task   = taskService.CreateTaskQuery().First();
            IVariableInstance result = runtimeService.CreateVariableInstanceQuery(c => c.ProcessInstanceId == task.ProcessInstanceId).First();
            IFileValue        value  = (IFileValue)result.TypedValue;

            Assert.That(value.Filename, Is.EqualTo(filename));
            Assert.That(value.MimeType, Is.EqualTo(type));
            Assert.That(value.Encoding, Is.EqualTo("UTF-8"));
            Assert.That(value.EncodingAsCharset, Is.EqualTo(Encoding.UTF8));
            //Scanner scanner = new Scanner(value.Value);
            //Assert.That(scanner.NextLine(), Is.EqualTo("ABC"));

            Assert.That(value.Value, Is.EqualTo("ABC"));
            // clean up
            repositoryService.DeleteDeployment(deployment.Id, true);
        }
        public virtual void testCreateDeploymentPa()
        {
            // given
            EmbeddedProcessApplication application = new EmbeddedProcessApplication();

            // when
            IDeployment deployment = repositoryService.CreateDeployment(application.Reference).Name(DEPLOYMENT_NAME).AddModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)).Deploy();

            // then
            IUserOperationLogEntry userOperationLogEntry = historyService.CreateUserOperationLogQuery().First();

            Assert.NotNull(userOperationLogEntry);

            Assert.AreEqual(EntityTypes.Deployment, userOperationLogEntry.EntityType);
            Assert.AreEqual(deployment.Id, userOperationLogEntry.DeploymentId);

            Assert.AreEqual(UserOperationLogEntryFields.OperationTypeCreate, userOperationLogEntry.OperationType);

            Assert.AreEqual("duplicateFilterEnabled", userOperationLogEntry.Property);
            Assert.IsNull(userOperationLogEntry.OrgValue);
            Assert.IsFalse(Convert.ToBoolean(userOperationLogEntry.NewValue));

            Assert.AreEqual(USER_ID, userOperationLogEntry.UserId);

            Assert.IsNull(userOperationLogEntry.JobDefinitionId);
            Assert.IsNull(userOperationLogEntry.ProcessInstanceId);
            Assert.IsNull(userOperationLogEntry.ProcessDefinitionId);
            Assert.IsNull(userOperationLogEntry.ProcessDefinitionKey);
            Assert.IsNull(userOperationLogEntry.CaseInstanceId);
            Assert.IsNull(userOperationLogEntry.CaseDefinitionId);
        }
//JAVA TO C# CONVERTER TODO Resources.Task: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteProcessDefinitionAndRefillDeploymentCache()
        [Test]   public virtual void testDeleteProcessDefinitionAndRefillDeploymentCache()
        {
            // given a deployment with two process definitions in one xml model file
            deployment = repositoryService.CreateDeployment().AddClasspathResource("resources/repository/twoProcesses.bpmn20.xml").Deploy();
            IProcessDefinition processDefinitionOne = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "one").First();
            IProcessDefinition processDefinitionTwo = repositoryService.CreateProcessDefinitionQuery(c => c.Key == "two").First();

            string idOne = processDefinitionOne.Id;

            //one is deleted from the deployment
            repositoryService.DeleteProcessDefinition(idOne);

            //when clearing the deployment cache
            processEngineConfiguration.DeploymentCache.DiscardProcessDefinitionCache();

            //then creating process instance from the existing process definition
            IProcessInstanceWithVariables procInst = runtimeService.CreateProcessInstanceByKey("two").ExecuteWithVariablesInReturn();

            Assert.NotNull(procInst);
            Assert.True(procInst.ProcessDefinitionId.Contains("two"));

            //should refill the cache
            ICache <string, ProcessDefinitionEntity> cache = processEngineConfiguration.DeploymentCache.ProcessDefinitionCache;

            Assert.NotNull(cache.Get(processDefinitionTwo.Id));
            //The deleted process definition should not be recreated after the cache is refilled
            Assert.IsNull(cache.Get(processDefinitionOne.Id));
        }
        public virtual void testDeleteDeploymentCascading()
        {
            // given
            IDeployment deployment = repositoryService.CreateDeployment().Name(DEPLOYMENT_NAME).AddModelInstance(RESOURCE_NAME, createProcessWithServiceTask(PROCESS_KEY)).Deploy();

            IQueryable <IUserOperationLogEntry> query = historyService.CreateUserOperationLogQuery(c => c.OperationType == UserOperationLogEntryFields.OperationTypeDelete);

            // when
            repositoryService.DeleteDeployment(deployment.Id, true);

            // then
            Assert.AreEqual(1, query.Count());

            IUserOperationLogEntry log = query.First();

            Assert.NotNull(log);

            Assert.AreEqual(EntityTypes.Deployment, log.EntityType);
            Assert.AreEqual(deployment.Id, log.DeploymentId);

            Assert.AreEqual(UserOperationLogEntryFields.OperationTypeDelete, log.OperationType);

            Assert.AreEqual("cascade", log.Property);
            Assert.IsNull(log.OrgValue);
            Assert.True(Convert.ToBoolean(log.NewValue));

            Assert.AreEqual(USER_ID, log.UserId);

            Assert.IsNull(log.JobDefinitionId);
            Assert.IsNull(log.ProcessInstanceId);
            Assert.IsNull(log.ProcessDefinitionId);
            Assert.IsNull(log.ProcessDefinitionKey);
            Assert.IsNull(log.CaseInstanceId);
            Assert.IsNull(log.CaseDefinitionId);
        }
Example #12
0
        public virtual void testDeployAndRemoveAsyncActivity()
        {
            ISet <string> deployments = new HashSet <string>();

            try
            {
                // given a deployment that contains a process called "process" with an async task "task"
                IDeployment deployment1 = repositoryService.CreateDeployment().AddClasspathResource("resources/bpmn/async/AsyncTaskTest.TestDeployAndRemoveAsyncActivity.v1.bpmn20.xml").Deploy();
                deployments.Add(deployment1.Id);

                // when redeploying the process where that task is not contained anymore
                IDeployment deployment2 = repositoryService.CreateDeployment().AddClasspathResource("resources/bpmn/async/AsyncTaskTest.TestDeployAndRemoveAsyncActivity.v2.bpmn20.xml").Deploy();
                deployments.Add(deployment2.Id);

                // and clearing the deployment cache (note that the equivalent of this in a real-world
                // scenario would be making the deployment with a different engine
                processEngineConfiguration.DeploymentCache.DiscardProcessDefinitionCache();

                // then it should be possible to load the latest process definition
                IProcessInstance processInstance = runtimeService.StartProcessInstanceByKey("process");
                Assert.NotNull(processInstance);
            }
            finally
            {
                foreach (string deploymentId in deployments)
                {
                    repositoryService.DeleteDeployment(deploymentId, true);
                }
            }
        }
Example #13
0
 public void CreateDeployment(IDeployment deployment)
 {
     using (var service = DataLocator.GetPersistenceService())
     {
         service.Object.Create(deployment.Name, deployment);
     }
 }
Example #14
0
        public async Task <bool> StartDeploymentAsync(string resourceGroupName, string location, string deploymentName, string templateFilePath, string parameters)
        {
            string armTemplate = GetARMTemplate(templateFilePath);

            await TryCreateResourceGroupAsync(resourceGroupName, location);

            if (_resourceManager.Deployments.CheckExistence(resourceGroupName,
                                                            deploymentName))
            {
                IDeployment deployment = await _resourceManager
                                         .Deployments
                                         .GetByResourceGroupAsync(resourceGroupName, deploymentName)
                                         .ConfigureAwait(false);

                ProvisioningState provisioningState = ProvisioningState.Parse(deployment.ProvisioningState);

                if (provisioningState.DeploymentRunning())
                {
                    return(false);
                }
            }

            _resourceManager
            .Deployments
            .Define(deploymentName)
            .WithExistingResourceGroup(resourceGroupName)
            .WithTemplate(armTemplate)
            .WithParameters(parameters)
            .WithMode(DeploymentMode.Incremental)
            .BeginCreate();

            return(true);
        }
Example #15
0
        public void 执行事务子流程(string bpmnFile)
        {
            string xml = IntegrationTestContext.ReadBpmn(bpmnFile);

            ICommandExecutor commandExecutor = (processEngine.ProcessEngineConfiguration as ProcessEngineConfigurationImpl).CommandExecutor;

            Authentication.AuthenticatedUser = new InProcessWorkflowEngine.TestUser()
            {
                Id       = "评审员",
                FullName = "评审员",
                TenantId = context.TenantId
            };

            IDeploymentBuilder builder = processEngine.RepositoryService.CreateDeployment()
                                         .Name(Path.GetFileNameWithoutExtension(bpmnFile))
                                         .TenantId(context.TenantId)
                                         .AddString(bpmnFile, xml)
                                         .EnableDuplicateFiltering()
                                         .TenantId(context.TenantId);

            IDeployment deploy = commandExecutor.Execute(new DeployCmd(builder));

            IProcessDefinition definition = processEngine.RepositoryService.CreateProcessDefinitionQuery()
                                            .SetDeploymentId(deploy.Id)
                                            .SetProcessDefinitionTenantId(context.TenantId)
                                            .SetLatestVersion()
                                            .SingleResult();

            IProcessInstance processInstance = commandExecutor.Execute(new StartProcessInstanceCmd(definition.Id, null));

            IList <ITask> tasks = processEngine.TaskService.GetMyTasks("评审员");

            commandExecutor.Execute(new CompleteTaskCmd(tasks[0].Id, null));
        }
        public Task <Deployment> Deploy([FromBody] ProcessDefinitionDeployer deployer)
        {
            IDeploymentBuilder deployment = this.repositoryService.CreateDeployment();

            if (deployer.DisableSchemaValidation)
            {
                deployment.DisableSchemaValidation();
            }

            if (deployer.EnableDuplicateFiltering)
            {
                deployment.EnableDuplicateFiltering();
            }

            string resourceName = deployer.Name.EndsWith("bpmn", StringComparison.OrdinalIgnoreCase) ? deployer.Name : $"{deployer.Name}.bpmn";

            IDeployment dep = deployment.Name(deployer.Name)
                              .Category(deployer.Category)
                              .Key(deployer.Key)
                              .TenantId(deployer.TenantId)
                              .BusinessKey(deployer.BusinessKey)
                              .BusinessPath(deployer.BusinessPath)
                              .StartForm(deployer.StartForm, deployer.BpmnXML)
                              .AddString(resourceName, deployer.BpmnXML)
                              .Deploy();

            return(Task.FromResult(deploymentConverter.From(dep)));
        }
        public virtual void testRedeploy()
        {
            // given
            IRepositoryService repositoryService = engineRule.RepositoryService;

            IBpmnModelInstance model1 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process1").Done();
            IBpmnModelInstance model2 = ESS.FW.Bpm.Model.Bpmn.Bpmn.CreateExecutableProcess("process2").Done();

            // first deployment
            IDeployment deployment1 = repositoryService.CreateDeployment().AddModelInstance("process1.bpmn", model1).AddModelInstance("process2.bpmn", model2).Deploy();

            // when
            authRule.Init(scenario).WithUser("userId").BindResource("deploymentId", deployment1.Id).Start();

            IDeployment deployment2 = repositoryService.CreateDeployment().AddDeploymentResources(deployment1.Id).Deploy();

            // then
            if (authRule.AssertScenario(scenario))
            {
                Assert.AreEqual(2, repositoryService.CreateDeploymentQuery().Count());
                deleteDeployments(deployment2);
                deleteAuthorizations();
            }

            deleteDeployments(deployment1);
        }
 public DeploymentCreateForecastWorker(
     IDeployment deployment,
     IOperation operation,
     Guid subscriptionId,
     string certificateThumbprint, 
     string serviceName,
     string deploymentSlot,
     ScheduleDay[] scheduleDays,
     string deploymentName,
     Uri packageUrl,
     string label,
     string configurationFilePath,
     bool startDeployment,
     bool treatWarningsAsError,
     int pollingIntervalInMinutes)
     : base(GetWorkerId(serviceName, deploymentSlot))
 {
     this.deployment = deployment;
     this.operation = operation;
     this.subscriptionId = subscriptionId;
     this.certificateThumbprint = certificateThumbprint;
     this.serviceName = serviceName;
     this.deploymentSlot = deploymentSlot;
     this.scheduleDays = scheduleDays;
     this.deploymentName = deploymentName;
     this.packageUrl = packageUrl;
     this.label = label;
     this.configurationFilePath = configurationFilePath;
     this.startDeployment = startDeployment;
     this.treatWarningsAsError = treatWarningsAsError;
     this.pollingIntervalInMinutes = pollingIntervalInMinutes;
 }
Example #19
0
        private static async Task Main(string[] args)
        {
            Console.WriteLine("Starting up...");

            Deployment = await InitializeApplication();

            var log = Deployment.Container.Resolve <ILogFactory>().CreateLog(typeof(Program));

            log.Information("Started.");
            var input = "";

            do
            {
                Console.Write(">");
                input = Console.ReadLine();
                Console.WriteLine("");

                switch (input)
                {
                case "c":
                    var cFactory     = Deployment.Container.Resolve <ICompressionFactory>();
                    var test         = System.Guid.NewGuid().ToByteArray();
                    var compressed   = cFactory.Compress(test, CompressionType.Gzip);
                    var uncompressed = cFactory.Decompress(compressed, CompressionType.Gzip);
                    log.Information("Compression Works:{0}", test.SequenceEqual(uncompressed));
                    break;

                default:
                    break;
                }
            } while (input != "q");
        }
Example #20
0
 public DeploymentCreateForecastWorker(
     IDeployment deployment,
     IOperation operation,
     Guid subscriptionId,
     string certificateThumbprint,
     string serviceName,
     string deploymentSlot,
     ScheduleDay[] scheduleDays,
     string deploymentName,
     Uri packageUrl,
     string label,
     string configurationFilePath,
     bool startDeployment,
     bool treatWarningsAsError,
     int pollingIntervalInMinutes)
     : base(GetWorkerId(serviceName, deploymentSlot))
 {
     this.deployment            = deployment;
     this.operation             = operation;
     this.subscriptionId        = subscriptionId;
     this.certificateThumbprint = certificateThumbprint;
     this.serviceName           = serviceName;
     this.deploymentSlot        = deploymentSlot;
     this.scheduleDays          = scheduleDays;
     this.deploymentName        = deploymentName;
     this.packageUrl            = packageUrl;
     this.label = label;
     this.configurationFilePath    = configurationFilePath;
     this.startDeployment          = startDeployment;
     this.treatWarningsAsError     = treatWarningsAsError;
     this.pollingIntervalInMinutes = pollingIntervalInMinutes;
 }
        public void UnitTestDoWork_With_Now_Not_In_The_Scheduled_Time()
        {
            MockRepository mockRepository = new MockRepository();

            // Set start time to 1 hour before now.
            TimeSpan dailyStartTime = (DateTime.Now - DateTime.Today).Add(this.oneHour);

            // Set end time to 1 hour after now.
            TimeSpan  dailyEndTime             = (DateTime.Now - DateTime.Today).Add(this.oneHour);
            const int PollingIntervalInMinutes = 60;

            // Arrange
            IDeployment mockDeployment = mockRepository.StrictMock <IDeployment>();
            IOperation  mockOperation  = mockRepository.StrictMock <IOperation>();

            // Act
            mockRepository.ReplayAll();
            DeploymentDeleteForecastWorker deploymentDeleteForecastWorker = new DeploymentDeleteForecastWorker(
                mockDeployment,
                mockOperation,
                this.subscriptionId,
                CertificateThumbprint,
                ServiceName,
                DeploymentSlot,
                new[] { new ScheduleDay {
                            DayOfWeek = DateTime.Now.DayOfWeek, EndTime = dailyEndTime, StartTime = dailyStartTime
                        } },
                PollingIntervalInMinutes);

            deploymentDeleteForecastWorker.DoWork();

            // Assert
            mockRepository.VerifyAll();
        }
 public ScheduledHorizontalScaleForecastWorker(
     IDeployment deployment,
     IOperation operation,
     Guid subscriptionId,
     string certificateThumbprint, 
     string serviceName,
     string deploymentSlot,
     HorizontalScale[] horizontalScales,
     ScheduleDay[] scheduleDays,
     bool treatWarningsAsError,
     string mode,
     int pollingIntervalInMinutes)
     : base(GetWorkerId(serviceName, deploymentSlot))
 {
     this.deployment = deployment;
     this.operation = operation;
     this.subscriptionId = subscriptionId;
     this.certificateThumbprint = certificateThumbprint;
     this.serviceName = serviceName;
     this.deploymentSlot = deploymentSlot;
     this.horizontalScales = horizontalScales;
     this.scheduleDays = scheduleDays;
     this.treatWarningsAsError = treatWarningsAsError;
     this.mode = mode;
     this.pollingIntervalInMinutes = pollingIntervalInMinutes;
 }
Example #23
0
        public override void Load(IDeployment deployment = null)
        {
            if (Loaded)
            {
                return;
            }

            if (deployment != null)
            {
                Deployment = deployment;
            }

            SetupAppDomain();

            var handle = Activator.CreateInstanceFrom(
                remoteDomain,
                typeof(TToolset).Assembly.Location,
                typeof(TToolset).FullName,
                false,
                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance,
                null,
                null,
                null,
                null,
                null);

            NestedToolset = handle.Unwrap() as IToolset;
            NestedToolset.Load(Deployment);
            Deployment = NestedToolset.Deployment;

            Loaded = true;
        }
Example #24
0
        //[Deployment]
        public virtual void TestConcurrencyInSubProcess()
        {
            IDeployment deployment = repositoryService.CreateDeployment().AddClasspathResource("resources/bpmn/subprocess/SubProcessTest.fixSystemFailureProcess.bpmn20.xml").Deploy();

            // After staring the process, both tasks in the subprocess should be active
            IProcessInstance pi    = runtimeService.StartProcessInstanceByKey("fixSystemFailure");
            IList <ITask>    tasks = taskService.CreateTaskQuery(c => c.ProcessInstanceId == pi.Id) /*.OrderByTaskName()*//*.Asc()*/.ToList().OrderBy(m => m.Name).ToList();

            // Tasks are ordered by name (see query)
            Assert.AreEqual(2, tasks.Count);
            ITask investigateHardwareTask = tasks[0];
            ITask investigateSoftwareTask = tasks[1];

            Assert.AreEqual("Investigate hardware", investigateHardwareTask.Name);
            Assert.AreEqual("Investigate software", investigateSoftwareTask.Name);

            // Completing both the tasks finishes the subprocess and enables the task after the subprocess
            taskService.Complete(investigateHardwareTask.Id);
            taskService.Complete(investigateSoftwareTask.Id);

            ITask writeReportTask = taskService.CreateTaskQuery(c => c.ProcessInstanceId == pi.Id).First();

            Assert.AreEqual("Write report", writeReportTask.Name);

            // Clean up
            repositoryService.DeleteDeployment(deployment.Id, true);
        }
Example #25
0
 public ScheduledHorizontalScaleForecastWorker(
     IDeployment deployment,
     IOperation operation,
     Guid subscriptionId,
     string certificateThumbprint,
     string serviceName,
     string deploymentSlot,
     HorizontalScale[] horizontalScales,
     ScheduleDay[] scheduleDays,
     bool treatWarningsAsError,
     string mode,
     int pollingIntervalInMinutes)
     : base(GetWorkerId(serviceName, deploymentSlot))
 {
     this.deployment            = deployment;
     this.operation             = operation;
     this.subscriptionId        = subscriptionId;
     this.certificateThumbprint = certificateThumbprint;
     this.serviceName           = serviceName;
     this.deploymentSlot        = deploymentSlot;
     this.horizontalScales      = horizontalScales;
     this.scheduleDays          = scheduleDays;
     this.treatWarningsAsError  = treatWarningsAsError;
     this.mode = mode;
     this.pollingIntervalInMinutes = pollingIntervalInMinutes;
 }
        public void UnitTestDoWork_With_Now_In_The_Scheduled_Time_And_Deployment_Exists_And_Second_Call_Not_Within_Polling_Interval()
        {
            MockRepository mockRepository = new MockRepository();

            // Set start time to 1 hour before now.
            TimeSpan dailyStartTime = (DateTime.Now - DateTime.Today).Subtract(this.oneHour);

            // Set end time to 1 hour after now.
            TimeSpan dailyEndTime = (DateTime.Now - DateTime.Today).Add(this.oneHour);

            // Set polling window to zero so the second call to "DoWork" is not within the first polling window.
            const int       PollingIntervalInMinutes = 0;
            OperationResult operationResult          = new OperationResult
            {
                Code           = "Test",
                HttpStatusCode = HttpStatusCode.OK,
                Id             = Guid.NewGuid(),
                Message        = string.Empty,
                Status         = OperationStatus.Succeeded
            };

            // Arrange
            IDeployment mockDeployment = mockRepository.StrictMock <IDeployment>();
            IOperation  mockOperation  = mockRepository.StrictMock <IOperation>();

            mockDeployment
            .Expect(d => d.CheckExists(this.subscriptionId, CertificateThumbprint, ServiceName, DeploymentSlot))
            .Repeat.Twice()
            .Return(true);
            mockDeployment
            .Expect(d => d.DeleteRequest(this.subscriptionId, CertificateThumbprint, ServiceName, DeploymentSlot))
            .Repeat.Twice()
            .Return(DeleteRequestId);
            mockOperation
            .Expect(o => o.StatusCheck(this.subscriptionId, CertificateThumbprint, DeleteRequestId))
            .Repeat.Twice()
            .Return(operationResult);

            // Act
            mockRepository.ReplayAll();
            DeploymentDeleteForecastWorker deploymentDeleteForecastWorker = new DeploymentDeleteForecastWorker(
                mockDeployment,
                mockOperation,
                this.subscriptionId,
                CertificateThumbprint,
                ServiceName,
                DeploymentSlot,
                new[] { new ScheduleDay {
                            DayOfWeek = DateTime.Now.DayOfWeek, EndTime = dailyEndTime, StartTime = dailyStartTime
                        } },
                PollingIntervalInMinutes);

            deploymentDeleteForecastWorker.DoWork();
            Thread.Sleep(10);
            deploymentDeleteForecastWorker.DoWork(); // Call DoWork twice to check the polling window works.

            // Assert
            mockRepository.VerifyAll();
        }
        public override void deployProcesses()
        {
            IDeployment deploy = testHelper.Deploy(DEFINITION_XML);

            sourceDefinition = engineRule.RepositoryService.CreateProcessDefinitionQuery(c => c.DeploymentId == deploy.Id).First();
            processInstance  = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);
            processInstance2 = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id);
        }
 public virtual void cleanUp()
 {
     if (deployment != null)
     {
         repositoryService.DeleteDeployment(deployment.Id, true);
         deployment = null;
     }
 }
        public EmbeddedDeployment(IDeployment physical)
        {
            if (physical == null)
            {
                throw new ArgumentException("physical");
            }

            this.physical = physical;
        }
        protected EmbeddedDeployment(IDeployment physical)
        {
            if (physical == null)
            {
                throw new ArgumentException("physical");
            }

            Physical = physical;
        }
Example #31
0
        public ImageToolset(IDeployment deployment)
        {
            if (deployment == null)
            {
                throw new ArgumentNullException("deployment");
            }

            Deployment = deployment;
        }
        public EmbeddedDeployment(IDeployment physical)
        {
            if (physical == null)
            {
                throw new ArgumentException("physical");
            }

            this.physical = physical;
        }
Example #33
0
        public ImageToolset(IDeployment deployment)
        {
            if (deployment == null)
            {
                throw new ArgumentNullException("deployment");
            }

            Deployment = deployment;
        }
        public void 获取已完成流程节点(string bpmnFile)
        {
            string xml = IntegrationTestContext.ReadBpmn(bpmnFile);

            ICommandExecutor commandExecutor = (processEngine.ProcessEngineConfiguration as ProcessEngineConfigurationImpl).CommandExecutor;

            Authentication.AuthenticatedUser = new InProcessWorkflowEngine.TestUser()
            {
                Id       = "评审员",
                FullName = "评审员",
                TenantId = context.TenantId
            };

            IDeploymentBuilder builder = processEngine.RepositoryService.CreateDeployment()
                                         .Name(Path.GetFileNameWithoutExtension(bpmnFile))
                                         .TenantId(context.TenantId)
                                         .AddString(bpmnFile, xml)
                                         .EnableDuplicateFiltering()
                                         .TenantId(context.TenantId);

            IDeployment deploy = commandExecutor.Execute(new DeployCmd(builder));

            IProcessDefinition definition = processEngine.RepositoryService.CreateProcessDefinitionQuery()
                                            .SetDeploymentId(deploy.Id)
                                            .SetProcessDefinitionTenantId(context.TenantId)
                                            .SetLatestVersion()
                                            .SingleResult();

            BpmnModel model = commandExecutor.Execute(new GetBpmnModelCmd(definition.Id));

            IProcessInstance processInstance = commandExecutor.Execute(new StartProcessInstanceCmd(definition.Id, null));

            IList <ITask> tasks = processEngine.TaskService.GetMyTasks("用户1");

            ITaskEntity      task      = tasks[0] as ITaskEntity;
            IExecutionEntity execution = commandExecutor.Execute(new GetExecutionByIdCmd(task.ExecutionId));

            processEngine.TaskService.Complete(task.Id, new Dictionary <string, object>
            {
                { "流程变量", "变量值" }
            });

            var list = commandExecutor.Execute(new GetCompletedTaskModelsCmd(task.ProcessInstanceId, true));

            Assert.Contains(model.MainProcess.FlowElements, x => list.Any(y => x.Id == y.Id));

            tasks = processEngine.TaskService.GetMyTasks("用户2");
            task  = tasks[0] as ITaskEntity;
            processEngine.TaskService.Complete(task.Id, new Dictionary <string, object>
            {
                { "流程变量", "变量值" }
            });

            list = commandExecutor.Execute(new GetCompletedTaskModelsCmd(task.ProcessInstanceId, true));

            Assert.Contains(model.MainProcess.FlowElements, x => list.Any(y => x.Id == y.Id));
        }
Example #35
0
        public virtual IProcessDefinition DeployForTenantAndGetDefinition(string tenant, IBpmnModelInstance bpmnModel)
        {
            IDeployment deployment = Deploy(CreateDeploymentBuilder().TenantId(tenant), new List <IBpmnModelInstance>()
            {
                bpmnModel
            }, new List <string>());

            return(engineRule.RepositoryService.CreateProcessDefinitionQuery(c => c.DeploymentId == deployment.Id).First());
        }
        public virtual void TestParsePriorityOnNonAsyncActivity()
        {
            // deploying a process definition where the activity
            // has a priority but defines no jobs succeeds
            IDeployment deployment = repositoryService.CreateDeployment().AddClasspathResource("resources/bpmn/job/JobPrioritizationBpmnTest.TestParsePriorityOnNonAsyncActivity.bpmn20.xml").Deploy();

            // cleanup
            repositoryService.DeleteDeployment(deployment.Id);
        }
Example #37
0
        public UpdateService(ILog logger) {
            _Logger = logger;
            _UpdateCheckInterval = new TimeSpan(0, 1, 0, 0); //Check for updates every hour, because quick deploy is nice
            _Deployment = ApplicationDeployment.IsNetworkDeployed
                              ? (IDeployment) new AppDeployment(_Logger)
                              : (IDeployment) new NoDeployment();

            _UpdateTimer = new Timer(1000) { AutoReset = true, Enabled = false };
            _UpdateTimer.Elapsed += UpdateTimerElapsed;
            _NextUpdateCheck = DateTime.Now.AddMinutes(1);
            _UpdateCheckIsBusy = false;
            _Deployment.UpdateReady += (o, e) => OnUpdateReady(e);
        }
 public WhiteListForecastWorker(
     ISubscription[] subscriptions,
     IDeployment deployment,
     IOperation operation,
     WhiteListService[] allowedServices,
     int pollingIntervalInMinutes)
     : base(GetWorkerId(typeof(WhiteListForecastWorker).FullName))
 {
     this.subscriptions = subscriptions;
     this.deployment = deployment;
     this.operation = operation;
     this.allowedServices = allowedServices;
     this.pollingIntervalInMinutes = pollingIntervalInMinutes;
 }
Example #39
0
        public void Load(IDeployment deployment = null)
        {
            if (Loaded)
            {
                return;
            }

            if (deployment != null)
            {
                Deployment = deployment;
            }

            WinApiHelper.SetDllDirectory(Deployment.Path);
            WkhtmltoxBindings.wkhtmltoimage_init(0);

            Loaded = true;
        }
 public DeploymentDeleteForecastWorker(
     IDeployment deployment, 
     IOperation operation, 
     Guid subscriptionId, 
     string certificateThumbprint, 
     string serviceName,
     string deploymentSlot,
     ScheduleDay[] scheduleDays,
     int pollingIntervalInMinutes)
     : base(GetWorkerId(serviceName, deploymentSlot))
 {
     this.deployment = deployment;
     this.operation = operation;
     this.subscriptionId = subscriptionId;
     this.certificateThumbprint = certificateThumbprint;
     this.serviceName = serviceName;
     this.deploymentSlot = deploymentSlot;
     this.scheduleDays = scheduleDays;
     this.pollingIntervalInMinutes = pollingIntervalInMinutes;
 }
 private static void SetupDeleteRequestWithStatusCheck(IDeployment mockDeployment, IOperation mockOperation, string serviceName, string deploymentSlot, string requestId)
 {
     mockDeployment
         .Expect(d => d.CheckExists(SubscriptionId, CertificateThumbprint, serviceName, deploymentSlot))
         .Repeat.Once()
         .Return(true);
     mockDeployment
         .Expect(d => d.DeleteRequest(SubscriptionId, CertificateThumbprint, serviceName, deploymentSlot))
         .Repeat.Once()
         .Return(requestId);
     mockOperation
         .Expect(o => o.StatusCheck(SubscriptionId, CertificateThumbprint, requestId))
         .Repeat.Once()
         .Return(new OperationResult { Status = OperationStatus.Succeeded });
 }
 private static void SetupHorizontallyScaleWithStatusCheck(IDeployment mockDeployment, IOperation mockOperation, string serviceName, string deploymentSlot, HorizontalScale[] horizontalScales, string requestId)
 {
     mockDeployment
         .Expect(d => d.CheckExists(SubscriptionId, CertificateThumbprint, serviceName, deploymentSlot))
         .Repeat.Once()
         .Return(true);
     mockDeployment
         .Expect(d => d.HorizontallyScale(SubscriptionId, CertificateThumbprint, serviceName, deploymentSlot, horizontalScales, true, Mode.Auto))
         .Repeat.Once()
         .Return(requestId);
     mockOperation
         .Expect(o => o.StatusCheck(SubscriptionId, CertificateThumbprint, requestId))
         .Repeat.Once()
         .Return(new OperationResult { Status = OperationStatus.Succeeded });
 }
 public DownloadTheLatestVersion(IDeployment deployment)
 {
     this.deployment = deployment;
 }
Example #44
0
 public CancelUpdate(IDeployment deployment)
 {
     this.deployment = deployment;
 }
 public WhatIsTheAvailableVersion(IDeployment deployment)
 {
     this.deployment = deployment;
 }
 public Win64EmbeddedDeployment(IDeployment physical) : base(physical) { }
Example #47
0
 public abstract void Load(IDeployment deployment = null);
Example #48
0
 public void Load(IDeployment deployment = null)
 {
     throw new NotImplementedException();
 }