private void doTexts(string xmlContent) { XDocument doc = XDocument.Parse(xmlContent); var texts = from txt in doc.Descendants("tctxt") select new Texts { TextId = int.Parse(txt.Attribute("id").Value), Title = txt.Element("tctitle").Value, Content = txt.Element("tccontent").Value, }; using (BombaJobDataContext db = new BombaJobDataContext(AppSettings.DBConnectionString)) { foreach (Texts t in texts) App.DbViewModel.AddText(t); } this.syncCategories(); }
private void doNewestOffers(string xmlContent) { XDocument doc = XDocument.Parse(xmlContent); var jobs = from job in doc.Descendants("job") select new JobOffers { OfferId = int.Parse(job.Attribute("id").Value), CategoryId = int.Parse(job.Attribute("cid").Value), HumanYn = int.Parse(job.Attribute("hm").Value) == 1, FreelanceYn = int.Parse(job.Attribute("fyn").Value) == 1, Title = job.Element("jottl").Value, Email = job.Element("joem").Value, CategoryTitle = job.Element("jocat").Value, Positivism = job.Element("jopos").Value, Negativism = job.Element("joneg").Value, PublishDate = DateTime.ParseExact(job.Element("jodt").Value, AppSettings.DateTimeFormat, null), Icon = ((int.Parse(job.Attribute("hm").Value) == 1) ? "iconperson" : "iconcompany"), }; using (BombaJobDataContext db = new BombaJobDataContext(AppSettings.DBConnectionString)) { foreach (JobOffers t in jobs) App.DbViewModel.AddJobOffer(t); } this.SynchronizationComplete(); }
private void doCategories(string xmlContent) { XDocument doc = XDocument.Parse(xmlContent); var cats = from cat in doc.Descendants("cat") select new Categories { CategoryId = int.Parse(cat.Attribute("id").Value), OffersCount = int.Parse(cat.Attribute("cnt").Value), Title = cat.Element("cttl").Value, }; using (BombaJobDataContext db = new BombaJobDataContext(AppSettings.DBConnectionString)) { foreach (Categories t in cats) App.DbViewModel.AddCategory(t); } this.syncNewestOffers(); }
private void doJobOffers(string xmlContent) { try { XDocument doc = XDocument.Parse(xmlContent); var jobs = from job in doc.Descendants("job") select new JobOffers { OfferId = int.Parse(job.Attribute("id").Value), CategoryId = int.Parse(job.Attribute("cid").Value), HumanYn = int.Parse(job.Attribute("hm").Value) == 1, FreelanceYn = int.Parse(job.Attribute("fyn").Value) == 1, Title = job.Element("jottl").Value, Email = job.Element("joem").Value, CategoryTitle = job.Element("jocat").Value, Positivism = job.Element("jopos").Value, Negativism = job.Element("joneg").Value, PublishDate = DateTime.ParseExact(job.Element("jodt").Value, AppSettings.DateTimeFormat, null), Icon = ((int.Parse(job.Attribute("hm").Value) == 1) ? "iconperson" : "iconcompany"), }; using (BombaJobDataContext db = new BombaJobDataContext(AppSettings.DBConnectionString)) { foreach (JobOffers t in jobs) App.DbViewModel.AddJobOffer(t); } } catch (Exception e) { AppSettings.LogThis("Synchronization - doJobOffers - " + e.ToString()); } if (this.currentOp != AppSettings.ServiceOp.ServiceOpJobs) { Deployment.Current.Dispatcher.BeginInvoke(() => { SyncComplete(this, new BombaJobEventArgs(false, "", "")); }); } }
public BombaJobViewModel(string bjDBConnectionString) { bjDB = new BombaJobDataContext(bjDBConnectionString); }