Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _exampleModel = new List<ExampleModel>();

            var exManager = new ExampleManager();
            var knManager = new KnapsackManager();
            var itManager = new ItemManager();

            var idEx = exManager.GetAllExamplesId();

            foreach (var id in idEx)
            {
                string knapsacks = string.Empty;
                string items = string.Empty;

                knManager.GetKnapsacks(id).ForEach(k => knapsacks+=","+k.Capacity);
                itManager.GetItems(id).ForEach(i => items+=","+i.Weight);

                _exampleModel.Add(new ExampleModel
                {
                    Id = id,
                    Error = exManager.GetCalculateError(id),
                    Knapsacks = knapsacks.TrimStart(','),
                    Items = items.TrimStart(',')
                });
            }

            ExamplesGrid.DataSource = _exampleModel;
            ExamplesGrid.DataBind();
        }
Exemplo n.º 2
0
        private void TryCalculate(int idEx)
        {
            var calculateModel = new CalculateModel();

            var knManager = new KnapsackManager();
            var itManager = new ItemManager();
            var exManager = new ExampleManager();

            calculateModel.Knapsacks = knManager.GetKnapsacks(idEx);
            calculateModel.Items = itManager.GetItems(idEx);
            calculateModel.CalculateError = exManager.GetCalculateError(idEx);

            _proxy.CalculateCompleted += _proxy_CalculateCompleted;
            _proxy.CalculateAsync(TransportConverter.CalculateModelConverter(calculateModel));
        }