Пример #1
0
        public static void Logout()
        {
            try
            {
                _watcher?.Dispose();
                _watcher = null;

                ResetCookie();
            }
            catch (Exception ex)
            { }
        }
Пример #2
0
        public static bool SetCookie(List <NameValue> headers)
        {
            if (CurrentCookie != null && expired != null && expired.Value > DateTime.Now)
            {
                return(true);
            }

            lock (lockObject)
            {
                try
                {
                    if (CurrentCookie != null && expired != null && expired.Value > DateTime.Now)
                    {
                        return(true);
                    }

                    var cookie = headers.FirstOrDefault(p => p.name == "Cookie").value;

                    Headers = headers;

                    UpdateCookies(cookie);

                    expired = DateTime.Now.AddMinutes(25);

                    var appSettings = ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetEntryAssembly().Location).AppSettings;
                    var exportPath  = appSettings.Settings["ExportFolder"].Value;

                    if (_watcher == null)
                    {
                        _watcher = new ExportDirectoryWatcher(exportPath);
                        _watcher.Run();
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);
                }
            }
        }