Esempio n. 1
0
        /// <summary>
        ///     Similar to Entity Framework Code First in concept, produce content files given a csharp object that represents the
        ///     doc type.
        /// </summary>
        /// <param name="baseDoc"></param>
        /// <param name="directoryInfo">
        ///     The folder these files will be written to if any content "merging" logic needs to take
        ///     place.
        /// </param>
        /// <returns>Relative filename path/name items & content</returns>
        public Dictionary <string, string> ContentFiles(BaseDoc baseDoc, DirectoryInfo directoryInfo)
        {
            string   solutionVersion = baseDoc.solutionVersion;
            FileInfo _ExistingTemplateJsonFileInfo = new FileInfo(string.Format(@"{0}\template.json", directoryInfo.FullName));

            // if there is an existing template.js the developer created, try to use as much of it as we can to write a new template.json that will accommodate the properties of the baseDoc passed
            string _TemplateJson = _ExistingTemplateJsonFileInfo.Exists
                                       ? File.ReadAllText(_ExistingTemplateJsonFileInfo.FullName)
                                       : _Interpreter.Write(new Rand().obj(baseDoc, "template.json"));

            //strip away any properties that may not be compatible datatype-wise with previous version of template.js & the new object
            string tempalte_json = _Interpreter.WritePI(
                _Interpreter.Write(
                    (BaseDoc)JsonConvert.DeserializeObject(
                        _TemplateJson,
                        baseDoc.GetType(),
                        new JsonSerializerSettings {
                Error = (o, args) => { args.ErrorContext.Handled = true; }
            })),
                new DocProcessingInstructions
            {
                DocChecksum     = 8678309,
                DocTypeName     = baseDoc.GetType().Name,
                solutionVersion = solutionVersion,
                DocTitle        = string.Format("{0} {1}, Base Line Data", baseDoc.DocTypeName, baseDoc.solutionVersion),
                DocId           = DocKey.DocIdFromKeys(
                    new Dictionary <string, string>
                {
                    { "DocTitle", baseDoc.DocTitle },
                    { "DocTypeName", baseDoc.DocTypeName },
                    { "solutionVersion", baseDoc.solutionVersion }
                })
            });


            Dictionary <string, string> _Dictionary = new Dictionary <string, string>
            {
                {
                    "template.json", tempalte_json
                },
                {
                    "default.htm", "<!-- TODO: add example code that could generically bind to the template.json to as an example -->"
                },
                {
                    "readme.txt", "TODO: add overview & links to resources"
                }
            };


            string[] files = Directory
                             .EnumerateFiles(directoryInfo.FullName, "*.*", SearchOption.AllDirectories)
                             .Union(_Dictionary.Keys)
                             .Select(m => string.Format("/{0}", m.Replace(directoryInfo.FullName, string.Empty).Replace("\\", "/").TrimStart('/', '\\')))
                             .Distinct()
                             .OrderBy(m => m)
                             .ToArray();

            File.WriteAllText(_ExistingTemplateJsonFileInfo.FullName, tempalte_json);
            return(_Dictionary);
        }
Esempio n. 2
0
        public ActionResult DocImgFiles(string id, string pageId)
        {
            ViewBag.pageId = getPageId(pageId);
            var info = new BaseDoc(id);

            return(View(info));
        }
Esempio n. 3
0
        /// <summary>
        ///     enumerate each PdfAcroField, convert it's value to clr type, use reflection to set that value to the clr object
        ///     BaseDoc
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocRevStrict"></param>
        /// <returns></returns>
        public override BaseDoc Read(byte[] DocData, bool DocRevStrict = false)
        {
            using (MemoryStream _MemoryStream = new MemoryStream(DocData))
                using (PdfDocument _PdfDocument = PdfReader.Open(_MemoryStream, PdfDocumentOpenMode.ReadOnly))
                {
                    DocProcessingInstructions _DocProcessingInstructions = ReadDocPI(_PdfDocument);

                    BaseDoc _BaseDoc = Runtime.ActivateBaseDoc(
                        _DocProcessingInstructions.DocTypeName,
                        DocRevStrict
                        ? _DocProcessingInstructions.solutionVersion
                        : TemplateController.Instance.TopDocRev(_DocProcessingInstructions.DocTypeName));

                    Type _BaseDocType = _BaseDoc.GetType();

                    for (int i = 0; i < _PdfDocument.AcroForm.Fields.Elements.Count; i++)
                    {
                        PdfAcroField      _Field             = _PdfDocument.AcroForm.Fields[i];
                        CompositeProperty _CompositeProperty = _Field.AsCompositeProperty();
                        string            _Value             = string.Format("{0}", _Field.Value);

                        PropertyInfo _PropertyInfo = _BaseDocType.GetProperty(_CompositeProperty.Name, _CompositeProperty.PropertyType);
                        _PropertyInfo.SetValue(_BaseDoc, Convert.ChangeType(_Value, _PropertyInfo.PropertyType), null);
                    }

                    return(SetPI(_BaseDoc, _DocProcessingInstructions));
                }
        }
Esempio n. 4
0
 /// <summary>
 ///     simple helper method to assign values from a DocProcessingInstruction type to a BaseDoc
 /// </summary>
 /// <param name="dstBaseDoc"></param>
 /// <param name="pi"></param>
 /// <param name="DocTypeName"></param>
 /// <param name="DocRev"></param>
 /// <returns></returns>
 public static BaseDoc SetPI(BaseDoc dstBaseDoc, DocProcessingInstructions pi, string DocTypeName = null, string DocRev = null)
 {
     dstBaseDoc                 = (BaseDoc)PropertyOverlay.Overlay(pi, dstBaseDoc);
     dstBaseDoc.DocTypeName     = DocTypeName ?? pi.DocTypeName;
     dstBaseDoc.solutionVersion = DocRev ?? pi.solutionVersion;
     return(dstBaseDoc);
 }
Esempio n. 5
0
        /// <summary>
        /// </summary>
        /// <param name="DocSrc"></param>
        /// <param name="DocKeysFromDocId"></param>
        /// <param name="DocTypeName"></param>
        /// <param name="DocKeys">have precedence over DocId when is not null</param>
        /// <param name="DocId"></param>
        /// <param name="RelayUrl"></param>
        /// <returns></returns>
        public object Get(out string DocSrc, out Dictionary <string, string> DocKeysFromDocId, string DocTypeName, Dictionary <string, string> DocKeys = null, string DocId = null, string RelayUrl = null)
        {
            DocSrc           = null;
            DocKeysFromDocId = new Dictionary <string, string>();
            BaseDoc _BaseDoc = null;
            Dictionary <string, List <string> > _RequiredDocKeys = new Dictionary <string, List <string> >();

            DocKeys = DocKeys ?? DocKey.DocIdToKeys(DocId);

            foreach (KeyValuePair <string, string> _Item in DocKeys)
            {
                _RequiredDocKeys[_Item.Key] = new List <string> {
                    _Item.Value
                }
            }
            ;

            //BUG:DocStatus is not persisted by in the DocData; this band-aid gets it from the LightDoc in order to return it to the calling DataContract method
            foreach (Document _Document in ListDocuments(new List <string> {
                DocTypeName
            }, _RequiredDocKeys, null, null, 1, 0, RelayUrl, DirectoryPath))
            {
                _BaseDoc = DocInterpreter.Instance.Read(_Document.AsDocSubmissions().Last().Value);
                if (_BaseDoc.DocIdKeys.Count == DocKeys.Count)
                {
                    DocSrc           = Nav.ToUrl(DocTypeName, DocId, RelayUrl);
                    DocKeysFromDocId = _BaseDoc.DocIdKeys;
                    // there is a chance the DocStatus may not be set when it comes to items like DOCREV BaseDocType(s)
                    _BaseDoc.DocStatus = bool.Parse(_Document.Get(Parm.DocStatus) ?? Boolean.FalseString);
                    break;
                }
            }

            return(_BaseDoc);
        }
Esempio n. 6
0
 public void ShowFormByDocName(object patientId, object visitId, object operId, string docName)
 {
     panelSafetyDoc.Controls.Clear();
     ApplicationConfiguration.MedicalDocucementElement document = ApplicationConfiguration.GetMedicalDocument(docName);
     //没有找到退出
     if (string.IsNullOrEmpty(document.Caption))
     {
         return;
     }
     try
     {
         Type t = Type.GetType(document.Type);
         baseDoc = Activator.CreateInstance(t) as BaseDoc;
         baseDoc.statusReadOnly = _statusName;
         baseDoc.isShowButton   = false;
         if (patientId != null)
         {
             object[] objs = new object[3];
             objs[0] = patientId;
             objs[1] = visitId;
             objs[2] = operId;
             baseDoc.SetDocParameters(objs);
         }
         baseDoc.LoadReport(ExtendApplicationContext.Current.AppPath + document.Path);
         baseDoc.AutoScroll = false;
         baseDoc.Height     = 1200;
         panelSafetyDoc.Controls.Add(baseDoc);
         // baseDoc.Dock = DockStyle.Fill;
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 根据文书名加载文书
        /// </summary>
        public BaseDoc GetAnesDoc(string docName)
        {
            Dictionary <string, MedicalDocElement>   docs            = MedicalDocSettings.GetMedicalDocNameAndPath();
            KeyValuePair <string, MedicalDocElement> keyValuePairDoc = new KeyValuePair <string, MedicalDocElement>();

            foreach (KeyValuePair <string, MedicalDocElement> keyValuePair in docs)
            {
                if (keyValuePair.Key.Trim() == docName.Trim())
                {
                    keyValuePairDoc = keyValuePair;
                    break;
                }
            }

            Type    t       = Type.GetType(keyValuePairDoc.Value.Type);
            BaseDoc baseDoc = Activator.CreateInstance(t) as BaseDoc;

            baseDoc.BackColor = Color.White;
            baseDoc.Name      = docName;
            baseDoc.Initial();
            string path = null;

            if (MedicalDocSettings.GetMedicalDocNameAndPath().ContainsKey(docName))
            {
                path = MedicalDocSettings.GetMedicalDocNameAndPath()[docName].Path;
                baseDoc.LoadReport(Path.Combine(ExtendAppContext.Current.AppPath, path));
            }

            return(baseDoc);
        }
Esempio n. 8
0
        private bool LoadDoc(string curDocName)
        {
            bool result = true;

            ApplicationConfiguration.MedicalDocucementElement document = ApplicationConfiguration.GetMedicalDocument(curDocName);

            //没有找到退出
            if (string.IsNullOrEmpty(document.Caption))
            {
                result = false;
                ShowMessageBox(string.Format("无法加载文书'{0}'的设计模版,请确保模版文件已经存在", curDocName), MessageBoxButton.OK, MessageBoxImage.Error, callBack: (r) =>
                {
                    this.CloseContentWindow();
                    return;
                }, isAsyncShow: true);
            }
            else
            {
                // 载入文书,获取文书名
                ExtendAppContext.Current.CurrentDocName = curDocName;
                ExtendAppContext.Current.CurntOpenForm  = new OpenForm(curDocName, null);
                Type t = Type.GetType(document.Type);
                curBaseDoc           = Activator.CreateInstance(t) as BaseDoc;
                curBaseDoc.BackColor = Color.White;
                curBaseDoc.Name      = curDocName;
                curBaseDoc.HideScrollBar();
                curBaseDoc.Initial();
                curBaseDoc.LoadReport(Path.Combine(System.Windows.Forms.Application.StartupPath, document.Path));
                curBaseDoc.SetAllControlEditable(ExtendAppContext.Current.IsPermission);
                // 设置文书大小
                SetDocSize(curDocName);
            }

            return(result);
        }
Esempio n. 9
0
        public LightDoc SubmitText(string DocData, string DocSubmittedByEmail, string RelayUrl = null, bool?DocStatus = null, DateTime?SubmittedDate = null, Dictionary <string, string> DocKeys = null, string DocTitle = null)
        {
            BaseDoc _BaseDoc = DocInterpreter.Instance.Read(DocData, true);
            DocProcessingInstructions _DocProcessingInstructions = DocInterpreter.Instance.ReadDocPI(DocData);

            string DocSrc;
            Dictionary <LightDoc, object> _DocSubmissions = new Dictionary <LightDoc, object>();

            Document _Document = GetDoc(_BaseDoc.DocTypeName, _BaseDoc.GetDocId());

            if (_Document != null)
            {
                if (_DocProcessingInstructions.DocChecksum == int.Parse(_Document.Get(Parm.DocChecksum)))
                {
                    if (!_DocProcessingInstructions.IsDocRev())
                    {
                        throw new NoChangesSinceLastSubmitException();
                    }
                    else
                    {
                        return(_BaseDoc.ToLightDoc());
                    }
                }

                if (!_DocProcessingInstructions.IsDocRev())
                {
                    if ((_Document.Get(Parm.DocStatus) ?? bool.FalseString) == bool.TrueString)
                    {
                        throw new NoOverwriteOfPreviouslyApproveException();
                    }
                }

                _DocSubmissions = _Document.AsDocSubmissions();
            }

            LightDoc _LightDoc = _BaseDoc.ToLightDoc();

            _LightDoc.DocSubmitDate = DateTime.Now;
            _LightDoc.DocIsBinary   = false;

            _DocSubmissions.Add(_LightDoc, DocData);

            using (StandardAnalyzer _StandardAnalyzer = new StandardAnalyzer(LUCENE_VERSION))
                using (IndexWriter _CurrentIndexWriter = new IndexWriter(FSDirectory.Open(DirectoryPath), _StandardAnalyzer, CreateNeeded(), IndexWriter.MaxFieldLength.UNLIMITED))
                {
                    if (_DocSubmissions.Count > 1)
                    {
                        _CurrentIndexWriter.UpdateDocument(_BaseDoc.docTermFromBaseDoc(), _DocSubmissions.AsDocument());
                    }
                    else
                    {
                        _CurrentIndexWriter.AddDocument(_DocSubmissions.AsDocument());
                    }

                    _CurrentIndexWriter.Commit();
                }

            return(_LightDoc);
        }
Esempio n. 10
0
        public static SqlDB GetInstance(BaseDoc baseDoc)
        {
            string key = baseDoc.GetType().Namespace;

            return(SqlDbDictionary.ContainsKey(key)
                       ? SqlDbDictionary[key]
                       : SqlDbDictionary[key] = new SqlDB(baseDoc));
        }
Esempio n. 11
0
        public BaseResponse DelDoc(string id)
        {
            UserManager user    = UserManager.getUserById(User.Identity.Name);
            var         docInfo = new BaseDoc(id);

            docInfo.SelDel();
            UserLog.create(string.Format("将文档[{0},{1}]标记为删除", docInfo.Caption, docInfo.DocTypeString), "文档管理", user, docInfo);
            return(BaseResponse.getResult("删除成功"));
        }
Esempio n. 12
0
        public BaseResponse UpdateDocImgFiles(BaseDocImgFilesUploadRequest info)
        {
            UserManager user    = UserManager.getUserById(User.Identity.Name);
            var         docInfo = new BaseDoc(info.DocId);

            docInfo.UpdatImgFileList(info.FilesList);
            UserLog.create("编辑图集", "文档管理", user, docInfo);
            return(BaseResponse.getResult("保存成功"));
        }
Esempio n. 13
0
        public BaseResponse <BaseDoc> SetDisable(string id)
        {
            UserManager user    = UserManager.getUserById(User.Identity.Name);
            var         docInfo = new BaseDoc(id);
            var         result  = docInfo.SetDisable();

            UserLog.create(string.Format("将文档[{0},{1}]设置为:{2}", result.Caption, result.DocTypeString, result.IsDisabled ? "禁用" : "未禁用"), "文档管理", user, docInfo);

            return(BaseResponse.getResult(result, "设置成功"));
        }
Esempio n. 14
0
 public BaseDoc(BaseDoc parent)
 {
     if (parent == null)
     {
         System.Console.WriteLine($"parent is <null> in {GetType()} constructor");
         return;
     }
     Parent = parent;
     parent.RegisterChild(this);
 }
Esempio n. 15
0
 public static LightDoc ToLightDoc(this BaseDoc o, string DocSrc = null)
 {
     return(new LightDoc
     {
         DocId = o.GetDocId(),
         DocSrc = DocSrc ?? Nav.ToUrl(o),
         DocStatus = o.DocStatus,
         DocTitle = o.DocTitle,
         DocTypeName = o.DocTypeName
     });
 }
Esempio n. 16
0
        /// <summary>
        ///     if the DocData is less then 2083 characters long (that is internet explorer's address bar limit), inline the actual
        ///     data to the URL. When that can't be achieved the document will be stored in MemoryCache and a quazi-ticket-number
        ///     will URL parameter will be used guaranteeing availability of anything that requests it within 10 minutes of this
        ///     method being called.
        /// </summary>
        /// <param name="BaseDoc"></param>
        /// <param name="RelayUrl"></param>
        /// <returns></returns>
        public static string ToUrl(BaseDoc BaseDoc, string RelayUrl = null)
        {
            if (string.IsNullOrWhiteSpace(RelayUrl))
            {
                RelayUrl = ReverseProxy.GetRelayUrl();
            }

            string DocTypeName = BaseDoc.DocTypeName;

            string _Url = string.IsNullOrWhiteSpace(RelayUrl)
                              ? string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}",
                                              RequestPaths.ApplicationPath,
                                              DocTypeName,
                                              Parm.DocBin,
                                              HttpUtility.UrlEncode(Compressor.CompressToBase64String(BaseDoc.ToBytes())))
                              : string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}&{4}={5}",
                                              RelayUrl,
                                              DocTypeName,
                                              Parm.DocBin,
                                              HttpUtility.UrlEncode(Compressor.CompressToBase64String(BaseDoc.ToBytes())),
                                              Parm.RelayUrl,
                                              HttpUtility.UrlEncode(RelayUrl)
                                              );

            //REF:http://support.microsoft.com/kb/208427
            if (_Url.Length > 2083)
            {
                string _CacheKey = HttpUtility.UrlEncode(string.Format("{0}.{1}", DocTypeName, _Url.GetHashCode()));

                if (HttpRuntime.Cache[_CacheKey] == null)
                {
                    HttpRuntime.Cache.Insert(_CacheKey,
                                             BaseDoc,
                                             null,
                                             Cache.NoAbsoluteExpiration,
                                             TimeSpan.FromMinutes(10));
                }

                _Url = string.IsNullOrWhiteSpace(RelayUrl)
                           ? string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}",
                                           RequestPaths.ApplicationPath,
                                           DocTypeName,
                                           Parm.DocCache,
                                           _CacheKey)
                           : string.Format("{0}/DocDataHandler.ashx?DocTypeName={1}&{2}={3}&{4}={5}",
                                           RelayUrl,
                                           DocTypeName,
                                           Parm.DocCache,
                                           _CacheKey,
                                           Parm.RelayUrl,
                                           HttpUtility.UrlEncode(RelayUrl));
            }
            return(_Url);
        }
Esempio n. 17
0
        /// <summary>
        /// </summary>
        /// <param name="_DocDirectoryInfo"></param>
        /// <param name="DocTypeName"></param>
        /// <param name="DocProperties"></param>
        /// <param name="DocRev"></param>
        /// <returns>TODO:Needs to return a DocRev & not write files to a physical directory</returns>
        public static BaseDoc Templify(string DocTypeName, List <CompositeProperty> DocProperties, string DocRev = null)
        {
            DirectoryInfo _DocDirectoryInfo =
                new DirectoryInfo(FilesystemTemplateController.GetDocDirectoryPath(DocTypeName)).mkdir();

            if (string.IsNullOrWhiteSpace(DocRev))
            {
                DocRev = DateTime.UtcNow.AsDocRev();
            }

            string temporaryNamespace  = RuntimeTypeNamer.CalcCSharpNamespace(DocTypeName, DocRev, typeof(DocTempleter).Name);
            string cSharpClassFullName = RuntimeTypeNamer.CalcCSharpNamespace(DocTypeName, DocRev);

            FileInfo _XsdFileInfo        = new FileInfo(String.Format(@"{0}\{1}", _DocDirectoryInfo.FullName, Runtime.MYSCHEMA_XSD_FILE_NAME));
            Type     _template_docx_type = new CompositeType(temporaryNamespace, _DocDirectoryInfo.Name, DocProperties.ToArray());

            // the "lazy-load" CompositeType requires activation in order for the _template_docx_obj.GetType().Assembly to register as having any types defined
            object _template_docx_obj = Activator.CreateInstance(_template_docx_type);

            string xsd = XsdExporter.ExportSchemas(
                _template_docx_obj.GetType().Assembly,
                new List <string> {
                DocTypeName
            },
                RuntimeTypeNamer.CalcSchemaUri(DocTypeName, DocRev)).First();

            File.WriteAllText(_XsdFileInfo.FullName, xsd, Encoding.Unicode);

            string myclasses_cs = new Xsd().ImportSchemasAsClasses(
                new[] { xsd },
                cSharpClassFullName,
                CodeGenerationOptions.GenerateOrder | CodeGenerationOptions.GenerateProperties,
                new StringCollection());

            myclasses_cs = Runtime.CustomizeXsdToCSharpOutput(DocTypeName, myclasses_cs, null, new[] { nameof(IDocModel) });

            if (Directory.Exists(RequestPaths.GetPhysicalApplicationPath(Resources.App_Code_DirectoryPath)))
            {
                File.WriteAllText(RequestPaths.GetPhysicalApplicationPath(Resources.App_Code_DirectoryPath, DocTypeName + ".cs"), myclasses_cs, Encoding.Unicode);
            }
            else
            {
                File.WriteAllText(_DocDirectoryInfo.FullName + @"\\example.cs", myclasses_cs, Encoding.Unicode);
            }

            BaseDoc _BaseDoc = Runtime.FindBaseDoc(Runtime.CompileCSharpCode(myclasses_cs), DocTypeName);

            // reset the values critical to this import that were implicitly set by the Rand()
            _BaseDoc.solutionVersion = DocRev;
            _BaseDoc.DocTypeName     = DocTypeName;
            _BaseDoc.href            = String.Empty;

            return(_BaseDoc);
        }
Esempio n. 18
0
        public void ShowDocByDocName(string docName)
        {
            ApplicationConfiguration.MedicalDocucementElement document = ApplicationConfiguration.GetMedicalDocument(docName);

            //没有找到退出
            if (string.IsNullOrEmpty(document.Caption))
            {
                //DialogResult dialogResult = XtraMessageBox.Show(string.Format("无法加载文书'{0}'的设计模版,请确保模版文件已经存在", docName),
                //        "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //this.workSpaceControl1.AddDocToWorkSpace(null);
                return;
            }

            try
            {
                Type    t       = Type.GetType(document.Type);
                BaseDoc baseDoc = Activator.CreateInstance(t) as BaseDoc;
                baseDoc.BackColor = Color.White;
                baseDoc.Name      = docName;
                baseDoc.HideScrollBar();
                baseDoc.Initial();
                baseDoc.LoadReport(ExtendApplicationContext.Current.AppPath + document.Path);
                if (baseDoc.DocKind == DocKind.Anes)
                {
                    // baseDoc.AfterPrint += new Medicalsystem.Anes.Framework.Documents.BaseDoc.EventAfterPrint(AfterPrint);
                }
                // this.workSpaceControl1.AddDocToWorkSpace(baseDoc);

                Timer a = new Timer();
                a.Interval = 1;
                a.Tick    += delegate
                {
                    baseDoc.ShowScrollBar();
                    //销毁定义器
                    a.Enabled = false;
                    a.Stop();
                    a.Dispose();
                };
                a.Enabled = true;


                if (ExtendApplicationContext.Current.AppType == ApplicationType.Anesthesia)
                {
                }
                else if (ExtendApplicationContext.Current.AppType == ApplicationType.PACU)
                {
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler.Handle(ex);
            }
        }
Esempio n. 19
0
        //TODO:Condense the parameters for Submit methods to a single ProcessingInstructions argument
        public LightDoc Submit(string DocData, string DocSubmittedBy, string RelayUrl = null, bool?DocStatus = null, DateTime?SubmittedDate = null, Dictionary <string, string> DocKeys = null, string DocTitle = null)
        {
            // let the BaseDoc parse it's string just as normal
            BaseDoc _SubmittedBaseDoc = DocInterpreter.Instance.Read(DocData, true);

            // has any DocRev of the given DocTypeName been submitted to the database previously?
            if (!SqlKnownDocTypes.ContainsKey(_SubmittedBaseDoc.DocTypeName))
            {
                SqlKnownDocTypes[_SubmittedBaseDoc.DocTypeName] = new List <Type> {
                    _SubmittedBaseDoc.GetType(), ReverseEngineerCodeFirst(_SubmittedBaseDoc)
                }
            }
        /// <summary>
        ///     does an Lucene.Net.Index.IndexWriter.Optimize()
        /// </summary>
        /// <returns></returns>
        public static void Rebuild(this LuceneController o)
        {
            lock (RebuildLock)
            {
                Debug.WriteLine("Start", "Rebuild");
                if (Directory.Exists(o.DirectoryPath) && Directory.EnumerateFiles(o.DirectoryPath).Any())
                {
                    using (StandardAnalyzer _StandardAnalyzer = new StandardAnalyzer(LuceneController.LUCENE_VERSION))
                        using (IndexWriter _CurrentIndexWriter = new IndexWriter(FSDirectory.Open(o.DirectoryPath),
                                                                                 _StandardAnalyzer,
                                                                                 false,
                                                                                 IndexWriter.MaxFieldLength.UNLIMITED))
                        {
                            foreach (string DocTypeName in o.List(new List <string> {
                                EmbededInterpreter.MY_ONLY_DOC_NAME
                            }).Select(_LightDoc => _LightDoc.GetTargetDocName()).Distinct())
                            {
                                int             PageIndex = 0, hashcode = 0;
                                List <Document> _ListDocument = new List <Document>();
                                do
                                {
                                    foreach (Document _Document in o.ListDocuments(new List <string> {
                                        DocTypeName
                                    }, null, null, null, 1, PageIndex++))
                                    {
                                        try
                                        {
                                            Dictionary <LightDoc, object> _DocSubmissions = _Document.AsDocSubmissions();

                                            BaseDoc _BaseDoc = _Document.AsDocSubmissions().Last().Key.DocIsBinary
                                                               ? DocInterpreter.Instance.Read((byte[])_Document.AsDocSubmissions().Last().Value)
                                                               : DocInterpreter.Instance.Read((string)_Document.AsDocSubmissions().Last().Value);

                                            Debug.WriteLine(string.Format(_BaseDoc.DocTitle, "Rebuild"));

                                            // last step on the "Document -> AsDocSubmissions -> *****AsDocument*****" conversions is where storage efficiencies are gained with each release of this assembly
                                            _CurrentIndexWriter.UpdateDocument(_BaseDoc.docTermFromBaseDoc(), _DocSubmissions.AsDocument());
                                        } catch (InterpreterLocationException)
                                        {
                                            /* if developer does not have all the DocRevs there is a chance this will happen */
                                        }
                                        _CurrentIndexWriter.Commit();
                                    }
                                }while (_ListDocument.Count == LuceneController.PAGE_SIZE_DEFAULT);
                            }

                            _CurrentIndexWriter.Optimize();
                        }
                }
            }
        }
Esempio n. 21
0
 /// <summary>
 ///     attempts to screen properties that follow the naming pattern & inner property structure InfoPath xsd signature
 ///     elements
 ///     converted to when processed by xsd.exe (_XsnToCSharp.tt) to yield the C# class.
 /// </summary>
 /// <param name="o"></param>
 /// <returns></returns>
 private static PropertyInfo[] GetFormObjectSignatureProperties(BaseDoc o)
 {
     return(CacheMan.Cache(() =>
     {
         return o
         .GetFormObjectMappedProperties()
         .Where(m => m.Name.StartsWith("signatures", StringComparison.InvariantCultureIgnoreCase))
         .ToArray();
     },
                           false,
                           o.DocTypeName,
                           o.solutionVersion,
                           "GetFormWetSignatureProperties"));
 }
Esempio n. 22
0
        public BaseDoc Read(string DocJson, bool DocRevStrict = false)
        {
            string DocTypeName = ReadDocTypeName(DocJson);
            string DocRev      = DocRevStrict
                                ? ReadRevision(DocJson)
                                : TemplateController.Instance.TopDocRev(DocTypeName);

            Type type = Runtime.ActivateBaseDoc(DocTypeName, DocRev).GetType();

            BaseDoc o = (BaseDoc)JsonConvert.DeserializeObject(DocJson, type, PIInclusionSettings);

            o.solutionVersion = DocRev;

            return(o);
        }
Esempio n. 23
0
        /// <summary>
        ///     A good place to ignore/exclude fields going to the database
        /// </summary>
        /// <param name="modelBuilder"></param>
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            string myNamespace  = GetType().Namespace;
            Type   _BaseDocType = AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes().Where(t => t.Namespace == myNamespace && t.BaseType == typeof(BaseDoc))).FirstOrDefault();

            if (_BaseDocType == null)
            {
                throw new Exception(string.Format("{0} can't resolve it's own {1}.[*:BaseDoc]", GetType().FullName, myNamespace));
            }

            BaseDoc _BaseDoc = (BaseDoc)Activator.CreateInstance(_BaseDocType);

            ToTable(modelBuilder, typeof(DocKey), _BaseDocType.Name);

            foreach (var t in _BaseDoc
                     .ListRelatedEntities()
                     .Select(m => new
            {
                TablePocoType = m,
                TableName = m.Name.ToLower()
            }).OrderBy(m => m.TableName)
                     .ToArray())
            {
                // ensure the type has some other property to translate to database columns other then the "Id" property
                //if (t.TablePocoType.GetProperties().Where(p => !p.GetCustomAttributes(true).Any(a => a.GetType() == typeof(NotMapped)) && !p.PropertyType.IsClass).Count() > 1)
                ToTable(modelBuilder, t.TablePocoType, _BaseDocType.Name);
            }

            //The .Net DateTime datatype may have values outside the SQL DateTime data type, SQL datetime2 encompasses all .Net DateTime data types
            modelBuilder
            .Properties <DateTime>()
            .Configure(c => c.HasColumnType("datetime2"));

            // auto identities for Id properties
            //modelBuilder
            //.Properties()
            //.Where(p => p.Name == "Id")
            //.Configure(c => c.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity));

            // reflection is used heavily throughout the solution, names must remain the same between models, poco & sql statements
            modelBuilder.Conventions.Remove <PluralizingTableNameConvention>();
            modelBuilder.Conventions.Remove <PluralizingEntitySetNameConvention>();
            modelBuilder.Conventions.Remove <TableAttributeConvention>();
            modelBuilder.Conventions.Add <SqlTableAttributeConvention>();

            base.OnModelCreating(modelBuilder);
        }
Esempio n. 24
0
        /// <summary>
        ///     Creates a new instance of the Doc parameter's type passed; merged/automapped/overlayed with another instance of
        ///     that same type constructed straight from the current template.xml located in the ~/form/{DocTypeName}/template.xml
        ///     of this application. Other properties specific not defined in the template.xml's text specific to this solution's
        ///     BaseDoc super-class & the current HttpContext are also inflated.
        /// </summary>
        /// <param name="DocSrc"></param>
        /// <param name="Doc"></param>
        /// <param name="DocKeys"></param>
        /// <param name="RelayUrl"></param>
        /// <param name="ProcessTemplate"></param>
        /// <returns></returns>
        public virtual BaseDoc Create(BaseDoc Doc, string RelayUrl = null, bool ProcessTemplate = true)
        {
            string DocTypeName = Doc.DocTypeName;

            // apply ~/form/{DocTypeName}/template.xml values to document passed into us
            if (ProcessTemplate)
            {
                Doc = PropertyOverlay.Overlay(Doc, DocInterpreter.Instance.Create(DocTypeName));
            }

            //TODO:need to type-safe all the "object Doc" parameter methods
            Doc.DocChecksum = DocInterpreter.Instance.CalcDocChecksum(Doc);

            Doc.DocSrc = Nav.ToUrl(Doc, RelayUrl);

            return(Doc);
        }
Esempio n. 25
0
        public static SqlDbContext CreateInstance(BaseDoc _BaseDoc)
        {
            Type   _BaseDocType       = _BaseDoc.GetType();
            string _DbContextTypeName = dCFormDBContextTypeName(_BaseDoc);

            string cSharpCode = string.Format(CREATE_INSTANCE_TEMPLATE, _BaseDocType.Namespace, _DbContextTypeName);

            // add using statements to beginning to top of the document
            cSharpCode = string.Join("", Runtime.USING_NAMESPACES.Keys.OrderBy(ns => ns).Select(ns => string.Format("using {0};\n", ns))) + cSharpCode;

            //TODO:Separate the dCFormDBContextTypeName from the BaseDoc assembly/code-gen. Runtime-compiled BaseDocs & SqlDbContext code placement organization needs to be rethought thru better.
            return((SqlDbContext)Activator
                   .CreateInstance(Runtime
                                   .CompileCSharpCode(cSharpCode, typeof(SqlDbContext).Namespace, _BaseDoc.DocTypeName, _BaseDoc.solutionVersion)
                                   .GetTypes()
                                   .First(m => m.Name == _DbContextTypeName)));
        }
Esempio n. 26
0
 public void ShowFormByDocName(object patientId, object visitId, object operId, string docName)
 {
     ApplicationConfiguration.MedicalDocucementElement document = ApplicationConfiguration.GetMedicalDocument(docName);
     //没有找到退出
     if (string.IsNullOrEmpty(document.Caption))
     {
         return;
     }
     try
     {
         Type    t       = Type.GetType(document.Type);
         BaseDoc baseDoc = Activator.CreateInstance(t) as BaseDoc;
         baseDoc.ShowScrollBar();
         // 设置指定的患者信息
         if (patientId != null)
         {
             object[] objs = new object[3];
             objs[0] = patientId;
             objs[1] = visitId;
             objs[2] = operId;
             baseDoc.SetDocParameters(objs);
         }
         baseDoc.LoadReport(ExtendApplicationContext.Current.AppPath + document.Path);
         DialogHostFormPC dialogHostForm = null;
         dialogHostForm       = new DialogHostFormPC(docName, 1200, 900);
         dialogHostForm.Child = baseDoc;
         if (AccessControl.CheckModifyRightForOperator(docName))//有Modify权限
         {
             baseDoc.SetAllControlEditable(true);
         }
         else
         {
             baseDoc.SetAllButtonsEnable(false);
             baseDoc.SetAllControlEditable(false);
         }
         if (baseDoc.AllowSingleDocModify())
         {
             baseDoc.SetAllControlEditable(true);
         }
         dialogHostForm.ShowDialog();
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Esempio n. 27
0
 /// <summary>
 /// 添加医疗文书
 /// </summary>
 /// <param name="baseDoc"></param>
 public void AddDocToWorkSpace(BaseDoc baseDoc)
 {
     panelProcess.Visible = true;
     panelControlContainter.Controls.Clear();
     panelControlContainter.BackColor = Color.FromArgb(199, 233, 250);
     if (baseDoc != null)
     {
         if (ExtendApplicationContext.Current.SystemStatus == ProgramStatus.AnesthesiaRecord || ExtendApplicationContext.Current.SystemStatus == ProgramStatus.PACURecord)
         {
             if (ExtendApplicationContext.Current.PatientInformationExtend != null)
             {
                 splitContainer1.Panel1Collapsed = false;
                 splitContainer1.Panel2Collapsed = false;
                 AnesEventShow(false, "");
             }
         }
         else
         {
             if (ExtendApplicationContext.Current.PatientInformationExtend != null)
             {
                 splitContainer1.Panel1Collapsed = false;
                 splitContainer1.Panel2Collapsed = true;
             }
         }
         _baseDoc     = baseDoc;
         baseDoc.Dock = DockStyle.Fill;
         panelControlContainter.Controls.Add(baseDoc);
         RaiseEvent("");
         //  Application.DoEvents();
         _dataTemplate = new DataTemplate(baseDoc);
         baseDoc.SaveTemplateClicked         += new EventHandler(SaveTemplateClicked);
         baseDoc.ApplyTemplateClicked        += new EventHandler(ApplyTemplateClicked);
         baseDoc.SaveAllDataTemplateClicked  += new EventHandler(SaveAllDataTemplateClicked);
         baseDoc.ApplyAllDataTemplateClicked += new EventHandler(ApplyAllDataTemplateClicked);
         _baseDoc.RefreshMonitorHandler      += delegate
         {
             if (monitor != null)
             {
                 monitor.GetVitalSignDataTable();
                 AccessOperEvent();
                 monitor.BringToFront();
             }
         };
     }
 }
Esempio n. 28
0
        /// <summary>
        /// 打印后自动打印PACU护理记录单
        /// </summary>
        protected override void OnAfterPrint()
        {
            DialogResult dr = MessageBox.Show("是否打印PACU护理记录单?", "提示", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes || dr == DialogResult.OK)
            {
                string docName = "PACU护理记录单";
                Dictionary <string, MedicalDocElement> docs = MedicalDocSettings.GetMedicalDocNameAndPath();
                Type    t       = Type.GetType(docs[docName].Type);
                BaseDoc baseDoc = Activator.CreateInstance(t) as BaseDoc;
                baseDoc.BackColor = Color.White;
                baseDoc.Name      = docs[docName].Caption;
                baseDoc.HideScrollBar();
                baseDoc.Initial();
                baseDoc.LoadReport(Path.Combine(System.Windows.Forms.Application.StartupPath, docs[docName].Path));
                baseDoc.PrintBaseDoc();
            }
        }
Esempio n. 29
0
        /// <summary>
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocRevStrict"></param>
        /// <returns></returns>
        public override BaseDoc Read(string DocData, bool DocRevStrict = false)
        {
            if (string.IsNullOrWhiteSpace(DocData))
            {
                return(null);
            }

            DocProcessingInstructions pi = ReadDocPI(DocData);

            string
                CollapsedElementsDocXml,
                DocTypeName = ReadDocTypeName(DocData),
                DocRev      = ReadDocRev(DocData);

            if (string.IsNullOrWhiteSpace(DocTypeName))
            {
                DocTypeName = pi.DocTypeName;
            }

            if (string.IsNullOrWhiteSpace(DocRev))
            {
                DocRev = pi.solutionVersion;
            }

            CollapsedElementsDocXml = CollapseDefaultValueElements(DocData, DocTypeName);

            BaseDoc dstBaseDoc = null;

            Type BaseDocType = Runtime.ActivateBaseDocType(
                DocTypeName,
                DocRevStrict
                    ? DocRev
                    : TemplateController.Instance.TopDocRev(DocTypeName));

            using (StringReader _StringReader = new StringReader(CollapsedElementsDocXml))
                using (XmlTextReader _XmlTextReader = new XmlTextReader(_StringReader))
                {
                    return(SetPI(
                               (BaseDoc) new XmlSerializer(BaseDocType).Deserialize(_XmlTextReader),
                               pi,
                               DocTypeName,
                               DocRev));
                }
        }
Esempio n. 30
0
        /// <summary>
        /// </summary>
        /// <param name="DocData"></param>
        /// <param name="DocRevStrict"></param>
        /// <returns></returns>
        public BaseDoc Read(string DocData, bool DocRevStrict = false)
        {
            if (String.IsNullOrWhiteSpace(DocData))
            {
                return(null);
            }

            string
                CollapsedElementsDocXml = CollapseDefaultValueElements(DocData),
                DocTypeName             = ReadDocTypeName(DocData),
                DocRev = ReadRevision(DocData);

            BaseDoc dstBaseDoc = null;

            Type BaseDocType = Runtime.ActivateBaseDoc(
                DocTypeName,
                DocRevStrict
                    ? DocRev
                    : TemplateController.Instance.TopDocRev(DocTypeName)).GetType();

            try
            {
                dstBaseDoc = XsdIntEgerFixDstBaseDocKnownTypes.Contains(BaseDocType)
                                 ? TryXsdIntEgerFixDstBaseDoc(DocRevStrict, DocTypeName, DocRev, CollapsedElementsDocXml, BaseDocType)
                                 : (BaseDoc)Serialization.ReadObject(CollapsedElementsDocXml, BaseDocType);
                //} catch (InvalidOperationException)
            }
            catch (Exception)
            {
                dstBaseDoc = TryXsdIntEgerFixDstBaseDoc(DocRevStrict, DocTypeName, DocRev, CollapsedElementsDocXml, BaseDocType);

                if (dstBaseDoc == null)
                {
                    throw;
                }

                XsdIntEgerFixDstBaseDocKnownTypes.Add(dstBaseDoc.GetType());
            }

            dstBaseDoc = (BaseDoc)PropertyOverlay.Overlay(ReadDocPI(CollapsedElementsDocXml), dstBaseDoc);

            return(dstBaseDoc);
        }