public string GenerateMongoCode(MongoDatabaseInfo databaseInfo, string collectionName, string linqQuery, string mode, out int injectedCodeStartPos) { var collectionInfo = databaseInfo.GetCollectionInfo(collectionName); var model = new CodeGenModel { LinqQuery = linqQuery, MongoDatabaseInfo = databaseInfo, MongoCollectionInfo = collectionInfo, Mode = mode, ModelType = mode == MongoSharpQueryMode.Json || !collectionInfo.Models.Any() ? "BsonDocument" : collectionInfo.Namespace + "." + collectionInfo.Models[0].RootClassName }; string code = new MongoCodeBehindGen(model).TransformText(); injectedCodeStartPos = 0; var injectPos = code.IndexOf("#region Injected Code", StringComparison.CurrentCultureIgnoreCase); if (injectPos > 0) { injectedCodeStartPos = injectPos + "#region Injected Code".Length; } return(code); }
private void GenerateUoW(CodeGenModel model) { var parameters = new Dictionary <string, object> { { "Model", model } }; var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.DomainProjectName")); foreach (var template in Templates.UoWTemplates) { this.AddFileFromTemplate( project, model.EntityName, @"Domain\" + template, parameters, skipIfExists: false); } }
private void GenerateWebUIConfig(CodeGenModel model) { var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.WebUIProjectName")); string configurationFilename = FindConfigurationFilename(project); var configFile = new ExeConfigurationFileMap(); configFile.ExeConfigFilename = configurationFilename; var configuration = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration( configFile, ConfigurationUserLevel.None); configuration.AppSettings.Settings.Remove("serviceBlock:restEndpointUri"); configuration.AppSettings.Settings.Add("serviceBlock:restEndpointUri", model.GetExtendedPropertyOrDefault("Global.WebApiBaseUri")); configuration.Save(); }
private void GenerateWebUIMenuLinks(CodeGenModel model) { var parameters = new Dictionary <string, object> { { "Model", model } }; var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.WebUIProjectName")); var folder = @"Views\MenuLinks"; this.AddFolder(project, folder); this.AddFileFromTemplate( project, folder + @"\Index", @"WebUI\MenuLinks", parameters, skipIfExists: false); }
private void GenerateOrchestrations(CodeGenModel model) { var parameters = new Dictionary <string, object> { { "Model", model } }; var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.WorkflowProjectName")); foreach (var template in Templates.OrchestrationTemplates) { var folder = model.GetClassFileFolderWithEntityName(model.OrchestrationNamespace); this.AddFolder(project, folder); this.AddFileFromTemplate( project, model.GetClassFileFolderWithEntityName(model.OrchestrationNamespace) + @"\" + template, @"Orchestrations\" + template, parameters, skipIfExists: false); } }
private void GenerateWebUIControllers(CodeGenModel model) { var parameters = new Dictionary <string, object> { { "Model", model } }; var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.WebUIProjectName")); foreach (var template in Templates.WebUIControllerTemplates) { var folder = model.GetClassFileFolder(model.WebUIControllerNamespace); this.AddFolder(project, folder); this.AddFileFromTemplate( project, model.GetClassFilePath(model.EntityName + template, model.WebUIControllerNamespace), @"WebUI\" + template, parameters, skipIfExists: false); } }
private void GenerateWebUIViews(CodeGenModel model) { var parameters = new Dictionary <string, object> { { "Model", model } }; var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.WebUIProjectName")); foreach (var template in Templates.WebUIViewTemplates) { var folder = @"Views\" + model.EntityName; this.AddFolder(project, folder); this.AddFileFromTemplate( project, folder + @"\Index", @"WebUI\" + template, parameters, skipIfExists: false); } }
private void GenerateDomainMessages(CodeGenModel model) { var parameters = new Dictionary <string, object> { { "Model", model } }; var project = FindProjectByName(model.GetExtendedPropertyOrDefault("Global.DomainProjectName")); foreach (var template in Templates.MessageTemplates) { var folder = model.GetClassFileFolderWithEntityName(model.MessagesNamespace); this.AddFolder(project, folder); this.AddFileFromTemplate( project, model.GetClassFilePathWithEntityName(template, model.MessagesNamespace), @"Domain\" + template, parameters, skipIfExists: false); } }
public PatchTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ControllerTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ModelComponentHTMLTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public MongoCodeBehindGen(CodeGenModel model) { Model = model; }
public ModelCreateComponentTSTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ModelServiceSpecTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public GetByKeyTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public RepositoryTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ModelModuleTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ModelDetailComponentSpecTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ViewModelTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ConfigurationTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public UpdateTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public ModelListComponentCSSTemplate(CodeGenConfig config, CodeGenModel model) { _config = config; _model = model; }
public IHttpActionResult Executedemo(JObject json) { try { #region Prepare //var serializer = new JsonSerializer(); //serializer.RegisterConverters(new[] { new DynamicJsonConverter() }); //dynamic Item = serializer.Deserialize(json, typeof(object)); //dynamic d = JObject.Parse("{number:1000, str:'string', array: [1,2,3,4,5,6]}"); //dynamic Item = JObject.Parse(json); //dynamic Item = JsonConvert.DeserializeObject<dynamic>(json); //dynamic d = JObject.Parse(json); dynamic Item = json; #endregion #region Validate #endregion #region SQL #endregion #region Log #endregion #region Process //return Json(item); #endregion var rs = new List <string>(); //set project name Item.projectname = "SSKD"; if (Item.typegen == "db") { rs = CodeGenModel.AutoGenDB(Item); } else if (Item.typegen == "querysearch") { rs = CodeGenModel.AutoGenQuerySearch(Item); } else if (Item.typegen == "model") { rs = CodeGenModel.AutoGenModel(Item); } else if (Item.typegen == "controller") { rs = CodeGenModel.AutoGenControllter(Item); } else if (Item.typegen == "viewform") { rs = CodeGenModel.AutoGenViewForm(Item); } else if (Item.typegen == "viewtree") { rs = CodeGenModel.AutoGenViewTree(Item); } else if (Item.typegen == "all") { rs = ((List <string>)CodeGenModel.AutoGenDB(Item)) .Concat((List <string>)CodeGenModel.AutoGenQuerySearch(Item)) .Concat((List <string>)CodeGenModel.AutoGenModel(Item)) .Concat((List <string>)CodeGenModel.AutoGenControllter(Item)) .Concat((List <string>)CodeGenModel.AutoGenViewTree(Item)) .Concat((List <string>)CodeGenModel.AutoGenViewForm(Item)) .ToList(); } return(Json(rs)); } catch (Exception objException) { return(Json(objException)); } }