public virtual void NewAlarmTarihce(CihazAlarmTanimi tanim, CihazAdres alarmadres) { AlarmTarihce = new mymodel.AlarmTarihce(); AlarmTarihce.Cihaz.Id = this.Cihaz.Id; AlarmTarihce.Alarm.Id = tanim.Id; AlarmTarihce.AlarmAdres = alarmadres; }
protected override void Save() { UpdateEntityData(); Transaction.Instance.Join(delegate() { base.Save(); string cihaztagadresId = string.Empty; string alarmtanimId = string.Empty; long Id = 0; foreach (DataRow rw in Adresler.Rows) { if (rw["Id"] != null && rw["Id"] != System.DBNull.Value) { Id = Convert.ToInt64(rw["Id"]); } else { Id = 0; } CihazAdres chz; if (Id == 0) { chz = new CihazAdres(); chz.Cihaz.Id = infoformentity.Id; chz.Adres.Id = Convert.ToInt64(Current.IsNull(rw["Adres_Id"], 0)); chz.AdresTipi = (mymodel.myenum.AdresTipi)Enum.Parse(typeof(mymodel.myenum.AdresTipi), Current.IsNull(rw["AdresTipi"], "").ToString()); chz.Davranis = (mymodel.myenum.Davranis)Enum.Parse(typeof(mymodel.myenum.Davranis), Current.IsNull(rw["Davranis"], "").ToString()); chz.Formul = Current.IsNull(rw["Formul"], "").ToString(); chz.IsLogTutulsun = bool.Parse(Current.IsNull(rw["IsLogTutulsun"], false).ToString()); chz.Insert(); } else { chz = Persistence.Read <CihazAdres>(Id); chz.Cihaz.Id = infoformentity.Id; chz.Adres.Id = Convert.ToInt64(Current.IsNull(rw["Adres_Id"], 0)); chz.AdresTipi = (mymodel.myenum.AdresTipi)Enum.Parse(typeof(mymodel.myenum.AdresTipi), Current.IsNull(rw["AdresTipi"], "").ToString()); chz.Davranis = (mymodel.myenum.Davranis)Enum.Parse(typeof(mymodel.myenum.Davranis), Current.IsNull(rw["Davranis"], "").ToString()); chz.Formul = Current.IsNull(rw["Formul"], "").ToString(); chz.IsLogTutulsun = bool.Parse(Current.IsNull(rw["IsLogTutulsun"], false).ToString()); chz.Update(); } cihaztagadresId += chz.Id + ","; } foreach (DataRow rw1 in AlarmAdresleri.Rows) { if (rw1["Id"] != null && rw1["Id"] != System.DBNull.Value) { Id = Convert.ToInt64(rw1["Id"]); } else { Id = 0; } CihazAdres chz = null; if (Id == 0) { chz = new CihazAdres(); chz.Cihaz.Id = infoformentity.Id; chz.Adres.Id = Convert.ToInt64(Current.IsNull(rw1["Adres_Id"], 0)); chz.AdresTipi = myenum.AdresTipi.AlarmAdresi;; chz.Davranis = myenum.Davranis.Oku; chz.Formul = Current.IsNull(rw1["Formul"], "").ToString(); chz.IsLogTutulsun = bool.Parse(Current.IsNull(rw1["IsLogTutulsun"], false).ToString()); chz.Insert(); } else { chz = Persistence.Read <CihazAdres>(Id); chz.Cihaz.Id = infoformentity.Id; chz.Adres.Id = Convert.ToInt64(Current.IsNull(rw1["Adres_Id"], 0)); chz.AdresTipi = myenum.AdresTipi.AlarmAdresi;; chz.Davranis = myenum.Davranis.Oku; chz.Formul = Current.IsNull(rw1["Formul"], "").ToString(); chz.IsLogTutulsun = bool.Parse(Current.IsNull(rw1["IsLogTutulsun"], false).ToString()); chz.Update(); } cihaztagadresId += chz.Id + ","; Id = 0; if (rw1["Id1"] != null && rw1["Id1"] != System.DBNull.Value) { Id = Convert.ToInt64(rw1["Id1"]); } else { Id = 0; } CihazAlarmTanimi alarmtanimi; if (Id == 0) { alarmtanimi = new CihazAlarmTanimi(); alarmtanimi.Cihaz.Id = infoformentity.Id; alarmtanimi.CihazAdres.Id = chz.Id; alarmtanimi.AlarmTipi = (mymodel.myenum.AlarmTipi)Enum.Parse(typeof(mymodel.myenum.AlarmTipi), Current.IsNull(rw1["AlarmTipi"], false).ToString()); alarmtanimi.AlarmMesaji = rw1["AlarmMesaji"].ToString(); alarmtanimi.DataTipi = (mymodel.myenum.MappedFieldType)Enum.Parse(typeof(mymodel.myenum.MappedFieldType), Current.IsNull(rw1["DataTipi1"], false).ToString()); alarmtanimi.IsLogTutulsun = bool.Parse(Current.IsNull(rw1["IsLogTutulsun1"], false).ToString()); alarmtanimi.SesAcik = bool.Parse(Current.IsNull(rw1["SesAcik"], false).ToString()); alarmtanimi.SesDosyasiAdresi = rw1["SesDosyasiAdresi"].ToString(); alarmtanimi.RSKodu.Id = Convert.ToInt64(Current.IsNull(rw1["RSKodu_Id"], 0)); alarmtanimi.Insert(); } else { alarmtanimi = Persistence.Read <CihazAlarmTanimi>(Id); alarmtanimi.Cihaz.Id = infoformentity.Id; alarmtanimi.CihazAdres.Id = chz.Id; alarmtanimi.AlarmTipi = (mymodel.myenum.AlarmTipi)Enum.Parse(typeof(mymodel.myenum.AlarmTipi), Current.IsNull(rw1["AlarmTipi"].ToString(), "").ToString()); alarmtanimi.AlarmMesaji = rw1["AlarmMesaji"].ToString(); alarmtanimi.DataTipi = (mymodel.myenum.MappedFieldType)Enum.Parse(typeof(mymodel.myenum.MappedFieldType), Current.IsNull(rw1["DataTipi1"].ToString(), "").ToString()); alarmtanimi.IsLogTutulsun = bool.Parse(Current.IsNull(rw1["IsLogTutulsun1"].ToString(), false).ToString()); alarmtanimi.SesAcik = bool.Parse(Current.IsNull(rw1["SesAcik"], false).ToString()); alarmtanimi.SesDosyasiAdresi = Current.IsNull(rw1["SesDosyasiAdresi"], "").ToString(); alarmtanimi.RSKodu.Id = Convert.ToInt64(Current.IsNull(rw1["RSKodu_Id"], 0)); alarmtanimi.Update(); } alarmtanimId += alarmtanimi.Id + ","; } try { if (cihaztagadresId.Length > 0) { cihaztagadresId = cihaztagadresId.Remove(cihaztagadresId.Length - 1, 1); } else { cihaztagadresId = "0"; } if (alarmtanimId.Length > 0) { alarmtanimId = alarmtanimId.Remove(alarmtanimId.Length - 1, 1); } else { alarmtanimId = "0"; } int i = Transaction.Instance.ExecuteNonQuery(" delete from CihazAdres where Cihaz_Id=@prm0 and Id Not in (" + cihaztagadresId + ")", new object[] { infoformentity.Id }); i = Transaction.Instance.ExecuteNonQuery(" delete from CihazAlarmTanimi where Cihaz_Id=@prm0 and Id Not in(" + alarmtanimId + ")", new object[] { infoformentity.Id }); } catch (Exception ex) { throw new Exception("Cihaz ait adresler silinemedi" + ex.Message); } }); }