public void ReadFileTestMethod1() { Assert.IsTrue(File.Exists(_fileName)); catalog _testingData = XmlFile.ReadXmlFile <catalog>(_fileName); Assert.IsTrue(File.Exists(_fileName)); Assert.IsTrue(TestingData.TestTestingData(_testingData)); }
public CatalogModel(catalog entity, bool encodeHtml = false) { if (entity != null) { Mapper.CreateMap <catalog, CatalogModel>(); Mapper.Map(entity, this); } }
private string ValidateModel(catalog model) { if (string.IsNullOrEmpty(model.name)) { return(string.Format(Constant.MsgRequired, "Tên nhóm sản phẩm")); } return(string.Empty); }
public void Xml2StringTestMethod() { catalog _catalog = CreateTestData(); string _catalogString = XmlSerialization.Serialize <catalog>(_catalog, _catalog.StylesheetName); catalog _newCatalog = XmlSerialization.Deserialize <catalog>(_catalogString); string _newCatalogString = XmlSerialization.Serialize <catalog>(_newCatalog, _catalog.StylesheetName); Assert.AreEqual <string>(_catalogString, _newCatalogString); }
//public catalog GetCatalog(catalog model) //{ // throw new NotImplementedException(); //} public catalog GetCatalog(catalog model) { var a = (from u in _db.catalogs where (model.id == 0 || u.id == model.id) && (string.IsNullOrEmpty(model.name) || u.name.Contains(model.name)) select u).FirstOrDefault(); return(a); }
private List <catalogBook> getDataHelper(string low, string high, bool lesserThan, bool GreaterThan) { List <catalogBook> bookList = new List <catalogBook>(); int.TryParse(low, out int lowNum); int.TryParse(high, out int highNum); using (FileStream fs = new FileStream("Books.xml", FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(catalog)); catalog books = (catalog)xs.Deserialize(fs); if (lesserThan == true && GreaterThan == true) { foreach (catalogBook book in books.book) { if (book.price >= lowNum && book.price <= highNum) { bookList.Add(book); } } } else if (lesserThan == true && GreaterThan == false) { foreach (catalogBook book in books.book) { if (book.price <= highNum) { bookList.Add(book); } } } else if (lesserThan == false && GreaterThan == true) { foreach (catalogBook book in books.book) { if (book.price >= lowNum) { bookList.Add(book); } } } else { foreach (catalogBook book in books.book) { if (book.price == lowNum || book.price == highNum) { bookList.Add(book); } } } } return(bookList); }
public void WriteXmlFileTestMethod1() { Assert.IsTrue(File.Exists(_fileName)); File.Delete(_fileName); catalog _testingData = TestingData.CreateTestingData(); Assert.IsNotNull(_testingData); XmlFile.WriteXmlFile <catalog>(_testingData, _fileName, FileMode.OpenOrCreate); Assert.IsTrue(File.Exists(_fileName)); }
private List <catalogBook> getDataHelper(string property, string propertyType) { List <catalogBook> bookList = new List <catalogBook>(); using (FileStream fs = new FileStream("Books.xml", FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(catalog)); catalog books = (catalog)xs.Deserialize(fs); switch (propertyType) { case "author": foreach (catalogBook book in books.book) { if (book.author.ToLower().Contains(property)) { bookList.Add(book); } } break; case "title": foreach (catalogBook book in books.book) { if (book.title.ToLower().Contains(property)) { bookList.Add(book); } } break; case "genre": foreach (catalogBook book in books.book) { if (book.genre.ToLower().Contains(property)) { bookList.Add(book); } } break; case "description": foreach (catalogBook book in books.book) { if (book.description.ToLower().Contains(property)) { bookList.Add(book); } } break; } } return(bookList); }
public List <catalog> GetLst(catalog model, int?page, int numberRecord, out int totalRecord) { var a = (from u in _db.catalogs where (model.id == 0 || u.id == model.id) && (string.IsNullOrEmpty(model.name) || u.name.Contains(model.name)) && u.del_flg == false select u); totalRecord = a.Count(); return(a.ToList().Skip((page.GetValueOrDefault() - 1) * numberRecord).Take(numberRecord).ToList()); }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { catalog ds = new catalog(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private List <catalogBook> getDataHelper(DateTime low, DateTime high, bool lesserThan, bool GreaterThan) { List <catalogBook> bookList = new List <catalogBook>(); using (FileStream fs = new FileStream("Books.xml", FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(catalog)); catalog books = (catalog)xs.Deserialize(fs); if (lesserThan == true && GreaterThan == true) { foreach (catalogBook book in books.book) { if (book.publish_date >= low && book.publish_date <= high) { bookList.Add(book); } } } else if (lesserThan == true && GreaterThan == false) { foreach (catalogBook book in books.book) { if (book.publish_date <= high) { bookList.Add(book); } } } else if (lesserThan == false && GreaterThan == true) { foreach (catalogBook book in books.book) { if (book.publish_date >= low) { bookList.Add(book); } } } else { foreach (catalogBook book in books.book) { if (book.publish_date == low || book.publish_date == high) { bookList.Add(book); } } } } return(bookList); }
public bool Add(catalog model) { try { _db.catalogs.Add(model); _db.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public void ConnectingToNonExsistingDB() { using (DataClasses1DataContext fake = new DataClasses1DataContext("Data Source = DESKTOP-2JETCTM; Initial Catalog = upssNothingHere; Integrated Security = True")) { catalog catalog = new catalog(); catalog.catalog_id = 2; catalog.catalog_name = "a nice flower"; catalog.catalog_genus = "with nice genus"; catalog.catalog_price = 80; catalog.catalog_quantity = 0; fake.catalogs.InsertOnSubmit(catalog); fake.SubmitChanges(); } }
public void Xml2FileTestMethod() { string _fileName = "TestFile.xml"; catalog _catalog = CreateTestData(); using (System.IO.FileStream _stream = new System.IO.FileStream(_fileName, System.IO.FileMode.Create)) XmlSerialization.WriteXmlFile <catalog>(_catalog, _stream, _catalog.StylesheetName); catalog _newCatalog; using (System.IO.FileStream _stream = new System.IO.FileStream(_fileName, System.IO.FileMode.Open)) _newCatalog = XmlSerialization.ReadXmlFile <catalog>(_stream); string _catalogString = XmlSerialization.Serialize <catalog>(_catalog, _catalog.StylesheetName); string _newCatalogString = XmlSerialization.Serialize <catalog>(_newCatalog, _catalog.StylesheetName); Assert.AreEqual <string>(_catalogString, _newCatalogString); }
public ConsoleInterface() { looping = true; menuState = "begin"; subMenuState = ""; queryData = new QueryData(); using (FileStream fs = new FileStream(@"Books.xml", FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(catalog)); catalog books = (catalog)xs.Deserialize(fs); authors = books.book.Select(b => b.author).Distinct().ToList(); titles = books.book.Select(b => b.title).Distinct().ToList(); genres = books.book.Select(b => b.genre).Distinct().ToList(); } }
}//end function static async Task<int> preform_operations(string[] arguments) { catalog cc=new catalog(); options options=args.process(arguments); bool debug=false; //Auto-config if(options.type=="auto-config" && !String.IsNullOrWhiteSpace(options.data_dir)){ tapeworm_core.auto_config a=new tapeworm_core.auto_config(options.data_dir,options.config_dir,options.delimiters); return 0; } string app_settings=String.Empty; app_settings="appsettings.json"; var builder = new ConfigurationBuilder(); IConfiguration configuration = builder.Build(); string config_dir=configuration.GetSection("AppConfiguration")["config"]; if(options.verbosity>0) debug=true; catalog c=new catalog(config_dir,options.build,debug); if(options.error>0) { Console.WriteLine("Exiting due to errors"); return 1; } if(options.help) { //nothing addidional is processed if the help scrren is shown return 0; } //do the thing. logic belongs in the main dll string output=(string)await c.perform_operation(options); Console.WriteLine(output); return 0; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); catalog ds = new catalog(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "bookDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
new LroAdaptationGenerator(catalog, ctx, fileDesc).Generate();
new ResourceNamesGenerator(catalog, ctx, fileDesc).Generate();
public List <catalogBook> getDataLINQ(string author, string title, string genre, string priceLow, string priceHigh, bool priceLesserThan, bool priceGreaterThan, DateTime publish_dateLow, DateTime publish_dateHigh, bool publish_dateLesserThan, bool publish_dateGreaterThan, string description) { List <catalogBook> list = new List <catalogBook>(); using (FileStream fs = new FileStream("Books.xml", FileMode.Open)) { XmlSerializer xs = new XmlSerializer(typeof(catalog)); catalog books = (catalog)xs.Deserialize(fs); author = author.ToLower(); title = title.ToLower(); genre = genre.ToLower(); description = description.ToLower(); var query = (from b in books.book select b); if (!String.IsNullOrEmpty(author)) { query = query.Where(book => book.author.ToLower().Contains(author)); } if (!String.IsNullOrEmpty(title)) { query = query.Where(book => book.title.ToLower().Contains(title)); } if (!String.IsNullOrEmpty(genre)) { query = query.Where(book => book.genre.ToLower().Contains(genre)); } if (!(String.IsNullOrEmpty(priceLow) && String.IsNullOrEmpty(priceHigh))) { int.TryParse(priceLow, out int lowNum); int.TryParse(priceHigh, out int highNum); if (priceLesserThan == true && priceGreaterThan == true) { query = query.Where(book => book.price >= lowNum && book.price <= highNum); } else if (priceLesserThan == true && priceGreaterThan == false) { query = query.Where(book => book.price <= highNum); } else if (priceLesserThan == false && priceGreaterThan == true) { query = query.Where(book => book.price >= lowNum); } else { query = query.Where(book => book.price == lowNum || book.price == highNum); } } if (!(publish_dateLow == DateTime.MinValue) && !(publish_dateHigh == DateTime.MinValue)) { if (publish_dateLesserThan == true && publish_dateGreaterThan == true) { query = query.Where(book => book.publish_date >= publish_dateLow && book.publish_date <= publish_dateHigh); } else if (publish_dateLesserThan == true && publish_dateGreaterThan == false) { query = query.Where(book => book.publish_date <= publish_dateHigh); } else if (publish_dateLesserThan == false && publish_dateGreaterThan == true) { query = query.Where(book => book.publish_date >= publish_dateLow); } else { query = query.Where(book => book.publish_date == publish_dateLow || book.publish_date == publish_dateHigh); } } if (!String.IsNullOrEmpty(description)) { query = query.Where(book => book.description.ToLower().Contains(description)); } list = query.Select(book => new catalogBook { author = book.author, title = book.title, genre = book.genre, price = book.price, publish_date = book.publish_date, description = book.description }).ToList(); } return(list); }