public void Run(RawlerBase parent) { try { var type = parent.GetType(); var field = type.GetProperty(PropertyName); var text = RawlerBase.GetText(string.Empty, Child, parent); if (field.PropertyType == typeof(string)) { field.SetValue(parent, text, null); } else if (field.PropertyType == typeof(int)) { int num; if (int.TryParse(text, out num)) { field.SetValue(parent, num, null); } else { ReportManage.ErrReport(parent, "InitTreeで" + PropertyName + "の値をint型に変換に失敗しました"); } } else if (field.PropertyType == typeof(double)) { double num; if (double.TryParse(text, out num)) { field.SetValue(parent, num, null); } else { ReportManage.ErrReport(parent, "InitTreeで" + PropertyName + "の値をdouble型に変換に失敗しました"); } } else if (field.PropertyType == typeof(bool)) { if (text.ToLower() == "true") { field.SetValue(parent, true, null); } else if (text.ToLower() == "false") { field.SetValue(parent, false, null); } else { ReportManage.ErrReport(parent, "InitTreeで" + PropertyName + "の値をbool型に変換に失敗しました。Valueは" + text); } } } catch (Exception ex) { ReportManage.ErrReport(parent, "InitTreeで" + PropertyName + "でエラーが発生しました。" + ex.Message); } }
/// <summary> /// Errをレポートする。 /// </summary> /// <param name="sender"></param> /// <param name="err"></param> /// <param name="errorCode"></param> public static void ErrReport(RawlerBase sender, string err, int errorCode = 0) { ReportEvnetArgs args; if (sender != null) { args = new ReportEvnetArgs(sender, GetTopComment(sender) + "ERR:" + sender.GetType().Name + ":" + err, true, true, code: errorCode); } else { args = new ReportEvnetArgs(sender, GetTopComment(sender) + "ERR:" + err, true, true, code: errorCode); } AddReportEventArgs(sender, args); ErrReportEvent?.Invoke(sender, args); }