Exemplo n.º 1
0
        public Providers GetAllChildStockExchangeProvidersOf(ProductionOrderOperation operation)
        {
            Ids productionOrderBomIds = _dbTransactionData.ProductionOrderBomGetAll()
                                        .GetProductionOrderBomsBy(operation);

            Providers providers = new Providers();

            foreach (var productionOrderBomId in productionOrderBomIds)
            {
                Demand productionOrderBom =
                    _dbTransactionData.ProductionOrderBomGetById(productionOrderBomId);
                foreach (var stockExchangeProvider in GetAllChildProvidersOf(productionOrderBom))
                {
                    if (stockExchangeProvider.GetType() == typeof(StockExchangeProvider))
                    {
                        providers.Add((StockExchangeProvider)stockExchangeProvider);
                    }
                    else
                    {
                        throw new MrpRunException(
                                  "A child of an productionOrderBom can only a StockExchangeProvider.");
                    }
                }
            }

            if (providers.Any() == false)
            {
                return(null);
            }

            return(providers);
        }
        public Provider GetProvider(string provider)
        {
            if (Providers == null || !Providers.Any())
            {
                throw new NullReferenceException("There are no providers set");
            }

            return(Providers.SingleOrDefault(x => x.Name.Equals(provider, StringComparison.CurrentCultureIgnoreCase)));
        }
        public Provider GetDefaultProvider()
        {
            if (Providers == null || !Providers.Any())
            {
                throw new NullReferenceException("There are no providers set");
            }

            return(Providers[0]);
        }
Exemplo n.º 4
0
        public static async Task <bool> HasConnection(Word word)
        {
            foreach (var imageProvider in Providers)
            {
                imageProvider._isAvailable = await imageProvider.TestTheConnection(word);
            }

            return(Providers.Any(x => x._isAvailable));
        }
Exemplo n.º 5
0
        IEnumerable <ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            List <ValidationResult> results = new();

            bool hasProfile   = Profile.HasValue;
            bool hasProviders = null != Providers && Providers.Any();

            if (hasProfile)
            {
                if (hasProviders)
                {
                    // Both Profile and Providers cannot be specified at the same time, otherwise
                    // cannot determine whether to use providers from the profile or the custom
                    // specified providers.
                    results.Add(new ValidationResult(
                                    string.Format(
                                        CultureInfo.InvariantCulture,
                                        Strings.ErrorMessage_TwoFieldsCannotBeSpecified,
                                        nameof(Profile),
                                        nameof(Providers))));
                }
            }
            else if (hasProviders)
            {
                // Validate that each provider is valid.
                int index = 0;
                foreach (EventPipeProvider provider in Providers)
                {
                    ValidationContext providerContext = new(provider, validationContext, validationContext.Items);
                    providerContext.MemberName = nameof(Providers) + "[" + index.ToString(CultureInfo.InvariantCulture) + "]";

                    Validator.TryValidateObject(provider, providerContext, results, validateAllProperties: true);

                    IOptionsMonitor <GlobalCounterOptions> counterOptions = validationContext.GetRequiredService <IOptionsMonitor <GlobalCounterOptions> >();
                    if (!CounterValidator.ValidateProvider(counterOptions.CurrentValue,
                                                           provider, out string errorMessage))
                    {
                        results.Add(new ValidationResult(errorMessage, new[] { nameof(EventPipeProvider.Arguments) }));
                    }

                    index++;
                }
            }
            else
            {
                // Either Profile or Providers must be specified
                results.Add(new ValidationResult(
                                string.Format(
                                    CultureInfo.InvariantCulture,
                                    Strings.ErrorMessage_TwoFieldsMissing,
                                    nameof(Profile),
                                    nameof(Providers))));
            }

            return(results);
        }
Exemplo n.º 6
0
        public async Task <bool> OrganizationOwner(Guid orgId)
        {
            if (Organizations?.Any(o => o.Id == orgId && o.Type == OrganizationUserType.Owner) ?? false)
            {
                return(true);
            }

            if (Providers.Any())
            {
                return((await GetProviderOrganizations()).Any(po => po.OrganizationId == orgId));
            }

            return(false);
        }
Exemplo n.º 7
0
    public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
    {
        var result = new List <ValidationResult>();

        if (!Providers.Any())
        {
            result.Add(new ValidationResult("No Providers", new[] { nameof(AggregateSearchCriteria.Providers) }));
        }
        if (!Aggregates.Any())
        {
            result.Add(new ValidationResult("No Aggregates", new[] { nameof(AggregateSearchCriteria.Aggregates) }));
        }
        return(result);
    }
Exemplo n.º 8
0
        public Demands GetUnsatisfiedCustomerOrderParts()
        {
            Demands unsatisfiedCustomerOrderParts = new Demands();

            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator();

            Demands customerOrderParts = dbTransactionData.CustomerOrderPartGetAll();

            foreach (var customerOrderPart in customerOrderParts)
            {
                Providers customerOrderPartChilds =
                    aggregator.GetAllChildProvidersOf(customerOrderPart);
                if (customerOrderPartChilds == null || customerOrderPartChilds.Any() == false)
                {
                    unsatisfiedCustomerOrderParts.Add(customerOrderPart);
                }
            }

            return(unsatisfiedCustomerOrderParts);
        }
        private void DeploySitemaps(Guid website)
        {
            var sitemapDirectory = Config.GetSitemapDirectory(website);
            var destDirInfo      = new DirectoryInfo(sitemapDirectory);
            var workingDirectory = Config.GetWorkingDirectory(website);
            var tempDirInfo      = new DirectoryInfo(workingDirectory);

            var sitemapIndexOriginFilepath      = Path.Combine(workingDirectory, SitemapIndexFilename);
            var sitemapIndexDestinationFilepath = Path.Combine(sitemapDirectory, SitemapIndexFilename);

            // Delete sitemap index
            if (File.Exists(sitemapIndexDestinationFilepath))
            {
                File.Delete(sitemapIndexDestinationFilepath);
            }

            // Cleanup destination directory first
            var siteMapsToDelete = destDirInfo
                                   .GetFiles()
                                   .Where(fileInfo => Providers.Any(provider => provider.IsMatch(fileInfo.Name)));

            foreach (var siteMapToDelete in siteMapsToDelete)
            {
                siteMapToDelete.Delete();
            }

            // Move sitemap index
            File.Move(sitemapIndexOriginFilepath, sitemapIndexDestinationFilepath);

            // Move temporary sitemap files to destination directory
            // Include all directory content (index + sitemaps)
            foreach (var siteMapFileInfo in tempDirInfo.GetFiles())
            {
                var destinationFilePath = Path.Combine(sitemapDirectory, siteMapFileInfo.Name);
                siteMapFileInfo.MoveTo(destinationFilePath);
            }
        }
Exemplo n.º 10
0
        public async Task <int> OnExecuteAsync(CommandLineApplication app, IConsole console)
        {
            var disconnectCts     = new CancellationTokenSource();
            var cancellationToken = console.GetCtrlCToken();

            if (!TryCreateClient(console, out var client))
            {
                return(1);
            }

            console.WriteLine("Connecting to application...");

            client.OnEventWritten += (evt) =>
            {
                // TODO: Format both kinds of messages ("Foo {0}" and "Foo {foo}")
                console.WriteLine($"{evt.ProviderName}/{evt.EventName}({evt.EventId}): {evt.Message}");
                for (var i = 0; i < evt.Payload.Count; i++)
                {
                    console.WriteLine($"  {evt.PayloadNames[i]}: {evt.Payload[i]}");
                }
            };

            client.OnEventCounterUpdated += (state) =>
            {
                console.WriteLine($"Counter: {state.ProviderName}/{state.CounterName} (Avg: {state.Mean}, StdDev: {state.StandardDeviation}, Count: {state.Count}, Min: {state.Min}, Max: {state.Max})");
            };

            client.Disconnected += (ex) =>
            {
                console.WriteLine("Disconnected");
                if (ex != null)
                {
                    console.Error.WriteLine(ex.ToString());
                }
                disconnectCts.Cancel();
            };

            await client.ConnectAsync();

            var enabledSomething = false;

            if (Loggers != null && Loggers.Any())
            {
                await client.EnableLoggersAsync(Loggers);

                enabledSomething = true;
            }

            if (Counters != null && Counters.Any())
            {
                await client.EnableCountersAsync(Counters);

                enabledSomething = true;
            }

            if (Providers != null && Providers.Any())
            {
                var requests = new List <EnableEventsRequest>(Providers.Count);
                foreach (var p in Providers)
                {
                    if (!TryCreateEventRequest(console, p, out var request))
                    {
                        return(1);
                    }
                    requests.Add(request);
                }
                await client.EnableEventsAsync(requests);

                enabledSomething = true;
            }

            if (!enabledSomething)
            {
                console.Error.WriteLine("At least one of '--provider', '--logger', or '--counter' must be provided.");
                return(1);
            }

            console.WriteLine("Connected, press Ctrl-C to terminate...");
            await CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, disconnectCts.Token).WaitForCancellationAsync();

            return(0);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Checks if the given provider is registered
 /// </summary>
 /// <param name="M">Single provider</param>
 /// <returns>true, if the provider exists</returns>
 public bool HasProvider(CryptoMode M)
 {
     return(Providers.Any(m => m.Mode == M));
 }
Exemplo n.º 12
0
 public CredentialService CreateNonInteractive()
 {
     bool handlesDefaultCredentials = Providers.Any(provider => provider is DefaultNetworkCredentialsCredentialProvider);
     var  lazyProviders             = AsyncLazy.New(() => Providers)
     ;                       return(new CredentialService(lazyProviders, nonInteractive: true, handlesDefaultCredentials: handlesDefaultCredentials));
 }
Exemplo n.º 13
0
 public bool ProviderUser(Guid providerId)
 {
     return(Providers?.Any(o => o.Id == providerId) ?? false);
 }
Exemplo n.º 14
0
 public bool ProviderProviderAdmin(Guid providerId)
 {
     return(Providers?.Any(o => o.Id == providerId && o.Type == ProviderUserType.ProviderAdmin) ?? false);
 }
        public void TestApplyConfirmations(string testConfigurationFileName)
        {
            InitThisTest(testConfigurationFileName);

            IDbTransactionData dbTransactionData =
                ZppConfiguration.CacheManager.GetDbTransactionData();
            IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator();

            // Ein CustomerOrderParts darf kein Kind haben und darf nicht beendet sein
            Ids customerOrderIds = new Ids();

            foreach (var demand in dbTransactionData.CustomerOrderPartGetAll())
            {
                CustomerOrderPart customerOrderPart = (CustomerOrderPart)demand;
                customerOrderIds.Add(customerOrderPart.GetCustomerOrderId());
                Providers childs = aggregator.GetAllChildProvidersOf(customerOrderPart);
                Assert.False(childs.Any());
                Assert.False(customerOrderPart.IsFinished());
            }

            // Ein PurchaseOrderPart darf kein Elter haben und darf nicht beendet sein.
            Ids purchaseOrderIds = new Ids();

            foreach (var demand in dbTransactionData.PurchaseOrderPartGetAll())
            {
                PurchaseOrderPart purchaseOrderPart = (PurchaseOrderPart)demand;
                purchaseOrderIds.Add(purchaseOrderPart.GetPurchaseOrderId());

                Assert.False(purchaseOrderPart.IsFinished());
                Demands demands = aggregator.GetAllParentDemandsOf(demand);
                Assert.True(demands == null || demands.Any() == false);
            }

            // Für jede CustomerOrder muss es mind. noch ein CustomerOrderPart geben.
            foreach (var customerOrder in dbTransactionData.CustomerOrderGetAll())
            {
                Assert.True(customerOrderIds.Contains(customerOrder.GetId()));
            }

            // Für jede PurchaseOrder muss es mind. noch ein PurchaseOrderPart geben.
            foreach (var purchaseOrder in dbTransactionData.PurchaseOrderGetAll())
            {
                Assert.True(purchaseOrderIds.Contains(purchaseOrder.GetId()));
            }

            // Ein StockExchangeProvider muss mind. ein Kind haben.
            foreach (var stockExchangeProvider in dbTransactionData.StockExchangeProvidersGetAll())
            {
                Demands childs = aggregator.GetAllChildDemandsOf(stockExchangeProvider);
                Assert.True(childs.Any());
            }

            // Ein StockExchangeDemand darf nicht beendet und geschlossen sein.
            foreach (var stockExchangeDemand in dbTransactionData.StockExchangeDemandsGetAll())
            {
                bool isOpen = OpenDemandManager.IsOpen((StockExchangeDemand)stockExchangeDemand);
                Assert.False(stockExchangeDemand.IsFinished() && isOpen == false);
            }

            // Eine ProductionOrder darf nicht beendet sein und für eine ProductionOrder
            // muss es mind. eine  Operation geben.
            Ids productionOrderIds = new Ids();
            Ids operationIds       = new Ids();

            foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll())
            {
                Id productionOrderId = operation.GetProductionOrderId();
                if (productionOrderIds.Contains(productionOrderId) == false)
                {
                    productionOrderIds.Add(productionOrderId);
                }

                operationIds.Add(operation.GetId());
            }
            foreach (var provider in dbTransactionData.ProductionOrderGetAll())
            {
                ProductionOrder productionOrder = (ProductionOrder)provider;
                Assert.False(productionOrder.DetermineProductionOrderState()
                             .Equals(State.Finished));
                Assert.True(productionOrderIds.Contains(productionOrder.GetId()));
            }

            // Für jede ProductionOrderBom muss die dazugehörige Operation da sein.
            foreach (var demand in dbTransactionData.ProductionOrderBomGetAll())
            {
                ProductionOrderBom productionOrderBom = (ProductionOrderBom)demand;
                operationIds.Contains(productionOrderBom.GetProductionOrderOperationId());
            }

            // Für jeden DemandToProvider und ProviderToDemand müssen die dazugehörigen
            // Demands und Provider existieren.
            foreach (var demandToProvider in dbTransactionData.DemandToProviderGetAll())
            {
                Demand   demand   = dbTransactionData.DemandsGetById(demandToProvider.GetDemandId());
                Provider provider =
                    dbTransactionData.ProvidersGetById(demandToProvider.GetProviderId());
                Assert.NotNull(demand);
                Assert.NotNull(provider);
            }

            foreach (var providerToDemand in dbTransactionData.ProviderToDemandGetAll())
            {
                Demand   demand   = dbTransactionData.DemandsGetById(providerToDemand.GetDemandId());
                Provider provider =
                    dbTransactionData.ProvidersGetById(providerToDemand.GetProviderId());
                Assert.NotNull(demand);
                Assert.NotNull(provider);
            }
        }
        /// <summary>
        /// TODO We need to have some events from providers to invalidate the cache if some project's
        /// target frameworks are changed (in this case we just need to remove/update cache items that have
        /// same DTE as changed project).
        ///  For now cache will be invalidated when solution is closed and reopened.
        /// </summary>
        /// <param name="filePath">Path to a code file being analyzed</param>
        /// <returns></returns>
        public IEnumerable <TargetFrameworkMetadata> GetTargetFrameworks(string filePath)
        {
            IEnumerable <TargetFrameworkMetadata> resultFrameworks = null;
            string uniqueProjectName = null;

            // try to get framework info for a given file from cache
            lock (_cacheLock)
            {
                if (FilesCache.TryGetValue(filePath, out uniqueProjectName) &&
                    ProjectFrameworksCache.TryGetValue(uniqueProjectName, out resultFrameworks))
                {
                    return(resultFrameworks);
                }
            }

            if (Providers == null || !Providers.Any())
            {
                return(null);
            }

            ThreadHelper.JoinableTaskFactory.Run(async delegate
            {
                // Switch to main thread
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
                try
                {
                    var container  = ServiceProvider.GetService <IComponentModel, SComponentModel>();
                    var dteProject = DocumentExtensions.GetVsHierarchy(filePath, ServiceProvider).GetDTEProject();

                    if (dteProject == null)
                    {
                        return;
                    }

                    var provider = Providers.FirstOrDefault(x => x.SupportsProject(dteProject));
                    if (provider != null)
                    {
                        uniqueProjectName = dteProject.UniqueName;
                        resultFrameworks  = provider.GetTargetFrameworks(dteProject);
                    }
                }
                catch (Exception e)
                {
                    // Add to Package Manager console?
                    Debug.Write(string.Format("{0}. Stack trace: {1}", e.Message, e.StackTrace));
                }
            });

            // add file and project frameworks to cache
            lock (_cacheLock)
            {
                if (ProjectFrameworksCache.Keys.Contains(uniqueProjectName))
                {
                    ProjectFrameworksCache[uniqueProjectName] = resultFrameworks;
                }
                else
                {
                    ProjectFrameworksCache.Add(uniqueProjectName, resultFrameworks);
                }

                if (FilesCache.Keys.Contains(filePath))
                {
                    FilesCache[filePath] = uniqueProjectName;
                }
                else
                {
                    FilesCache.Add(filePath, uniqueProjectName);
                }
            }

            return(resultFrameworks);
        }