Beispiel #1
0
        public ActionResult Requests()
        {
            //filter
            User Admin = Session["USER"] as User;

            if (Admin == null)
            {
                return(HttpNotFound());
            }
            else
            {
                unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                GenericRepository <Employee> empRepo = unitOfWork.GetRepoInstance <Employee>();
                Employee Requester = empRepo.GetBy(r => r.EmployeeID == Admin.UserID).FirstOrDefault();
                if (Requester.RoleID != 1)
                {
                    return(HttpNotFound());
                }
                else
                {
                    unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                    GenericRepository <RequestCode> reqRepo = unitOfWork.GetRepoInstance <RequestCode>();
                    ViewBag.error = null;
                    List <RequestCode> requsests = reqRepo.GetBy(r => r.IsDeleted == false).ToList();

                    return(View("Requests", requsests));
                }
            }
        }
Beispiel #2
0
        public ActionResult NewEmployee()
        {
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Employee> empRepo  = unitOfWork.GetRepoInstance <Employee>();
            GenericRepository <User>     userRepo = unitOfWork.GetRepoInstance <User>();
            string cate     = this.Request.Form["Category"];
            string role     = this.Request.Form["Role"];
            string name     = this.Request.Form["Username"];
            string password = this.Request.Form["Password"];
            string passHash = Cryptography.GetRandomKey(64);
            User   emp      = new User()
            {
                IsVerified = true,
                Active     = true,
                CreatedAt  = DateTime.Now,
                Hash       = passHash,
                Password   = Cryptography.Encrypt(password, passHash)
            };

            userRepo.Add(emp);
            Employee empc = new Employee()
            {
                EmployeeID = emp.UserID,
                RoleID     = Int32.Parse(role),
                UserName   = name,
                CategoryID = Int32.Parse(cate)
            };

            empRepo.Add(empc);
            unitOfWork.SaveChanges();
            return(RedirectToAction("Dashboard"));
        }
Beispiel #3
0
        public ActionResult CategoryDetail(int id)
        {
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Category> catRepository   = unitOfWork.GetRepoInstance <Category>();
            GenericRepository <Employee> adminRepository = unitOfWork.GetRepoInstance <Employee>();
            Category cd = catRepository.GetBy(c => c.CategoryID == id).FirstOrDefault();
            Employee e  = adminRepository.GetBy(c => c.CategoryID == id && c.RoleID == 2).FirstOrDefault();

            if (e != null)
            {
                CatgeroyView catDetail = new CatgeroyView()
                {
                    CategoryID          = cd.CategoryID,
                    CategoryAdmin       = e.UserName,
                    CategoryDescription = cd.CategoryDescription,
                    CategoryName        = cd.CategoryName
                };
                return(View("CategoryDetail", catDetail));
            }
            else
            {
                CatgeroyView catDetail = new CatgeroyView()
                {
                    CategoryID          = cd.CategoryID,
                    CategoryAdmin       = "No Admin",
                    CategoryDescription = cd.CategoryDescription,
                    CategoryName        = cd.CategoryName
                };
                return(View("CategoryDetail", catDetail));
            }
        }
Beispiel #4
0
        public ActionResult Dashboard()
        {
            User Admin = Session["USER"] as User;

            if (Admin == null)
            {
                return(HttpNotFound());
            }
            else
            {
                unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                GenericRepository <Employee> emp2Repo = unitOfWork.GetRepoInstance <Employee>();
                Employee Requester = emp2Repo.GetBy(r => r.EmployeeID == Admin.UserID).FirstOrDefault();
                if (Requester.RoleID != 1)
                {
                    return(HttpNotFound());
                }

                else
                {
                    unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                    GenericRepository <Category> cateRepo  = unitOfWork.GetRepoInstance <Category>();
                    GenericRepository <Role>     rolesRepo = unitOfWork.GetRepoInstance <Role>();
                    //GenericRepository<User> userRepo = unitOfWork.GetRepoInstance<User>();

                    GenericRepository <Employee> empRepo = unitOfWork.GetRepoInstance <Employee>();
                    List <Employee> empo = empRepo.GetBy(z => z.User.Active == true).ToList();
                    //  User[] userEmp = new User[empo.Count()];
                    ViewBag.categories = cateRepo.GetAll().ToList();
                    ViewBag.roles      = rolesRepo.GetAll().ToList();
                    return(View("Dashboard", empo));
                }
            }
        }
Beispiel #5
0
        public void TestMethod1()
        {
            GenericUnitOfWork  uow = new GenericUnitOfWork();
            DistributorService distributorService = new DistributorService(uow);
            bool SavedAll = distributorService.AddRange(new List <_Distributor>()
            {
                new _Distributor()
                {
                    DistributorName        = "Cty ABC",
                    RegionId               = 34,
                    DistributorAddress     = "552 Quang Trung, Go Vap, TP Ho Chi Minh",
                    DistributorEmail       = "*****@*****.**",
                    DistributorPhoneNumber = "0120000001",
                    Status      = "Cooperating",
                    Description = "No Describe anymore"
                },
                new _Distributor()
                {
                    DistributorName        = "Cty XYZ",
                    RegionId               = 48,
                    DistributorAddress     = "789 Nguyễn Huệ, Đống Đa, TP Hà Nội",
                    DistributorEmail       = "*****@*****.**",
                    DistributorPhoneNumber = "0120000002",
                    Status      = "Cooperating",
                    Description = "No Describe anymore"
                },
            });

            Assert.AreEqual(true, SavedAll);
        }
        // Return Details of a Certain Case
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 2;
            }
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>   caseRepository   = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Status> statusRepository = unitOfWork.GetRepoInstance <Status>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            userCase.Status = statusRepository.GetBy(st => st.StatusID == userCase.StatusID).FirstOrDefault();
            GenericRepository <File> fileRepository = unitOfWork.GetRepoInstance <File>();
            File userFile = fileRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            DateTime End = userCase.SubmissionDate.AddDays(3);

            ViewBag.Timer = End.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;

            CaseDetailsVM caseDetailsVM = new CaseDetailsVM();

            caseDetailsVM.Case = userCase;

            if (userFile != null)
            {
                caseDetailsVM.FileID        = userFile.FileID;
                caseDetailsVM.FileName      = userFile.FileName;
                caseDetailsVM.Content       = userFile.Content;
                caseDetailsVM.SavedFileName = userFile.SavedFileName;
            }
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();

            if (userCase.StatusID == 2)
            {
                Employee_Case empCase = empCaseRepository.GetBy(ec => ec.CaseID == caseId && ec.EmployeeID == userId).FirstOrDefault();
                if (empCase.OpenedAt == null)
                {
                    empCase.OpenedAt = DateTime.Now;
                    empCaseRepository.Edit(empCase);
                    unitOfWork.SaveChanges();
                }
            }
            if (userCase.StatusID == 2 || userCase.StatusID == 3)
            {
                Employee_Case empCase = empCaseRepository.GetBy(ec => ec.CaseID == caseId && ec.EmployeeID == userId).FirstOrDefault();
                if (empCase.OpenedAt != null)
                {
                    DateTime timer2 = (DateTime)empCase.OpenedAt;
                    ViewBag.Timer2 = timer2.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
                }
            }

            return(View(caseDetailsVM));
        }
        // Return List of Escalated Cases
        public ActionResult GetEscalatedList()
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 1;
            }
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <User> userRepository = unitOfWork.GetRepoInstance <User>();
            GenericRepository <Case> caseRepository = unitOfWork.GetRepoInstance <Case>();

            var         result        = caseRepository.GetBy(c => c.StartupID == userId).OrderBy(c => c.CategoryID);
            List <Case> EscalatedList = new List <Case>();

            if (result.Count() != 0)
            {
                foreach (Case c in result)
                {
                    if (c.StatusID == 3)
                    {
                        EscalatedList.Add(c);
                    }
                }
            }
            ViewBag.TableName = "Escalated Cases";
            return(View("CasesList", EscalatedList));
        }
        public ActionResult AssignEmployees(long empId, long caseId)
        {
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Employee_Case> empRepository = unitOfWork.GetRepoInstance <Employee_Case>();
            List <Employee_Case> allAssingedEmps            = empRepository.GetBy(ec => ec.EmployeeID == empId && ec.CaseID == caseId).ToList();

            if (allAssingedEmps == null)
            {
                Employee_Case assignEmp = new Employee_Case();
                assignEmp.EmployeeID = empId;
                assignEmp.CaseID     = caseId;
                assignEmp.AssignDate = DateTime.Now;
                empRepository.Add(assignEmp);

                GenericRepository <Case> empCase = unitOfWork.GetRepoInstance <Case>();
                Case currentCase = empCase.GetBy(c => c.CaseID == caseId).FirstOrDefault();
                currentCase.StatusID = 2;
                empCase.Edit(currentCase);
            }
            else
            {
                Employee_Case currentEmpCase = empRepository.GetBy(ec => ec.EmployeeID == empId && ec.CaseID == caseId).FirstOrDefault();
                currentEmpCase.IsDeleted = false;
                if (currentEmpCase.Case.StatusID == 3)
                {
                    currentEmpCase.Case.StatusID = 2;
                }
                empRepository.Edit(currentEmpCase);
            }

            unitOfWork.SaveChanges();
            return(RedirectToAction("CaseDetails", new { caseId = caseId }));
        }
        // Return Details of a Certain Case
        public ActionResult CaseDetails(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 1;
            }

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>   caseRepository   = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Status> statusRepository = unitOfWork.GetRepoInstance <Status>();
            Case userCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            userCase.Status = statusRepository.GetBy(st => st.StatusID == userCase.StatusID).FirstOrDefault();
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();

            if (empCaseRepository.GetBy(c => c.CaseID == caseId).Count() != 0)
            {
                ViewBag.LastRating = empCaseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault().Rating;
            }
            if (userCase.StartupID == userId)
            {
                return(View(userCase));
            }
            else
            {
                return(HttpNotFound());
            }
        }
Beispiel #10
0
        public ActionResult Startups()
        {
            List <StartUpDetails> list = new List <StartUpDetails>();

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Startup> myRepo = unitOfWork.GetRepoInstance <Startup>();
            GenericRepository <User>    uRepo  = unitOfWork.GetRepoInstance <User>();
            GenericRepository <Case>    cRepo  = unitOfWork.GetRepoInstance <Case>();

            List <Startup> allstarts = myRepo.GetAll().ToList();

            foreach (Startup s in allstarts)
            {
                StartUpDetails st = new StartUpDetails();
                st.StartUpName = s.CompanyName;
                st.telephone   = s.CompanyNumber;
                st.email       = uRepo.GetBy(a => a.UserID == s.CompanyID).FirstOrDefault().Email;
                st.noCases     = cRepo.GetBy(a => a.StartupID == s.CompanyID).Count().ToString();
                st.Active      = uRepo.GetBy(a => a.UserID == s.CompanyID).FirstOrDefault().Active;


                st.Date      = uRepo.GetBy(a => a.UserID == s.CompanyID).FirstOrDefault().CreatedAt.ToShortDateString();
                st.StartUpID = s.CompanyID;
                //  st.listCases = cRepo.GetBy(a => a.StartupID == s.CompanyID).ToList();
                list.Add(st);
            }

            return(View(list));
        }
        // Take The new Case
        public ActionResult TakeNewCase(long caseId)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 2;
            }
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>          caseRepository    = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();

            Employee_Case newRecord = new Employee_Case()
            {
                EmployeeID = userId,
                CaseID     = caseId
            };

            empCaseRepository.Add(newRecord);

            Case updatedCase = caseRepository.GetBy(c => c.CaseID == caseId).FirstOrDefault();

            updatedCase.StatusID = 2;
            caseRepository.Edit(updatedCase);
            unitOfWork.SaveChanges();

            return(RedirectToAction("CaseDetails", new { caseId = caseId }));
        }
Beispiel #12
0
        public Main_Form(User user)
        {
            InitializeComponent();
            admin                 = user;
            work                  = new GenericUnitOfWork(new ServerContext(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString));
            repositoryUser        = work.Reposiyory <User>();
            repositoryGroup       = work.Reposiyory <Group>();
            repositoryQuestion    = work.Reposiyory <Question>();
            repositoryResult      = work.Reposiyory <Result>();
            repositoryTest        = work.Reposiyory <Test>();
            repositoryAnswer      = work.Reposiyory <Answer>();
            repositoryUserAnswear = work.Reposiyory <UserAnswear>();


            dataGridView1.Visible   = false;
            comboBox1.Visible       = false;
            label1.Visible          = false;
            groupBox2.Visible       = false;
            comboBox1.DisplayMember = "Title";
            removeButton.Visible    = false;

            repositoryGroup.GetAll().ToList().ForEach(row =>
            {
                comboBox1.Items.Add(row);
            });

            TestServer server = new TestServer(work);

            server.Start();
        }
Beispiel #13
0
        protected void Session_Start()
        {
            Session["UNITOFWORK"] = new GenericUnitOfWork();

            if (Request.Cookies["LoginCookie"] != null)
            {
                long   id;
                string token = Request.Cookies["LoginCookie"]["RemeberMe"];
                Int64.TryParse(Request.Cookies["LoginCookie"]["UserID"].ToString(), out id);

                GenericUnitOfWork unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];

                GenericRepository <User> userRepository = unitOfWork.GetRepoInstance <User>();
                User testedUser = userRepository.GetBy(u => u.UserID == id).FirstOrDefault();

                if (testedUser != null)
                {
                    if (testedUser.RememberToken == token)
                    {
                        Session["USER"] = testedUser;
                    }
                }
            }
            else
            {
            }
        }
Beispiel #14
0
        public Form1(Form form)
        {
            InitializeComponent();
            unVisableGroup();
            work = new GenericUnitOfWork(new ServerContext(ConfigurationManager.ConnectionStrings["conStr"].ConnectionString));
            dataGridView1.DataSource = work.Repository <Group>().GetAll();
            this.form = form;


            listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //Сервер завжди сідає на локал хост!!
            IPHostEntry iPHostEntry = Dns.GetHostEntry("localhost");
            IPAddress   iPAddress   = iPHostEntry.AddressList[1]; //[0] доступ до першої мережевої карти


            int port = 33333;


            IPEndPoint iPEndPoint = new IPEndPoint(iPAddress, port);

            listenSocket.Bind(iPEndPoint);
            var token = tokenSource.Token;

            Task.Factory.StartNew(() => ListenThread(listenSocket, token), token);
        }
        public static void CreateAccount(LoginModel items, GenericUnitOfWork _unitOfWork)
        {
            var createUser    = _unitOfWork.GetRepoInstance <User>();
            var createAccount = _unitOfWork.GetRepoInstance <Account>();
            var users         = new User()
            {
                Firstname     = items.Firstname,
                LastName      = items.LastName,
                Sex           = items.Sex,
                ContactNumber = items.ContactNumber,
                Address       = items.Address,
                CreatedDate   = DateTime.Now
            };

            createUser.Add(users);

            var accounts = new Account()
            {
                Username    = items.Username,
                Password    = items.Password,
                StatusId    = (int)Status.Active,
                CreatedDate = DateTime.Now
            };

            createAccount.Add(accounts);

            _unitOfWork.SaveChanges();
        }
Beispiel #16
0
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            dynamic controller;
            string  controllerName = filterContext.RequestContext.HttpContext.Request.RawUrl.Split('/')[1].ToLower();

            switch (controllerName)
            {
            case "home":
                controller = (HomeController)filterContext.Controller;
                break;

            case "search":
                controller = (SearchController)filterContext.Controller;
                break;

            case "account":
                controller = (AccountController)filterContext.Controller;
                break;

            case "admin":
                controller = (AdminController)filterContext.Controller;
                break;

            case "shopping":
                controller = (ShoppingController)filterContext.Controller;
                break;

            default:
                controller = (HomeController)filterContext.Controller;
                break;
            }

            GenericUnitOfWork _unitOfWork = controller._unitOfWork;
            // filterContext.Controller.ViewBag.CategoryAndSubCategory = _unitOfWork.GetRepositoryInstance<Tbl_Category>().GetAllRecordsIQueryable().ToList();
        }
Beispiel #17
0
 /// <summary>
 /// Method to write log into db
 /// </summary>
 /// <param name="exception">Exception</param>
 /// <param name="actionName">Action name/Method name</param>
 /// <param name="controllerName">controllerName/ClassName</param>
 /// <param name="loginUserId">LoginUserId</param>
 private static void WriteLogDb(Exception exception, string actionName, string controllerName, int loginUserId)
 {
     try
     {
         using (var actionMapUnit = new GenericUnitOfWork())
         {
             // We can make a table for error log
             //var dbErrorlog = new DB_ERROR_LOG
             //{
             //ActionName = actionName,
             //ContollerName = controllerName,
             //ErrorMessage = exception.ToString(),
             //LoginUserId = loginUserId,
             //HostName = Dns.GetHostName(),
             //CreateDate = DateTime.Now
             //};
             //actionMapUnit.DbErrorUnitOfWork.Insert(dbErrorlog);
             //actionMapUnit.Save();
         }
     }
     catch (Exception ex)
     {
         LogException(ex);
         throw;
     }
 }
Beispiel #18
0
        public ActionResult Codes()
        {
            User Admin = Session["USER"] as User;

            if (Admin == null)
            {
                return(HttpNotFound());
            }
            else
            {
                unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                GenericRepository <Employee> empRepo = unitOfWork.GetRepoInstance <Employee>();
                Employee Requester = empRepo.GetBy(r => r.EmployeeID == Admin.UserID).FirstOrDefault();
                if (Requester.RoleID != 1)
                {
                    return(HttpNotFound());
                }

                else
                {
                    unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
                    GenericRepository <Code> codeRepo = unitOfWork.GetRepoInstance <Code>();
                    ViewBag.Total = codeRepo.GetAll().Count();
                    ViewBag.Used  = codeRepo.GetBy(r => r.UsedBefore == true).Count();
                    List <Code> codes = codeRepo.GetAll().ToList();
                    return(View("Codes", codes));
                }
            }
        }
Beispiel #19
0
        public ActionResult SendCode(int id)
        {
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <RequestCode> reqRepo  = unitOfWork.GetRepoInstance <RequestCode>();
            GenericRepository <Code>        codeRepo = unitOfWork.GetRepoInstance <Code>();
            RequestCode request = reqRepo.GetBy(r => r.RequestID == id).FirstOrDefault();



            Code sendingCode = codeRepo.GetBy(c => c.UsedBefore == false && c.Sent == false).FirstOrDefault();

            if (sendingCode == null)
            {
                ViewBag.error = "All codes are used or sent but not used";
                List <RequestCode> requsests = reqRepo.GetBy(r => r.IsDeleted == false).ToList();
                return(View("~/Areas/Admin/Views/Admin/Requests.cshtml", requsests));
            }
            else
            {
                sendingCode.Sent = true;
                codeRepo.Edit(sendingCode);
                request.IsDeleted = true;
                reqRepo.Edit(request);

                unitOfWork.SaveChanges();


                SendEmail.send(request.Email, sendingCode.ExpireAt.ToString(), this.Request, sendingCode.CodeValue, null, "~/email.html");
                return(RedirectToAction("Requests"));
            }
        }
        //Messages
        public ActionResult Messages(long caseId, int?page)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 1;
            }
            MessagesVM model = new MessagesVM();

            model.Messages = new List <Message>();

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Message> messageRepository = unitOfWork.GetRepoInstance <Message>();

            var result = messageRepository.GetBy(m => m.CaseID == caseId && (m.ReceiverID == userId || m.SenderID == userId)).OrderByDescending(m => m.SubmissionDate);

            if (result != null)
            {
                foreach (Message message in result)
                {
                    model.Messages.Add(message);
                }
            }
            page = 1;
            int pageSize   = 3;
            int pageNumber = (page ?? 1);

            model.Messages.ToPagedList(pageNumber, pageSize);
            return(View(model));
        }
Beispiel #21
0
        // Return Opened Cases (Escalated or Current)
        public ActionResult GetOpenList()
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 2;
            }
            List <Case> myList     = new List <Case>();
            int         pageSize   = 2;
            int         pageNumber = 1;
            int         pageCount  = 1;

            ViewBag.TableName = "Open Cases";
            Dashboard model = new Dashboard();

            model.Open = GetEmpCaseList(true);
            ////////////////////////////////////////////////////////////

            GenericRepository <Case>          caseRepository    = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <Employee_Case> empCaseRepository = unitOfWork.GetRepoInstance <Employee_Case>();
            var result = empCaseRepository.GetBy(ec => ec.EmployeeID == userId);

            if (result != null)
            {
                foreach (Employee_Case ec in result)
                {
                    if (ec.IsDeleted != false)
                    {
                        Case temp = caseRepository.GetBy(c => c.CaseID == ec.CaseID).FirstOrDefault();
                        if (temp.StatusID == 1)
                        {
                            // Solved
                            myList.Add(temp);
                        }
                    }
                }

                pageCount    = (int)Math.Ceiling((double)myList.Count() / pageSize);
                model.Solved = (myList.Skip((pageNumber - 1) * pageSize).Take(pageSize)).ToList();
            }

            model.Solved = (myList.Skip((pageNumber - 1) * pageSize).Take(pageSize)).ToList();
            /////////////////////////////////////////////////
            ViewBag.CurrentPage = pageNumber;
            ViewBag.PageCount   = pageCount;

            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];

            GenericRepository <User> userRepo = unitOfWork.GetRepoInstance <User>();
            User user = userRepo.GetBy(u => u.UserID == userId).FirstOrDefault();

            ViewBag.User = user;
            return(View("OpenCasesList", model));
        }
        //public ActionResult NewCase()
        //{
        //    unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
        //    GenericRepository<Priority> priority_caseRepository = unitOfWork.GetRepoInstance<Priority>();
        //    //GenericRepository<Status> status_caseRepository = unitOfWork.GetRepoInstance<Status>();
        //    GenericRepository<Category> category_caseRepository = unitOfWork.GetRepoInstance<Category>();

        //    List<Priority> priorities = priority_caseRepository.GetAll().ToList();
        //    List<Category> categories = category_caseRepository.GetAll().ToList();

        //    ViewBag.Priorities = priorities;
        //    ViewBag.Categories = categories;

        //    NewCaseVM newcasevm = new NewCaseVM();
        //    newcasevm.Case = new Case();
        //    newcasevm.CaseID = newcasevm.Case.CaseID;
        //    return View(newcasevm);
        //}



        //Submit New Case
        public ActionResult SendCase(NewCaseVM newCase)
        {
            long userId;

            if (Session["USER"] != null)
            {
                userId = ((User)Session["USER"]).UserID;
            }
            else
            {
                userId = 1;
            }
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Case>     caserepo = unitOfWork.GetRepoInstance <Case>();
            GenericRepository <DAL.File> filerepo = unitOfWork.GetRepoInstance <DAL.File>();

            Case startupCase = new Case();

            startupCase = newCase.Case;
            startupCase.SubmissionDate = DateTime.Now;
            startupCase.StatusID       = 4;
            startupCase.StartupID      = userId;
            caserepo.Add(startupCase);

            //try
            //{
            if (newCase.File != null)
            {
                Guid   g          = Guid.NewGuid();
                string GuidString = Convert.ToBase64String(g.ToByteArray());
                GuidString = GuidString.Replace("=", "");
                GuidString = GuidString.Replace("+", "");

                string _FileName       = Path.GetFileName(newCase.File.FileName);
                string _UniqueFileName = GuidString + "+" + _FileName;
                //string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _UniqueFileName);


                byte[] uploadedFile = new byte[newCase.File.InputStream.Length];
                //var x = newCase.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);
                DAL.File NewFile = new DAL.File();
                NewFile.FileName      = _FileName;
                NewFile.SavedFileName = _UniqueFileName;
                NewFile.CaseID        = startupCase.CaseID;
                NewFile.Content       = uploadedFile;
                NewFile.FileType      = newCase.File.ContentType;
                filerepo.Add(NewFile);
            }
            //}
            //catch
            //{
            //    ViewBag.Message = "File upload failed!!";
            //    return View("NewCase", newCase);
            //}

            unitOfWork.SaveChanges();

            return(RedirectToAction("Dashboard"));
        }
Beispiel #23
0
        public IEnumerable <FilterList> GetByControllerName(string controllerName)
        {
            GenericUnitOfWork <RightController> uow = new GenericUnitOfWork <RightController>(factory);
            int controllerId = uow.Repository.Get(d => d.Name == controllerName).Select(d => d.Id).FirstOrDefault();

            uow.Dispose();
            return(GetByControllerId(controllerId));
        }
Beispiel #24
0
 public Engine()
 {
     this.timer           = new System.Timers.Timer();
     this.timer.AutoReset = false;
     this.timer.Elapsed  += new System.Timers.ElapsedEventHandler(timer_Elapsed);
     logger = new Tracing.Logger();
     guow   = new GenericUnitOfWork("Reversals");
 }
Beispiel #25
0
 public ActionResult CategoryEdit(Tbl_Category table)
 {
     using (GenericUnitOfWork _unitOfWork = new GenericUnitOfWork())
     {
         _unitOfWork.GetRepositoryInstance <Tbl_Category>().Update(table);
         return(RedirectToAction("Categories"));
     }
 }
Beispiel #26
0
        public PartialViewResult CategoryEmployee(int id)
        {
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <Employee> empRepository = unitOfWork.GetRepoInstance <Employee>();
            List <Employee> empcat = empRepository.GetBy(c => c.CategoryID == id).OrderBy(c => c.RoleID).ToList();

            return(PartialView("_LoadView", empcat));
        }
Beispiel #27
0
 public HomeController(UserManager <ApplicationUser> user)
 {
     _user         = user;
     unitOfWork    = new GenericUnitOfWork(new HrContext());
     RolRep        = unitOfWork.Repository <Roles>();
     FeaRep        = unitOfWork.Repository <Features>();
     FeatureConfig = unitOfWork.Repository <FeatureAccessConfig>();
 }
Beispiel #28
0
 public HomeController()
 {
     unitOfWork    = new GenericUnitOfWork(new HrContext());
     MenuRep       = unitOfWork.Repository <Menu>();
     RolRep        = unitOfWork.Repository <Roles>();
     FeaRep        = unitOfWork.Repository <DataAccess.Models.SubMenu>();
     FeatureConfig = unitOfWork.Repository <FeatureAccessConfig>();
 }
Beispiel #29
0
 public OrgDataController(GenericUnitOfWork uow)
 {
     _uow = uow;
     GetCountryList();
     GetWomensRightsIssueList();
     GetOperationalAreaList();
     GetLearntAboutList();
 }
        public FileResult DownloadFile(long id)
        {
            unitOfWork = (GenericUnitOfWork)Session["UNITOFWORK"];
            GenericRepository <File> fileRepository = unitOfWork.GetRepoInstance <File>();
            File userFile = fileRepository.GetBy(c => c.FileID == id).FirstOrDefault();

            return(File(userFile.Content, userFile.FileType, userFile.FileName));
        }
        private int widthImage = 200; //tiene que ser multiplo de 4. Antes tenia 40 en ambos pero se venia medio mal la foto, con 200 la foto es mas nitida logicamente, creo que es mejor

        #endregion Fields

        #region Constructors

        public RecognizeBLL()
        {
            unitOfWork = new GenericUnitOfWork();
            unitOfWork.SaveChanges();

            pathFaceRecognition = HttpRuntime.AppDomainAppPath;
            pathImg = pathFaceRecognition + @"\" + imagesFolder;
            pathXMLHaarcascade = pathFaceRecognition + @"\" + HaarCascadeFolder + @"\" + HaarCascadeFile;
        }
Beispiel #32
0
        public List<EndDayShow> GetEndDayShowProcedure(int numend, int kind)
        {
            /*
            var Tov_allRepository = new GenericRepository<Tov_all>(new TestContext());
            var FuelRepository = new GenericRepository<Fuel>(new TestContext());

            var tov_all = Tov_allRepository.GetAll();
            var fuel = FuelRepository.GetAll();
*/
            var uow = new GenericUnitOfWork();

            var viewEndDayList = uow.Repository<ViewEndDay>().GetAll()
                .Where(a => a.Numend == numend && a.Kind == kind)
                .Select(a => new EndDayShow { Amount =a.Amount.Value, CodFuel = a.Codfuel, Depart = a.Depart, Kind = a.Kind, Name = a.Name, Pay = a.Pay.Value, Price = a.Price})
                .ToList();
            
            //var newTov_all = uow.Repository<Tov_all>().GetAll().Where(a => a.Numend == numend).Where(a => a.Kind == kind);

            //var newFuel = uow.Repository<Fuel>().GetAll();

            return viewEndDayList;
        }
Beispiel #33
0
 public UserBLL()
 {
     unitOfWork = new GenericUnitOfWork();
     unitOfWork.SaveChanges();
 }
        public string saveEmployee(Image newImage, string name, string middleName, string lastName, string email, FaceRecognizerMethode faceRecognizerMethode)
        {
            unitOfWork = new GenericUnitOfWork();
            GenericRepository<Employee> employeeRepo = unitOfWork.GetRepoInstance<Employee>();

            Employee employee = null;
            try
            {

                employee = (employeeRepo.GetAllRecords().Where<Employee>(e => e.email == email)).First<Employee>();
            }
            catch
            {
                Debug.WriteLine("Nuevo usuario");
            }

            //Add Employee if not exist. The email is unique
            if (employee == null)
            {
                employee = new Employee { name = name, middleName = middleName, lastName = lastName, email = email };
                employeeRepo.Add(employee);
                unitOfWork.SaveChanges();
            }

            //I save the image with a guid as a name
            GenericRepository<DistanceResult> distanceResultRepo = unitOfWork.GetRepoInstance<DistanceResult>();
            Guid guid = Guid.NewGuid();

            var inputImage = new Image<Bgr, Byte>(new Bitmap(newImage));
            Rectangle[] rectangleFace = detection(inputImage, pathXMLHaarcascade);

            //The function detection(..) can extract N faces

            if (rectangleFace.Length <= 0)
            {
                return Result.NoDetected.ToString();
            }
            else if (rectangleFace.Length > 1)
            {
                return Result.MultipleFacesDetected.ToString();
            }
            else
            {
                Image<Gray, byte> grayFrame = toGrayEqualizeFrame(inputImage);

                Image<Gray, Byte> faceEMGUCV = formatRectangleFaces(grayFrame.ToBitmap(), rectangleFace[0]);

                faceEMGUCV._EqualizeHist();

                faceEMGUCV.Save(pathImg + @"\" + guid.ToString()+".Jpeg");

                FaceRecognizer faceRecognition;

                switch (faceRecognizerMethode.ToString())
                {
                    case "EigenFaceRecognizerMethode": faceRecognition = new EigenFaceRecognizer(numComponentsEigen, thresholdEigen); //try catch aca
                        break;
                    case "FisherFaceRecognizerMethode": faceRecognition = new FisherFaceRecognizer(numComponentsFisher, thresholdFisher);
                        break;
                    case "LBPHFaceRecognizerMethode": faceRecognition = new LBPHFaceRecognizer(radiusLBPH, neighborsLBPH, gridXLBPH, gridYLBPH, thresholdLBPH);
                        break;
                    default: return null;
                };

                double distance = 2;

                //Save register
                DistanceResult dist = new DistanceResult();
                dist.algorithm = RecognizeBLL.FaceRecognizerMethode.FisherFaceRecognizerMethode.ToString();
                dist.employeeId = employee.employeeId;
                dist.photoName = guid.ToString();
                dist.distance = distance;
                distanceResultRepo.Add(dist);

                unitOfWork.SaveChanges();

                int lengthArrays = distanceResultRepo.GetAllRecords().Count();
                imagesDB = new Image<Gray, Byte>[lengthArrays];
                labels = new int[lengthArrays];
                int i = 0;
                foreach (DistanceResult di in distanceResultRepo.GetAllRecords())
                {
                    //This is to recalculate the faceRecognition and save it, but I think is not necesari declare imageDB and labels as global
                    imagesDB[i] = new Image<Gray, Byte>(pathImg + @"\" + di.photoName + ".Jpeg");
                    labels[i] = di.employeeId;
                    i++;
                }

                if (employeeRepo.GetAllRecords().Count() > 1)
                {
                    faceRecognition.Train(imagesDB, labels);
                    faceRecognition.Save(pathImg + @"\" + "TrainingSet");
                }
                return Result.Saved.ToString();
            }
            //return Result.Error.ToString();
        }