public virtual void Run(MESStationBase Station, MESStationInput Input) { if (function == null) { if (type == null) { if (assenby == null) { try { assenby = Assembly.LoadFile(System.IO.Directory.GetCurrentDirectory() + "\\" + DLL); } catch { //assenby = Assembly.LoadFile(System.Web.HttpContext.Current.Server.MapPath(DLL)); //assenby = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory+"\\bin\\"+ DLL); assenby = Assembly.Load("MESStation"); } } type = assenby.GetType(ClassName.Trim().Replace("\r\n", "")); if (type == null) { throw new Exception(ClassName.Trim().Replace("\r\n", "") + "Can not be Create!"); } } function = type.GetMethod(FunctionName.Trim().Replace("\r\n", "")); } try { //function.Invoke(null, new object[] { null, null, null }); function.Invoke(null, new object[] { Station, Input, Paras }); } catch (MESReturnMessage e1) { throw e1; } catch (Exception ee) { if (ee.InnerException.GetType() == typeof(MESReturnMessage)) { throw ee.InnerException; } if (ee.InnerException != null) { throw ee.InnerException; } throw ee; } }
private void ValidateClass() { if (ClassName.Trim().Length == 0) { throw new FileHelpersException("The ClassName can't be empty"); } for (int i = 0; i < mFields.Count; i++) { if (((FieldBuilder)mFields[i]).FieldName.Trim().Length == 0) { throw new FileHelpersException("The " + (i + 1).ToString() + "th field name can't be empty"); } if (((FieldBuilder)mFields[i]).FieldType.Trim().Length == 0) { throw new FileHelpersException("The " + (i + 1).ToString() + "th field type can't be empty"); } } }
private void ValidateClass() { if (ClassName.Trim().Length == 0) { throw new FileHelpersException(Messages.Errors.EmptyClassName.Text); } for (int i = 0; i < mFields.Count; i++) { if (((FieldBuilder)mFields[i]).FieldName.Trim().Length == 0) { throw new FileHelpersException(Messages.Errors.EmptyFieldName .Position((i + 1).ToString()) .Text); } if (((FieldBuilder)mFields[i]).FieldType.Trim().Length == 0) { throw new FileHelpersException(Messages.Errors.EmptyFieldType .Position((i + 1).ToString()) .Text); } } }
public override string ToString() { StringBuilder builder = new StringBuilder(); builder.Append(string.Format("public partial class {0} : EntityBase<{0}> \r\n{{\r\n", ClassName.Trim())); builder.Append("private FSBDigitalSubmissionsData _fsbData;\r\n"); if (IsRepeatable) { var dataItemName = Properties.FirstOrDefault(p => p.IsRepeater).Value; var lastMatch = Regex.Match(dataItemName, "[A-Z][a-z0-9]+$", RegexOptions.RightToLeft).Value; dataItemName = dataItemName.Substring(0, dataItemName.Length - lastMatch.Length); builder.Append(string.Format("private {0}Data _item;\r\n", dataItemName)); } builder.AppendFormat("\r\n#region Constructors\r\n"); builder.Append(string.Format("public {0}()\r\n{{\r\n", ClassName)); builder.Append("\r\n}\r\n\r\n"); builder.Append(string.Format("public {0}(FSBDigitalSubmissionsData fsbData)\r\n{{\r\nthis._fsbData = fsbData;", ClassName)); builder.Append("\r\n}\r\n"); if (IsRepeatable) { var dataItemName = Properties.FirstOrDefault(p => p.IsRepeater).Value; var lastMatch = Regex.Match(dataItemName, "[A-Z][a-z0-9]+$", RegexOptions.RightToLeft).Value; dataItemName = dataItemName.Substring(0, dataItemName.Length - lastMatch.Length); builder.Append(string.Format("public {0}({1}Data item)\r\n{{\r\nthis._item = item;", ClassName, dataItemName)); builder.Append("\r\n}\r\n"); } builder.AppendFormat("#endregion\r\n"); foreach (var property in Properties) { if (property.IsClass) { string fullClassName = ClassName + property.PropertyName.FirstCharToUpper(); if (Classes.ContainsKey(fullClassName)) { var propAsClass = Classes[fullClassName]; if (propAsClass.IsRepeatable) { builder.Append(string.Format("\r\nprivate List<{0}> {1}Field;\r\n[System.Xml.Serialization.XmlElement(\"{1}\")]\r\npublic List<{0}> {1}s \r\n{{\r\n get \r\n{{\r\n ", fullClassName, property.PropertyName)); var dataListValue = propAsClass.Properties.FirstOrDefault(p => p.IsRepeater).Value; var lastMatch = Regex.Match(dataListValue, "[A-Z][a-z0-9]+$", RegexOptions.RightToLeft).Value; dataListValue = dataListValue.Substring(0, dataListValue.Length - lastMatch.Length); builder.AppendFormat("return _fsbData.Investments.{0}DataList\r\n.Select(item =>\r\n new {1}(item))\r\n.ToList(); \r\n}}\r\n", dataListValue, fullClassName); builder.AppendFormat(" set\r\n{{\r\n{1}Field = value;\r\n}} \r\n}}\r\n", fullClassName, property.PropertyName); } else { builder.Append(string.Format("\r\nprivate {0} {1}Field;\r\npublic {0} {1} \r\n{{\r\n get \r\n{{\r\n return new {0}(_fsbData); \r\n}}\r\n set\r\n{{\r\n{1}Field = value;\r\n}} \r\n}}\r\n", ClassName + property.PropertyName.FirstCharToUpper(), property.PropertyName)); } } else { builder.Append(string.Format("\r\nprivate {0} {1}Field;\r\npublic {0} {1} \r\n{{\r\n get \r\n{{\r\n return new {0}(_fsbData); \r\n}}\r\n set\r\n{{\r\n{1}Field = value;\r\n}} \r\n}}\r\n", ClassName + property.PropertyName.FirstCharToUpper(), property.PropertyName)); } } else { builder.Append(property.ToString()); } } builder.Append("}\r\n\r\n"); if (Classes != null && Classes.Count > 0) { foreach (var classItem in XmlClasses) { builder.Append(classItem.ToString()); } } return(builder.ToString()); }