Esempio n. 1
0
        public async Task <IActionResult> CreateNew(DeployChoiceViewModel choices)
        {
            if (ModelState.IsValid)
            {
                //Logic to generate valid viewmodel with AzureDeployName parameter.


                var service       = new DeployTypesService(_context);
                var DeployChoices = _service.CreateDeployTypes(choices);

                Guid guid      = Guid.NewGuid();
                var  newdeploy = new DeployType();
                newdeploy.DeployName        = DeployChoices.DeployName;
                newdeploy.Description       = DeployChoices.Description;
                newdeploy.DeploySaved       = "No";
                newdeploy.TennantID         = DeployChoices.TennantID;
                newdeploy.DeployFile        = DeployChoices.DeployFile;
                newdeploy.ParamsFile        = DeployChoices.ParamsFile;
                newdeploy.DeployCode        = DeployChoices.DeployCode;
                newdeploy.ResourceGroupName = DeployChoices.ResourceGroupName;
                newdeploy.AzureDeployName   = DeployChoices.DeployCode + guid;
                _context.Add(newdeploy);
                await _context.SaveChangesAsync();


                return(RedirectToAction("Index", new { id = DeployChoices.TennantID }));
            }
            return(View(choices));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("DeployTypeID,TennantID,DeployName")] DeployType deployType)
        {
            if (id != deployType.DeployTypeID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(deployType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DeployTypeExists(deployType.DeployTypeID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", new { id = deployType.TennantID }));
            }
            ViewData["TennantID"] = new SelectList(_context.Tennants, "TennantID", "TennantID", deployType.TennantID);
            return(View(deployType));
        }
Esempio n. 3
0
    public void HandlePowerUpType(DeployType deployType)
    {
        //To prevent Unity from creating multiple copies of the same component in inspector at runtime
        Component c = gameObject.GetComponent <IDeployable>() as Component;

        if (c != null)
        {
            Destroy(c);
        }

        switch (deployType)
        {
        case DeployType.StellarBomb:
            iDeployable = gameObject.AddComponent <StellarBomb>();
            break;

        case DeployType.DefenceNet:
            iDeployable = gameObject.AddComponent <DefenceNet>();
            break;

        case DeployType.Terraform:
            iDeployable = gameObject.AddComponent <Terraform>();
            break;

        case DeployType.Wormhole:
            iDeployable = gameObject.AddComponent <Wormhole>();
            break;

        case DeployType.PlaceFleet:
            iDeployable = gameObject.AddComponent <PlaceFleet>();
            break;
        }
    }
Esempio n. 4
0
    // TODO Get this working
    public System.Object GetDeployType(DeployType deployType)
    {
        var ns       = typeof(DeployType).Namespace;
        var typeName = ns + "." + deployType.ToString();

        return(System.Activator.CreateInstance(System.Type.GetType(typeName)));
    }
Esempio n. 5
0
        private void deployTypeChecker(DeployType type)
        {
            switch (type)
            {
            case DeployType.Development:
                System.Console.WriteLine("DEVELOPMENT TYPE DEPLOYMENT");
                break;


            case DeployType.Production:
                System.Console.WriteLine("PRODUCTION TYPE DEPLOYMENT");
                break;

            default:
                break;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Returns the type of deployment needed to delete a file deployed with the given type
        /// </summary>
        public static DeployType GetDeletetionType(DeployType type)
        {
            switch (type)
            {
            case DeployType.Prolib:
                return(DeployType.DeleteInProlib);

            case DeployType.CopyFolder:
                return(DeployType.DeleteFolder);

            case DeployType.Copy:
            case DeployType.Move:
                return(DeployType.Delete);

            default:
                return(DeployType.None);
            }
        }
Esempio n. 7
0
 public void SaveWorkflow()
 {
     if (Query <string>("fn") == "save")
     {
         string jsonStr = Query <string>("json");
         int    op;
         if (int.TryParse(Query <string>("saveOp"), out op) && !string.IsNullOrEmpty(jsonStr))
         {
             DeployType dte = (DeployType)op;
             string     returnMsg;
             bool       result = WF.Deploy.Save(jsonStr, dte, out returnMsg);
             jsonResult = JsonHelper.OutResult(result, result ? "保存成功!" : "保存失败:" + returnMsg);
         }
         else
         {
             jsonResult = JsonHelper.OutResult(false, "参数错误!");
         }
     }
 }
Esempio n. 8
0
        //上传导入
        public void ImportWorkflowXmlFile()
        {
            HttpRequest request = HttpContext.Current.Request;

            if (request.Files.Count > 0)
            {
                try
                {
                    HttpPostedFile postFile      = request.Files[0];
                    String         fileExtension = System.IO.Path.GetExtension(postFile.FileName).ToLower();
                    if (fileExtension.ToLower() != ".xml")
                    {
                        jsonResult = JsonHelper.OutResult(false, "上传的XML文件格式不正确,请重新上传");
                        return;
                    }
                    Stream stream = postFile.InputStream;
                    if (stream != null && stream.Length > 0)
                    {
                        Byte[] bytes = new Byte[stream.Length];
                        stream.Read(bytes, 0, bytes.Length);
                        string     xmlContent = System.Text.Encoding.UTF8.GetString(bytes);
                        DeployType deployType = (DeployType)Query <int>("DeployType");
                        string     msg;
                        bool       success = WF.Deploy.Save(xmlContent, deployType, out msg);
                        jsonResult = JsonHelper.OutResult(success, success ? "导入成功" : msg);
                    }
                }
                catch (Exception ex)
                {
                    jsonResult = JsonHelper.OutResult(false, "导入失败");
                    Log.WriteLogToTxt(ex);
                    return;
                }
            }
            else
            {
                jsonResult = JsonHelper.OutResult(false, "请上传工作流定义Xml文件");
            }
        }
Esempio n. 9
0
        public void Execute(DeployType type, string chainId, DeployArg arg = null)
        {
            switch (type)
            {
            case DeployType.Deploy:
                foreach (var cmd in _deployCommands)
                {
                    cmd.Action(arg);
                }
                break;

            case DeployType.Remove:
                foreach (var cmd in _removeCommands)
                {
                    cmd.Action(arg);
                }
                break;

            default:
                throw new ArgumentException("deploy type is incorrect");
            }
        }
Esempio n. 10
0
        public static FileToDeploy New(DeployType deployType, string sourcePath, string targetBasePath, DeployTransferRule rule)
        {
            switch (deployType)
            {
            case DeployType.Prolib:
                return(new FileToDeployProlib(sourcePath, targetBasePath, rule));

            case DeployType.Zip:
                return(new FileToDeployZip(sourcePath, targetBasePath, rule));

            case DeployType.DeleteInProlib:
                return(new FileToDeployDeleteInProlib(sourcePath, targetBasePath, rule));

            case DeployType.Ftp:
                return(new FileToDeployFtp(sourcePath, targetBasePath, rule));

            case DeployType.Delete:
                return(new FileToDeployDelete(sourcePath, targetBasePath, rule));

            case DeployType.Copy:
                return(new FileToDeployCopy(sourcePath, targetBasePath, rule));

            case DeployType.Move:
                return(new FileToDeployMove(sourcePath, targetBasePath, rule));

            case DeployType.Cab:
                return(new FileToDeployCab(sourcePath, targetBasePath, rule));

            case DeployType.CopyFolder:
                return(new FileToDeployCopyFolder(sourcePath, targetBasePath, rule));

            case DeployType.DeleteFolder:
                return(new FileToDeployDeleteFolder(sourcePath, targetBasePath, rule));

            default:
                throw new ArgumentOutOfRangeException("deployType", deployType, null);
            }
        }
Esempio n. 11
0
        public static DeployTransferRule New(DeployType type)
        {
            switch (type)
            {
            case DeployType.Prolib:
                return(new DeployTransferRuleProlib());

            case DeployType.Cab:
                return(new DeployTransferRuleCab());

            case DeployType.Zip:
                return(new DeployTransferRuleZip());

            case DeployType.DeleteInProlib:
                return(new DeployTransferRuleDeleteInProlib());

            case DeployType.Ftp:
                return(new DeployTransferRuleFtp());

            case DeployType.Delete:
                return(new DeployTransferRuleDelete());

            case DeployType.Copy:
                return(new DeployTransferRuleCopy());

            case DeployType.Move:
                return(new DeployTransferRuleMove());

            case DeployType.CopyFolder:
                return(new DeployTransferRuleCopyFolder());

            case DeployType.DeleteFolder:
                return(new DeployTransferRuleDeleteFolder());

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
Esempio n. 12
0
        private async Task <string> CreateReservationAsync(
            DateTime start,
            DeployType deploy,
            ServerType server,
            DateTime?end = null
            )
        {
            var request = new CreateReservationRequest()
            {
                DeployType = deploy.NumericValue(),
                ServerType = server.NumericValue(),
                BranchName = Generator.RandomString(10),
                UserId     = Generator.RandomString(32),
                Start      = start.ToApiDate(),
                End        = (end ?? start.AddDays(1)).ToApiDate(),
            };
            var httpResponse = await Client.PostAsync("/api/reservation", request.ToRequestBody());

            httpResponse.EnsureSuccessStatusCode();

            var responseBody = await httpResponse.Content.ReadAsStringAsync();

            return(JsonConvert.DeserializeObject <CreateReservationResponse>(responseBody).Id);
        }
Esempio n. 13
0
 public FileToDeploy(string targetDir, DeployType deployType, bool finalDeploy)
 {
     TargetDir   = targetDir;
     DeployType  = deployType;
     FinalDeploy = finalDeploy;
 }
Esempio n. 14
0
 public TransferNeeded(string targetDir, DeployType deployType, bool finalDeploy)
 {
     TargetDir   = targetDir;
     DeployType  = deployType;
     FinalDeploy = finalDeploy;
 }
Esempio n. 15
0
 public TransferNeeded(string targetDir, DeployType deployType, bool finalDeploy)
 {
     TargetDir = targetDir;
     DeployType = deployType;
     FinalDeploy = finalDeploy;
 }
Esempio n. 16
0
 public FileToDeploy(string targetDir, DeployType deployType, bool finalDeploy)
 {
     TargetDir = targetDir;
     DeployType = deployType;
     FinalDeploy = finalDeploy;
 }
Esempio n. 17
0
        private async Task <CreateBatchReservationResponse> CreateBatchReservationAsync(DateTime start, DateTime end, DeployType deployType, ServerType[] serverTypes)
        {
            var request = new CreateBatchReservationRequest()
            {
                DeployType  = deployType.NumericValue(),
                ServerTypes = serverTypes.Select(t => t.NumericValue()).ToList(),
                BranchName  = Generator.RandomString(10),
                UserId      = Generator.RandomString(10),
                Start       = start.ToApiDate(),
                End         = end.ToApiDate(),
            };

            var httpResponse = await Client.PostAsync("/api/batch/reservation", request.ToRequestBody());

            httpResponse.EnsureSuccessStatusCode();
            var responseJson = await httpResponse.Content.ReadAsStringAsync();

            return(responseJson.DeserializeJson <CreateBatchReservationResponse>());
        }
Esempio n. 18
0
        private async Task <List <GetBatchReservationResponse> > QueryBatchReservationAsync(DateTime start, DeployType deployType)
        {
            var httpResponse = await Client.GetAsync($"/api/batch/reservation?start={start.ToApiDate()}&deploy={deployType.NumericValue()}");

            httpResponse.EnsureSuccessStatusCode();
            var stringResponse = await httpResponse.Content.ReadAsStringAsync();

            return(stringResponse.DeserializeJson <List <GetBatchReservationResponse> >());
        }