static void Main(string[] args) { Console.WriteLine("Please input your orders like '10 IMG'"); Console.WriteLine("Input 'OK' in a new line to complete"); List <string> orders = new List <string>(); string oneLine = Console.ReadLine(); while (oneLine.ToUpper() != "OK") { orders.Add(oneLine.ToUpper()); oneLine = Console.ReadLine(); } ClientOrder clientOrder = new ClientOrder(); foreach (var one in orders) { string[] strOrders = one.Split(' '); if (strOrders.Length < 2) { continue; } int posts = 0; int.TryParse(strOrders[0], out posts); if (posts > 0) { MediaOrder mediaOrder = new MediaOrder(strOrders[1].ToUpper(), posts); clientOrder.AddMediaOrder(mediaOrder); } } InitAllMediaBundleItem.Run(); FilledClientOrder filledClientOrder = ClientOrderCalculator.CalClientOrder(clientOrder); Console.WriteLine("\nThe result is......\n"); Console.WriteLine(filledClientOrder.GetResutlStr()); Console.ReadKey(); }
public static FilledMediaOrder CalMediaOrder(MediaOrder mediaOrderItem) { MediaBundles mediaBundles = AllMediaBundles.allBundles[mediaOrderItem.MediaType]; FilledMediaOrder filledMediaOrder = new FilledMediaOrder(mediaOrderItem.MediaType, mediaOrderItem.TargetPosts); try { FilledResult filledResult = MiniumBundleCalculator.CalBundles(mediaOrderItem.TargetPosts, mediaBundles.BundleList.Select(item => item.PostsCount).ToList()); filledMediaOrder.offset = filledResult.Offset; for (int i = 0; i < filledResult.filledNumbers.Count; i++) { FilledSingleBundle filledSingleBundle = new FilledSingleBundle(mediaBundles.BundleList[i]); filledSingleBundle.CountNeeded = filledResult.filledNumbers[i]; filledMediaOrder.filledBundleList.Add(filledSingleBundle); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(filledMediaOrder); }
/// <summary> /// The constructor for MediaCriteria objects. /// Be advised that all parameters are optional. A parameter-less MediaCriteria object will match any media type with /// any genre and any content, with no special ordering, no offset, and no limit on the number of items. /// In other words, it will match any and all media items. /// </summary> /// <param name="type"> /// The media type. /// </param> /// <param name="order"> /// The ordering. /// </param> /// <param name="genre"> /// The genre. /// </param> /// <param name="searchText"> /// The free-form search query. /// </param> /// <param name="limit"> /// The maximum number of items. /// </param> /// <param name="offset"> /// The number of items skipped at the beginning. /// </param> public MediaCriteria(MediaType type = MediaType.Any, MediaOrder order = MediaOrder.Default, string genre = "", string searchText = "", int limit = -1, int offset = 0) { Type = type; Order = order; Genre = genre; SearchText = searchText; Limit = limit; Offset = offset; }