Exemple #1
0
 /// <summary>
 /// 添加新的保存记录对象
 /// </summary>
 public void NewSaveOfProject(_Projects p_infos)
 {
     /* DataRow row = this.m_HistoryTable.NewRow();
      * row["Name"] = p_infos.Name;
      * row["Date"] = DateTime.Now;
      * row["FileName"] = DateTime.Now + "_" + row["Key"];
      * this.m_HistoryTable.Rows.Add(row);*/
 }
Exemple #2
0
        public override void InSerializable(object e)
        {
            _Projects proj = e as _Projects;

            this.Parent        = proj;
            this.StrustObject  = new _DataObjectList();
            this.Reveal        = new _Reveal(this);
            this.Property      = new _En_Property(this);
            this.NonSeriObject = new _DataObjectList();
            this.NonSeriObject.Add("工程统计", new _ProjStatistics());
            //proj.StrustObject.Add(this.Directory.Key, this);
        }
Exemple #3
0
        /// <summary>
        /// 读取文件
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static _Projects BinaryDeserializeByProject(string fileName)
        {
            try
            {
                using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
                {
                    BinaryFormatter formater = new BinaryFormatter();
                    long            lenth    = stream.Length;
                    ArrayList       list11   = new ArrayList();
                    _Projects       proj     = null;
                    _Engineering    en       = null;

                    while (stream.Position != lenth)
                    {
                        object obj = formater.Deserialize(stream);
                        if (obj is _Projects)
                        {
                            proj = obj as _Projects;
                            proj.StrustObject = new _DataObjectList();
                        }
                        if (proj != null)
                        {
                            if (obj is _Engineering)
                            {
                                en              = obj as _Engineering;
                                en.Parent       = proj;
                                en.StrustObject = new _DataObjectList();
                                proj.StrustObject.Add(en.Directory.Key, en);
                            }
                            if (obj is _UnitProject)
                            {
                                _UnitProject un = obj as _UnitProject;
                                un.Parent = en;
                                en.StrustObject.Add(un.Directory.Key, un);
                            }
                        }
                    }
                    return(proj);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 二进制序列化对象
        /// </summary>
        /// <param name="obj"></param>
        public static void BinarySerialize(string path, _Projects obj)
        {
            using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                BinaryFormatter formater = new BinaryFormatter();

                formater.Serialize(stream, obj);
                //循环单项
                foreach (_Engineering info in obj.StrustObject.ObjectList.Values)
                {
                    formater.Serialize(stream, info);
                    foreach (_UnitProject up in info.StrustObject.ObjectList.Values)
                    {
                        formater.Serialize(stream, up);
                    }
                }
            }
        }