public static async Task<Judet[]> Judete() { if (judFinderCache != null) { return judFinderCache.judete; } using (var rep = new RepositoryLiteDb<Judet>()) { var exists = rep.ExistsData(); if (!exists) { Console.WriteLine("save judete to local"); var sl = new SirutaLoader(); var jud = (await sl.InitJudete()).ToArray(); var ms = await rep.StoreDataAsNew(jud); } Console.WriteLine("get data from local"); return rep.RetrieveData().ToArray(); } }
public async Task<ActionResult> LoadData(string id) { if (string.IsNullOrEmpty(id)) { return View(); } var dataSaved=new List<RopDataSaved>(); using (var rep = new RepositoryLiteDb<RopDataSaved>()) { var q = rep.RetrieveData().ToArray(); if (q.Length > 0) { dataSaved.AddRange(q); } } string typeName = id.Replace("_", "."); var existTypeName = (dataSaved.FirstOrDefault(it => it.Name == typeName) != null); if (!existTypeName) { var dataRetr = await Repository.GetOrLoad(typeName); dataSaved.AddRange( dataRetr.Select(ropDocument => new RopDataSaved() { ID = ropDocument.ID, Name = typeName, Document = ropDocument })); using (var rep = new RepositoryLiteDb<RopDataSaved>()) { var q = await rep.StoreDataAsNew(dataSaved.ToArray()); } } this.HttpContext.Application["dataSaved"] = dataSaved.ToArray(); return View(); }
public async Task <ActionResult> LoadData(string id) { if (string.IsNullOrEmpty(id)) { return(View()); } var dataSaved = new List <RopDataSaved>(); using (var rep = new RepositoryLiteDb <RopDataSaved>()) { var q = rep.RetrieveData().ToArray(); if (q.Length > 0) { dataSaved.AddRange(q); } } string typeName = id.Replace("_", "."); var existTypeName = (dataSaved.FirstOrDefault(it => it.Name == typeName) != null); if (!existTypeName) { var dataRetr = await Repository.GetOrLoad(typeName); dataSaved.AddRange( dataRetr.Select(ropDocument => new RopDataSaved() { ID = ropDocument.ID, Name = typeName, Document = ropDocument })); using (var rep = new RepositoryLiteDb <RopDataSaved>()) { var q = await rep.StoreDataAsNew(dataSaved.ToArray()); } } this.HttpContext.Application["dataSaved"] = dataSaved.ToArray(); return(View()); }
public async Task<RopDocument[]> GetData() { var type = this.GetType().FullName; using (var rep = new RepositoryLiteDb<RopDocument>(type)) { var exists = rep.ExistsData(); if (!exists) { var rd = await FillDate(); var notId = rd.FirstOrDefault(it => string.IsNullOrWhiteSpace(it.ID)); if (notId != null) { throw new ArgumentException("not id for" + notId.Name + "-- " + notId.PathDocument); } await rep.StoreDataAsNew(rd); } var data = rep.RetrieveData(); return data.ToArray(); } }
//static async Task<UAT[]> GetUAT(Judet[] judete) //{ // return new UAT[0]; // using (var repUAT = new Repository<UAT>()) // { // var exists = repUAT.ExistsData(); // if (!exists) // { // Console.WriteLine("save uat to local"); // var sl = new SirutaLoader(); // var uat = await sl.InitUat(judete); // var ms = await repUAT.StoreDataAsNew(uat.ToArray()); // } // Console.WriteLine("get data from local"); // return repUAT.RetrieveData().ToArray(); // } //} static void Main(string[] args) { //var dd = new DownloadData(); //var dataBytes = dd.Data("http://www.date.gov.ro/dataset/3c128d2f-f4e2-47d5-ad11-a5602c1e4856/resource/61a73bc0-34c6-4067-b1c4-3ab659323c87/download/numrul-medicilor-pe-judee-i-ministere-din-sectorul-public-numrul-medicilor-pe-ministere-macroreg.xls").Result; // var x= AppDomain.CurrentDomain.GetData("DataDirectory"); if (x == null) { AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(Directory.GetCurrentDirectory(),"App_Data")); } var judete = JudeteLoader.Judete().Result; foreach (var judet in judete) { Console.WriteLine(judet.Nume); } var dataSv = DataSavedLoader.DataSaved().Result; var dataSaved=new List<RopDataSaved>(); foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(),"Rop*.dll")) { try { Assembly.LoadFile(file); } catch (Exception ex) { string s = ex.Message; } } var interfaceLoader = typeof (IRopLoader); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => interfaceLoader.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract) .ToArray(); foreach (var type in types) { Console.WriteLine("loading "+type.Name); var dataRetr = Repository.GetOrLoad(type).Result; dataSaved.AddRange( dataRetr.Select(ropDocument => new RopDataSaved() { ID = ropDocument.ID, Name = type.AssemblyQualifiedName, //Document = ropDocument })); } //var dataRetr =Repository.GetOrLoad(type).Result; //dataSaved.AddRange( // dataRetr.Select(ropDocument => new RopDataSaved() // { // ID = ropDocument.ID, // Name = type.AssemblyQualifiedName, // //Document = ropDocument // })); //type = typeof(Farmacii); //dataRetr = Repository.GetOrLoad(typeof(Farmacii)).Result; //dataSaved.AddRange( // dataRetr.Select(ropDocument => new RopDataSaved() // { // ID = ropDocument.ID, // Name = type.AssemblyQualifiedName, // //Document = ropDocument // })); using (var rep = new RepositoryLiteDb<RopDataSaved>()) { var q =rep.StoreDataAsNew(dataSaved.ToArray()).Result; } }
//static async Task<UAT[]> GetUAT(Judet[] judete) //{ // return new UAT[0]; // using (var repUAT = new Repository<UAT>()) // { // var exists = repUAT.ExistsData(); // if (!exists) // { // Console.WriteLine("save uat to local"); // var sl = new SirutaLoader(); // var uat = await sl.InitUat(judete); // var ms = await repUAT.StoreDataAsNew(uat.ToArray()); // } // Console.WriteLine("get data from local"); // return repUAT.RetrieveData().ToArray(); // } //} static void Main(string[] args) { //var dd = new DownloadData(); //var dataBytes = dd.Data("http://www.date.gov.ro/dataset/3c128d2f-f4e2-47d5-ad11-a5602c1e4856/resource/61a73bc0-34c6-4067-b1c4-3ab659323c87/download/numrul-medicilor-pe-judee-i-ministere-din-sectorul-public-numrul-medicilor-pe-ministere-macroreg.xls").Result; // var x = AppDomain.CurrentDomain.GetData("DataDirectory"); if (x == null) { AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(Directory.GetCurrentDirectory(), "App_Data")); } var judete = JudeteLoader.Judete().Result; foreach (var judet in judete) { Console.WriteLine(judet.Nume); } var dataSv = DataSavedLoader.DataSaved().Result; var dataSaved = new List <RopDataSaved>(); foreach (var file in Directory.GetFiles(Directory.GetCurrentDirectory(), "Rop*.dll")) { try { Assembly.LoadFile(file); } catch (Exception ex) { string s = ex.Message; } } var interfaceLoader = typeof(IRopLoader); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => interfaceLoader.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract) .ToArray(); foreach (var type in types) { Console.WriteLine("loading " + type.Name); var dataRetr = Repository.GetOrLoad(type).Result; dataSaved.AddRange( dataRetr.Select(ropDocument => new RopDataSaved() { ID = ropDocument.ID, Name = type.AssemblyQualifiedName, //Document = ropDocument })); } //var dataRetr =Repository.GetOrLoad(type).Result; //dataSaved.AddRange( // dataRetr.Select(ropDocument => new RopDataSaved() // { // ID = ropDocument.ID, // Name = type.AssemblyQualifiedName, // //Document = ropDocument // })); //type = typeof(Farmacii); //dataRetr = Repository.GetOrLoad(typeof(Farmacii)).Result; //dataSaved.AddRange( // dataRetr.Select(ropDocument => new RopDataSaved() // { // ID = ropDocument.ID, // Name = type.AssemblyQualifiedName, // //Document = ropDocument // })); using (var rep = new RepositoryLiteDb <RopDataSaved>()) { var q = rep.StoreDataAsNew(dataSaved.ToArray()).Result; } }