public static void LogOut() { for (int i = 2; i < _sWindows.Count; i++) { object o = _sWindows[i]; if (o != null) { //if (o is System.Windows.Forms.Form) //{ // ((System.Windows.Forms.Form)o).Close(); //} //else if (o is System.Windows.Forms.ContainerControl) //{ // System.Windows.Forms.Form frm = ((System.Windows.Forms.ContainerControl)o).ParentForm; // if (frm != null) // { // frm.Close(); // frm = null; // } //} } } MSession session = MSession.Get(Env.GetContext(), false); // finish if (session != null) { session.Logout(); } VLogErrorBuffer.Get(true).ResetBuffer(false); Reset(true); }
public static void SessionEnd(Ctx ctx) { try { //VAdvantage.Logging.VLogMgt.Shutdown(ctx); MSession s = MSession.Get(ctx); if (s != null) { s.Logout(); } } catch { } }
// [ValidateAntiForgeryToken] //[Authorize] public ActionResult LogOff() { //WebSecurity.Logout(); try { Ctx ctx = Session["ctx"] as Ctx; //VAdvantage.Logging.VLogMgt.Shutdown(ctx); MSession s = MSession.Get(ctx); s.Logout(); } catch { } FormsAuthentication.SignOut(); //if (Session != null) // Session.Abandon(); return(RedirectToAction("Index", "Home")); }
//[Authorize] public ActionResult LogOff() { //WebSecurity.Logout(); try { MSession s = MSession.Get(Session["ctx"] as Ctx); s.Logout(); } catch { } FormsAuthentication.SignOut(); if (Session != null) { Session.Abandon(); } return(RedirectToAction("Index", "Home")); }
/// <summary> /// Return the Form pointer of WindowNo - or null /// </summary> /// <param name="WindowNo"></param> /// <returns></returns> /// <summary> /// Exit System /// </summary> /// <param name="status"></param> public static void ExitEnv(int status) { // End Session MSession session = MSession.Get(Env.GetContext(), false); // finish if (session != null) { session.Logout(); } // Reset(true); // final cache reset _log.Info(""); // VLogMgt.Shutdown(); // if (VAdvantage.DataBase.Ini.IsClient()) { Environment.Exit(status); } } // close
//[MethodImpl(MethodImplOptions.Synchronized)] //[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] /// <summary> /// Entry Point of Framework /// </summary> /// <param name="form"></param> /// <returns></returns> public ActionResult Index(FormCollection form) { //if (!User.Identity.IsAuthenticated) //{ // // Required to allow javascript redirection through to browser // this.Response.TrySkipIisCustomErrors = true; // this.Response.Status = "401 Unauthorized"; // this.Response.StatusCode = 401; // // note that the following line is .NET 4.5 or later only // // otherwise you have to suppress the return URL etc manually! // this.Response.SuppressFormsAuthenticationRedirect = true; // // If we got this far, something failed //} var url = CloudLogin.IsAllowedToLogin(Request.Url.ToString()); if (!string.IsNullOrEmpty(url)) { return(RedirectPermanent(url)); } VAdvantage.DataBase.DBConn.SetConnectionString();//Init database conection LoginModel model = null; if (User.Identity.IsAuthenticated) { try { //var conf = WebConfigurationManager.OpenWebConfiguration(System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath); // SessionStateSection section = (SessionStateSection) conf.GetSection("system.web/sessionState"); // int timeout = (int) section.Timeout.TotalMinutes; Session.Timeout = 20; // ideal timout } catch { } //AccountController a = new AccountController(); //a.LogOff(); FormsIdentity ident = User.Identity as FormsIdentity; Ctx ctx = null; if (ident != null) { FormsAuthenticationTicket ticket = ident.Ticket; string loginContextString = ticket.UserData;// get login context string from Form Ticket LoginContext lCtx = JsonHelper.Deserialize(loginContextString, typeof(LoginContext)) as LoginContext; IDataReader dr = null; //create class from string string key = ""; if (Session["ctx"] != null) { ctx = Session["ctx"] as Ctx; //Update Old Session MSession session = MSession.Get(ctx, false); if (session != null) { session.Logout(); } key = ctx.GetSecureKey(); //if (Session.Timeout < 2) //{ SessionEventHandler.SessionEnd(ctx); Session.Timeout = 17; //} Session["ctx"] = null; } ctx = new Ctx(lCtx.ctxMap); //cretae new context if (key != "") { ctx.SetSecureKey(key); } Session["ctx"] = ctx; //get login Language object on server var loginLang = ctx.GetAD_Language(); Language l = Language.GetLanguage(ctx.GetAD_Language()); //Language.GetLoginLanguage(); l = VAdvantage.Utility.Env.VerifyLanguage(ctx, l); ctx.SetContext(VAdvantage.Utility.Env.LANGUAGE, l.GetAD_Language()); ctx.SetContext(VAdvantage.Utility.Env.ISRIGHTTOLEFT, VAdvantage.Utility.Env.IsRightToLeft(loginLang) ? "Y" : "N"); new VAdvantage.Login.LoginProcess(ctx).LoadSysConfig(); ViewBag.culture = ctx.GetAD_Language(); ViewBag.direction = ctx.GetIsRightToLeft() ? "rtl" : "ltr"; //Change Authentication model = new LoginModel(); model.Login1Model = new Login1Model(); model.Login2Model = new Login2Model(); model.Login1Model.UserName = User.Identity.Name; model.Login1Model.LoginLanguage = ctx.GetAD_Language(); model.Login2Model.Role = ctx.GetAD_Role_ID().ToString(); model.Login2Model.Client = ctx.GetAD_Client_ID().ToString(); model.Login2Model.Org = ctx.GetAD_Org_ID().ToString(); model.Login2Model.Warehouse = ctx.GetAD_Warehouse_ID().ToString(); var RoleList = new List <KeyNamePair>(); var ClientList = new List <KeyNamePair>(); var OrgList = new List <KeyNamePair>(); var WareHouseList = new List <KeyNamePair>(); LoginHelper.Login(model, out RoleList); //string diableMenu = ctx.GetContext("#DisableMenu"); Helpers.MenuHelper mnuHelper = new Helpers.MenuHelper(ctx); // inilitilize menu class bool disableMenu = MRole.GetDefault(ctx).IsDisableMenu(); ctx.SetIsBasicDB(mnuHelper.GetIsBasicDB()); // If Home page not linked OR home page Linked BUT Menu is not disabled , then show home page. // If Home is linked as well as menu is disabled then don't load Default Home Page Settings if (MRole.GetDefault(ctx).GetHomePage_ID() == 0 || (MRole.GetDefault(ctx).GetHomePage_ID() > 0 && !disableMenu)) { HomeModels hm = new HomeModels(); objHomeHelp = new HomeHelper(); hm = objHomeHelp.getLoginUserInfo(ctx, 32, 32); ViewBag.UserPic = hm.UsrImage; } if (!disableMenu) // if menu is not disabled, only then load menu. { //get current user info ViewBag.Menu = mnuHelper.GetMenuTree(); // create tree Session["barNodes"] = ViewBag.Menu.GetBarNodes(); /* add is session to get it in favourite call */ ViewBag.TreeHtml = mnuHelper.GetMenuTreeUI(ViewBag.Menu.GetRootNode(), @Url.Content("~/")); } ViewBag.disableMenu = disableMenu; mnuHelper.dispose(); // LoginHelper.GetClients(id) ClientList = LoginHelper.GetClients(ctx.GetAD_Role_ID()); // .Add(new KeyNamePair(ctx.GetAD_Client_ID(), ctx.GetAD_Client_Name())); OrgList = LoginHelper.GetOrgs(ctx.GetAD_Role_ID(), ctx.GetAD_User_ID(), ctx.GetAD_Client_ID()); // .Add(new KeyNamePair(ctx.GetAD_Org_ID(), ctx.GetAD_Org_Name())); WareHouseList = LoginHelper.GetWarehouse(ctx.GetAD_Org_ID()); // .Add(new KeyNamePair(ctx.GetAD_Warehouse_ID(), ctx.GetContext("#M_Warehouse_Name"))); ViewBag.RoleList = RoleList; ViewBag.ClientList = ClientList; ViewBag.OrgList = OrgList; ViewBag.WarehouseList = WareHouseList; lock (_lock) // Locked bundle Object and session Creation to handle concurrent requests. { //Cretae new Sessin MSession sessionNew = MSession.Get(ctx, true, GetVisitorIPAddress(true)); var lst = VAdvantage.ModuleBundles.GetStyleBundles(); //Get All Style Bundle foreach (var b in lst) { if (!BundleTable.Bundles.Contains(b)) { BundleTable.Bundles.Add(b); //Add in Mvc Bundle Table } } var lstRTLStyle = VAdvantage.ModuleBundles.GetRTLStyleBundles(); //Get All Script Bundle foreach (var b in lstRTLStyle) { if (!BundleTable.Bundles.Contains(b)) { BundleTable.Bundles.Add(b); //Add in Mvc Bundlw Table } } var lstScript = VAdvantage.ModuleBundles.GetScriptBundles(); //Get All Script Bundle foreach (var b in lstScript) { if (!BundleTable.Bundles.Contains(b)) { BundleTable.Bundles.Add(b); //Add in Mvc Bundlw Table } } ViewBag.LibSuffix = ""; ViewBag.FrameSuffix = "_v1"; int libFound = 0; foreach (Bundle b in BundleTable.Bundles) { if (b.Path.Contains("ViennaBase") && b.Path.Contains("_v") && ViewBag.LibSuffix == "") { ViewBag.LibSuffix = Util.GetValueOfInt(ctx.GetContext("#FRONTEND_LIB_VERSION")) > 2 ? "_v3" : "_v2"; libFound++; } if (b.Path.Contains("VIS") && b.Path.Contains("_v")) { ViewBag.FrameSuffix = Util.GetValueOfInt(ctx.GetContext("#FRAMEWORK_VERSION")) > 1 ? "_v2" : "_v1"; libFound++; } if (libFound >= 2) { break; } } //check system setting// set to skipped lib } } } else { model = new LoginModel(); model.Login1Model = new Login1Model(); //model.Login1Model.UserName = "******"; //model.Login1Model.Password = "******"; model.Login1Model.LoginLanguage = "en_US"; model.Login2Model = new Login2Model(); ViewBag.RoleList = new List <KeyNamePair>(); ViewBag.OrgList = new List <KeyNamePair>(); ViewBag.WarehouseList = new List <KeyNamePair>(); ViewBag.ClientList = new List <KeyNamePair>(); ViewBag.Languages = Language.GetLanguages(); Session["ctx"] = null; ViewBag.direction = "ltr"; ViewBag.LibSuffix = ""; foreach (Bundle b in BundleTable.Bundles) { if (b.Path.Contains("ViennaBase") && b.Path.Contains("_v")) { ViewBag.LibSuffix = "_v2"; break; } } } return(View(model)); }
} // getActive public bool StopAll() { log.Info("Stop All log================================>" + DateTime.Now.Millisecond.ToString()); ViennaServer[] servers = GetActive(); // Interrupt for (int i = 0; i < servers.Length; i++) { ViennaServer server = servers[i]; try { if (server.GetServerThread().IsAlive) { server.SetPriority(ThreadPriority.Highest); server.Interrupt(); } } catch (Exception e) { log.Log(Level.SEVERE, "(Interrupting) - " + server, e); } } // for all servers Thread.Sleep(0); //yielding // Wait for death for (int i = 0; i < servers.Length; i++) { ViennaServer server = servers[i]; try { int maxWait = 10; // 10 iterations = 1 sec while (server.GetServerThread().IsAlive) { if (maxWait-- == 0) { log.Severe("Wait timeout for interruped " + server); break; } Thread.Sleep(100); // 1/10 } } catch (Exception e) { log.Log(Level.SEVERE, "(Waiting) - " + server, e); } } // for all servers // Final Check int noRunning = 0; int noStopped = 0; for (int i = 0; i < servers.Length; i++) { ViennaServer server = servers[i]; try { if (server.GetServerThread().IsAlive) { log.Warning("Alive: " + server); noRunning++; } else { log.Info("Stopped: " + server); noStopped++; } } catch (Exception e) { log.Log(Level.SEVERE, "(Checking) - " + server, e); noRunning++; } } // End Session MSession session = MSession.Get(Env.GetContext(), false); // finish if (session != null) { session.Logout(); } m_servers.Clear(); log.Fine("Running=" + noRunning + ", Stopped=" + noStopped); //ViennaServerGroup.Get().Dump(); return(noRunning == 0); } // stopAll