Exemplo n.º 1
0
        private HomeModel GetHomeModel(FormCollection formCollection = null)
        {
            var model = new Models.HomeModel();

            model.StretchTableName = Constants.StretchTableName;
            string remoteDatabaseName = StretchDbService.GetDatabaseName(Constants.StretchDBAzureConnectionString);
            string remoteTableName    = StretchDbService.GetRemoteTableName(Constants.StretchTableName, Constants.StretchDbOnPremiseConnectionString, remoteDatabaseName);

            model.StretchEnabled   = !string.IsNullOrWhiteSpace(remoteTableName);
            model.IsDatabaseOnline = SqlAlwaysOnService.IsServerConnected(Constants.SQLAlwaysOnConnectionString);

            if (SqlAlwaysOnService.IsPrimaryDatabase(Constants.SqlAlwaysOnPrimaryConnectionString))
            {
                model.AlwaysOnPrimaryDatabaseServer   = SqlAlwaysOnService.GetServerName(Constants.SqlAlwaysOnPrimaryConnectionString);
                model.AlwaysOnSecondaryDatabaseServer = SqlAlwaysOnService.GetServerName(Constants.SqlAlwaysOnSecondaryConnectionString);;
            }
            else
            {
                model.AlwaysOnPrimaryDatabaseServer   = SqlAlwaysOnService.GetServerName(Constants.SqlAlwaysOnSecondaryConnectionString);
                model.AlwaysOnSecondaryDatabaseServer = SqlAlwaysOnService.GetServerName(Constants.SqlAlwaysOnPrimaryConnectionString);;
            }

            model.TotalSpaceUsed  = StretchDbService.GetUsedSpace(Constants.StretchTableName, Constants.StretchDbOnPremiseConnectionString, StorageMode.ALL);
            model.RemoteSpaceUsed = StretchDbService.GetUsedSpace(Constants.StretchTableName, Constants.StretchDbOnPremiseConnectionString, StorageMode.REMOTE_ONLY);
            model.LocalSpaceUsed  = StretchDbService.GetUsedSpace(Constants.StretchTableName, Constants.StretchDbOnPremiseConnectionString, StorageMode.LOCAL_ONLY);

            return(model);
        }
Exemplo n.º 2
0
        public JsonResult GetAccounts(string store, string sidx, string sord, int page, int rows)
        {
            int totalRecords;

            bool   isServerOnline            = SqlAlwaysOnService.IsServerConnected(Constants.SQLAlwaysOnConnectionString);
            string primaryConnectionString   = string.Empty;
            string secondaryConnectionString = string.Empty;

            if (isServerOnline)
            {
                if (SqlAlwaysOnService.IsPrimaryDatabase(Constants.SqlAlwaysOnPrimaryConnectionString))
                {
                    primaryConnectionString   = Constants.SqlAlwaysOnPrimaryConnectionString;
                    secondaryConnectionString = Constants.SqlAlwaysOnSecondaryConnectionString;
                }
                else
                {
                    primaryConnectionString   = Constants.SqlAlwaysOnSecondaryConnectionString;
                    secondaryConnectionString = Constants.SqlAlwaysOnPrimaryConnectionString;
                }
            }

            string connectionString = !string.IsNullOrEmpty(store) && store == "Secondary" ? secondaryConnectionString : primaryConnectionString;

            var accounts = SqlAlwaysOnService.GetAccounts(connectionString, sidx, sord, page, rows, out totalRecords);

            var totalPages = (int)Math.Ceiling((float)totalRecords / (float)rows);

            var jsonData = new
            {
                total = totalPages,
                page,
                records = totalRecords,
                rows    = accounts
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public string EditAccount(string store, int id, DimAccount model)
        {
            bool   isServerOnline            = SqlAlwaysOnService.IsServerConnected(Constants.SQLAlwaysOnConnectionString);
            string primaryConnectionString   = string.Empty;
            string secondaryConnectionString = string.Empty;

            if (isServerOnline)
            {
                if (SqlAlwaysOnService.IsPrimaryDatabase(Constants.SqlAlwaysOnPrimaryConnectionString))
                {
                    primaryConnectionString   = Constants.SqlAlwaysOnPrimaryConnectionString;
                    secondaryConnectionString = Constants.SqlAlwaysOnSecondaryConnectionString;
                }
                else
                {
                    primaryConnectionString   = Constants.SqlAlwaysOnSecondaryConnectionString;
                    secondaryConnectionString = Constants.SqlAlwaysOnPrimaryConnectionString;
                }
            }

            string connectionString = !string.IsNullOrEmpty(store) && store == "Secondary" ? secondaryConnectionString : primaryConnectionString;

            return(SqlAlwaysOnService.UpdateAccount(connectionString, id, model));
        }