コード例 #1
0
 public void fillPull(List <Restriction> values)
 {
     workDirectories = new Dictionary <string, string>();
     foreach (var s in values)
     {
         pullValue.Enqueue(s.ReplicaId);
         if (s.WorkDirectory != string.Empty)
         {
             workDirectories.Add(s.ReplicaId, s.WorkDirectory);
             if (!Directory.Exists(s.WorkDirectory))
             {
                 Directory.CreateDirectory(s.WorkDirectory);
             }
             else
             {
                 var flushCommand = new FlushFolder();
                 flushCommand.FolderPath = s.WorkDirectory;
                 flushCommand.RegionId   = this.RegionID;
                 preProcess += flushCommand.processAction;
             }
         }
     }
     lastElementCount = pullValue.Count;
 }
コード例 #2
0
        public void operatePull()
        {
            if (CommandText == String.Empty)
            {
                throw new Exception("Не заполнен шаблон текста команды.Операция будет прервана");
            }
            if (ConnectionString == String.Empty)
            {
                throw new Exception("Не заполнена строка соединения.Операция будет прервана");
            }
            if (pullValue.Count == 0)
            {
                throw new Exception("Пулл значений пуст.Операция будет прервана");
            }
            //ThreadPool.SetMaxThreads(WindowSize, WindowSize);
            if (workDirectories == null)
            {
                workDirectories = new Dictionary <string, string>();
            }
            foreach (var s in pullValue)
            {
                if (workDirectories.ContainsKey(s))
                {
                    continue;
                }
                var command = new SqlCommand(this.ExtractPathSQL, new SqlConnection(this.ConnectionString));
                command.Parameters.Add(new SqlParameter("Replica", s));
                if (command.Connection.State == System.Data.ConnectionState.Closed)
                {
                    command.Connection.Open();
                }
                using (var dataReader = command.ExecuteReader())
                {
                    dataReader.Read();
                    switch (direction)
                    {
                    case DirectionsEnum.Import:
                    {
                        workDirectories.Add(s, dataReader.GetString(0));
                        break;
                    }

                    case DirectionsEnum.Export:
                    {
                        workDirectories.Add(s, dataReader.GetString(1));
                        break;
                    }

                    default:
                        break;
                    }
                    var flushImportCommand = new FlushFolder();
                    flushImportCommand.FolderPath = dataReader.GetString(0);
                    flushImportCommand.RegionId   = this.RegionID;
                    this.preProcess += flushImportCommand.processAction;
                    var flushExportCommand = new FlushFolder();
                    flushExportCommand.FolderPath = dataReader.GetString(1);
                    flushExportCommand.RegionId   = this.RegionID;
                    this.preProcess += flushExportCommand.processAction;
                }
                if (command.Connection.State == System.Data.ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            try
            {
                preProcess();
            }
            catch
            {
            }

            Status = RunningStatusEnum.Running;
            this.RunProcess();
        }