private string GetReturnMessage(string message) { try { if (objBooking.BookingReturns.Count == 0) { return(""); } Booking objReturn = objBooking.BookingReturns[0]; string msg = message; msg += Environment.NewLine + "Return Details : " + Environment.NewLine; object propertyValue = string.Empty; foreach (var tag in AppVars.listofSMSTags.Where(c => msg.Contains(c.TagMemberValue))) { switch (tag.TagObjectName) { case "booking": if (tag.TagPropertyValue.Contains('.')) { string[] val = tag.TagPropertyValue.Split(new char[] { '.' }); object parentObj = objReturn.GetType().GetProperty(val[0]).GetValue(objReturn, null); if (parentObj != null) { propertyValue = parentObj.GetType().GetProperty(val[1]).GetValue(parentObj, null); } else { propertyValue = string.Empty; } break; } else { if (tag.ConditionNotNull.ToStr() == "BabySeats" && tag.TagPropertyValue.ToStr() == "BabySeats") { propertyValue = objReturn.GetType().GetProperty(tag.TagPropertyValue2).GetValue(objReturn, null); if (!string.IsNullOrEmpty(propertyValue.ToStr().Trim()) && propertyValue.ToStr().Contains("<<<")) { string[] arr = propertyValue.ToStr().Split(new string[] { "<<<" }, StringSplitOptions.None); propertyValue = "B Seat 1 : " + arr[0].ToStr() + Environment.NewLine + "B Seat 2 : " + arr[1].ToStr(); } } else { propertyValue = tag.ConditionNotNullReplacedValue.ToStr(); } //if (!string.IsNullOrEmpty(tag.ConditionNotNull) && objBooking.GetType().GetProperty(tag.ConditionNotNull) != null) //{ // propertyValue = tag.ConditionNotNullReplacedValue.ToStr(); //} //else //{ // propertyValue = objBooking.GetType().GetProperty(tag.TagPropertyValue).GetValue(objBooking, null); //} } if (string.IsNullOrEmpty(propertyValue.ToStr()) && !string.IsNullOrEmpty(tag.TagPropertyValue2)) { propertyValue = objReturn.GetType().GetProperty(tag.TagPropertyValue2).GetValue(objReturn, null); } break; case "driver": if (tag.TagPropertyValue.Contains('.')) { string[] val = tag.TagPropertyValue.Split(new char[] { '.' }); object parentObj = ObjDriver.GetType().GetProperty(val[0]).GetValue(ObjDriver, null); if (parentObj != null) { propertyValue = parentObj.GetType().GetProperty(val[1]).GetValue(parentObj, null); } else { propertyValue = string.Empty; } break; } else { propertyValue = ObjDriver.GetType().GetProperty(tag.TagPropertyValue).GetValue(ObjDriver, null); } if (string.IsNullOrEmpty(propertyValue.ToStr()) && !string.IsNullOrEmpty(tag.TagPropertyValue2)) { propertyValue = ObjDriver.GetType().GetProperty(tag.TagPropertyValue2).GetValue(ObjDriver, null); } break; default: propertyValue = AppVars.objSubCompany.GetType().GetProperty(tag.TagPropertyValue).GetValue(AppVars.objSubCompany, null); break; } msg = msg.Replace(tag.TagMemberValue, tag.TagPropertyValuePrefix.ToStr() + string.Format(tag.TagDataFormat, propertyValue) + tag.TagPropertyValueSuffix.ToStr()); } return(msg.Replace("\n\n", "\n")); } catch (Exception ex) { // ENUtils.ShowMessage(ex.Message); return(""); } }
private string GetMessage(string message) { try { string msg = message; object propertyValue = string.Empty; foreach (var tag in AppVars.listofSMSTags.Where(c => msg.Contains(c.TagMemberValue))) { switch (tag.TagObjectName) { case "booking": if (tag.TagPropertyValue.Contains('.')) { string[] val = tag.TagPropertyValue.Split(new char[] { '.' }); object parentObj = objBooking.GetType().GetProperty(val[0]).GetValue(objBooking, null); if (parentObj != null) { propertyValue = parentObj.GetType().GetProperty(val[1]).GetValue(parentObj, null); } else { propertyValue = string.Empty; } break; } else { if (!string.IsNullOrEmpty(tag.ConditionNotNull) && objBooking.GetType().GetProperty(tag.ConditionNotNull) != null) { if (tag.ConditionNotNull.ToStr() == "BabySeats" && tag.TagPropertyValue.ToStr() == "BabySeats") { propertyValue = objBooking.GetType().GetProperty(tag.TagPropertyValue2).GetValue(objBooking, null); if (!string.IsNullOrEmpty(propertyValue.ToStr().Trim()) && propertyValue.ToStr().Contains("<<<")) { string[] arr = propertyValue.ToStr().Split(new string[] { "<<<" }, StringSplitOptions.None); propertyValue = "B Seat 1 : " + arr[0].ToStr() + Environment.NewLine + "B Seat 2 : " + arr[1].ToStr(); } } else if (objBooking.GetType().GetProperty(tag.ConditionNotNull).GetValue(objBooking, null) != null) { propertyValue = tag.ConditionNotNullReplacedValue.ToStr(); } //else //{ // propertyValue = tag.ConditionNotNullReplacedValue.ToStr(); //} } else { propertyValue = objBooking.GetType().GetProperty(tag.TagPropertyValue).GetValue(objBooking, null); } } if (string.IsNullOrEmpty(propertyValue.ToStr()) && !string.IsNullOrEmpty(tag.TagPropertyValue2)) { propertyValue = objBooking.GetType().GetProperty(tag.TagPropertyValue2).GetValue(objBooking, null); } break; case "Booking_ViaLocations": if (tag.TagPropertyValue == "ViaLocValue") { string[] VilLocs = null; int cnt = 1; VilLocs = objBooking.Booking_ViaLocations.Select(c => cnt++.ToStr() + ". " + c.ViaLocValue).ToArray(); if (VilLocs.Count() > 0) { string Locations = "VIA POINT(s) : \n" + string.Join("\n", VilLocs); propertyValue = Locations; } else { propertyValue = string.Empty; } } break; case "driver": if (tag.TagPropertyValue.Contains('.')) { string[] val = tag.TagPropertyValue.Split(new char[] { '.' }); object parentObj = ObjDriver.GetType().GetProperty(val[0]).GetValue(ObjDriver, null); if (parentObj != null) { propertyValue = parentObj.GetType().GetProperty(val[1]).GetValue(parentObj, null); } else { propertyValue = string.Empty; } break; } else { propertyValue = ObjDriver.GetType().GetProperty(tag.TagPropertyValue).GetValue(ObjDriver, null); } if (string.IsNullOrEmpty(propertyValue.ToStr()) && !string.IsNullOrEmpty(tag.TagPropertyValue2)) { propertyValue = ObjDriver.GetType().GetProperty(tag.TagPropertyValue2).GetValue(ObjDriver, null); } break; default: propertyValue = AppVars.objSubCompany.GetType().GetProperty(tag.TagPropertyValue).GetValue(AppVars.objSubCompany, null); break; } msg = msg.Replace(tag.TagMemberValue, tag.TagPropertyValuePrefix.ToStr() + string.Format(tag.TagDataFormat, propertyValue) + tag.TagPropertyValueSuffix.ToStr()); } return(msg.Replace("\n\n", "\n")); } catch (Exception ex) { // ENUtils.ShowMessage(ex.Message); return(""); } }