private void AssignRunOrderIndexIfZero(PackageToRun instancePackage) { if (instancePackage.RunOrder == 0) { instancePackage.RunOrder = GetMostHighIndex(instancePackage) + 1; } }
private void UpdateInstance(PackageToRun packageToRunModified, PackageToRun instancePackage) { instancePackage.InstanceName = packageToRunModified.InstanceName; instancePackage.Parameter = packageToRunModified.Parameter; instancePackage.RunOnServerStart = packageToRunModified.RunOnServerStart; AssignRunOrderIndexIfZero(instancePackage); ReorderPackages(packageToRunModified, instancePackage); instancePackage.RunOrder = packageToRunModified.RunOrder; }
private static void ReorderToUpper(PackageToRun packageToRunModified, PackageToRun instancePackage, IEnumerable <PackageToRun> instancesExceptModified) { var instancesToReorder = instancesExceptModified.Where(i => i.RunOrder >= packageToRunModified.RunOrder && i.RunOrder <= instancePackage.RunOrder); foreach (var packageToRun in instancesToReorder) { packageToRun.RunOrder++; } }
private int GetMostHighIndex(PackageToRun instancePackage) { var packagesNonZero = _packagesToRun.Except(new List <PackageToRun>() { instancePackage }).Where(p => p.RunOrder > 0) .OrderByDescending(p => p.RunOrder); if (packagesNonZero.Any()) { return(packagesNonZero.First().RunOrder); } return(0); }
public void AddInstanceToRun(PackageToRun packageToRun) { var packagesToRun = _packagesToRun.Where(p => p.PackageId == packageToRun.PackageId && p.InstanceName == packageToRun.InstanceName); if (!packagesToRun.Any()) { AddInstance(packageToRun); } else { var instancePackage = packagesToRun.First(); UpdateInstance(packageToRun, instancePackage); } Persist(); }
private void ReorderPackages(PackageToRun packageToRunModified, PackageToRun instancePackage) { var instancesExceptModified = _packagesToRun.Except(new List <PackageToRun>() { instancePackage }); if (packageToRunModified.RunOrder < instancePackage.RunOrder) { ReorderToUpper(packageToRunModified, instancePackage, instancesExceptModified); } else { ReorderToLower(packageToRunModified, instancePackage, instancesExceptModified); } }
private async Task <bool> RunInstance(PackageToRun packageToRun, List <Assembly> assemblies) { var packageInstance = RunInstanceOfPackage(packageToRun.PackageId, assemblies); if (packageInstance != null) { var running = await packageInstance.Run(packageToRun.InstanceName, packageToRun.PackageId, _hostingConfiguration.GetAddressServer(), _hostingConfiguration.GetPortServer(), _hostingConfiguration.GetUseSsl(), packageToRun.Parameter); if (running) { _instancesRunning.Add(packageToRun.InstanceId, new PackageInstance(packageToRun, packageInstance)); } return(running); } return(false); }
public PackageInstance(PackageToRun packagePackageToRun, ISentinel instance) { PackageToRun = packagePackageToRun; Instance = instance; }
private void AddInstance(PackageToRun packageToRun) { AssignRunOrderIndexIfZero(packageToRun); _packagesToRun.Add(packageToRun); }