public void CatalogContentsMatch( ) { var catalogs = new CatalogCollection(); var expAny = new DirectoryInfo(catalogs.Root).GetDirectories().Any(); Assert.AreEqual(expAny, catalogs.Directories.Any()); }
protected void BindData() { CatalogCollection ccoll = PE_DAL.GetCatalogInterface(this.PubID); if (ccoll.Count > 0) { Catalog c = ccoll[0]; this.CascadingDropDown1.SelectedValue = this.hidden_listCategory.Value = c.CATEGORY.ToString(); this.CascadingDropDown2.ContextKey = this.hidden_listSubCategory.Value = c.SUBCATEGORY.ToString(); this.CascadingDropDown3.ContextKey = this.hidden_listSubSubCategory.Value = c.SUBSUBCATEGORY.ToString(); if (c.WYNTK > 0) { this.chkboxWYNTK.Checked = System.Convert.ToBoolean(c.WYNTK); if (c.CATALOG_SUBJECT > 0) { this.ListSubject.SelectedIndex = this.ListSubject.Items.IndexOf( this.ListSubject.Items.FindByValue(c.CATALOG_SUBJECT.ToString())); } } if (c.SPANISH_WYNTK > 0) { this.chkboxWYNTKSpanish.Checked = System.Convert.ToBoolean(c.SPANISH_WYNTK); if (c.CATALOG_SUBJECT > 0) { this.ListSubject.SelectedIndex = this.ListSubject.Items.IndexOf( this.ListSubject.Items.FindByValue(c.CATALOG_SUBJECT.ToString())); } } } }
public void ConstructCatalogCollection( ) { var catalogs = new CatalogCollection(); Assert.IsNotNull(catalogs); Assert.IsNotNull(catalogs.Root); }
public void CreateDuplicateCatalog( ) { var catalogs = new CatalogCollection(); var tempCatalog = catalogs.Create("temp"); // throw exception catalogs.Create("temp"); }
public async void InitializeControl( Uri serverUri, Configuration configuration, CatalogCollection catalogs ) { _Configuration = configuration; _Catalogs = catalogs; _RestDataServiceClient = new DataServiceRestClient( serverUri ); _RestRawDataServiceClient = new RawDataServiceRestClient( serverUri ); await FetchAllParts(); }
public void InitializeTest( ) { if (!DataDirectory.Exists) { DataDirectory.Create(); } else { foreach (var d in DataDirectory.GetDirectories()) { d.Delete(true); } } CatalogCollection.Sync(); }
/// <summary> /// Returns the attribute's value of the attribute with the key <paramref name="key"/> If the attribute consists of a catalog entry the entry /// is returned, otherwise the attribute's value (string, int, double or DateTime) is returned. /// </summary> public static object GetRawAttributeValue( this IAttributeItem item, ushort key, Configuration configuration, CatalogCollection catalogs) { var value = item.GetAttribute(key); if (value == null) { return(null); } if (value.RawValue != null) { return(value.RawValue); } return(configuration.ParseValue(key, value.Value, catalogs)); }
public async void InitializeControl( Uri serverUri, Configuration configuration, CatalogCollection catalogs ) { _Configuration = configuration; _Catalogs = catalogs; _RestDataServiceClient = new DataServiceRestClient( serverUri ); _RestRawDataServiceClient = new RawDataServiceRestClient( serverUri ); var partPath = PathHelper.String2PartPathInformation( _PartTextBox.Text ); var parts = await _RestDataServiceClient.GetParts( partPath ); var partsArray = parts as InspectionPlanPart[] ?? parts.ToArray(); if( partsArray.Any() ) _CurrentPart = partsArray.First(); var chars = await _RestDataServiceClient.GetCharacteristics( partPath ); var charsArray = chars as InspectionPlanCharacteristic[] ?? chars.ToArray(); if( charsArray.Any() ) _CurrentCharacteristics = charsArray; FillRawDataListView(); }
public static CatalogCollection GetCatalogs() { var allCatalogs = new CatalogCollection(); var mergedCatalog = new List <Catalog>(); try { // TODO async tasks // companyA List <CatalogSupplier> suppliersA = FileProcessor.InportCsv <CatalogSupplier>("./input/suppliersA.csv"); List <CatalogBarcodes> barcodesA = FileProcessor.InportCsv <CatalogBarcodes>("./input/barcodesA.csv"); List <Catalog> productsA = FileProcessor.InportCsv <Catalog>("./input/catalogA.csv"); productsA.ForEach(p => p.Source = "A"); // companyB List <CatalogSupplier> suppliersB = FileProcessor.InportCsv <CatalogSupplier>("./input/suppliersB.csv"); List <CatalogBarcodes> barcodesB = FileProcessor.InportCsv <CatalogBarcodes>("./input/barcodesB.csv"); List <Catalog> productsB = FileProcessor.InportCsv <Catalog>("./input/catalogB.csv"); productsB.ForEach(p => p.Source = "B"); var duplicateProducts = barcodesB.Where(w => barcodesA.Any(a => a.Barcode == w.Barcode)) .Select(s => s.SKU).Distinct().ToList(); // merge A + B mergedCatalog = new List <Catalog>(productsA); var ignoreDuplicate = productsB.Where(w => !duplicateProducts.Any(a => a == w.SKU)).Select(s => s).ToList(); mergedCatalog.AddRange(ignoreDuplicate); allCatalogs.MergedCatalog = mergedCatalog; allCatalogs.CompanyA = new List <Catalog>(productsA); allCatalogs.CompanyB = new List <Catalog>(productsB); // save output FileProcessor.ExportCsv <Catalog>("./output/result_output.csv", mergedCatalog.AsEnumerable()); } catch (Exception) { throw; } return(allCatalogs); }
public frmMain() { InitializeComponent(); catalogList = new CatalogCollection(); verbatimList = new Dictionary<string,string>(); }
/// <summary> /// Returns the attribute's value of the attribute with the key <paramref name="key"/> If the attribute consists of a catalog entry the entry /// is returned, otherwise the attribute's value (string, int, double or DateTime) is returned. /// </summary> public static object GetRawAttributeValue( this IAttributeItem item, ushort key, Configuration configuration, CatalogCollection catalogs ) { var value = item.GetAttribute( key ); if( value == null ) return null; if( value.RawValue != null ) return value.RawValue; return configuration.ParseValue( key, value.Value, catalogs ); }
public Database() { Catalogs = new CatalogCollection(); }
/// <summary> /// Returns the value represented by <paramref name="attributeValue"/>. <paramref name="attributeValue"/> musst be the language neutral database entry of an attribute. /// I.e. if an attribute represents a catatalogue entry, the catalog entry is returned. If an attribute represents a normal value /// of type string, int, double or DateTime the value is returned with that type. /// </summary> public object ParseValue( ushort key, string attributeValue, CatalogCollection catalogs ) { object result = attributeValue; if( attributeValue != null ) { var def = GetDefinition( key ); var definition = def as CatalogAttributeDefinition; if( definition != null ) { if( catalogs != null ) result = catalogs[definition.Catalog, attributeValue]; } else if( attributeValue.Length > 0 ) { try { var attDef = ( AttributeDefinition )def; switch( attDef.Type ) { case AttributeType.Integer: result = int.Parse( attributeValue, CultureInfo.InvariantCulture ); break; case AttributeType.Float: result = double.Parse( attributeValue, CultureInfo.InvariantCulture ); break; case AttributeType.DateTime: result = XmlConvert.ToDateTime( attributeValue, XmlDateTimeSerializationMode.RoundtripKind ); break; } } catch { // ignored } } } return result ?? attributeValue; }
/// <summary> /// Returns a formatted value for the attribute <paramref name="value"/>. If the value is a catalog entry, the catalog value will /// be returned. This method uses the <paramref name="provider"/> for formatting the value. If the <paramref name="provider"/> /// is not specified, the <see cref="CultureInfo.CurrentUICulture"/> is used to format the resulting value. /// </summary> public string GetFormattedValue( ushort key, string value, CatalogCollection catalogs, IFormatProvider provider = null ) { if( value == null ) return null; var def = GetDefinition( key ); if( def is CatalogAttributeDefinition ) { if( catalogs != null ) { var entry = catalogs[ ( (CatalogAttributeDefinition)def ).Catalog, value ]; if( entry != null ) return entry.ToString( CultureInfo.InvariantCulture ); } } else if( value.Length > 0 ) { try { var attDef = (AttributeDefinition)def; switch( attDef.Type ) { case AttributeType.Integer: return int.Parse( value, CultureInfo.InvariantCulture ).ToString( provider ?? CultureInfo.CurrentUICulture ); case AttributeType.Float: return double.Parse( value, CultureInfo.InvariantCulture ).ToString( provider ?? CultureInfo.CurrentUICulture ); case AttributeType.DateTime: return XmlConvert.ToDateTime( value, XmlDateTimeSerializationMode.RoundtripKind ).ToString( provider ?? CultureInfo.CurrentUICulture ); } } catch { // ignored } } return value; }
/// <summary> /// This method fetches the list of catalogs from the data service. Attributes can point to a catalog entry (as described by the /// configuration) using the index of the catalog entry. This is the list of all catalogs including their entries. Please keep in /// mind that it might be possible that an attribute value points to a non existing catalog entry. /// </summary> private async Task FetchCatalogs() { try { LogMessage( "Fetching catalogs from data service." ); var sw = System.Diagnostics.Stopwatch.StartNew(); var catalogs = await _RestDataServiceClient.GetCatalogs(); _Catalogs = new CatalogCollection( catalogs ); sw.Stop(); LogMessage( "Successfully fetched {1} catalogs from data service in {0} ms: '{2}'.\r\n", sw.ElapsedMilliseconds, _Catalogs.Count, string.Join( ", ", _Catalogs.Select( c => c.Name ) ) ); } catch( Exception ex ) { LogMessage( "Error fetching catalogs from data service: '{0}'.\r\n", ex.Message ); } }