public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile() { Path = base.GetFileLocation(), Type = CodeFileType.Repository, Name = Template.Element("FileName").Value .Replace("$SYS_TARGET$", data.Target) }; if (data.IncludeSmartFile) { file.Content = "using NextGen.NG7.Common.Interfaces.SmartFiles.DataAccess;" + Environment.NewLine + Template.Element("Main").Value .Replace("$SYS_REPOSITORYBASE$", "RepositoryBase, ISmartFileRepository") .Replace("$SYS_METHODS_TEMPLATE$", Template.Element("SmartFileMethods").Value .Replace("$SYS_VAR_TARGET$", GetVariableName(data.Target))) .Replace("$SYS_TARGET$", data.Target) .Replace("$SYS_PLURAL_TARGET$", Utils.Util.Pluralize(data.Target)); } else { file.Content = Template.Element("Main").Value .Replace("$SYS_REPOSITORYBASE$", "RepositoryBase") .Replace("$SYS_METHODS_TEMPLATE$", Template.Element("CRUDMethods").Value .Replace("$SYS_VAR_TARGET$", GetVariableName(data.Target))) .Replace("$SYS_TARGET$", data.Target) .Replace("$SYS_PLURAL_TARGET$", Utils.Util.Pluralize(data.Target)); } base.Files = new List<CodeFile>() { file }; return file; }
public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile(); string membersTemplate = Template.Element("MemberTemplate").Value; StringBuilder privateMember = new StringBuilder(); StringBuilder memberBuilder = new StringBuilder(); StringBuilder initializerBuilder = new StringBuilder(); data.MetaData.ForEach(m => { initializerBuilder.Append(String.Format("\t\t{0} = _{1},{2}", m.Name, GetVariableName(m.Name), Environment.NewLine)); privateMember.Append(String.Format("\t\t{0} _{1};{2}", GetDataType(m), GetVariableName(m.Name), Environment.NewLine)); memberBuilder.Append(membersTemplate.Replace("$MEMBER_NAME$", m.Name) .Replace("$MEMBER_DATATYPE$", GetDataType(m)) .Replace("$MEMBER_VAR_NAME$", GetVariableName(m.Name))); }); file.Content = Template.Element("Main").Value .Replace("$SYS_MEMBER_INIT$", initializerBuilder.ToString().Trim().TrimEnd(',')) .Replace("$SYS_MEMBER_TEMPLATE$", privateMember.Append(memberBuilder).ToString()) .Replace("$SYS_TARGET$", data.Target); file.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", data.Target); file.Path = base.GetFileLocation(); file.Type = CodeFileType.UnitTestBuilder; base.Files = new List<CodeFile>() { file }; return file; }
public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile(); StringBuilder members = new StringBuilder(); string memberTemplate = Template.Element("Members").Value; Dictionary<string, string> mTemplate = new Dictionary<string, string>(); data.MetaData.ForEach(m => { mTemplate["$SYS_DATAMEMBER$"] = m.IsDataMember ? "[DataMember]" : string.Empty; mTemplate["$SYS_NEWGUID$"] = m.Guid.ToUpper(); mTemplate["$SYS_DATATYPE$"] = GetDataType(m); mTemplate["$SYS_MEMBERNAME$"] = m.Name; mTemplate["$SYS_ATTRNAME$"] = m.Name; mTemplate["$SYS_ATTRDESCRIPTION$"] = string.IsNullOrEmpty(m.Description) ? m.Name.ToStringDescription() : m.Description; mTemplate["$SYS_ATTR1$"] = !data.IsViewTarget && m.IsRequired ? ", Required = true" : string.Empty; mTemplate["$SYS_ATTR2$"] = m.IsPK ? ", PrimaryOrCompositeKey = true" : string.Empty; members.Append(memberTemplate.ReplaceContent(mTemplate)); }); Dictionary<string, string> mainTemplate = new Dictionary<string, string>(); mainTemplate["$SYS_NEWGUID$"] = data.TargetGuid; mainTemplate["$SYS_MEMBERS_TEMPLATE$"] = members.ToString(); mainTemplate["$SYS_TARGET$"] = data.Target; mainTemplate["$SYS_TABLEDATANAME$"] = data.TableDataName; mainTemplate["$SYS_TABLEDATADESCRIPTION$"] = data.TableDataDescription; file.Content = Template.Element("Main").Value.ReplaceContent(mainTemplate); file.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", data.Target); file.Path = base.GetFileLocation(); file.Type = CodeFileType.ServiceObject; base.Files = new List<CodeFile>() { file }; return file; }
public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile(); StringBuilder content = new StringBuilder(); content.Append(Template.Element("Using").Value); if (data.IncludeSmartFile) content.Append("using NextGen.NG7.Common.BusinessLogic.SmartFiles;"); content.Append(Environment.NewLine + "namespace " + Template.Element("Namespace").Value + Environment.NewLine); content.Append(String.Format("{{{0}public interface I{1}Manager : IBusinessLogicManager {0}{{{0}", Environment.NewLine, data.Target)); content.Append("//ATTENTION: CHECK THE ROUTES AND FUNCTION NAME/PARAMETERS" + Environment.NewLine); Dictionary<string, string> mTemplate = new Dictionary<string, string>(); mTemplate["$SYS_TARGET$"] = data.Target; new RouteMetaData().GenerateRoutes(data.Target, data.IncludeSmartFile, data.TargetProduct,data.TargetModule).ForEach(r => { //content.Append(Environment.NewLine); content.Append(r.Summary); //content.Append(Environment.NewLine); }); content.Append("}" + Environment.NewLine + "}"); file.Content = content.ToString(); file.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", data.Target); file.Path = base.GetFileLocation(); file.Type = CodeFileType.IManager; base.Files = new List<CodeFile>() { file }; return file; }
public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile(); StringBuilder validationMembers = new StringBuilder(); string stringFieldValidateTemplate = Template.Element("StringFieldValidate").Value.TrimStart(); string guidFieldValidateTemplate = Template.Element("GuidFieldValidate").Value.TrimStart(); string guidNullableFieldTemplate = Template.Element("GuidNullableField").Value.TrimStart(); data.MetaData.ForEach(m => { if (m.IsRequired && !m.Name.Equals(data.Target + "Id")) { if (m.DataType == typeof(string)) { validationMembers.Append(stringFieldValidateTemplate.Replace("$SYS_MEMBERNAME$", m.Name)); } else if (m.DataType == typeof(Guid)) { validationMembers.Append(guidFieldValidateTemplate.Replace("$SYS_MEMBERNAME$", m.Name)); } } }); data.MetaData.ForEach(m => { if (!m.IsRequired && m.DataType == typeof(Guid)) { validationMembers.Append(guidNullableFieldTemplate.Replace("$SYS_MEMBERNAME$", m.Name)); } }); string templateValue = string.Empty; if (data.IncludeSmartFile) { var getSmartFileById = string.Empty; if (data.TargetProduct.ToLower().Equals("core")) templateValue = Template.Element("SmartFileOperations").Value.Replace("$SYS_GETSMARTFILEIDTEMPLATE$", Template.Element("GetSmartFileId_Core").Value); else templateValue = Template.Element("SmartFileOperations").Value.Replace("$SYS_GETSMARTFILEIDTEMPLATE$", Template.Element("GetSmartFileId_NonCore").Value); templateValue = Template.Element("Main").Value.Replace("$SYS_METHODS_TEMPLATE$", templateValue); } else { templateValue = Template.Element("Main").Value.Replace("$SYS_METHODS_TEMPLATE$", Template.Element("CRUDOperations").Value); } file.Content = templateValue.Replace("$SYS_VALIDATION_MEMBERS$", validationMembers.ToString()) .Replace("$SYS_VAR_TARGET$", GetVariableName(data.Target)) .Replace("$SYS_TARGET$", data.Target) .Replace("$SYS_PLURAL_TARGET$", Utils.Util.Pluralize(data.Target)); file.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", data.Target); file.Path = base.GetFileLocation(); file.Type = CodeFileType.Manager; base.Files = new List<CodeFile>() { file }; return file; }
public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile(); string memberTemplate = Template.Element("Members").Value; Func<List<MetaData>, bool, string> fnGetMemberString = (metadata, isColumAttrAdd) => { StringBuilder members = new StringBuilder(); metadata.ForEach(m => { if (!(m.Name.ToLower().Equals("amendfilterorganizationid") || m.Name.ToLower().Equals("amendstatus"))) { if (isColumAttrAdd && !m.Name.Equals(data.Target + "Id") && m.Name.StartsWith(data.Target)) { members.Append("[Column(\"" + m.Name + "\")] " + Environment.NewLine); var cName = m.Name.Replace(data.Target, ""); members.Append(memberTemplate.Replace("$SYS_DATATYPE$", GetDataType(m)).Replace("$SYS_MEMBERNAME$", cName)); } else members.Append(memberTemplate.Replace("$SYS_DATATYPE$", GetDataType(m)).Replace("$SYS_MEMBERNAME$", m.Name)); } }); return members.ToString(); }; Dictionary<string, string> mTemplate = new Dictionary<string, string>(); Func<InformationSchema, CodeFile> fnCreateFile = (infoX) => { CodeFile fileX = new CodeFile(); mTemplate["$SYS_TARGET$"] = infoX.Target; mTemplate["$SYS_MEMBERS_TEMPLATE$"] = fnGetMemberString(infoX.MetaData, false); mTemplate["$SYS_MAINTARGET$"] = infoX.Target; fileX.Content = Template.Element("Main").Value.ReplaceContent(mTemplate); fileX.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", infoX.Target); fileX.Path = base.GetFileLocation(); fileX.Type = CodeFileType.RepositoryObject; return fileX; }; Func<InformationSchema, CodeFile> fnCreateViewFile = (infoX) => { CodeFile fileX = new CodeFile(); mTemplate["$SYS_TARGET$"] = infoX.Target; mTemplate["$SYS_MAINTARGET$"] = infoX.TargetName; mTemplate["$SYS_MEMBERS_TEMPLATE$"] = fnGetMemberString(infoX.MetaData, true); mTemplate["$SYS_BASEVIEW$"] = data.IncludeSmartFile ? ": SmartItemViewBase" : string.Empty; fileX.Content = Template.Element("MainView").Value.ReplaceContent(mTemplate); fileX.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", infoX.Target + "View"); fileX.Path = base.GetFileLocation(); fileX.Type = CodeFileType.RepositoryObject; return fileX; }; if (data.IsViewTarget) { base.Files = new List<CodeFile>() { fnCreateViewFile(data) }; } else { base.Files = new List<CodeFile>() { fnCreateFile(data) }; if (data.IncludeSmartFile) { var info = new InformationSchema(data.Target + "Library"); base.Files.Add(fnCreateFile(info)); info = new InformationSchema(data.Target + "LibraryAmendFilter"); base.Files.Add(fnCreateFile(info)); info = new InformationSchema("ngvwGetAll" + data.Target + "Library"); base.Files.Add(fnCreateViewFile(info)); } else { var info = new InformationSchema("ngvwGet" + data.Target); base.Files.Add(fnCreateViewFile(info)); } } return file; }
public override CodeFile Build(InformationSchema data) { CodeFile file = new CodeFile(); StringBuilder insertMembers = new StringBuilder(); StringBuilder updateMembers = new StringBuilder(); StringBuilder svcObjMembers = new StringBuilder(); string insertMemberTemplate = data.IncludeSmartFile ? Template.Element("InsertSmartFileMember").Value : Template.Element("InsertMember").Value; string updateMemberTemplate = Template.Element("UpdateMember").Value; data.MetaData.ForEach(m => { if (!m.Name.Equals(data.Target + "Id")) { svcObjMembers.Append(String.Format("\t\t.With{0}({2}){1}", m.Name, Environment.NewLine, GetDefaultDataValue(m))); if (m.IsRequired) { if (m.DataType == typeof(string)) { insertMembers.Append(insertMemberTemplate .Replace("$SYS_MEMBERNAME$", m.Name) .Replace("$SYS_NULLVALUE$", "string.Empty") .Replace("$SYS_NULLVALUE_MSG$", "Empty")); updateMembers.Append(updateMemberTemplate .Replace("$SYS_MEMBERNAME$", m.Name) .Replace("$SYS_NULLVALUE$", "string.Empty") .Replace("$SYS_NULLVALUE_MSG$", "Empty")); } else if (m.DataType == typeof(Guid)) { insertMembers.Append(insertMemberTemplate .Replace("$SYS_MEMBERNAME$", m.Name) .Replace("$SYS_NULLVALUE$", "Guid.Empty") .Replace("$SYS_NULLVALUE_MSG$", "Guid.Empty")); updateMembers.Append(updateMemberTemplate .Replace("$SYS_MEMBERNAME$", m.Name) .Replace("$SYS_NULLVALUE$", "Guid.Empty") .Replace("$SYS_NULLVALUE_MSG$", "Guid.Empty")); } } } }); string templateValue = Template.Element(data.IncludeSmartFile ? "SmartFileTest" : "CRUDTest").Value; if (data.TargetProduct.ToLower().Equals("core")) { templateValue = templateValue .Replace("SetupMocks(InsertedParentOrganization.OrganizationId, $SYS_TARGET$Library);", "") .Replace("SetupMocks(InsertedParentOrganization.OrganizationId, Mapper.Map<CoreRepositoryObject.Library>($SYS_TARGET$Library));", "") .Replace("SetupMocks(InsertedOrganization.OrganizationId, Mapper.Map<CoreRepositoryObject.Library>($SYS_TARGET$Library));", "") .Replace("SetupMocks(InsertedOrganization.OrganizationId, $SYS_TARGET$Library);", "") .Replace("SetupMocks(newOrganization.OrganizationId, $SYS_VAR_TARGET$Library);", "") .Replace("SetupMocks(inheritorOrganization.OrganizationId, $SYS_TARGET$Library);", "") .Replace("$SYS_MOCKSTEMPLATE$", ""); } else { templateValue = templateValue.Replace("$SYS_MOCKSTEMPLATE$", Template.Element("MockTemplate").Value); } file.Content = templateValue .Replace("$SYS_INSERT_OPS_VALIDATIONS$", insertMembers.ToString()) .Replace("$SYS_UPDATE_OPS_VALIDATIONS$", updateMembers.ToString()) .Replace("$SYS_SVCOBJ_MEMBERS$", svcObjMembers.ToString()) .Replace("$SYS_VAR_TARGET$", GetVariableName(data.Target)) .Replace("$SYS_VAR_PLURAL_TARGET$", Util.Pluralize(GetVariableName(data.Target))) .Replace("$SYS_TARGET$", data.Target) .Replace("$SYS_PLURAL_TARGET$", Util.Pluralize(data.Target)); file.Name = Template.Element("FileName").Value.Replace("$SYS_TARGET$", data.Target); file.Path = base.GetFileLocation(); file.Type = CodeFileType.UnitTest; base.Files = new List<CodeFile>() { file }; return file; }