Пример #1
0
        /// <summary>
        /// 获取功能模块确定的GridScheme
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="entryParam"></param>
        /// <returns></returns>
        public override LibGridScheme GetDefinedGridScheme(LibHandle handle, LibEntryParam entryParam)
        {
            LibGridScheme gridScheme = null;
            StringBuilder builder    = new StringBuilder();

            if (entryParam != null)
            {
                foreach (var item in entryParam.ParamStore)
                {
                    builder.AppendFormat("{0}", item.Value);
                }
            }
            string           schemeName    = string.Format("{0}{1}List.bin", "dm.Directory", builder.ToString());
            LibDisplayScheme displayScheme = null;
            string           path          = Path.Combine(EnvProvider.Default.MainPath, "Scheme", "ShowScheme", schemeName);

            if (File.Exists(path))
            {
                LibBinaryFormatter formatter = new LibBinaryFormatter();
                using (FileStream fs = new FileStream(path, FileMode.Open))
                {
                    displayScheme = (LibDisplayScheme)formatter.Deserialize(fs);
                }
            }
            if (displayScheme != null)
            {
                gridScheme = displayScheme.GridScheme[0];
            }
            return(gridScheme);
        }
Пример #2
0
        public LibSqlModel GetSqlModel(string name)
        {
            #region 序列化
            byte[]             mybyte    = Default.StringGetBytes(name);
            LibSqlModel        dataSet   = null;
            LibBinaryFormatter formatter = new LibBinaryFormatter();
            if (mybyte != null && mybyte.Length != 0)
            {
                MemoryStream stream = new MemoryStream(mybyte);
                stream.Position = 0;
                dataSet         = (LibSqlModel)formatter.Deserialize(stream);
            }
            #endregion


            if (dataSet == null || mybyte == null)
            {
                object lockItem = lockObjDic.GetOrAdd(name, new object());
                lock (lockItem)
                {
                    string preFix = name.Substring(0, name.IndexOf('.'));
                    string path   = Path.Combine(EnvProvider.Default.MainPath, "SqlModel", preFix, string.Format("{0}.bin", name));
                    if (File.Exists(path))
                    {
                        using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
                        {
                            dataSet     = (LibSqlModel)formatter.Deserialize(fs);
                            fs.Position = 0;
                            BinaryReader br    = new BinaryReader(fs);
                            byte[]       bytes = br.ReadBytes((int)br.BaseStream.Length);
                            br.Close();
                            Default.StringSetBytes(name, bytes, new TimeSpan(0, 30, 0));
                        }
                    }
                }
            }
            return(dataSet);
        }
Пример #3
0
        public static ProgIdConfigListing GetProgIdListing(string mainPath)
        {
            ProgIdConfigListing progIdListing = null;
            LibBinaryFormatter  formatter     = new LibBinaryFormatter();
            string filePath = Path.Combine(mainPath, "Runtime", BcfFileName);

            if (File.Exists(filePath))
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    progIdListing = (ProgIdConfigListing)formatter.Deserialize(fs);
                }
            }
            return(progIdListing);
        }