//{PREFIX}-{POD_TYPE}{RETRO_TYPE}-{RETRO_ID}-{TRACK}-{POD_ID} public ProductionCode deconstructProdCode(string prodCodeStr) { ProductionCode prodCode = new ProductionCode(); string[] prodCodeArr = prodCodeStr.Split('-'); if (prodCodeArr.Length == 5) { prodCode.PREFIX = prodCodeArr[0]; prodCode.retro_id = int.Parse(prodCodeArr[2]); prodCode.track = int.Parse(prodCodeArr[3]); prodCode.pod_id = int.Parse(prodCodeArr[4]); //deconstruct type reference if (prodCodeArr[1].Length == 2) { prodCode.pod_type = prodCodeArr[1][0].ToString(); prodCode.retro_type = prodCodeArr[1][1].ToString(); } else { prodCode.pod_type = prodCodeArr[1].Substring(0, 2); prodCode.retro_type = prodCodeArr[1][2].ToString(); } return(prodCode); } return(null); }
//{PREFIX}-{POD_TYPE}{RETRO_TYPE}-{RETRO_ID}-{TRACK}-{POD_ID} public string assignNewPodId(string prodCodeStr, int newPodId) { ProductionCode prodCode = new ProductionCode(); prodCode = deconstructProdCode(prodCodeStr); prodCode.pod_id = newPodId; return(prodCode.ToString()); }
public string assignNewTrack(string prodCodeStr, int newTrack) { ProductionCode prodCode = new ProductionCode(); prodCode = deconstructProdCode(prodCodeStr); prodCode.track = newTrack; return(prodCode.ToString()); }
public string assignNewRetroType(string prodCodeStr, string newRetroTypeCode) { ProductionCode prodCode = new ProductionCode(); prodCode = deconstructProdCode(prodCodeStr); prodCode.retro_type = newRetroTypeCode; return(prodCode.ToString()); }
public async Task TestAB() { //create sequencer ISequencerUC sequencer = SequencerUC.Construct(); //create production code ProductionCode worker = new ProductionCode(sequencer); //register production code sequencer event spots //strategy, one production code event is translated to one unit test code event sequencer .Register(ProductionCode.SequencingEnumTest.SpotBegin, new StrategyOneOnOneUC()) .Register(ProductionCode.SequencingEnumTest.SpotEnd, new StrategyOneOnOneUC()) ; //start concurrent tasks Task.Run(() => { worker.Worker("A"); }); Task.Run(() => { worker.Worker("B"); }); //await two production code events IProductionPointUC taskWorkerBegin1 = await worker.Sequencer.TestPointAsync(ProductionCode.SequencingEnumTest.SpotBegin); IProductionPointUC taskWorkerBegin2 = await worker.Sequencer.TestPointAsync(ProductionCode.SequencingEnumTest.SpotBegin); IProductionPointUC taskWorkerBeginA; IProductionPointUC taskWorkerBeginB; //detect which event is which taskWorkerBeginA = (string)taskWorkerBegin1.ProductionArg == "A" ? taskWorkerBegin1 : null; taskWorkerBeginA = (string)taskWorkerBegin2.ProductionArg == "A" ? taskWorkerBegin2 : taskWorkerBeginA; //detect which event is which taskWorkerBeginB = (string)taskWorkerBegin1.ProductionArg == "B" ? taskWorkerBegin1 : null; taskWorkerBeginB = (string)taskWorkerBegin2.ProductionArg == "B" ? taskWorkerBegin2 : taskWorkerBeginB; //decide about the order of execution taskWorkerBeginA.Complete("A runs first"); //await A to run to SpotB IProductionPointUC taskWorkerEndA = await worker.Sequencer.TestPointAsync(ProductionCode.SequencingEnumTest.SpotEnd); //decide about the order of execution taskWorkerBeginB.Complete("B runs second"); IProductionPointUC taskWorkerEndB = await worker.Sequencer.TestPointAsync(ProductionCode.SequencingEnumTest.SpotEnd); taskWorkerEndA.Complete("A continue"); taskWorkerEndB.Complete("B continue"); }
public string incTrackFromProdCode(string prodCodeStr) { ProductionCode prodCode = deconstructProdCode(prodCodeStr); int track = -1; try { ++prodCode.track; return(prodCode.ToString()); } catch (Exception) { return(""); } }
public static async Task LoadCoupons(int allotCoupons = 100) { var lastPoint = GetCheckPoint(); //get all codes not in production var availCoupons = _context.CouponRepositories .Where(c => c.InProduction == false) .Count(); //get all code in the repository var totalRepo = _context.CouponRepositories.Count(); if (allotCoupons >= availCoupons) { await CouponCodes.Run(totalRepo, allotCoupons); } var getCodes = _context.CouponRepositories .Where(c => c.CouponRepositoryID >= (lastPoint + 1) && c.CouponRepositoryID <= (lastPoint + allotCoupons)) .ToList(); //Load Repo Code to Production //Update Repo Code Status In repository foreach (var code in getCodes) { _context = new ApplicationDbContext(); var productionCode = new ProductionCode { CouponCode = code.CouponCode }; _context.ProductionCodes.Add(productionCode); var repoCode = _context.CouponRepositories.FirstOrDefault(c => c.CouponRepositoryID == code.CouponRepositoryID); repoCode.InProduction = true; await _context.SaveChangesAsync(); } //Update Check point var lastValue = getCodes[getCodes.Count - 1]; _context.CheckPoints.Add(new CheckPoint { LastPoint = lastValue.CouponRepositoryID }); await _context.SaveChangesAsync(); }
public MyDatabase() { Entities.Movie m1 = new Entities.Movie() { Id = 1, Title = "Godfather" }; Entities.Movie m2 = new Movie.Entities.Movie() { Id = 2, Title = "Finding Nemo" }; Entities.Movie m3 = new Entities.Movie() { Id = 3, Title = "28 days later" }; Entities.Movie m4 = new Entities.Movie() { Id = 4, Title = "Scarface" }; Director d1 = new Director() { Id = 1, FirstName = "Spielberg" }; Director d2 = new Director() { Id = 2, FirstName = "Danny Boyle" }; Director d3 = new Director() { Id = 3, FirstName = "De Palma" }; Actor a1 = new Actor() { Id = 1, FirstName = "Tom Hardy" }; Actor a2 = new Actor() { Id = 2, FirstName = "Megan Fox" }; Actor a3 = new Actor() { Id = 3, FirstName = "Robert Doonie Junie" }; Actor a4 = new Actor() { Id = 4, FirstName = "Jonny Depp" }; Actor a5 = new Actor() { Id = 5, FirstName = "De Vito" }; Actor a6 = new Actor() { Id = 6, FirstName = "Fillipidis" }; Address ad1 = new Address() { Id = 1, StreetName = "Malibu" }; Address ad2 = new Address() { Id = 2, StreetName = "Miami" }; Address ad3 = new Address() { Id = 3, StreetName = "Los Angeles" }; Address ad4 = new Address() { Id = 4, StreetName = "Santa Barbara" }; Address ad5 = new Address() { Id = 5, StreetName = "Stavrokopidou 43" }; Address ad6 = new Address() { Id = 6, StreetName = "Omonoia" }; Address ad7 = new Address() { Id = 7, StreetName = "Biktoria" }; Address ad8 = new Address() { Id = 8, StreetName = "Monastiraki" }; ProductionCode p1 = new ProductionCode() { Id = 1, Code = "AT-23482764" }; ProductionCode p2 = new ProductionCode() { Id = 2, Code = "FR-56456SDF" }; ProductionCode p3 = new ProductionCode() { Id = 3, Code = "GF-344543DD" }; ProductionCode p4 = new ProductionCode() { Id = 4, Code = "FG-45645564" }; //============Assign Directors to Movies m1.Director = d1; d1.Movies.Add(m1); m2.Director = d1; d1.Movies.Add(m2); m3.Director = d2; d2.Movies.Add(m3); m4.Director = d3; d3.Movies.Add(m4); //============Assign Actors to Movies m1.Actors.Add(a1); m1.Actors.Add(a2); m1.Actors.Add(a3); a1.Movies.Add(m1); a1.Movies.Add(m2); a1.Movies.Add(m3); m2.Actors.Add(a4); m2.Actors.Add(a5); m2.Actors.Add(a6); a4.Movies.Add(m2); a5.Movies.Add(m2); a6.Movies.Add(m2); //============Assign ProductionCode to Movie m1.ProductionCode = p1; p1.Movie = m1; m2.ProductionCode = p2; p2.Movie = m2; m3.ProductionCode = p3; p3.Movie = m3; m4.ProductionCode = p4; p4.Movie = m4; //============Assign Addresses to Actors a1.Addresses.Add(ad1); a1.Addresses.Add(ad2); a1.Addresses.Add(ad3); ad1.Actor = a1; ad2.Actor = a2; ad3.Actor = a3; a2.Addresses.Add(ad4); ad4.Actor = a2; a3.Addresses.Add(ad5); ad5.Actor = a3; a4.Addresses.Add(ad6); ad6.Actor = a4; a5.Addresses.Add(ad7); ad7.Actor = a5; a6.Addresses.Add(ad8); ad8.Actor = a6; Movies.Add(m1); Movies.Add(m2); Movies.Add(m3); Movies.Add(m4); Directors.Add(d1); Directors.Add(d2); Directors.Add(d3); Actors.Add(a1); Actors.Add(a2); Actors.Add(a3); Actors.Add(a4); Actors.Add(a5); Actors.Add(a6); Addresses.Add(ad1); Addresses.Add(ad2); Addresses.Add(ad3); Addresses.Add(ad4); Addresses.Add(ad5); Addresses.Add(ad6); Addresses.Add(ad7); Addresses.Add(ad8); ProductionCodes.Add(p1); ProductionCodes.Add(p2); ProductionCodes.Add(p3); ProductionCodes.Add(p4); }
protected override void Seed(Bollywood.Database.Mydatabase context) { //==============Create ProductionCode ProductionCode c1 = new ProductionCode() { Number = "AT-12345" }; ProductionCode c2 = new ProductionCode() { Number = "BF-55555" }; ProductionCode c3 = new ProductionCode() { Number = "JP-34567" }; //==============Create Genres Genre g1 = new Genre() { Kind = "Action" }; Genre g2 = new Genre() { Kind = "Drama" }; Genre g3 = new Genre() { Kind = "Comedy" }; //==============Create Directors Director d1 = new Director() { FirstName = "Pedro", LastName = "Almodovar", Country = Country.Spain, PhotoUrl = "#", DateOfBirth = new DateTime(1960, 6, 12) }; Director d2 = new Director() { FirstName = "Quentin", LastName = "Tarantino", Country = Country.America, PhotoUrl = "#", DateOfBirth = new DateTime(1980, 9, 12) }; Director d3 = new Director() { FirstName = "Steven", LastName = "Spielberg", Country = Country.America, PhotoUrl = "#", DateOfBirth = new DateTime(1946, 12, 18) }; //==============Create Actors Actor a1 = new Actor() { FirstName = "Brad", LastName = "Pitt", DateOfBirth = new DateTime(1963, 12, 18), PhotoUrl = "#", Country = Country.America, Telephone = "6958451236", Salary = 46000 }; Actor a2 = new Actor() { FirstName = "Thanasis", LastName = "Veggos", DateOfBirth = new DateTime(1927, 5, 7), PhotoUrl = "#", Country = Country.Greece, Telephone = "45981652", Salary = 35000 }; Actor a3 = new Actor() { FirstName = "Hector", LastName = "Gatsos", DateOfBirth = new DateTime(1987, 4, 17), PhotoUrl = "#", Country = Country.Greece, Telephone = "123123123", Salary = 50000 }; //==============Create Movies Movie m1 = new Movie() { Title = "Avatar", Country = Country.America, Duration = 180, PhotoUrl = "#", ProductionDate = new DateTime(2009, 01, 01), Rating = 7.8, TrailerUrl = "#" }; Movie m2 = new Movie() { Title = "Julieta", Country = Country.Spain, Duration = 198, PhotoUrl = "#", ProductionDate = new DateTime(2016, 01, 01), Rating = 7.1, TrailerUrl = "#" }; Movie m3 = new Movie() { Title = "Seven", Country = Country.America, Duration = 156, PhotoUrl = "#", ProductionDate = new DateTime(1995, 01, 01), Rating = 8.6, TrailerUrl = "#" }; //==============Assign Director to Movie m1.Director = d1; m2.Director = d1; m3.Director = d2; //==============Assign Acotrs to Movie m1.Actors = new List <Actor>() { a1, a2, a3 }; m2.Actors = new List <Actor>() { a3 }; m3.Actors = new List <Actor>() { a2 }; //==============Assign Genres to Movie m1.Genres = new List <Genre>() { g1, g2 }; m2.Genres = new List <Genre>() { g2, g3 }; m3.Genres = new List <Genre>() { g3 }; //==============Assign Movies to Production Code c1.Movie = m1; c2.Movie = m2; c3.Movie = m3; //==============Adding Context Tables context.ProductionCodes.AddOrUpdate(x => x.Number, c1, c2, c3); context.Genres.AddOrUpdate(x => x.Kind, g1, g2, g3); context.Actors.AddOrUpdate(x => x.FirstName, a1, a2, a3); context.Directors.AddOrUpdate(x => x.FirstName, d1, d2, d3); context.Movies.AddOrUpdate(x => x.Title, m1, m2, m3); }