public void GetAppliedCarsTest() { int artID = 638819; int badArtID = -1; using( TecdocBaseDataContext ctx = new TecdocBaseDataContext() ) { ctx.Log = new DebuggerWriter(); try { var res = ctx.GetAppliedCars( artID ); Assert.IsTrue( res.Count() > 0, "Вернулся пустой документ для возможного артикула" ); res = ctx.GetAppliedCars( badArtID ); Assert.IsTrue(res.Count() == 0, "Вернулся непустой документ для невозможного артикула"); } catch( Exception e ) { if( e is AssertFailedException ) { throw; } else { Assert.Fail( String.Format( "Не могу загрузить список машин для ЗЧ с артикулом {0}", 638819 ) ); } } } }
public void GetImagesTest() { int artID = 638819; int badArtID = -1; using( var ctx = new TecdocBaseDataContext() ) { ctx.Log = new DebuggerWriter(); var val1 = ctx.GetImages( artID ); var val2 = ctx.GetImages( badArtID ); Assert.IsTrue( val2.Count == 0 ); } }
public static CarType GetModification( int modificationId, bool showAll, IEnumerable<int> countriesIds ) { using( var ctx = new TecdocBaseDataContext() ) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<CarType>( m => m.Name ); dlo.LoadWith<CarType>( m => m.Model ); dlo.LoadWith<Model>( m => m.Name ); dlo.LoadWith<Model>( m => m.Manufacturer ); ctx.LoadOptions = dlo; return ctx.GetModification( modificationId, showAll, countriesIds ); } }
RmsAuto.TechDoc.Entities.TecdocBase.Manufacturer GetManufacturer( string mfrBrand, bool withModels ) { using( var ctx = new TecdocBaseDataContext() ) { if( withModels ) { var dlo = new DataLoadOptions(); dlo.LoadWith<RmsAuto.TechDoc.Entities.TecdocBase.Manufacturer>( m => m.Models ); ctx.LoadOptions = dlo; } var toRet = ctx.Manufacturers.Where( m => m.Name == ( mfrBrand == null ? this.MfrBrand : mfrBrand ) ).FirstOrDefault(); Assert.IsNotNull( toRet ); return toRet; } }
public void PartTypeTreeTest() { int typ_id = 15270; // 525 i (192 HP) Modification //int mod_id = 1449; // BMW 5 (E39) Model int st_item_id = 10001; // Номер айтема в дереве поиска using( TecdocBaseDataContext ctx = new TecdocBaseDataContext() ) { ctx.Log = new DebuggerWriter(); var tree = ctx.GetTree( typ_id ); var itemName = ctx.GetTreeItem( typ_id, st_item_id ); } }
public void ListModificationsTest() { using( var ctx = new TecdocBaseDataContext() ) { var mfr = GetManufacturer( null, true ); var models = mfr.Models.ToList(); if( mfr.Models.Count > 0 ) { var arr1 = ctx.ListModifications(models[0].ID, true, new int[] { 185, 246 }); var arr2 = ctx.ListModifications(models[0].ID, false, new int[] { 185, 246 }); Assert.IsTrue( arr2.Count <= arr1.Count ); } } }
public void ListMfrsTest() { using( var ctx = new TecdocBaseDataContext() ) { var mfrs = ctx.ListManufacturers( true, new int[] { 185, 246 } ); Assert.IsNotNull( mfrs ); } }
public void GetPartInfoTest() { int artID = 638819; int badArtID = -1; using( var ctx = new TecdocBaseDataContext() ) { ctx.Log = new DebuggerWriter(); var val1 = ctx.GetPartInfo( artID ); try { var val2 = ctx.GetPartInfo( badArtID ); } catch( ArgumentException ) { } } }
/// <summary> /// Загружает доп инфу по спарпартам. Перенесен из фасада текдока, все равно используется только в поиске в связке со типом SparePart. /// </summary> /// <param name="keys">Инумерабл спарпартов</param> /// <returns>Словарь доп инфы по парткеям</returns> public static Dictionary<PartKey, AdditionalInfo> GetAdditionalInfo( IEnumerable<PartKey> keys ) { //var brands = keys.Select( k => k.Manufacturer ).Distinct(); var list = new List<AdditionalInfo>(); return list.GroupBy(ai => ai.Key).ToDictionary(g => g.Key, g => g.First()); var partNumbers = keys.Select( k => k.PartNumber ).Distinct().ToArray(); using( var ctx = new TecdocBaseDataContext() ) { for( var i = 0 ; i < partNumbers.Length ; i += 2000 ) { /*var res = ctx.ArticleLookups .Where( la => partNumbers.Skip( i ).Take( Math.Min( 2000, partNumbers.Length - i ) ).Contains( la.SearchNumber ) && la.ARL_KIND == '1' ) .GroupBy( la => new { Brand = la.Article.Supplier.Name, PartNumber = la.Article.ArticleNumber, TecDocArticulId = la.Article.ID } ).Select( result => new AdditionalInfo() { Key = new PartKey( result.Key.Brand, result.Key.PartNumber ), //may be SearchNumber ??? TecDocArticulId = result.Key.TecDocArticulId, PartDescription = result.First().Article.CompleteName.Text, HasPics = ( from gra in ctx.GraphicsToArticleLinks join gr in ctx.Graphics on gra.LGA_GRA_ID equals gr.ID where gra.LGA_ART_ID == result.Key.TecDocArticulId && gr.GRA_GRD_ID != null select gra.LGA_ART_ID ).Any(), HasAppliedCars = ( from la_1 in ctx.ArticleLinks join lat_1 in ctx.ArticleLinkToCarTypeLinks on la_1.ID equals lat_1.ArticleLinkID where la_1.LA_ART_ID == result.Key.TecDocArticulId select lat_1.CarTypeID ).Any(), HasDescription = ( from ac in ctx.ArticleCriterionLinks where ac.ACR_ART_ID == result.Key.TecDocArticulId select ac.ACR_CRI_ID ).Any() } );*/ var res = ctx.ArticleLookups .Where( la => partNumbers.Skip( i ).Take( Math.Min( 2000, partNumbers.Length - i ) ).Contains( la.SearchNumber ) && la.ARL_KIND == '1' ) .Select( la => new AdditionalInfo() { Key = new PartKey( la.Article.Supplier.Name, la.Article.ArticleNumber ), TecDocArticulId = la.Article.ID, PartDescription = la.Article.CompleteName.Tex_Text, HasPics = ( from gra in ctx.GraphicsToArticleLinks join gr in ctx.Graphics on gra.LGA_GRA_ID equals gr.ID where gra.LGA_ART_ID == la.Article.ID && gr.GRA_GRD_ID != null select gra.LGA_ART_ID ).Any(), HasAppliedCars = ( from la_1 in ctx.ArticleLinks join lat_1 in ctx.ArticleLinkToCarTypeLinks on la_1.ID equals lat_1.ArticleLinkID where la_1.LA_ART_ID == la.Article.ID select lat_1.CarTypeID ).Any(), HasDescription = ( from ac in ctx.ArticleCriterionLinks where ac.ACR_ART_ID == la.Article.ID select ac.ACR_CRI_ID ).Any() } ); list.AddRange( res ); } return list.GroupBy( ai => ai.Key ).ToDictionary( g => g.Key, g => g.First() ); } }
/// <summary> /// Получить полный список марок автомобилей /// </summary> /// <returns></returns> public static List<Manufacturer> ListManufacturers() { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { return ctx.ListManufacturers(); } }
public static SearchTreeNodeHelper GetTreeItem( int modificationId, int searchTreeNodeId ) { using( var ctx = new TecdocBaseDataContext() ) { return ctx.GetTreeItem( modificationId, searchTreeNodeId ); } }
public static List<SearchTreeNodeHelper> GetTree( int modificationId ) { using( var ctx = new TecdocBaseDataContext() ) { return ctx.GetTree( modificationId ); } }
public static List<Supplier> GetSuppliers() { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { return ctx.GetSuppliers(); } }
public static PartInfo GetPartInfo( int artId ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { var dlo = new DataLoadOptions(); dlo.LoadWith<Article>( a => a.Supplier ); dlo.LoadWith<Article>( a => a.CompleteName ); ctx.LoadOptions = dlo; return ctx.GetPartInfo( artId ); } }
public static IEnumerable<KeyValuePair<string, string>> GetPartAddInfo( int artId ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { return ctx.GetPartAddInfo( artId ); } }
public static int LookupModificationId( int modelId, string mName ) { using( var ctx = new TecdocBaseDataContext() ) { return ctx.LookupModificationId( modelId, mName ); } }
public static IEnumerable<CarType> GetAppliedCars( int artId ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { var dlo = new DataLoadOptions(); dlo.LoadWith<CarType>( m => m.Name ); dlo.LoadWith<CarType>( m => m.BodyName ); dlo.LoadWith<CarType>( m => m.FuelSupplyName ); dlo.LoadWith<CarType>( m => m.Model ); dlo.LoadWith<Model>( m => m.Name ); dlo.LoadWith<Model>( m => m.Manufacturer ); ctx.LoadOptions = dlo; return ctx.GetAppliedCars( artId ); } }
/// <summary> /// Получить список марок автомобилей, отфильтрованный по стране и /// опционально отфильтрованный по маркам /// </summary> /// <param name="showAll"></param> /// <returns></returns> public static List<Manufacturer> ListManufacturers( bool showAll, IEnumerable<int> countriesIds ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Manufacturer>( m => m.Brand ); ctx.LoadOptions = dlo; return ctx.ListManufacturers( showAll, countriesIds ); } }
public void ListCountriesTest() { using( var ctx = new TecdocBaseDataContext() ) { var cs = ctx.ListCountries(); Assert.IsNotNull( cs ); Assert.IsTrue( cs.Count > 0 ); } }
public static List<Model> ListModels( int manufacturerID ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { var dlo = new DataLoadOptions(); dlo.LoadWith<Model>( m => m.Name ); ctx.LoadOptions = dlo; return ctx.ListModels( manufacturerID ); } }
public void ListModelsTest() { using( var ctx = new TecdocBaseDataContext() ) { var mfr = GetManufacturer( null ); var arr1 = ctx.ListModels(mfr.ID, true, true, new int[] { 185, 246 }); var arr2 = ctx.ListModels(mfr.ID, true, false, new int[] { 185, 246 }); Assert.IsTrue( arr1.Count >= arr2.Count ); var curModels = ctx.ListModels( mfr.ID ); } }
public static List<Model> ListModels( int manufacturerId, bool isCarModel, bool showAll, IEnumerable<int> countriesIds ) { using( var ctx = new TecdocBaseDataContext() ) { ctx.DeferredLoadingEnabled = false; DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Model>( m => m.Name ); ctx.LoadOptions = dlo; return ctx.ListModels( manufacturerId, isCarModel, showAll, countriesIds ); } }
public void ListPartsTest() { int typID = 15270; // 525 i (192 HP) Modification int catID = 10142; // Аккум int badTypID = -1; int badCatID = -1; using( TecdocBaseDataContext ctx = new TecdocBaseDataContext() ) { XmlDocument doc = new XmlDocument(); try { var arr1 = ctx.ListParts( typID, catID ); Assert.IsTrue( arr1.Count > 0, "Вернулся пустой документ для возможных параметров" ); var arr2 = ctx.ListParts( badTypID, badCatID ); Assert.IsTrue( arr2.Count == 0, "Вернулся непустой документ для невозможных параметров" ); } catch( Exception e ) { if( e is AssertFailedException ) { throw; } else { Assert.Fail( String.Format( "Не могу загрузить список ЗЧ для {0}/{1}", typID, catID ) ); } } } }
public static List<CarType> ListModifications( int modelID ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { var dlo = new DataLoadOptions(); dlo.LoadWith<CarType>( m => m.Name ); dlo.LoadWith<CarType>( m => m.FullName ); //dlo.LoadWith<CarType>(m => m.Model); //dlo.LoadWith<Model>(m => m.Name); ctx.LoadOptions = dlo; return ctx.ListModelModifications( modelID ); } }
RmsAuto.TechDoc.Entities.TecdocBase.Manufacturer GetManufacturer( string mfrBrand ) { using( var ctx = new TecdocBaseDataContext() ) { var toRet = ctx.Manufacturers.Where( m => m.Name == ( mfrBrand == null ? this.MfrBrand : mfrBrand ) ).FirstOrDefault(); Assert.IsNotNull( toRet ); return toRet; } }
public static List<CarType> ListModifications( int modelId, bool showAll, IEnumerable<int> countriesIds ) { using( var ctx = new TecdocBaseDataContext() ) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<CarType>( m => m.Name ); dlo.LoadWith<CarType>( m => m.EngineName ); dlo.LoadWith<CarType>( m => m.FuelSupplyName ); ctx.LoadOptions = dlo; return ctx.ListModifications( modelId, showAll, countriesIds ); } }
public static List<PartsListItem> ListParts( int modificationId, int searchTreeNodeId ) { using( var ctx = new TecdocBaseDataContext() ) { var dlo = new DataLoadOptions(); dlo.LoadWith<Article>( a => a.ArticleNumber); dlo.LoadWith<Article>(a => a.Name); dlo.LoadWith<Article>(a => a.CompleteName); dlo.LoadWith<Article>(a => a.Supplier); ctx.LoadOptions = dlo; return ctx.ListParts( modificationId, searchTreeNodeId ).ToList(); } }
public static int LookupModelId( int manufacturerId, string mName ) { using( var ctx = new TecdocBaseDataContext() ) { return ctx.LookupModelId( manufacturerId, mName ); } }
public void GetPartAddInfoTest() { int artID = 638819; int badArtID = -1; using( var ctx = new TecdocBaseDataContext() ) { ctx.Log = new DebuggerWriter(); XmlDocument xml1 = new XmlDocument(); XmlDocument xml2 = new XmlDocument(); var val1 = ctx.GetPartAddInfo( artID ); var val2 = ctx.GetPartAddInfo( badArtID ); Assert.IsTrue( val1.Count() >= val2.Count() ); Assert.IsTrue( val2.Count() == 0); } }
public static Model GetModelById( int modelId, bool showAll, IEnumerable<int> countriesIds ) { using( var ctx = new RmsAuto.TechDoc.Entities.TecdocBase.TecdocBaseDataContext() ) { DataLoadOptions dlo = new DataLoadOptions(); dlo.LoadWith<Model>( m => m.Manufacturer ); dlo.LoadWith<Model>( m => m.Name ); ctx.LoadOptions = dlo; return ctx.GetModel( modelId, showAll, countriesIds ); } }