Exemple #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            ApplicationSetup();

            DataManager dataManager = DataManager.Instance;

            LogClient.Config logClientConfig = LogClient.Config.Instance;

            dataManager.LoadUserData();

            Current.MainWindow = new MainWindow();
            Current.MainWindow.Show();
        }
Exemple #2
0
        public Config()
        {
            logClientConfig = LogClient.Config.Instance;
            logClientConfig.SqlPasswordChangedEvent += UpdateEncryptedSqlPassword;
            while (!logClientConfig.KeySettingCompleted())
            {
                Thread.Sleep(2000);
                Console.WriteLine("Wait For AccessKey and SecretKey");
            }
            listData = new List <string>();
            dicData  = new Dictionary <Tuple <Category, Key>, string>();

            dataSettingFullName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dataSettingFileName);
            LoadFile2List(dataSettingFullName, listData);
            LoadDataList2Dictionary(listData, dicData);
            ConfigLoaded = true;


            while (true)
            {
                if (!logClientConfig.SqlIdPassordSettingCompleted())
                {
                    Thread.Sleep(2000);
                    Console.WriteLine("Wait For SqlId SqlPass");
                }
                else
                {
                    try
                    {
                        if (!LogClient.Config.Instance.GetValue(LogClient.Category.Repository, LogClient.Key.SqlEncryptedPassword).Trim().Equals(""))
                        {
                            DecryptedPassword = TranString.DecodeRijndael(
                                LogClient.Config.Instance.GetValue(LogClient.Category.Repository, LogClient.Key.SqlEncryptedPassword),
                                LogClient.Config.Instance.GetCryptionKey());
                        }
                        break;
                    }
                    catch (Exception ex)
                    {
                        log.Error(string.Format("Cryption Error : {0}, {1}", ex.Message, ex.StackTrace));
                        Thread.Sleep(2000);
                    }
                }
            }

            // Sender:::Type:::B     ncp
            if (GetValue(Category.Sender, Key.Type).Equals("b", StringComparison.OrdinalIgnoreCase))
            {
                log.Error("Database Create Skipped Sender:::Type:::B");
                DbConfigLoad();
                log.Error("database configuration load completed!");
            }
            else
            {
                //// schema gen
                CounterLoaded = false;
                if (IsExistsRepository(GetValue(Category.Repository, Key.InitialCatalog)))
                {
                    log.Warn("Database Create Skipped");
                }
                else
                {
                    try
                    {
                        if (!Directory.Exists(GetValue(Category.Repository, Key.DatabaseFilePath)))
                        {
                            Directory.CreateDirectory(GetValue(Category.Repository, Key.DatabaseFilePath));
                        }
                        if (!Directory.Exists(GetValue(Category.Repository, Key.LogFilePath)))
                        {
                            Directory.CreateDirectory(GetValue(Category.Repository, Key.LogFilePath));
                        }

                        if (Common.QueryExecuter(GetConnectionString(InitialCatalog.Master)
                                                 , string.Format(CreateRepositoryQuery,
                                                                 GetValue(Category.Repository, Key.InitialCatalog),
                                                                 GetValue(Category.Repository, Key.DatabaseFilePath),
                                                                 GetValue(Category.Repository, Key.LogFilePath))))
                        {
                            log.Warn("Database Create Success");
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
                    }
                }
            }

            try
            {
                CounterLoaded = IsExistsCounterDetails();

                if (GetValue(Category.Perfmon, Key.SkipLoadCounter).ToUpper() == "Y" && CounterLoaded)
                {
                    log.Warn("Schema Create Skipped");
                }
                else
                {
                    if (Common.QueryExecuter(GetConnectionString(InitialCatalog.Repository), CreateSchemaQuery))
                    {
                        log.Warn("Schema Create Success");
                    }
                    else
                    {
                        log.Warn("Schema Create Failed");
                    }
                }
                //// schema gen completed

                LocalIp   = Common.GetLocalIpAddress(IpType.LocalFirstIp);
                LocalPort = GetPort();
                SetSqlVersion();
            }
            catch (Exception ex)
            {
                log.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
            }
        }
Exemple #3
0
 public WcfRestServer(Dictionary <string, object> appInstances)
 {
     config = LogClient.Config.Instance;
 }