Esempio n. 1
0
        public Task DeployRepository(IDeployable deployable)
        {
            string ApplicationsFolder   = deployable.ApplicationDeploymentLocations();
            string RepositoryFolder     = deployable.RepositoryDeploymentLocations();
            string ApplicationsLocation = deployable.ApplicationsCurrentLocations();
            string RepositoryLocations  = deployable.RepositoryCurrentLocations();
            bool   IsUpdate             = deployable.IsUpdate();

            if (IsUpdate == false)
            {
                if (!Directory.Exists(RepositoryFolder))
                {
                    Directory.CreateDirectory(RepositoryFolder);
                }
                if (!Directory.Exists(ApplicationsFolder))
                {
                    Directory.CreateDirectory(ApplicationsFolder);
                }
                FileSystem.CopyDirectory(ApplicationsLocation, ApplicationsFolder, true);
                FileSystem.CopyDirectory(RepositoryLocations, RepositoryFolder, true);
                return(Task.CompletedTask);
            }
            else
            {
                FileSystem.CopyDirectory(ApplicationsLocation, ApplicationsFolder, true);
                return(Task.CompletedTask);
            }
        }
Esempio n. 2
0
        public async Task <Deployment> BeginDeploymentAsync(IDeployable deployment)
        {
            using (var client = await _managementClientProvider.CreateResourceManagementClient(deployment.SubscriptionId))
            {
                await client.ResourceGroups.CreateOrUpdateAsync(
                    deployment.ResourceGroupName,
                    new ResourceGroup {
                    Location = deployment.Location
                });

                var templateParams = deployment.DeploymentParameters;

                var properties = new Microsoft.Azure.Management.ResourceManager.Models.Deployment
                {
                    Properties = new DeploymentProperties
                    {
                        Template   = await _templateProvider.GetTemplate(deployment.TemplateName),
                        Parameters = _templateProvider.GetParameters(templateParams),
                        Mode       = DeploymentMode.Incremental
                    }
                };

                // Start the ARM deployment
                var deploymentResult = await client.Deployments.BeginCreateOrUpdateAsync(
                    deployment.ResourceGroupName,
                    deployment.DeploymentName,
                    properties);

                return(ToDeploymentStatus(deploymentResult));
            }
        }
Esempio n. 3
0
 public async Task <Deployment> GetDeploymentAsync(IDeployable deployment)
 {
     using (var client = await _managementClientProvider.CreateResourceManagementClient(deployment.SubscriptionId))
     {
         return(await GetDeploymentInnerAsync(deployment));
     }
 }
Esempio n. 4
0
        public static List <Transportation> Create(string name, IDeployable deployable,
                                                   Region from, Region to, CostOfStage cost)
        {
            var            list  = new List <Transportation>();
            var            route = Misc.ShortestPath(from, to);
            var            iter  = route.First;
            Transportation prev  = null;

            while (iter.Next != null)
            {
                Transportation transportation;

                transportation = new Transportation($"Transferring {deployable} to a new destination: {to}", deployable, iter.Next.Value,
                                                    ResourceManager.GetCostOf(nameof(Installation), TypesOfCostOfStage.Transportation));

                if (prev != null)
                {
                    prev._AfterCompleted = p => transportation.IsPending = false;
                }

                list.Add(transportation);

                prev = transportation;
                iter = iter.Next;
            }

            return(list);
        }
Esempio n. 5
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. 6
0
 public Deployment(string name, Region destination, IDeployable deployable, CostOfStage cost) :
     base(name, cost)
 {
     DeployableObject = deployable;
     Destination      = destination;
     Cost             = cost;
 }
Esempio n. 7
0
 public Transportation(string name, IDeployable deployable, Region nextStop,
                       CostOfStage cost, Action <Transportation> afterCompleted = null) : base(name, cost)
 {
     Name            = name;
     Cargo           = deployable;
     Cost            = cost;
     NextStop        = nextStop;
     IsPending       = true;
     _AfterCompleted = afterCompleted;
 }
Esempio n. 8
0
        public DeployCommand( )
        {
            IsCommand("deploy", "Deploy applications from directory");

            HasRequiredOption("remote=", "The remote upload location URI (only ftp:// and sftp:// are supported as of now)", remote =>
            {
                try {
                    DeployFullURI = new Uri(remote);
                    if (!DeployFullURI.AbsoluteUri.EndsWith("/"))
                    {
                        DeployFullURI = new Uri(string.Format("{0}/", DeployFullURI.AbsoluteUri));
                    }
                } catch (UriFormatException e) {
                    Console.WriteLine("Error parsing the remote url - {0}", e.Message);
                    Environment.Exit(1);
                }

                switch (DeployFullURI.Scheme.ToLower())
                {
                case "ftp":
                    Deployment = new DeployFTP();
                    break;

                case "sftp":
                    Deployment = new DeploySFTP();
                    break;

                default:
                    Deployment = null;
                    break;
                }
            });

            HasRequiredOption("dir|directory=", "Deploy from specified directory", dir => FileOrWorkingDirectory = dir);
            HasOption("ext|extension=", "Targeted files extension in specified directory", ext => FilesExtension = ext);

            HasOption("user|username="******"Login username", username => Deployment.LoginInfo.UserName = username);
            HasOption("pass|password="******"Login password", pass => Deployment.LoginInfo.Password     = pass);
            HasOption("privatekey=", "Private key for authentication (used only for SFTP for now)", privatekey_path =>
            {
                if (Deployment.GetType() == typeof(DeploySFTP))
                {
                    ((DeploySFTP)Deployment).PrivateKeyPath = privatekey_path;
                }
            });

            HasOption("privatekeypass="******"Private key passphrase (if there is one)", privatekey_pass =>
            {
                if (Deployment.GetType() == typeof(DeploySFTP))
                {
                    ((DeploySFTP)Deployment).PrivateKeyPassphrase = privatekey_pass;
                }
            });
        }
Esempio n. 9
0
        private void DoDeploy()
        {
            IDeployable deploy = tvProjects.SelectedNode.Tag as IDeployable;

            if (deploy == null)
            {
                return;
            }

            deploy.Deploy();
        }
Esempio n. 10
0
        public string DeployableStatus(IDeployable deployable)
        {
            switch (deployable.State)
            {
            case DeplyomentState.IDLE:
                return("Idle");

            case DeplyomentState.DEPLOYING:
                return("Deploying");

            case DeplyomentState.DEPLOYED:
                return("Deployed");
            }
            return("");
        }
Esempio n. 11
0
        public async Task <Deployment> WaitForCompletionAsync(IDeployable deployment)
        {
            using (var client = await _managementClientProvider.CreateResourceManagementClient(deployment.SubscriptionId))
            {
                var deploymentResult = await GetDeploymentInnerAsync(deployment);

                while (deploymentResult.ProvisioningState == ProvisioningState.Running ||
                       deploymentResult.ProvisioningState == ProvisioningState.Accepted)
                {
                    await Task.Delay(2000);

                    deploymentResult = await GetDeploymentInnerAsync(deployment);
                }
                return(deploymentResult);
            }
        }
Esempio n. 12
0
        public static string DeployableStatus(IDeployable deployable)
        {
            switch (deployable.State)
            {
            case DeploymentState.IDLE:
                return("Idle");

            case DeploymentState.DEPLOYING:
                return($"Deploying\n{deployable.DeploymentInfo}");

            case DeploymentState.DEPLOYED:
                return("Deployed");

            default:
                return("");
            }
        }
Esempio n. 13
0
        public void WriteResourceLocations(IDeployable deployable)
        {
            string Database       = $@"Database;{deployable.RepositoryDeploymentLocations()}";
            string FileRepository = $@"FileRepository;{deployable.FileRepositoryDeploymentLocations()}";
            string Application    = $@"Application;{deployable.DocumentRepositoryDeploymentLocation()}";
            string Administration = $@"Administration;{deployable.AdministrationDeploymentLocations()}";

            foreach (var folder in deployable.ResourceFolders())
            {
                using (StreamWriter writer = new StreamWriter(Path.GetFullPath($@"{folder}\ResourceLocations.txt"), false))
                {
                    writer.WriteLine(Database);
                    writer.WriteLine(FileRepository);
                    writer.WriteLine(Application);
                    writer.WriteLine(Administration);
                }
            }
        }
Esempio n. 14
0
        private async Task <Deployment> GetDeploymentInnerAsync(IDeployable deployment)
        {
            using (var client = await _managementClientProvider.CreateResourceManagementClient(deployment.SubscriptionId))
            {
                var deploymentResult = await client.Deployments.GetAsync(
                    deployment.ResourceGroupName,
                    deployment.DeploymentName);

                IEnumerable <DeploymentOperation> failedOps = null;
                if (deploymentResult.Properties.ProvisioningState == "Failed")
                {
                    var operation = await client.DeploymentOperations.ListAsync(
                        deployment.ResourceGroupName, deployment.DeploymentName);

                    failedOps = operation.Where(op => op.Properties.ProvisioningState == "Failed");
                }

                return(ToDeploymentStatus(deploymentResult, failedOps));
            }
        }
Esempio n. 15
0
        private void Configure(AttributeSet attributes, IDeployable deployable)
        {
            if (deployable == null)
            {
                return;
            }

            if (attributes.DeployedAs != null)
            {
                deployable.AssetDeployment = attributes.DeployedAs.Deployment;

                var moduleName = attributes.DeployedAs.ModuleName;
                if (!string.IsNullOrEmpty(moduleName))
                {
                    _nameManager.AddResolutionHandler(
                        NameResolutionPhase.ResolveElementReferences,
                        (nm, d, n) => d.Module = nm.ResolveModule(n),
                        deployable,
                        moduleName);
                }
            }
        }
Esempio n. 16
0
        public bool TryDeploy(int index = 0)
        {
            if (_inventory.Count <= index)
            {
                Debug.Log($"ENTITY: ERROR, OUT OF RANGE INVENTORY INDEX: {index} {_inventory.Count}");
                return(false);
            }
            IDeployable item = _inventory[index] as IDeployable;

            if (item == null)
            {
                Debug.Log("ENTITY: ERROR, NON-ITEM IN INVENTORY");
                return(false);
            }

            if (item.Deploy(CurrentPosition, (byte)_context.factionID))
            {
                _inventory.RemoveAt(index);
                return(true);
            }

            return(false);
        }
Esempio n. 17
0
        private string PinvokeInternalDefineFor(IDeployable staticLib)
        {
            var validLib = new NPath(staticLib.ToString()).FileNameWithoutExtension.Replace('-', '_').Replace('.', '_');

            return($"FORCE_PINVOKE_{validLib}_INTERNAL=1");
        }
Esempio n. 18
0
    private static StartInfo StartInfoFor(DotsRuntimeCSharpProgramConfiguration config, IDeployable deployedGame)
    {
        var exe = deployedGame.Path;

        if (deployedGame is DotNetAssembly dotNetGame)
        {
            exe = dotNetGame.Path.ChangeExtension("exe");
        }

        if (config.Platform is WebGLPlatform)
        {
            return(new BrowserStartInfo(new Uri(deployedGame.Path.MakeAbsolute().ToString(SlashMode.Native)).AbsoluteUri));
        }

        return(new ExecutableStartInfo(new Shell.ExecuteArgs()
        {
            Executable = exe, WorkingDirectory = exe.Parent
        }, true));
    }
Esempio n. 19
0
        protected override void unbuilt_kits_pane()
        {
            if (unbuilt_kits.Count == 0)
            {
                return;
            }
            GUILayout.Label("Available DIY kits:", Styles.label, GUILayout.ExpandWidth(true));
            GUILayout.BeginVertical(Styles.white);
            BeginScroll(unbuilt_kits.Count, ref unbuilt_scroll);
            ConstructionKitInfo add    = null;
            IDeployable         deploy = null;

            foreach (var info in unbuilt_kits)
            {
                GUILayout.BeginHorizontal();
                draw_task(info);
                if (info.ConstructionSpace is IDeployable depl)
                {
                    if (depl.State == DeploymentState.DEPLOYED)
                    {
                        if (GUILayout.Button(
                                new GUIContent("Add", "Add this kit to construction queue"),
                                Styles.enabled_button,
                                GUILayout.ExpandWidth(false),
                                GUILayout.ExpandHeight(true)))
                        {
                            add = info;
                        }
                    }
                    else if (depl.State != DeploymentState.DEPLOYING)
                    {
                        if (GUILayout.Button(
                                new GUIContent("Deploy", "Deploy this kit and fix it to the ground"),
                                Styles.active_button,
                                GUILayout.ExpandWidth(false),
                                GUILayout.ExpandHeight(true)))
                        {
                            deploy = depl;
                        }
                    }
                    else
                    {
                        GUILayout.Label(DeployableStatus(depl),
                                        Styles.boxed_label,
                                        GUILayout.ExpandWidth(true),
                                        GUILayout.ExpandHeight(true));
                    }
                }
                else if (GUILayout.Button(
                             new GUIContent("Add", "Add this kit to construction queue"),
                             Styles.enabled_button,
                             GUILayout.ExpandWidth(false),
                             GUILayout.ExpandHeight(true)))
                {
                    add = info;
                }
                GUILayout.EndHorizontal();
            }
            if (add != null)
            {
                Queue.Enqueue(add);
            }
            else if (deploy != null)
            {
                deploy.Deploy();
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }
Esempio n. 20
0
        private void tvProjects_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                tvProjects.SelectedNode = e.Node;

                menuProject.Items.Clear();

                //判斷是否可以開啟
                IEditorManager editorManager = e.Node.Tag as IEditorManager;
                if (editorManager != null)
                {
                    if (editorManager.Editors.Count == 1)
                    {
                        IEditable     editable = editorManager.Editors[0];
                        ToolStripItem item     = menuProject.Items.Add(editable.DocumentTitle, actImgs.Images[editable.ImageKey], cmEdit_Click);
                        item.Tag = editable;
                    }
                    else if (editorManager.Editors.Count > 0)
                    {
                        ToolStripMenuItem menuItem = new ToolStripMenuItem("開啟");
                        menuProject.Items.Add(menuItem);

                        foreach (IEditable editable in editorManager.Editors)
                        {
                            ToolStripItem item = menuItem.DropDownItems.Add(editable.DocumentTitle, actImgs.Images[editable.ImageKey], cmEdit_Click);
                            item.Tag = editable;
                        }
                    }
                }

                //判斷是否可以改名
                ToolStripMenuItem cmRename = new ToolStripMenuItem("重新命名(&N)");
                this.CheckMenuItemVisiable(typeof(IRenameable), cmRename);
                cmRename.Click += new EventHandler(cmRename_Click);
                cmRename.Image  = actImgs.Images["rename"];

                //判斷是否可以新增
                IAddable addable = e.Node.Tag as IAddable;
                if (addable != null)
                {
                    menuProject.Items.Add(addable.TitleOfAdd, actImgs.Images["add"], cmAdd_Click);
                }

                //判斷是否可以重新整理
                ToolStripMenuItem cmReload = new ToolStripMenuItem("重新整理(&R)");
                this.CheckMenuItemVisiable(typeof(IReloadable), cmReload);
                cmReload.Click += new EventHandler(cmReload_Click);
                cmReload.Image  = actImgs.Images["reload"];

                //判斷是否可以刪除
                IDeleteable deleteable = e.Node.Tag as IDeleteable;
                if (deleteable != null)
                {
                    menuProject.Items.Add(deleteable.TitleOfDelete, actImgs.Images["delete"], cmDelete_Click);
                }

                //判斷是否可以測試
                ITestable testable = e.Node.Tag as ITestable;
                if (testable != null)
                {
                    menuProject.Items.Add(testable.TitleOfTest, actImgs.Images[testable.TestImageKey], cmTest_Click);
                }

                //判斷是否可以匯出
                ToolStripMenuItem cmExport = new ToolStripMenuItem("匯出(&E)");
                this.CheckMenuItemVisiable(typeof(IExportable), cmExport);
                cmExport.Click += new EventHandler(cmExport_Click);
                cmExport.Image  = actImgs.Images["export"];

                //判斷是否可以匯入
                ToolStripMenuItem cmImport = new ToolStripMenuItem("匯入(&I)");
                this.CheckMenuItemVisiable(typeof(IImportable), cmImport);
                cmImport.Click += new EventHandler(cmImport_Click);
                cmImport.Image  = actImgs.Images["import"];

                //判斷是否可以加入專案
                IJoinProject join = e.Node.Tag as IJoinProject;
                if (join != null)
                {
                    menuProject.Items.Add("加入專案(&J)", actImgs.Images["join"], cmJoinProject_Click);
                }

                //判斷是否可以匯入
                ILeaveProject leave = e.Node.Tag as ILeaveProject;
                if (leave != null)
                {
                    menuProject.Items.Add("從專案卸載(&L)", actImgs.Images["leave"], cmLeaveProject_Click);
                }

                //判斷是否可以上傳
                ISyncUpload upload = e.Node.Tag as ISyncUpload;
                if (upload != null)
                {
                    menuProject.Items.Add("同步至伺服器(&U)", actImgs.Images["upload"], cmUpload_Click);
                }

                //判斷是否可以下載
                ISyncDownload download = e.Node.Tag as ISyncDownload;
                if (download != null)
                {
                    menuProject.Items.Add("自伺服器同步(&D)", actImgs.Images["download"], cmDownload_Click);
                }

                //判斷是否可以設定
                ISetupable setup = e.Node.Tag as ISetupable;
                if (setup != null)
                {
                    menuProject.Items.Add(setup.SetupTitle + "(&S)", actImgs.Images["setup"], cmSetup_Click);
                }

                //判斷是否可以佈署
                IDeployable deploy = e.Node.Tag as IDeployable;
                if (deploy != null)
                {
                    menuProject.Items.Add("佈署(&L)", actImgs.Images["deploy"], cmDeploy_Click);
                }

                //判斷是否可以佈署到實體
                IDeployToPhysical deployToPhysical = e.Node.Tag as IDeployToPhysical;
                if (deployToPhysical != null)
                {
                    menuProject.Items.Add("佈署到實體(&P)", actImgs.Images["deployToPhysical"], tsbtnDeployToPhysical_Click);
                }

                //判斷是否可以從實體 Service 載入
                IImportFromPhysical importFromPhysical = e.Node.Tag as IImportFromPhysical;
                if (importFromPhysical != null)
                {
                    menuProject.Items.Add("實體 Service 載入(&X)", actImgs.Images["importFromPhysical"], tsbtnImportFromPhysical_Click);
                }

                menuProject.Show(e.Location);
            }
        }
Esempio n. 21
0
        private void tvProjects_AfterSelect(object sender, TreeViewEventArgs e)
        {
            INodeHandler handler = e.Node.Tag as INodeHandler;

            if (handler != null)
            {
                if (handler.IsFirstClick)
                {
                    handler.OnFirstClick();
                }
                else
                {
                    handler.OnClick();
                }
            }
            splitContainer1.Panel2.Controls.Clear();

            IDeleteable del = handler as IDeleteable;

            tsbtnDelete.Enabled = false;
            if (del != null)
            {
                tsbtnDelete.Enabled     = true;
                tsbtnDelete.ToolTipText = del.TitleOfDelete;
                menuProject.Items.Add(del.TitleOfDelete, actImgs.Images["delete"], cmDelete_Click);
            }

            IAddable add = handler as IAddable;

            tsbtnAdd.Enabled = false;
            if (add != null)
            {
                tsbtnAdd.Enabled     = true;
                tsbtnAdd.ToolTipText = add.TitleOfAdd;
                menuProject.Items.Add(add.TitleOfAdd, actImgs.Images["add"], cmAdd_Click);
            }

            IReloadable reload = handler as IReloadable;

            tsbtnReload.Enabled = false;
            if (reload != null)
            {
                tsbtnReload.Enabled = true;
            }

            ITestable test = handler as ITestable;

            tsbtnTest.Enabled = false;
            if (test != null)
            {
                tsbtnTest.Image   = actImgs.Images[test.TestImageKey];
                tsbtnTest.Enabled = true;
            }

            IRenameable rename = handler as IRenameable;

            tsbtnRename.Enabled = false;
            if (rename != null)
            {
                tsbtnRename.Enabled = true;
            }

            IExportable export = handler as IExportable;

            tsbtnExport.Enabled = false;
            if (export != null)
            {
                tsbtnExport.Enabled = true;
            }

            ISetupable setup = handler as ISetupable;

            cmSetup.Enabled = false;
            if (setup != null)
            {
                cmSetup.Enabled = true;
            }

            IDeployable deploy = handler as IDeployable;

            cmDeploy.Enabled = false;
            if (deploy != null)
            {
                cmDeploy.Enabled = true;
            }

            IDeployToPhysical phyDeploy = handler as IDeployToPhysical;

            tsbtnDeployToPhysical.Enabled = false;
            if (phyDeploy != null)
            {
                tsbtnDeployToPhysical.Enabled = true;
            }

            IImportFromPhysical phyImport = handler as IImportFromPhysical;

            tsbtnImportFromPhysical.Enabled = false;
            if (phyImport != null)
            {
                tsbtnImportFromPhysical.Enabled = true;
            }

            IImportable import = handler as IImportable;

            tsbtnImport.Enabled = false;
            if (import != null)
            {
                tsbtnImport.Enabled = true;
            }

            IJoinProject joinProject = handler as IJoinProject;

            tsbtnJoinProject.Enabled = false;
            if (joinProject != null)
            {
                tsbtnJoinProject.Enabled = true;
            }

            ILeaveProject leaveProject = handler as ILeaveProject;

            tsbtnLeaveProject.Enabled = false;
            if (leaveProject != null)
            {
                tsbtnLeaveProject.Enabled = true;
            }

            ISyncUpload syncUplaod = handler as ISyncUpload;

            cmUpload.Enabled = false;
            if (syncUplaod != null)
            {
                cmUpload.Enabled = true;
            }

            ISyncUpload syncDownload = handler as ISyncUpload;

            cmDownload.Enabled = false;
            if (syncDownload != null)
            {
                cmDownload.Enabled = true;
            }

            tsEditMode.Items.Clear();
            rsbtnSave.Enabled = false;
            IEditorManager manager = handler as IEditorManager;

            if (manager != null)
            {
                rsbtnSave.Enabled = false;
                foreach (IEditable editable in manager.Editors)
                {
                    ToolStripItem item = tsEditMode.Items.Add(editable.ModeTitle, actImgs.Images[editable.ImageKey], cmEdit_Click);
                    item.ToolTipText = editable.ModeTitle;
                    item.Text        = string.Empty;
                    item.Tag         = editable;
                }
            }
        }