/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { WSHttpBinding newWsHttpBinding = new WSHttpBinding { MaxReceivedMessageSize = int.MaxValue, MaxBufferPoolSize = int.MaxValue, // Required, since we're returning such a large string. ReaderQuotas = new XmlDictionaryReaderQuotas { MaxArrayLength = 16384, MaxBytesPerRead = 4096, MaxDepth = 128, MaxNameTableCharCount = 16384, MaxStringContentLength = int.MaxValue } }; // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(newWsHttpBinding, new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"DumpProcessThreadsActivity&{ProcessId}"); Console.WriteLine(result); } }
public ActionResult CreateWorkOrder(long serviceRequestId) { var serviceRequest = _serviceRequestRepository.GetById(serviceRequestId); var workOrder = new WorkOrder { IsNew = true, ServiceRequestId = serviceRequest.Id, SiteId = serviceRequest.SiteId, AssetId = serviceRequest.AssetId, LocationId = serviceRequest.LocationId, RequestorName = serviceRequest.RequestorName, RequestorEmail = serviceRequest.RequestorEmail, RequestorPhone = serviceRequest.RequestorPhone, RequestedDateTime = serviceRequest.RequestedDateTime, CreatedUserId = this._workContext.CurrentUser.Id }; _workOrderRepository.InsertAndCommit(workOrder); //start workflow var workflowInstanceId = WorkflowServiceClient.StartWorkflow(workOrder.Id, EntityType.WorkOrder, 0, this._workContext.CurrentUser.Id); return(Json(new { workOrderId = workOrder.Id })); }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { if (!Kernel32 && !NtosKrnl) { throw new InvalidOperationException("At least one parameter, either 'Kernel32' or 'NtosKrnl' must be defined."); } if (Kernel32 && NtosKrnl) { WriteWarning("The default is NtosKrnl when both source file parameters are defined."); } using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string targetFile = string.Empty; if (Kernel32) { targetFile = "kernel32.dll"; } if (NtosKrnl) { targetFile = "ntoskrnl.exe"; } Version result = Version.Parse((string)newWorkflowServiceClient.InvokeWorkflow($"GetOsFileVersionActivity&{targetFile}")); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { WSHttpBinding newWsHttpBinding = new WSHttpBinding { MaxReceivedMessageSize = int.MaxValue, MaxBufferPoolSize = int.MaxValue, // Required, since we're returning such a large array of objects. ReaderQuotas = new XmlDictionaryReaderQuotas { MaxArrayLength = int.MaxValue, MaxBytesPerRead = 4096, MaxDepth = 128, MaxNameTableCharCount = 16384, MaxStringContentLength = int.MaxValue } }; // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(newWsHttpBinding, new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { EventLogEntry[] result = newWorkflowServiceClient.InvokeEventsWorkflow($"GetWindowsEventsActivity&{Log}!{Source}!{EventId}"); if (Filter) { // Do the work on this side, as it's easier. DateTime targetDateTime = DateTime.UtcNow - TimeSpan; EventLogEntry[] filteredResults = result.ToList().Where(e => e.TimeGenerated > targetDateTime).ToArray(); WriteObject(filteredResults); } else { WriteObject(result); } } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"CopyNIsAndDLLsActivity&{ProcessId}!{TargetPath}"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { bool result = (bool)newWorkflowServiceClient.InvokeWorkflow($"FileExistsActivity&{FilePath}"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"ModifyConfigurationFileActivity&{ConfigurationFile}!{ConfigurationKey}!{ConfigurationFile}"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow("InstallSysInternalsActivity"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { object result = newWorkflowServiceClient.InvokeWorkflow($"GetProcessIdActivity&{Process}!{IsAppPool}"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"ReadFileContentsActivity&{FilePath}"); Console.WriteLine(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { TimeSpan result = TimeSpan.Parse((string)newWorkflowServiceClient.InvokeWorkflow("GetSystemUptimeActivity")); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { bool result = bool.Parse((string)newWorkflowServiceClient.InvokeWorkflow($"PingActivity&{Target}")); WriteObject(result); } }
public ActionResult Edit(ContractModel model) { var contract = _contractRepository.GetById(model.Id); var assignment = contract.Assignment; if (ModelState.IsValid) { contract = model.ToEntity(contract); if (contract.IsNew == true) { string number = _autoNumberService.GenerateNextAutoNumber(_dateTimeHelper.ConvertToUserTime(DateTime.UtcNow, DateTimeKind.Utc), contract); contract.Number = number; } //always set IsNew to false when saving contract.IsNew = false; //copy to Assignment if (contract.Assignment != null) { contract.Assignment.Number = contract.Number; contract.Assignment.Description = contract.Description; contract.Assignment.Priority = contract.Priority; } _contractRepository.Update(contract); //commit all changes in UI this._dbContext.SaveChanges(); //trigger workflow action if (!string.IsNullOrEmpty(model.ActionName)) { WorkflowServiceClient.TriggerWorkflowAction(contract.Id, EntityType.Contract, assignment.WorkflowDefinitionId, assignment.WorkflowInstanceId, assignment.WorkflowVersion.Value, model.ActionName, model.Comment, this._workContext.CurrentUser.Id); //Every time we query twice, because EF is caching entities so it won't get the latest value from DB //We need to detach the specified entity and load it again this._dbContext.Detach(contract.Assignment); assignment = _assignmentRepository.GetById(contract.AssignmentId); } //notification SuccessNotification(_localizationService.GetResource("Record.Saved")); return(Json(new { number = contract.Number, status = assignment.Name, assignedUsers = assignment.Users.Select(u => u.Name), availableActions = assignment.AvailableActions ?? "" })); } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding { ReceiveTimeout = TimeSpan.FromMinutes(5), SendTimeout = TimeSpan.FromMinutes(5) }, new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow("WindowsUpdateActivity"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { WriteWarning("The environment variable will be for the user context that the service runs under."); // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"SetSymbolsEnvironmentPath&{SymbolFilePath}"); WriteObject(result); } }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { WSHttpBinding newWsHttpBinding = new WSHttpBinding { MaxReceivedMessageSize = int.MaxValue, MaxBufferPoolSize = int.MaxValue }; // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(newWsHttpBinding, new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"WebStringActivity&{Uri}"); Console.WriteLine(result); } }
public ActionResult Create() { var contract = new Contract { IsNew = true, Priority = (int?)AssignmentPriority.Medium, CreatedUserId = this._workContext.CurrentUser.Id }; _contractRepository.InsertAndCommit(contract); //start workflow var workflowInstanceId = WorkflowServiceClient.StartWorkflow(contract.Id, EntityType.Contract, 0, this._workContext.CurrentUser.Id); return(Json(new { Id = contract.Id })); }
public ActionResult Create() { var tenantLease = new TenantLease { IsNew = true, Priority = (int?)AssignmentPriority.Medium, CreatedUserId = this._workContext.CurrentUser.Id }; _tenantLeaseRepository.InsertAndCommit(tenantLease); //start workflow var workflowInstanceId = WorkflowServiceClient.StartWorkflow(tenantLease.Id, EntityType.TenantLease, 0, this._workContext.CurrentUser.Id); return(Json(new { Id = tenantLease.Id })); }
/// <summary> /// Overrides the <see cref="ProcessRecord"/> method inherited from <see cref="Cmdlet"/>. /// </summary> protected override void ProcessRecord() { // Wrap in using to prevent leaks from non-disposed calls. using (WorkflowServiceClient newWorkflowServiceClient = new WorkflowServiceClient(new WSHttpBinding(), new EndpointAddress($"http://{Server}:65534/WorkflowService/service"))) { string result = (string)newWorkflowServiceClient.InvokeWorkflow($"StartSecureDeleteActivity&{FilePath}"); if (result.Contains("Bad Science")) { WriteWarning("SDelete does not exist on the system. Run 'Install-RemoteSysInternals' to install the SysInternal tools on the server."); } else { WriteObject(result); } } }
public ActionResult Create() { var serviceRequest = new ServiceRequest { IsNew = true, Priority = (int?)AssignmentPriority.Medium, RequestorName = _workContext.CurrentUser.Name, RequestorEmail = _workContext.CurrentUser.Email, RequestorPhone = _workContext.CurrentUser.Phone, RequestedDateTime = DateTime.UtcNow, CreatedUserId = this._workContext.CurrentUser.Id }; _serviceRequestRepository.InsertAndCommit(serviceRequest); //start workflow var workflowInstanceId = WorkflowServiceClient.StartWorkflow(serviceRequest.Id, EntityType.ServiceRequest, 0, this._workContext.CurrentUser.Id); return(Json(new { Id = serviceRequest.Id })); }
public ActionResult Cancel(long?parentId, long id) { var serviceRequest = _serviceRequestRepository.GetById(id); var assignment = serviceRequest.Assignment; var assignmentHistories = _assignmentHistoryRepository.GetAll() .Where(a => a.EntityId == serviceRequest.Id && a.EntityType == EntityType.ServiceRequest) .ToList(); _serviceRequestRepository.Delete(serviceRequest); _assignmentRepository.Delete(assignment); foreach (var history in assignmentHistories) { _assignmentHistoryRepository.Delete(history); } this._dbContext.SaveChanges(); //cancel wf WorkflowServiceClient.CancelWorkflow( serviceRequest.Id, EntityType.ServiceRequest, assignment.WorkflowDefinitionId, assignment.WorkflowInstanceId, assignment.WorkflowVersion.Value, this._workContext.CurrentUser.Id); return(new NullJsonResult()); }
public ActionResult Edit(TenantLeaseModel model) { var tenantLease = _tenantLeaseRepository.GetById(model.Id); var assignment = tenantLease.Assignment; //find the list of leases status are leasing var existingLeases = _tenantLeaseRepository.GetAll().Where(l => l.SiteId == model.SiteId && l.PropertyId == model.PropertyId && l.TenantId == model.TenantId && l.Assignment.Name == "Leasing" && l.Id != model.Id).ToList(); if (existingLeases.Count > 0) { ModelState.AddModelError("TenantLease", _localizationService.GetResource("TenantLease.CannotCreateNewLease")); } if (ModelState.IsValid) { var hasChangedRentalTermAndDate = HasChangedRentalTermAndDate(tenantLease, model); tenantLease = model.ToEntity(tenantLease); if (tenantLease.IsNew == true) { string number = _autoNumberService.GenerateNextAutoNumber(_dateTimeHelper.ConvertToUserTime(DateTime.UtcNow, DateTimeKind.Utc), tenantLease); tenantLease.Number = number; } //always set IsNew to false when saving tenantLease.IsNew = false; //copy to Assignment if (tenantLease.Assignment != null) { tenantLease.Assignment.Number = tenantLease.Number; tenantLease.Assignment.Description = tenantLease.Description; tenantLease.Assignment.Priority = tenantLease.Priority; } _tenantLeaseRepository.Update(tenantLease); //commit all changes in UI this._dbContext.SaveChanges(); //trigger workflow action if (!string.IsNullOrEmpty(model.ActionName)) { WorkflowServiceClient.TriggerWorkflowAction(tenantLease.Id, EntityType.TenantLease, assignment.WorkflowDefinitionId, assignment.WorkflowInstanceId, assignment.WorkflowVersion.Value, model.ActionName, model.Comment, this._workContext.CurrentUser.Id); //Every time we query twice, because EF is caching entities so it won't get the latest value from DB //We need to detach the specified entity and load it again this._dbContext.Detach(tenantLease.Assignment); assignment = _assignmentRepository.GetById(tenantLease.AssignmentId); } //Generate Payment Schedule and Payment this._dbContext.Detach(tenantLease); tenantLease = _tenantLeaseRepository.GetById(tenantLease.Id); if (hasChangedRentalTermAndDate) { var tenantPayments = tenantLease.TenantPayments.Where(p => p.TenantLeasePaymentScheduleId != null).ToList(); var hasNotAnyPaymentCollectionOrDaysLateInTenantPayment = HasNotAnyPaymentCollectionOrDaysLateInTenantPayment(tenantPayments); if (hasNotAnyPaymentCollectionOrDaysLateInTenantPayment) { _tenantLeaseService.GeneratePaymentSchedules(tenantLease); var firstPaymentSchedulePeriod = _tenantLeasePaymentScheduleRepository.GetAll() .Where(s => s.TenantLeaseId == tenantLease.Id) .OrderBy(s => s.DueDate) .FirstOrDefault(); _tenantLeaseService.CreateRentPayment(firstPaymentSchedulePeriod, tenantLease.FirstPaymentDate); this._dbContext.SaveChanges(); } else { return(Json(new { Errors = _localizationService.GetResource("TenantLease.CannotGeneratePayment") })); } } //notification SuccessNotification(_localizationService.GetResource("Record.Saved")); return(Json(new { number = tenantLease.Number, status = assignment.Name, assignedUsers = assignment.Users.Select(u => u.Name), availableActions = assignment.AvailableActions ?? "" })); } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }