Exemplo n.º 1
0
 Boolean ProcessItem(Int64 itemId, String itemName)
 {
     if (!_counters.ContainsKey(itemName))
     {
         _counters.Add(itemName, 0);
     }
     ReplicationService.PackageData pd = new ReplicationService.PackageData();
     using (var cmd = _cnn.CreateCommand())
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = String.Format("a2repl.get_{0}_for_send", itemName);
         cmd.Parameters.AddWithValue("@id", itemId);
         using (var rdr = cmd.ExecuteReader())
         {
             do
             {
                 var di = new ReplicationService.DataTable();
                 ReadDataTable(di, rdr);
                 while (rdr.Read())
                 {
                     ReadData(di, rdr);
                 }
                 if (pd.Tables == null)
                 {
                     pd.Tables = new List <ReplicationService.DataTable>();
                 }
                 pd.Tables.Add(di);
             } while (rdr.NextResult());
         }
     }
     pd.HasContent = pd.Tables != null;
     Log.Write("\t{0} Id={1}{2} ...", itemName, itemId.ToString(), SqlExtension.Id2String(itemId));
     pd.ItemName = itemName; // обязательно!
     pd.ItemId   = itemId;
     _client.SendPackage(_clientId, _sessionId, pd);
     using (var cmd = _cnn.CreateCommand())
     {
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.CommandText = String.Format("a2repl.set_{0}_sent", itemName);
         cmd.Parameters.AddWithValue("@sessionid", _sessionId);
         cmd.Parameters.AddWithValue("@id", itemId);
         cmd.ExecuteNonQuery();
     }
     Log.WriteLine("   успешно");
     _counters[itemName]++;
     return(true);
 }
Exemplo n.º 2
0
 Boolean ProcessPackage(ref Boolean bError)
 {
     // получаем ID и имя элемента для отправки
     ReplicationService.DataForGet dg = _client.GetItemForGet(_clientId, _sessionId);
     if (dg == null)
     {
         return(false); // нет данных
     }
     Log.Write("\t{0} Id={1}{2} ...", dg.TableName, dg.Id.ToString(), SqlExtension.Id2String(dg.Id));
     if (!ProcessOneElement(dg, ref bError))
     {
         Log.WriteLine("   ошибка");
         return(false);
     }
     Log.WriteLine("   успешно");
     return(true);
 }