Exemplo n.º 1
0
        /// <summary>
        /// Update the progress table, this is table client will use to check process and then navigate to
        /// display top results
        /// </summary>
        /// <param name="message"></param>
        /// <param name="progressCounter"></param>
        /// <param name="entities"></param>
        /// <returns></returns>
        private async Task UpdateProgress(ManagementModel message,
                                          int progressCounter,
                                          ObjectsModel entities,
                                          bool isInError)
        {
            //Update Progress table
            var currentProgress = await _azureService.RetrieveEntityAsync <ProgressEntity>(AppConst.ProgressTable, AppConst.CountProgressPartitionKey, message.ProcessId);

            var progress = (ProgressEntity)currentProgress.Result;

            progress.NormalProgress = message.IsGardenSearch ? progress.NormalProgress : progress.NormalProgress + progressCounter;
            progress.GardenProgress = message.IsGardenSearch ? progress.GardenProgress + progressCounter : progress.GardenProgress;

            //Update this so if someone added or removed and object the count will still match up at end to indigate process have completed
            progress.NumberOfNormalObjects = message.IsGardenSearch ? progress.NumberOfNormalObjects : entities.TotaalAantalObjecten;
            progress.NumberOfGardenObjects = message.IsGardenSearch ? entities.TotaalAantalObjecten : progress.NumberOfGardenObjects;

            progress.IsNormalSearchDone = progress.NumberOfNormalObjects == progress.NormalProgress && progress.NormalProgress > 0;
            progress.IsGardenSearchDone = progress.NumberOfGardenObjects == progress.GardenProgress && progress.GardenProgress > 0;

            if (isInError)
            {
                if (!progress.InErrorState)
                {
                    progress.InErrorState = isInError;
                }
            }

            await _azureService.InsertOrMergeAsync(AppConst.ProgressTable, progress);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Process agent info and add to count
        /// </summary>
        /// <param name="item"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private async Task ProcessAgentAsync(ObjectModel item, ManagementModel message)
        {
            //Initially removed these characters to keep string safe for table storage rowkey. Not really needed anymore as this is not rowkey anymore
            var makelaarNaam = item.MakelaarNaam.Replace("/", "").Replace(@"\", "");
            var agentResult  = await _azureService.RetrieveEntityAsync <AgentsEntity>(AppConst.AgentsTable, message.ProcessId, item.MakelaarId.ToString());

            var agentEntity = (AgentsEntity)agentResult.Result;

            if (agentEntity == null)
            {
                var agent = new AgentsEntity
                {
                    PartitionKey = message.ProcessId,
                    RowKey       = item.MakelaarId.ToString(),
                    GardenCount  = message.IsGardenSearch ? 1 : 0,
                    NormalCount  = !message.IsGardenSearch ? 1 : 0,
                    AgentName    = makelaarNaam
                };

                await _azureService.InsertOrMergeAsync(AppConst.AgentsTable, agent);

                return;
            }

            if (message.IsGardenSearch)
            {
                agentEntity.GardenCount += 1;
            }
            else
            {
                agentEntity.NormalCount += 1;
            }

            await _azureService.InsertOrMergeAsync(AppConst.AgentsTable, agentEntity);
        }
        // GET: /Management/
        public ActionResult Index()
        {
            DataSet         employeesTable  = new DataSet();
            ManagementModel ManagementModel = new ManagementModel();

            string connectionString = FirstREST.SqlConnection.GetConnectionString();

            using (System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand("Select * From dbo.Employee", connection))
                {
                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                    {
                        adapter.Fill(employeesTable, "Employees");

                        foreach (DataRow row in employeesTable.Tables["Employees"].Rows)
                        {
                            EmployeeModel temp_employee = new EmployeeModel();
                            temp_employee.id           = row.Field <string>("id");
                            temp_employee.name         = row.Field <string>("abbrv_name");
                            temp_employee.email        = row.Field <string>("email");
                            temp_employee.phone_number = row.Field <string>("phone");
                            ManagementModel.employees.Add(temp_employee);
                        }
                    }
                }
            }

            return(View(ManagementModel));
        }
Exemplo n.º 4
0
        // GET
        public IActionResult Index()
        {
            List <SelectListItem> items        = new List <SelectListItem>();
            List <SelectListItem> itemsProduct = new List <SelectListItem>();

            ManagementModel model = new ManagementModel();

            foreach (Allergie allergie in _manager.GetAllergies())
            {
                items.Add(new SelectListItem
                {
                    Value = allergie.AllergieId + "",
                    Text  = allergie.Naam
                });
            }

            foreach (Product product in _manager.GetProducts())
            {
                itemsProduct.Add(new SelectListItem
                {
                    Value = product.ProductId + "",
                    Text  = product.Naam
                });
            }

            model.Items        = items;
            model.ItemsProduct = itemsProduct;
            return(View(model));
        }
        /// <summary>
        /// Initialize Model
        /// </summary>
        /// <returns>Management Model</returns>
        public ManagementModel InitializeModel(string key)
        {
            using (new PerformanceMonitor())
            {
                var model = new ManagementModel();
                model.Applications = this.GetApplications();
                model.Preference   = GetPreference(ServerConfiguration.ApplicationIdentifier, User.Identity.Data().Identifier);
                if (!string.IsNullOrWhiteSpace(key))
                {
                    model.Application = (from data in model.Applications
                                         where data.PublicKey == key
                                         select data).FirstOrDefault();
                }
                else if (null == model.Preference || null == model.Preference.CurrentApplication || Guid.Empty == model.Preference.CurrentApplication.Identifier)
                {
                    model.Application = model.Applications.FirstOrDefault();
                }
                else
                {
                    model.Application = (from data in model.Applications
                                         where data.ApplicationId == model.Preference.CurrentApplication.Identifier
                                         select data).FirstOrDefault();
                }

                if (string.IsNullOrWhiteSpace(model.Application.PublicKey))
                {
                    model.Application.PublicKey = model.Application.Id.ToAscii85().GetHexMD5();
                }

                return(model);
            }
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Department,Location")] ManagementModel managementModel)
        {
            if (id != managementModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(managementModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ManagementModelExists(managementModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(managementModel));
        }
        public ActionResult Performance(Guid?identifier, string key)
        {
            using (new PerformanceMonitor())
            {
                var model = new ManagementModel();

                try
                {
                    model = this.InitializeModel(key);

                    if (null != model.Application && Guid.Empty != model.Application.ApplicationId)
                    {
                        var query = new LogQuery()
                        {
                            ApplicationIdentifier = model.Application.ApplicationId,
                            Top        = MaxTop,
                            From       = DateTime.UtcNow.AddDays(-7),
                            Identifier = identifier,
                        };

                        var source = new LogCore();
                        model.Data = source.SelectOccurrences(query);
                    }
                }
                catch (Exception ex)
                {
                    logger.Log(ex, EventTypes.Error, (int)Fault.Unknown);

                    model.Error = WebResponse.Bind((int)Fault.Unknown, ex.Message);
                }

                return(View(model));
            }
        }
Exemplo n.º 8
0
        // Supprimer une catégorie de produit/article
        private void OnClickDeleteItemCat(object sender, RoutedEventArgs e)
        {
            try
            {
                mg = new ManagementModel();

                var itemCat = (CategoryModel)((ListViewItem)lv_itemsCategory.ContainerFromElement((Button)sender)).Content;
                var it      = db.CATEGORY.FirstOrDefault(i => i.id_category == itemCat.Id);
                db.CATEGORY.Remove(it);
                db.SaveChanges();

                lv_itemsCategory.ItemsSource = mg.GetAllCategory();
                DialogHost.Show(new Message()
                {
                    message_tb = { Text = "Catégorie supprimée avec succès" }
                }, "RootDialog");
            }
            catch (Exception ex)
            {
                DialogHost.Show(new Message()
                {
                    message_tb = { Text = "Impossible de supprimer la catégorie " + ex.Message }
                }, "RootDialog");
            }
        }
        public static void LoadManagementSystemConfig(ManagementSystem management, String filename)
        {
            var             jsonFile        = File.ReadAllText(filename);
            ManagementModel managementModel = JsonSerializer.Deserialize <ManagementModel>(jsonFile);


            management.Name = managementModel.Name;
            management.ManagementSystemPoint = new IPEndPoint(IPAddress.Parse(managementModel.IpAddress), managementModel.Port);



            management.DevicesList = new Dictionary <String, String>();



            foreach (NetworkNode element in managementModel.NetworkNodeList)
            {
                management.DevicesList.Add(element.NodeName, element.JsonFile);
            }

            management.AllDevicesList = new Dictionary <string, IPEndPoint>();


            foreach (Device device in managementModel.DevicesList)
            {
                management.AllDevicesList.Add(device.name, new IPEndPoint(IPAddress.Parse(device.IPAddress), device.port));
            }
        }
Exemplo n.º 10
0
 public bool InsertRoom(ManagementModel managementModel)
 {
     try
     {
         if (managementModel.id > 0)
         {
             RoomManagement item = POS.RoomManagements.Where(x => x.Id == managementModel.id).FirstOrDefault();
             if (item == null)
             {
                 return(false);
             }
             else
             {
                 item.Name       = managementModel.Name;
                 item.NoOfTables = managementModel.NoOfTables;
                 POS.SaveChanges();
                 return(true);
             }
         }
         else
         {
             RoomManagement room = new RoomManagement();
             room.Name       = managementModel.Name;
             room.NoOfTables = managementModel.NoOfTables;
             POS.RoomManagements.Add(room);
             POS.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public void Data()
        {
            var model = new ManagementModel();
            var items = new List <string>();

            for (int i = 0; i < 3; i++)
            {
                items.Add(StringHelper.ValidString());
            }

            model.Data = items;

            bool found = false;

            foreach (string item in items)
            {
                found = false;
                foreach (string data in model.Data)
                {
                    if (item == data)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    Assert.Fail();
                }
            }
        }
        public void ApplicationNull()
        {
            var model = new ManagementModel();

            Assert.IsNull(model.Application);
            model.Application = null;
            Assert.IsNull(model.Application);
        }
        public void Preference()
        {
            var model = new ManagementModel();
            var data  = new UserPreference();

            model.Preference = data;
            Assert.AreEqual <UserPreference>(data, model.Preference);
        }
        public void DataNull()
        {
            var model = new ManagementModel();

            Assert.IsNull(model.Data);
            model.Data = null;
            Assert.IsNull(model.Data);
        }
Exemplo n.º 15
0
        public IngredientCategoryList(int idItem)
        {
            InitializeComponent();
            IdItem = idItem;
            ManagementModel mg = new ManagementModel();

            lv_ingredientCategoryList.ItemsSource = mg.GetAllIngredientCat();
        }
        public void Applications()
        {
            var model = new ManagementModel();
            var data  = new List <ApplicationDetailsModel>();

            model.Applications = data;

            Assert.AreEqual <IEnumerable <ApplicationDetailsModel> >(data, model.Applications);
        }
Exemplo n.º 17
0
 public ManagementController(IOptions <StateConfigs> configs)
 {
     func       = new Functional();
     acc        = new AccountModel(configs);
     dt         = new DataTable();
     management = new ManagementModel(configs);
     state      = configs.Value;
     address    = new List <InformationAddress>();
 }
Exemplo n.º 18
0
        public async Task RunAsync(ManagementModel message)
        {
            var  messageType = $"SchoolFunctions.MessageHandlers.{message.MessageType}MessageHandler";
            Type type        = Type.GetType(messageType);

            Container container = new Container();

            container.Register(type);
            var instance = (IMessageHandler)container.GetInstance(type);
            await instance.HandleAsync(message);
        }
Exemplo n.º 19
0
        private void showItemsOptionsOnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            mg = new ManagementModel();
            var liste = (ItemModel)lv_items.SelectedItem;

            if (liste != null)
            {
                idItem = liste.Id;
                lv_itemsOptions.ItemsSource = mg.GetItemsOptionsByItem(idItem);
            }
        }
Exemplo n.º 20
0
        private void ShowItemsOptions(object sender, SelectionChangedEventArgs e)
        {
            mg = new ManagementModel();
            var sel = (MenuOptions)lv_menuOption.SelectedItem;

            if (sel != null)
            {
                int id = sel.Id;
                lv_menuItemsOptions.ItemsSource = mg.GetMenuItemsOptions(id);
            }
        }
Exemplo n.º 21
0
        void IPartImportsSatisfiedNotification.OnImportsSatisfied()
        {
            var mgmtParams = new ManagementModelParameters
            {
                DelayedProgramInfos = this._dataContainer.DelayedApplications,
                StartupProgramInfos = this._startupInfo.Retrieve()
            };
            var mgmtModel = this._managementModelFactory.Get(mgmtParams);

            this.ManagementModel = mgmtModel;
        }
Exemplo n.º 22
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Department,Location")] ManagementModel managementModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(managementModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(managementModel));
        }
Exemplo n.º 23
0
        public async Task RunAsync(ManagementModel message)
        {
            var  messageType = $"Count.Functions.MessageHandlers.{message.MessageType}MessageHandler";
            Type type        = Type.GetType(messageType);

            _container.Register(type);
            _container.Register <IAzureService, AzureService>();
            _container.Register <IRestService, RestService>();
            var instance = (IMessageHandler)_container.GetInstance(type);
            await instance.HandleAsync(message).ConfigureAwait(false);
        }
Exemplo n.º 24
0
        private void showIngredientsOnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            mg = new ManagementModel();
            var liste = (ItemsCategoryModel)lv_ingredientCategory.SelectedItem;

            if (liste != null)
            {
                int id = liste.Id;
                //     lv.ItemsSource = mg.GetItemsOptionsByItem(id);
                lv_ingredient.ItemsSource = mg.GetIngredientByCat(id);
            }
        }
Exemplo n.º 25
0
        // On select category show list of items
        private void showItemsOnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            mg = new ManagementModel();
            var liste = (CategoryModel)lv_itemsCategory.SelectedItem;

            if (liste != null)
            {
                idItemCat                   = liste.Id;
                nameItemCat                 = liste.Title;
                lv_items.ItemsSource        = mg.GetItemsByCat(idItemCat);
                lv_itemsOptions.ItemsSource = null;
            }
        }
        /// <summary>
        /// Will queue a new message for Begin process where the process will restart with Garden added as search criteria
        /// </summary>
        /// <param name="processId"></param>
        /// <returns></returns>
        private async Task SendSearchCriteriaMessage(string processId)
        {
            var messageDetails = new ManagementModel
            {
                ProcessId      = processId,
                MessageType    = MessageType.BeginProcess.ToString(),
                ObjectNumber   = 1,
                IsGardenSearch = true
            };

            var messageContent = JsonConvert.SerializeObject(messageDetails);
            await _azureService.SendMessageAsync(AppConst.ManagementQueueName, messageContent);
        }
Exemplo n.º 27
0
 private void ManagementLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         mg = new ManagementModel();
         lv_itemsCategory.ItemsSource      = mg.GetAllCategory();
         lv_menu.ItemsSource               = mg.GetAllMenu();
         lv_menuOption.ItemsSource         = mg.GetMenuOptions();
         lv_ingredientCategory.ItemsSource = mg.GetAllIngredientCat();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 28
0
        public List <ManagementModel> GetManagements()
        {
            var query = POS.RoomManagements.ToList();

            List <ManagementModel> managements = new List <ManagementModel>();

            foreach (var item in query)
            {
                ManagementModel manag = new ManagementModel();
                manag.id         = item.Id;
                manag.Name       = item.Name;
                manag.NoOfTables = (int)item.NoOfTables;
                managements.Add(manag);
            }
            return(managements);
        }
        public void Application()
        {
            var model = new ManagementModel();
            var app   = new ApplicationDetailsModel()
            {
                ApplicationId = Guid.NewGuid(),
                IsValid       = true,
                ValidUntil    = DateTime.UtcNow,
            };

            model.Application = app;

            Assert.AreEqual <Guid>(app.ApplicationId, model.Application.ApplicationId);
            Assert.AreEqual <bool>(app.IsValid, model.Application.IsValid);
            Assert.AreEqual <DateTime>(app.ValidUntil, model.Application.ValidUntil);
        }
Exemplo n.º 30
0
        public async Task Create()
        {
            var processId   = Guid.NewGuid().ToString();
            var messageBody = new ManagementModel
            {
                ProcessId    = processId,
                MessageType  = MessageType.BeginProcess.ToString(),
                ObjectNumber = 1
            };

            var message = JsonConvert.SerializeObject(messageBody);

            _sqlite.Add(new ProcessEntity {
                ProcessId = processId
            });
            await _azure.SendMessageAsync(AppConst.ManagementQueueName, message);
        }