Example #1
0
 public static void ShowWindow(Guid kernelId, Action <bool, string> downloadComplete = null)
 {
     ContainerWindow.ShowWindow(new ContainerWindowViewModel {
         IconName      = "Icon_Logo",
         CloseVisible  = Visibility.Visible,
         HeaderVisible = Visibility.Collapsed,
         FooterVisible = Visibility.Collapsed,
         Width         = DevMode.IsDebugMode ? 1200 : AppStatic.MainWindowWidth,
         Height        = AppStatic.GetMainWindowHeight(isDevMode: false)
     },
                                ucFactory: (window) => {
         var uc         = new KernelPage();
         uc.CloseWindow = () => window.Close();
         return(uc);
     },
                                beforeShow: uc => {
         if (kernelId != Guid.Empty)
         {
             KernelPageViewModel vm = (KernelPageViewModel)uc.DataContext;
             vm.Download(kernelId, (isSuccess, message) => {
                 if (isSuccess)
                 {
                     ((KernelPage)uc).CloseWindow();
                 }
                 downloadComplete(isSuccess, message);
             });
         }
     }, fixedSize: true);
 }
Example #2
0
        public ActionResult AddArticle(Article article)
        {
            var data = new object();

            article.CreatedDate = DateTime.Now;
            article.UpdateDate  = DateTime.Now;

            try
            {
                using (var db = new DIYFE.EF.DIYFEEntities())
                {
                    db.Articles.Add(article);
                    db.SaveChanges();
                }
                AppStatic.LoadStaticCache();
                data = new { success = true };
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message != null)
                {
                    data = new { success = false, message = ex.InnerException.Message };
                }
                else
                {
                    data = new { success = false, message = ex.Message + " Another reason why EF sucks" };
                }
                return(Json(data));
            }

            return(Json(data));
        }
Example #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            AppStatic.LoadStaticCache();

            RegisterGlobalFilters(GlobalFilters.Filters);
            //RegisterRoutes(RouteTable.Routes);

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(System.Web.Optimization.BundleTable.Bundles);
            //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
        }
Example #4
0
        public ActionResult AddCategory(DIYFE.EF.Category category)
        {
            var data = new object();

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                if (category.ThirdLevCategoryId == 0 && category.SecondLevCategoryId != 0)
                {
                    category.ThirdLevCategoryId = db.Categories.Max(c => c.ThirdLevCategoryId).Value;
                }
                if (category.SecondLevCategoryId == 0)
                {
                    category.SecondLevCategoryId = db.Categories.Max(c => c.SecondLevCategoryId).Value;
                }
                if (category.CategoryId == 0)
                {
                    category.CategoryId = db.Categories.Max(c => c.CategoryId);
                }
                db.Categories.Add(category);
                db.SaveChanges();
                data = new { success = true };
                //allCats = db.Categories.ToList();
            }

            AppStatic.LoadStaticCache();

            //Category cat = new Category();
            //if (cat.InsertCategory(category))
            //{
            //    AppStatic.LoadStaticCache();
            //    data = new { success = true };
            //}
            //else
            //{
            //    data = new { success = false, message = "Failed to insert new category." };
            //    return Json(data);
            //}

            return(Json(data));
        }
Example #5
0
        public ActionResult Login(LoginViewModel user)
        {
            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                }

                if (ModelState.IsValid)
                {
                    XElement res = AppStatic.SystemController.UserLogin(user.UserName, user.Password);
                    if (AppStatic.SystemController.Status)
                    {
                        XElement resss = AppStatic.SystemController.UserProfile(res.Value);

                        SystemUser loggedUser = new SystemUser().FromXml(resss.Element("SystemUser"));
                        loggedUser.UserName = user.UserName;
                        List <Claim> claims = new List <Claim>();
                        claims.Add(new Claim(ClaimTypes.Name, loggedUser.UserName));
                        claims.Add(new Claim(ClaimTypes.NameIdentifier, loggedUser.USER_ID.ToString()));

                        if (loggedUser.UserID != 0)
                        {
                            claims.Add(new Claim("UserID", loggedUser.USER_ID.ToString()));
                        }
                        if (loggedUser.USER_DEPARTMENT_ID != 0)
                        {
                            claims.Add(new Claim("DepartmentID", loggedUser.USER_DEPARTMENT_ID.ToString()));
                        }
                        if (loggedUser.USER_DEPARTMENT_ID != 0)
                        {
                            claims.Add(new Claim("DepartmentName", loggedUser.DEPARTMENT_NAME));
                        }
                        if (loggedUser.USER_TYPE_NAME != "")
                        {
                            claims.Add(new Claim("USER_TYPE", loggedUser.USER_TYPE_NAME));
                        }
                        if (loggedUser.USER_NAME != "")
                        {
                            claims.Add(new Claim("USER_NAME", loggedUser.USER_NAME));
                        }

                        var identity = new ClaimsIdentity(
                            claims,
                            DefaultAuthenticationTypes.ApplicationCookie,
                            ClaimTypes.Name, ClaimTypes.Role);

                        if (loggedUser.USER_TYPE_NAME.ToUpper() == "ADMIN")
                        {
                            identity.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
                        }
                        if (loggedUser.USER_TYPE_NAME.ToUpper() == "HEAD_AUDITOR")
                        {
                            identity.AddClaim(new Claim(ClaimTypes.Role, "Head_Auditor"));
                        }
                        if (loggedUser.USER_TYPE_NAME.ToUpper() == "BRANCH_AUDITOR")
                        {
                            identity.AddClaim(new Claim(ClaimTypes.Role, "Branch_Auditor"));
                        }
                        if (loggedUser.USER_TYPE_NAME.ToUpper() == "DIRECTOR")
                        {
                            identity.AddClaim(new Claim(ClaimTypes.Role, "Director"));
                        }

                        Authentication.SignIn(new AuthenticationProperties {
                            IsPersistent = true
                        }, identity);

                        //return RedirectToAction("Index", "Home", new { Area = "" });
                        return(RedirectToAction("Home", "Home", new { Area = "" }));
                    }
                    else
                    {
                        AppStatic.SetError(AppStatic.SystemController.GetErrors(), AppStatic.SystemController.Message, ModelState);
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                Globals.WriteErrorLog(ex);
            }
            return(View());
        }