示例#1
0
        public void Destroy()
        {
            if (File.Exists(path_to_dir + wrada_cookie + ".wjs"))
            {
                File.Delete(path_to_dir + wrada_cookie + ".wjs");
            }
            CurrentCookie = new SessionModel()
            {
                ClientIP = HttpContext.Current.Request.UserHostAddress,
                WSession = wrada_cookie,
                Role     = SessionModel.WRADA_Roles.Guest,
                ID       = "",
                UserName = "",
                Validity = DateTime.Now.AddHours(ValidityHours), Data = new Dictionary <string, object>()
            };

            string string_CurrentCookie = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

            File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie, System.Text.Encoding.Default);
        }
示例#2
0
 protected override void Dispose(bool disposing)
 {
     WUser = null;
     GC.Collect();
     base.Dispose(disposing);
 }
示例#3
0
        public void Destroy()
        {
            if (File.Exists(path_to_dir + wrada_cookie + ".wjs"))
                File.Delete(path_to_dir + wrada_cookie + ".wjs");
            CurrentCookie = new SessionModel()
                {
                    ClientIP = HttpContext.Current.Request.UserHostAddress,
                    WSession = wrada_cookie,
                    Role =SessionModel.WRADA_Roles.Guest,
                    ID = "",
                    UserName = "",
                    Validity = DateTime.Now.AddHours(ValidityHours), Data = new Dictionary<string,object>()
                };

            string string_CurrentCookie = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

            File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie, System.Text.Encoding.Default);
        }
示例#4
0
        public WRADA_AUTH_MVC()
        {
            if (System.IO.Directory.Exists(path_to_dir) == false)
            {
                System.IO.Directory.CreateDirectory(path_to_dir);
            }

            if (HttpContext.Current.Request.Cookies["WSession"] != null)
            {
                wrada_cookie = HttpContext.Current.Request.Cookies["WSession"].Value;
            }
            else
            {
                wrada_cookie = Guid.NewGuid().ToString();
                HttpContext.Current.Response.Cookies.Add(new HttpCookie("WSession", wrada_cookie));
            }

            if (File.Exists(path_to_dir + wrada_cookie + ".wjs") == false)
            {
                CurrentCookie = new SessionModel()
                {
                    ClientIP = HttpContext.Current.Request.UserHostAddress,
                    WSession = wrada_cookie,
                    Role = SessionModel.WRADA_Roles.Guest,
                    ID = "",
                    UserName = "",
                    Validity = DateTime.Now.AddHours(ValidityHours), Data = new Dictionary<string,object>()
                };

                string string_CurrentCookie = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

                File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie, System.Text.Encoding.Default);

            }
            else
            {

                string string_CurrentCookie = File.ReadAllText(path_to_dir + wrada_cookie + ".wjs", System.Text.Encoding.Default);

                CurrentCookie = Newtonsoft.Json.JsonConvert.DeserializeObject<SessionModel>(string_CurrentCookie);

                if (CurrentCookie.Validity < DateTime.Now)
                {
                    CurrentCookie = new SessionModel()
                    {
                        ClientIP = HttpContext.Current.Request.UserHostAddress,
                        WSession = wrada_cookie,
                        Role = SessionModel.WRADA_Roles.Guest,
                        ID = "",
                        UserName = "",
                        Validity = DateTime.Now.AddHours(ValidityHours),
                        Data = new Dictionary<string, object>()
                    };

                    string string_CurrentCookie2 = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

                    File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie2, System.Text.Encoding.Default);

                }

                if (CurrentCookie.ClientIP != HttpContext.Current.Request.UserHostAddress)
                {
                    CurrentCookie = new SessionModel()
                    {
                        ClientIP = HttpContext.Current.Request.UserHostAddress,
                        WSession = wrada_cookie,
                        Role = SessionModel.WRADA_Roles.Guest,
                        ID = "",
                        UserName = "",
                        Validity = DateTime.Now.AddHours(ValidityHours),
                        Data = new Dictionary<string, object>()
                    };

                    string string_CurrentCookie2 = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

                    File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie2, System.Text.Encoding.Default);

                }

                CurrentCookie.Validity = DateTime.Now.AddHours (ValidityHours);

                this.Save();

            }
        }
示例#5
0
        public WRADA_AUTH_MVC()
        {
            if (System.IO.Directory.Exists(path_to_dir) == false)
            {
                System.IO.Directory.CreateDirectory(path_to_dir);
            }

            if (HttpContext.Current.Request.Cookies["WSession"] != null)
            {
                wrada_cookie = HttpContext.Current.Request.Cookies["WSession"].Value;
            }
            else
            {
                wrada_cookie = Guid.NewGuid().ToString();
                HttpContext.Current.Response.Cookies.Add(new HttpCookie("WSession", wrada_cookie));
            }

            if (File.Exists(path_to_dir + wrada_cookie + ".wjs") == false)
            {
                CurrentCookie = new SessionModel()
                {
                    ClientIP = HttpContext.Current.Request.UserHostAddress,
                    WSession = wrada_cookie,
                    Role     = SessionModel.WRADA_Roles.Guest,
                    ID       = "",
                    UserName = "",
                    Validity = DateTime.Now.AddHours(ValidityHours), Data = new Dictionary <string, object>()
                };

                string string_CurrentCookie = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

                File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie, System.Text.Encoding.Default);
            }
            else
            {
                string string_CurrentCookie = File.ReadAllText(path_to_dir + wrada_cookie + ".wjs", System.Text.Encoding.Default);

                CurrentCookie = Newtonsoft.Json.JsonConvert.DeserializeObject <SessionModel>(string_CurrentCookie);

                if (CurrentCookie.Validity < DateTime.Now)
                {
                    CurrentCookie = new SessionModel()
                    {
                        ClientIP = HttpContext.Current.Request.UserHostAddress,
                        WSession = wrada_cookie,
                        Role     = SessionModel.WRADA_Roles.Guest,
                        ID       = "",
                        UserName = "",
                        Validity = DateTime.Now.AddHours(ValidityHours),
                        Data     = new Dictionary <string, object>()
                    };

                    string string_CurrentCookie2 = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

                    File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie2, System.Text.Encoding.Default);
                }

                if (CurrentCookie.ClientIP != HttpContext.Current.Request.UserHostAddress)
                {
                    CurrentCookie = new SessionModel()
                    {
                        ClientIP = HttpContext.Current.Request.UserHostAddress,
                        WSession = wrada_cookie,
                        Role     = SessionModel.WRADA_Roles.Guest,
                        ID       = "",
                        UserName = "",
                        Validity = DateTime.Now.AddHours(ValidityHours),
                        Data     = new Dictionary <string, object>()
                    };

                    string string_CurrentCookie2 = Newtonsoft.Json.JsonConvert.SerializeObject(CurrentCookie);

                    File.WriteAllText(path_to_dir + wrada_cookie + ".wjs", string_CurrentCookie2, System.Text.Encoding.Default);
                }

                CurrentCookie.Validity = DateTime.Now.AddHours(ValidityHours);

                this.Save();
            }
        }
示例#6
0
 protected override void Dispose(bool disposing)
 {
     WUser = null;
     GC.Collect();
     base.Dispose(disposing);
 }