Exemple #1
0
        public IProject OpenProjectFile(string projectFile)
        {
            ProjectSerializeData data           = null;
            IProject             currentProject = null;

            this.LastErrMsg = string.Empty;
            string fileName = Path.GetFileName(projectFile);

            try
            {
                try
                {
                    using (FileStream stream = new FileStream(projectFile, FileMode.Open))
                    {
                        BinaryFormatter formatter = new BinaryFormatter();
                        data = formatter.Deserialize(stream) as ProjectSerializeData;
                    }
                }
                catch (SerializationException)
                {
                    ProjectSingleton.Instance.OpenV3R5ProjectFile = true;
                    data = new ProjectConversion(projectFile).SerializeDataConvert();
                }
                this.m_PrjSerializeData = data;
                ProjectLogicMgr.Instance.CreateProject(this.CfgPath, data.NetType, null);
                currentProject = ProjectSingleton.CurrentProject;
                ProjectSingleton.CurrentProject.ProjectSerializeData.PrintSeeting = this.m_PrjSerializeData.PrintSeeting;
                ProjectSingleton.CurrentProject.ProjectSerializeData.PSCollection = this.m_PrjSerializeData.PSCollection;
                MainFormSingleton.CurrentMainForm.ResourceMrgMenuItem.Visible     = false;
                ProjectInfo projectInfo = new ProjectInfo
                {
                    projectName     = fileName,
                    projectDocument = projectFile,
                    projectLossPath = this.GetLossPath(projectFile)
                };
                currentProject.Name           = fileName;
                currentProject.ProjectIPLFile = projectFile;
                (currentProject as GeneralProjectEntity).AllSubSysData = data.AllSubSysData;
                currentProject = ProjectDataConvert.Convert(currentProject, data.Version);
                this.CreateLossPath(projectInfo.projectLossPath);
                this.LockProjectFile(projectInfo);
            }
            catch (IOException exception)
            {
                this.LastErrMsg = "The \"" + fileName + "\" had been opened by another application!";
                WriteLog.Logger.Error("OpenProjectFile failed!:" + exception.Message);
                return(null);
            }
            catch (Exception exception2)
            {
                this.LastErrMsg = "Open \"" + fileName + "\" failed!";
                WriteLog.Logger.Error("OpenProjectFile failed!:" + exception2.Message);
                return(null);
            }
            return(currentProject);
        }
 public GeneralProjectEntity(NetWorkType netType, string cfgFile)
 {
     this.m_ProjectSerializeData       = new ProjectSerializeData();
     this.ProjectSerializeData.NetType = netType;
     this.m_CfgFile       = cfgFile;
     this.m_AppContext    = new ApplicationContext();
     this.m_AllSubSys     = new List <IGeneralSubSys>();
     this.m_SubSysConvert = new Dictionary <string, IDataConvert>();
     this.ProjectIPLFile  = string.Empty;
     this.NeedPromptSave  = false;
 }
Exemple #3
0
 public IProject OpenProjectFile(string projectFile)
 {
     ProjectSerializeData data = null;
     IProject currentProject = null;
     this.LastErrMsg = string.Empty;
     string fileName = Path.GetFileName(projectFile);
     try
     {
         try
         {
             using (FileStream stream = new FileStream(projectFile, FileMode.Open))
             {
                 BinaryFormatter formatter = new BinaryFormatter();
                 data = formatter.Deserialize(stream) as ProjectSerializeData;
             }
         }
         catch (SerializationException)
         {
             ProjectSingleton.Instance.OpenV3R5ProjectFile = true;
             data = new ProjectConversion(projectFile).SerializeDataConvert();
         }
         this.m_PrjSerializeData = data;
         ProjectLogicMgr.Instance.CreateProject(this.CfgPath, data.NetType, null);
         currentProject = ProjectSingleton.CurrentProject;
         ProjectSingleton.CurrentProject.ProjectSerializeData.PrintSeeting = this.m_PrjSerializeData.PrintSeeting;
         ProjectSingleton.CurrentProject.ProjectSerializeData.PSCollection = this.m_PrjSerializeData.PSCollection;
         MainFormSingleton.CurrentMainForm.ResourceMrgMenuItem.Visible = true;
         ProjectInfo projectInfo = new ProjectInfo();
         projectInfo.projectName = fileName;
         projectInfo.projectDocument = projectFile;
         projectInfo.projectLossPath = this.GetLossPath(projectFile);
         currentProject.Name = fileName;
         currentProject.ProjectIPLFile = projectFile;
         (currentProject as GeneralProjectEntity).AllSubSysData = data.AllSubSysData;
         currentProject = ProjectDataConvert.Convert(currentProject, data.Version);
         this.CreateLossPath(projectInfo.projectLossPath);
         this.LockProjectFile(projectInfo);
     }
     catch (IOException exception)
     {
         this.LastErrMsg = "The \"" + fileName + "\" had been opened by another application!";
         WriteLog.Logger.Error("OpenProjectFile failed!:" + exception.Message);
         return null;
     }
     catch (Exception exception2)
     {
         this.LastErrMsg = "Open \"" + fileName + "\" failed!";
         WriteLog.Logger.Error("OpenProjectFile failed!:" + exception2.Message);
         return null;
     }
     return currentProject;
 }