Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var path = args[0];

            OperationsAPI.initAPI();
            OperationsAPI.StageListPath = @"\Configs\ConnectStageList.xml";
            OperationsAPI.ConfigPath    = @"\Configs\ConnectConfig.xml";
            var globalConf = AsyncReplicaOperations.StageConnectSettings.getInstance();
            var localConf  = new GroupSettings(path);

            if (!localConf.isValid)
            {
                return;
            }

            foreach (RuntimeRegionSettings regionSetting in localConf.EntitiesList)
            {
                SqlConnection sqlConnection = new SqlConnection();
                try
                {
                    var sqlConnectionBuilder = new SqlConnectionStringBuilder();
                    sqlConnectionBuilder.DataSource         = globalConf.FindId(regionSetting.RegionId).ServerName;
                    sqlConnectionBuilder.InitialCatalog     = globalConf.FindId(regionSetting.RegionId).StageDBName;
                    sqlConnectionBuilder.IntegratedSecurity = true;
                    sqlConnection = new SqlConnection(sqlConnectionBuilder.ToString());
                    if (!SqlConnectionChecker.checkConnection(sqlConnection))
                    {
                        throw new Exception("Невозможно подключиться к региону " + regionSetting.RegionId);
                    }
                    var command = new SqlCommand("select FILEPATHSAVE,FILEPATHLOAD from REPLICAS", sqlConnection);
                    sqlConnection.Open();
                    using (var reader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                    {
                        while (reader.Read())
                        {
                            var flushPath = reader.GetString(0);
                            FlushFolder(flushPath);
                            Console.WriteLine(string.Format("[MESSAGE] {0:HH:mm:ss} Папка {1} успешно очищена", DateTime.Now, flushPath));
                            flushPath = reader.GetString(1);
                            FlushFolder(flushPath);
                            Console.WriteLine(string.Format("[MESSAGE] {0:HH:mm:ss} Папка {1} успешно очищена", DateTime.Now, flushPath));
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("[ERROR] {0:HH:mm:ss} {1}", DateTime.Now, e.Message));
                }
                finally
                {
                    if (sqlConnection.State == System.Data.ConnectionState.Open)
                    {
                        sqlConnection.Close();
                    }
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            OperationsAPI.initAPI();
            OperationsAPI.StageListPath = @"\Configs\ConnectStageList.xml";
            OperationsAPI.ConfigPath    = @"\Configs\ConnectConfig.xml";
            this.LoadConfigs();
            pullers = new List <AsyncSQLConnectPuller>();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            List <string> errorList = new List <string>();

            try
            {
                OperationsAPI.initAPI();
                OperationsAPI.StageListPath = @"\Configs\ConnectStageList.xml";
                Console.WriteLine("Начинается проверка...");
                var globalConf = StageConnectSettings.getInstance();

                if (globalConf.isValid)
                {
                    foreach (RegionSetting globalSetting in globalConf.EntitiesList)
                    {
                        var connectionBuilder = new SqlConnectionStringBuilder();
                        connectionBuilder.DataSource         = globalSetting.ServerName;
                        connectionBuilder.InitialCatalog     = globalSetting.StageDBName;
                        connectionBuilder.IntegratedSecurity = true;
                        connectionBuilder.ConnectTimeout     = 5;
                        connectionBuilder.ConnectRetryCount  = 1;
                        if (!SqlConnectionChecker.checkConnection(new SqlConnection(connectionBuilder.ToString())))
                        {
                            errorList.Add(globalSetting.RegionId);
                        }
                    }
                    if (errorList.Count > 0)
                    {
                        Console.WriteLine("Обнаружены ошибки при валидации:");
                        foreach (string item in errorList)
                        {
                            Console.WriteLine(string.Format("Регион {0} не валиден. Проверьте настройки соединения", item));
                        }
                    }
                    else
                    {
                        Console.WriteLine("Не обнаружены ошибки при валидации.");
                    }
                }
                else
                {
                    throw new Exception("Файл конфигурации не валиден");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Произошла следующая ошибка: " + e.Message);
            }
            finally
            {
                Console.ReadKey();
            }
        }
Ejemplo n.º 4
0
 private static void InitAPI()
 {
     OperationsAPI.initAPI();
     OperationsAPI.ConfigPath             = Properties.Settings.Default.ConfigPath;
     OperationsAPI.ExportReplicaProcedure = Properties.Settings.Default.ExportReplicaProc;
     OperationsAPI.Host = Properties.Settings.Default.Host;
     OperationsAPI.ImportReplicaProcedure = Properties.Settings.Default.ImportReplicaProc;
     OperationsAPI.MailCCRecep            = Properties.Settings.Default.MailCCRecep;
     OperationsAPI.MailRecep                      = Properties.Settings.Default.MailRecep;
     OperationsAPI.Port                           = Properties.Settings.Default.Port;
     OperationsAPI.RetryPackageCount              = Properties.Settings.Default.RetryPackageEndCount;
     OperationsAPI.SenderMail                     = Properties.Settings.Default.SenderMail;
     OperationsAPI.StageListPath                  = Properties.Settings.Default.StageListPath;
     OperationsAPI.ThreadCount                    = Properties.Settings.Default.ThreadCount;
     OperationsAPI.UseNotify                      = Properties.Settings.Default.UseNotify;
     OperationsAPI.PackageExistWaitTimeOut        = Properties.Settings.Default.WaitPackageForExist;
     Properties.Settings.Default.PropertyChanged += Default_PropertyChanged;
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            try
            {
                OperationsAPI.initAPI();
                OperationsAPI.StageListPath = @"\Configs\ConnectStageList.xml";
                Console.WriteLine("Начинается формирование конфигов...");
                var globalConf = StageConnectSettings.getInstance();

                if (globalConf.isValid)
                {
                    var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\AutoCreateConfigs";
                    if (Directory.Exists(path))
                    {
                        Console.WriteLine("Папка с логами существует.Папка будет удалена");
                        Directory.Delete(path, true);
                    }
                    foreach (RegionSetting globalSetting in globalConf.EntitiesList)
                    {
                        SaveConfig(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\AutoCreateConfigs", globalSetting.RegionId, DirectionsEnum.Import);
                        SaveConfig(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\AutoCreateConfigs", globalSetting.RegionId, DirectionsEnum.Export);
                    }
                    Console.WriteLine("Создание конфигов успешно");
                }
                else
                {
                    throw new Exception("Файл конфигурации не валиден");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Произошла следующая ошибка: " + e.Message);
            }
            finally
            {
                Console.ReadKey();
            }
        }
Ejemplo n.º 6
0
 static void InitSettings()
 {
     sqlConnectionBuilder = new SqlConnectionStringBuilder();
     sqlConnectionBuilder.ConnectRetryInterval = 3;
     sqlConnectionBuilder.IntegratedSecurity   = true;
     sqlConnectionBuilder.InitialCatalog       = "master";
     timer   = new Stopwatch();
     pullers = new List <AsyncSQLConnectPuller>();
     OperationsAPI.initAPI();
     OperationsAPI.ConfigPath             = Properties.Settings.Default.ConfigPath;
     OperationsAPI.ExportReplicaProcedure = Properties.Settings.Default.ExportReplicaProc;
     OperationsAPI.Host = Properties.Settings.Default.Host;
     OperationsAPI.ImportReplicaProcedure = Properties.Settings.Default.ImportReplicaProc;
     OperationsAPI.MailCCRecep            = Properties.Settings.Default.MailCCRecep;
     OperationsAPI.MailRecep               = Properties.Settings.Default.MailRecep;
     OperationsAPI.Port                    = Properties.Settings.Default.Port;
     OperationsAPI.RetryPackageCount       = Properties.Settings.Default.RetryPackageEndCount;
     OperationsAPI.SenderMail              = Properties.Settings.Default.SenderMail;
     OperationsAPI.StageListPath           = Properties.Settings.Default.StageListPath;
     OperationsAPI.ThreadCount             = Properties.Settings.Default.ThreadCount;
     OperationsAPI.UseNotify               = Properties.Settings.Default.UseNotify;
     OperationsAPI.PackageExistWaitTimeOut = Properties.Settings.Default.WaitPackageForExist;
     sqlConnection = new SqlConnection();
 }