示例#1
0
        static void ObjWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker ProjWorker = sender as BackgroundWorker;

            object[] param   = e.Argument as object[];
            FileInfo file    = param[0] as FileInfo;
            CResult  cresult = param[1] as CResult;

            using (FileStream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
            {
                GZipStream zip = new GZipStream(stream, CompressionMode.Decompress);
                {
                    BinaryFormatter formater = new BinaryFormatter();
                    _FileHeader     header   = (_FileHeader)formater.Deserialize(zip);
                    _StructSource   ds       = (_StructSource)formater.Deserialize(zip);
                    //创建新的单位工程(单位工程业务体)
                    _UnitProject unit = new _UnitProject();
                    unit.Ready(ds);

                    /*obj.InSerializable(file);
                     *
                     * //初始化新的临时对象(不参与序列化此对象每次使用需要呗初始化)
                     * obj.Property.Temporary = new _Temporary();
                     * //默认同步临时库对象
                     * obj.Property.Temporary.Libraries = obj.Property.DLibraries.Copy();
                     * obj.Property.Temporary.Libraries.Init(APP.Application);*/
                    cresult.Value   = unit;
                    cresult.Success = true;
                    e.Result        = new object[] { file, cresult };
                }
                zip.Close();
            }
        }
示例#2
0
        void bWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bWorker = sender as BackgroundWorker;

            object[]  param = e.Argument as object[];
            _COBJECTS obj   = param[1] as _COBJECTS;
            string    path  = param[0].ToString();

            ToolKit.GetDirectoryInfo(path.Substring(0, path.LastIndexOf("\\")));
            using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    GZipStream      zip      = new GZipStream(stream, CompressionMode.Compress);
                    BinaryFormatter formater = new BinaryFormatter();
                    obj.StructSource.AcceptChanges();
                    _FileHeader header = new _FileHeader();
                    header.Set("总造价", obj.StatusInfo.当前工程总造价.ToString());
                    formater.Serialize(ms, header);
                    formater.Serialize(ms, obj.StructSource);
                    byte[] buffer = ms.ToArray();
                    zip.Write(buffer, 0, buffer.Length);
                    zip.Close();
                    e.Result = path;
                }
            }
        }
示例#3
0
        /*/// <summary>
         * /// 项目配置信息
         * /// </summary>
         * /// <param name="tran"></param>
         * private void SaveEx_ProjInfomation(IDbTransaction tran)
         * {
         *  foreach (DataRow row in this.Current.StructSource.ModelInfomation.Rows)
         *  {
         *      if (row.RowState != DataRowState.Deleted)
         *      {
         *          this.ProjDataBase.Insert_ProjInfomation(row, tran);
         *      }
         *  }
         * }
         *
         * /// <summary>
         * /// 项目结构表数据
         * /// </summary>
         * /// <param name="tran"></param>
         * private void SaveEx_Project(IDbTransaction tran)
         * {
         *  foreach (DataRow row in this.Current.StructSource.ModelProject.Rows)
         *  {
         *      if (row.RowState != DataRowState.Deleted)
         *      {
         *          this.ProjDataBase.Insert_Project(row, tran);
         *      }
         *  }
         * }*/

        #endregion

        /// <summary>
        /// 提供一套静态方法此处获取头文件对象
        /// </summary>
        /// <param name="p_FileInfo"></param>
        /// <returns></returns>
        public static _FileHeader OnlyReadHeader(FileInfo p_FileInfo)
        {
            _HeaderBase db = new _HeaderBase(string.Format(_DataBase.AccessConnString, p_FileInfo.FullName));
            _FileHeader fh = db.Get_FileHeader();

            db.Conn = null;
            db      = null;
            System.GC.Collect();
            return(fh);
        }
示例#4
0
        /// <summary>
        /// 批量开始工作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void PLWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bWorker = sender as BackgroundWorker;

            object[]        param = e.Argument as object[];
            ArrayList       obj   = param[1] as ArrayList;
            string          path  = param[0].ToString();
            FileInfo        fi;
            GZipStream      zip;
            string          ph;
            BinaryFormatter formater;
            DataSet         ds;
            _FileHeader     header;

            byte[] buffer;
            foreach (_COBJECTS info in obj)
            {
                ph = string.Format("{0}\\{1}.JGCX", path, info.Name);
                fi = new FileInfo(ph);
                if (fi.Exists)
                {
                    ph = string.Format("{0}\\复件 {1}.JGCX", path, info.Name);
                }

                using (FileStream stream = new FileStream(ph, FileMode.Create, FileAccess.Write, FileShare.None))
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        zip      = new GZipStream(stream, CompressionMode.Compress);
                        formater = new BinaryFormatter();
                        //info.StructSource.AcceptChanges();
                        ds = info.StructSource.Copy();
                        ds.AcceptChanges();

                        header = new _FileHeader();
                        header.Set("总造价", info.StatusInfo.当前工程总造价.ToString());
                        formater.Serialize(ms, header);

                        formater.Serialize(ms, ds);
                        buffer = ms.ToArray();
                        zip.Write(buffer, 0, buffer.Length);
                        zip.Close();
                    }
                }
            }
            e.Result = path;
        }
示例#5
0
        /// <summary>
        /// 获取头数据
        /// </summary>
        /// <returns></returns>
        public _FileHeader Get_FileHeader()
        {
            string sql = "select [value] from 变量表 where [key] = 'ZZJ' and [Type] = '-3'";

            object obj = this.ExecuteScalar(sql);

            if (obj != null)
            {
                _FileHeader info = new _FileHeader();
                info.Set("总造价", obj);
                return(info);
            }
            else
            {
                return(new _FileHeader());
            }
        }
示例#6
0
        /// <summary>
        /// 单位工程处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        static void UnitWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundWorker ProjWorker = sender as BackgroundWorker;
                object[]         param      = e.Argument as object[];
                ApplicationForm  form       = param[0] as ApplicationForm;
                _Files           file       = param[1] as _Files;
                _Business        bus        = param[2] as _Business;

                using (FileStream stream = new FileStream(file.FullName, FileMode.Open, FileAccess.Read))
                {
                    //stream.Position = 0;
                    GZipStream zip = new GZipStream(stream, CompressionMode.Decompress, true);
                    {
                        //zip.Seek(0, SeekOrigin.Begin);
                        BinaryFormatter formater = new BinaryFormatter();
                        _FileHeader     header   = (_FileHeader)formater.Deserialize(zip);
                        _StructSource   ds       = (_StructSource)formater.Deserialize(zip);
                        //创建新的单位工程(单位工程业务体)
                        _UnitProject unit = new _UnitProject();
                        unit.Files = file;
                        unit.Ready(ds);
                        //初始化新的临时对象(不参与序列化此对象每次使用需要呗初始化)

                        /*obj.Property.Temporary = new _Temporary();
                         * //默认同步临时库对象
                         * obj.Property.Temporary.Libraries = obj.Property.DLibraries.Copy();
                         * obj.Property.Temporary.Libraries.Init(APP.Application);
                         * obj.Application = APP.Application;*/
                        e.Result = new object[] { form, unit, bus };
                    }
                    zip.Close();
                }
            }
            catch (Exception)
            {
                MsgBox.Show(_Prompt.无法识别的打开文件, MessageBoxButtons.OK);
            }
        }
示例#7
0
 /// <summary>
 /// 读取数据的头文件对象
 /// </summary>
 /// <param name="p_FileInfo"></param>
 /// <returns></returns>
 static _FileHeader OnlyReadHeader(FileInfo p_FileInfo)
 {
     using (FileStream stream = new FileStream(p_FileInfo.FullName, FileMode.Open, FileAccess.Read))
     {
         GZipStream zip = new GZipStream(stream, CompressionMode.Decompress);
         {
             BinaryFormatter formater = new BinaryFormatter();
             _FileHeader     header   = null;
             try
             {
                 header = (_FileHeader)formater.Deserialize(zip);
             }
             catch (Exception)
             {
                 header = null;
             }
             finally
             {
                 zip.Close();
             }
             return(header);
         }
     }
 }