Пример #1
0
        public async Task <IActionResult> OnPost()
        {
            resetTypeDropdownList();

            if (!ModelState.IsValid)
            {
                TempData[MessageKey] = "Le formulaire n'est pas valide.";
                return(Page());
            }

            await _stockRepository.Insert(new Dbo.ClientItems()
            {
                Name    = Name,
                Price   = Price,
                Stock   = Stock,
                TypeId  = Type,
                PicName = Image
            });

            ClientLogs log = new ClientLogs
            {
                Id      = 0,
                Date    = DateTime.Now,
                Class   = this.GetType().Name,
                Type    = "Add",
                Logtype = LoggerType.INFO.GetFriendlyName(),
                Message = "Product: " + Name + " has been added to the Stock base",
            };

            await _logRepository.Insert(log);

            TempData[MessageKey] = "Le produit a bien été enregistré !";
            ModelState.Clear();
            return(Page());
        }
Пример #2
0
        public void GetDetailedСallReportByClient(IClient client)
        {
            MessageHandlerEvent(this, $"Поиск по клиенту {client.Name} {client.LastName}");
            var clientLogs = ClientLogs.Where(x => x.Client == client).ToList();

            try
            {
                MessageHandlerEvent(this, $"Клиент {client.Name} {client.LastName}");
                if (clientLogs.Count != 0)
                {
                    foreach (var log in clientLogs)
                    {
                        MessageHandlerEvent(this, $"Исходящий номер {log.Connections.OutgoingNumber}, дата звонка {log.Connections.FinishConnection.ToString("dd.MM.yyyy HH:mm")}, продолжительность соединения {log.Connections.DurationConnection.Seconds}с, стоимость {log.Cost}руб.");
                    }
                    MessageHandlerEvent(this, "");
                }
                else
                {
                    MessageHandlerEvent(this, $"Для клиента {client.Name} {client.LastName} отчетов не обнаружено");
                }
            }
            catch
            {
                throw new Exception("GetDetailedСallReportByClient");
            }
        }
Пример #3
0
        public ClientLogs GetAllLogs()
        {
            ClientLogs clientLogs = new ClientLogs();
            string     logs       = CallLogService("");

            return(clientLogs);
        }
Пример #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                TempData[MessageKey] = "Le formulaire n'est pas valide.";
                return(Page());
            }

            var employees = _employeeRepository.Get().Result;
            var employee  = employees.Where(emp => emp.Username == userNAME).FirstOrDefault();

            if (Tools.CheckPassword(employee.PasswordHash, oldPassword) == false)
            {
                TempData[MessageKey] = "Votre ancien mot de passe n'est pas correct.";
                return(Page());
            }


            if (newPassword != confirmPassword)
            {
                TempData[MessageKey] = "Les 2 champs nouveaux mots de passe ne correspondent pas.";
                return(Page());
            }


            newPassword = Tools.Hash(newPassword);
            Dbo.ClientUsers newUser = new Dbo.ClientUsers
            {
                Id           = employee.Id,
                Username     = employee.Username,
                PasswordHash = newPassword,
                RoleId       = employee.RoleId
            };
            var result = _employeeRepository.Update(newUser);


            ClientLogs log = new ClientLogs
            {
                Id      = 0,
                Date    = DateTime.Now,
                Class   = this.GetType().Name,
                Type    = "employee.Username",
                Logtype = LoggerType.INFO.GetFriendlyName(),
                Message = "Employee: " + employee.Username + " bas been update to the base",
            };

            await _logRepository.Insert(log);

            TempData[MessageKey] = "Votre profil a bien été éditer !";
            ModelState.Clear();
            OnGet();

            return(Page());
        }
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                TempData[MessageKey] = "Le formulaire n'est pas valide.";
                return(Page());
            }
            if (newName != null && newPassword == confirmPassword)
            {
                var roles          = _employeeRepository.GetTypeRoles();
                var nbRoleAdmin    = roles.Where(item => item.Name.ToLower().Contains("admin")).FirstOrDefault();
                var nbRoleEmployee = roles.Where(item => item.Name.ToLower().Contains("employee")).FirstOrDefault();

                //default value
                long role = 1;

                if (nbRoleEmployee != null)
                {
                    role = nbRoleEmployee.Id;
                }

                if (newRole && nbRoleAdmin != null)
                {
                    role = nbRoleAdmin.Id;
                }



                newPassword = Tools.Hash(newPassword);
                Dbo.ClientUsers newUser = new Dbo.ClientUsers
                {
                    Username     = newName,
                    PasswordHash = newPassword,
                    RoleId       = role
                };
                var test = await _employeeRepository.Insert(newUser);


                ClientLogs log = new ClientLogs
                {
                    Id      = 0,
                    Date    = DateTime.Now,
                    Class   = this.GetType().Name,
                    Type    = "Add Employee",
                    Logtype = LoggerType.INFO.GetFriendlyName(),
                    Message = "Employee: " + newName + " bas been added to the base",
                };

                await _logRepository.Insert(log);

                return(RedirectToPage("./AdminEmployees"));
            }
            return(Page());
        }
Пример #6
0
        private void ConnectionHandler(object sender, IConnection connection)
        {
            IContract contract = Contracts.FirstOrDefault(x => x.Client.ClientTerminal.ClientNumberOfTelephone == connection.ClientNumberOfTelephone);

            if (contract != null)
            {
                ClientLogs.Add(new ClientLog(contract.Client, connection));
            }
            else
            {
                throw new Exception("С абонентом не заключен контракт");
            }
        }
        public async Task <IActionResult> OnPostAsync()
        {
            long id = long.Parse(Request.Form["Id"]);

            PicName = Request.Form["Image"];
            if (PicName == "") // Quand l'user n'a pas fourni d'image, on reprend celle d'avant
            {
                PicName = _stockRepository.Get().Result.FirstOrDefault(it => it.Id == id).PicName;
            }
            long TypeId = 0;

            if (Type == null) // Pareil pour le type
            {
                TypeId = _stockRepository.Get().Result.FirstOrDefault(it => it.Id == id).TypeId;
            }
            else
            {
                TypeId = long.Parse(Type);
            }

            Dbo.ClientItems item = new Dbo.ClientItems {
                Id      = id,
                Name    = Name,
                PicName = PicName,
                Stock   = Stock,
                Price   = Price,
                TypeId  = TypeId
            };
            var result = _stockRepository.Update(item).Result;

            ClientLogs log = new ClientLogs
            {
                Id      = 0,
                Date    = DateTime.Now,
                Class   = this.GetType().Name,
                Type    = "Update",
                Logtype = LoggerType.INFO.GetFriendlyName(),
                Message = "Product: " + Name + " has been updated in the Stock base",
            };

            await _logRepository.Insert(log);

            return(Redirect("/ProductDetail/" + id));
        }
Пример #8
0
 public void GetDetailedСallReportForReportPeriod(IClient client)
 {
     {
         bool isPeriod = false;
         while (isPeriod == false)
         {
             MessageHandlerEvent(this, "Введите отчетный период (пример 01.2021)");
             var inputStringh = "01." + Console.ReadLine();
             isPeriod = DateTime.TryParse(inputStringh, out DateTime reportPeriod);
             if (isPeriod)
             {
                 try
                 {
                     var reportByPeriod = Reports.FirstOrDefault(x => x.ReportPeriod == reportPeriod.ToString("y"));
                     if (reportByPeriod == null)
                     {
                         var logsByReportPeriod = ClientLogs.Where(x => x.Client == client).
                                                  Where(x => x.Connections.FinishConnection.ToString("y") == reportPeriod.ToString("y")).ToList();
                         var     DurationOfConversations = logsByReportPeriod.Sum(x => x.Connections.DurationConnection.Seconds);
                         decimal totalSummCollect        = logsByReportPeriod.Sum(x => x.Cost);
                         if (logsByReportPeriod.Count != 0)
                         {
                             reportByPeriod = new ReportCalls(client, reportPeriod.ToString("y"), client.TariffPlan, DurationOfConversations, client.Money, totalSummCollect, logsByReportPeriod);
                             Reports.Add(reportByPeriod);
                         }
                         else
                         {
                             MessageHandlerEvent(this, $"В данном отчетном периоде звонков не обнаружено");
                         }
                     }
                     PrintReportByPeriod(reportByPeriod, reportPeriod);
                 }
                 catch
                 {
                     throw new Exception("Ошибка в методе GetDetailedСallReportForReportPeriod");
                 }
             }
             else
             {
                 MessageHandlerEvent(this, $"Не корректный ввод, введите дату в предложенном формате (пример 01.2021)");
             }
         }
     }
 }
Пример #9
0
        public void GetDetailedСallReportByCallDate()
        {
            Console.WriteLine("Введите дату для поиска звонков (пример 15.01.2021)");
            bool isTime = false;

            while (isTime == false)
            {
                isTime = DateTime.TryParse(Console.ReadLine(), out DateTime dateTime);
                if (isTime)
                {
                    try
                    {
                        var calls = ClientLogs.Where(x => x.Connections.FinishConnection.ToString("dd.MM.yyyy") == dateTime.ToString("dd.MM.yyyy"));
                        if (calls.Count() > 0)
                        {
                            MessageHandlerEvent(this, $"Дата поиска {dateTime.ToString("dd.MM.yyyy")}");
                            foreach (var call in calls)
                            {
                                MessageHandlerEvent(this, $"Клиент {call.Client.Name} {call.Client.LastName}");
                                MessageHandlerEvent(this, $"Исходящий номер {call.Connections.OutgoingNumber}, дата звонка {call.Connections.FinishConnection.ToString("dd.MM.yyyy HH:mm")}, продолжительность соединения {call.Connections.DurationConnection.Seconds}с, стоимость {call.Cost}руб.");
                                MessageHandlerEvent(this, "");
                            }
                        }
                        else
                        {
                            MessageHandlerEvent(this, $"На данную дату отчетов не обнаружено");
                        }
                    }
                    catch
                    {
                        throw new Exception("Ошибка в методе GetDetailedСallReportByCallDate");
                    }
                }
                else
                {
                    MessageHandlerEvent(this, $"Не корректный ввод, введите дату в предложенном формате (пример 15.01.2021)");
                }
            }
        }
Пример #10
0
        public void GetDetailedСallReportByCallCost()
        {
            Console.WriteLine("Введите стоимость для поиска звонков (пример 0,05)");
            bool isCost = false;

            while (isCost == false)
            {
                isCost = Decimal.TryParse(Console.ReadLine(), out decimal costCall);
                if (isCost)
                {
                    try
                    {
                        var calls = ClientLogs.Where(x => x.Cost == costCall).ToList();
                        if (calls.Count() != 0)
                        {
                            MessageHandlerEvent(this, $"Поиск по стоимости звонка {costCall}");


                            foreach (var call in calls)
                            {
                                MessageHandlerEvent(this, $"Клиент {call.Client.Name} {call.Client.LastName}");
                                MessageHandlerEvent(this, $"Исходящий номер {call.Connections.OutgoingNumber}, дата звонка {call.Connections.FinishConnection.ToString("dd.MM.yyyy HH:mm")}, продолжительность соединения {call.Connections.DurationConnection.Seconds}с, стоимость {call.Cost}руб.");
                            }
                            MessageHandlerEvent(this, "");
                        }
                    }
                    catch
                    {
                        throw new Exception("GetDetailedСallReportByCallCost");
                    }
                }
                else
                {
                    MessageHandlerEvent(this, $"Не корректный ввод, введите стоимость звонка в предложенном формате (пример 0,05)");
                }
            }
        }
Пример #11
0
        public async Task <IActionResult> OnPost()
        {
            ClientUsers employee = _employeeRepository.Get().Result.Where(emp => emp.Id == Int64.Parse(EmployeeId)).FirstOrDefault();
            await _employeeRepository.Delete(Int64.Parse(EmployeeId));

            ClientLogs log = new ClientLogs {
                Id      = 0,
                Date    = DateTime.Now,
                Class   = this.GetType().Name,
                Type    = "Delete",
                Logtype = LoggerType.INFO.GetFriendlyName(),
                Message = "Employee: " + employee == null ? "" : employee.Username + " has been removed from the employee base",
            };

            await _logRepository.Insert(log);

            userName = Tools.checkUser(Request.Cookies["user"], _employeeRepository, 2);
            if (userName == null)
            {
                return(RedirectToPage("/Login"));
            }

            return(Page());
        }
Пример #12
0
        public async Task <IActionResult> OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (login == null || password == null)
            {
                return(Page());
            }

            var employees = _employeeRepository.Get().Result;

            if (employees == null)
            {
                return(Page());
            }

            var employee = employees.Where(emp => emp.Username == login).FirstOrDefault();

            if (employee == null)
            {
                return(Page());
            }

            if (Tools.CheckPassword(employee.PasswordHash, password) == false)
            {
                ClientLogs l = new ClientLogs
                {
                    Id      = 0,
                    Date    = DateTime.Now,
                    Class   = this.GetType().Name,
                    Type    = "Login",
                    Logtype = LoggerType.WARNING.GetFriendlyName(),
                    Message = "Employee: " + login + " tried to connect but typed a wrong password",
                };

                await _logRepository.Insert(l);

                return(Page());
            }


            WriteCookie("user", employee.Id.ToString());
            WriteCookie("userName", employee.Username);

            ClientLogs log = new ClientLogs
            {
                Id      = 0,
                Date    = DateTime.Now,
                Class   = this.GetType().Name,
                Type    = "Login",
                Logtype = LoggerType.INFO.GetFriendlyName(),
                Message = "Employee: " + login + " connected successfully",
            };

            await _logRepository.Insert(log);

            //Connected
            return(RedirectToPage("./Index"));
        }
        protected internal override void RaiseLog(Exception ex)
        {
            var str = ex.Message + Environment.NewLine + "stacktrace: " + ex.StackTrace;

            ClientLogs?.Invoke(this, str);
        }
 protected internal override void RaiseLog(string message)
 {
     ClientLogs?.Invoke(this, message);
 }