public bool TakeOver(PackageContainerBase container) { try { // close old one if (Container != null) { if (Container.IsOpen) { Container.Close(); } Container = null; } // figure out, what to load Container = container; // success! return(true); } catch (Exception ex) { throw new PackageCentralException( $"PackageCentral: while performing takeover " + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); } }
public PackageContainerBase(CopyMode mode, PackageContainerBase other, PackageCentral packageCentral = null) { if ((mode & CopyMode.Serialized) > 0 && other != null) { // nothing here } if (packageCentral != null) { _packageCentral = packageCentral; } }
public PackageContainerBuffered(CopyMode mode, PackageContainerBase other, PackageCentral packageCentral = null) : base(mode, other, packageCentral) { if ((mode & CopyMode.Serialized) > 0 && other != null) { } if ((mode & CopyMode.BusinessData) > 0 && other is PackageContainerBuffered o) { IndirectLoadSave = o.IndirectLoadSave; } }
public PackageContainerRepoItem(CopyMode mode, PackageContainerBase other, PackageCentral packageCentral = null) : base(mode, other, packageCentral) { if ((mode & CopyMode.Serialized) > 0 && other is PackageContainerRepoItem o) { _assetIds = new List <string>(o.AssetIds); _aasIds = new List <string>(o.AasIds); _location = "" + o.Location; _description = "" + o.Description; _tag = "" + o.Tag; this.CodeType2D = "" + o.CodeType2D; } }
public static PackageContainerBase GuessAndCreateFor( PackageCentral packageCentral, string location, string fullItemLocation, bool overrideLoadResident, PackageContainerBase takeOver = null, PackageContainerOptionsBase containerOptions = null, PackCntRuntimeOptions runtimeOptions = null) { var task = Task.Run(() => GuessAndCreateForAsync( packageCentral, location, fullItemLocation, overrideLoadResident, takeOver, containerOptions, runtimeOptions)); return(task.Result); }
public bool Load( PackageCentral packageCentral, string location, string fullItemLocation, bool overrideLoadResident, PackageContainerOptionsBase containerOptions = null, PackCntRuntimeOptions runtimeOptions = null) { try { // close old one if (Container != null) { if (Container.IsOpen) { Container.Close(); } Container = null; } // figure out, what to load var task = Task.Run(async() => await PackageContainerFactory.GuessAndCreateForAsync( packageCentral, location, fullItemLocation, overrideLoadResident, null, containerOptions, runtimeOptions)); var guess = task.Result; if (guess == null) { return(false); } // success! Container = guess; return(true); } catch (Exception ex) { throw new PackageCentralException( $"PackageCentral: while performing load from {location} " + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}", ex); } }
public static async Task <PackageContainerNetworkHttpFile> CreateAndLoadAsync( PackageCentral packageCentral, string location, string fullItemLocation, bool overrideLoadResident, PackageContainerBase takeOver = null, PackageContainerOptionsBase containerOptions = null, PackCntRuntimeOptions runtimeOptions = null) { var res = new PackageContainerNetworkHttpFile(CopyMode.Serialized, takeOver, packageCentral, location, containerOptions); if (overrideLoadResident || true == res.ContainerOptions?.LoadResident) { await res.LoadFromSourceAsync(fullItemLocation, runtimeOptions); } return(res); }
// // Constructors // /// <summary> /// By design, a PackageConnector is based on a PackageContainer. For some funcionality, it will require /// a link to the container. For some other, not. /// The basepoint is the left part of an URL, which forms an Endpoint; routes will generated to the right of /// it. /// </summary> public PackageConnectorHttpRest(PackageContainerBase container, Uri endpoint) : base(container) { _endpoint = endpoint; // split into base address and end part _baseAddress = new Uri(endpoint.GetLeftPart(UriPartial.Authority)); _endPointSegments = endpoint.GetComponents(UriComponents.Path, UriFormat.SafeUnescaped); // make HTTP Client var handler = new HttpClientHandler(); handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials; _client = new HttpClient(handler); _client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); _client.BaseAddress = _baseAddress; }
public void Close() { try { // close old one if (Container != null) { if (Container.IsOpen) { Container.Close(); } Container = null; } } catch (Exception ex) { throw new PackageCentralException( $"PackageCentral: while performing close " + $"at {AdminShellUtil.ShortLocation(ex)} gave: {ex.Message}"); } }
public PackageContainerLocalFile(CopyMode mode, PackageContainerBase other, PackageCentral packageCentral = null, string sourceFn = null, PackageContainerOptionsBase containerOptions = null) : base(mode, other, packageCentral) { if ((mode & CopyMode.Serialized) > 0 && other != null) { } if ((mode & CopyMode.BusinessData) > 0 && other is PackageContainerLocalFile o) { sourceFn = o.Location; } if (sourceFn != null) { SetNewLocation(sourceFn); } if (containerOptions != null) { ContainerOptions = containerOptions; } }
public static async Task <PackageContainerBase> GuessAndCreateForAsync( PackageCentral packageCentral, string location, string fullItemLocation, bool overrideLoadResident, PackageContainerBase takeOver = null, PackageContainerOptionsBase containerOptions = null, PackCntRuntimeOptions runtimeOptions = null) { // access if (location == null) { return(null); } var ll = location.ToLower(); // guess runtimeOptions?.Log?.Info($"Trying to guess package container for {location} .."); var guess = PackageContainerGuess.FromLocation(location, runtimeOptions); if (guess == null) { runtimeOptions?.Log?.Info("Aborting"); return(null); } // start runtimeOptions?.Log?.Info($".. with containerOptions = {containerOptions?.ToString()}"); // TODO (MIHO, 2021-02-01): check, if demo option is still required if (ll.Contains("/demo")) { return(await Demo(packageCentral, location, overrideLoadResident, containerOptions, runtimeOptions)); } // starts with http ? if (guess.GuessedType == typeof(PackageContainerNetworkHttpFile)) { var cnt = await PackageContainerNetworkHttpFile.CreateAndLoadAsync( packageCentral, location, fullItemLocation, overrideLoadResident, takeOver, containerOptions, runtimeOptions); if (cnt.ContainerOptions.StayConnected && guess.AasId.HasContent() && guess.HeadOfPath.HasContent()) { cnt.ConnectorPrimary = new PackageConnectorHttpRest(cnt, new Uri(guess.HeadOfPath + "/aas/" + guess.AasId)); } return(cnt); } // check FileInfo for (possible?) local file FileInfo fi = null; try { fi = new FileInfo(location); } catch (Exception ex) { LogInternally.That.SilentlyIgnoredError(ex); } // if file, try to open (might throw exceptions!) if (fi != null) { // seems to be a valid (possible) file return(await PackageContainerLocalFile.CreateAndLoadAsync( packageCentral, location, fullItemLocation, overrideLoadResident, takeOver, containerOptions)); } // no?? runtimeOptions?.Log?.Info($".. no any possible option for package container found .. Aborting!"); return(null); }
// // Constructors // public PackageConnectorEventStore(PackageContainerBase container) : base(container) { }
// // Constructors // /// <summary> /// By design, a PackageConnector is based on a PackageContainer. /// </summary> public PackageConnectorBase(PackageContainerBase container) { _container = container; }