public void Create(OperationInfoBase entity) { var row = Mapper.Map <JobInfo>(entity); _conext.JobInfos.Add(row); _conext.SaveChanges(); }
private void SelectServiceOperation(OperationInfoBase operationInfo) { Fx.Assert(operationInfo != null, "operationInfo cannot be null"); ServiceContractListItem serviceContract = this.serviceContracts.Find(operationInfo.GetContractFullName(null)); // Dont select operation if the contract cannot be found in the serviceContracts list if (serviceContract == null) { return; } ServiceOperationListItem operationItem = null; if (operationInfo is OperationInfo) { operationItem = new WorkflowServiceOperationListItem(); operationItem.Validating += new CancelEventHandler(ServiceOperationValidating); operationItem.Name = operationInfo.Name; ((WorkflowServiceOperationListItem)operationItem).Operation = operationInfo as OperationInfo; } else if (operationInfo is TypedOperationInfo) { operationItem = new TypedServiceOperationListItem(); operationItem.Validating += new CancelEventHandler(ServiceOperationValidating); operationItem.Name = operationInfo.Name; ((TypedServiceOperationListItem)operationItem).Operation = operationInfo as TypedOperationInfo; } serviceContract.SelectionOperation(operationItem); }
private void UpdateImplementingActivities() { ServiceOperationListItem operationListItem = this.Item as ServiceOperationListItem; WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; TypedServiceOperationListItem reflectedOperationListItem = this.Item as TypedServiceOperationListItem; OperationInfoBase operation = null; if (workflowOperationListItem != null) { operation = workflowOperationListItem.Operation; } else if (reflectedOperationListItem != null) { operation = reflectedOperationListItem.Operation; } Fx.Assert(operation != null, "operation should not be null at this point"); // workflow operations list item will complain if some operationInfo objects have different signature than others // for the same operation name. This will happen when we are updating the activities, since they already have a operation // object for that operation name, but with a different signature. so make them all point to null first ,then update. if (workflowOperationListItem != null) { foreach (Activity activity in operationListItem.ImplementingActivities) { PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, null); } } foreach (Activity activity in operationListItem.ImplementingActivities) { PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, operation.Clone()); } }
public void AddJob <T>(Expression <Action <T> > expreissonJob, OperationInfoBase operationInfo) { var jobId = BackgroundJob.Schedule(expreissonJob, TimeSpan.FromSeconds(5)); operationInfo.JobId = jobId; operationInfo.Save(); }
public void AddServiceOperation(OperationInfoBase operationInfo, Activity implementingActivity) { if (operationInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo"); } TypedOperationInfo typedOperationInfo = operationInfo as TypedOperationInfo; OperationInfo workflowOperationInfo = operationInfo as OperationInfo; string contractName = operationInfo.GetContractFullName(null); // Do not add operation if the contractName is not valid. Not throwing here gives the user to fix // a broken contract/operation by selecting a different operation from the UI. if (String.IsNullOrEmpty(contractName)) { return; } ServiceContractListItem serviceContract = this.serviceContracts.Find(contractName); if (typedOperationInfo != null) { if (serviceContract == null) { serviceContract = new ServiceContractListItem(this.operationsListBox); serviceContract.Validating += new CancelEventHandler(ServiceContractValidating); serviceContract.Name = contractName; serviceContract.ContractType = typedOperationInfo.ContractType; serviceContract.IsCustomContract = false; AddServiceContract(serviceContract); } TypedServiceOperationListItem operationItem = new TypedServiceOperationListItem(); operationItem.Validating += new CancelEventHandler(ServiceOperationValidating); operationItem.Name = typedOperationInfo.Name; operationItem.Operation = typedOperationInfo; operationItem.ImplementingActivities.Add(implementingActivity); serviceContract.AddOperation(operationItem); } else if (workflowOperationInfo != null) { if (serviceContract == null) { serviceContract = new ServiceContractListItem(this.operationsListBox); serviceContract.Validating += new CancelEventHandler(ServiceContractValidating); serviceContract.Name = workflowOperationInfo.ContractName; serviceContract.IsCustomContract = true; AddServiceContract(serviceContract); } WorkflowServiceOperationListItem workflowOperationItem = new WorkflowServiceOperationListItem(); workflowOperationItem.Validating += new CancelEventHandler(ServiceOperationValidating); workflowOperationItem.Operation = workflowOperationInfo; workflowOperationItem.ImplementingActivities.Add(implementingActivity); serviceContract.AddOperation(workflowOperationItem); } }
private void PopulateParametersGrid(OperationInfoBase operationInfoBase) { if (operationInfoBase != null) { string paramName; string direction; Type paramType; Type returnType = typeof(void); foreach (OperationParameterInfo paramInfo in operationInfoBase.GetParameters(this.ServiceProvider)) { paramType = paramInfo.ParameterType; paramName = paramInfo.Name; if (paramInfo.Name.Equals(SR2.GetString(SR2.ReturnValueString))) { returnType = paramType; continue; } else { if (paramInfo.IsOut) { if (paramInfo.IsIn) { direction = SR2.GetString(SR2.ParameterDirectionRef); } else { direction = SR2.GetString(SR2.ParameterDirectionOut); } } else if (paramType.IsByRef) { direction = SR2.GetString(SR2.ParameterDirectionRef); } else { // If neither IsOut nor IsByRef is true we assume it is an In parameter. direction = SR2.GetString(SR2.ParameterDirectionIn); } } //Add this type to list of typeColumn Items AddToTypeList(paramType); this.parametersGrid.Rows.Add(new object[] { paramName, paramType, direction }); } // add the retval as the first parameter AddToTypeList(returnType); this.parametersGrid.Rows.Insert(0, new object[] { SR2.GetString(SR2.ReturnValueString), returnType, SR2.GetString(SR2.ParameterDirectionOut) }); DataGridViewRow returnValueRow = this.parametersGrid.Rows[0]; returnValueRow.Cells[this.nameColumn.Index].ReadOnly = true; returnValueRow.Cells[this.directionColumn.Index].ReadOnly = true; } }
public void Update(Guid id, Action <OperationInfoBase> action) { var row = _conext.JobInfos.SingleOrDefault(r => r.Id == id); if (row == null) { throw new ArgumentOutOfRangeException(nameof(id)); } var opInfo = new OperationInfoBase { Id = row.Id, JobId = Convert.ToString(row.JobId), SerializedInfo = row.SerializedInfo, SignarRHubName = row.SignarRHubName }; action(opInfo); row.SerializedInfo = opInfo.SerializedInfo; row.SignarRHubName = opInfo.SignarRHubName; _conext.SaveChanges(); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (provider == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("provider"); } OperationInfoBase pickedServiceOperation = null; if (TryPickOperation(provider, (Activity)context.Instance, (OperationInfoBase)value, out pickedServiceOperation)) { return(pickedServiceOperation); } else { return(base.EditValue(context, provider, value)); } }
private void okButton_Click(object sender, EventArgs e) { object selectedObject = operationsListBox.SelectedItem; if (selectedObject == null) { selectedOperation = null; } if (selectedObject is TypedServiceOperationListItem) { selectedOperation = ((TypedServiceOperationListItem)selectedObject).Operation; } else if (selectedObject is WorkflowServiceOperationListItem) { selectedOperation = ((WorkflowServiceOperationListItem)selectedObject).Operation; } else { // dont close the dialog when contracts are selected return; } this.DialogResult = DialogResult.OK; this.Close(); }
public override void UpdateView() { // set the dialog fonts from vs. IUIService uisvc = (IUIService) this.ServiceProvider.GetService(typeof(IUIService)); if (uisvc != null) { this.Font = (Font) uisvc.Styles["DialogFont"]; } TypedServiceOperationListItem operationListItem = this.Item as TypedServiceOperationListItem; WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; if (operationListItem != null) { operationInfoBase = operationListItem.Operation; SetEditability(false); } if (workflowOperationListItem != null) { operationInfoBase = workflowOperationListItem.Operation; if (workflowOperationListItem.Operation.HasProtectionLevel) { this.protectionLevelComboBox.SelectedItem = workflowOperationListItem.Operation.ProtectionLevel; } else { this.protectionLevelComboBox.SelectedItem = SR2.GetString(SR2.UseRuntimeDefaults); } SetEditability(true); } Fx.Assert(operationInfoBase != null, "list Item should be either ReflectedServiceOperationListItem or WorkflowServiceOperationListItem"); this.oneWayCheckBox.Checked = operationInfoBase.GetIsOneWay(ServiceProvider); Fx.Assert(operationInfoBase != null, "Operation Info should be non-null at this point"); SetupColumns(); PopulateParametersGrid(operationInfoBase); if (!this.parametersGrid.ReadOnly) { this.parametersGrid.Rows.Add(this.ParameterTemplateRowName, null, null); } this.operationNameTextBox.Text = operationInfoBase.Name; this.permissionRoleTextBox.Text = operationInfoBase.PrincipalPermissionRole; this.permissionNameTextBox.Text = operationInfoBase.PrincipalPermissionName; this.permissionRoleTextBox.TextChanged += new EventHandler(permissionRoleTextChanged); if (workflowOperationListItem != null) { this.operationNameTextBox.Validating += new CancelEventHandler(operationNameTextBox_Validating); this.operationNameTextBox.Validated += new EventHandler(operationNameTextBox_Validated); } this.oneWayCheckBox.CheckedChanged += new EventHandler(oneWayCheckBoxCheckedChanged); this.permissionNameTextBox.TextChanged += new EventHandler(permissionNameTextChanged); this.parametersGrid.SelectionChanged += new EventHandler(parametersGrid_SelectionChanged); if (!this.parametersGrid.ReadOnly) { this.parametersGrid.CellValidating += new DataGridViewCellValidatingEventHandler(parametersGrid_CellValidating); this.parametersGrid.CellEndEdit += new DataGridViewCellEventHandler(parametersGridCellEndEdit); this.parametersGrid.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(parametersGrid_EditingControlShowing); this.parametersGrid.KeyDown += new KeyEventHandler(parametersGrid_KeyDown); } this.protectionLevelComboBox.SelectedValueChanged += new System.EventHandler(this.protectionLevelComboBoxSelectedValueChanged); RefreshParameterOperationButtons(); }
public void TestMethod1() { bool messageInvoked = false; var infoRepo = new JobInfoRepositoryMock(); var container = (new MockContainerConfig((c) => { var contextMock = new Mock <IHubContext>(); var mockClients = new Mock <IHubCallerConnectionContext <dynamic> >(); dynamic all = new ExpandoObject(); mockClients.Setup(m => m.All).Returns((ExpandoObject)all); contextMock.Setup(context => context.Clients).Returns(mockClients.Object); var provider = new Mock <IHubContextProvider>(); provider.Setup(p => p.GetConnectionContext("TestHub")).Returns(contextMock.Object); int counter = 0; all.updateSiteState = new Action <Guid>((infoId) => { var info = new DeploySiteInfo(infoRepo, provider.Object, infoId); lock (this) { switch (counter) { case 0: Assert.AreEqual(info.RestoreDbCopyFiles, OperationStageState.Completed); Assert.AreEqual(info.CreateWebApp, OperationStageState.Pending); Assert.AreEqual(info.ModifyConfigs, OperationStageState.Pending); counter++; break; case 1: Assert.AreEqual(info.RestoreDbCopyFiles, OperationStageState.Completed); Assert.AreEqual(info.CreateWebApp, OperationStageState.Completed); Assert.AreEqual(info.ModifyConfigs, OperationStageState.Pending); counter++; break; case 2: Assert.AreEqual(info.RestoreDbCopyFiles, OperationStageState.Completed); Assert.AreEqual(info.CreateWebApp, OperationStageState.Completed); Assert.AreEqual(info.ModifyConfigs, OperationStageState.Completed); break; } } }); c.RegisterInstance(provider.Object); c.RegisterType <ISiteDeployProvider, SiteDeployProviderMock>(); c.RegisterInstance <IJobInfoRepository>(infoRepo); })).GetContainer(); var siteDeployProvider = container.Resolve <ISiteDeployProvider>(); var data = new SiteCreateData { Name = "asdsadsa", Db = new SqlServerInstance { ServerName = "", InstanceName = "" }, UserName = "******" }; OperationInfoBase progressInfo = siteDeployProvider.GetOperationsInfo(); progressInfo.SignarRHubName = "TestHub"; progressInfo.OnStateChanged += (hub, info) => { hub.Clients.All.updateSiteState(info.Id); }; var progressJobId = progressInfo.Id; infoRepo.Create(progressInfo); siteDeployProvider.DeployWebApp(data, progressJobId); }
public static bool TryPickOperation(IServiceProvider serviceProvider, Activity activity, OperationInfoBase currentOperation, out OperationInfoBase selectedOperation) { selectedOperation = null; bool isReceiveActivity = activity is ReceiveActivity; try { using (OperationPickerDialog operationPicker = new OperationPickerDialog(serviceProvider, isReceiveActivity)) { Walker activityTreeWalker = new Walker(); Type allowedActivityType = null; if (isReceiveActivity) { allowedActivityType = typeof(ReceiveActivity); } else { allowedActivityType = typeof(SendActivity); } activityTreeWalker.FoundActivity += delegate(Walker walker, WalkerEventArgs eventArgs) { Activity foundActivity = eventArgs.CurrentActivity; if (!(allowedActivityType.IsAssignableFrom(foundActivity.GetType()))) { return; } if (!foundActivity.Enabled) { return; } if (foundActivity is ReceiveActivity) { ReceiveActivity reciveActivity = foundActivity as ReceiveActivity; if (reciveActivity.ServiceOperationInfo != null) { operationPicker.AddServiceOperation(reciveActivity.ServiceOperationInfo, reciveActivity); } } if (foundActivity is SendActivity) { SendActivity sendActivity = foundActivity as SendActivity; if (sendActivity.ServiceOperationInfo != null) { operationPicker.AddServiceOperation(sendActivity.ServiceOperationInfo, sendActivity); } } }; activityTreeWalker.Walk(activity.RootActivity); OperationInfoBase currentServiceOperationInfo = currentOperation as OperationInfoBase; if (currentServiceOperationInfo != null) { operationPicker.SelectedOperation = currentServiceOperationInfo; } DialogResult dialogResult = operationPicker.ShowDialog(); if ((operationPicker.SelectedOperation != null) && (dialogResult == DialogResult.OK) && !operationPicker.SelectedOperation.Equals(currentServiceOperationInfo)) { selectedOperation = operationPicker.SelectedOperation.Clone(); return(true); } } } catch (Exception e) { DesignerHelpers.ShowMessage(serviceProvider, e.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); throw; } return(false); }
public static bool TryPickOperation(IServiceProvider serviceProvider, Activity activity, OperationInfoBase currentOperation, out OperationInfoBase selectedOperation) { selectedOperation = null; bool isReceiveActivity = activity is ReceiveActivity; try { using (OperationPickerDialog operationPicker = new OperationPickerDialog(serviceProvider, isReceiveActivity)) { Walker activityTreeWalker = new Walker(); Type allowedActivityType = null; if (isReceiveActivity) { allowedActivityType = typeof(ReceiveActivity); } else { allowedActivityType = typeof(SendActivity); } activityTreeWalker.FoundActivity += delegate(Walker walker, WalkerEventArgs eventArgs) { Activity foundActivity = eventArgs.CurrentActivity; if (!(allowedActivityType.IsAssignableFrom(foundActivity.GetType()))) { return; } if (!foundActivity.Enabled) { return; } if (foundActivity is ReceiveActivity) { ReceiveActivity reciveActivity = foundActivity as ReceiveActivity; if (reciveActivity.ServiceOperationInfo != null) { operationPicker.AddServiceOperation(reciveActivity.ServiceOperationInfo, reciveActivity); } } if (foundActivity is SendActivity) { SendActivity sendActivity = foundActivity as SendActivity; if (sendActivity.ServiceOperationInfo != null) { operationPicker.AddServiceOperation(sendActivity.ServiceOperationInfo, sendActivity); } } }; activityTreeWalker.Walk(activity.RootActivity); OperationInfoBase currentServiceOperationInfo = currentOperation as OperationInfoBase; if (currentServiceOperationInfo != null) { operationPicker.SelectedOperation = currentServiceOperationInfo; } DialogResult dialogResult = operationPicker.ShowDialog(); if ((operationPicker.SelectedOperation != null) && (dialogResult == DialogResult.OK) && !operationPicker.SelectedOperation.Equals(currentServiceOperationInfo)) { selectedOperation = operationPicker.SelectedOperation.Clone(); return true; } } } catch (Exception e) { DesignerHelpers.ShowMessage(serviceProvider, e.Message, DR.GetString(DR.WorkflowDesignerTitle), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); throw; } return false; }
public override void UpdateView() { // set the dialog fonts from vs. IUIService uisvc = (IUIService)this.ServiceProvider.GetService(typeof(IUIService)); if (uisvc != null) { this.Font = (Font)uisvc.Styles["DialogFont"]; } TypedServiceOperationListItem operationListItem = this.Item as TypedServiceOperationListItem; WorkflowServiceOperationListItem workflowOperationListItem = this.Item as WorkflowServiceOperationListItem; if (operationListItem != null) { operationInfoBase = operationListItem.Operation; SetEditability(false); } if (workflowOperationListItem != null) { operationInfoBase = workflowOperationListItem.Operation; if (workflowOperationListItem.Operation.HasProtectionLevel) { this.protectionLevelComboBox.SelectedItem = workflowOperationListItem.Operation.ProtectionLevel; } else { this.protectionLevelComboBox.SelectedItem = SR2.GetString(SR2.UseRuntimeDefaults); } SetEditability(true); } Fx.Assert(operationInfoBase != null, "list Item should be either ReflectedServiceOperationListItem or WorkflowServiceOperationListItem"); this.oneWayCheckBox.Checked = operationInfoBase.GetIsOneWay(ServiceProvider); Fx.Assert(operationInfoBase != null, "Operation Info should be non-null at this point"); SetupColumns(); PopulateParametersGrid(operationInfoBase); if (!this.parametersGrid.ReadOnly) { this.parametersGrid.Rows.Add(this.ParameterTemplateRowName, null, null); } this.operationNameTextBox.Text = operationInfoBase.Name; this.permissionRoleTextBox.Text = operationInfoBase.PrincipalPermissionRole; this.permissionNameTextBox.Text = operationInfoBase.PrincipalPermissionName; this.permissionRoleTextBox.TextChanged += new EventHandler(permissionRoleTextChanged); if (workflowOperationListItem != null) { this.operationNameTextBox.Validating += new CancelEventHandler(operationNameTextBox_Validating); this.operationNameTextBox.Validated += new EventHandler(operationNameTextBox_Validated); } this.oneWayCheckBox.CheckedChanged += new EventHandler(oneWayCheckBoxCheckedChanged); this.permissionNameTextBox.TextChanged += new EventHandler(permissionNameTextChanged); this.parametersGrid.SelectionChanged += new EventHandler(parametersGrid_SelectionChanged); if (!this.parametersGrid.ReadOnly) { this.parametersGrid.CellValidating += new DataGridViewCellValidatingEventHandler(parametersGrid_CellValidating); this.parametersGrid.CellEndEdit += new DataGridViewCellEventHandler(parametersGridCellEndEdit); this.parametersGrid.EditingControlShowing += new DataGridViewEditingControlShowingEventHandler(parametersGrid_EditingControlShowing); this.parametersGrid.KeyDown += new KeyEventHandler(parametersGrid_KeyDown); } this.protectionLevelComboBox.SelectedValueChanged += new System.EventHandler(this.protectionLevelComboBoxSelectedValueChanged); RefreshParameterOperationButtons(); }
public void Create(OperationInfoBase entity) { _store[entity.Id] = entity; }