Esempio n. 1
0
        private bool SaveTempletToServer(byte[] byteTempletData)
        {
            //获取当前模板类型信息
            TempletType docTypeInfo = null;

            if (this.ActiveTemplet != null)
            {
                docTypeInfo = this.ActiveTemplet.DocTypeInfo;
            }
            else if (this.ActiveScript != null)
            {
                docTypeInfo = this.ActiveScript.DocTypeInfo;
            }

            TempletSelectForm frmTempletSelect = new TempletSelectForm();

            frmTempletSelect.Description = "请选择需要更新的目标病历模板:";
            frmTempletSelect.MultiSelect = false;
            if (docTypeInfo != null)
            {
                frmTempletSelect.ApplyEnv         = docTypeInfo.ApplyEnv;
                frmTempletSelect.DefaultDocTypeID = docTypeInfo.DocTypeID;
            }
            if (frmTempletSelect.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }
            if (frmTempletSelect.SelectedDocTypes == null)
            {
                return(false);
            }
            if (frmTempletSelect.SelectedDocTypes.Count <= 0)
            {
                return(false);
            }

            docTypeInfo = frmTempletSelect.SelectedDocTypes[0];
            short shRet = TempletTypeAccess.Instance.SaveTempletDataToDB(docTypeInfo.DocTypeID, byteTempletData);

            if (shRet != SystemData.ReturnValue.OK)
            {
                string szDocTypeName = docTypeInfo.DocTypeName;
                MessageBoxEx.Show(string.Format("模板“{0}”保存失败!", szDocTypeName));
                return(false);
            }
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// 将本地目录下的模板提交到服务器
        /// </summary>
        public void ImportTemplet()
        {
            TempletSelectForm frmTempletSelect = new TempletSelectForm();

            frmTempletSelect.MultiSelect = true;
            frmTempletSelect.Description = "请选择需要导入的病历类型模板:";

            string szApplyEnv = this.toolcboApplyEnv.Text;

            szApplyEnv = SystemData.TempletTypeApplyEnv.GetApplyEnvCode(szApplyEnv);
            frmTempletSelect.ApplyEnv = szApplyEnv;

            if (frmTempletSelect.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            List <TempletType> lstDocTypeInfos = frmTempletSelect.SelectedDocTypes;

            if (lstDocTypeInfos == null || lstDocTypeInfos.Count <= 0)
            {
                return;
            }

            FolderBrowserDialog folderDialog = new FolderBrowserDialog();

            folderDialog.Description         = "请选择模板在本地的存放目录:";
            folderDialog.ShowNewFolderButton = false;
            if (folderDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            string szDirPath = folderDialog.SelectedPath;

            WorkProcess.Instance.Initialize(this.MainForm, 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;
                }

                TempletType docTypeInfo = lstDocTypeInfos[index];
                if (docTypeInfo == null || docTypeInfo.IsFolder)
                {
                    continue;
                }

                //读取本地模板文件
                byte[] byteTempletData = null;
                string szTempletFile   = string.Format("{0}\\{1}.hndt", szDirPath, docTypeInfo.DocTypeName);
                if (!GlobalMethods.IO.GetFileBytes(szTempletFile, ref byteTempletData))
                {
                    sbExecuteResult.AppendLine("----导入失败! DocTypeName=" + docTypeInfo.DocTypeName);
                    continue;
                }

                //保存模板到服务器
                shRet = TempletTypeAccess.Instance.SaveTempletDataToDB(docTypeInfo.DocTypeID, byteTempletData);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    sbExecuteResult.AppendLine("----导入失败! DocTypeName=" + docTypeInfo.DocTypeName);
                    continue;
                }
                sbExecuteResult.AppendLine("导入成功! DocTypeName=" + docTypeInfo.DocTypeName);
            }
            WorkProcess.Instance.Close();
            this.ShowTextData(sbExecuteResult.ToString());
        }