/// <summary> /// </summary> /// <returns>current DocTypeNames known to this system</returns> public List <string> DocTypeNames() => CacheMan.Cache(() => DocTypeServedItems() .Select(typ => typ.Name) .ToList(), false, nameof(DocTypeNames));
private static byte[] GetCabDecodedAttachment(string DocTypeName, string DocTypeVer) { return(CacheMan.Cache(() => { Dictionary <string, string> DocKeys; const int SP1Header_Size = 20; const int FIXED_HEADER = 16; string attachmentName; byte[] reaponseFile = null; string DocSrc; object o = ServiceController.LuceneController.Get( out DocSrc, out DocKeys, "DOCREV", new Dictionary <string, string> { { "TargetDocTypeVer", DocTypeVer }, { "TargetDocTypeName", DocTypeName } }); if (o == null) { o = ServiceController.LuceneController.Get( out DocSrc, out DocKeys, "DOCREV", new Dictionary <string, string> { { "DocTypeVer", DocTypeVer }, { "DocTypeName", DocTypeName } }); } byte[] decodedAttachment = null; if (o != null) { IDocRev_Gen2 _IDocRev = (IDocRev_Gen2)o; using (MemoryStream ms = new MemoryStream(_IDocRev.TargetDocTypeFiles)) using (BinaryReader theReader = new BinaryReader(ms)) { //Position the reader to get the file size. byte[] headerData = new byte[FIXED_HEADER]; headerData = theReader.ReadBytes(headerData.Length); int fileSize = (int)theReader.ReadUInt32(); int attachmentNameLength = (int)theReader.ReadUInt32() * 2; byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength); //InfoPath uses UTF8 encoding. Encoding enc = Encoding.Unicode; //attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength - 2); decodedAttachment = theReader.ReadBytes(fileSize); } } return decodedAttachment; }, false, "GetCabDecodedAttachment", DocTypeName, DocTypeVer)); }
public override DocTypeInfo Info(string DocTypeName) => CacheMan.Cache(() => (DocTypeInfo)GetMethodInfo(DocCmd.Info).Invoke(UnderlyingWSClient, new object[] { DocTypeName }), false, "DocTypeInfo", DocTypeName, DocCmd.Info);
public static bool IsMatch(this string s, Pat pattern) { return(CacheMan.Cache(() => new Regex( DictionaryStringPatternSystemTextRegularExpressionsRegex[pattern]), false, pattern).IsMatch(s)); }
public string OpenText(string DocTypeName, string DocTypeVer, string filename) { return(CacheMan.Cache(() => { using (MemoryStream _MemoryStream = OpenRead(DocTypeName, DocTypeVer, filename)) return _MemoryStream.AsString(); }, false, "OpenText", DocTypeName, DocTypeVer, filename)); }
public string OpenText(HttpContext context, out string filename) { filename = GetHttpContextFileName(context); return(CacheMan.Cache(() => { TemplateFileInfo r; using (MemoryStream _MemoryStream = OpenRead(context, out r)) return _MemoryStream.AsString(); }, false, "OpenText", context.Request.Url.ToString())); }
/// <summary> /// Types that can be actively served via WCF as "new" documents. There types must have a folder representation in the /// file system. This list is cached internally. Before the list is constructed models and other contents are processed /// & imported to the docdb database. /// </summary> /// <returns>current DocTypeNames known to this system</returns> public List <Type> DocTypeServedItems() => CacheMan.Cache(() => { List <Type> l = new List <Type>(); Parallel.ForEach( DocTypeDirectories(), DocTypeName => l.Add(Runtime.ActivateBaseDocType(DocTypeName, TemplateController.Instance.TopDocRev(DocTypeName)))); return(l); }, false, "DocTypes");
internal static T InstanceLocatorByName <T>(string DocTypeName, string DocRev = null) where T : DocBaseInterpreter => CacheMan.Cache(() => { foreach (T _IDocDataInterpreter in ContentInterpreterInstances.OfType <T>()) { //TODO:Need a better way of discovering what IDocDataInterpreter can process the given document; it needs to consider the DocRev also if (_IDocDataInterpreter.Processable(DocTypeName, DocRev)) { return(_IDocDataInterpreter); } } throw new Exception(String.Format("{0} {1}, {2} could not locate a DocDataInterpreter to process the data passed", DocTypeName, DocRev, typeof(DocInterpreter).Name)); }, false, "InstanceLocatorByName", DocTypeName, DocRev ?? String.Empty);
/// <summary> /// Types that can be actively served via WCF as "new" documents. There types must have a folder representation in the /// file system. This list is cached internally. Before the list is constructed models and other contents are processed /// & imported to the nosql database. /// </summary> /// <returns>current DocTypeNames known to this system</returns> public static List <Type> DocTypeServedItems() { return(CacheMan.Cache(() => { ImporterController.ImportDocModelsRunOnce(); return Directory .EnumerateDirectories(FilesystemTemplateController.DirectoryPath) .Select(path => new DirectoryInfo(path).Name) .Select(DocTypeName => DocInterpreter.Instance.Create(DocTypeName).GetType()) .ToList(); }, false, "DocTypes")); }
/// <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")); }
/// <summary> /// Reads the DocRev from the local AppDomain working_folder\form\*. When nothing is found the Docdb store for the most /// current DocRev. The first item in descending string order. /// </summary> /// <param name="DocTypeName"></param> /// <returns>string.Empty if nothing is found</returns> public string TopDocRev(string DocTypeName, bool forceRefresh) => CacheMan.Cache(() => DocTypeName.Equals(EmbededInterpreter.MY_ONLY_DOC_NAME, StringComparison.CurrentCultureIgnoreCase) ? EmbededInterpreter.MY_ONLY_DOC_VERSION.ToString() : _DefaultTopDocFilesystemTemplateController.TopDocRev(DocTypeName) ?? _OtherIDocResourceControllers //DOCREVs should always come from the embedded controller .Select(m => m.TopDocRev(DocTypeName)) .Where(DocRev => !string.IsNullOrWhiteSpace(DocRev)) .OrderByDescending(DocRev => new Version(DocRev)) .ToArray() .FirstOrDefault(), forceRefresh, "TopDocRev", DocTypeName);
/// <summary> /// Further filters GetFormObjectMappedProperties stripping IgnoreDataMember,XmlIgnoreAttribute,ScriptIgnoreAttribute & /// NotMapped properties /// </summary> /// <param name="filled">when true, ensures the properties have been explicitly set</param> /// <returns></returns> public PropertyInfo[] GetFormObjectNavProperties(bool filled = false) { PropertyInfo[] p = CacheMan.Cache(() => GetFormObjectMappedProperties(false) .Where(m => m.DeclaringType != typeof(BaseDoc) && m.DeclaringType != typeof(BaseAutoIdent) ) .ToArray(), false, "GetFormObjectNavProperties", GetType().FullName, "GetFormObjectNavProperties"); return(p.Where(m => !filled || !this.IsDefaultValue(m)).ToArray()); }
/// <summary> /// Reads the DOCREV from the local AppDomain working_folder\form\*. When nothing is found the nosql store for the most /// current DOCREV. The first item in descending string order. /// </summary> /// <param name="DocTypeName"></param> /// <returns>string.Empty if nothing is found</returns> public string TopDocRev(string DocTypeName, bool forceRefresh) { //TODO:change solutionVersion properties to System.Version return(CacheMan.Cache(() => _DefaultTopDocFilesystemTemplateController.TopDocRev(DocTypeName) ?? _OtherIDocResourceControllers //DOCREVs should always come from the embedded controller .Where(m => (DocTypeName == "DOCREV") == (typeof(EmbededTemplateController) == m.GetType())) .Select(m => m.TopDocRev(DocTypeName)) .Where(DocRev => !string.IsNullOrWhiteSpace(DocRev)) .OrderByDescending(DocRev => new Version(DocRev)) .ToArray() .FirstOrDefault(), forceRefresh, "TopDocRev", DocTypeName)); }
/// <summary> /// Intended time of use it that of a "post cache reset" time. If cache has been cleared, all the logic behind this /// method will run. /// </summary> public static void TryDocRevImporting() => CacheMan.Cache(() => { ReadIDocModelCSharpCode(); dirs.PushRange(Directory .EnumerateDirectories(FilesystemTemplateController.DirectoryPath) .Select(dirpath => new DirectoryInfo(dirpath).FullName) .Where(dirpath => !dirs.Contains(dirpath)) .OrderByDescending(dirpath => new[] { Directory.GetLastWriteTime(dirpath).Ticks } .Union( GetRelativeFilePathsInDirectoryTree(dirpath, true) .Select(filepath => File.GetLastWriteTimeUtc(filepath).Ticks)) .Max()) .ToArray()); // starting with the newest directory, synchronously process each & abend when its found that nothing is imported string dir; while (dirs.TryPop(out dir) && ImportContentFolder(dir).Any()) { } // process the remaining directories queued asynchronously (as this is a resource intensive) on the chance that the "GetLastWriteTimeUtc" lied to us if (!dirs.IsEmpty) { Tasker.StartNewTask(() => { while (dirs.TryPop(out dir)) { ImportContentFolder(dir); } return(true); }); } return(new object()); }, false, "ImportDocModelsRunOnce" );
internal static IDocTextInterpreter InstanceLocatorByName(string DocTypeName, string DocRev = null) { return(CacheMan.Cache(() => { if (DocTypeName == "DOCREV") { return _otherInstances[0]; } foreach (IDocTextInterpreter _IDocDataInterpreter in _otherInstances) { //TODO:Need a better way of discovering what IDocDataInterpreter can process the given document; it needs to consider the DocRev also if (_IDocDataInterpreter.Processable(DocTypeName, DocRev)) { return _IDocDataInterpreter; } } throw new Exception(string.Format("{0} could not locate a DocDataInterpreter to process the data passed", typeof(DocInterpreter).Name)); }, false, "InstanceLocatorByName", DocTypeName, DocRev ?? string.Empty)); }
/// <summary> /// serialize-able, settable properties /// </summary> /// <param name="filled">when true, ensures the properties have been explicitly set</param> /// <returns></returns> public PropertyInfo[] GetFormObjectMappedProperties(bool filled = false) { PropertyInfo[] p = CacheMan.Cache(() => { return(GetType().GetProperties( BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty).Where(m => m.CanWrite && m.PropertyType.IsPublic && m.PropertyType.IsSerializable && !m.PropertyType.IsArray && !ExpressionParser.GetNonNullableType(m.PropertyType).IsAbstract && !ExpressionParser.GetNonNullableType(m.PropertyType).IsGenericType).ToArray()); }, false, GetType().FullName, "GetFormObjectMappedProperties"); return(p.Where(m => !filled || !this.IsDefaultValue(m)).ToArray()); }
public static string CalcSqlSchemaName(this BaseDoc _BaseDoc) { return(CacheMan.Cache(() => { int checksum = 0; foreach (var t in _BaseDoc.ListRelatedEntities() .Select(m => new { TablePocoType = m, TableName = m.Name.ToLower() }) .OrderBy(m => m.TableName)) { checksum ^= t.TableName.GetHashCode(); foreach (var p in t .TablePocoType .GetProperties() .Select(p => new { ColumnAttribute = p.GetCustomAttributes(true).OfType <ColumnAttribute>().FirstOrDefault(), DataTypeName = p.PropertyType.Name }).Where(m => m.ColumnAttribute != null && !string.IsNullOrWhiteSpace(m.ColumnAttribute.Name)) .OrderBy(m => m.ColumnAttribute.Name.ToLower())) { checksum ^= p.ColumnAttribute.Name.ToLower().GetHashCode() ^ p.DataTypeName.GetHashCode(); } } return string.Format( "{0}_{1}", _BaseDoc.DocTypeName, Base36.Encode(Math.Abs(checksum))); }, false, _BaseDoc.GetType().FullName)); }
/// <summary> /// </summary> /// <returns>current DocTypeNames known to this system</returns> public static List <string> DocTypeNames() { return(CacheMan.Cache(() => DocTypeServedItems().Select(typ => typ.Name).ToList(), false, "DocTypeNames")); }