private void OperateAuto() { try { var runTimeEnum = runtimeConfig.EntitiesList.Cast <RuntimeRegionSettings>().ToList().GetEnumerator(); while (runTimeEnum.MoveNext()) { TabItem tabItem = CreateLogTabItem(runTimeEnum.Current.RegionId); TabElement.Items.Add(tabItem); sqlConnectionBuilder.DataSource = runTimeEnum.Current.ServerName; sqlConnectionBuilder.InitialCatalog = runTimeEnum.Current.StageDBName; sqlConnection = new SqlConnection(sqlConnectionBuilder.ToString()); if (!AsyncReplicaOperations.SqlConnectionChecker.checkConnection(sqlConnection)) { throw new Exception(string.Format("Неудачное подключение к серверу по региону {0}", runTimeEnum.Current.RegionId)); } switch (runTimeEnum.Current.Direction) { case DirectionsEnum.Import: { direction = AsyncReplicaOperations.DirectionsEnum.Import; procName = OperationsAPI.ImportReplicaProcedure; break; } case DirectionsEnum.Export: { direction = AsyncReplicaOperations.DirectionsEnum.Export; procName = OperationsAPI.ExportReplicaProcedure; break; } } extractPathSQL = "select top 1 FILEPATHLOAD,FILEPATHSAVE from Replicas where REPLICAID = @Replica"; if (!AsyncReplicaOperations.SqlConnectionChecker.checkProcedure(sqlConnection, direction)) { throw new Exception(string.Format("Процедура не найдена в базе {0}.Продолжение невозможно.", sqlConnection.Database)); } var command = new SqlCommand { Connection = sqlConnection, CommandText = string.Format("use {0} select CAST(REPLICAID as varchar(8)) from REPLICAS", sqlConnection.Database) }; if (command.Connection.State != ConnectionState.Open) { command.Connection.Open(); } StartPuller(tabItem, command, runTimeEnum.Current); } } catch (Exception error) { MessageBox.Show(error.Message, "Возникла ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ManualSettings_Closing(object sender, System.ComponentModel.CancelEventArgs e) { var settings = (StageConnector)sender; serverName = settings.ServerName; stageName = settings.DBName; procName = settings.ProcName; direction = settings.Direction; }
private void DirectionSelector_Closing(object sender, System.ComponentModel.CancelEventArgs e) { direction = ((SelectDirection)sender).Direction; }
static private void OperateAuto() { var runTimeEnum = runTimeConfig.EntitiesList.Cast <RuntimeRegionSettings>().ToList().GetEnumerator(); while (runTimeEnum.MoveNext()) { try { sqlConnectionBuilder.DataSource = runTimeEnum.Current.ServerName; sqlConnectionBuilder.InitialCatalog = runTimeEnum.Current.StageDBName; sqlConnection = new SqlConnection(sqlConnectionBuilder.ToString()); if (!AsyncReplicaOperations.SqlConnectionChecker.checkConnection(sqlConnection)) { throw new Exception(string.Format("Неудачное подключение к серверу по региону {0}", runTimeEnum.Current.RegionId)); } switch (runTimeEnum.Current.Direction) { case DirectionsEnum.Import: { direction = AsyncReplicaOperations.DirectionsEnum.Import; procName = OperationsAPI.ImportReplicaProcedure; break; } case DirectionsEnum.Export: { direction = AsyncReplicaOperations.DirectionsEnum.Export; procName = OperationsAPI.ExportReplicaProcedure; break; } } extractPathSQL = "select top 1 FILEPATHLOAD,FILEPATHSAVE from Replicas where REPLICAID = @Replica"; if (!AsyncReplicaOperations.SqlConnectionChecker.checkProcedure(sqlConnection, direction)) { throw new Exception(string.Format("Процедура не найдена в базе {0}.Продолжение невозможно.", sqlConnection.Database)); } var command = new SqlCommand { Connection = sqlConnection, CommandText = string.Format(@"select CAST(REPLICAID as varchar(8)) from [{0}].[dbo].[REPLICAS] r inner join[{1}].[dbo].[GM_RETAILSTOREPARAMETERS] p on r.REPLICAID = p.STOREID where p.ISOFFLINE = 0 order by AWAREVERSION desc", sqlConnection.Database, sqlConnection.Database.Replace("STAGE", "AX")) }; if (command.Connection.State != ConnectionState.Open) { command.Connection.Open(); } StartPuller(command, runTimeEnum.Current); } catch (Exception error) { Console.WriteLine(error.Message); } } }