/// <summary> /// 生成实体代码 /// </summary> /// <param name="project"></param> /// <param name="schema"></param> public override void CreateEntityCode(ProjectConfig project, EntityConfig schema) { Message = schema.Caption; var rootPath = RootPath(project); var entityPath = IOHelper.CheckPath(rootPath, "Entity"); CreateCode <EntityBuilder>(project, schema, IOHelper.CheckPath(entityPath, "Model")); if (schema.IsClass) { return; } CreateCode <EntityValidateBuilder>(project, schema, IOHelper.CheckPath(entityPath, "Extend")); var accessPath = IOHelper.CheckPath(rootPath, "DataAccess"); if (project.DbType == DataBaseType.MySql) { CreateCode <MySqlAccessBuilder>(project, schema, IOHelper.CheckPath(accessPath, "DataAccess")); } else { CreateCode <SqlServerAccessBuilder>(project, schema, IOHelper.CheckPath(accessPath, "DataAccess")); } CreateCode <BusinessBuilder>(project, schema, IOHelper.CheckPath(accessPath, "DataBusiness")); }
/// <summary> /// 导入 /// </summary> public static void Importe() { if (Instance != null) { return; } string path = ConfigurationManager.Root.GetValue("contentRoot", Environment.CurrentDirectory); if (!string.IsNullOrEmpty(ZeroApplication.Config.AddInPath)) { path = IOHelper.CheckPath(path, ZeroApplication.Config.AddInPath); } ZeroTrace.WriteInfo("AddIn", path); Instance = new AddInImporter(); IocHelper.ServiceCollection.AddSingleton(pro => Instance); // 通过容器对象将宿主和部件组装到一起。 DirectoryCatalog directoryCatalog = new DirectoryCatalog(path); var container = new CompositionContainer(directoryCatalog); container.ComposeParts(Instance); foreach (var reg in Instance.Registers) { ZeroTrace.WriteInfo("AddIn", reg.GetType().Assembly.FullName); } }
/// <summary> /// 保存 /// </summary> private static void SaveGlobal() { var global = Path.GetDirectoryName(Path.GetDirectoryName(typeof(ConfigWriter).Assembly.Location)); var directory = IOHelper.CheckPath(global, "Global"); GlobalConfig.GlobalSolution.FileName = Path.Combine(directory, "global.json"); SaveSolution(GlobalConfig.GlobalSolution, directory); }
private void SaveTypedefs() { var path = IOHelper.CheckPath(Directory, "Typedefs"); foreach (var type in Solution.TypedefItems.ToArray()) { SaveTypedef(type, path); } }
/// <summary> /// 保存API对象 /// </summary> public void SaveApies() { var path = IOHelper.CheckPath(Directory, "apis"); foreach (var api in Solution.ApiItems.ToArray()) { Save(api, path, ".ent"); } }
/// <summary> /// 保存通知对象 /// </summary> public void SaveNotifies() { string path = IOHelper.CheckPath(Directory, "notifies"); foreach (var notify in Solution.NotifyItems.ToArray()) { Save(notify, path, ".ent"); } }
/// <summary> /// 保存以备下次启动时使用 /// </summary> public void Save(string file) { string json; lock (this) json = JsonConvert.SerializeObject(this); IOHelper.CheckPath(Path.GetDirectoryName(file)); File.WriteAllText(file, json); }
private void SaveEnums() { var path = IOHelper.CheckPath(Directory, "Enums"); foreach (var type in Solution.Enums.ToArray()) { SaveEnum(type, path); } }
/// <summary> /// 生成扩展代码 /// </summary> protected override void CreateExCode(string path) { if (Entity.IsInternal || Entity.IsClass || Entity.DenyScope.HasFlag(AccessScopeType.Client)) { return; } IOHelper.CheckPath(path, "Page"); ActionCsCode(path); ExportCsCode(path); }
/// <summary> /// 生成项目代码 /// </summary> /// <param name="project"></param> public override void CreateProjectCode(ProjectConfig project) { var dbPath = IOHelper.CheckPath(project.ModelPath, "DataBase"); var db = new DataBaseBuilder { Project = project }; db.CreateBaseCode(dbPath); db.CreateExtendCode(dbPath); }
/// <summary> /// 升级配置类 /// </summary> /// <returns></returns> public void Load() { var path = IOHelper.CheckPath(@"C:\Projects\AgebullDesigner", "UpgradeDocument"); var files = IOHelper.GetAllFiles(path, "cfg"); RootConfig.ConfigTypes.Clear(); foreach (var file in files) { RootConfig.ConfigTypes.Add(ConfigLoader.DeSerializer <ClassUpgradeConfig>(file)); } }
public void CreateUnitCode() { var path = Path.GetDirectoryName( Path.GetDirectoryName( Path.GetDirectoryName( System.Environment.CurrentDirectory))); ApiDiscover discover = new ApiDiscover(); discover.Discover(this.GetType().Assembly); discover.NUnitCode(IOHelper.CheckPath(path, "AutoCode")); }
/// <summary> /// 生成实体代码 /// </summary> /// <param name="project"></param> /// <param name="schema"></param> public override void CreateEntityCode(ProjectConfig project, EntityConfig schema) { IOHelper.CheckPath(schema.Parent.MobileCsPath); var builder = new MobileEntityCoder { Project = schema.Parent, Entity = schema }; builder.CreateBaseCode(schema.Parent.MobileCsPath); builder.CreateExtendCode(schema.Parent.MobileCsPath); }
/// <summary> /// 控制器代码 /// </summary> public override void CreateBaCode(string path) { string dir = IOHelper.CheckPath(path, "Controllers", this.Project.DataBaseObjectName); string file = Path.Combine(dir, Table.EntityName + "Controller.cs"); //if (File.Exists(file)) // return; string code = string.Format(ControlTemplate , this.Project.DataBaseObjectName , Table.EntityName , Save()); this.SaveCode(file, code); }
/// <summary> /// 生成实体代码 /// </summary> /// <param name="project"></param> /// <param name="schema"></param> public override void CreateEntityCode(ProjectConfig project, EntityConfig schema) { Message = "正在生成" + schema.Caption + "..."; if (!schema.IsReference) { var entityPath = IOHelper.CheckPath(project.ClientCsPath); var builder = new ClientEntityCoder { Entity = schema, Project = project }; builder.CreateBaseCode(entityPath); builder.CreateExtendCode(entityPath); } if (!string.IsNullOrEmpty(project.CodePath)) { var cppPath = IOHelper.CheckPath(project.CodePath); var builder = new CppStructCoder { Entity = schema, Project = project }; builder.CreateBaseCode(cppPath); builder.CreateExtendCode(cppPath); } if (!schema.IsClass && !string.IsNullOrEmpty(project.CodePath)) { var cppPath = IOHelper.CheckPath(project.CodePath); { var builder = new CppModelCoder { Entity = schema, Project = project }; builder.CreateBaseCode(cppPath); builder.CreateExtendCode(cppPath); } if (!schema.IsReference) { var builder = new CppAccessCoder { Entity = schema, Project = project }; builder.CreateBaseCode(cppPath); builder.CreateExtendCode(cppPath); } } Message = schema.Caption + "已完成"; }
public void CreateMarkdown() { ApiDiscover discover = new ApiDiscover(); discover.Discover(typeof(NetEventControler).Assembly); var path = IOHelper.CheckPath(Environment.CurrentDirectory, "MarkDown"); var extend = new ApiMarkDown { ServiceInfos = discover.ServiceInfos }; extend.MarkDown(path); }
/// <summary> /// 生成扩展代码 /// </summary> public override void CreateExCode(string path) { string dir = IOHelper.CheckPath(path, "Views", Table.EntityName); string file = Path.Combine(dir, "Index.cshtml"); //if (File.Exists(file)) // return; string code = string.Format(HtmlTemplate , this.Project.DataBaseObjectName == "Plot" ? "策划数据" : "用户数据" , Table.Caption ?? Table.Description ?? Table.EntityName , EasyUiGrid() , EasyUiForm() , Table.PrimaryColumn.PropertyName); this.SaveCode(file, code); }
/// <summary> /// 升级配置类 /// </summary> /// <returns></returns> public void Save() { var path = IOHelper.CheckPath(@"C:\Projects\AgebullDesigner", "UpgradeDocument"); if (RootConfig.ConfigTypes.Count == 0) { MessageBox.Show(@"点错了吧"); return; } foreach (var type in RootConfig.ConfigTypes) { var file = Path.Combine(path, type.Name + ".cfg"); ConfigWriter.Serializer(file, type); } }
/// <summary> /// 初始化 /// </summary> public void Initialize() { try { if (disable) { return; } if (split <= 0) { split = 10; } split <<= 20; if (minFreeSize <= 0) { minFreeSize = 1; } if (maxFile <= 0) { maxFile = 999; } if (string.IsNullOrWhiteSpace(LogPath)) { path = LogRecorder.LogPath; if (string.IsNullOrWhiteSpace(path)) { path = Path.Combine(Environment.CurrentDirectory, "logs"); } } IOHelper.CheckPath(path); } catch (Exception ex) { Console.WriteLine(ex.ToString(), "TextRecorder.Initialize LogPath"); } try { var size = IOHelper.FolderDiskInfo(LogPath); if (size.AvailableSize < MinFreeSize) { disable = true; } } catch (Exception ex) { Console.WriteLine(ex.ToString(), "TextRecorder.Initialize LogPath"); } }
/// <summary> /// 当前记录的时间点 /// </summary> private void CheckTimePoint() { var day = (DateTime.Today.Year << 16) + (DateTime.Today.Month << 8) + DateTime.Today.Day; if (day == _recordTimePoint) { return; } pointTime = DateTime.Today; if (dayFolder) { IOHelper.CheckPath(LogPath, $"{pointTime.Year}{pointTime.Month:D2}{pointTime.Day:D2}"); } DisposeWriters(true); _recordTimePoint = day; }
/// <summary> /// 载入 /// </summary> /// <param name="sluFile"></param> public static SolutionConfig Load(string sluFile) { ConfigLoader loader = new ConfigLoader(); loader.LoadSolution(IOHelper.CheckPath(GlobalConfig.ProgramRoot, "Global"), "global.json", true); GlobalConfig.GlobalSolution = loader._solution; if (string.IsNullOrEmpty(sluFile) || string.Equals(sluFile, GlobalConfig.GlobalSolution.FileName, StringComparison.OrdinalIgnoreCase)) { return(GlobalConfig.GlobalSolution); } loader = new ConfigLoader(); loader.LoadSolution(Path.GetDirectoryName(sluFile), Path.GetFileName(sluFile), false); return(loader._solution); }
/// <summary> /// 生成Markdown文档(在当前目录的md目录下) /// </summary> public static void CreateMarkdown(params Assembly[] assemblies) { foreach (var assembly in assemblies) { ApiDiscover discover = new ApiDiscover(); discover.Discover(assembly); var path = IOHelper.CheckPath(Environment.CurrentDirectory, "md"); var extend = new ApiMarkDown { ServiceInfos = discover.ServiceInfos }; extend.MarkDown(path); } }
/// <summary> /// 生成Markdown文档(在当前目录的md目录下) /// </summary> public static void CreateMarkdown(params Type[] types) { foreach (var type in types) { ApiDiscover discover = new ApiDiscover(); discover.Discover(type); var path = IOHelper.CheckPath(Environment.CurrentDirectory, "md"); var extend = new ApiMarkDown { ServiceInfos = discover.ServiceInfos }; extend.MarkDown(path); } }
private async Task AsyncPostQueue() { await Task.Yield(); //还原发送异常文件 var path = IOHelper.CheckPath(ZeroAppOption.Instance.DataFolder, "consul"); var isFailed = ReQueueErrorMessage(path); Logger.Information("异步消息投递已启动"); while (ZeroFlowControl.IsAlive) { if (isFailed) { await Task.Delay(1000); isFailed = true; } if (redisQueues.Count == 0) { try { await semaphore.WaitAsync(60000, tokenSource.Token); } catch (TaskCanceledException) { Logger.Information("收到系统退出消息,正在退出..."); return; } catch (Exception ex) { Logger.Warning(() => $"错误信号.{ex.Message}"); isFailed = true; continue; } } while (redisQueues.TryDequeue(out ConsulQueueItem item)) { if (!await DoPost(Logger, path, item)) { isFailed = true; break; } } } Logger.Information("异步消息投递已关闭"); }
public void CreateApiSqlCode() { var path = Path.GetDirectoryName( Path.GetDirectoryName( Path.GetDirectoryName( System.Environment.CurrentDirectory))); ApiDiscover discover = new ApiDiscover(); discover.Discover(typeof(NetEventControler).Assembly); var extend = new ApiSqlCode { ServiceInfos = discover.ServiceInfos }; extend.ApiSql(IOHelper.CheckPath(path, "Sql")); }
public void CreateUnitCode() { var path = Path.GetDirectoryName( Path.GetDirectoryName( Path.GetDirectoryName( System.Environment.CurrentDirectory))); ApiDiscover discover = new ApiDiscover(); discover.Discover(GetType().Assembly); var extend = new ApiUnitTestCode { ServiceInfos = discover.ServiceInfos }; extend.NUnitCode(IOHelper.CheckPath(path, "AutoCode")); }
/// <summary> /// 保存解决方案 /// </summary> /// <param name="project"></param> /// <param name="checkState"></param> public void SaveProject(ProjectConfig project, bool checkState = true) { string filename = Path.Combine(Directory, "Projects", project.Name + ".prj"); DeleteOldFile(project, filename, true); IOHelper.CheckPath(Directory, "Projects", project.Name); foreach (var entity in project.Entities.ToArray()) { SaveEntity(entity, checkState); } if (project.IsDelete) { SolutionConfig.Current.Projects.Remove(project); } Serializer(filename, project); }
static void CheckAddIn() { if (string.IsNullOrEmpty(ZeroApplication.Config.AddInPath)) { return; } var path = IOHelper.CheckPath(ZeroApplication.Config.RootPath, ZeroApplication.Config.AddInPath); ZeroTrace.SystemLog("AddIn(Service)", path); IocHelper.ServiceCollection.AddSingleton(pro => Instance); // 通过容器对象将宿主和部件组装到一起。 DirectoryCatalog directoryCatalog = new DirectoryCatalog(path); var container = new CompositionContainer(directoryCatalog); container.ComposeParts(Instance); foreach (var reg in Instance.Registers) { ZeroTrace.SystemLog("AddIn(System)", reg.GetType().Assembly.FullName); } }
/// <summary> /// 用户操作现场 /// </summary> internal void LoadApiScript() { if (Document == null) { SelecTestItem = new ApiTestItem { Visibility = Visibility.Collapsed }; return; } var folder = IOHelper.CheckPath(ZeroApplication.Config.DataFolder, "Scripts", Station.StationName); var file = Path.Combine(folder, Document.RouteName.Replace('/', '_') + ".json"); if (!File.Exists(file)) { CreateDefaultItem(); return; } try { var json = File.ReadAllText(file); if (string.IsNullOrWhiteSpace(json)) { CreateDefaultItem(); return; } SelecTestItem = JsonConvert.DeserializeObject <ApiTestItem>(json); if (SelecTestItem?.Api == null) { CreateDefaultItem(); } } catch (Exception ex) { Trace.WriteLine(ex); CreateDefaultItem(); } }
/// <summary> /// 用户操作现场 /// </summary> internal void SaveApiScript() { if (SelecTestItem == null) { return; } var folder = IOHelper.CheckPath(ZeroApplication.Config.DataFolder, "Scripts", Station.StationName); var file = Path.Combine(folder, Document.RouteName.Replace('/', '_') + ".json"); try { File.WriteAllText(file, JsonConvert.SerializeObject(SelecTestItem)); } catch (Exception ex) { Trace.WriteLine(ex); } SelecTestItem.IsModify = false; }