Exemplo n.º 1
0
            void RefreshThread(object o)
            {
                while (true)
                {
                    Thread.Sleep(50 * 60 * 1000); // Wait 50 Minutes...
                    //Thread.Sleep(1 * 60 * 1000);  // Wait 1 Minute for test...
                    LiveAuthClient client = this.AuthClient;
                    if (client != null)
                    {
                        Traces.Main_TraceEvent(TraceEventType.Information, 1, "Try to refresh token!");
                        bool res = client.ForceRefreshToken(result =>
                        {
                            // Result of refresh token
                            Traces.Main_TraceEvent(TraceEventType.Information, 1, "RefreshToken Result: State: {0}, Status: {1}", result.State, result.Status);

                            // Inform the others that the accesstoken has changed...
                            // INFO: Do we need to synchronize the access to the token!?
                            OnSessionChanged();
                        }
                                                            );
                        if (res == false)
                        {
                            Traces.Main_TraceEvent(TraceEventType.Error, 1, "RefreshToken failed (false)");
                        }
                    }
                }
            }
Exemplo n.º 2
0
        internal static void NewsgroupUpdateInfo(string groupName, string text, bool enabledPrefetch = false)
        {
            if (string.IsNullOrEmpty(text) == false)
            {
                Traces.Main_TraceEvent(TraceEventType.Information, 1, groupName + ": " + text);
            }

            if (sMainWindow == null)
            {
                return;
            }

            sMainWindow.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(() =>
            {
                // Try to find the group in the prefetch list and update the text...
                if (sMainWindow._groupViewSource != null)
                {
                    var uic = sMainWindow._groupViewSource.FirstOrDefault(
                        p => string.Equals(p.Name, groupName, StringComparison.OrdinalIgnoreCase));
                    if (uic != null)
                    {
                        if (string.IsNullOrEmpty(text) == false)
                        {
                            uic.Info = text;
                        }
                        if (enabledPrefetch)
                        {
                            uic.Action.ChangeCanExecute(true);
                        }
                    }
                }
            }));
        }
Exemplo n.º 3
0
 string GetString(RegistryKey key, string name)
 {
     try
     {
         var o = key.GetValue(name);
         if (o is string)
         {
             return((string)o);
         }
         var ic = o as IConvertible;
         if (ic != null)
         {
             try
             {
                 return(ic.ToString(System.Globalization.CultureInfo.InvariantCulture));
             }
             catch (Exception exp)
             {
                 Traces.Main_TraceEvent(TraceEventType.Critical, 1, "GetString.ToString: Error: {0}", NNTPServer.Traces.ExceptionToString(exp));
             }
         }
         if (o != null)
         {
             return(o.ToString());
         }
     }
     catch (Exception exp)
     {
         Traces.Main_TraceEvent(TraceEventType.Critical, 1, "GetString: Error: {0}", NNTPServer.Traces.ExceptionToString(exp));
     }
     return(null);
 }
Exemplo n.º 4
0
        static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            string expMsg = NNTPServer.Traces.ExceptionToString(e.ExceptionObject as Exception);

            if (string.IsNullOrEmpty(expMsg))
            {
                expMsg = "<Unknown Exception>";
            }
            Traces.Main_TraceEvent(System.Diagnostics.TraceEventType.Critical, 1, "UnhandledException: {0}",
                                   expMsg);

            var    exp = e.ExceptionObject as Exception;
            string msg = "<Unknown>";

            if (exp != null)
            {
                msg = exp.Message;
            }

            var dlg = new SendDebugDataWindow();

            dlg.UnhandledExceptionMessage = msg;
            if (dlg.ShowDialog() == true)
            {
                try
                {
                    var app = (App)Current;
                    app.SendLogs(expMsg, dlg.UsersEMail, dlg.UsersDescription, dlg.UserSendEmail);
                }
                catch { }
                Environment.Exit(-1);
            }
        }
Exemplo n.º 5
0
        static public UICache Load(string fileName)
        {
            try
            {
                if (Directory.Exists(Path.GetDirectoryName(fileName)) == false)
                {
                    return(null);
                }
                if (File.Exists(fileName) == false)
                {
                    return(null);
                }

                var ser = new XmlSerializer(typeof(UICache));
                using (var sr = new StreamReader(fileName))
                {
                    var res = ser.Deserialize(sr) as UICache;
                    return(res);
                }
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Critical, 1, "Error while deserializing UICache: {0}\r\n{1}", fileName, NNTPServer.Traces.ExceptionToString(exp));
            }
            return(null);
        }
Exemplo n.º 6
0
        void f_OnPrefetch(object sender, EventArgs e)
        {
            var g = sender as NewsgroupAnswers;

            if (g != null)
            {
                g.Info = "?";
                g.Action.ChangeCanExecute(false);
                System.Threading.ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    var t = o as MainWindow;
                    try
                    {
                        bool exceptionOccured;
                        t._forumsDataSource.GetNewsgroup("<self>", g.Name, true, out exceptionOccured);
                    }
                    catch (Exception exp)
                    {
                        Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp));
                        NewsgroupUpdateInfo(g.Name, string.Format("EXCEPTION: {0}", exp.Message), true);
                    }
                    NewsgroupUpdateInfo(g.Name, null, true); // Stelle auf jeden Fall sicher, dass der Button wieder enabled wird
                }, this);
            }
        }
Exemplo n.º 7
0
        private void StartBridgeAsync(Action <bool, string> onFinishedCallback)
        {
            int port = 119;
            int parsedPort;

            if (int.TryParse(txtPort.Text, out parsedPort))
            {
                port = parsedPort;
            }

            string domainName = UserSettings.Default.DomainName;

            lblInfo.Text       = "Starting server... please wait...";
            cmdStart.IsEnabled = false;

            var thread = new System.Threading.Thread(
                delegate(object o)
            {
                var t     = o as MainWindow;
                var bRes  = false;
                var error = string.Empty;
                try
                {
                    StartBridgeInternal(t, port, domainName);
                    bRes = true;
                }
                catch (Exception exp)
                {
                    Traces.Main_TraceEvent(TraceEventType.Error, 1, "StartBridgeInternal: {0}", NNTPServer.Traces.ExceptionToString(exp));
                    error = exp.Message;
                }
                t.Dispatcher.Invoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    new Action(
                        delegate
                {
                    if (bRes)
                    {
                        t.Started = true;
                    }
                    else
                    {
                        t.lblInfo.Text = error;
                        t.ApplySettings();  // for correcting the "LiveId auologin" menu entry
                    }
                    t.cmdStart.IsEnabled = true;
                    if (onFinishedCallback != null)
                    {
                        onFinishedCallback(bRes, error);
                    }
                }));
            });

            thread.IsBackground = true;
            thread.SetApartmentState(System.Threading.ApartmentState.STA);
            thread.Start(this);
        }
Exemplo n.º 8
0
 void SetInt32(RegistryKey key, string name, int value)
 {
     try
     {
         key.SetValue(name, value, RegistryValueKind.DWord);
     }
     catch (Exception exp)
     {
         Traces.Main_TraceEvent(TraceEventType.Critical, 1, "SetInt32: Error: {0}", NNTPServer.Traces.ExceptionToString(exp));
     }
 }
Exemplo n.º 9
0
 private void OnAuthCompleted(AuthResult result) // async
 {
     Traces.Main_TraceEvent(TraceEventType.Information, 1, string.Format("AuthResult: {0} - {1} - {2}",
                                                                         result.ErrorCode, result.ErrorDescription, result.AuthorizeCode));
     this.CleanupAuthForm();
     if (result.AuthorizeCode != null)
     {
         Task task = this.AuthClient.ExchangeAuthCodeAsync(result.AuthorizeCode).ContinueWith(t =>
         {
             if (t.Exception != null)
             {
                 return(t.Exception);
             }
             return(null);
         });
         task.Wait();
     }
 }
Exemplo n.º 10
0
 private void DoLogin()
 {
     //if (_liveConnectHelper == null)
     {
         _liveConnectHelper = new LiveConnectHelper();
         {
             // Notify about Session changes...
             _liveConnectHelper.SessionChanged += delegate(string accessToken, string refreshToken)
             {
                 Traces.Main_TraceEvent(TraceEventType.Information, 1,
                                        "Authenticated: Session changed! AccessToken: {0}, RefreshToken: {1}",
                                        accessToken, refreshToken);
                 AccessToken  = accessToken;
                 RefreshToken = refreshToken;
             };
         }
     }
     _liveConnectHelper.DoLogin(Win32Wnd);
 }
Exemplo n.º 11
0
        private void btnCopyToClipboard_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var o in this.lb.Items)
            {
                sb.Append(o);
                sb.AppendLine();
            }

            try
            {
                Clipboard.SetText(sb.ToString());
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp));
            }
        }
Exemplo n.º 12
0
 private void CmdLoadNewsgroupListClick(object sender, RoutedEventArgs e)
 {
     cmdLoadNewsgroupList.IsEnabled = false;
     ThreadPool.QueueUserWorkItem(delegate(object o)
     {
         var t = o as MainWindow;
         try
         {
             var idx = 0;
             Traces.Main_TraceEvent(TraceEventType.Information, 1, "Start prefetching newsgroup list");
             SetPrefetchInfo(t, "Start prefetching newsgroup list", false);
             var groups = t._forumsDataSource.PrefetchNewsgroupList(
                 p => SetPrefetchInfo(t, string.Format("Group {0}: {1}", ++idx, p.GroupName), false));
             SetPrefetchInfo(t, string.Format("DONE: ({0} newsgroups)", idx), true);
             Traces.Main_TraceEvent(TraceEventType.Information, 1, "Prefetching DONE; {0} newsgroups", idx);
             if ((groups != null) && (groups.Count > 0))
             {
                 // Save UI-Cache and refresh
                 if (!t.Dispatcher.CheckAccess())
                 {
                     t.Dispatcher.Invoke(
                         System.Windows.Threading.DispatcherPriority.Normal,
                         new Action(
                             delegate
                     {
                         var uic = new NewsgroupAnswersCollection();
                         uic.AddRange(groups.Select(p => new NewsgroupAnswers()
                         {
                             Name = p.GroupName
                         }).OrderBy(p2 => p2.Name, StringComparer.InvariantCultureIgnoreCase)
                                      );
                         SaveUICache(uic);
                     }));
                 }
             }
         }
         catch (Exception exp)
         {
             SetPrefetchInfo(t, string.Format("Exception: {0}", NNTPServer.Traces.ExceptionToString(exp)), true);
         }
     }, this);
 }
Exemplo n.º 13
0
 public void Save(string filename)
 {
     try
     {
         var path = Path.GetDirectoryName(filename);
         if (Directory.Exists(path) == false)
         {
             Directory.CreateDirectory(path);
         }
         var ser = new XmlSerializer(typeof(UICache));
         using (var sw = new StreamWriter(filename))
         {
             ser.Serialize(sw, this);
         }
     }
     catch (Exception exp)
     {
         Traces.Main_TraceEvent(TraceEventType.Critical, 1, "Error while serializing UICache: {0}", NNTPServer.Traces.ExceptionToString(exp));
     }
 }
Exemplo n.º 14
0
 bool?GetBoolean(RegistryKey key, string name)
 {
     try
     {
         var iv = GetInt32(key, name);
         if (iv.HasValue)
         {
             if (iv.Value != 0)
             {
                 return(true);
             }
             return(false);
         }
     }
     catch (Exception exp)
     {
         Traces.Main_TraceEvent(TraceEventType.Critical, 1, "GetBoolean: Error: {0}", NNTPServer.Traces.ExceptionToString(exp));
     }
     return(null);
 }
Exemplo n.º 15
0
 private void mnuDebugWindow_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (mnuDebugWindow.IsChecked)
         {
             _debugWindow       = new DebugWindow();
             _debugWindow.Owner = this;
             _debugWindow.Show();
             _debugWindow.Closed += new EventHandler(_debugWindow_Closed);
         }
         else
         {
             _debugWindow.Close();
             _debugWindow = null;
         }
     }
     catch (Exception exp)
     {
         Traces.Main_TraceEvent(TraceEventType.Error, 1, "Error in mnuDebugWindow_click: {0}", NNTPServer.Traces.ExceptionToString(exp));
     }
 }
Exemplo n.º 16
0
        void SetEnum(RegistryKey key, string name, Enum value)
        {
            int iVal = 0;

            try
            {
                var ic = value as IConvertible;
                if (ic != null)
                {
                    iVal = ic.ToInt32(System.Globalization.CultureInfo.InvariantCulture);
                }
                else
                {
                    throw new NotSupportedException("Could not convert enum to int");
                }
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Critical, 1, "SetEnum {0}: Error: {1}", value, NNTPServer.Traces.ExceptionToString(exp));
                return;
            }
            SetInt32(key, name, iVal);
        }
Exemplo n.º 17
0
            private void OnSessionChanged()
            {
                LiveConnectSession session = this.AuthClient.Session;

                //bool isSignedIn = session != null;
                if (session != null)
                {
                    Traces.Main_TraceEvent(TraceEventType.Error, 1, "Session changed: Expires: {0}, AccessToken: {1}", session.Expires.ToString("u", System.Globalization.CultureInfo.InvariantCulture), session.AccessToken);

                    if (_RefreshThread == null)
                    {
                        _RefreshThread = new Thread(RefreshThread);
                        _RefreshThread.IsBackground = true;
                        _RefreshThread.Name         = "RefreshThread";
                        _RefreshThread.Start(null);
                    }

                    var handler = SessionChanged;
                    if (handler != null)
                    {
                        handler(session.AccessToken, session.RefreshToken);
                    }
                }
            }
Exemplo n.º 18
0
 private static void SwaggerLog(string s)
 {
     Traces.WebService_TraceEvent(TraceEventType.Verbose, 1, s);
 }
Exemplo n.º 19
0
        internal void SendLogs(string unhandledException, string userEmail, string userComment, bool userSendEmail)
        {
            string zipFile = null;

            try
            {
                zipFile = _logFile.CreateZipFile();
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp));
            }

            if (zipFile == null)
            {
                if (string.IsNullOrEmpty(unhandledException) == false)
                {
                    MessageBox.Show("Failed to ZIP the debug data! Please restart the bridge!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    MessageBox.Show("Failed to ZIP the debug data!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                return;
            }
            try
            {
                string err = UploadDiagnoseData.DoIt(zipFile, unhandledException, userEmail, userComment, userSendEmail);
                if (err == null)
                {
                    if (string.IsNullOrEmpty(unhandledException) == false)
                    {
                        MessageBox.Show("Debug data send... Thank your for helping to improve the bridge or find problems!\r\n\r\nPlease restart the bridge!");
                    }
                    else
                    {
                        MessageBox.Show("Debug data send... Thank your for helping to improve the bridge or find problems!");
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(unhandledException) == false)
                    {
                        MessageBox.Show("Failed to send debug data:\r\n" + err + "\r\n\r\nPlease restart the bridge!", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else
                    {
                        MessageBox.Show("Failed to send debug data:\r\n" + err, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                }
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp));
            }
            try
            {
                File.Delete(zipFile);
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp));
            }
        }
Exemplo n.º 20
0
 private static void SwaggerLogExp(string s, Exception exp)
 {
     Traces.WebService_TraceEvent(TraceEventType.Error, 1, "{0}:{1}{2}", s, Environment.NewLine, NNTPServer.Traces.ExceptionToString(exp));
 }
Exemplo n.º 21
0
        private static void StartBridgeInternal(MainWindow t, int port, string domainName)
        {
            string authenticationTicket = null;

            Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "LiveConnect: Try authentication");
            t.DoLogin();
            authenticationTicket = t.AccessToken;
            if (string.IsNullOrEmpty(authenticationTicket))
            {
                // Reset the RefreshToken, if the authentication has failed...
                UserSettings.Default.RefreshToken = string.Empty;
                Traces.Main_TraceEvent(TraceEventType.Error, 1, "Could not authenticate with LiveConnect!");
                throw new ApplicationException("Could not authenticate with LiveConnect!");
            }
            Traces.Main_TraceEvent(TraceEventType.Information, 1, "Authenticated: AccessToken: {0}", authenticationTicket);

            // Create the forums-ServiceProvider
            Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "Create forums service provider: {0}", "social");

#if true
            var provider = new WebServiceAnswers.SwaggerAccess();
            provider.UpdateAuthTicket(authenticationTicket);

            WebServiceAnswers.SwaggerAccess.Log    = SwaggerLog;
            WebServiceAnswers.SwaggerAccess.LogExp = SwaggerLogExp;
#else
            WebServiceAnswers.IForumData provider = new QnAClient("httpLiveAuth");
#endif
            t._Provider = provider;


            //if (provider.Endpoint.Behaviors.Contains(typeof(Microsoft.Support.Community.CpsAuthHeaderBehavior)))
            //{
            //  provider.Endpoint.Behaviors.Remove(typeof(Microsoft.Support.Community.CpsAuthHeaderBehavior));
            //}
            //t._answersAuthHeader = new Microsoft.Support.Community.CpsAuthHeaderBehavior(authenticationTicket);
            //provider.Endpoint.Behaviors.Add(t._answersAuthHeader);

            //foreach (var op in provider.Endpoint.Contract.Operations)
            //{
            //  var dcsb =
            //    op.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>();
            //  //if (dcsb == null)
            //  //{
            //  //  dcsb = new System.ServiceModel.Description.DataContractSerializerOperationBehavior(op);
            //  //}
            //  if (dcsb != null)
            //  {
            //    const int maxObj = 65536*100;
            //    if (dcsb.MaxItemsInObjectGraph < maxObj)
            //    dcsb.MaxItemsInObjectGraph = maxObj; // Default is 65536; increase it...
            //    //dcsb.IgnoreExtensionDataObject = true;
            //  }
            //}


            // Try to test the provider once:
            try
            {
                provider.GetSupportedLocales();
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Error, 1, NNTPServer.Traces.ExceptionToString(exp));
                throw;
            }

            // Create our DataSource for the forums
            Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "Creating datasource for NNTP server");
            t._forumsDataSource = new Answers.ForumDataSource(provider, domainName);
            t._forumsDataSource.UsePlainTextConverter      = UserSettings.Default.UsePlainTextConverter;
            t._forumsDataSource.AutoLineWrap               = UserSettings.Default.AutoLineWrap;
            t._forumsDataSource.HeaderEncoding             = UserSettings.Default.EncodingForClientEncoding;
            t._forumsDataSource.InMimeUseHtml              = (UserSettings.Default.InMimeUse == UserSettings.MimeContentType.TextHtml);
            t._forumsDataSource.UserDefinedTags            = UserSettings.Default.UserDefinedTags;
            t._forumsDataSource.ShowUserNamePostfix        = UserSettings.Default.ShowUserNamePostfix;
            t._forumsDataSource.PostsAreAlwaysFormatFlowed = UserSettings.Default.PostsAreAlwaysFormatFlowed;
            t._forumsDataSource.TabAsSpace          = UserSettings.Default.TabAsSpace;
            t._forumsDataSource.UseCodeColorizer    = UserSettings.Default.UseCodeColorizer;
            t._forumsDataSource.AddHistoryToArticle = UserSettings.Default.AddHistoryToArticle;

            t._forumsDataSource.ProgressData += t._forumsDataSource_ProgressData;


            // Now start the NNTP-Server
            Traces.Main_TraceEvent(TraceEventType.Verbose, 1, "Starting NNTP server");
            t._nntpServer = new NNTPServer.NntpServer(t._forumsDataSource, true);
            t._nntpServer.EncodingSend      = UserSettings.Default.EncodingForClientEncoding;
            t._nntpServer.ListGroupDisabled = UserSettings.Default.DisableLISTGROUP;
            //t._nntpServer.DetailedErrorResponse = detailedErrorResponse;
            string errorMessage;
            t._nntpServer.Start(port, 64, UserSettings.Default.BindToWorld, out errorMessage);
            if (errorMessage != null)
            {
                throw new ApplicationException(errorMessage);
            }
        }
Exemplo n.º 22
0
 private void OnAuthNavigatedUrl(string url)
 {
     Traces.Main_TraceEvent(TraceEventType.Information, 1, string.Format("AuthNavigatedUrl: {0}", url));
 }
Exemplo n.º 23
0
        void Load()
        {
            try
            {
                using (var r = UserAppDataRegistryForReading)
                {
                    if (r == null)
                    {
                        return;
                    }

                    int?   i;
                    bool?  b;
                    string s;

                    b = GetBoolean(r, "AutoStart");
                    if (b.HasValue)
                    {
                        AutoStart = b.Value;
                    }

                    b = GetBoolean(r, "AutoMinimize");
                    if (b.HasValue)
                    {
                        AutoMinimize = b.Value;
                    }

                    //b = GetBoolean(r, "DetailedErrorResponse");
                    //if (b.HasValue)
                    //    DetailedErrorResponse = b.Value;

                    b = GetBoolean(r, "BindToWorld");
                    if (b.HasValue)
                    {
                        BindToWorld = b.Value;
                    }

                    UsePlainTextConverters?ptc = GetEnum <UsePlainTextConverters>(r, "UsePlainTextConverterEnum");
                    if (ptc.HasValue)
                    {
                        UsePlainTextConverter = ptc.Value;
                    }

                    b = GetBoolean(r, "PostsAreAlwaysFormatFlowed");
                    if (b.HasValue)
                    {
                        PostsAreAlwaysFormatFlowed = b.Value;
                    }

                    i = GetInt32(r, "Port");
                    if (i.HasValue)
                    {
                        Port = i.Value;
                    }

                    //i = GetInt32(r, "ListPageSize");
                    //if (i.HasValue)
                    //    ListPageSize = i.Value;

                    //i = GetInt32(r, "ArticlePageSize");
                    //if (i.HasValue)
                    //    ArticlePageSize = i.Value;

                    s          = GetString(r, "DomainName");
                    DomainName = s;

                    //s = GetString(r, "UserEmail");
                    //UserEmail = s;

                    //s = GetString(r, "UserName");
                    //UserName = s;

                    s = GetString(r, "RefreshToken");
                    this.RefreshToken = s;

                    s = GetString(r, "ClientId");
                    if (string.IsNullOrEmpty(s) == false)
                    {
                        this.ClientId = s;
                    }

                    s = GetString(r, "Scopes");
                    if (string.IsNullOrEmpty(s) == false)
                    {
                        this.Scopes = s;
                    }

                    //s = GetString(r, "AuthenticationBlob");
                    //AuthenticationBlob = s;

                    i = GetInt32(r, "AutoLineWrap");
                    if (i.HasValue)
                    {
                        AutoLineWrap = i.Value;
                    }

                    s = GetString(r, "EncodingForClient");
                    EncodingForClient = s;

                    //s = GetString(r, "UserGuid");
                    //if (string.IsNullOrEmpty(s) == false)
                    //{
                    //    try
                    //    {
                    //        UserGuid = new Guid(s);
                    //    }
                    //    catch { }
                    //}

                    MimeContentType?mt = GetEnum <MimeContentType>(r, "InMimeUse");
                    if (mt.HasValue)
                    {
                        InMimeUse = mt.Value;
                    }

                    //b = GetBoolean(r, "UseAnswersForums");
                    //if (b.HasValue)
                    //    UseAnswersForums = b.Value;

                    //b = GetBoolean(r, "UseSocialForums");
                    //if (b.HasValue)
                    //    UseSocialForums = b.Value;

                    ArticleConverter.UserDefinedTagCollection.PreCompileXmlSerializer();
                    s = GetString(r, "UserDefinedTags");
                    if (string.IsNullOrEmpty(s) == false)
                    {
                        var u = ArticleConverter.UserDefinedTagCollection.FromString(s);
                        if (u != null)
                        {
                            _userDefinedTags = u;
                        }
                    }

                    ArticleConverter.UserMappingCollection.PreCompileXmlSerializer();
                    s = GetString(r, "UserMappings");
                    if (string.IsNullOrEmpty(s) == false)
                    {
                        var u = ArticleConverter.UserMappingCollection.FromString(s);
                        if (u != null)
                        {
                            _userMappings = u;
                        }
                    }

                    b = GetBoolean(r, "DisableUserAgentInfo");
                    if (b.HasValue)
                    {
                        DisableUserAgentInfo = b.Value;
                    }

                    b = GetBoolean(r, "DisableLISTGROUP");
                    if (b.HasValue)
                    {
                        DisableLISTGROUP = b.Value;
                    }

                    b = GetBoolean(r, "ShowUserNamePostfix");
                    if (b.HasValue)
                    {
                        ShowUserNamePostfix = b.Value;
                    }

                    i = GetInt32(r, "TabAsSpace");
                    if (i.HasValue)
                    {
                        TabAsSpace = i.Value;
                    }

                    b = GetBoolean(r, "UseCodeColorizer");
                    if (b.HasValue)
                    {
                        UseCodeColorizer = b.Value;
                    }

                    b = GetBoolean(r, "AddHistoryToArticle");
                    if (b.HasValue)
                    {
                        AddHistoryToArticle = b.Value;
                    }

                    i = GetInt32(r, "MaxThreadCountOnFirstretrival");
                    if (i.HasValue)
                    {
                        MaxThreadCountOnFirstRetrival = i.Value;
                    }

                    MetaInfoDisplay?mt2 = GetEnum <MetaInfoDisplay>(r, "MetaInfo");
                    if (mt2.HasValue)
                    {
                        MetaInfo = mt2.Value;
                    }

                    b = GetBoolean(r, "ShowUsersSignature");
                    if (b.HasValue)
                    {
                        ShowUsersSignature = b.Value;
                    }

                    UpdateInfoModeEnum?uim = GetEnum <UpdateInfoModeEnum>(r, "UpdateInfoMode");
                    if (uim.HasValue)
                    {
                        UpdateInfoMode = uim.Value;
                    }

                    MessageInfoEnum?mie = GetEnum <MessageInfoEnum>(r, "MessageInfos");
                    if (mie.HasValue)
                    {
                        MessageInfos = mie.Value;
                    }

                    b = GetBoolean(r, "SendSupersedesHeader");
                    if (b.HasValue)
                    {
                        SendSupersedesHeader = b.Value;
                    }

                    b = GetBoolean(r, "UpdateAsync");
                    if (b.HasValue)
                    {
                        UpdateAsync = b.Value;
                    }
                }
            }
            catch (Exception exp)
            {
                Traces.Main_TraceEvent(TraceEventType.Critical, 1, "Error loading settings from the registry: {0}", NNTPServer.Traces.ExceptionToString(exp));
            }
        }
Exemplo n.º 24
0
        public void Save()
        {
            lock (this)
            {
                try
                {
                    using (var r = UserAppDataRegistryForWriting)
                    {
                        SetBoolean(r, "AutoStart", AutoStart);

                        SetBoolean(r, "AutoMinimize", AutoMinimize);

                        //SetBoolean(r, "DetailedErrorResponse", DetailedErrorResponse);

                        SetBoolean(r, "BindToWorld", BindToWorld);

                        SetEnum(r, "UsePlainTextConverterEnum", UsePlainTextConverter);

                        SetBoolean(r, "PostsAreAlwaysFormatFlowed", PostsAreAlwaysFormatFlowed);

                        SetInt32(r, "Port", Port);

                        //SetInt32(r, "ListPageSize", ListPageSize);

                        //SetInt32(r, "ArticlePageSize", ArticlePageSize);

                        SetString(r, "DomainName", DomainName);

                        //SetString(r, "UserEmail", UserEmail);

                        //SetString(r, "UserName", UserName);

                        SetString(r, "ClientId", ClientId);
                        SetString(r, "RefreshToken", RefreshToken);
                        SetString(r, "Scopes", Scopes);

                        //SetString(r, "AuthenticationBlob", AuthenticationBlob);

                        SetInt32(r, "AutoLineWrap", AutoLineWrap);

                        SetString(r, "EncodingForClient", EncodingForClient);

                        //SetString(r, "UserGuid", UserGuid.ToString());

                        SetEnum(r, "InMimeUse", InMimeUse);

                        //SetBoolean(r, "UseAnswersForums", UseAnswersForums);

                        //SetBoolean(r, "UseSocialForums", UseSocialForums);

                        SetString(r, "UserDefinedTags", UserDefinedTags.GetString());

                        SetString(r, "UserMappings", UserMappings.GetString());

                        SetBoolean(r, "DisableUserAgentInfo", DisableUserAgentInfo);

                        SetBoolean(r, "DisableLISTGROUP", DisableLISTGROUP);

                        SetBoolean(r, "ShowUserNamePostfix", ShowUserNamePostfix);

                        SetInt32(r, "TabAsSpace", TabAsSpace);

                        SetBoolean(r, "UseCodeColorizer", UseCodeColorizer);

                        SetBoolean(r, "AddHistoryToArticle", AddHistoryToArticle);

                        SetInt32(r, "MaxThreadCountOnFirstretrival", MaxThreadCountOnFirstRetrival);

                        SetEnum(r, "MetaInfo", MetaInfo);

                        SetBoolean(r, "ShowUsersSignature", ShowUsersSignature);

                        SetEnum(r, "UpdateInfoMode", UpdateInfoMode);

                        SetEnum(r, "MessageInfos", MessageInfos);

                        SetBoolean(r, "SendSupersedesHeader", SendSupersedesHeader);

                        SetBoolean(r, "UpdateAsync", UpdateAsync);
                    }
                }
                catch (Exception exp)
                {
                    Traces.Main_TraceEvent(TraceEventType.Critical, 1, "Error saving settings to the registry: {0}",
                                           NNTPServer.Traces.ExceptionToString(exp));
                }
            }
        }