Example #1
0
 internal static ServerGateway FromResourceGateway(GatewayDetails resourceGateway)
 {
     return(new ServerGateway()
     {
         GatewayResourceId = resourceGateway.GatewayResourceId,
         GatewayObjectId = resourceGateway.GatewayObjectId != null ? resourceGateway.GatewayObjectId : null,
         DmtsClusterUri = resourceGateway.DmtsClusterUri != null ? resourceGateway.DmtsClusterUri : null
     });
 }
Example #2
0
 public static void CreateSaveGatewayDetails(CMSDataContext db, GatewayAccount gatewayAccount, IQueryable <GatewayConfigurationTemplate> template)
 {
     foreach (var item in template)
     {
         var detail = new GatewayDetails
         {
             GatewayAccountId   = gatewayAccount.GatewayAccountId,
             GatewayDetailName  = item.GatewayDetailName,
             GatewayDetailValue = item.IsBoolean ? "true" : DatabaseTestBase.RandomString(),
             IsBoolean          = item.IsBoolean
         };
         db.GatewayDetails.InsertOnSubmit(detail);
         db.SubmitChanges();
     }
 }
Example #3
0
        public AnalysisServicesServer CreateOrUpdateServer(
            string resourceGroupName,
            string serverName,
            string location,
            string skuName        = null,
            Hashtable customTags  = null,
            string administrators = null,
            AnalysisServicesServer existingServer = null,
            string backupBlobContainerUri         = null,
            int ReadonlyReplicaCount     = 0,
            string DefaultConnectionMode = null,
            IPv4FirewallSettings setting = null,
            string gatewayResourceId     = null)
        {
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                resourceGroupName = GetResourceGroupByServer(serverName);
            }

            var tags = (customTags != null)
                ? TagsConversionHelper.CreateTagDictionary(customTags, true)
                : null;

            var adminList = new List <string>();

            if (!string.IsNullOrEmpty(administrators))
            {
                adminList.AddRange(administrators.Split(','));
                if (adminList.Count == 0)
                {
                    adminList.Add(_currentUser);
                }
            }

            GatewayDetails gatewayDetails = null;

            if (gatewayResourceId == DissasociateGateway)
            {
                gatewayDetails = new GatewayDetails();
            }
            else if (gatewayResourceId != null)
            {
                gatewayDetails = new GatewayDetails(gatewayResourceId);
            }

            AnalysisServicesServer newOrUpdatedServer = null;

            if (existingServer != null)
            {
                var updateParameters = new AnalysisServicesServerUpdateParameters()
                {
                    Sku  = skuName == null ? existingServer.Sku : GetResourceSkuFromName(skuName),
                    Tags = tags,
                };

                if (adminList.Count > 0)
                {
                    updateParameters.AsAdministrators = new ServerAdministrators(adminList);
                }

                if (backupBlobContainerUri != null)
                {
                    updateParameters.BackupBlobContainerUri = backupBlobContainerUri;
                }

                if (ReadonlyReplicaCount != -1)
                {
                    updateParameters.Sku.Capacity = ReadonlyReplicaCount + 1;
                }

                if (DefaultConnectionMode != null)
                {
                    updateParameters.QuerypoolConnectionMode = (ConnectionMode)Enum.Parse(typeof(ConnectionMode), DefaultConnectionMode, true);
                }

                if (setting != null)
                {
                    updateParameters.IpV4FirewallSettings = setting;
                }

                if (gatewayDetails != null)
                {
                    updateParameters.GatewayDetails = gatewayDetails;
                }

                newOrUpdatedServer = _client.Servers.Update(resourceGroupName, serverName, updateParameters);
            }
            else
            {
                ConnectionMode?connectionMode = null;
                if (DefaultConnectionMode != null)
                {
                    connectionMode = (ConnectionMode)Enum.Parse(typeof(ConnectionMode), DefaultConnectionMode, true);
                }

                if (adminList.Count == 0)
                {
                    adminList.Add(_currentUser);
                }

                newOrUpdatedServer = _client.Servers.Create(
                    resourceGroupName,
                    serverName,
                    new AnalysisServicesServer()
                {
                    AsAdministrators       = new ServerAdministrators(adminList),
                    BackupBlobContainerUri = backupBlobContainerUri,
                    Location = location,
                    Sku      = GetResourceSkuFromName(skuName, ReadonlyReplicaCount + 1),
                    Tags     = tags,
                    QuerypoolConnectionMode = connectionMode,
                    IpV4FirewallSettings    = setting,
                    GatewayDetails          = gatewayDetails
                });
            }

            return(newOrUpdatedServer);
        }
Example #4
0
        public JsonResult InsertAccount([System.Web.Http.FromBody] Models.GatewayAccountJsonModel json, bool IsInsert)
        {
            var paymentProcesses = CurrentDatabase.PaymentProcess.ToList();
            var paymentProcess   = paymentProcesses.Single(x => x.ProcessId == json.ProcessId);

            if (IsInsert)
            {
                var gtAccount       = new GatewayAccount();
                var gtDetailAccount = new GatewayDetails();

                gtAccount.GatewayAccountName = json.GatewayAccountName;
                gtAccount.GatewayId          = json.GatewayId;
                CurrentDatabase.GatewayAccount.InsertOnSubmit(gtAccount);
                CurrentDatabase.SubmitChanges();

                for (int i = 0; i < json.GatewayAccountInputs.Count(); i++)
                {
                    gtDetailAccount.GatewayAccountId   = gtAccount.GatewayAccountId;
                    gtDetailAccount.GatewayDetailName  = json.GatewayAccountInputs[i];
                    gtDetailAccount.GatewayDetailValue = json.GatewayAccountValues[i];
                    gtDetailAccount.IsBoolean          = json.GatewayAccountValues[i] == "true" || json.GatewayAccountValues[i] == "false" ? true : false;
                    CurrentDatabase.GatewayDetails.InsertOnSubmit(gtDetailAccount);
                    gtDetailAccount = new GatewayDetails();
                }

                if (json.UseForAll)
                {
                    foreach (var process in paymentProcesses.Where(p => p.ProcessId != (int)PaymentProcessTypes.TemporaryRecurringGiving))
                    {
                        process.GatewayAccountId = gtAccount.GatewayAccountId;
                    }
                }
                else
                {
                    paymentProcess.GatewayAccountId = gtAccount.GatewayAccountId;
                }
            }
            else
            {
                for (int i = 0; i < json.GatewayAccountInputs.Count(); i++)
                {
                    var gtDetailAccount = CurrentDatabase.GatewayDetails.Single(
                        x => x.GatewayDetailName == json.GatewayAccountInputs[i] &&
                        x.GatewayAccountId == json.GatewayAccountId);

                    gtDetailAccount.GatewayDetailValue = json.GatewayAccountValues[i];
                }

                if (json.UseForAll)
                {
                    foreach (var process in paymentProcesses.Where(p => p.ProcessId != (int)PaymentProcessTypes.TemporaryRecurringGiving))
                    {
                        process.GatewayAccountId = json.GatewayAccountId;
                    }
                }
                else
                {
                    paymentProcess.GatewayAccountId = json.GatewayAccountId;
                }
            }
            CurrentDatabase.SubmitChanges();

            return(GetGatewayAccounts());
        }