Пример #1
0
 /// <summary>
 /// Sybase internal use only.
 /// <summary>
 public static void SaveBatch()
 {
     Sybase.Persistence.ConnectionWrapper     _conn    = YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.AcquireDBWriteConnection();
     YPF.Comercial.RRCC.SUP.LocalKeyGenerator _batch_2 = YPF.Comercial.RRCC.SUP.LocalKeyGenerator.ID_BATCH;
     lock (_batch_2)
     {
         bool ok_3 = false;
         Sybase.Persistence.LocalTransaction tran = null;
         try
         {
             tran = _conn.BeginTransaction();
             _batch_2.Update();
             ok_3 = true;
         }
         finally
         {
             if (ok_3)
             {
                 tran.Commit();
             }
             else if (tran != null)
             {
                 tran.Rollback();
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Sybase internal use only.
        /// <summary>
        public static bool InitSync()
        {
            //lock(typeof(YPF.Comercial.RRCC.SUP.CRMMobileDesaDB))
            //{
            Sybase.Persistence.LocalTransaction _tran = null;
            bool ok_3 = false;

            try
            {
                Sybase.Persistence.ConnectionWrapper _conn = YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.AcquireDBWriteConnection();
                _tran = _conn.BeginTransaction();
                ok_3  = false;

                Sybase.Collections.GenericList <YPF.Comercial.RRCC.SUP.KeyGenerator> list_4 = YPF.Comercial.RRCC.SUP.KeyGenerator.FindAll();
                int size_5 = list_4.Count;
                if ((size_5 == 0))
                {
                    YPF.Comercial.RRCC.SUP.KeyGenerator batch_6 = new YPF.Comercial.RRCC.SUP.KeyGenerator();
                    batch_6.RemoteId = (".");
                    batch_6.BatchId  = (1);
                    batch_6.LastId   = (-1);
                    batch_6.Create();
                    YPF.Comercial.RRCC.SUP.KeyGenerator batch_7 = new YPF.Comercial.RRCC.SUP.KeyGenerator();
                    batch_7.RemoteId = (".");
                    batch_7.BatchId  = (2);
                    batch_7.LastId   = (-1);
                    batch_7.Create();
                    ok_3 = true;
                    return(true);
                }
                if ((size_5 == 4))
                {
                    foreach (YPF.Comercial.RRCC.SUP.KeyGenerator item_8 in list_4)
                    {
                        if ((item_8.LastId == -1))
                        {
                            item_8.Delete();
                        }
                    }
                    list_4 = YPF.Comercial.RRCC.SUP.KeyGenerator.FindAll();
                }
                YPF.Comercial.RRCC.SUP.KeyGenerator batch_10 = list_4[0];
                ok_3 = true;
                long last_11 = batch_10.LastId;
                long next_12 = batch_10.NextId;
                return(((last_11 == -1)) || (next_12 > last_11));
            }
            finally
            {
                if (ok_3)
                {
                    _tran.Commit();
                }
                else
                {
                    _tran.Rollback();
                }
            }
            //}
        }
Пример #3
0
 /// <summary>
 /// Sybase internal use only.
 /// <summary>
 public void NextBatch()
 {
     //lock(typeof(YPF.Comercial.RRCC.SUP.CRMMobileDesaDB))
     //{
     Sybase.Persistence.ConnectionWrapper       _conn   = YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.AcquireDBWriteConnection();
     Sybase.Persistence.LocalTransaction        _tran_1 = _conn.BeginTransaction();
     YPF.Comercial.RRCC.SUP.LocalKeyGeneratorPK _pk_2   = new YPF.Comercial.RRCC.SUP.LocalKeyGeneratorPK();
     _pk_2.RemoteId = ("*");
     _pk_2.BatchId  = (1);
     YPF.Comercial.RRCC.SUP.LocalKeyGenerator _batch_3 = YPF.Comercial.RRCC.SUP.LocalKeyGenerator.Find(_pk_2);
     if (_batch_3 == null)
     {
         _batch_3          = new YPF.Comercial.RRCC.SUP.LocalKeyGenerator();
         _batch_3.RemoteId = (_pk_2.RemoteId);
         _batch_3.BatchId  = (_pk_2.BatchId);
         _batch_3.FirstId  = (1);
         _batch_3.NextId   = (1 + 100000);
         // _batch_3.LastId =(9223372036854775807);
         _batch_3.LastId = (2147483647);
         _batch_3.Save();
         this.RemoteId = ("*");
         this.BatchId  = (1);
         this.FirstId  = (1);
         this.NextId   = (1);
         this.LastId   = (100000);
     }
     else
     {
         long _next_4 = _batch_3.NextId;
         long _next_5 = _next_4 + 100000;
         _batch_3.NextId = (_next_5);
         _batch_3.Save();
         this.FirstId = (_next_4);
         this.NextId  = (_next_4);
         this.LastId  = (_next_5 - 1);
     }
     _tran_1.Commit();
     //}
 }
        /// <summary>
        /// Sybase internal use only.
        /// <summary>
        public void RbsReplayInternal(YPF.Comercial.RRCC.SUP.RelevamientoProducto entity)
        {
            YPF.Comercial.RRCC.SUP.intrnl.OperationReplay _replay = new YPF.Comercial.RRCC.SUP.intrnl.OperationReplay();
            _replay.RemoteId  = (".");
            _replay.Component = ("CRMMobileDesa.RelevamientoProducto_rs");
            _replay.EntityKey = (entity.KeyToString());
            _replay.Operation = (entity.LastOperation);
            bool _includeBig = !("delete").Equals(_replay.Operation);

            com.sybase.afx.json.JsonObject _parameters = new com.sybase.afx.json.JsonObject();
            _parameters.Put("entity", YPF.Comercial.RRCC.SUP.RelevamientoProducto.__toJSON(entity, _includeBig));
            //_replay.Parameters =(_parameters.ToString());
            //lock(typeof(YPF.Comercial.RRCC.SUP.CRMMobileDesaDB))
            //{
            Sybase.Persistence.ConnectionWrapper _conn = YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.AcquireDBWriteConnection();
            Sybase.Persistence.LocalTransaction  _tran = null;
            try
            {
                _tran = _conn.BeginTransaction();

                com.sybase.afx.json.JsonObject _json = new com.sybase.afx.json.JsonObject();
                _replay.Attributes = (_json.ToString());
                _replay.Save();
                _replay.SaveParameter(_parameters);
                _tran.Commit();
            }
            catch (Sybase.Persistence.PersistenceException pe)
            {
                _tran.Rollback();
                throw pe;
            }
            catch (System.ApplicationException e)
            {
                _tran.Rollback();
                throw e;
            }
            //}
        }
        public void Finish_rbsReplayInternal(Sybase.Persistence.IOperationReplay _call_tmp)
        {
            YPF.Comercial.RRCC.SUP.intrnl.OperationReplay _call = (YPF.Comercial.RRCC.SUP.intrnl.OperationReplay)_call_tmp;
            com.sybase.afx.json.JsonObject parameters           = (com.sybase.afx.json.JsonObject)(com.sybase.afx.json.JsonReader
                                                                                                   .Parse(_call.Parameters));
            string exception = _call.Exception;

            YPF.Comercial.RRCC.SUP.RelevamientoProducto entity = (YPF.Comercial.RRCC.SUP.RelevamientoProducto)(YPF.Comercial.RRCC.SUP.RelevamientoProducto.__fromJSON(parameters.Get("entity")));

            //lock(typeof(YPF.Comercial.RRCC.SUP.CRMMobileDesaDB))
            //{
            Sybase.Persistence.ConnectionWrapper conn = YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.AcquireDBWriteConnection();
            Sybase.Persistence.LocalTransaction  tran = null;
            try
            {
                tran = conn.BeginTransaction();

                long ____id = entity.ReplayCounter;
                YPF.Comercial.RRCC.SUP.RelevamientoProducto _client        = YPF.Comercial.RRCC.SUP.RelevamientoProducto.Find(entity._pk());
                YPF.Comercial.RRCC.SUP.RelevamientoProducto _downloadState = null;
                if (_client != null)
                {
                    _downloadState = _client.DownloadState;
                }
                if (exception == null)
                {
                    YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.GetCallbackHandler().OnReplaySuccess(_client == null ? entity : _client);
                    YPF.Comercial.RRCC.SUP.RelevamientoProducto.GetCallbackHandler().OnReplaySuccess(_client == null ? entity : _client);
                    if ((_client != null) && _client.IsPending)
                    {
                        long _rc = _client.ReplayPending;
                        if (_rc == ____id)
                        {
                            if (_rc == _client.ReplayCounter)
                            {
                                _client._cancelPending2(false);
                            }
                            else
                            {
                                _client.ReplayPending = 0;
                                _client.ReplayFailure = 0;
                                _client.__update(true);
                            }
                        }
                    }
                }
                else
                {
                    _client.ReplayFailure = (_client.ReplayPending);
                    _client._cascadeUpdateReplayCounterPending(false);
                    if (_client != null && _client.ReplayPending == ____id)
                    {
                        _client.ReplayPending = (0);
                        _client.ReplayCounter = (YPF.Comercial.RRCC.SUP.KeyGenerator.GenerateId());
                        _client.ReplayFailure = (____id);
                        _client.__update(true);
                        if (_downloadState != null)
                        {
                            _downloadState._update_os();
                        }
                    }
                    YPF.Comercial.RRCC.SUP.CRMMobileDesaDB.GetCallbackHandler().OnReplayFailure(_client);
                    YPF.Comercial.RRCC.SUP.RelevamientoProducto.GetCallbackHandler().OnReplayFailure(_client);
                }
                _call.Delete();
                tran.Commit();
            }
            catch (Sybase.Persistence.PersistenceException pe)
            {
                tran.Rollback();
                throw pe;
            }
            catch (System.ApplicationException e)
            {
                tran.Rollback();
                throw e;
            }
            //}
        }