/// <summary> /// Deprecated Method for adding a new object to the DowntimeReasonSet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToDowntimeReasonSet(DowntimeReason downtimeReason) { base.AddObject("DowntimeReasonSet", downtimeReason); }
private string saveAllPostRows() { List<PostRowData> dd = getPostRowDatas(); if (dd == null) return "no data"; using (DB db = new DB(DBHelper.GetConnectionString(_currentClient))) { DowntimeReason dr; foreach (var item in dd) { var levels = item.Path.Split('>'); if (levels.Length < 3) Array.Resize(ref levels, 3); if (string.IsNullOrEmpty(levels[0]) && string.IsNullOrEmpty(levels[1]) && string.IsNullOrEmpty(levels[2])) continue; if (item.Id <= 0) { dr = new DowntimeReason { Level1 = levels[0], Level2 = levels[1], Level3 = levels[2], Duration = item.Duration, Client = _currentClient, HideReasonInReports = item.HideReasonInReports, Line = (!string.IsNullOrEmpty(Line) ? Line : "company-demo"), IsChangeOver = item.IsChangeOver }; db.AddToDowntimeReasonSet(dr); } else { var q = from o in db.DowntimeReasonSet where o.ID == item.Id && o.Client == _currentClient select o; dr = q.FirstOrDefault(); if (dr == null) continue; if ((string.IsNullOrEmpty(dr.Line) || dr.Line == "company-demo") && (!string.IsNullOrEmpty(Line) && Line != "company-demo"))//assumes it is a global reason code and they're adding a Line specific { DowntimeReason reason = new DowntimeReason { Level1 = levels[0], Level2 = levels[1], Level3 = levels[2], Duration = item.Duration, HideReasonInReports = item.HideReasonInReports, Line = (!string.IsNullOrEmpty(Line) ? Line : "company-demo"), IsChangeOver = item.IsChangeOver, Client = _currentClient }; db.AddToDowntimeReasonSet(reason); } else { dr.Level1 = levels[0]; dr.Level2 = levels[1]; dr.Level3 = levels[2]; dr.Duration = item.Duration; dr.HideReasonInReports = item.HideReasonInReports; dr.Line = (!string.IsNullOrEmpty(Line) ? Line : "company-demo"); dr.IsChangeOver = item.IsChangeOver; } } } //delete rows foreach (var item in getPostRowDatasDeleteRows()) { var q = from o in db.DowntimeReasonSet where o.ID == item && o.Client == _currentClient select o; dr = q.FirstOrDefault(); if (dr == null) continue; if(dr.Line == Line)//Don't want to accidently delete another Line's reason code db.DeleteObject(dr); } db.SaveChanges(); return "true"; } }
/// <summary> /// Create a new DowntimeReason object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="hideReasonInReports">Initial value of the HideReasonInReports property.</param> /// <param name="isChangeOver">Initial value of the IsChangeOver property.</param> /// <param name="duration">Initial value of the Duration property.</param> public static DowntimeReason CreateDowntimeReason(global::System.Int32 id, global::System.Boolean hideReasonInReports, global::System.Boolean isChangeOver, global::System.Int32 duration) { DowntimeReason downtimeReason = new DowntimeReason(); downtimeReason.ID = id; downtimeReason.HideReasonInReports = hideReasonInReports; downtimeReason.IsChangeOver = isChangeOver; downtimeReason.Duration = duration; return downtimeReason; }