private bool SaveTempletToServer(string szScriptSource, byte[] byteScriptData) { //获取当前模板类型信息 ScriptConfig scriptConfig = null; if (this.ActiveScript != null) { scriptConfig = this.ActiveScript.ScriptConfig; } else if (this.ActiveScript != null) { scriptConfig = this.ActiveScript.ScriptConfig; } ScriptSelectForm frmTempletSelect = new ScriptSelectForm(); frmTempletSelect.Description = "请选择需要更新的目标病历模板:"; frmTempletSelect.MultiSelect = false; if (scriptConfig != null) { frmTempletSelect.DefaultDocTypeID = scriptConfig.SCRIPT_ID; } if (frmTempletSelect.ShowDialog() != DialogResult.OK) { return(false); } if (frmTempletSelect.SelectedScriptConfigs == null) { return(false); } if (frmTempletSelect.SelectedScriptConfigs.Count <= 0) { return(false); } scriptConfig = frmTempletSelect.SelectedScriptConfigs[0]; scriptConfig.MODIFY_TIME = SysTimeHelper.Instance.Now; short shRet = ScriptConfigAccess.Instance.SaveScriptDataToDB(scriptConfig, szScriptSource, byteScriptData); if (shRet != SystemData.ReturnValue.OK) { string szDocTypeName = scriptConfig.SCRIPT_NAME; MessageBoxEx.Show(string.Format("模板“{0}”保存失败!", szDocTypeName)); return(false); } return(true); }
/// <summary> /// 将服务器上的模板导出到本地目录 /// </summary> public void ExportTemplet() { FolderBrowserDialog folderDialog = new FolderBrowserDialog(); folderDialog.Description = "请选择模板导出目录:"; folderDialog.ShowNewFolderButton = true; if (folderDialog.ShowDialog() != DialogResult.OK) { return; } string szDirPath = folderDialog.SelectedPath; ScriptSelectForm frmTempletSelect = new ScriptSelectForm(); frmTempletSelect.MultiSelect = true; frmTempletSelect.Description = "请选择需要导出的病历类型模板:"; if (frmTempletSelect.ShowDialog() != DialogResult.OK) { return; } List <ScriptConfig> lstDocTypeInfos = frmTempletSelect.SelectedScriptConfigs; if (lstDocTypeInfos == null || lstDocTypeInfos.Count <= 0) { return; } WorkProcess.Instance.Initialize(this.DebuggerForm, lstDocTypeInfos.Count, "正在导出系统模板..."); StringBuilder sbExecuteResult = new StringBuilder(); short shRet = SystemData.ReturnValue.OK; for (int index = 0; index <= lstDocTypeInfos.Count - 1; index++) { WorkProcess.Instance.Show(null, index + 1); if (WorkProcess.Instance.Canceled) { break; } ScriptConfig docTypeInfo = lstDocTypeInfos[index]; if (docTypeInfo == null || docTypeInfo.IS_FOLDER == 1) { continue; } //从服务器上下载模板 string byteTempletData = null; shRet = ScriptConfigAccess.Instance.GetScriptSource(docTypeInfo.SCRIPT_ID, ref byteTempletData); if (shRet != SystemData.ReturnValue.OK) { sbExecuteResult.AppendLine("----导出失败! DocTypeName=" + docTypeInfo.SCRIPT_NAME); continue; } //将模板写入本地文件 string szTempletFile = string.Format("{0}\\{1}.vbs", szDirPath, docTypeInfo.SCRIPT_NAME); if (!GlobalMethods.IO.WriteFileText(szTempletFile, byteTempletData)) { sbExecuteResult.AppendLine("----导出失败! DocTypeName=" + docTypeInfo.SCRIPT_NAME); continue; } sbExecuteResult.AppendLine("导出成功! SCRIPT_NAME=" + docTypeInfo.SCRIPT_NAME); } WorkProcess.Instance.Close(); this.ShowTextData(sbExecuteResult.ToString()); }