public ProcessDTO CopyPropertisVal() { ProcessDTO obj = new ProcessDTO(); Type t = this.GetType(); foreach (PropertyInfo property in t.GetProperties()) { var val = property.GetValue(this, null); PropertyExtension.SetPropertyValue(obj, property.Name, val); } return(obj); }
public static ProcessDTO Parse(string json) { if (string.IsNullOrEmpty(json)) { throw new ArgumentNullException(); } ProcessDTOTmp tmp = new ProcessDTOTmp(); //------------ парсинг Json ---------- tmp = JsonConvert.DeserializeObject <ProcessDTOTmp>(json, new IsoDateTimeConverter { DateTimeFormat = "dd.MM.yyyy HH:mm:ss" }); tmp.Json = json; ProcessDTO dto = tmp.CopyPropertisVal(); //----------------------------------- return(dto); }
public void Save(ProcessDTO dto) { try { string ReporName = dto.ReportPath.Remove(0, dto.ReportPath.LastIndexOf(@"\") + 1); if (!String.IsNullOrWhiteSpace(ReporName)) { if (!String.IsNullOrWhiteSpace(dto.Json) & !String.IsNullOrWhiteSpace(ReporName)) { //DbOracle db = new DbOracle(); try { //if (db.Open("", "", "")) //{ using (StreamWriter writer = new StreamWriter("C:\\call.txt", true)) { writer.WriteLine(String.Format("Вызов процедур базы данных {0} {1} ( {2}, {3} )", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), "proc", dto.DateTimeStart.ToString(), ReporName)); writer.Flush(); } // db.Close(); //} } catch (Exception err) { //db.Close(); throw new Exception(String.Format("Ошибка PasportSave метод Save Вызов процедур базы данных делаем откат {0} {1}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), err.ToString())); } } } } catch (Exception ex) { throw new Exception(String.Format("Ошибка PasportSave метод Save {0} {1}", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"), ex.ToString())); } }