Exemple #1
0
        /// <summary>
        /// This callback is called when the catalog combobox is deployed.
        /// </summary>
        private void DeployCatalogCommandExecute()
        {
            if (_taskRetrieveDataBasesIsLaunched)
            {
                return;
            }

            var context = TaskScheduler.FromCurrentSynchronizationContext();

            Catalogs.Clear();
            Catalogs.Add("(loading databases ...)");
            var connectionString = CreateConnectionStringWithoutCatalog();

            _taskRetrieveDataBasesIsLaunched = true;
            GetDatabases(connectionString).ContinueWith(taskResult =>
            {
                try
                {
                    var databases = taskResult.Result;
                    Catalogs.Clear();
                    databases.ForEach(s => Catalogs.Add(s));
                }
                finally
                {
                    _taskRetrieveDataBasesIsLaunched = false;
                }
            }, context);
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new <see cref="RecursiveDirectoryCatalog"/>.
 /// </summary>
 /// <param name="path">
 /// The root directory path. In addition to the root, subdirectories of this path are searched for parts.
 /// </param>
 public RecursiveDirectoryCatalog(string path)
 {
     foreach (var catalog in GetCatalogs(path))
     {
         Catalogs.Add(catalog);
     }
 }
Exemple #3
0
            public AppCatalog(string baseDir = null, string relSearchPath = null)
            {
                // This logic is 'borrowed' from the decompiled guts of the class
                //    <<System.ComponentModel.Composition.Hosting.ApplicationCatalog>>
                // The behavior is mostly the same, but it is simplified for our
                // particular use-case, and enhanced to support setting the BaseDir

                if (baseDir == null)
                {
                    baseDir = AppDomain.CurrentDomain.BaseDirectory;
                }

                if (relSearchPath == null)
                {
                    relSearchPath = AppDomain.CurrentDomain.RelativeSearchPath;
                }

                BaseDirectory      = baseDir;
                RelativeSearchPath = relSearchPath;

                Catalogs.Add(new DirectoryCatalog(baseDir, "*.dll"));
                Catalogs.Add(new DirectoryCatalog(baseDir, "*.exe"));
                if (!string.IsNullOrEmpty(relSearchPath))
                {
                    foreach (var path in relSearchPath.Split(new char[] { ';' },
                                                             StringSplitOptions.RemoveEmptyEntries))
                    {
                        var catDir = Path.Combine(baseDir, path);
                        if (Directory.Exists(catDir))
                        {
                            Catalogs.Add(new DirectoryCatalog(catDir, "*.dll"));
                        }
                    }
                }
            }
        /// <summary>
        /// make a copy of catalog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btCopy_Click(object sender, RoutedEventArgs e)
        {
            //get the selected item
            if (lbCatalogs.SelectedItem == null)
            {
                return;
            }
            ICatalog copy = lbCatalogs.SelectedItem as ICatalog;

            //copy fields
            var cat = new Catalog.Catalog(ComputeNode);

            BermudaConfigUtil.CopyCatalog(copy, cat);

            //open the window
            CatalogConfig window = new CatalogConfig(cat, "");
            var           ret    = window.ShowDialog();

            if (!ret.HasValue || ret == false)
            {
                return;
            }

            //add to list
            Catalogs.Add(cat);
            ComputeNode.Catalogs.Add(cat.CatalogName, cat);
        }
 private void PrintCatalogs()
 {
     Catalogs.Clear();
     foreach (var item in GetCatalogs())
     {
         Catalogs.Add(item);
     }
 }
        public MultipleDirectoryCatalog(string path, bool watchDirector, string filter)
        {
            string directoryName = GetNormalizedDirectoryName(path);

            foreach (string subDirectory in Directory.GetDirectories(directoryName))
            {
                Catalogs.Add(new DirectoryCatalog(subDirectory, watchDirector, filter));
            }
        }
Exemple #7
0
        public CatalogData GetOrGenerateCatalog(Market market)
        {
            if (!Catalogs.ContainsKey(market.Id))
            {
                Catalogs.Add(market.Id, market.Catalog.Generate().Compress());
            }
            else if (!market.IsActive(Catalogs[market.Id].GeneratedAt))
            {
                Catalogs[market.Id] = market.Catalog.Generate().Compress();
            }

            return(Catalogs[market.Id]);
        }
        private void AddCatalogAddCommandExecute(object obj)
        {
            Catalog newCatalog = new Catalog
            {
                title = AddCatalogTitle
            };

            _dataBase.Catalog.Add(newCatalog);
            Catalogs.Add(newCatalog);
            _dataBase.SaveChanges();

            AddingCatalogStatusText = "Added!";

            AddCatalogTitle = string.Empty;
        }
Exemple #9
0
 public bool AddProduct(string sku, string description, string[] barcodes, int supplierID)
 {
     if (Catalogs.Any(p => p.SKU.Equals(sku, StringComparison.InvariantCultureIgnoreCase)))
     {
         return(false);
     }
     else
     {
         Catalogs.Add(new Product()
         {
             SKU = sku, Description = description, Original = CATALOG_ORIGINAL
         });
         return(AddBarcodes(sku, barcodes, supplierID));
     }
 }
        private void ConfigureMef()
        {
            var adapter = new AutofacContainerAdapter(_context);
            var containerExportProvider = new ContainerExportProvider(adapter);
            var scope = _context as ISharingLifetimeScope;

            if (scope != null)
            {
                var parentScope = scope.ParentLifetimeScope;
                var parent      = parentScope != null?parentScope.ResolveOptional <CompositionIntegration>() : null;

                if (parent != null)
                {
                    // Get the parent ContainerExportProvider
                    var parentContainerExportProvider = (ContainerExportProvider)parent.Providers.Where(
                        ep => typeof(ContainerExportProvider).IsAssignableFrom(ep.GetType())).First();

                    // Collect all the exports provided by the parent container and add
                    // them to the child export provider
                    foreach (var definition in parentContainerExportProvider.FactoryExportProvider.ReadOnlyDefinitions)
                    {
                        containerExportProvider.FactoryExportProvider.Register(
                            definition.ContractType,
                            definition.RegistrationName);
                    }

                    // Grab all the parent export providers except the container ones
                    var exportProviders = new List <ExportProvider>(
                        parent.Providers.Where(
                            ep => !typeof(ContainerExportProvider).IsAssignableFrom(ep.GetType())))
                    {
                        containerExportProvider
                    };

                    var catalog = new AggregateCatalog(parent.Catalogs);
                    //NOTE: this might result in duplicate exports... need to investigate.

                    Register   = true;
                    _providers = exportProviders.ToArray();
                    Catalogs.Add(catalog);
                }
                else
                {
                    Register   = true;
                    _providers = new ExportProvider[] { containerExportProvider };
                }
            }
        }
Exemple #11
0
        private void ResetCatalog(CultureInfo cultureInfo)
        {
            if (Catalogs == null)
            {
                Catalogs = new List <ICatalog>();
            }
            else
            {
                Catalogs.Clear();
            }

            foreach (var domainName in mDomainNames)
            {
                Catalogs.Add(GetCatalog(cultureInfo, domainName));
            }
        }
Exemple #12
0
        public void Merge(string catalogBPath, string supplierBPath, string barcodeBPath)
        {
            var catalogB   = LoadProducts(catalogBPath, "B");
            var suppliersB = LoadSupplier(supplierBPath);
            var barcodesB  = LoadBarcodes(barcodeBPath, catalogB, suppliersB);

            foreach (var productBarcode in barcodesB)
            {
                if (!Barcodes.Any(bc => bc.Barcode == productBarcode.Barcode))
                {
                    if (!Catalogs.Any(p => p.SKU == productBarcode.Product.SKU))
                    {
                        Catalogs.Add(productBarcode.Product);
                    }
                    Barcodes.Add(productBarcode);
                }
            }
        }
        async public Task LoadCatalogs()
        {
            if (IsCatalogsLoading || !IsUserViewModelLoaded)
            {
                return;
            }
            IsCatalogsLoading = true;
            hasCatalogs       = null;

            var options = new EtaApiQueryStringParameterOptions();

            options.AddParm(EtaApiConstants.EtaApi_Latitude, UserViewModel.Location.Latitude.ToString("0.00000"));
            options.AddParm(EtaApiConstants.EtaApi_Longitude, UserViewModel.Location.Longitude.ToString("0.00000"));
            options.AddParm(EtaApiConstants.EtaApi_LocationDetermined, UNIXTime.GetTimestamp(DateTime.Now));
            options.AddParm(EtaApiConstants.EtaApi_Geocoded, UserViewModel.Location.IsGeoCoded ? "0" : "0");
            options.AddParm(EtaApiConstants.EtaApi_Accuracy, "0");//userModel.Location.Accuracy.ToString());
            options.AddParm(EtaApiConstants.EtaApi_Ditance, UserViewModel.Distance.ToString());

            var response = await Api.GetCatalogListAsync(options);

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                if (Catalogs.Any())
                {
                    Catalogs.Clear();
                }

                if (response.HasErrors)
                {
                    IsCatalogsLoaded = false;
                }
                else
                {
                    foreach (var catalog in response.Result)
                    {
                        Catalogs.Add(catalog);
                    }
                    IsCatalogsLoaded = true;
                }
                HasCatalogs       = Catalogs.Any();
                IsCatalogsLoading = false;
            });
        }
        /// <summary>
        /// create a new catalog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btNew_Click(object sender, RoutedEventArgs e)
        {
            //new item
            var cat = new Catalog.Catalog(ComputeNode);

            cat.CatalogMetadata = new CatalogMetadata(cat);

            //open the window
            CatalogConfig window = new CatalogConfig(cat, "");
            var           ret    = window.ShowDialog();

            if (!ret.HasValue || ret == false)
            {
                return;
            }

            //add to list
            Catalogs.Add(cat);
            ComputeNode.Catalogs.Add(cat.CatalogName, cat);
        }
        private void ExecuteCommand(Func <Catalog, bool> apiMethod, object obj)
        {
            if (obj != null)
            {
                Catalog catalog  = obj as Catalog;
                bool    response = apiMethod(catalog);

                Catalogs?.Clear();
                MarketAPI.GetCatalog(out List <Catalog> catalogs, out bool result);

                if (result && catalogs != null)
                {
                    catalogs.ForEach(x => Catalogs.Add(x));
                }

                MessageBox.Show
                (
                    response ?
                    MarketAPI.SuccessMessage : MarketAPI.FailMessage
                );
            }
        }
Exemple #16
0
        public void OnCatalogReceived(Catalog obj)
        {
            if (!Catalogs.ContainsKey(obj.DeviceID))
            {
                Catalogs.Add(obj.DeviceID, obj);
                logger.Debug("OnCatalogReceived: " + JsonConvert.SerializeObject(obj));
            }
            if (GBSIPTransactions.ContainsKey(obj.DeviceID))
            {
                SIPTransaction _SIPTransaction = GBSIPTransactions[obj.DeviceID];
                obj.DeviceList.Items.FindAll(item => item != null).ForEach(catalogItem =>
                {
                    var devCata = DevType.GetCataType(catalogItem.DeviceID);
                    if (devCata == DevCataType.Device)
                    {
                        _SIPTransaction.TransactionRequestFrom.URI.User = catalogItem.DeviceID;
                        string gbname = "GB_" + catalogItem.Name;
                        //string gbname = "gb" + _SIPTransaction.TransactionRequest.RemoteSIPEndPoint.Address.ToString();
                        if (!string.IsNullOrEmpty(catalogItem.ParentID) && !obj.DeviceID.Equals(catalogItem.DeviceID))
                        {
                            gbname = "GB_" + catalogItem.Name;
                        }
                        logger.Debug("OnCatalogReceived.DeviceDmsRegister: catalogItem=" + JsonConvert.SerializeObject(catalogItem));

                        //query device info from db
                        string edit = IsDeviceExisted(catalogItem.DeviceID) ? "updated" : "added";

                        //Device Dms Register
                        DeviceDmsRegister(_SIPTransaction, gbname);

                        //Device Edit Event
                        DeviceEditEvent(catalogItem.DeviceID, edit);
                    }
                });
            }
        }
Exemple #17
0
        /// <summary>
        /// Reads properties of "Catalog" metadata objects
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="conf"></param>
        /// <param name="ct"></param>
        /// <returns></returns>
        private async Task ReadCatalogsAsync(DbConnection connection, BracketsFileNode conf, CancellationToken ct)
        {
            var objectGuids = GetMetadataObjectGuids(conf.GetNode(4, 1, 1, 16));

            foreach (var objectGuid in objectGuids)
            {
                var objectInfo = BracketsFileParser.Parse(await GetStringConfigFileDataAsync(connection, objectGuid, ct));

                var obj = ReadMetadataObject <Catalog>(objectInfo.GetNode(1, 9, 1), objectGuid);

                var objectDetailsNodesCount = (int)objectInfo.GetNode(2);

                for (int i = 3; i < (3 + objectDetailsNodesCount); i++)
                {
                    var objectDetailsNode = objectInfo.GetNode(i);

                    var objectDetailsNodeGuid = (string)objectDetailsNode.GetNode(0);

                    switch (objectDetailsNodeGuid)
                    {
                    case "cf4abea7-37b2-11d4-940f-008048da11f9":
                        obj.Requisities = ReadRequisities(objectDetailsNode);
                        break;

                    case "932159f9-95b2-4e76-a8dd-8849fe5c5ded":
                        obj.TabularSections = ReadTabularSections(objectDetailsNode);
                        break;

                    default:
                        continue;
                    }
                }

                Catalogs.Add(obj);
            }
        }
Exemple #18
0
        private void CatalogsControl_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            switch (e.PropertyName)
            {
            case "Type":
            case "Norm":
            {
                var t = _integrationBase.ApiCore.Catalogs.GetAll($"Type={Type}&Norm={Norm}");

                ItemProperties.Clear();
                CatalogItems.Clear();
                _catalogs.Clear();

                if (t != null && t.Count > 0)
                {
                    foreach (var item in t)
                    {
                        Catalogs.Add(new CatalogGroup
                            {
                                Id          = item.Id,
                                Name        = item.Name,
                                Description = item.Description
                            });
                        if (Type == "CrossSection")
                        {
                            var serviceUrl = $"{_integrationBase.ServerName}/v2/content/crosssectiondefinitions/{item.Id}";
                            try
                            {
                                var cd = BimPlus.LightCaseClient.GenericProxies.RestGet <DtoCrossSectionDefinition>(serviceUrl, _integrationBase.ClientConfiguration);
                                if (cd == null || cd.Shapes?.Count == 0)
                                {
                                    continue;
                                }
                                foreach (var shape in cd.Shapes)
                                {
                                    Catalogs.Add(new CatalogGroup
                                        {
                                            Id          = shape.Id,
                                            Description = shape.Name,
                                            Name        = ""
                                        });
                                }
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(string.Format("Get catalogs: {0}", ex.Message));
                            }
                        }
                    }
                }
                break;
            }

            case "SelectedCatalog":
            {
                var catalog = SelectedCatalog as CatalogGroup;
                if (catalog == null)
                {
                    break;
                }
                var items = _integrationBase.ApiCore.Catalogs.GetAllCatalogItems(catalog.Id);
                ItemProperties.Clear();
                CatalogItems.Clear();
                foreach (var item in items)
                {
                    CatalogItems.Add(new CatalogGroup
                        {
                            Id          = item.Id,
                            Name        = item.Name,
                            Description = item.Description
                        });
                }
                break;
            }

            case "SelectedItem":
            {
                var item = SelectedItem as CatalogGroup;
                if (item == null)
                {
                    break;
                }
                var properties = _integrationBase.ApiCore.Catalogs.GetCatalogItem(item.Id);
                ItemProperties.Clear();
                foreach (var property in properties.Properties)
                {
                    ItemProperties.Add(new CatalogProperty
                        {
                            Id             = property.Key,
                            Name           = ContentAttributes.Find(x => x.Id == property.Key)?.Name ?? property.Key.ToString(),
                            AttributeValue = property.Value
                        });
                }
                break;
            }
            }
            //base.PropertyChanged(sender, e);
        }
Exemple #19
0
        public static void NewCatalog(ref TextBook tb)
        {
            Catalogs catalogs = new Catalogs();
            //以文本方式打开小说
            BufferedStream bs       = new BufferedStream(File.OpenRead(tb.FullName));
            StreamReader   sr       = new StreamReader(bs, Encoding.Default);
            long           position = 0;
            string         buffer;
            Regex          re = new Regex("书名:\\w{1,50}", RegexOptions.IgnorePatternWhitespace);

            while (string.IsNullOrEmpty(tb.BookName))
            {
                buffer = sr.ReadLine();
                tb.Lines++;
                if (!string.IsNullOrEmpty(buffer))
                {
                    position += buffer.Length;
                    Match m = re.Match(buffer);
                    if (m.Success)
                    {
                        tb.BookName = m.Value;
                        break;
                    }
                }
            }

            re = new Regex("作者:\\w{1,50}", RegexOptions.IgnorePatternWhitespace);

            while (string.IsNullOrEmpty(tb.Author))
            {
                buffer = sr.ReadLine();
                tb.Lines++;
                if (!string.IsNullOrEmpty(buffer))
                {
                    position += buffer.Length;
                    Match m = re.Match(buffer);
                    if (m.Success)
                    {
                        tb.Author = m.Value;
                        break;
                    }
                }
            }

            re = new Regex(@"第(一|二|三|四|五|六|七|八|九|十|零|百|千|万|\d){1,50}章.+\s", RegexOptions.IgnorePatternWhitespace);

            CatalogPuple  cp = null;
            StringBuilder sb = new StringBuilder();

            while (!sr.EndOfStream)
            {
                buffer = sr.ReadLine();
                tb.Lines++;
                if (!string.IsNullOrEmpty(buffer))
                {
                    position += buffer.Length;

                    Match m = re.Match(buffer);
                    //判断章节
                    if (m.Success)
                    {
                        position += Environment.NewLine.Length;

                        if (cp != null)
                        {
                            //是章节保存内容
                            cp.Content = sb.ToString();
                            sb.Remove(0, sb.Length);
                        }

                        cp          = new CatalogPuple();
                        cp.Position = position;
                        cp.Name     = m.Value;
                        cp.Begin    = tb.Lines;
                        if (catalogs.Count > 1)
                        {
                            catalogs[catalogs.Count - 1].End = cp.Begin - 1;
                        }
                        catalogs.Add(cp);
                    }
                    else
                    {
                        if (cp != null)
                        {
                            //不是章节则是内容
                            sb.AppendLine(buffer);
                        }
                    }
                }
            }
            sr.Close();
            tb.Catalogs = catalogs;
        }
Exemple #20
0
 public void AddRoot(Catalog catalog)
 {
     Catalogs.Add(new CatalogModel(catalog));
 }