public void UpdateHauspaket(HauspaketEntity hauspaketEntity) { hauspaket result = (from x in db.hauspaket where x.hauspaket_id == hauspaketEntity.HauspaketId select x).SingleOrDefault(); result.hauspaket_id = hauspaketEntity.HauspaketId; result.benutzer_id = hauspaketEntity.BenutzerId; result.berater_id = hauspaketEntity.BeraterId; result.hersteller_id = hauspaketEntity.HerstellerId; result.bezeichnung = hauspaketEntity.Bezeichnung; result.grundflaeche = hauspaketEntity.Grundflaeche; result.wohnflaeche = hauspaketEntity.Wohnflaeche; result.stockwerke = hauspaketEntity.Stockwerke; result.preis = hauspaketEntity.Preis; result.archived = hauspaketEntity.Archived; db.SaveChanges(); InsertSyncJn(new SyncJnEntity() { JnId = Convert.ToInt32(DateTime.Now.Ticks), JnOperation = "update", JnPk = hauspaketEntity.HauspaketId, JnTable = "hauspaket", Synced = false }); }
public void DeleteHauspaket(HauspaketEntity hauspaketEntity) { hauspaket result = (from x in db.hauspaket where x.hauspaket_id == hauspaketEntity.HauspaketId select x).SingleOrDefault(); db.hauspaket.Remove(result); db.SaveChanges(); }
internal void SendChanges(HauspaketEntity hausPaket, List <AttachmentsEntity> attach, List <HauspaketAttributZuordEntity> zuords, string syncOperation) { HauspaketDTO dto = new HauspaketDTO() { Archived = (hausPaket.Archived == false ? "0" : (hausPaket.Archived == true ? "1" : "0")), BenutzerId = hausPaket.BenutzerId, BeraterId = hausPaket.BeraterId, Bezeichnung = hausPaket.Bezeichnung, Grundflaeche = Convert.ToDouble(hausPaket.Grundflaeche), HauspaketId = hausPaket.HauspaketId, HerstellerId = hausPaket.HerstellerId, Preis = Convert.ToDouble(hausPaket.Preis), Stockwerke = hausPaket.Stockwerke, Wohnflaeche = Convert.ToDouble(hausPaket.Wohnflaeche), SyncOperation = syncOperation }; foreach (var item in attach) { dto.HauspaketAttachements = new List <Attachements>(); dto.HauspaketAttachements.Add(new Attachements() { AttachementId = item.AttachementId, Bezeichnung = item.Bezeichnung, Filename = item.Filename, HauspaketId = item.HauspaketId, Mimetype = item.Mimetype, Size = item.Size, SyncOperation = syncOperation }); } foreach (var item in zuords) { dto.HauspaketAttributZuordnungen = new List <HauspaketAttributZuord>(); dto.HauspaketAttributZuordnungen.Add(new HauspaketAttributZuord() { HauspaketId = item.HauspaketId, WertId = item.WertId, SyncOperation = syncOperation }); } client.SaveHauspaket(dto); }
public void InsertHauspaket(HauspaketEntity hauspaketEntity) { hauspaket h = new hauspaket() { hauspaket_id = hauspaketEntity.HauspaketId, benutzer_id = hauspaketEntity.BenutzerId, berater_id = hauspaketEntity.BeraterId, hersteller_id = hauspaketEntity.HerstellerId, bezeichnung = hauspaketEntity.Bezeichnung, grundflaeche = hauspaketEntity.Grundflaeche, wohnflaeche = hauspaketEntity.Wohnflaeche, stockwerke = hauspaketEntity.Stockwerke, preis = hauspaketEntity.Preis, archived = hauspaketEntity.Archived }; db.hauspaket.Add(h); db.SaveChanges(); }
internal void SyncHauspaket(Hauspaket item) { HauspaketEntity ent = new HauspaketEntity() { Archived = (item.Archived == "0" ? false : (item.Archived == "1" ? true : false)), BenutzerId = Convert.ToInt32(item.BenutzerId), BeraterId = Convert.ToInt32(item.BeraterId), Bezeichnung = item.Bezeichnung, Grundflaeche = Convert.ToDecimal(item.Grundflaeche), HauspaketId = Convert.ToInt32(item.HauspaketId), HerstellerId = Convert.ToInt32(item.HerstellerId), Preis = Convert.ToDecimal(item.Preis), Stockwerke = Convert.ToInt32(item.Stockwerke), Wohnflaeche = Convert.ToDecimal(item.Wohnflaeche) }; switch (item.SyncOperation) { case "INSERT": { dataHandler.InsertHauspaket(ent); } break; case "UPDATE": { dataHandler.UpdateHauspaket(ent); } break; case "DELETE": { dataHandler.DeleteHauspaket(ent); } break; } }
public void FullSync() { //Zuerst lokale Ädnerungen an WS schicken. //Hauspaket Attachement AttrZuord List <SyncJnEntity> pendingSyncs = daoc.GetPendingSyncs(); foreach (var sync in pendingSyncs) { if (sync.JnTable.ToUpper() == "HAUSPAKET") { HauspaketEntity hausPaket = daoc.GetHauspaket(sync.JnPk); List <AttachmentsEntity> attach = daoc.GetAttachments(sync.JnPk); List <HauspaketAttributZuordEntity> zuords = daoc.GetHauspaketAttributZuordnungen(sync.JnPk); wsc.SendChanges(hausPaket, attach, zuords, sync.JnOperation); sync.Synced = true; daoc.UpdateSyncJournal(sync); } } //Alle Daten vom WebService abfragen. var data = wsc.FullSync(); // Wenn erfolgreich, dann Alle Tabellen Leeren /* INSERT ORDER ei Delete umgekehrt!!! * 1 hauspaket_attribut D * 2 hauspaket_attribut_wert D * 3 hauspaket_attribut_regel D * 4 hersteller D * 5 berater D * 6 hauspaket D * 7 attachements D * 8 hauspaket_attrib_zuord D */ if (data != null) { daoc.ClearHauspaketAttributZuord(); daoc.ClearAttachements(); daoc.ClearHauspaket(); daoc.ClearBerater(); daoc.ClearHersteller(); daoc.ClearHauspaketAttributRegel(); daoc.ClearHauspaketAttributWert(); daoc.ClearHauspaketAttribut(); } foreach (var item in data.HauspaketAttributTable) { daoc.SyncHauspaketAttribut(item); } foreach (var item in data.HauspaketAttributWertTable) { daoc.SyncHauspaketAttributWert(item); } foreach (var item in data.HauspaketAttributRegelTable) { daoc.SyncHauspaketAttributRegel(item); } foreach (var item in data.HerstellerTable) { daoc.SyncHersteller(item); } foreach (var item in data.BeraterTable) { daoc.SyncBerater(item); } foreach (var item in data.HauspaketTable) { daoc.SyncHauspaket(item); } foreach (var item in data.AttachementsTable) { daoc.SyncAttachments(item); } foreach (var item in data.HauspaketAttributZuordTable) { daoc.SyncHauspaketAttributZuord(item); } }