void BrowsMicroservice(MicroserviceItem service)
        {
            if (service.Status != MicroserviceItem.EnumStatus.Run)
            {
                var ans = MessageBox.Show(@"Microservice not started, Do you want to start service first ?", @"Start Service", MessageBoxButtons.YesNoCancel);
                switch (ans)
                {
                case System.Windows.Forms.DialogResult.Cancel:
                    return;

                case System.Windows.Forms.DialogResult.Yes:
                    service.Start();
                    return;

                case System.Windows.Forms.DialogResult.None:
                case System.Windows.Forms.DialogResult.OK:
                case System.Windows.Forms.DialogResult.Abort:
                case System.Windows.Forms.DialogResult.Retry:
                case System.Windows.Forms.DialogResult.Ignore:
                case System.Windows.Forms.DialogResult.No:
                    break;
                }
            }
            Helper.Launch($"http://localhost:{service.Port}");
        }
Пример #2
0
        async void UIElement_OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var service = GetServiceByTag(sender);

            highPriority = service;
            OnAutoRefreshTimerOnTick(null, null);

            var nugetUpdatesWindow = new NugetUpdatesWindow(service.NugetIsUpdating)
            {
                Owner = this,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                NugetList             = service.OldReferences,
                Title = service.Service + " Microservice Nuget Updates",
            };

            var showDialog = nugetUpdatesWindow.ShowDialog();

            switch (showDialog)
            {
            case true:
                service.UpdateSelectedPackages();
                break;

            default:
                break;
            }
        }
 public NugetReference(ProjectItemGroupPackageReference @ref, MicroserviceItem service, SolutionProject project)
 {
     Name    = @ref.Include;
     Version = @ref.Version;
     Latest  = FindLatest();
     Project = project;
     Service = service;
 }
 public NugetReference(string package, string version, MicroserviceItem service, SolutionProject project)
 {
     Name    = package;
     Version = version;
     Latest  = FindLatest();
     Project = project;
     Service = service;
 }
Пример #5
0
 async Task FetchUpdates(MicroserviceItem service)
 {
     await Task.Factory.StartNew(async() =>
     {
         LocalGitChanges(service);
         var nugetTasks = Task.Run(() => service.RefreshPackages());
         await CalculateGitUpdates(service);
         await Task.WhenAll(nugetTasks);
     });
 }
Пример #6
0
        async Task CalculateGitUpdates(MicroserviceItem service)
        {
            if (service.WebsiteFolder.IsEmpty())
            {
                return;
            }
            service.RollProgress($"Fetch '{service.Service}' local git updates ...");
            var projFOlder = service.WebsiteFolder.AsDirectory().Parent;

            if (projFOlder == null || !Directory.Exists(Path.Combine(projFOlder.FullName, ".git")))
            {
                return;
            }

            service.GitUpdates = "0";
            try
            {
                var fetchoutput = "git.exe".AsFile(searchEnvironmentPath: true)
                                  .Execute("fetch", waitForExit: true, configuration: x => x.StartInfo.WorkingDirectory = projFOlder.FullName);

                service.LogMessage($"git fetch completed ... ({service.Service})");

                var output = "git.exe".AsFile(searchEnvironmentPath: true)
                             .Execute("status", waitForExit: true, configuration: x => x.StartInfo.WorkingDirectory = projFOlder.FullName);

                var status = ReadGitInfo(output);
                if (status != null && status.GitRemoteCommits > 0)
                {
                    service.LogMessage($"There are {status.GitRemoteCommits} git commit(s) available to update .");
                }

                service.GitUpdates = status?.GitRemoteCommits.ToString();
            }
            catch (Exception e)
            {
                service.LogMessage("Error on git command ...", e.Message);
                service.StopProgress($"Error on git command, please open the '{service}' log window for detail.");
            }

            service.GitUpdateIsInProgress = false;
            service.StopProgress();
        }
        void LocalGitChanges(MicroserviceItem service)
        {
            service.LocalGitChanges = "...";
            service.LocalGitTooltip = "no changes.";

            if (service.WebsiteFolder.IsEmpty())
            {
                return;
            }

            var projFOlder = service.WebsiteFolder.AsDirectory().Parent;

            if (projFOlder == null || !Directory.Exists(Path.Combine(projFOlder.FullName, ".git")))
            {
                return;
            }

            try
            {
                var fetchoutput = "git.exe".AsFile(searchEnvironmentPath: true)
                                  .Execute("status --short", waitForExit: true, configuration: x => x.StartInfo.WorkingDirectory = projFOlder.FullName);

                var changes = new List <string>(
                    fetchoutput.Split(new string[] { "\r\n" },
                                      StringSplitOptions.RemoveEmptyEntries)).Count();

                if (changes > 0)
                {
                    service.LocalGitChanges = changes.ToString();
                }

                service.LocalGitTooltip = changes > 0 ? changes.ToString() + " uncommited changes." : "no changes.";
            }
            catch (Exception e)
            {
                service.LogMessage("Error on git command ...", e.Message);
            }
        }
Пример #8
0
        bool LoadFile(string filePath)
        {
            FileInfo file = filePath.AsFile();

            ServicesDirectory = file.Directory; //filePath.AsDirectory();

            var serviceInfos = ServicesDirectory?.GetDirectories()
                               .Where(x => File.Exists(x.FullName + @"\Website\appsettings.json"))
                               .Select(x =>
                                       new ServiceInfo
            {
                Name               = getServiceName(x.FullName + @"\Website\appSettings.json"),
                ProjectFolder      = x.FullName,
                WebsiteFolder      = Path.Combine(x.FullName, "Website"),
                LaunchSettingsPath = Path.Combine(x.FullName, @"Website\Properties", "launchSettings.json")
            });

            if (!CheckIfServicesDirectoryExist())
            {
                return(false);
            }

            servicesDirectoryLastWriteTime = ServicesDirectory.LastWriteTime;

            txtFileInfo.Text = ServicesDirectory.FullName;
            txtSolName.Text  = ServicesDirectory.Name;
            if (serviceInfos == null)
            {
                return(false);
            }

            foreach (var serviceInfo in serviceInfos)
            {
                var serviceName = serviceInfo.Name;
                var srv         = ServiceData.SingleOrDefault(srvc => srvc.Service == serviceName);
                if (srv == null)
                {
                    srv = new MicroserviceItem();
                    ServiceData.Add(srv);
                }

                var port           = "";
                var status         = MicroserviceItem.EnumStatus.NoSourcerLocally;
                var parentFullName = ServicesDirectory?.FullName ?? "";
                var projFolder     = serviceInfo.ProjectFolder;
                var websiteFolder  = serviceInfo.WebsiteFolder;
                var launchSettings = serviceInfo.LaunchSettingsPath;
                var procId         = -1;

                if (File.Exists(@launchSettings))
                {
                    status = MicroserviceItem.EnumStatus.Pending;
                    port   = GetPortNumberFromLaunchSettingsFile(launchSettings);
                }
                else
                {
                    websiteFolder = null;
                }

                srv.Status         = status;
                srv.Service        = serviceName;
                srv.Port           = port;
                srv.ProcId         = procId;
                srv.SolutionFolder = projFolder;
                srv.WebsiteFolder  = websiteFolder;
            }

            FilterListBy(txtSearch.Text);

            projectLoaded = true;

            if (watcher == null)
            {
                StartFileSystemWatcher(ServicesDirectory);
            }

            Refresh();

            return(true);
        }
Пример #9
0
        Task FetchUpdates(MicroserviceItem service)
        {
            var refresh = Task.Factory.StartNew(service.RefreshPackages, TaskCreationOptions.LongRunning);

            return(refresh);
        }