private static void BookCheckSeats(DayPart part) { List <string> checkBook = new List <string>(0); for (int i = 1; i < cListRow - 1; ++i) { for (int j = 1; j < cListCol - 1; ++j) { if (part == DayPart.Part1) { string str = BookAndCheckSeatDay1(i, j); if (str != "") { checkBook.Add(str); } } if (part == DayPart.Part2) { string str = BookAndCheckSeatDay2(i, j); if (str != "") { checkBook.Add(str); } } } } for (int t = 0; t < checkBook.Count; t++) { char a = checkBook[t].Split(',')[0].ToCharArray()[0]; int r = int.Parse(checkBook[t].Split(',')[1]); int c = int.Parse(checkBook[t].Split(',')[2]); cSeatArray[r, c] = a; } }
public void SetDayPart(DayPart daypart) { switch (daypart) { case DayPart.NIGHT: RenderSettings.skybox = skyboxNight; this.SetLights(lightIntensityNight); break; case DayPart.MORNING: RenderSettings.skybox = skyboxMorning; this.SetLights(lightIntensityMorning); break; case DayPart.AFTERNOON: RenderSettings.skybox = skyboxAfternoon; this.SetLights(lightIntensityAfternoon); break; case DayPart.EVENING: RenderSettings.skybox = skyboxEvening; this.SetLights(lightIntensityEvening); break; } }
private Engineer GetAvailableEngineer( BauDbContext ctx, DateTime currentDate, DayPart dayPart) { // rule 1 and 2 var excludedEngineerIds = GetExcludedEngineerIds(ctx, currentDate); // First get not used engineers for period of time containing WORKING DAYS // where NUMBER OF WORKING DAYS is equal the number of engineers divided by 2. // Otherwise we could fill every two weeks by only 10 engineers. var availableEngineerIds = GetNotUsedEngineerIdList(ctx, currentDate) .Except(excludedEngineerIds); // rule one & two // then get engineers from opposite dayPart in order to fulfill the second part of the day within two weeks // rule 3 if (availableEngineerIds.Count() == 0) { availableEngineerIds = GetEngineerIdListForPreviousPeriodForOppositeDayPart(ctx, currentDate, dayPart) .Except(excludedEngineerIds); // rule one, two } return(ctx.Engineers .Where(e => availableEngineerIds.Contains(e.Id)) .OrderBy(e => Guid.NewGuid()) // trick: randomization .FirstOrDefault()); }
public void GetDayPartByDowAndTimeString_ShouldReturnDayPart() { //Arrange var expected = new DayPart { DayPartName = "2100-2359(Mon-Fri)", Timeslices = new List <Timeslice> { new Timeslice { DowPattern = new List <string> { "Mon", "Tue", "Wed", "Thu", "Fri" }, FromTime = "21:00", ToTime = "23:59" } } }; //Act var result = KPICalculationHelpers.GetDayPartByDowTimeString(_dayParts, expected.DayPartName); //Assert Assert.IsTrue(result.DayPartName == expected.DayPartName); }
public void GetDayPartByDowAndTimeStringAndOnlyOneDow_ShouldReturnDayPart() { //Arrange var expected = new DayPart { DayPartName = "1000-1259(Mon-Mon)", Timeslices = new List <Timeslice> { new Timeslice { DowPattern = new List <string> { "Mon" }, FromTime = "10:00", ToTime = "12:59" } } }; //Act var result = KPICalculationHelpers.GetDayPartByDowTimeString(_dayParts, expected.DayPartName); //Assert Assert.IsTrue(result.DayPartName == expected.DayPartName); }
public void At_6_returns_morning() { ICurrentHourProvider current_hour_provider = CreateCurrentHourProviderReturning(6); DayPartProvider tested = new DayPartProvider(current_hour_provider); DayPart result = tested.GetDayPart(); Assert.AreEqual(DayPart.Morning, result); }
public void At_12_returns_afternoon() { ICurrentHourProvider current_hour_provider = CreateCurrentHourProviderReturning(12); DayPartProvider tested = new DayPartProvider(current_hour_provider); DayPart result = tested.GetDayPart(); Assert.AreEqual(DayPart.Afternoon, result); }
public void At_20_returns_night() { ICurrentHourProvider current_hour_provider = CreateCurrentHourProviderReturning(20); DayPartProvider tested = new DayPartProvider(current_hour_provider); DayPart result = tested.GetDayPart(); Assert.AreEqual(DayPart.Night, result); }
private static IDayPartProvider CreateDayPartProviderReturning(DayPart part) { Mock <IDayPartProvider> mock = new Mock <IDayPartProvider>(); mock.Setup(p => p.GetDayPart()).Returns(part); IDayPartProvider day_part_provider = mock.Object; return(day_part_provider); }
public void In_any_moment_it_says_bye_returning_Adios_plus_name(DayPart day_part) { var day_part_provider = CreateDayPartProviderReturning(day_part); Greeter tested = new Greeter(day_part_provider); String bye = tested.SayBye("Juan"); Assert.AreEqual("Adios Juan", bye); }
public void setDayPart(DayPart daypart) { switch (daypart) { case DayPart.NIGHT: setNightTime(); break; case DayPart.DAY: setDayTime(); break; } }
public void SetEngineer( DayPart dayPart, int engineerId, string firrstName, string lastName) { if (dayPart == DayPart.Morning) { MorningEngineer.SetEngineer(engineerId, firrstName, lastName); } else if (dayPart == DayPart.Afternoon) { AfternoonEngineer.SetEngineer(engineerId, firrstName, lastName); } }
/// <summary> /// Return the next <see cref="DayPart"/>. /// </summary> /// <param name="part">The <see cref="DayPart"/> query.</param> /// <returns>The next <see cref="DayPart"/> after the query.</returns> public static DayPart Next(this DayPart part) { switch (part) { case DayPart.MO: return(DayPart.MI); case DayPart.MI: return(DayPart.AF); case DayPart.AF: return(DayPart.EV); case DayPart.EV: return(DayPart.NI); case DayPart.NI: return(DayPart.MO); default: throw new NotImplementedException(); } }
int ICalendarPlus.HourFor(DayPart dayPart) { switch (dayPart) { case DayPart.MO: return(9); case DayPart.MI: return(12); case DayPart.AF: return(15); case DayPart.EV: return(18); case DayPart.NI: return(21); default: throw new NotImplementedException(); } }
private List <int> GetEngineerIdListForPreviousPeriodForOppositeDayPart( BauDbContext ctx, DateTime currentDate, DayPart dayPart) { var oppositeDayPart = dayPart == DayPart.Morning ? DayPart.Afternoon : DayPart.Morning; var startDate = GetStartDateForAllEnginner(ctx, currentDate); var engineerIds = ctx.PlanItems .Where(i => startDate <= i.Date && i.Date <= currentDate && i.DayPart == oppositeDayPart) .Select(i => i.EngineerId) .Distinct() .ToList(); return(engineerIds == null || engineerIds.Count == 0 ? new List <int>() : new List <int>(engineerIds)); }
private void CreatePlanItem( BauDbContext ctx, DateTime currentDate, DayPart dayPart) { var availableEngineer = GetAvailableEngineer(ctx, currentDate, dayPart); if (availableEngineer == null) { return; } var newPlanItem = new PlanItem() { Date = currentDate, DayPart = dayPart, Engineer = availableEngineer, EngineerId = availableEngineer.Id }; availableEngineer.PlanItems.Add(newPlanItem); ctx.PlanItems.Add(newPlanItem); ctx.SaveChanges(); }
/// <summary>Flattens the day part.</summary> /// <param name="dayPart">The day part.</param> /// <returns></returns> public DayPartFlattenModel FlattenDayPart(DayPart dayPart) { var dayPartFlattenModel = new DayPartFlattenModel(); if (dayPart is null) { return(dayPartFlattenModel); } dayPartFlattenModel.DaypartTimeAndDays = FlattenTimeSlices(dayPart.Timeslices); dayPartFlattenModel.DaypartTargetRatings = dayPart.DesiredPercentageSplit; dayPartFlattenModel.DaypartActualRatings = dayPart.CurrentPercentageSplit; dayPartFlattenModel.DaypartTargetActualDiff = dayPartFlattenModel.DaypartActualRatings - dayPartFlattenModel.DaypartTargetRatings; dayPartFlattenModel.DaypartTargetAchievedPct = GetDaypartTargetAchievedPct(); return(dayPartFlattenModel); decimal GetDaypartTargetAchievedPct() => Math.Round(dayPartFlattenModel.DaypartTargetRatings == 0 ? 0 : dayPartFlattenModel.DaypartActualRatings / dayPartFlattenModel.DaypartTargetRatings * 100, 2, MidpointRounding.AwayFromZero); }
public ChildAttendanceRequest(DayPart Daypart) : base(Daypart) { }
public static DayPart GetDayPart(string dayPartString) { DayPart daypart = AllDayParts.SingleOrDefault(d => d.ToString() == dayPartString); return(daypart); }
public DayTemperature(DayPart dayPart, DateTime date, int temperature) { this.dayPart = dayPart; this.date = date; this.temperature = temperature; }
/// <summary> /// Run the code examples. /// </summary> /// <param name="user">The DFP user object running the code examples.</param> public override void Run(DfpUser user) { // Get the LineItemService. LineItemService lineItemService = (LineItemService) user.GetService(DfpService.v201511.LineItemService); // Set the order that all created line items will belong to and the // placement ID to target. long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE")); long[] targetPlacementIds = new long[] {long.Parse(_T("INSERT_PLACEMENT_ID_HERE"))}; // Create inventory targeting. InventoryTargeting inventoryTargeting = new InventoryTargeting(); inventoryTargeting.targetedPlacementIds = targetPlacementIds; // Create geographical targeting. GeoTargeting geoTargeting = new GeoTargeting(); // Include the US and Quebec, Canada. Location countryLocation = new Location(); countryLocation.id = 2840L; Location regionLocation = new Location(); regionLocation.id = 20123L; geoTargeting.targetedLocations = new Location[] {countryLocation, regionLocation}; Location postalCodeLocation = new Location(); postalCodeLocation.id = 9000093; // Exclude Chicago and the New York metro area. Location cityLocation = new Location(); cityLocation.id = 1016367L; Location metroLocation = new Location(); metroLocation.id = 200501L; geoTargeting.excludedLocations = new Location[] {cityLocation, metroLocation}; // Exclude domains that are not under the network's control. UserDomainTargeting userDomainTargeting = new UserDomainTargeting(); userDomainTargeting.domains = new String[] {"usa.gov"}; userDomainTargeting.targeted = false; // Create day-part targeting. DayPartTargeting dayPartTargeting = new DayPartTargeting(); dayPartTargeting.timeZone = DeliveryTimeZone.BROWSER; // Target only the weekend in the browser's timezone. DayPart saturdayDayPart = new DayPart(); saturdayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201511.DayOfWeek.SATURDAY; saturdayDayPart.startTime = new TimeOfDay(); saturdayDayPart.startTime.hour = 0; saturdayDayPart.startTime.minute = MinuteOfHour.ZERO; saturdayDayPart.endTime = new TimeOfDay(); saturdayDayPart.endTime.hour = 24; saturdayDayPart.endTime.minute = MinuteOfHour.ZERO; DayPart sundayDayPart = new DayPart(); sundayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201511.DayOfWeek.SUNDAY; sundayDayPart.startTime = new TimeOfDay(); sundayDayPart.startTime.hour = 0; sundayDayPart.startTime.minute = MinuteOfHour.ZERO; sundayDayPart.endTime = new TimeOfDay(); sundayDayPart.endTime.hour = 24; sundayDayPart.endTime.minute = MinuteOfHour.ZERO; dayPartTargeting.dayParts = new DayPart[] {saturdayDayPart, sundayDayPart}; // Create technology targeting. TechnologyTargeting technologyTargeting = new TechnologyTargeting(); // Create browser targeting. BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.isTargeted = true; // Target just the Chrome browser. Technology browserTechnology = new Technology(); browserTechnology.id = 500072L; browserTargeting.browsers = new Technology[] {browserTechnology}; technologyTargeting.browserTargeting = browserTargeting; // Create an array to store local line item objects. LineItem[] lineItems = new LineItem[5]; for (int i = 0; i < 5; i++) { LineItem lineItem = new LineItem(); lineItem.name = "Line item #" + i; lineItem.orderId = orderId; lineItem.targeting = new Targeting(); lineItem.targeting.inventoryTargeting = inventoryTargeting; lineItem.targeting.geoTargeting = geoTargeting; lineItem.targeting.userDomainTargeting = userDomainTargeting; lineItem.targeting.dayPartTargeting = dayPartTargeting; lineItem.targeting.technologyTargeting = technologyTargeting; lineItem.lineItemType = LineItemType.STANDARD; lineItem.allowOverbook = true; // Set the creative rotation type to even. lineItem.creativeRotationType = CreativeRotationType.EVEN; // Set the size of creatives that can be associated with this line item. Size size = new Size(); size.width = 300; size.height = 250; size.isAspectRatio = false; // Create the creative placeholder. CreativePlaceholder creativePlaceholder = new CreativePlaceholder(); creativePlaceholder.size = size; lineItem.creativePlaceholders = new CreativePlaceholder[] {creativePlaceholder}; // Set the line item to run for one month. lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY; lineItem.endDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddMonths(1), "America/New_York"); // Set the cost per unit to $2. lineItem.costType = CostType.CPM; lineItem.costPerUnit = new Money(); lineItem.costPerUnit.currencyCode = "USD"; lineItem.costPerUnit.microAmount = 2000000L; // Set the number of units bought to 500,000 so that the budget is // $1,000. Goal goal = new Goal(); goal.goalType = GoalType.LIFETIME; goal.unitType = UnitType.IMPRESSIONS; goal.units = 500000L; lineItem.primaryGoal = goal; lineItems[i] = lineItem; } try { // Create the line items on the server. lineItems = lineItemService.createLineItems(lineItems); if (lineItems != null) { foreach (LineItem lineItem in lineItems) { Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and" + " named \"{2}\" was created.", lineItem.id, lineItem.orderId, lineItem.name); } } else { Console.WriteLine("No line items created."); } } catch (Exception e) { Console.WriteLine("Failed to create line items. Exception says \"{0}\"", e.Message); } }
public void addCaregiver(DayPart dayPart, Caregiver caregiver) { if (!roster.ContainsKey(dayPart)) roster[dayPart] = new Tuple<List<Caregiver>, List<Child>>(new List<Caregiver>(), new List<Child>()); roster[dayPart].Item1.Add(caregiver); }
public void TestCreateLineItems() { // Create inventory targeting. InventoryTargeting inventoryTargeting = new InventoryTargeting(); inventoryTargeting.targetedPlacementIds = new long[] {placementId}; // Create geographical targeting. GeoTargeting geoTargeting = new GeoTargeting(); // Include the US and Quebec, Canada. Location countryLocation = new Location(); countryLocation.id = 2840L; Location regionLocation = new Location(); regionLocation.id = 20123L; geoTargeting.targetedLocations = new Location[] {countryLocation, regionLocation}; // Exclude Chicago and the New York metro area. Location cityLocation = new Location(); cityLocation.id = 1016367L; Location metroLocation = new Location(); metroLocation.id = 200501L; geoTargeting.excludedLocations = new Location[] {cityLocation, metroLocation}; // Exclude domains that are not under the network's control. UserDomainTargeting userDomainTargeting = new UserDomainTargeting(); userDomainTargeting.domains = new String[] {"usa.gov"}; userDomainTargeting.targeted = false; // Create day-part targeting. DayPartTargeting dayPartTargeting = new DayPartTargeting(); dayPartTargeting.timeZone = DeliveryTimeZone.BROWSER; // Target only the weekend in the browser's timezone. DayPart saturdayDayPart = new DayPart(); saturdayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201508.DayOfWeek.SATURDAY; saturdayDayPart.startTime = new TimeOfDay(); saturdayDayPart.startTime.hour = 0; saturdayDayPart.startTime.minute = MinuteOfHour.ZERO; saturdayDayPart.endTime = new TimeOfDay(); saturdayDayPart.endTime.hour = 24; saturdayDayPart.endTime.minute = MinuteOfHour.ZERO; DayPart sundayDayPart = new DayPart(); sundayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201508.DayOfWeek.SUNDAY; sundayDayPart.startTime = new TimeOfDay(); sundayDayPart.startTime.hour = 0; sundayDayPart.startTime.minute = MinuteOfHour.ZERO; sundayDayPart.endTime = new TimeOfDay(); sundayDayPart.endTime.hour = 24; sundayDayPart.endTime.minute = MinuteOfHour.ZERO; dayPartTargeting.dayParts = new DayPart[] {saturdayDayPart, sundayDayPart}; // Create technology targeting. TechnologyTargeting technologyTargeting = new TechnologyTargeting(); // Create browser targeting. BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.isTargeted = true; // Target just the Chrome browser. Technology browserTechnology = new Technology(); browserTechnology.id = 500072L; browserTargeting.browsers = new Technology[] {browserTechnology}; technologyTargeting.browserTargeting = browserTargeting; // Create an array to store local line item objects. LineItem[] lineItems = new LineItem[2]; for (int i = 0; i < lineItems.Length; i++) { LineItem lineItem = new LineItem(); lineItem.name = "Line item #" + new TestUtils().GetTimeStamp(); lineItem.orderId = orderId; lineItem.targeting = new Targeting(); lineItem.targeting.inventoryTargeting = inventoryTargeting; lineItem.targeting.geoTargeting = geoTargeting; lineItem.targeting.userDomainTargeting = userDomainTargeting; lineItem.targeting.dayPartTargeting = dayPartTargeting; lineItem.targeting.technologyTargeting = technologyTargeting; lineItem.lineItemType = LineItemType.STANDARD; lineItem.allowOverbook = true; // Set the creative rotation type to even. lineItem.creativeRotationType = CreativeRotationType.EVEN; // Set the size of creatives that can be associated with this line item. Size size = new Size(); size.width = 300; size.height = 250; size.isAspectRatio = false; // Create the creative placeholder. CreativePlaceholder creativePlaceholder = new CreativePlaceholder(); creativePlaceholder.size = size; lineItem.creativePlaceholders = new CreativePlaceholder[] {creativePlaceholder}; // Set the line item to run for one month. lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY; lineItem.endDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddMonths(1), "America/New_York"); // Set the cost per unit to $2. lineItem.costType = CostType.CPM; lineItem.costPerUnit = new Money(); lineItem.costPerUnit.currencyCode = "USD"; lineItem.costPerUnit.microAmount = 2000000L; // Set the number of units bought to 500,000 so that the budget is // $1,000. Goal goal = new Goal(); goal.units = 500000L; goal.unitType = UnitType.IMPRESSIONS; lineItem.primaryGoal = goal; lineItems[i] = lineItem; } LineItem[] localLineItems = null; Assert.DoesNotThrow(delegate() { localLineItems = lineItemService.createLineItems(lineItems); }); Assert.NotNull(localLineItems); Assert.AreEqual(localLineItems.Length, 2); Assert.AreEqual(localLineItems[0].name, lineItems[0].name); Assert.AreEqual(localLineItems[0].orderId, lineItems[0].orderId); Assert.AreEqual(localLineItems[1].name, lineItems[1].name); Assert.AreEqual(localLineItems[1].orderId, lineItems[1].orderId); }
public List<Child> getChildren(DayPart dayPart) { if (!roster.ContainsKey(dayPart)) return new List<Child>(); return roster[dayPart].Item2; }
public void TestCreateLineItems() { // Create inventory targeting. InventoryTargeting inventoryTargeting = new InventoryTargeting(); inventoryTargeting.targetedPlacementIds = new long[] { placementId }; // Create geographical targeting. GeoTargeting geoTargeting = new GeoTargeting(); // Include the US and Quebec, Canada. Location countryLocation = new Location(); countryLocation.id = 2840L; Location regionLocation = new Location(); regionLocation.id = 20123L; geoTargeting.targetedLocations = new Location[] { countryLocation, regionLocation }; // Exclude Chicago and the New York metro area. Location cityLocation = new Location(); cityLocation.id = 1016367L; Location metroLocation = new Location(); metroLocation.id = 200501L; geoTargeting.excludedLocations = new Location[] { cityLocation, metroLocation }; // Exclude domains that are not under the network's control. UserDomainTargeting userDomainTargeting = new UserDomainTargeting(); userDomainTargeting.domains = new String[] { "usa.gov" }; userDomainTargeting.targeted = false; // Create day-part targeting. DayPartTargeting dayPartTargeting = new DayPartTargeting(); dayPartTargeting.timeZone = DeliveryTimeZone.BROWSER; // Target only the weekend in the browser's timezone. DayPart saturdayDayPart = new DayPart(); saturdayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201602.DayOfWeek.SATURDAY; saturdayDayPart.startTime = new TimeOfDay(); saturdayDayPart.startTime.hour = 0; saturdayDayPart.startTime.minute = MinuteOfHour.ZERO; saturdayDayPart.endTime = new TimeOfDay(); saturdayDayPart.endTime.hour = 24; saturdayDayPart.endTime.minute = MinuteOfHour.ZERO; DayPart sundayDayPart = new DayPart(); sundayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201602.DayOfWeek.SUNDAY; sundayDayPart.startTime = new TimeOfDay(); sundayDayPart.startTime.hour = 0; sundayDayPart.startTime.minute = MinuteOfHour.ZERO; sundayDayPart.endTime = new TimeOfDay(); sundayDayPart.endTime.hour = 24; sundayDayPart.endTime.minute = MinuteOfHour.ZERO; dayPartTargeting.dayParts = new DayPart[] { saturdayDayPart, sundayDayPart }; // Create technology targeting. TechnologyTargeting technologyTargeting = new TechnologyTargeting(); // Create browser targeting. BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.isTargeted = true; // Target just the Chrome browser. Technology browserTechnology = new Technology(); browserTechnology.id = 500072L; browserTargeting.browsers = new Technology[] { browserTechnology }; technologyTargeting.browserTargeting = browserTargeting; // Create an array to store local line item objects. LineItem[] lineItems = new LineItem[2]; for (int i = 0; i < lineItems.Length; i++) { LineItem lineItem = new LineItem(); lineItem.name = "Line item #" + new TestUtils().GetTimeStamp(); lineItem.orderId = orderId; lineItem.targeting = new Targeting(); lineItem.targeting.inventoryTargeting = inventoryTargeting; lineItem.targeting.geoTargeting = geoTargeting; lineItem.targeting.userDomainTargeting = userDomainTargeting; lineItem.targeting.dayPartTargeting = dayPartTargeting; lineItem.targeting.technologyTargeting = technologyTargeting; lineItem.lineItemType = LineItemType.STANDARD; lineItem.allowOverbook = true; // Set the creative rotation type to even. lineItem.creativeRotationType = CreativeRotationType.EVEN; // Set the size of creatives that can be associated with this line item. Size size = new Size(); size.width = 300; size.height = 250; size.isAspectRatio = false; // Create the creative placeholder. CreativePlaceholder creativePlaceholder = new CreativePlaceholder(); creativePlaceholder.size = size; lineItem.creativePlaceholders = new CreativePlaceholder[] { creativePlaceholder }; // Set the line item to run for one month. lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY; lineItem.endDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddMonths(1), "America/New_York"); // Set the cost per unit to $2. lineItem.costType = CostType.CPM; lineItem.costPerUnit = new Money(); lineItem.costPerUnit.currencyCode = "USD"; lineItem.costPerUnit.microAmount = 2000000L; // Set the number of units bought to 500,000 so that the budget is // $1,000. Goal goal = new Goal(); goal.units = 500000L; goal.unitType = UnitType.IMPRESSIONS; lineItem.primaryGoal = goal; lineItems[i] = lineItem; } LineItem[] localLineItems = null; Assert.DoesNotThrow(delegate() { localLineItems = lineItemService.createLineItems(lineItems); }); Assert.NotNull(localLineItems); Assert.AreEqual(localLineItems.Length, 2); Assert.AreEqual(localLineItems[0].name, lineItems[0].name); Assert.AreEqual(localLineItems[0].orderId, lineItems[0].orderId); Assert.AreEqual(localLineItems[1].name, lineItems[1].name); Assert.AreEqual(localLineItems[1].orderId, lineItems[1].orderId); }
public AttendanceRequest(DayPart Daypart) : this() { this.Dayparts = Daypart; }
public List<Caregiver> getCaregivers(DayPart dayPart) { if (!roster.ContainsKey(dayPart)) return new List<Caregiver>(); return roster[dayPart].Item1; }
public LineItem CreateLineItem(DfpUser user, long orderId, string adUnitId) { LineItemService lineItemService = (LineItemService)user.GetService(DfpService.v201306.LineItemService); long placementId = CreatePlacement(user, new string[] { adUnitId }).id; // Create inventory targeting. InventoryTargeting inventoryTargeting = new InventoryTargeting(); inventoryTargeting.targetedPlacementIds = new long[] { placementId }; // Create geographical targeting. GeoTargeting geoTargeting = new GeoTargeting(); // Include the US and Quebec, Canada. Location countryLocation = new Location(); countryLocation.id = 2840L; Location regionLocation = new Location(); regionLocation.id = 20123L; geoTargeting.targetedLocations = new Location[] { countryLocation, regionLocation }; // Exclude Chicago and the New York metro area. Location cityLocation = new Location(); cityLocation.id = 1016367L; Location metroLocation = new Location(); metroLocation.id = 200501L; geoTargeting.excludedLocations = new Location[] { cityLocation, metroLocation }; // Exclude domains that are not under the network's control. UserDomainTargeting userDomainTargeting = new UserDomainTargeting(); userDomainTargeting.domains = new String[] { "usa.gov" }; userDomainTargeting.targeted = false; // Create day-part targeting. DayPartTargeting dayPartTargeting = new DayPartTargeting(); dayPartTargeting.timeZone = DeliveryTimeZone.BROWSER; // Target only the weekend in the browser's timezone. DayPart saturdayDayPart = new DayPart(); saturdayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201306.DayOfWeek.SATURDAY; saturdayDayPart.startTime = new TimeOfDay(); saturdayDayPart.startTime.hour = 0; saturdayDayPart.startTime.minute = MinuteOfHour.ZERO; saturdayDayPart.endTime = new TimeOfDay(); saturdayDayPart.endTime.hour = 24; saturdayDayPart.endTime.minute = MinuteOfHour.ZERO; DayPart sundayDayPart = new DayPart(); sundayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201306.DayOfWeek.SUNDAY; sundayDayPart.startTime = new TimeOfDay(); sundayDayPart.startTime.hour = 0; sundayDayPart.startTime.minute = MinuteOfHour.ZERO; sundayDayPart.endTime = new TimeOfDay(); sundayDayPart.endTime.hour = 24; sundayDayPart.endTime.minute = MinuteOfHour.ZERO; dayPartTargeting.dayParts = new DayPart[] { saturdayDayPart, sundayDayPart }; // Create technology targeting. TechnologyTargeting technologyTargeting = new TechnologyTargeting(); // Create browser targeting. BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.isTargeted = true; // Target just the Chrome browser. Technology browserTechnology = new Technology(); browserTechnology.id = 500072L; browserTargeting.browsers = new Technology[] { browserTechnology }; technologyTargeting.browserTargeting = browserTargeting; LineItem lineItem = new LineItem(); lineItem.name = "Line item #" + new TestUtils().GetTimeStamp(); lineItem.orderId = orderId; lineItem.targeting = new Targeting(); lineItem.targeting.inventoryTargeting = inventoryTargeting; lineItem.targeting.geoTargeting = geoTargeting; lineItem.targeting.userDomainTargeting = userDomainTargeting; lineItem.targeting.dayPartTargeting = dayPartTargeting; lineItem.targeting.technologyTargeting = technologyTargeting; lineItem.lineItemType = LineItemType.STANDARD; lineItem.allowOverbook = true; // Set the creative rotation type to even. lineItem.creativeRotationType = CreativeRotationType.EVEN; // Set the size of creatives that can be associated with this line item. Size size = new Size(); size.width = 300; size.height = 250; size.isAspectRatio = false; // Create the creative placeholder. CreativePlaceholder creativePlaceholder = new CreativePlaceholder(); creativePlaceholder.size = size; lineItem.creativePlaceholders = new CreativePlaceholder[] { creativePlaceholder }; // Set the length of the line item to run. //lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY; lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY; lineItem.endDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddMonths(1)); // Set the cost per unit to $2. lineItem.costType = CostType.CPM; lineItem.costPerUnit = new Money(); lineItem.costPerUnit.currencyCode = "USD"; lineItem.costPerUnit.microAmount = 2000000L; // Set the number of units bought to 500,000 so that the budget is // $1,000. lineItem.unitsBought = 500000L; lineItem.unitType = UnitType.IMPRESSIONS; return(lineItemService.createLineItem(lineItem)); }
/// <summary> /// Run the code examples. /// </summary> public void Run(DfpUser user) { using (LineItemService lineItemService = (LineItemService)user.GetService(DfpService.v201705.LineItemService)) { // Set the order that all created line items will belong to and the // placement ID to target. long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE")); long[] targetPlacementIds = new long[] { long.Parse(_T("INSERT_PLACEMENT_ID_HERE")) }; // Create inventory targeting. InventoryTargeting inventoryTargeting = new InventoryTargeting(); inventoryTargeting.targetedPlacementIds = targetPlacementIds; // Create geographical targeting. GeoTargeting geoTargeting = new GeoTargeting(); // Include the US and Quebec, Canada. Location countryLocation = new Location(); countryLocation.id = 2840L; Location regionLocation = new Location(); regionLocation.id = 20123L; geoTargeting.targetedLocations = new Location[] { countryLocation, regionLocation }; Location postalCodeLocation = new Location(); postalCodeLocation.id = 9000093; // Exclude Chicago and the New York metro area. Location cityLocation = new Location(); cityLocation.id = 1016367L; Location metroLocation = new Location(); metroLocation.id = 200501L; geoTargeting.excludedLocations = new Location[] { cityLocation, metroLocation }; // Exclude domains that are not under the network's control. UserDomainTargeting userDomainTargeting = new UserDomainTargeting(); userDomainTargeting.domains = new String[] { "usa.gov" }; userDomainTargeting.targeted = false; // Create day-part targeting. DayPartTargeting dayPartTargeting = new DayPartTargeting(); dayPartTargeting.timeZone = DeliveryTimeZone.BROWSER; // Target only the weekend in the browser's timezone. DayPart saturdayDayPart = new DayPart(); saturdayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201705.DayOfWeek.SATURDAY; saturdayDayPart.startTime = new TimeOfDay(); saturdayDayPart.startTime.hour = 0; saturdayDayPart.startTime.minute = MinuteOfHour.ZERO; saturdayDayPart.endTime = new TimeOfDay(); saturdayDayPart.endTime.hour = 24; saturdayDayPart.endTime.minute = MinuteOfHour.ZERO; DayPart sundayDayPart = new DayPart(); sundayDayPart.dayOfWeek = Google.Api.Ads.Dfp.v201705.DayOfWeek.SUNDAY; sundayDayPart.startTime = new TimeOfDay(); sundayDayPart.startTime.hour = 0; sundayDayPart.startTime.minute = MinuteOfHour.ZERO; sundayDayPart.endTime = new TimeOfDay(); sundayDayPart.endTime.hour = 24; sundayDayPart.endTime.minute = MinuteOfHour.ZERO; dayPartTargeting.dayParts = new DayPart[] { saturdayDayPart, sundayDayPart }; // Create technology targeting. TechnologyTargeting technologyTargeting = new TechnologyTargeting(); // Create browser targeting. BrowserTargeting browserTargeting = new BrowserTargeting(); browserTargeting.isTargeted = true; // Target just the Chrome browser. Technology browserTechnology = new Technology(); browserTechnology.id = 500072L; browserTargeting.browsers = new Technology[] { browserTechnology }; technologyTargeting.browserTargeting = browserTargeting; // Create an array to store local line item objects. LineItem[] lineItems = new LineItem[5]; for (int i = 0; i < 5; i++) { LineItem lineItem = new LineItem(); lineItem.name = "Line item #" + i; lineItem.orderId = orderId; lineItem.targeting = new Targeting(); lineItem.targeting.inventoryTargeting = inventoryTargeting; lineItem.targeting.geoTargeting = geoTargeting; lineItem.targeting.userDomainTargeting = userDomainTargeting; lineItem.targeting.dayPartTargeting = dayPartTargeting; lineItem.targeting.technologyTargeting = technologyTargeting; lineItem.lineItemType = LineItemType.STANDARD; lineItem.allowOverbook = true; // Set the creative rotation type to even. lineItem.creativeRotationType = CreativeRotationType.EVEN; // Set the size of creatives that can be associated with this line item. Size size = new Size(); size.width = 300; size.height = 250; size.isAspectRatio = false; // Create the creative placeholder. CreativePlaceholder creativePlaceholder = new CreativePlaceholder(); creativePlaceholder.size = size; lineItem.creativePlaceholders = new CreativePlaceholder[] { creativePlaceholder }; // Set the line item to run for one month. lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY; lineItem.endDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddMonths(1), "America/New_York"); // Set the cost per unit to $2. lineItem.costType = CostType.CPM; lineItem.costPerUnit = new Money(); lineItem.costPerUnit.currencyCode = "USD"; lineItem.costPerUnit.microAmount = 2000000L; // Set the number of units bought to 500,000 so that the budget is // $1,000. Goal goal = new Goal(); goal.goalType = GoalType.LIFETIME; goal.unitType = UnitType.IMPRESSIONS; goal.units = 500000L; lineItem.primaryGoal = goal; lineItems[i] = lineItem; } try { // Create the line items on the server. lineItems = lineItemService.createLineItems(lineItems); if (lineItems != null) { foreach (LineItem lineItem in lineItems) { Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and" + " named \"{2}\" was created.", lineItem.id, lineItem.orderId, lineItem.name); } } else { Console.WriteLine("No line items created."); } } catch (Exception e) { Console.WriteLine("Failed to create line items. Exception says \"{0}\"", e.Message); } } }
public CaregiverAvailability(DayPart dayparts) : base(dayparts) { }