void Dump(CodeBlockNested b) { String dir = Path.Combine( DirHelper.FindParentDir(BaseDirName), "IG", "Content", "Resources" ); foreach (String file in Directory.GetFiles(dir, "*.json")) { String fhirText = File.ReadAllText(file); FhirJsonParser parser = new FhirJsonParser(); var resource = parser.Parse(fhirText, typeof(Resource)); switch (resource) { case StructureDefinition structureDefinition: this.Dump(b, structureDefinition); break; case CodeSystem codeSystem: this.Dump(b, codeSystem); break; case ValueSet valueSet: this.Dump(b, valueSet); break; default: throw new NotImplementedException($"Unknown resource type '{file}'"); } } }
void WriteIntroDocDescription(String className, String blockName, String outputCodePath, String penId) { CodeEditor editor = new CodeEditor(); editor.Load(Path.Combine(DirHelper.FindParentDir("BreastRadiology.XUnitTests"), "ResourcesMaker", outputCodePath)); UpdateClass(className, penId); if (this.spreadSheetData.TryGetRow(penId, out DataRow row) == false) { throw new Exception($"Missing value for penid '{penId}'"); } CodeBlockNested description = editor.Blocks.Find(blockName); if (description == null) { throw new Exception($"Can not find editor block {blockName}"); } description.Clear(); AppIfNotNull(description, penId, "Description", row[UMLSCol]); editor.Save(); }
public static void OutputModel(Dictionary <string, TableMetaData> tables, GlobalConfiguration config, IProgressBar progress = null) { ResetProgress(progress); var path = Path.Combine(config.OutputBasePath, "Model"); Directory.CreateDirectory(path); BaseModelGenerator g = new ModelGenerator(config); // 解析 var i = 0; var sb = new StringBuilder(); foreach (var key in tables.Keys) { var table = tables[key]; if (config.ExcludeTables != null && config.ExcludeTables.Any(p => p.Name == table.Name)) { continue; } sb.AppendLine(g.RenderModelFor(table)); File.AppendAllText(Path.Combine(path, string.Format("{0}.cs", g.FileName)), sb.ToString()); sb.Clear(); PrintProgress(progress, ++i, tables.Count); } // 拷贝公用文件到指定目录 DirHelper.CopyDirectory(Path.Combine("CopyFiles", "Model"), path); }
public static async Task <int> Main(string[] args) { string profilePath = DirHelper.GetTempPath(); ProfileOptimization.SetProfileRoot(profilePath); ProfileOptimization.StartProfile("bicep.profile"); Console.OutputEncoding = TemplateEmitter.UTF8EncodingWithoutBom; BicepDeploymentsInterop.Initialize(); if (FeatureProvider.TracingEnabled) { Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); } // this event listener picks up SDK events and writes them to Trace.WriteLine() using (FeatureProvider.TracingEnabled ? AzureEventSourceListenerFactory.Create(FeatureProvider.TracingVerbosity) : null) { var program = new Program(new InvocationContext( new AzResourceTypeLoader(), Console.Out, Console.Error, features: null, clientFactory: null)); // this must be awaited so dispose of the listener occurs in the continuation // rather than the sync part at the beginning of RunAsync() return(await program.RunAsync(args)); } }
public static void OutputDAL(Dictionary <string, TableMetaData> tables, GlobalConfiguration config, IProgressBar progress = null) { ResetProgress(progress); var path = Path.Combine(config.OutputBasePath, "DAL"); Directory.CreateDirectory(path); var sb = new StringBuilder(); BaseDALGenerator g = null; // TODO:有点丑陋,可以考虑走ioc switch (config.DBType) { case "mssql": g = new Generator.Core.MSSql.DALGenerator(config); break; case "mysql": g = new Generator.Core.MySql.DALGenerator(config); break; case "oracle": g = new Generator.Core.Oracle.DALGenerator(config); break; default: throw new NotSupportedException("不支持的数据库类型"); } // 解析 var i = 0; foreach (var key in tables.Keys) { var table = tables[key]; if (config.ExcludeTables != null && config.ExcludeTables.Any(p => p.Name == table.Name)) { continue; } sb.Append(g.RenderDALFor(table)); // Joined var join_info = config.JoinedTables == null ? null : config.JoinedTables.FirstOrDefault(p => p.MainTable.Name == table.Name); if (join_info != null) { } File.AppendAllText(Path.Combine(path, string.Format("{0}Helper.cs", table.Name)), sb.ToString()); sb.Clear(); PrintProgress(progress, ++i, tables.Count); } // 生成BaseTableHelper、PageDataView File.AppendAllText(Path.Combine(path, "BaseTableHelper.cs"), g.RenderBaseTableHelper()); // 拷贝公用文件到指定目录 DirHelper.CopyDirectory(Path.Combine("CopyFiles", "DAL"), path); }
PreFhirGenerator CreatePreFhir() { PreFhirGenerator preFhir = new PreFhirGenerator(null, Path.Combine(DirHelper.FindParentDir("PreFhir"), "Cache")); preFhir.StatusInfo += this.PreFhir_StatusInfo; preFhir.StatusWarnings += this.PreFhir_StatusWarnings; preFhir.StatusErrors += this.PreFhir_StatusErrors; return(preFhir); }
public ActionResult SwfUploading(FormCollection collection) { if (Request.Files.Count > 0) { string gID = DateTime.Now.Year + "\\" + DateTime.Now.ToString("MMdd"); for (int i = 0; i < Request.Files.Count; i++) { var c = Request.Files[i]; if (c != null && c.ContentLength > 0) { int lastSlashIndex = c.FileName.LastIndexOf("\\"); string fileName = c.FileName.Substring(lastSlashIndex + 1, c.FileName.Length - lastSlashIndex - 1); string fix = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower(); string time = DateTime.Now.ToString("yyyyMMddHHmmssfff"); string rename = time + "." + fix; string filepath = Common.UploadHepler.Path + gID; string path = gID + "\\" + rename; /*判断是否为办公文件,如果是则保存到指定目录转换成swf供在线播放*/ if (fix == "doc" || fix == "ppt" || fix == "xls" || fix == "pdf") { filepath = UploadHepler.Path + "doc"; path = "doc\\" + rename; new DBContext().ExecuteNonQuery(@"insert into service_flashpaper_printe_queue(OriginalName,NewName,Created,IsConverted) values('" + rename + "','" + time + ".swf" + "',getdate(),0)"); } DirHelper.CheckFolder(filepath); string fullname = filepath + "\\" + rename; c.SaveAs(fullname); /*是否添加水印*/ string newFilePath = ""; if (SiteHelper.Default.WatermarkEnable == 1 && (fix == "jpg" || fix == "gif" || fix == "bmp" || fix == "png" || fix == "jepg")) { Common.UploadHepler.WatermarkImage(fullname, UploadHepler.Path.Replace(@"\upload\", "") + SiteHelper.Default.WatermarkImg.Replace("/", @"\"), out newFilePath); } if (newFilePath != "") { path = gID + "\\wm_" + rename; } attachment = new Attachment(); attachment.ID = int.Parse(string.IsNullOrEmpty(collection["aid"]) ? "0" : collection["aid"]); attachment.Size = Common.UploadHepler.ConvertAttachmentLength((double)c.ContentLength); attachment.FileName = fileName; //attachment.attype = 2; attachment.CreateDate = DateTime.Now; attachment.CreateUserID = CurrentMember.ID; attachment.Fix = fix; //attachment.ssid = int.Parse(string.IsNullOrEmpty(collection["ssid"]) ? "0" : collection["ssid"]); attachment.Url = path; attachmentclass.Insert(attachment); } } } return(Content(attachment.ID + "," + UploadHepler.AttachmentUrl(attachment.Url) + "," + attachment.Fix)); }
/// <summary> /// 目录浏览 /// </summary> /// <returns></returns> public ActionResult AlbumDir(string dir) { ArrayList folderlist = DirHelper.GetFolders(Server.MapPath("~") + "/" + dir); ViewData["folderlist"] = folderlist; ArrayList filelist = DirHelper.GetFiles(Server.MapPath("~") + "/" + dir); ViewData["filelist"] = filelist; return(View()); }
public BRExamples() { this.OutDir = Path.Combine( DirHelper.FindParentDir("HL7"), "BreastRadiologyProfiles", "IG", "Content", "Examples" ); }
private void btnExport_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxSelectPath.Text)) { MessageBox.Show("请选择文件夹"); return; } new Thread(() => { try { if (btnExport.InvokeRequired) { btnExport.Invoke(new Action <string>((m) => { btnExport.Enabled = true; btnExport.Text = "导出中..."; }), ""); } else { btnExport.Enabled = true; btnExport.Text = "导出中..."; } DirHelper dirHelper = new DirHelper(textBoxSelectPath.Text); List <string> fileNames = dirHelper.GetFileNames(showMsg); //MessageBox.Show(string.Join(",", fileNames.ToArray())); new ExcelHelper("所有文件名", fileNames, 1).ExportEXCEL(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (btnExport.InvokeRequired) { btnExport.Invoke(new Action <string>((m) => { btnExport.Enabled = true; btnExport.Text = "开始导出"; }), ""); } else { btnExport.Enabled = true; btnExport.Text = "开始导出"; } } }).Start(); }
//创建Service void CreateService(string table) { DirHelper.CheckFolder(filePath + "..\\Models\\Service"); string savePath = filePath + "..\\Models\\Service\\" + table + "Service.cs"; string templatePath = PathHelper.SelectedTempPath + "Service.txt"; if (!System.IO.File.Exists(savePath)) { SaveFile(table, templatePath, savePath); } }
public void GenerateElementFixCode() { String outputPath = Path.Combine(DirHelper.FindParentDir("Projects"), "SliceGen", "R4", "FhirKhit.SliceGen.R4", "CSApi", "ElementFixCode.cs"); GenerateFixCode g = new GenerateFixCode(); g.Generate(outputPath); }
String ParseDir(String path) { path = path.Trim(); if (path.StartsWith("^")) { path = path.Substring(1); Int32 index = path.IndexOf('\\'); String relDir = path.Substring(0, index); relDir = DirHelper.FindParentDir(relDir); path = path.Substring(index + 1); path = Path.Combine(relDir, path); } return(path); }
public static async Task Main(string[] args) => await RunWithCancellationAsync(async cancellationToken => { var profilePath = DirHelper.GetTempPath(); ProfileOptimization.SetProfileRoot(profilePath); ProfileOptimization.StartProfile("bicepserver.profile"); var parser = new Parser(settings => { settings.IgnoreUnknownArguments = true; }); await parser.ParseArguments <CommandLineOptions>(args) .WithNotParsed((x) => Environment.Exit(1)) .WithParsedAsync(async options => await RunServer(options, cancellationToken)); });
public static async Task Main() => await RunWithCancellationAsync(async cancellationToken => { string profilePath = DirHelper.GetTempPath(); ProfileOptimization.SetProfileRoot(profilePath); ProfileOptimization.StartProfile("bicepserver.profile"); // the server uses JSON-RPC over stdin & stdout to communicate, // so be careful not to use console for logging! var server = new Server( Console.OpenStandardInput(), Console.OpenStandardOutput(), new Server.CreationOptions()); await server.RunAsync(cancellationToken); });
public static void OutputModel(SQLMetaData config, bool enableProgress = true) { var path = Path.Combine(_basePath, "Model"); Directory.CreateDirectory(path); ConsoleProgressBar progress = null; if (enableProgress) { progress = GetProgressBar(); } var sb = new StringBuilder(); var g = new ModelGenerator(config); // 解析 for (int i = 0; i < config.Tables.Count; i++) { var table = config.Tables[i]; if (config.ExceptTables.Contains(table.Name)) { continue; } sb.Append(config.Model_HeaderNote); sb.Append(string.Join(Environment.NewLine, config.Model_Using)); sb.AppendLine(); sb.AppendLine(); sb.AppendLine(config.Model_Namespace); sb.AppendLine("{"); sb.AppendLine(g.Get_Class(table.Name)); sb.AppendLine("}"); File.AppendAllText(Path.Combine(path, string.Format("{0}.cs", table.Name)), sb.ToString()); sb.Clear(); if (progress != null) { // 打印进度 ProgressPrint(progress, (i + 1), config.Tables.Count); } } // 拷贝公用文件到指定目录 DirHelper.CopyDirectory(Path.Combine("CopyFiles", "Model"), path); }
public static void OutputModel(Dictionary <string, TableMetaData> tables, GlobalConfiguration config, IProgressBar progress = null) { ResetProgress(progress); var path = Path.Combine(config.OutputBasePath, "Model"); Directory.CreateDirectory(path); BaseModelGenerator g = new ModelGenerator(config); // 解析 var i = 0; var sb = new StringBuilder(); foreach (var key in tables.Keys) { var table = tables[key]; if (config.ExcludeTables != null && config.ExcludeTables.Any(p => p.Name == table.Name)) { continue; } sb.AppendLine(g.RenderModelFor(table)); File.AppendAllText(Path.Combine(path, string.Format("{0}.cs", g.FileName)), sb.ToString()); sb.Clear(); PrintProgress(progress, ++i, tables.Count); } // 如果配置文件指定了JoinedTables,那么这里需要为这些关联表生成额外的包装model, // 路径:Model\JoinedViewModel if (config.JoinedTables != null && config.JoinedTables.Count > 0) { //Directory.CreateDirectory(Path.Combine(path, "JoinedViewModel")); //var sb2 = new StringBuilder(); //foreach (var map in config.JoinedTables) //{ // sb2.AppendLine(g.Get_Join_Head(map)); // sb2.AppendLine(g.Get_Joined_Class(map)); // sb2.AppendLine(g.Get_Join_Tail(map)); // File.AppendAllText(Path.Combine(path, "JoinedViewModel", string.Format("{0}.cs", "Joined" + g.FileName)), sb2.ToString()); // sb2.Clear(); //} } // 拷贝公用文件到指定目录 DirHelper.CopyDirectory(Path.Combine("CopyFiles", "Model"), path); }
public void Dump() { String baseDir = DirHelper.FindParentDir("BreastRadiology.XUnitTests"); String rDir = Path.Combine(baseDir, "Resources"); String path = Path.Combine(rDir, "Template.html"); String cacheDir = Path.Combine(baseDir, "Cache"); FhirStructureDefinitions.Create(cacheDir); CodeEditor ce = new CodeEditor(); ce.Load(path); CodeBlockNested b = ce.Blocks.Find("Body"); this.Dump(b); ce.Save(Path.Combine(DirHelper.FindParentDir(BaseDirName), "IG", "Content", "Dump.html")); }
//创建Entity void CreateEntity(string table) { DirHelper.CheckFolder(PathHelper.Entitypath); DataTable dt = new DBContext(constring).GetMap(table); string savePath = PathHelper.Entitypath + table + ".cs"; string templatePath = PathHelper.SelectedTempPath + "Entity.txt"; string content = FileHelper.ReadFile(templatePath); content = content.Replace("[ClassName]", table); StringBuilder sb = new StringBuilder(); sb.Append(" /// <summary>\r\n /// 属性更改通知\r\n /// </summary>\r\n"); sb.Append(" private List<string> _ChangedList = new List<string>();\r\n"); sb.Append(" /// <summary>\r\n /// 属性更改通知\r\n /// </summary>\r\n"); sb.Append(" [ColumnAttribute(\"ChangedList\", true, false, true)]\r\n"); sb.Append(" public List<string> ChangedList{get{return _ChangedList;}}\r\n"); sb.Append(" /// <summary>\r\n /// 客户端通知事件\r\n /// </summary>\r\n"); sb.Append(" public event PropertyChangedEventHandler PropertyChanged;\r\n"); sb.Append(" protected virtual void OnPropertyChanged(string propName)\r\n {\r\n"); sb.Append(" if (_ChangedList == null || !_ChangedList.Contains(propName))\r\n {\r\n"); sb.Append(" _ChangedList.Add(propName);\r\n"); sb.Append("\r\n }\r\n if(PropertyChanged != null)\r\n {\r\n"); sb.Append(" PropertyChanged(this, new PropertyChangedEventArgs(propName));\r\n"); sb.Append("\r\n }\r\n }\r\n"); var d_dt = DBColumnDescriptionHelper.GetDescriptions(constring, table); foreach (DataColumn item in dt.Columns) { string MS_Description = DBColumnDescriptionHelper.GetDescription(d_dt, item.ColumnName); sb.Append(" /// <summary>\r\n ///" + MS_Description + "\r\n /// </summary>\r\n"); sb.Append(" private " + RelaceType(item) + " _" + item.ColumnName + ";\r\n"); sb.Append(" /// <summary>\r\n ///" + MS_Description + "\r\n /// </summary>\r\n"); sb.Append(" [ColumnAttribute(\"" + item.ColumnName + "\", false, " + (item.AutoIncrement == true ? "true" : "false") + ", " + (item.AllowDBNull == true ? "true" : "false") + ")]\r\n"); sb.Append(" public " + RelaceType(item) + " " + item.ColumnName + " { get { return _" + item.ColumnName + ";} set{"); sb.Append("_" + item.ColumnName + " = value;OnPropertyChanged(\"" + item.ColumnName + "\");"); sb.Append("} } \r\n\r\n\r\n"); } content = content.Replace("[FieldName]", sb.ToString()); if (isCovert) { FileHelper.WriteFile(savePath, content); } }
protected void Page_Load(object sender, EventArgs e) { string result = string.Empty; int intBigHeight; int intBigWidth; string strBigData; int intSmallHeight; int intSmallWidth; string strSmallData; try { Session.Remove("ArticImg"); string path = Server.MapPath("~") + @"upload\avatar\"; DirHelper.CheckFolder(path); intBigHeight = int.Parse(Request.Form["BigHeight"].ToString()); intBigWidth = int.Parse(Request.Form["BigWidth"].ToString()); strBigData = Request.Form["BigData"].ToString(); string bmpBigJpg = DateTime.Now.ToString("yyyyMMddHHmmss") + "_w" + intBigWidth + "_h" + intBigHeight + ".jpg"; SaveBmp(BuildBitmap(intBigWidth, intBigHeight, strBigData), path + "\\" + bmpBigJpg); intSmallHeight = int.Parse(Request.Form["SmallHeight"].ToString()); intSmallWidth = int.Parse(Request.Form["SmallWidth"].ToString()); strSmallData = Request.Form["SmallData"].ToString(); string bmpSmallJpg = DateTime.Now.ToString("yyyyMMddHHmmss") + "_t" + intBigWidth + "_h" + intBigWidth + ".jpg"; SaveBmp(BuildBitmap(intSmallWidth, intSmallHeight, strSmallData), path + "\\" + bmpSmallJpg); #region 缩略图 string avatar = "/upload/avatar/" + bmpBigJpg;///图片地址 Session["ArticImg"] = avatar; Response.Write("1"); #endregion } catch { Response.Write("0"); } Response.End(); }
public void B7_RunPublisher() { DateTime start = DateTime.Now; Trace.WriteLine("Starting B7_RunPublisher"); try { String executingDir = Path.Combine(DirHelper.FindParentDir("BreastRadiologyProfilesV2"), "IG", "guide"); String jarPath = Path.Combine(executingDir, "input-cache", "org.hl7.fhir.publisher.jar"); String igPath = Path.Combine(executingDir, "ig.ini"); if (File.Exists(jarPath) == false) { throw new Exception($"Missing publisher jar '{jarPath}'"); } IGPublisher p = new IGPublisher(); p.StatusErrors += this.StatusErrors; p.StatusInfo += this.StatusInfo; p.StatusWarnings += this.StatusWarnings; p.Publish(executingDir, jarPath, igPath); if (p.HasErrors) { StringBuilder sb = new StringBuilder(); p.FormatErrorMessages(sb); Trace.WriteLine(sb.ToString()); Assert.IsTrue(false); } } catch (Exception err) { Trace.WriteLine(err.Message); Assert.IsTrue(false); } TimeSpan span = DateTime.Now - start; Trace.WriteLine($"Ending B7_RunPublisher[{(Int32)span.TotalSeconds}]"); }
static void Main(string[] args) { var input_path = ConfigurationManager.AppSettings["input_path"].Trim(); var output_path = ConfigurationManager.AppSettings["output_path"].Trim(); if (string.IsNullOrWhiteSpace(input_path)) { Print("请指定输入文件路径!", 3); goto End; } if (string.IsNullOrWhiteSpace(output_path)) { Print("请指定输出文件路径!", 3); goto End; } // 生成服务文件 Print("按 'y/Y' 生成服务类文件..."); var key = string.Empty; do { key = Console.ReadLine(); if (key == "Y" || key == "y") { Generate(input_path, output_path); DirHelper.Redirect(output_path); Print("生成完毕!"); break; } Console.WriteLine("按‘quit’退出"); }while (key != "quit"); End: Print("结束!"); Console.Read(); Environment.Exit(0); }
protected void Page_Load(object sender, EventArgs e) { int intBigHeight; int intBigWidth; string strBigData; int intSmallHeight; int intSmallWidth; string strSmallData; try { string path = Server.MapPath("~") + @"upload\avatar\"; DirHelper.CheckFolder(path); intBigHeight = int.Parse(Request.Form["BigHeight"].ToString()); intBigWidth = int.Parse(Request.Form["BigWidth"].ToString()); strBigData = Request.Form["BigData"].ToString(); string bmpBigJpg = CurrentMember.ID + "_w" + intBigWidth + "_h" + intBigHeight + ".jpg"; SaveBmp(BuildBitmap(intBigWidth, intBigHeight, strBigData), path + "\\" + bmpBigJpg); intSmallHeight = int.Parse(Request.Form["SmallHeight"].ToString()); intSmallWidth = int.Parse(Request.Form["SmallWidth"].ToString()); strSmallData = Request.Form["SmallData"].ToString(); string bmpSmallJpg = CurrentMember.ID + "_w" + intSmallWidth + "_h" + intSmallHeight + ".jpg"; SaveBmp(BuildBitmap(intSmallWidth, intSmallHeight, strSmallData), path + "\\" + bmpSmallJpg); #region 更新头像 Member member = new MemberRepository().Search().Where(b => b.ID == CurrentMember.ID).First(); member.Avatar = "/upload/avatar/" + bmpBigJpg; new MemberRepository().Update(member); Session.Remove("CurrentUser"); #endregion Response.Write("1"); } catch { Response.Write("0"); } Response.End(); }
Int32 Execute(string[] args) { try { if (String.IsNullOrEmpty(this.output) == true) { throw new Exception($"Output not set"); } this.preFhir = new PreFhirGenerator(null, "."); this.ParseArgs(args); String optionsFile = Path.Combine(DirHelper.FindParentDir("PreFhir"), "Options.txt"); if (File.Exists(optionsFile)) { String optionsTxt = File.ReadAllText(optionsFile); String[] optionsArr = optionsTxt.ToArgs(); this.ParseArgs(optionsArr); } this.preFhir.StatusErrors += this.Dfg_StatusErrors; this.preFhir.StatusInfo += this.Dfg_StatusInfo; this.preFhir.StatusWarnings += this.Dfg_StatusWarnings; if (this.preFhir.HasErrors == false) { this.preFhir.Process(); } if (this.preFhir.HasErrors) { throw new Exception($"Program failesd with {this.preFhir.Errors.Count()} errors"); } return(0); } catch (Exception err) { Console.WriteLine(err.Message); return(-1); } }
static Int32 Main(string[] args) { try { CodeEditor.DebugFlag = true; String outputDir = Path.Combine(DirHelper.FindParentDir("Maker"), "FhirKhit.Maker.Common", "MClasses"); using (MakerGen dfg = new MakerGen(outputDir)) { dfg.StatusErrors += Dfg_StatusErrors; dfg.StatusInfo += Dfg_StatusInfo; dfg.StatusWarnings += Dfg_StatusWarnings; Int32 retVal = dfg.GenerateBaseClasses(outputDir); return(retVal); } } catch (Exception err) { Console.WriteLine(err.Message); return(-1); } }
static String TestDir() { return(Path.Combine(DirHelper.FindParentDir("FhirKhit"), "Data", "US Core")); }
void GenerateFindCommonChildren() { CodeEditor editor = new CodeEditor(); CodeBlockNested main = editor.Blocks.AppendBlock(); main .AppendLine($"using System;") .AppendLine($"using System.Linq;") .AppendLine($"using System.Collections.Generic;") .AppendLine($"using System.Reflection;") .AppendLine($"using System.Text;") .AppendLine($"using FhirKhit.Tools;") .AppendLine($"using Hl7.Fhir.Introspection;") .AppendLine($"using Hl7.Fhir.Model;") .AppendLine($"using Hl7.Fhir.Support.Model;") .AppendLine($"using System.Diagnostics;") .AppendLine($"using Hl7.FhirPath;") .BlankLine() #if FHIR_R3 .AppendLine($"namespace FhirKhit.Tools.R3") #elif FHIR_R4 .AppendLine($"namespace FhirKhit.Tools.R4") #endif .OpenBrace() .AppendCode($"public partial class ElementDefinitionNode") .OpenBrace() ; CodeBlockNested construct = main.AppendBlock(); CodeBlockNested methods = main.AppendBlock(); main .CloseBrace() .CloseBrace() ; construct .SummaryOpen() .Summary($"Create ElementDefinitionNode for child of common/primitive Fhir data type elements") .SummaryClose() .AppendCode($"public ElementDefinitionNode FindCommonChild(String parentPath, String childName)") .OpenBrace() .AppendCode($"switch (this.FhirItemType.FriendlyName())") .OpenBrace() ; GenerateFindCommonChild(construct, methods, FHIRAllTypes.Ratio); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Period); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Range); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Attachment); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Identifier); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Annotation); GenerateFindCommonChild(construct, methods, FHIRAllTypes.HumanName); GenerateFindCommonChild(construct, methods, FHIRAllTypes.CodeableConcept); GenerateFindCommonChild(construct, methods, FHIRAllTypes.ContactPoint); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Coding); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Money); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Address); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Timing); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Quantity); GenerateFindCommonChild(construct, methods, FHIRAllTypes.SampledData); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Signature); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Age); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Distance); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Duration); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Count); #if FHIR_R4 GenerateFindCommonChild(construct, methods, FHIRAllTypes.MoneyQuantity); #endif GenerateFindCommonChild(construct, methods, FHIRAllTypes.SimpleQuantity); GenerateFindCommonChild(construct, methods, FHIRAllTypes.Extension); construct .AppendCode($"default: return null;") .CloseBrace() .CloseBrace() ; #if FHIR_R3 String outputPath = Path.Combine(DirHelper.FindParentDir("Tools"), "FhirKhit.Tools.R3", "ElementDefinitionNode.FindChild.cs"); #elif FHIR_R4 String outputPath = Path.Combine(DirHelper.FindParentDir("Tools"), "FhirKhit.Tools.R4", "ElementDefinitionNode.FindChild.cs"); #endif editor.Save(outputPath); }
void WriteIds(String className, String outputCodePath, String csBlockName, IEnumerable <String> penIdsEnum) { String[] penIds = penIdsEnum.ToArray(); CodeEditor editor = new CodeEditor(); editor.Load(Path.Combine(DirHelper.FindParentDir("BreastRadiology.XUnitTests"), "ResourcesMaker", outputCodePath)); CodeBlockNested concepts = editor.Blocks.Find(csBlockName); if (concepts == null) { throw new Exception($"Can not find editor block {csBlockName}"); } concepts.Clear(); concepts.AppendLine($"#region Codes"); for (Int32 i = 0; i < penIds.Length; i++) { String penId = penIds[i]; UpdateClass(className, penId); if (this.spreadSheetData.TryGetRow(penId, out DataRow row) == false) { throw new Exception($"Missing value for penid '{penId}'"); } String code = FormatCode(row[this.spreadSheetData.itemNameCol].ToString()); String conceptBlockName = CodeValue(code); String App(String s, Object t, String sb) { switch (t) { case DBNull dbNullValue: return(s); case String stringValue: // verify we have correct column. if (stringValue != sb) { Trace.WriteLine($"Invalid Modality '{stringValue}'. Expected {sb}"); } if (String.IsNullOrEmpty(s) == false) { s += " | "; } s += $"Modalities.{sb}"; return(s); default: throw new Exception("Invalid excel cell value"); } } String validWith = App("", row[this.spreadSheetData.mgCol], "MG"); ; validWith = App(validWith, row[this.spreadSheetData.mriCol], "MRI"); validWith = App(validWith, row[this.spreadSheetData.nmCol], "NM"); validWith = App(validWith, row[this.spreadSheetData.usCol], "US"); concepts .AppendLine($"new ConceptDef()") .AppendLine($" .SetCode(\"{conceptBlockName}\")") .AppendLine($" .SetDisplay(\"{code}\")") //.AppendLine($" .SetDefinition(\"[PR] {code}\")") .AppendLine($" .MammoId(\"{penId}\")") ; if (String.IsNullOrEmpty(validWith) == false) { concepts.AppendLine($" .ValidModalities({validWith})"); } AppIfNotNull(concepts, penId, "SetDicom", row[DicomCol]); AppIfNotNull(concepts, penId, "SetSnomedCode", row[SnomedCol]); //AppIfNotNull(concepts, penId, "SetOneToMany", row[13]); AppIfNotNull(concepts, penId, "SetSnomedDescription", row[SnomedDescriptionCol]); //AppIfNotNull(concepts, "SetICD10", row[ICD10Col]); if (AppIfNotNull(concepts, penId, "SetUMLS", row[UMLSCol]) == false) { AppIfNotNull(concepts, penId, "SetACR", row[ACRCol]); } if (i < penIds.Length - 1) { concepts .AppendLine($","); } } concepts.AppendLine($"#endregion // Codes"); editor.Save(); }
private static string GetTemplateFile(string name) { return(DirHelper.FindFile(Path.Combine("Templates", "DAL"), name + ".txt", true)); }
public void Z_BuildSpreadSheetOfItems() { DataTable dt; DataTable CreateTable() { DataTable retVal = new DataTable("Pages"); retVal.Columns.Add(new DataColumn("Checked", typeof(Boolean))); retVal.Columns.Add(new DataColumn("Link", typeof(String))); retVal.Columns.Add(new DataColumn("Notes", typeof(String))); return(retVal); } void Add(String path, String filter) { foreach (String file in Directory.GetFiles(path, filter)) { String fileName = Path.GetFileNameWithoutExtension(file); dt.Rows.Add( new object[] { null, $"http://build.fhir.org/ig/HL7/fhir-breast-radiology-ig/{fileName}.html", null }); } } void AddBlank() { dt.Rows.Add(new object[] { null, null, null }); } dt = CreateTable(); String resourcesDir = Path.Combine( DirHelper.FindParentDir("BreastRadiologyProfilesV2"), "IG", "Content", "Resources" ); Add(resourcesDir, "StructureDefinition-*.json"); AddBlank(); AddBlank(); AddBlank(); Add(resourcesDir, "CodeSystem-*.json"); AddBlank(); AddBlank(); AddBlank(); Add(resourcesDir, "ValueSet-*.json"); String savePath = @"c:\Temp\BreastRadPages.xlsx"; XLWorkbook workbook = new XLWorkbook(); IXLWorksheet sheet = workbook.Worksheets.Add(dt); sheet.Columns().AdjustToContents(); sheet.Columns().Style.Border.BottomBorder = XLBorderStyleValues.Thin; sheet.Columns().Style.Border.TopBorder = XLBorderStyleValues.Thin; sheet.Columns().Style.Border.RightBorder = XLBorderStyleValues.Thin; sheet.Columns().Style.Border.LeftBorder = XLBorderStyleValues.Thin; sheet.Columns().Style.Alignment.WrapText = true; sheet.Columns().Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; sheet.Columns().Style.Alignment.Vertical = XLAlignmentVerticalValues.Top; File.Delete(savePath); workbook.SaveAs(savePath); }