Пример #1
0
 private SpinerBaseBO(String p_basePath)
 {
     try
     {
         strBasePath   = p_basePath;
         configBase    = SpinerBaseConfig.Load(strBasePath);
         objRepository = null;
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        public void fnConnect(Connection p_connection)
        {
            try
            {
                if (objRepository is null == false)
                {
                    objRepository.Dispose();
                    objRepository = null;
                }

                objRepository = new Repository.SpinerBaseRep(p_connection);

                ConfigBase.LastConnection = p_connection;
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        public void sbDoMigration(Card p_migration)
        {
            Repository.SpinerBaseRep objTargetRepository;
            DataSet objReturn;
            int     intProcessed;
            bool    blnSucess;

            try

            {
                intProcessed = 0;

                //Read
                onEvProgress(0, 0, "Reading source data.");
                objReturn = objRepository.fnExecuteDataSet(p_migration);
                onEvProgress(0, 0, "Data retreived.");

                //Prepare target
                objTargetRepository = new Repository.SpinerBaseRep(p_migration.TargetConnection);
                onEvProgress(0, 0, "Connecting to target.");

                //Write
                onEvProgress(0, objReturn.Tables[0].Rows.Count, "Sending data to target.");
                objTargetRepository.Begin();
                blnSucess = true;
                foreach (DataRow row in objReturn.Tables[0].Rows)
                {
                    intProcessed++;
                    try
                    {
                        objTargetRepository.sbExecuteDirect(row[0].ToString(), false);
                        onEvProgress(intProcessed, objReturn.Tables[0].Rows.Count, "Processed: " + row[0].ToString());
                    }
                    catch (Exception ex)
                    {
                        onEvProgress(intProcessed, objReturn.Tables[0].Rows.Count, "Error: " + ex.Message);
                        blnSucess = false;
                        break;
                    }
                }

                if (blnSucess)
                {
                    onEvProgress(intProcessed, objReturn.Tables[0].Rows.Count, "Finished with sucess.");
                    objTargetRepository.Commit();
                }
                else
                {
                    onEvProgress(intProcessed, objReturn.Tables[0].Rows.Count, "Finished with error.");
                    objTargetRepository.RollBack();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                onEvFinished("Ok");
            }
        }