public async Task Can_delete_existing_resource() { // Arrange Performer existingPerformer = _fakers.Performer.Generate(); await _testContext.RunOnDatabaseAsync(async dbContext => { dbContext.Performers.Add(existingPerformer); await dbContext.SaveChangesAsync(); }); var requestBody = new { atomic__operations = new[] { new { op = "remove", @ref = new { type = "performers", id = existingPerformer.StringId } } } }; const string route = "/operations"; // Act (HttpResponseMessage httpResponse, string responseDocument) = await _testContext.ExecutePostAtomicAsync <string>(route, requestBody); // Assert httpResponse.Should().HaveStatusCode(HttpStatusCode.NoContent); responseDocument.Should().BeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { Performer performerInDatabase = await dbContext.Performers.FirstWithIdOrDefaultAsync(existingPerformer.Id); performerInDatabase.Should().BeNull(); }); }
private void lb_performers_SelectedIndexChanged(object sender, EventArgs e) { try { Performer perftemp = ((Performer)lb_performers.SelectedItem); if (perftemp.ImageName == "*.jpg" || perftemp.ImageName == null) { pb_performer.Image = null; } else { pb_performer.Image = Image.FromFile(perftemp.ImageName); } lb_perfs_comps.DataSource = perftemp.Compositions; Invalidate(); FPerformers.ActiveForm.Update(); } catch { } }
/// <summary> /// 获取任务节点审批人 /// </summary> /// <param name="activityId"></param> /// <returns></returns> public PerformerList GetActivityPerformers(string activityId) { IList <Participant> participants = GetActivityParticipants(activityId); PerformerList performers = new PerformerList(); if (participants.Any()) { foreach (var pp in participants) { if (pp.Type == ParticipantTypeEnum.User) { Performer pf = new Performer(); pf.UserId = pp.ID; pf.UserName = pp.Name; performers.Add(pf); } else if (pp.Type == ParticipantTypeEnum.Role) { var ps = GetPerformerByRole(pp.ID); if (ps.Any()) { performers.AddRange(ps); } } else if (pp.Type == ParticipantTypeEnum.DynRole) { IDictionary <string, object> bizData = ProcessEntity.BizData as IDictionary <string, object>; var ps = GetPerformerByDynRole(pp.ID, pp.BindField, bizData); if (ps.Any()) { performers.AddRange(ps); } } else if (pp.Type == ParticipantTypeEnum.Other) { //同其他节点审批人 PerformerList others = GetActivityPerformers(pp.ID); performers.AddRange(others); } } } return(performers); }
public void CanPerformShouldReturnFalse() { IStage stage = new Stage(); ISetController controller = new SetController(stage); ISet set = new Short("Set1"); ISong song = new Song("Song1", new System.TimeSpan(0, 1, 2)); IPerformer performer = new Performer("Pesho", 11); IInstrument instrument = new Microphone(); performer.AddInstrument(instrument); //set.AddSong(song); set.AddPerformer(performer); stage.AddSet(set); string expectedResult = "1. Set1:\r\n-- Did not perform"; string actualResult = controller.PerformSets(); Assert.AreEqual(expectedResult, actualResult); }
public void CheckPerform() { IPerformer performer = new Performer("Ivan", 23); IInstrument instrument = new Drums(); ISong song = new Song("I am a Dreamer!", new TimeSpan(0, 4, 0)); performer.AddInstrument(instrument); this.set.AddPerformer(performer); this.set.AddSong(song); this.stage.AddSet(set); this.stage.AddSong(song); this.stage.AddPerformer(performer); string actualResult = this.controller.PerformSets(); string expectedResult = "1. Test:\r\n-- 1. I am a Dreamer! (04:00)\r\n-- Set Successful"; Assert.AreEqual(actualResult, expectedResult); }
public void Establish() { _commandProcessor = new SpyCommandProcessor(); _channel = new FakeChannel(); var mapper = new MyEventMessageMapper(); var messagePump = new MessagePump <MyEvent>(_commandProcessor, mapper); messagePump.Channel = _channel; messagePump.TimeoutInMilliseconds = 5000; var @event = new MyEvent(); var message = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonConvert.SerializeObject(@event))); _channel.Add(message); _performer = new Performer(_channel, messagePump); _performerTask = _performer.Run(); _performer.Stop(); }
public void PerformSets_CanPerform_InstrumentWearsDown() { var set = new Long("Long"); set.AddSong(new Song("Wave", new TimeSpan(0, 0, 01, 01))); var performer = new Performer("Pesho", 23); var instrument = new Guitar(); performer.AddInstrument(instrument); set.AddPerformer(performer); this.stage.AddSet(set); var expected = 40; this.controller.PerformSets(); var result = instrument.Wear; Assert.AreEqual(expected, result); }
public PerformerCanStopTests() { _commandProcessor = new SpyCommandProcessor(); _channel = new FakeChannel(); var mapper = new MyEventMessageMapper(); var messagePump = new MessagePumpBlocking <MyEvent>(_commandProcessor, mapper); messagePump.Channel = _channel; messagePump.TimeoutInMilliseconds = 5000; var @event = new MyEvent(); var message = new Message(new MessageHeader(Guid.NewGuid(), "MyTopic", MessageType.MT_EVENT), new MessageBody(JsonSerializer.Serialize(@event, JsonSerialisationOptions.Options))); _channel.Enqueue(message); _performer = new Performer(_channel, messagePump); _performerTask = _performer.Run(); _performer.Stop(); }
public ActionResult Edit(Performer perf) { if (perf.Performer_Id == 0) { TempData["message"] = string.Format("Исполнитель : {0} был добавлен", perf.Company_Name); context.Performers.Add(perf); } else { TempData["message"] = string.Format("Исполнитель c ID {0} был изменен", perf.Performer_Id); } context.Entry(perf).State = perf.Performer_Id == 0 ? EntityState.Added : EntityState.Modified; context.SaveChanges(); return RedirectToAction("Index"); }
public void Play() { var performer2 = new Performer("Gosho", "Goshev", 26); stage.AddPerformer(performer); stage.AddPerformer(performer2); var songs1 = new Song("CandyShop", new TimeSpan(5, 50, 30)); stage.AddSong(song); stage.AddSong(songs1); stage.AddSongToPerformer(song.Name, performer.FullName); stage.AddSongToPerformer(songs1.Name, performer2.FullName); var message = stage.Play(); Assert.AreEqual($"2 performers played 2 songs", message); }
public void Play_ShouldWorkCorrectly() { Song song1 = new Song("You", new TimeSpan(0, 3, 24)); Song song2 = new Song("She", new TimeSpan(0, 2, 22)); Performer performer = new Performer("Fil", "Kir", 29); stage.AddSong(song1); stage.AddSong(song2); stage.AddPerformer(performer); stage.AddSongToPerformer("You", "Fil Kir"); stage.AddSongToPerformer("She", "Fil Kir"); var actual = stage.Play(); var expected = "1 performers played 2 songs"; Assert.AreEqual(actual, expected); }
public void Test2() { IStage stage = new Stage(); ISet set = new Short("Set1"); IPerformer perfomer = new Performer("Ivan", 20); perfomer.AddInstrument(new Guitar()); set.AddPerformer(perfomer); set.AddSong(new Song("Song1", new TimeSpan(0, 0, 1, 2))); stage.AddSet(set); ISetController setController = new SetController(stage); string actualResult = setController.PerformSets(); Assert.That(actualResult, Is.EqualTo("1. Set1:\r\n-- 1. Song1 (01:02)\r\n-- Set Successful")); }
public void CheckInstrument_AfterPerformance_ShouldBeWornDown() { ISet set = new Short("Seta"); IPerformer performer = new Performer("Jay-Z", 15); IInstrument instrument = new Drums(); ISong song = new Song("Vijda mu se kraq", new System.TimeSpan(00, 01, 20)); performer.AddInstrument(instrument); set.AddPerformer(performer); set.AddSong(song); this.stage.AddSet(set); this.controller.PerformSets(); var expected = 80; var actual = instrument.Wear; Assert.That(actual, Is.EqualTo(expected)); }
public async Task <IActionResult> Create(PerformersCreateViewModel model) { if (ModelState.IsValid) { var performer = new Performer() { Id = Guid.NewGuid().ToString(), Name = model.Name, Description = model.Description }; await _dbContext.Performers.AddAsync(performer); await _dbContext.SaveChangesAsync(); return(Redirect("/Performer")); } return(View(model)); }
public void Test_Play() { var performer2 = new Performer("Pepi", "Mekicov", 30); stage.AddPerformer(performer); stage.AddPerformer(performer2); var song2 = new Song("Burni Noshti", new TimeSpan(0, 2, 30)); stage.AddSong(song); stage.AddSong(song2); stage.AddSongToPerformer(song.Name, performer.FullName); stage.AddSongToPerformer(song2.Name, performer2.FullName); var message = stage.Play(); Assert.AreEqual("2 performers played 2 songs", message); }
public void WearDownShouldBeIncluded() { ISet set = new Medium("setIsLit"); IPerformer performer = new Performer("Goshaka", 13); ISong song = new Song("Tribute", new TimeSpan(0, 2, 30)); IInstrument instrument = new Guitar(); performer.AddInstrument(instrument); set.AddSong(song); set.AddPerformer(performer); stage.AddSet(set); setController.PerformSets(); setController.PerformSets(); string actualResult = setController.PerformSets(); string expectedResult = "1. setIsLit:\r\n-- Did not perform"; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void PerformSetsShouldReturnSuccessMessage() { Stage stage = new Stage(); SetController setController = new SetController(stage); Set set = new Short("WestSet"); Performer performer = new Performer("Name", 18); Song song = new Song("SongName", new TimeSpan(0, 2, 30)); Instrument instrument = new Microphone(); performer.AddInstrument(instrument); set.AddSong(song); set.AddPerformer(performer); stage.AddSet(set); string actual = setController.PerformSets(); string expected = "1. WestSet:\r\n-- 1. SongName (02:30)\r\n-- Set Successful"; Assert.AreEqual(expected, actual); }
public void TestMessageWhenSetDidNotPerform() { IPerformer performer = new Performer("Ivan", 20); ISong song = new Song("Song1", new TimeSpan(0, 1, 2)); this.stage.AddSong(song); ISet set = new Short("Set1"); set.AddPerformer(performer); set.AddSong(song); this.stage.AddSet(set); string actual = this.setController.PerformSets().Trim(); string expected = "1. Set1:" + Environment.NewLine + "-- Did not perform"; Assert.That(actual, Is.EqualTo(expected)); }
public void SetWasPerformed() { Stage stage = new Stage(); SetController sc = new SetController(stage); var set = new Short("mySet"); Performer p = new Performer("PP", 19); set.AddPerformer(p); Song s = new Song("song", new System.TimeSpan(0, 3, 0)); set.AddPerformer(p); p.AddInstrument(new Guitar()); set.AddSong(s); stage.AddSet(set); var result = sc.PerformSets(); Assert.IsTrue(result.Contains("1. mySet:")); }
public void TestOrderMultipleSong() { //Arrange string expectedEnd = "1. set:\r\n-- 1. firstSong (00:01)\r\n-- 2. secondSong (00:02)\r\n-- 3. thurdSong (00:03)\r\n-- Set Successful\r\n2. secondSet:\r\n-- Did not perform"; IStage stage = new Stage(); ISet set = new Medium("set"); IPerformer performer = new Performer("pencho", 3); performer.AddInstrument(new Guitar()); ISong firstSong = new Song("firstSong", new System.TimeSpan(0, 0, 1)); ISong secondSong = new Song("secondSong", new System.TimeSpan(0, 0, 2)); ISong thurdSong = new Song("thurdSong", new System.TimeSpan(0, 0, 3)); set.AddPerformer(performer); set.AddSong(firstSong); set.AddSong(secondSong); set.AddSong(thurdSong); ISet secondSet = new Long("secondSet"); IPerformer secondPerformer = new Performer("Mincho", 20); performer.AddInstrument(new Microphone()); ISong secondPerformerFirstSong = new Song("secondFirstSong", new System.TimeSpan(0, 0, 1)); ISong secondPerformerSecondSong = new Song("secondSecondSong", new System.TimeSpan(0, 0, 2)); secondSet.AddPerformer(secondPerformer); secondSet.AddSong(secondPerformerFirstSong); secondSet.AddSong(secondPerformerSecondSong); stage.AddSet(set); stage.AddSet(secondSet); this.controller = new SetController(stage); //Act string actual = this.controller.PerformSets(); //Assert Assert.IsTrue(actual.Contains(expectedEnd)); }
public void Test7() { try { IStage stage = new Stage(); ISet set = new Medium("MediumSet"); set.AddSong(new Song("newSong", new System.TimeSpan(0, 5, 0))); Performer peso = new Performer("Pesho", 50); set.AddPerformer(peso); stage.AddSet(set); SetController setController = new SetController(stage); string result = setController.PerformSets(); Assert.That(!result.Contains("-- Set Successful")); } catch { Assert.Fail(); } }
public async Task <IActionResult> PerformerDetailsAsync(int id, string command) { var user = await userManager.GetUserAsync(User); Performer performer = (from p in pRepo.Performers where p.Id == id select p).FirstOrDefault(); if (command == "add") { user.Favorites.Add(performer); } else if (command == "remove") { user.Favorites.Remove(performer); return(View("PerformersHome")); } return(View("Error")); }
public void TestControllerDidNotPerformSet() { var set1 = new Short("set1"); var performer = new Performer("Danny", 39); var instrument = new Guitar(); performer.AddInstrument(instrument); var song = new Song("name", new TimeSpan(0, 0, 15, 0)); var stage = new Stage(); stage.AddSet(set1); stage.AddPerformer(performer); stage.AddSong(song); var controller = new SetController(stage); var expected = "1. set1:" + Environment.NewLine + "-- Did not perform"; Assert.AreEqual(expected, controller.PerformSets()); }
public void SetControllerShouldReturnSuccessMessage() { IStage stage = new Stage(); ISetController setController = new SetController(stage); ISet set = new Short("Set1"); IPerformer performer = new Performer("Pesho", 12); performer.AddInstrument(new Guitar()); ISong song = new Song("Song", new TimeSpan(0, 2, 30)); set.AddPerformer(performer); set.AddSong(song); stage.AddSet(set); string actualResult = setController.PerformSets(); string expectedResult = "1. Set1:\r\n-- 1. Song (02:30)\r\n-- Set Successful"; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void ReturnSongsAndPerformersCount_WhenPlaying() { stage.AddPerformer(performer); stage.AddSong(song); stage.AddSongToPerformer(song.Name, performer.FullName); Song secondSong = new Song("SecondSong", timeSpan); Performer secondPerformer = new Performer("Second", "Performer", 20); stage.AddPerformer(secondPerformer); stage.AddSong(secondSong); stage.AddSongToPerformer(secondSong.Name, secondPerformer.FullName); int expectedSongsCount = 2; int expectedPerformersCount = 2; Assert.AreEqual(stage.Performers.Count, expectedPerformersCount); Assert.AreEqual(stage.Play(), $"{expectedPerformersCount} performers played {expectedSongsCount} songs"); }
public ActionResult Create(Performer comedian) { //set initial values for likes and dislikes comedian.Likes = 0; comedian.Dislikes = 0; //set a default value for picture if it's null if (comedian.PictureUrl == null) { comedian.PictureUrl = "~\\Content\\laughter.jpg"; } if (ModelState.IsValid) { db.Performers.Add(comedian); db.SaveChanges(); return RedirectToAction("Index"); } return View(comedian); }
public void Play_ReturnCorrectString() { Song song1 = new Song("S1", new TimeSpan(0, 1, 23)); Song song2 = new Song("S2", new TimeSpan(0, 2, 23)); Performer performer1 = new Performer("A", "A", 20); Performer performer2 = new Performer("B", "B", 20); stage.AddPerformer(performer1); stage.AddPerformer(performer2); stage.AddSong(song1); stage.AddSong(song2); stage.AddSongToPerformer("S1", performer1.FullName.ToString()); stage.AddSongToPerformer("S2", performer2.FullName.ToString()); int totalSongs = stage.Performers.Sum(p => p.SongList.Count); string actual = stage.Play(); string expected = "2 performers played 2 songs"; Assert.That(2, Is.EqualTo(totalSongs)); Assert.That(actual, Is.EqualTo(expected)); }
public void TestResultAfterSetsPlay() { ISet set = new Short("Set1"); IPerformer gosho = new Performer("Gosho", 20); gosho.AddInstrument(new Guitar()); set.AddPerformer(gosho); ISong song = new Song("Song1", new TimeSpan(0, 1, 2)); set.AddSong(song); IStage stage = new Stage(); stage.AddSet(set); ISetController setController = new SetController(stage); string actualResult = setController.PerformSets(); string expectedResult = "1. Set1:\r\n-- 1. Song1 (01:02)\r\n-- Set Successful"; Assert.AreEqual(actualResult, expectedResult); }
/// <summary> /// 获取审批人通过业务角色 /// </summary> /// <param name="roleId"></param> /// <returns></returns> private PerformerList GetPerformerByRole(string roleId) { PerformerList plist = new PerformerList(); DynamicParameters param = new DynamicParameters(); param.Add("RoleUid", roleId); IEnumerable <FapBizRoleEmployee> employees = _dataAccessor.QueryWhere <FapBizRoleEmployee>("BizRoleUid=@RoleUid", param, true); if (employees != null && employees.Count() > 0) { foreach (var employee in employees) { Performer pf = new Performer(); pf.UserId = employee.EmpUid; pf.UserName = employee.EmpUidMC; plist.Add(pf); } } return(plist); }
public void WornDown() { Stage stage = new Stage(); SetController sc = new SetController(stage); var set = new Short("mySet"); Performer p = new Performer("PP", 19); var g = new Guitar(); p.AddInstrument(g); Song s = new Song("song", new System.TimeSpan(0, 3, 0)); set.AddPerformer(p); set.AddSong(s); stage.AddSet(set); sc.PerformSets(); Assert.That(g.Wear < 100); }
public void PerformSetShouldDecreaseInstrumentWearDown() { AddPerformerAndSongToSet(); IInstrument instrument = new Guitar(); IPerformer performer = new Performer("Nasko", 18); performer.AddInstrument(instrument); ISong song = new Song("Song", new TimeSpan(0, 2, 20)); set.AddPerformer(performer); set.AddSong(song); double actualValue = instrument.Wear; setController.PerformSets(); double expectedValue = instrument.Wear; Assert.AreNotEqual(expectedValue, actualValue); }
public ResponseResult<List<Performer>> GetUserByRole(int id) { var result = ResponseResult<List<Performer>>.Default(); try { var performList = new List<Performer>(); var wfService = new WorkflowService(); var itemList = wfService.GetUserByRole(id).ToList(); foreach (var item in itemList) { Performer performer = new Performer(item.UserID.ToString(), item.UserName); performList.Add(performer); } result = ResponseResult<List<Performer>>.Success(performList, "成功获取流角色用户数据!"); } catch (System.Exception ex) { result = ResponseResult<List<Performer>>.Error(string.Format( "获取角色用户数据失败, 异常信息:{0}", ex.Message)); } return result; }
/// <summary> /// 退回流程 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBackward_Click(object sender, EventArgs e) { WfAppRunner appRunner = new WfAppRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "WallwaOrder"; appRunner.UserID = "1"; appRunner.UserName = "******"; //下一步执行人 PerformerList list = new PerformerList(); Performer p = new Performer("13", "andun");//下一步人ID,Name list.Add(p); Dictionary<String, PerformerList> dict = new Dictionary<String, PerformerList>(); dict.Add("fc8c71c5-8786-450e-af27-9f6a9de8560f", list); //print activity:"fc8c71c5-8786-450e-af27-9f6a9de8560f"下一步节点的标识ID appRunner.NextActivityPerformers = dict; IWorkflowService wfService = new WorkflowService(); var result = wfService.JumpProcess(appRunner); var msg = string.Format("流程跳转回退结果:{0}\r\n", result.Status); textBox1.Text += msg; }
void OnEnable() { Performer performer1 = new Performer (); p1_name.text = string.Concat ("Name: ", performer1.GetFirstName (), performer1.GetLastName ()); }
/// <summary> /// This function is used to search the events in a particular /// location based on the given parameters /// </summary> /// <param name="keywords">The search criteria</param> /// <param name="category">the category of the search criteria</param> /// <param name="date">The date as a search criteria</param> /// <param name="location">Sets the geographical point of interest for the search</param> /// <param name="within">Sets a geographical radius for the search</param> /// <param name="key">key required to call the API</param> /// <returns>JSON in string format containg all the events supplied as a result of the search</returns> public string GetEvents(string keywords, string location, string category, String within, string date, string key) { //http://api.eventful.com/rest/events/search?app_key=rPwttTPbhzGmX99K&keywords=books&location=San+Diego&date=Future String apiCall = "http://api.eventful.com/rest/events/search?app_key=" + key; string outputString = null; if (keywords != null) { apiCall = apiCall + "&keywords=" + keywords; } if (location != null) { apiCall = apiCall + "&location=" + location; } if (category != null) { apiCall = apiCall + "&category=" + category; } if (date != null) { apiCall = apiCall + "&date=" + date; } if (within != null) { apiCall = apiCall + "&within=" + within; } int count = 0; using (WebClient wc = new WebClient()) { string xml = wc.DownloadString(apiCall); XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); XmlNodeList root = doc.SelectNodes("/search/events/event"); count = root.Count; string json = JsonConvert.SerializeXmlNode(doc); JObject obj = JObject.Parse(json); int temp = 0; int tempPerformer = 0; int tempPCount = 0; Event events = null; Events eventsAll = new Events(); //http://api.eventful.com/rest/events/search?app_key=rPwttTPbhzGmX99K&keywords=rihanna&date=Future while (temp < count) { events = new Event(); //obj["search"]["events"]["event"][temp]["image"]["medium"]; events.eventID = (string)obj["search"]["events"]["event"][temp]["@id"]; events.eventTitle = (string)obj["search"]["events"]["event"][temp]["title"]; events.eventUrl = (string)obj["search"]["events"]["event"][temp]["url"]; events.eventStartTime = (string)obj["search"]["events"]["event"][temp]["start_time"]; events.eventStopTime = (string)obj["search"]["events"]["event"][temp]["stop_time"]; events.venueUrl = (string)obj["search"]["events"]["event"][temp]["venue_url"]; events.venueName = (string)obj["search"]["events"]["event"][temp]["venue_name"]; events.venueAddress = (string)obj["search"]["events"]["event"][temp]["venue_address"]; events.eventCityName = (string)obj["search"]["events"]["event"][temp]["city_name"]; events.eventState = (string)obj["search"]["events"]["event"][temp]["region_name"]; events.eventStateAbbr = (string)obj["search"]["events"]["event"][temp]["region_abbr"]; events.eventPostalCode = (string)obj["search"]["events"]["event"][temp]["postal_code"]; events.eventCountryName = (string)obj["search"]["events"]["event"][temp]["country_name"]; events.eventCountryAbbr = (string)obj["search"]["events"]["event"][temp]["country_abbr"]; events.eventLatitude = (string)obj["search"]["events"]["event"][temp]["latitude"]; events.eventLongitude = (string)obj["search"]["events"]["event"][temp]["longitude"]; JObject performerJSON = (JObject)obj["search"]["events"]["event"][temp]["performers"]; tempPCount = performerJSON.Count; while (tempPerformer < tempPCount) { Performer performer = new Performer(); performer.performerID = (string)performerJSON["performer"]["id"]; performer.performerName = (string)performerJSON["performer"]["name"]; performer.performerUrl = (string)performerJSON["performer"]["url"]; performer.performerBio = (string)performerJSON["performer"]["short_bio"]; events.performers.Add(performer); tempPerformer++; } events.eventImageUrl = (string)obj["search"]["events"]["event"][temp]["image"]["medium"]["url"]; eventsAll.events.Add(events); temp++; } outputString = JsonConvert.SerializeObject(eventsAll); } return outputString; }
/// <summary> /// 获取当前等待办理节点的任务分配人列表 /// </summary> /// <param name="runner"></param> /// <returns></returns> public IList<Performer> GetTaskPerformers(WfAppRunner runner) { var tm = new TaskManager(); var tasks = tm.GetReadyTaskOfApp(runner).ToList(); Performer performer; IList<Performer> performerList = new List<Performer>(); foreach (var task in tasks) { performer = new Performer(task.AssignedToUserID, task.AssignedToUserName); performerList.Add(performer); } return performerList; }
/// <summary> /// XML节点预定义跳转 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSkip_Click(object sender, EventArgs e) { WfAppRunner appRunner = new WfAppRunner(); appRunner.ProcessGUID = process_guid; appRunner.AppInstanceID = application_instance_id; appRunner.AppName = "WallwaOrder"; appRunner.UserID = "13"; appRunner.UserName = "******"; IWorkflowService wfService = new WorkflowService(); var nodeViewList = wfService.GetNextActivityTree(appRunner); if (nodeViewList != null && nodeViewList.Count() == 1) { var nodeView = nodeViewList[0]; if (nodeView.IsSkipTo == true) { //下一步执行人 PerformerList list = new PerformerList(); Performer p = new Performer("1", "admin");//下一步人ID,Name list.Add(p); Dictionary<String, PerformerList> dict = new Dictionary<String, PerformerList>(); dict.Add(nodeView.ActivityGUID, list); //nodeView.ID 下一步节点的标识ID appRunner.NextActivityPerformers = dict; var result = wfService.JumpProcess(appRunner); var msg = string.Format("流程跳转结果:{0}\r\n", result.Status); textBox1.Text += msg; } } }
public IDictionary<string, PerformerList> NextActivityPerformers(string nextActivityPerformers) { IDictionary<string, PerformerList> nextActivityPerformersDictionary = new Dictionary<string, PerformerList>(); string[] array = nextActivityPerformers.Split(','); foreach (string items in array) { string stepId = GetValueOfNodeIdList(items, "step"); if (!string.IsNullOrWhiteSpace(stepId) && stepId != "0") { string userId = GetValueOfNodeIdList(items, "member"); Performer performer = null; if (!string.IsNullOrWhiteSpace(userId) && userId != "0" && userId.Length > 0) { SysUserEntity userEntity = WorkFlows.GetSysUserModel(Convert.ToInt32(userId)); if (userEntity != null && userEntity.ID > 0) { performer = new Performer(userId, userEntity.UserName); } } if (performer == null) performer = new Performer("0", string.Empty); if (nextActivityPerformersDictionary.ContainsKey(stepId)) { (nextActivityPerformersDictionary[stepId]).Add(performer); } else { PerformerList pList = new PerformerList(); pList.Add(performer); nextActivityPerformersDictionary.Add(stepId, pList); } } } return nextActivityPerformersDictionary; }
/// <summary> /// 获取流程的发起人 /// </summary> /// <param name="processInstanceID"></param> /// <returns></returns> internal Performer GetProcessInitiator(int processInstanceID) { var entity = GetById(processInstanceID); Performer performer = new Performer(entity.CreatedByUserID, entity.CreatedByUserName); return performer; }
/// <summary> /// 创建子流程时,重新生成runner信息 /// </summary> /// <param name="runner"></param> /// <param name="subProcessNode"></param> /// <returns></returns> private WfAppRunner CopyActivityForwardRunner(WfAppRunner runner, Performer performer, SubProcessNode subProcessNode) { WfAppRunner subRunner = new WfAppRunner(); subRunner.AppInstanceCode = runner.AppInstanceCode; subRunner.AppInstanceID = runner.AppInstanceID; subRunner.AppName = runner.AppName; subRunner.UserID = performer.UserID; subRunner.UserName = performer.UserName; subRunner.ProcessGUID = subProcessNode.SubProcessGUID; return subRunner; }
public static unsafe void Main(string[] args) { TrinityConfig.CurrentRunningMode = RunningMode.Embedded; // Characters Character Rachel = new Character(Name: "Rachel Green", Gender: 0, Married: true); Character Monica = new Character(Name: "Monica Geller", Gender: 0, Married: true); Character Phoebe = new Character(Name: "Phoebe Buffay", Gender: 0, Married: true); Character Joey = new Character(Name: "Joey Tribbiani", Gender: 1, Married: false); Character Chandler = new Character(Name: "Chandler Bing", Gender: 1, Married: true); Character Ross = new Character(Name: "Ross Geller", Gender: 1, Married: true); // Performers Performer Jennifer = new Performer(Name: "Jennifer Aniston", Age: 43, Characters: new List<long>()); Performer Courteney = new Performer(Name: "Courteney Cox", Age: 43, Characters: new List<long>()); Performer Lisa = new Performer(Name: "Lisa Kudrow", Age: 43, Characters: new List<long>()); Performer Matt = new Performer(Name: "Matt Le Blanc", Age: 43, Characters: new List<long>()); Performer Matthew = new Performer(Name: "Matthew Perry", Age: 43, Characters: new List<long>()); Performer David = new Performer(Name: "David Schwimmer", Age: 43, Characters: new List<long>()); // Portrayal Relationship Rachel.Performer = Jennifer.CellID; Jennifer.Characters.Add(Rachel.CellID); Monica.Performer = Courteney.CellID; Courteney.Characters.Add(Monica.CellID); Phoebe.Performer = Lisa.CellID; Lisa.Characters.Add(Phoebe.CellID); Joey.Performer = Matt.CellID; Matt.Characters.Add(Joey.CellID); Chandler.Performer = Matthew.CellID; Matthew.Characters.Add(Chandler.CellID); Ross.Performer = David.CellID; David.Characters.Add(Ross.CellID); // Marriage relationship Monica.Spouse = Chandler.CellID; Chandler.Spouse = Monica.CellID; Rachel.Spouse = Ross.CellID; Ross.Spouse = Rachel.CellID; // Friendship Friendship friend_ship = new Friendship(new List<long>()); friend_ship.friends.Add(Rachel.CellID); friend_ship.friends.Add(Monica.CellID); friend_ship.friends.Add(Phoebe.CellID); friend_ship.friends.Add(Joey.CellID); friend_ship.friends.Add(Chandler.CellID); friend_ship.friends.Add(Ross.CellID); // Save Runtime cells to Trinity memory storage Global.LocalStorage.SavePerformer(Jennifer); Global.LocalStorage.SavePerformer(Courteney); Global.LocalStorage.SavePerformer(Lisa); Global.LocalStorage.SavePerformer(Matt); Global.LocalStorage.SavePerformer(Matthew); Global.LocalStorage.SavePerformer(David); Global.LocalStorage.SaveCharacter(Rachel); Global.LocalStorage.SaveCharacter(Monica); Global.LocalStorage.SaveCharacter(Phoebe); Global.LocalStorage.SaveCharacter(Joey); Global.LocalStorage.SaveCharacter(Chandler); Global.LocalStorage.SaveCharacter(Ross); // Dump memory storage to disk for persistence Global.LocalStorage.SaveStorage(); long spouse_id = -1; using (var cm = Global.LocalStorage.UseCharacter(Monica.CellID)) { if (cm.Married) spouse_id = cm.Spouse; } using (var cm = Global.LocalStorage.UseCharacter(spouse_id)) { Console.WriteLine(cm.Name); } }
public static Performer CreatePerformer(int performerId, string name) { Performer performer = new Performer(); performer.PerformerId = performerId; performer.Name = name; return performer; }
/// <summary> /// 插入任务数据 /// </summary> /// <param name="activityInstance"></param> /// <param name="performer"></param> /// <param name="runner"></param> /// <param name="session"></param> internal void Insert(ActivityInstanceEntity activityInstance, Performer performer, WfAppRunner runner, IDbSession session) { Insert(activityInstance, performer.UserID, performer.UserName, runner.UserID, runner.UserName, session); }
/// <summary> /// 创建加签节点记录 /// </summary> /// <param name="activityResource"></param> private void CreateSignForwardTasks(ActivityResource activityResource) { SignForwardTypeEnum signForwardType = (SignForwardTypeEnum)Enum.Parse(typeof(SignForwardTypeEnum), base.ActivityForwardContext.ActivityResource.DynamicVariables["SignForwardType"]); //根据当前活动实例的记录为加签发起人创建一条新的记录,并修改CompleteOrder var newActivityInstance = base.ActivityInstanceManager.CreateActivityInstanceObject(base.ActivityForwardContext.FromActivityInstance); newActivityInstance.AssignedToUserIDs = activityResource.AppRunner.UserID; newActivityInstance.AssignedToUserNames = activityResource.AppRunner.UserName; newActivityInstance.MIHostActivityInstanceID = base.ActivityForwardContext.FromActivityInstance.ID; newActivityInstance.SignForwardType = (short)signForwardType; if (signForwardType == SignForwardTypeEnum.SignForwardParallel) { if (base.ActivityForwardContext.ActivityResource.DynamicVariables.ContainsKey("SignForwardCompleteOrder")) newActivityInstance.CompleteOrder = float.Parse(base.ActivityForwardContext.ActivityResource.DynamicVariables["SignForwardCompleteOrder"]); else newActivityInstance.CompleteOrder = 1; } newActivityInstance.ComplexType = (short)ComplexTypeEnum.SignForward; //获取加签人集合 var plist = activityResource.NextActivityPerformers[base.ActivityForwardContext.Activity.ActivityGUID]; //前加签是别人先审核,然后自己再审核 if (signForwardType == SignForwardTypeEnum.SignForwardBefore) { newActivityInstance.CompleteOrder = plist.Count + 1; newActivityInstance.ActivityState = (short)ActivityStateEnum.Suspended; } else if (signForwardType == SignForwardTypeEnum.SignForwardBehind) { //后加签是自己审批后,其他接收人再加签 newActivityInstance.CompleteOrder = 1; } //主节点挂起后,插入当前人的加签记录信息, 并插入任务记录 base.ActivityInstanceManager.Insert(newActivityInstance, base.Session); var signer = new Performer(base.ActivityForwardContext.ActivityResource.AppRunner.UserID, base.ActivityForwardContext.ActivityResource.AppRunner.UserName); base.TaskManager.Insert(newActivityInstance, signer, base.ActivityForwardContext.ActivityResource.AppRunner, base.Session); //创建新加签节点记录 var signforwardActivityInstance = new ActivityInstanceEntity(); for (var i = 0; i < plist.Count; i++) { signforwardActivityInstance = base.ActivityInstanceManager.CreateActivityInstanceObject(base.ActivityForwardContext.FromActivityInstance); signforwardActivityInstance.ComplexType = (short)ComplexTypeEnum.SignForward; signforwardActivityInstance.AssignedToUserIDs = plist[i].UserID; signforwardActivityInstance.AssignedToUserNames = plist[i].UserName; signforwardActivityInstance.MIHostActivityInstanceID = base.ActivityForwardContext.FromActivityInstance.ID; if (signForwardType == SignForwardTypeEnum.SignForwardBefore) { signforwardActivityInstance.CompleteOrder = (short)(i + 1); if (i > 0) { //加签是串行加签,逐次完成 signforwardActivityInstance.ActivityState = (short)ActivityStateEnum.Suspended; } } else if (signForwardType == SignForwardTypeEnum.SignForwardBehind) { signforwardActivityInstance.CompleteOrder = (short)(i + 2); signforwardActivityInstance.ActivityState = (short)ActivityStateEnum.Suspended; } signforwardActivityInstance.SignForwardType = (short)signForwardType; base.ActivityInstanceManager.Insert(signforwardActivityInstance, base.Session); base.TaskManager.Insert(signforwardActivityInstance, plist[i], activityResource.AppRunner, base.Session); } }
public void AddToPerformers(Performer performer) { base.AddObject("Performers", performer); }