コード例 #1
0
        private static void UpdatePrimaryRegion(string productName, string uniqueId, string tableName)
        {
            Dictionary <string, string> primaryConfigs = MultiRegionConfig.GetConfigWithConfigKey(MultiRegionConfigTypes.PrimaryRegion, productName + "-RS-SQLCON");
            string        connectionString             = null;
            SqlConnection objSqlCon = null;

            primaryConfigs.ForEach(config => { connectionString = config.Value; });
            try
            {
                ReliableSqlDatabase sqlHelper = new ReliableSqlDatabase(connectionString);
                objSqlCon = (SqlConnection)sqlHelper.CreateConnection();
                objSqlCon.Open();
                SqlCommand objSqlCommand = new SqlCommand("UPDATE " + tableName + " SET isReplicated = 1 where Guid = '" + uniqueId + "'");
                objSqlCommand.CommandType = CommandType.Text;
                objSqlCommand.Connection  = objSqlCon;
                objSqlCommand.ExecuteNonQuery();
            }
            catch (Exception exp)
            {
                throw exp;
            }
            finally
            {
                if (objSqlCon.State == ConnectionState.Open)
                {
                    objSqlCon.Close();
                }
            }
        }
コード例 #2
0
        protected BaseSqlDataAccess(IGepService gepservice) : base(gepservice)
        {
            string constring = UserContext.GetConfig(PartnerConfigKey.SQL_CONNECTION);

            // This condition will not be there in real world scenario
            if (!string.IsNullOrEmpty(constring))
            {
                sqlHelper = new ReliableSqlDatabase(constring, internalLogger);
            }
        }
コード例 #3
0
        public static List <CommonProcessQueue> GetPrimaryRegionData(CommonProcessQueue sourceRegionMetadata, ReplicationRegion primaryRegion)
        {
            try
            {
                ReliableSqlDatabase sqlHelper     = new ReliableSqlDatabase(primaryRegion.ConnectionString);
                SqlConnection       objSqlCon     = null;
                DataSet             sourceDataSet = null;

                objSqlCon = (SqlConnection)sqlHelper.CreateConnection();
                objSqlCon.Open();
                using (SqlCommand objSqlCommand = new SqlCommand("select * from " + sourceRegionMetadata.TableName + " where isreplicated = 0"))
                {
                    objSqlCommand.CommandType = CommandType.Text;
                    sourceDataSet             = sqlHelper.ExecuteDataSet(objSqlCommand);
                }
                sourceDataSet.Tables[0].TableName = sourceRegionMetadata.TableName;

                List <CommonProcessQueue> cpqList = new List <CommonProcessQueue>();

                DataTable dataTable = sourceDataSet.Tables[0].Clone();
                dataTable.Columns["updatedon"].DateTimeMode = DataSetDateTime.Utc;
                dataTable = sourceDataSet.Tables[0];
                foreach (DataRow dr in dataTable.Rows)
                {
                    CommonProcessQueue cpq = new CommonProcessQueue
                    {
                        ReplicationConfigKey      = sourceRegionMetadata.ReplicationConfigKey,
                        ReplicationSourceRegionId = sourceRegionMetadata.ReplicationSourceRegionId,
                        TransactionDateTime       = ((DateTime)dr["updatedon"]).ToUniversalTime(),
                        Guid          = dr["guid"].ToString(),
                        TableName     = sourceRegionMetadata.TableName,
                        ProcessStatus = 1
                    };
                    cpqList.Add(cpq);
                }

                return(cpqList);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
コード例 #4
0
        public static DataTable GetPrimaryRegionDataForReplication(CommonProcessQueue sourceRegionMetadata, ReplicationRegion primaryRegion)
        {
            try
            {
                ReliableSqlDatabase sqlHelper     = new ReliableSqlDatabase(primaryRegion.ConnectionString);
                SqlConnection       objSqlCon     = null;
                DataSet             sourceDataSet = null;

                objSqlCon = (SqlConnection)sqlHelper.CreateConnection();
                objSqlCon.Open();
                using (SqlCommand objSqlCommand = new SqlCommand("select * from " + sourceRegionMetadata.TableName + " where isreplicated = 0"))
                {
                    objSqlCommand.CommandType = CommandType.Text;
                    sourceDataSet             = sqlHelper.ExecuteDataSet(objSqlCommand);
                }
                sourceDataSet.Tables[0].TableName = sourceRegionMetadata.TableName;

                return(sourceDataSet.Tables[0]);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }