public void GetTask(string fileName) { var validateFileName = new VerifierFileAndStatus(fileName); fileName = validateFileName.VerifyFileName(); var xml = new XMLRepository(fileName); // xml.GetTasks(); }
public XMLStorage(string connectionString) { CheckFolder(connectionString); CategoryRepository = new XMLRepository<CategoryEntity>(connectionString + CategoriesFileName); FinanceItemRepository = new XMLRepository<FinanceItemEntity>(connectionString + FinanceItemFileName); MilestoneRepository = new XMLRepository<MilestoneEntity>(connectionString + MilestonesFileName); }
public void Get_Element_Success_Response() { var result = new XMLRepository(); var output = result.GetElements(Constant.FilePath); Assert.IsNotEmpty(output.Result.OutputObject); }
public void UpdateDate(string id, string date, string fileName) { var validateFileAndStatus = new VerifierFileAndStatus(fileName); fileName = validateFileAndStatus.VerifyFileName(); var validateDateAndDuDate = new VerifierDateAndDueDate(date); var tempdate = validateDateAndDuDate.VerifyTempDate(); var xml = new XMLRepository(fileName); // xml.UpdateDate(id, tempdate); }
static void Main(string[] args) { ILogger logger = new Logger(); IDownloader downloader = new Downloader(logger); IRepository <FeatureCollection> repository = new XMLRepository <FeatureCollection>(logger); var data = downloader.DownloadInfo("https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&limit=20"); var deserializedData = JsonConvert.DeserializeObject <FeatureCollection>(data); repository.Add(deserializedData); }
public void ResetParts() { var defaultRepo = new XMLRepository <Part>(Properties.Resources.DefaultsPartsDataFile); Clear(); using (var t = StartTransaction()) { AddRange(defaultRepo.GetAll()); t.Commit(); } }
public void TestWords() { // Delete the file if it exists if (File.Exists(filename)) { File.Delete(filename); } // Create a language XMLRepository xmlRepository = new XMLRepository(filename); Language language = new Language() { Code = "EN", Name = "English" }; xmlRepository.CreateLanguage(language); xmlRepository.SetSourceLanguage("EN"); Assert.AreEqual(0, xmlRepository.ListWords().Count()); // Add some words xmlRepository.CreateWord(new Word() { Name = "repository", status = 1, Translation = "skladiste" }); xmlRepository.CreateWord(new Word() { Name = "create", status = 1, Translation = "stvorite" }); xmlRepository.CreateWord(new Word() { Name = "vomit", status = 2, Translation = "povracati" }); xmlRepository.CreateWord(new Word() { Name = "pissed off", status = 2, Translation = "iznerviran" }); xmlRepository.CreateWord(new Word() { Name = "urge", status = 3, Translation = "goniti, nagon" }); Assert.AreEqual(5, xmlRepository.ListWords().Count()); // Update some of the words xmlRepository.UpdateWord(new Word() { Name = "pissed off", status = 3, Translation = "iznervirati" }); Assert.AreEqual(5, xmlRepository.ListWords().Count()); // Delete few words xmlRepository.DeleteWord("create"); xmlRepository.DeleteWord("urge"); Assert.AreEqual(3, xmlRepository.ListWords().Count()); }
/// <summary> /// Constructor /// </summary> /// <param name="service"></param> /// <param name="repository"></param> /// <param name="testList"></param> /// <param name="filtersModelFilters"></param> public GetTestListCommand(IImageManager imageManager, BindableCollection <SingleTest> testList, XMLRepository xmlRepository) { _testList = testList; _xmlRepository = xmlRepository; Command = new RelayCommand(x => DoGetTestList(x)); DisplayInfo = new DisplayInfo { Description = Resources.ReloadTestList, Image16 = imageManager.GetImage16Path("Restore") }; }
public void ShouldAddANewProduct() { var xmlString = "<ArrayOfProduct></ArrayOfProduct>"; var repository = new XMLRepository<Product,int>(xmlString, "ArrayOfProduct"); repository.Add(new Product { Category = "Food", Name = "Bread", Price = 10, Stock = 4 }); }
static async System.Threading.Tasks.Task Main() { IXMLRepository xmlRepo = new XMLRepository(); IEmployeeOperation employee = new EmployeeOperation(xmlRepo); EmployeDecorator employDeco = new EmployeDecorator(employee); ConsoleKeyInfo cki; Console.WriteLine("Console XML Operation Assignment 2 \r"); Console.WriteLine("------------------------\n"); do { cki = Console.ReadKey(false); Console.WriteLine("Choose an option from the following list:"); Console.WriteLine("\t1 - Add to XML"); Console.WriteLine("\t2 - Print XML"); Console.WriteLine("\t3 - Delete XML Record"); Console.WriteLine("\t4 - Add New Node"); Console.Write("Your option? "); switch (Console.ReadLine()) { case "1": await AddEmployee(employDeco); break; case "2": await GetEmployee(employDeco); break; case "3": await DeleteEmployee(employDeco); break; case "4": await AddNode(); break; } } while (cki.Key != ConsoleKey.Escape); Console.Write("Press any key to close the XML console app..."); Console.ReadKey(); }
public void ShouldGetAllProduct() { var xmlString = "<ArrayOfProduct></ArrayOfProduct>"; var repository = new XMLRepository<Product, int>(xmlString, "ArrayOfProduct"); repository.Add(new Product { Category = "Food", Name = "Bread", Price = 10, Stock = 4 }); var actualResult = repository.GetAll(); Assert.AreEqual(3, actualResult.Count()); }
public void TestLanguages() { // Delete the file if it exists if (File.Exists(filename)) { File.Delete(filename); } // Create a file and check there are no languages XMLRepository xmlRepository = new XMLRepository(filename); Assert.AreEqual(0, xmlRepository.ListLanguages().Count()); // Add English and Serbian and make sure there are 2 languages xmlRepository.CreateLanguage(new Language() { Code = "EN", Name = "English", Alphabet = "abcdefghijklmnopqrstuvwxyz" }); xmlRepository.CreateLanguage(new Language() { Code = "SR", Name = "Srpski" }); Assert.AreEqual(2, xmlRepository.ListLanguages().Count()); // Check English is there Language English = xmlRepository.RetreiveLanguage("EN"); Assert.AreEqual("EN", English.Code); Assert.AreEqual("English", English.Name); Assert.AreEqual("abcdefghijklmnopqrstuvwxyz", English.Alphabet); // Change English English.Name = "easy english"; English.Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; xmlRepository.UpdateLanguage(English); // Check that English is updated Assert.AreEqual("EN", English.Code); Assert.AreEqual("easy english", English.Name); Assert.AreEqual("ABCDEFGHIJKLMNOPQRSTUVWXYZ", English.Alphabet); // Delete English and then Serbian xmlRepository.DeleteLanguage("EN"); Assert.AreEqual(1, xmlRepository.ListLanguages().Count()); xmlRepository.DeleteLanguage("SR"); Assert.AreEqual(0, xmlRepository.ListLanguages().Count()); }
public void Reset() { var defaultRepo = new XMLRepository <AssemblyOptions>(Properties.Resources.DefaultOptionsDataFile); Clear(); using (var t = StartTransaction()) { if (!defaultRepo.GetAll().Any()) { Add(new AssemblyOptions()); } else { AddRange(defaultRepo.GetAll()); } t.Commit(); } }
static void Main(string[] args) { ILogger logger = new FileLogger(); IDownloader downloader = new Downloader(logger); IRepository <FeatureCollection> repository = new XMLRepository <FeatureCollection>(logger); var data = downloader.Download("https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&limit=50"); if (!string.IsNullOrEmpty(data)) { var deserializedData = JsonConvert.DeserializeObject <FeatureCollection>(data); repository.Add(deserializedData); } else { System.Console.WriteLine("Произошла ошибка, обратитесь к системному администратору"); System.Console.ReadLine(); } }
public List <XmlModel> ProcessXml(int xmlId) { XMLRepository xr = new XMLRepository(new POCEntities()); XmlDocument doc = new XmlDocument(); var a = xr.GetXmlFileById(xmlId); doc.LoadXml(a.XmlFile); var xml = XElement.Parse(a.XmlFile); var elementsAndIndex = xml .DescendantsAndSelf() .Select((node, index) => new { index = index + 1, node }) .ToList(); List <XmlModel> elementsWithIndexAndParentIndex = elementsAndIndex .Select( elementAndIndex => new { Element = elementAndIndex.node, Index = elementAndIndex.index, ParentElement = elementsAndIndex.SingleOrDefault(parent => parent.node == elementAndIndex.node.Parent) }) .Select( elementAndIndexAndParent => new XmlModel { NodeName = elementAndIndexAndParent.Element.Name.LocalName, NodeId = elementAndIndexAndParent.Index, ParentId = elementAndIndexAndParent.ParentElement == null ? 0 : elementAndIndexAndParent.ParentElement.index, NodeValue = elementAndIndexAndParent.Element.HasElements == true? null : elementAndIndexAndParent.Element.Value, }) .ToList(); return(elementsWithIndexAndParentIndex); }
public XMLService(string filePath, Catalog catalog) { XmlQualifiedName catalogName = new XmlQualifiedName("ctl", "http://LibraryStorage.Catalog/1.0.0.0"); XmlQualifiedName bookName = new XmlQualifiedName("bk", "http://LibraryStorage.Book/1.0.0.0"); XmlQualifiedName paperName = new XmlQualifiedName("npr", "http://LibraryStorage.Newspaper/1.0.0.0"); XmlQualifiedName patentName = new XmlQualifiedName("ptn", "http://LibraryStorage.Patent/1.0.0.0"); namepsaces = new Dictionary <Type, XmlSerializerNamespaces> { { typeof(Catalog), new XmlSerializerNamespaces(new[] { catalogName, bookName, paperName, patentName }) }, { typeof(Book), new XmlSerializerNamespaces(new[] { bookName }) }, { typeof(Patent), new XmlSerializerNamespaces(new[] { patentName }) }, { typeof(Newspaper), new XmlSerializerNamespaces(new[] { paperName }) } }; repository = String.IsNullOrWhiteSpace(filePath) ? new XMLRepository("DefaultName.xml") : new XMLRepository(filePath); if (catalog != null) { repository.Save(catalog); } stream = repository.Load(); stream.Seek(0, SeekOrigin.Begin); reader = XmlReader.Create(stream, new XmlReaderSettings() { Async = true, IgnoreWhitespace = true }); reader.ReadToFollowing("Catalog"); reader.Read(); }
public static ICustomerRepository GetRepository(string repositoryType) { ICustomerRepository repository; switch (repositoryType) { case "SQL": repository = new SQLRepository(); break; case "XML": repository = new XMLRepository(); break; case "CSV": repository = new CSVRepository(); break; default: throw new ArgumentException("Invalid repository type " + repositoryType); } return(repository); }
public XMLService(string fileName) { this.repository = new XMLRepository(); this.fileName = fileName; }
/// <summary> /// Constructor /// </summary> public ShowTestPropertiesCommand(IImageManager imageManager, IObservableValue <SingleTest> selectedTest, BindableCollection <ResourcePropertyModel> testProperties4Debug, XMLRepository xmlRepository) { DisplayInfo = new DisplayInfo { Description = Resources.ImportAndShowProperties, Image16 = imageManager.GetImage16Path("Import") }; Command = new RelayCommand(_ => { FillUiWithImportedTest(testProperties4Debug, xmlRepository.ShowTestProperties(selectedTest.Value.TestIDNumber)); }, _ => (selectedTest.Value != null)); }
public void UpdateStatus(string id, string status, string fileName) { var validateFileAndStatus = new VerifierFileAndStatus(fileName, status); status = validateFileAndStatus.VerifyStatus(); fileName = validateFileAndStatus.VerifyFileName(); var xml = new XMLRepository(fileName); // xml.UpdateStatus(id, status); }
public TaskService(string fileName) { this.repository = new XMLRepository(fileName); }
/// <summary> /// Constructor /// </summary> /// <param name="service"></param> /// <param name="selectedTest"></param> public RunTestCommand(IImageManager imageManager, ObservableValue <SingleTest> selectedTest, ICommandViewModel showTestPropertiesCommand, XMLRepository xmlRepository) { Command = new RelayCommand(_ => DoRunTest(selectedTest.Value.TestIDNumber, showTestPropertiesCommand, xmlRepository), _ => (selectedTest.Value != null)); DisplayInfo = new DisplayInfo { Description = Resources.RunSelectedTest, Image16 = imageManager.GetImage16Path("Run") }; }
public void SaveDataExeption(string path, Catalog catalog, Type exception) { XMLRepository repository = new XMLRepository(path); Assert.Throws(exception, () => repository.Save(catalog)); }
public void NotExistingPathExeption(string repositoryName, Type exception) { XMLRepository repository = new XMLRepository(repositoryName); Assert.Throws(exception, () => repository.Load()); }
private static void DoSaveAsNewResources(ICommandViewModel showTestPropertiesCommand, XMLRepository xmlRepository, HomeViewModel homeView) { string newTestName = homeView.NewTestName; string newFuelName = homeView.NewFuelName; string newVehicleName = homeView.NewVehicleName; if (!homeView.NewTestEnabled) { newTestName = null; } if (!homeView.NewFuelEnabled) { newFuelName = null; } if (!homeView.NewVehicleEnabled) { newVehicleName = null; } if (newTestName != null || newFuelName != null || newVehicleName != null) { showTestPropertiesCommand.Command.Execute(null); xmlRepository.SaveAsNewResources(newTestName, newFuelName, newVehicleName); } }
public static void Setup(TestContext testContext) { _financeItemRepository = new XMLRepository<FinanceItemEntity>("FinanceItems.xml"); }
/// <summary> /// Constructor /// </summary> public SaveAsNewResourcesCommand(IImageManager imageManager, IObservableValue <SingleTest> selectedTest, HomeViewModel homeView, ICommandViewModel showTestPropertiesCommand, XMLRepository xmlRepository) { DisplayInfo = new DisplayInfo { Description = Resources.SaveAsNewResources, Image16 = imageManager.GetImage16Path("Save") }; Command = new RelayCommand(_ => DoSaveAsNewResources(showTestPropertiesCommand, xmlRepository, homeView), _ => (selectedTest.Value != null)); }
private void DoRunTest(string resourceName, ICommandViewModel showTestPropertiesCommand, XMLRepository xmlRepository) { showTestPropertiesCommand.Command.Execute(null); xmlRepository.RunTest(resourceName); }
public HomeViewModel(IImageManager imageManager, IShellViewModel shellViewModel, XMLRepository xmlRepository) { _shellViewModel = shellViewModel; TestList = new SortableBindableCollection <SingleTest>(); SelectedTest = new ObservableValue <SingleTest> { Changed = _ => { TestProperties4Debug.Clear(); } }; TestProperties4Debug = new BindableCollection <ResourcePropertyModel>(); SortSettings = new SortSettings("TestCell", ListSortDirection.Ascending); SortSettings.Changed += (sender, args) => this.Sort(TestList); ColumnNameToSortKey = new Dictionary <string, Func <SingleTest, IComparable> > { }; ColumnNameToSortKey.Add("TestCell", i => i.TestCell); ColumnNameToSortKey.Add("TestID", i => i.TestIDNumber); ColumnNameToSortKey.Add("VehicleID", i => i.VehicleID); ColumnNameToSortKey.Add("ProjectID", i => i.ProjectID); ColumnNameToSortKey.Add("TestTypeCode", i => i.TestTypeCode); ColumnNameToSortKey.Add("Priority", i => i.Priority); ColumnNameToSortKey.Add("ModificationDate", i => i.ModificationDate); GetTestListCommand = new GetTestListCommand(imageManager, TestList, xmlRepository); ShowTestPropertiesCommand = new ShowTestPropertiesCommand(imageManager, SelectedTest, TestProperties4Debug, xmlRepository); RunTestCommand = new RunTestCommand(imageManager, SelectedTest, ShowTestPropertiesCommand, xmlRepository); SaveAsNewResourcesCommand = new SaveAsNewResourcesCommand(imageManager, SelectedTest, this, ShowTestPropertiesCommand, xmlRepository); ControlSaveAsCommand = new ControlSaveAsCommand(imageManager, SelectedTest, this); var imagePathPattern = "/STARS.Applications.VETS.Plugins.VTS.UI;component/Images/{0}.png"; DisplayInfo = new ExplorerDisplayInfo { Description = Resources.VtsVets, Image16 = string.Format(imagePathPattern, "green_car_16"), Image32 = string.Format(imagePathPattern, "green_car_32"), ExplorerImage16 = string.Format(imagePathPattern, "white_car_16"), }; DisplayName = Resources.VtsVets; OnTestFinish.TestFinished += OnTestFinished; }