Exemplo n.º 1
0
        public static void Save(FlowProject Project)
        {
            IFormatter formatter = new BinaryFormatter();
            FileStream fs        = null;

            try
            {
                fs = new FileStream(Project.FileFullName, FileMode.Create);
                formatter.Serialize(fs, Project);

                AddLogToMainLog("保存工程成功! " + Project.FileFullName);
                MessageBox.Show("保存工程成功!");
            }
            catch (Exception emx)
            {
                MessageBox.Show(emx.Message);
                AddLogToMainLog("保存工程失败! " + Project.FileFullName);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
        }
Exemplo n.º 2
0
        public static bool LoadProject(string filename)
        {
            bool       res = false;
            FileStream fs  = null;

            try
            {
                FlowProject Project = null;
                fs = new FileStream(filename, FileMode.Open);
                fs.Seek(0, SeekOrigin.Current);
                IFormatter formatter = new BinaryFormatter();
                while (fs.Position < fs.Length)
                {
                    Project = (FlowProject)formatter.Deserialize(fs);
                }
                if (Project != null)
                {
                    if (Projects.Exists(x => x.ProjectID == Project.ProjectID))
                    {
                        FrmDialog.ShowDialog(null, "该工程已经被打开");
                    }
                    else
                    {
                        ProjectPasswordDialog confirmDig = new ProjectPasswordDialog(Project);
                        if (confirmDig.ShowDialog() == DialogResult.OK)
                        {
                            Project.FileFullName = filename;
                            //初始化所有图元
                            Mediator.ToolForm.InitTreeView(Project);
                            Mediator.ToolForm.InitTreeUser(Project);
                            Mediator.ToolForm.InitTreeConnections(Project);

                            Projects.Add(Project);
                            res = true;
                        }
                    }
                }
            }
            catch (Exception emx)
            {
                MessageBox.Show(emx.Message + " " + emx.InnerException);
                AddLogToMainLog(emx.Message);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            return(res);
        }
Exemplo n.º 3
0
 public static void SaveProject(FlowProject Project)
 {
     if (Project == null)
     {
         FrmDialog.ShowDialog(FlowDesign, "没有工程可保存!");
         return;
     }
     if (Project.FileFullName == "")
     {
         SaveAsProject(Project);
     }
     else
     {
         Save(Project);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 准备开始发布流程,要发布的流程工程
        /// </summary>
        public static void PublishFlowStart(FlowProject project)
        {
            if (FlowDataBaseManager.IOServer == null)
            {
                AddLogToMainLog("发布流程失败,您当前所在的采集站没有采集站工程!");
                MessageBox.Show(FlowDesign, "发布流程失败,您当前所在的采集站没有采集站工程!");
                return;
            }
            TcpData tcpData    = new TcpData();
            string  commandStr = "PROJECTID:" + project.ProjectID + "#IO_SERVER_ID:" + FlowDataBaseManager.IOServer.SERVER_ID + "#RESULT:#MSG:工程发布请求";

            byte[] publishbytes = tcpData.StringToTcpByte(commandStr, Scada.AsyncNetTcp.ScadaTcpOperator.流程发布请求);
            //发送登录命令
            TcpClient.Send(new ArraySegment <byte>(publishbytes));
            AddLogToMainLog("发布流程命令请求已经下发到服务器,请耐心等待服务器进一步提示!");
        }
Exemplo n.º 5
0
        public static void CreateNewProject()
        {
            CreateProjectDialog dig = new CreateProjectDialog();

            if (dig.ShowDialog(FlowDesign) == DialogResult.OK)
            {
                FlowProject Project = new FlowProject();
                Project.Title        = dig.ProjectTitle;
                Project.Password     = dig.Password;
                Project.ProjectID    = GUIDTo16.GuidToLongID().ToString();
                Project.FileFullName = dig.FileFullName;
                Mediator.ToolForm.InitTreeView(Project);
                Mediator.ToolForm.InitTreeUser(Project);
                Mediator.ToolForm.InitTreeConnections(Project);

                Projects.Add(Project);
            }
        }
Exemplo n.º 6
0
        public static void SaveAsProject(FlowProject Project)
        {
            if (Project == null)
            {
                FrmDialog.ShowDialog(FlowDesign, "没有工程可保存!");
                return;
            }
            SaveFileDialog dig = new SaveFileDialog();

            dig.Filter = "流程图(*.flow)|*.flow";
            if (dig.ShowDialog(FlowDesign) == DialogResult.OK)
            {
                try
                {
                    Project.FileFullName = dig.FileName;
                    Save(Project);
                }
                catch (Exception ex)
                {
                    FlowManager.ThrowExceptionToMain(ex);
                }
            }
        }