// DELETE: api/Approver/5 public IHttpActionResult Delete(int id) { Approver result = ApproverList.Where(p => p.ID == id).FirstOrDefault(); var resultflag = ApproverList.Remove(result); return(Ok(resultflag)); }
public void Defaults() { var result = SettingsAttributeReader.ReadFromAttribute(null); Assert.IsNotNull(result); Approver.Verify(result); }
public void NonDefaults() { var result = SettingsAttributeReader.ReadFromAttribute( new CustomAttributeMock( new Dictionary <string, object> { { "ScriptPromotionPath", @"D:\scripts" }, { "MsSqlServerScripts", true }, { "MySqlScripts", true }, { "OracleScripts", true }, { "ProduceSagaScripts", false }, { "ProduceTimeoutScripts", false }, { "ProduceSubscriptionScripts", false }, { "ProduceOutboxScripts", false } })); Assert.IsNotNull(result); Approver.Verify(result); }
public Leave Approve(Approver nextApprover) { Status = Status.APPROVED; Approver = nextApprover; return(this); }
public void process(string dp) { Approver emp = model.Approvers.Where(x => x.Department_ID == dp && x.Status == "Active").FirstOrDefault(); emp.Status = "Inactive"; model.SaveChanges(); }
/// <summary> /// 向上移动 /// </summary> /// <param name="Order"></param> /// <param name="Orders"></param> /// <returns></returns> public ActionResult ApproverMove(string Id, string Orders, string ProcessItemId) { Guid Aid = new Guid(Id); //根据该字段的id找到order Approver a = new Approver(); a = (from aps in db.Approver where (aps.Id == new Guid(Id)) select aps).Single(); //第二个表的查询 int Orde = Convert.ToInt32(Orders); Approver b = new Approver(); b = (from aps in db.Approver where (aps.Order == Orde && aps.ProcessItemId == new Guid(ProcessItemId)) select aps).Single(); a.Order = a.Order - 1; db.Entry(a).State = EntityState.Modified; b.Order = b.Order + 1; db.Entry(b).State = EntityState.Modified; //2.保存到数据库 int i = db.SaveChanges(); return(Json(i, JsonRequestBehavior.AllowGet)); }
public void RunMapReduce() { using (var store = InMemoryStoreBuilder.GetInMemoryStore()) { store.ExecuteIndex(new SagaListIndex()); using (var session = store.OpenSession()) { foreach (var sagaHistory in GetFakeHistory()) { session.Store(sagaHistory); } session.SaveChanges(); } store.WaitForIndexing(); using (var session = store.OpenSession()) { var mapReduceResults = session.Query <SagaListIndex.Result, SagaListIndex>() .ToList(); Approver.Verify(mapReduceResults); } } }
public async Task <IActionResult> Edit(int CaseID, string LocalUserID, [Bind("CaseID,LocalUserID,Approved,Order,LocalGroupID")] Approver approver) { if (CaseID != approver.CaseID || LocalUserID != approver.LocalUserID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(approver); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ApproverExists(approver.CaseID, approver.LocalUserID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CaseID"] = new SelectList(_context.Case, "CaseID", "CaseID", approver.CaseID); ViewData["LocalUserID"] = new SelectList(_context.LocalUser, "LocalUserID", "LocalUserID", approver.LocalUserID); ViewData["LocalGroupID"] = new SelectList(_context.LocalGroup, "LocalGroupID", "LocalGroupID", approver.LocalGroupID); return(View(approver)); }
public bool AddApproverForDepartment(int idEmployee, int idDepartment, int approveNumber) { using (var db = new KadrDataContext()) { try { var currentApprover = db.Approver.Where( f => f.idDepartment == idDepartment & f.ApproverType.ApproveNumber == approveNumber & f.DateEnd == null).ToArray(); foreach (var approver in currentApprover) { approver.DateEnd = DateTime.Now; } var newApprover = new Approver { idApproverType = db.ApproverType.Where(w => w.ApproveNumber == approveNumber).Select( s => s.id).FirstOrDefault(), idDepartment = idDepartment, idEmployee = idEmployee, DateBegin = DateTime.Now, DateEnd = null }; db.Approver.InsertOnSubmit(newApprover); db.SubmitChanges(); return(true); } catch (System.Exception) { return(false); } } }
public IApprover AddApprover(int clientId, int approverId, bool isPrimary) { Approver appr = new Approver { ClientID = clientId, ApproverID = approverId }; Approver existing = Session.Get <Approver>(appr); IApprover result; if (existing == null) { appr.Active = true; Session.Save(appr); SetPrimary(appr, isPrimary); result = appr.CreateModel <IApprover>(); } else { existing.Active = true; SetPrimary(existing, isPrimary); result = existing.CreateModel <IApprover>(); } return(result); }
public virtual void SaveWithWeirdCharacters() { var endpointName = nameof(SaveWithWeirdCharacters); var definition = new SagaDefinition( tableSuffix: "SagaWithWeirdCharactersಠ_ಠ", name: "SagaWithWeirdCharactersಠ_ಠ", correlationProperty: new CorrelationProperty ( name: "SimplePropertyಠ_ಠ", type: CorrelationPropertyType.String ) ); var execute = new TestDelegate(() => { DropAndCreate(definition, endpointName, schema); var id = Guid.NewGuid(); var result = SaveWeirdAsync(id, endpointName).GetAwaiter().GetResult(); Assert.IsNotNull(result); Approver.Verify(result, s => s.Replace(id.ToString(), "theSagaId")); }); if (SupportsUnicodeIdentifiers) { execute(); } else { Assert.Throws <Exception>(execute); } }
public void PlatformSampleSettings() { //HINT: Particular.PlatformSample includes a parameterized version of the ServiceControl.exe.config file. //If any changes have been made to settings, this may break the embedded config in that project, which may need to be updated. Approver.Verify(new Settings()); }
public async Task ShouldNotCacheContext() { var stringWriter = new StringWriter(); var pipelineModifications = new PipelineModifications(); pipelineModifications.Additions.Add(new Behavior1.Registration(stringWriter)); pipelineModifications.Additions.Add(new Stage1.Registration(stringWriter)); pipelineModifications.Additions.Add(new Behavior2.Registration(stringWriter)); pipelineModifications.Additions.Add(new StageFork.Registration(stringWriter)); pipelineModifications.Additions.Add(new Stage2.Registration(stringWriter)); pipelineModifications.Additions.Add(new Terminator.Registration(stringWriter)); var pipeline = new Pipeline <ITransportReceiveContext>(new FakeBuilder(), pipelineModifications); stringWriter.WriteLine("Run 1"); var context = new TestableTransportReceiveContext(); context.Extensions.Set <IPipelineCache>(new FakePipelineCache()); context.Extensions.Set(ExtendableExtensions.RunSpecificKey, 1); await pipeline.Invoke(context); stringWriter.WriteLine("Run 2"); context = new TestableTransportReceiveContext(); context.Extensions.Set <IPipelineCache>(new FakePipelineCache()); context.Extensions.Set(ExtendableExtensions.RunSpecificKey, 2); await pipeline.Invoke(context); Approver.Verify(stringWriter.ToString()); }
public void Print_ShouldPrettifyEscapedStrings() { var json = @"{""PrerequisiteStatus"": {""IsSatisfied"": false, ""Reasons"": [""Because some \""escaped\"" json content""]}}"; var prettified = JsonPrettyPrinter.Print(json); Approver.Verify(prettified); }
public void Print_ShouldPrettifyJsonContent() { var json = @"{""Container"":{""Type"":""NServiceBus.CommonObjectBuilder""}}"; var prettified = JsonPrettyPrinter.Print(json); Approver.Verify(prettified); }
public static void Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter) { var normalizeLineEndingsForTextFiles = CurrentCaller.GetFirstFrameForAttribute <IgnoreLineEndingsAttribute>(); var shouldIgnoreLineEndings = normalizeLineEndingsForTextFiles == null || normalizeLineEndingsForTextFiles.IgnoreLineEndings; Approver.Verify(new FileApprover(writer, namer, shouldIgnoreLineEndings), reporter); }
public void Should_have_all_relevant_extraction_apis_exposed() { var transactionInformationConfigurationMethods = typeof(TransactionInformationConfiguration) .GetMethods(BindingFlags.Public | BindingFlags.Instance) .Where(m => m.Name.StartsWith("Extract")) .OrderBy(m => m.Name) .ThenBy(m => m.GetParameters().Length) .Select(m => m.ToString()); var containerInformationExtractorMethods = typeof(ContainerInformationExtractor) .GetMethods(BindingFlags.Public | BindingFlags.Instance) .Where(m => m.Name.StartsWith("Extract")) .OrderBy(m => m.Name) .ThenBy(m => m.GetParameters().Length) .Select(m => m.ToString()); var partitionKeyExtractorMethods = typeof(PartitionKeyExtractor) .GetMethods(BindingFlags.Public | BindingFlags.Instance) .Where(m => m.Name.StartsWith("Extract")) .OrderBy(m => m.Name) .ThenBy(m => m.GetParameters().Length) .Select(m => m.ToString()); // represents the missing extraction methods in the TransactionInformationConfiguration object var methodInfos = containerInformationExtractorMethods.Union(partitionKeyExtractorMethods).Except(transactionInformationConfigurationMethods) .Distinct() .ToArray(); Approver.Verify(methodInfos.Length == 0 ? "Represents the missing extraction methods in the TransactionInformationConfiguration object and should remain empty" : string.Join(Environment.NewLine, methodInfos)); }
public void ToSerializable() { var operations = new List <TransportOperation> { new TransportOperation( messageId: "Id1", properties: new DispatchProperties(new Dictionary <string, string> { { "OptionKey1", "OptionValue1" } }), body: new byte[] { 0x20, 0x21 }, headers: new Dictionary <string, string> { { "HeaderKey1", "HeaderValue1" } } ) }; var serializableOperations = operations.ToSerializable(); Approver.Verify(serializableOperations); }
public void IntegrationTest() { var testDirectory = TestContext.CurrentContext.TestDirectory; var temp = Path.Combine(testDirectory, "InnerTaskTemp"); if (!Directory.Exists(temp)) { return; } Directory.Delete(temp, true); var intermediatePath = Path.Combine(temp, "IntermediatePath"); Directory.CreateDirectory(temp); Directory.CreateDirectory(intermediatePath); var innerTask = new InnerTask( assemblyPath: Path.Combine(testDirectory, "ScriptBuilderTask.Tests.Target.dll"), intermediateDirectory: intermediatePath, projectDirectory: "TheProjectDir", solutionDirectory: Path.Combine(temp, "PromotePath"), logError: (error, s1) => throw new Exception(error)); innerTask.Execute(); var files = Directory.EnumerateFiles(temp, "*.*", SearchOption.AllDirectories).Select(s => s.Replace(temp, "temp")).ToList(); Assert.IsNotEmpty(files); Approver.Verify(files); }
public void UpdateWithTransitional() { var endpointName = nameof(UpdateWithTransitional); var definition = new SagaDefinition( tableSuffix: "CorrAndTransitionalSaga", name: "CorrAndTransitionalSaga", correlationProperty: new CorrelationProperty ( name: "CorrelationProperty", type: CorrelationPropertyType.String ), transitionalCorrelationProperty: new CorrelationProperty ( name: "TransitionalCorrelationProperty", type: CorrelationPropertyType.String ) ); DropAndCreate(definition, endpointName, schema); var id = Guid.NewGuid(); var sagaData1 = new CorrAndTransitionalSaga.SagaData { Id = id, CorrelationProperty = "theCorrelationProperty", TransitionalCorrelationProperty = "theTransitionalCorrelationProperty", OriginalMessageId = "theOriginalMessageId", Originator = "theOriginator", SimpleProperty = "PropertyValue" }; var persister = SetUp(endpointName, schema); using (var connection = dbConnection()) using (var transaction = connection.BeginTransaction()) using (var storageSession = new StorageSession(connection, transaction, true, null)) { persister.Save(sagaData1, storageSession, "theProperty").GetAwaiter().GetResult(); storageSession.CompleteAsync().GetAwaiter().GetResult(); } using (var connection = dbConnection()) using (var transaction = connection.BeginTransaction()) using (var storageSession = new StorageSession(connection, transaction, true, null)) { var sagaData = persister.Get <CorrAndTransitionalSaga.SagaData>(id, storageSession).GetAwaiter().GetResult(); sagaData.Data.SimpleProperty = "UpdatedValue"; persister.Update(sagaData.Data, storageSession, sagaData.Version).GetAwaiter().GetResult(); storageSession.CompleteAsync().GetAwaiter().GetResult(); } using (var connection = dbConnection()) using (var transaction = connection.BeginTransaction()) using (var storageSession = new StorageSession(connection, transaction, true, null)) { var sagaData = persister.Get <CorrAndTransitionalSaga.SagaData>(id, storageSession).GetAwaiter().GetResult(); Assert.IsNotNull(sagaData); Approver.Verify(sagaData, s => s.Replace(id.ToString(), "theSagaId")); Assert.AreEqual(2, sagaData.Version); } }
private void SetPrimary(Approver appr, bool isPrimary) { var query = Session.Query <Approver>().Where(x => x.ClientID == appr.ClientID); if (isPrimary) { foreach (Approver item in query) { if (item.ApproverID == appr.ApproverID) { item.IsPrimary = true; } else { item.IsPrimary = false; } Session.Update(item); } } else { appr.IsPrimary = false; Session.Update(appr); } }
public async Task SubmitApproval(Leave leave) { var approver = _personDomainService.FindNextApprover( leave.Approver.PersonId, leave.LeaderMaxLevel); await _leaveDomainService.SubmitApproval(leave, Approver.FromPerson(approver)); }
public async Task Make_sure_things_are_in_DI() { await Scenario.Define <Context>() .WithEndpoint <StartedEndpoint>(b => b.When(e => e.SendLocal(new SomeMessage()))) .Done(c => c.GotTheMessage) .Run(); var builder = new StringBuilder(); var coreComponents = spyContainer.RegisteredComponents.Values .Where(c => c.Type.Assembly == typeof(IMessage).Assembly) .OrderBy(c => c.Type.FullName) .ToList(); builder.AppendLine("----------- Used registrations (Find ways to stop accessing them)-----------"); foreach (var component in coreComponents.Where(c => c.WasResolved)) { builder.AppendLine(component.ToString()); } builder.AppendLine("----------- Registrations not used by the core, can be removed in next major if downstreams have been confirmed to not use it -----------"); foreach (var component in coreComponents.Where(c => !c.WasResolved)) { builder.AppendLine(component.ToString()); } Approver.Verify(builder.ToString()); }
public ActionResult GetStaffByFL(ApproverModel model) { ApproverModel approver = new ApproverModel(); string viewName = "CreateApprover"; if (!model.Id.Equals(Guid.Empty)) { Approver entityApprover = staffService.GetApproverById(model.Id); approver = ApproverExtension.ToModel(entityApprover); viewName = "EditApprover"; } UserSession.CurrentSession.ProjectDonorId = (Guid)model.ProjectDonorId; List <FinanceLimit> financeLimits = budgetService.GetFinanceLimits(countryProg.Id); Guid flId = model.FinancialLimitId != null ? (Guid)model.FinancialLimitId : Guid.Empty; List <StaffView> staffList = (model.ActivityCode != NotificationHelper.grnCode && model.ActivityCode != NotificationHelper.wrnCode) ? staffService.GetStaffByFinanceLimit(flId, countryProg.Id) : staffService.GetStaffByCountryProgramme(countryProg.Id); approver.FinancialLimitId = model.FinancialLimitId; approver.ActivityCode = model.ActivityCode; approver.ActionType = model.ActionType; approver.ActionTypes = new SelectList(SCMS.CoreBusinessLogic.NotificationsManager.NotificationHelper.GetActionType(model.ActivityCode), "Name", "Name"); approver.FinancialLimits = new SelectList(financeLimits, "Id", "Name", model.FinancialLimitId); approver.SystemUsers = new SelectList(staffList, "Id", "StaffName"); approver.DocumentTypes = new SelectList(SCMS.CoreBusinessLogic.NotificationsManager.NotificationHelper.GetDocumentTypes4Project(), "DocumentCode", "DocumentName"); ViewBag.Unlimited = FinanceLimitUlimited(flId, financeLimits); return(View(viewName, approver)); }
public void GetSubscribers() { var timeoutCommands = SubscriptionCommandBuilder.Build(sqlDialect, "TheTablePrefix"); // TODO: Not much point validating a type name Approver.Verify(timeoutCommands.GetSubscribers.ToString(), scenario: GetType().Name); }
public void GetNextChunk() { var startSlice = new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc); var timeout1Time = startSlice.AddSeconds(1); var timeout2Time = goodUtcNowValue.AddSeconds(10); var timeout1 = new TimeoutData { Destination = "theDestination", State = new byte[] { 1 }, Time = timeout1Time, Headers = new Dictionary <string, string>() }; var timeout2 = new TimeoutData { Destination = "theDestination", State = new byte[] { 1 }, Time = timeout2Time, Headers = new Dictionary <string, string>() }; var persister = Setup(schema); persister.Add(timeout1, null).Await(); persister.Add(timeout2, null).Await(); var nextChunk = persister.GetNextChunk(startSlice).Result; Assert.That(nextChunk.NextTimeToQuery, Is.EqualTo(timeout2Time).Within(TimeSpan.FromSeconds(1))); Assert.IsNotNull(nextChunk); Assert.AreEqual(DateTimeKind.Utc, nextChunk.NextTimeToQuery.Kind); Approver.Verify(nextChunk, s => s.Replace(timeout1.Id, "theId")); }
public void WithTransitionalAndNoCorrelation() { var errorsException = Assert.Throws <ErrorsException>(() => SagaDefinitionValidator.ValidateSagaDefinition(null, "saga1", "Transitional", "tableSuffix")); Assert.IsNotNull(errorsException.Message); Approver.Verify(errorsException.Message); }
private void TestSagaDefinition <TSagaType>(ModuleDefinition moduleToUse = null) { moduleToUse = moduleToUse ?? module; var dataType = moduleToUse.GetTypeDefinition <TSagaType>(); var instructions = InstructionAnalyzer.GetConfigureHowToFindSagaInstructions(dataType); var results = new SagaInspectionResults { HasUnmanagedCalls = InstructionAnalyzer.CallsUnmanagedMethods(instructions), HasUnexpectedCalls = InstructionAnalyzer.CallsUnexpectedMethods(instructions), HasBranchingLogic = InstructionAnalyzer.ContainsBranchingLogic(instructions) }; try { SagaDefinitionReader.TryGetSagaDefinition(dataType, out results.SagaDefinition); } catch (Exception x) { results.Exception = x.Message; } Approver.Verify(results); }
public override void MakeLeaveDayRequest(DayStatus dayStatus) { var leaveDay = new LeaveDay(dayStatus, this); History.Add(leaveDay.DeepClone()); Approver.Approve(leaveDay); }
public void Print_ShouldPrettifyCollections() { var json = @"{""Dependencies"":[""RootFeature"",""DelayedDeliveryFeature""],""StartupTasks"":[]}"; var prettified = JsonPrettyPrinter.Print(json); Approver.Verify(prettified); }
public void SetSuccessor(Approver successor) { this.Successor = successor; }
public void SetSuccessor(Approver approver) { this.Successor = approver; }