Exemple #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);
        }
Exemple #2
0
        private static void BuildProgIdListing(string mainPath, string bcfPath, string extendBcfPath, string fileName, Dictionary <string, Assembly> assemblyDic)
        {
            LibBinaryFormatter formatter = new LibBinaryFormatter();

            if (Directory.Exists(bcfPath))
            {
                ProgIdConfigListing progIdListing = BuildProgId(bcfPath, extendBcfPath, assemblyDic);
                using (FileStream fs = new FileStream(Path.Combine(mainPath, "Runtime", fileName), FileMode.Create))
                {
                    formatter.Serialize(fs, progIdListing);
                }
            }
        }
Exemple #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);
        }
Exemple #4
0
        private void SaveSqlModel(string name, DataSet dataSet)
        {
            string preFix = name.Substring(0, name.IndexOf('.'));
            string path   = Path.Combine(EnvProvider.Default.MainPath, "SqlModel", preFix);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            LibSqlModel libDataSet = new LibSqlModel();

            libDataSet.CloneDataSet(dataSet);
            using (FileStream fs = new FileStream(Path.Combine(path, string.Format("{0}.bin", name)), FileMode.Create, FileAccess.Write))
            {
                LibBinaryFormatter formatter = new LibBinaryFormatter();
                formatter.Serialize(fs, libDataSet);
            }
        }
Exemple #5
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);
        }