예제 #1
0
        public ActionResult AppStart()
        {
            System.Exception ex = Server.GetLastError();
            Server.ClearError();

            AnvilExceptionModel ec = null;
            if (ex == null)
            {
                ec = new AnvilExceptionModel(new Exception("An unknown error prevented this application from starting"), "Application Start Failure", null, null, null);
            }
            else
            {
                ec = new AnvilExceptionModel(ex, "Application Start Failure", null, null, null);
            }

            return View(ec);
        }
예제 #2
0
        public ActionResult ArchiveComputer(ComputerInfo m)
        {
            try
            {
                RemoteComputer c = new RemoteComputer(m.ComputerName, @"lcps\earlyms", "Lcp$-pw1");

                c.Refresh();

                c.DBAcrchive(m, User.Identity.Name);

                return View("Index", new { name = m.ComputerName });
            }
            catch (Exception ex)
            {
                AnvilExceptionModel em = new AnvilExceptionModel(ex, "Archive Computer", "Computers", "Computers", "Index");
                return View("Error", em);
            }
        }
예제 #3
0
        public ActionResult AddStaffClause(StaffFilterClauseModel m)
        {
            if (!m.BuildingInclude & !m.EmployeeTypeInclude & !m.JobTitleInclude & !m.StatusInclude & !m.StaffIdInclude & !m.LastNameInclude)
                ModelState.AddModelError("", "Please include at least one field in the filter");

            MemberFilter f = null;

            try
            {
                f = DbContext.MemberFilters.First(x => x.FilterId.Equals(m.FilterId));
            }
            catch
            {
                ModelState.AddModelError("", "Invalid filter id");
            }

            int count = DbContext.StaffFilterClauses.Where(x => x.FilterId.Equals(m.FilterId)).Count();

            bool hasErrors = ViewData.ModelState.Values.Any(x => x.Errors.Count > 1);
            List<ModelState> errors = ViewData.ModelState.Values.Where(x => x.Errors.Count() > 0).ToList();

            if (ModelState.IsValid)
            {
                try
                {
                    StaffFilterClause c = new StaffFilterClause();

                    AnvilEntity e = new AnvilEntity(m);
                    e.CopyTo(c);
                    c.StaffFilterClauseId = Guid.NewGuid();
                    c.SortIndex = count;
                    DbContext.StaffFilterClauses.Add(c);
                    DbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    return View("~/Views/Shared/Error.cshtml", new AnvilExceptionModel(ex, "Create Staff Clause", "My", "Contacts", "EditStaffFilter"));
                }
            }
            else
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector("The staff filter clause could not be validated");
                foreach (ModelState ms in errors)
                {
                    foreach (var x in ms.Errors)
                    {
                        ec.Add(x.ErrorMessage);
                    }
                }

                AnvilExceptionModel em = new AnvilExceptionModel(ec.ToException(), "Create Staff Filter Clause", null, null, null);

                MemberFilterModel fm = new MemberFilterModel(f);

                fm.Exception = em;

                return View("EditFilter", fm);
            }

            return RedirectToAction("EditFilter", new { id = m.FilterId });
        }
예제 #4
0
        public ActionResult EditFilter(MemberFilter f)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    DbContext.Entry(f).State = System.Data.Entity.EntityState.Modified;
                    DbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    AnvilExceptionModel em = new AnvilExceptionModel(ex, "Edit Filter", "My", "Contacts", "Index");
                    return View("Error", em);
                }
            }

            return RedirectToAction("EditFilter", new { id = f.FilterId });
        }
예제 #5
0
        public ActionResult DeleteStudentFilter(Guid id)
        {
            try
            {
                MemberFilter f = DbContext.MemberFilters.Find(id);

                MemberFilterClass fc = f.FilterClass;

                List<StudentFilterClause> cc = DbContext.StudentFilterClauses
                    .Where(x => x.FilterId.Equals(id))
                    .ToList();

                DbContext.StudentFilterClauses.RemoveRange(cc);
                DbContext.SaveChanges();

                DbContext.MemberFilters.Remove(f);
                DbContext.SaveChanges();

                return RedirectToRoute("Index", new { c = fc });
            }
            catch (Exception ex)
            {
                AnvilExceptionModel em = new AnvilExceptionModel(ex, "Delete Student Filter", "My", "Contacts", "Index");
                return View("Error", em);
            }
        }
예제 #6
0
        public ActionResult DeleteStudentClause(Guid id)
        {
            try
            {
                StudentFilterClause c = DbContext.StudentFilterClauses.Find(id);
                Guid fid = c.FilterId;
                DbContext.StudentFilterClauses.Remove(c);
                DbContext.SaveChanges();
                return RedirectToAction("EditFilter", new { id = fid });
            }
            catch (Exception ex)
            {
                AnvilExceptionModel em = new AnvilExceptionModel(ex, "Create Student Clause", "Index", "Contacts", "Index");

                return View("Error", em);
            }
        }
예제 #7
0
        public ActionResult AddStudentClause(StudentFilterClauseModel m)
        {
            try
            {
                DynamicStudentFilter f = new DynamicStudentFilter(m.FilterId);
                f.CreateClause(m.ToFilterClause());
                f.Refresh();

                return RedirectToAction("EditFilter", new { id = m.FilterId });
            }
            catch (Exception ex)
            {
                AnvilExceptionModel em = new AnvilExceptionModel(ex, "Create Student Clause", m.FormArea, m.FormController, "Index");

                return View("Error", em);
            }
        }
예제 #8
0
 //
 // GET: /LcpsLdap/LdapOuTemplate/
 public ActionResult Index()
 {
     try
     {
         return View(new OUTemplateViewModel(DbContext));
     }
     catch(Exception ex)
     {
         AnvilExceptionModel em = new AnvilExceptionModel(ex, "OU Templates", "Public", "Home", "Index");
         return View("Error", em);
     }
 }
예제 #9
0
        // GET: /HumanResources/HRStaff/
        public ActionResult Index(int? page, int? pageSize)
        {
            StackTrace st = new StackTrace();
            StackFrame sf = st.GetFrame(0);

            MethodBase mb = sf.GetMethod();

            try
            {
                StaffFilterClauseModel m = this.StaffClause;
                DynamicStaffClause c = new DynamicStaffClause(m);
                List<HRStaffRecord> ss = c.Execute();

                ViewBag.Total = ss.Count().ToString();

                if (page == null)
                    page = 1;

                if (pageSize == null)
                    pageSize = 12;

                PagedList<HRStaffRecord> pl = new PagedList<HRStaffRecord>(ss, page.Value, pageSize.Value);

                return View(pl);
            }
            catch (Exception ex)
            {
                AnvilExceptionModel em = new AnvilExceptionModel(ex, "Get Staff Records", "Public", "Home", "Index");
                return View("Error", em);
            }
        }