コード例 #1
0
        private void button_findOutputFormat_Click(object sender, EventArgs e)
        {
            // 出现对话框,询问Project名字
            GetProjectNameDlg dlg = new GetProjectNameDlg();
            MainForm.SetControlFont(dlg, this.Font, false);

            dlg.Text = "请指定 订单输出 方案名";
            dlg.scriptManager = this.ScriptManager;
            dlg.ProjectName = this.comboBox_outputFormat.Text;
            dlg.NoneProject = false;
            dlg.DisableNoneProject = true;

            this.AppInfo.LinkFormState(dlg, "OrderOutputItemDialog_GetProjectNameDlg_state");
            dlg.ShowDialog(this);
            this.AppInfo.UnlinkFormState(dlg);

            if (dlg.DialogResult != DialogResult.OK)
                return;

            this.comboBox_outputFormat.Text = dlg.ProjectName;
        }
コード例 #2
0
ファイル: CfgDlg.cs プロジェクト: renyh1013/dp2
        private void button_print_findProject_Click(object sender, EventArgs e)
        {
            // 出现对话框,询问Project名字
            GetProjectNameDlg dlg = new GetProjectNameDlg();
            MainForm.SetControlFont(dlg, this.Font, false);

            dlg.scriptManager = this.MainForm.OperHistory.ScriptManager;
            dlg.ProjectName = this.textBox_print_projectName.Text;
            dlg.NoneProject = false;

            this.MainForm.AppInfo.LinkFormState(dlg, "GetProjectNameDlg_state");
            dlg.ShowDialog(this);
            this.MainForm.AppInfo.UnlinkFormState(dlg);


            if (dlg.DialogResult != DialogResult.OK)
                return;

            this.textBox_print_projectName.Text = dlg.ProjectName;
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: renyh1013/dp2
        private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            string strError = "";

            if (e.Button == toolBarButton_stop)
            {
                stopManager.DoStopActive();
            }

            if (e.Button == toolBarButton_begin)
            {
                // 出现对话框,询问Project名字
                GetProjectNameDlg dlg = new GetProjectNameDlg();
                MainForm.SetControlFont(dlg, this.DefaultFont);

                dlg.scriptManager = this.scriptManager;
                dlg.ProjectName = AppInfo.GetString(
                    "main",
                    "lastUsedProject",
                    "");
                dlg.NoneProject = Convert.ToBoolean(AppInfo.GetInt(
                    "main",
                    "lastNoneProjectState",
                    0));

                this.AppInfo.LinkFormState(dlg, "GetProjectNameDlg_state");
                dlg.ShowDialog(this);
                this.AppInfo.UnlinkFormState(dlg);


                if (dlg.DialogResult != DialogResult.OK)
                    return;

                string strProjectName = "";
                string strLocate = "";	// 方案文件目录

                if (dlg.NoneProject == false)
                {
                    // string strWarning = "";

                    strProjectName = dlg.ProjectName;

                    // 获得方案参数
                    // strProjectNamePath	方案名,或者路径
                    // return:
                    //		-1	error
                    //		0	not found project
                    //		1	found
                    int nRet = scriptManager.GetProjectData(
                        strProjectName,
                        out strLocate);

                    if (nRet == 0)
                    {
                        strError = "方案 " + strProjectName + " 没有找到...";
                        goto ERROR1;
                    }
                    if (nRet == -1)
                    {
                        strError = "scriptManager.GetProjectData() error ...";
                        goto ERROR1;
                    }
                }

                AppInfo.SetString(
                    "main",
                    "lastUsedProject",
                    strProjectName);
                AppInfo.SetInt(
                    "main",
                    "lastNoneProjectState",
                    Convert.ToInt32(dlg.NoneProject));



                if (tabControl_main.SelectedTab == this.tabPage_range)
                {
                    this.DoExport(strProjectName, strLocate);
                }
                else if (tabControl_main.SelectedTab == this.tabPage_import)
                {
                    this.DoImport(strProjectName, strLocate);
                }

            }

            return;

        ERROR1:
            MessageBox.Show(this, strError);
        }
コード例 #4
0
ファイル: ProjectManageDlg.cs プロジェクト: renyh1013/dp2
        // 导出
        private void button_export_Click(object sender, System.EventArgs e)
        {
            // 未按下Control键, 一般导出功能
            if (!(Control.ModifierKeys == Keys.Control))
            {
                button_CopyToFile_Click(null, null);
                return;
            }

            // 特殊导出功能
            int nRet;
            string strError = "";

            TreeNode node = treeView1.SelectedNode;

            if (node == null)
            {
                MessageBox.Show(this, "请先选定要导出的方案...");
                return;
            }

            string strSourceProjectName = node.FullPath;

            string strSourceLocate = "";

            // 获得源方案参数
            // strProjectNamePath	方案名,或者路径
            // return:
            //		-1	error
            //		0	not found project
            //		1	found
            nRet = scriptManager.GetProjectData(
                strSourceProjectName,
                out strSourceLocate);
            if (nRet == -1)
            {
                MessageBox.Show(this, "source GetProjectData() " + strSourceProjectName + " error...");
                return;
            }
            if (nRet == 0)
            {
                MessageBox.Show(this, "source project " + strSourceProjectName + " not found error...");
                return;
            }

            // 询问project*.xml文件全路径
            SaveFileDialog projectDefFileDlg = new SaveFileDialog();

            projectDefFileDlg.CreatePrompt = false;
            projectDefFileDlg.FileName = "outer_projects.xml";
            projectDefFileDlg.InitialDirectory = Environment.CurrentDirectory;
            projectDefFileDlg.Filter = "projects files (outer*.xml)|outer*.xml|All files (*.*)|*.*";
            //dlg.FilterIndex = 2 ;
            projectDefFileDlg.RestoreDirectory = true;

            if (projectDefFileDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            // 如果文件不存在,则创建之
            if (File.Exists(projectDefFileDlg.FileName) == false)
                ScriptManager.CreateDefaultProjectsXmlFile(projectDefFileDlg.FileName,
                    "outercfgs");

            // 创建ScriptManager对象
            ScriptManager newScriptManager = new ScriptManager();
            newScriptManager.applicationInfo = null;	//applicationInfo;
            newScriptManager.CfgFilePath = projectDefFileDlg.FileName;
            newScriptManager.Load();

            // 查询Project路径+名是否已经在输出的projects.xml已经存在

            REDOEXPORT:

            string strTargetLocate = "";
            // 获得方案参数
            // strProjectNamePath	方案名,或者路径
            // return:
            //		-1	error
            //		0	not found project
            //		1	found
            nRet = newScriptManager.GetProjectData(
                strSourceProjectName,
                out strTargetLocate);
            if (nRet == -1)
            {
                MessageBox.Show(this, "target GetProjectData() " + strSourceProjectName + " error...");
                return;
            }

            // 发现重名,询问是否覆盖
            if (nRet == 1)
            {
                string strText = "外部方案集\r\n  (由文件 '" + projectDefFileDlg.FileName + "' 管理)\r\n已经存在一个与源 \r\n'"
                    + strSourceProjectName + "'\r\n 同名的方案\r\n  (其磁盘目录位于 '"
                    + strTargetLocate + "')。\r\n\r\n"
                    + "请问是否覆盖此方案?\r\n(Yes=覆盖; No=改名后导出;Cancel=放弃操作)\r\n\r\n注意:覆盖后无法还原。";


                DialogResult msgResult = MessageBox.Show(this,
                    strText,
                    "script",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);
                if (msgResult == DialogResult.Cancel)
                    return;

                if (msgResult == DialogResult.Yes)
                {	// 覆盖
                    // 拷贝目录
                    nRet = PathUtil.CopyDirectory(strSourceLocate,
                        strTargetLocate,
                        true,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    goto END1;
                }
                else
                {	// 改名


                    // 询问新名字
                    GetProjectNameDlg nameDlg = new GetProjectNameDlg();
                    GuiUtil.AutoSetDefaultFont(nameDlg);

                    nameDlg.Text = "请选定目标(外部)新方案名";
                    nameDlg.scriptManager = newScriptManager;
                    nameDlg.ProjectName = strSourceProjectName;

                    nameDlg.StartPosition = FormStartPosition.CenterScreen;
                    nameDlg.ShowDialog(this);

                    if (nameDlg.DialogResult != DialogResult.OK)
                        goto END2;

                    strSourceProjectName = nameDlg.ProjectName;
                    goto REDOEXPORT;

                }



            }
            else // 不重名,直接复制
            {
                // 创建一个新的project,获得strTargetLocate
                int nPrefixNumber = -1;	// 0
                strTargetLocate = newScriptManager.NewProjectLocate(
                    PathUtil.PureName(strSourceLocate),	// 尽量取和源相同的末级目录名
                    ref nPrefixNumber);

                // 拷贝目录
                nRet = PathUtil.CopyDirectory(strSourceLocate,
                    strTargetLocate,
                    true,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                // 实际插入project参数
                XmlNode projNode = newScriptManager.NewProjectNode(
                    strSourceProjectName,	// 沿用原来的名字
                    strTargetLocate,
                    false);	// false表示不需要创建目录和缺省文件

            }

        END1:

            newScriptManager.Save();
            MessageBox.Show(this, "方案 '" + strSourceProjectName
                + "' \r\n已经成功导出到文件 \r\n'"
                + newScriptManager.CfgFilePath + "' \r\n所管理的外部方案集内。");
            return;
        END2:
            return;
        ERROR1:
            MessageBox.Show(this, strError);
            return;
        }
コード例 #5
0
ファイル: ProjectManageDlg.cs プロジェクト: renyh1013/dp2
        // 导入
        private void button_import_Click(object sender, System.EventArgs e)
        {
            // 未按下Control键, 一般导入功能 -- 导入当前目录
            if (!(Control.ModifierKeys == Keys.Control))
            {
                button_PasteFromFile_Click(null, null);
                return;
            }

            int nRet;
            string strError = "";

            // 询问project*.xml文件全路径
            OpenFileDialog projectDefFileDlg = new OpenFileDialog();

            projectDefFileDlg.FileName = "outer_projects.xml";
            projectDefFileDlg.InitialDirectory = Environment.CurrentDirectory;
            projectDefFileDlg.Filter = "projects files (outer*.xml)|outer*.xml|All files (*.*)|*.*";
            //dlg.FilterIndex = 2 ;
            projectDefFileDlg.RestoreDirectory = true;

            if (projectDefFileDlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ScriptManager newScriptManager = new ScriptManager();
            newScriptManager.applicationInfo = null;	//applicationInfo;
            newScriptManager.CfgFilePath = projectDefFileDlg.FileName;
            newScriptManager.Load();

            // 选取要Import的Project名

            GetProjectNameDlg nameDlg = new GetProjectNameDlg();
            GuiUtil.AutoSetDefaultFont(nameDlg);

            nameDlg.Text = "请选定要导入的外部方案名";
            nameDlg.scriptManager = newScriptManager;
            /*
            nameDlg.textBox_projectName.Text = applicationInfo.GetString(
                "projectmanagerdlg_import",
                "lastUsedProject",
                "");
            */

            nameDlg.StartPosition = FormStartPosition.CenterScreen;
            nameDlg.ShowDialog(this);

            if (nameDlg.DialogResult != DialogResult.OK)
                return;

            string strSourceProjectName = nameDlg.ProjectName;

            string strSourceLocate = "";

            // 获得源方案参数
            // strProjectNamePath	方案名,或者路径
            // return:
            //		-1	error
            //		0	not found project
            //		1	found
            nRet = newScriptManager.GetProjectData(
                strSourceProjectName,
                out strSourceLocate);
            if (nRet == -1)
            {
                MessageBox.Show(this, "source GetProjectData() " + strSourceProjectName + " error...");
                return;
            }
            if (nRet == 0)
            {
                MessageBox.Show(this, "source project " + strSourceProjectName + " not found error...");
                return;
            }


            /*
            applicationInfo.SetString(
                "projectmanagerdlg_import",
                "lastUsedProject",
                nameDlg.textBox_projectName.Text);
            */

            REDOEXPORT:

            string strTargetLocate = "";
            // 获得目标方案参数
            // strProjectNamePath	方案名,或者路径
            // return:
            //		-1	error
            //		0	not found project
            //		1	found
            nRet = this.scriptManager.GetProjectData(
                strSourceProjectName,
                out strTargetLocate);
            if (nRet == -1)
            {
                MessageBox.Show(this, "target GetProjectData() " + strSourceProjectName + " error...");
                return;
            }

            // 发现重名,询问是否覆盖
            if (nRet == 1)
            {
                string strText = "当前已经存在与源 '"
                    + strSourceProjectName + "' 同名的目标方案(磁盘目录位于'"
                    + strTargetLocate + "')。\r\n\r\n"
                    + "请问是否覆盖已有的目标方案?\r\n(Yes=覆盖; No=改名后导入;Cancel=放弃操作)";

                DialogResult msgResult = MessageBox.Show(this,
                    strText,
                    "script",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);
                if (msgResult == DialogResult.Cancel)
                    return;
                if (msgResult == DialogResult.Yes)
                {	// 覆盖
                    // 拷贝目录
                    nRet = PathUtil.CopyDirectory(strSourceLocate,
                        strTargetLocate,
                        true,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    goto END1;
                }
                else
                {	// 改名
                    // 询问新名字
                    nameDlg = new GetProjectNameDlg();
                    GuiUtil.AutoSetDefaultFont(nameDlg);

                    nameDlg.Text = "请制定目标(系统内)新方案名";
                    nameDlg.scriptManager = this.scriptManager;
                    nameDlg.ProjectName = strSourceProjectName;

                    nameDlg.StartPosition = FormStartPosition.CenterScreen;
                    nameDlg.ShowDialog(this);

                    if (nameDlg.DialogResult != DialogResult.OK)
                        goto END2;

                    strSourceProjectName = nameDlg.ProjectName;
                    goto REDOEXPORT;

                }



            }
            else // 不重名,直接复制
            {
                // 创建一个新的project,获得strTargetLocate
                int nPrefixNumber = -1;	// 0
                strTargetLocate = this.scriptManager.NewProjectLocate(
                    PathUtil.PureName(strSourceLocate),	// 尽量取和源相同的末级目录名
                    ref nPrefixNumber);

                // 拷贝目录
                nRet = PathUtil.CopyDirectory(strSourceLocate,
                    strTargetLocate,
                    true,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                // 实际插入project参数
                XmlNode projNode = this.scriptManager.NewProjectNode(
                    strSourceProjectName,	// 沿用原来的名字
                    strTargetLocate,
                    false);	// false表示不需要创建目录和缺省文件

                // 兑现显示?
                scriptManager.RefreshTree(treeView1);
            }

        END1:

            this.scriptManager.Save();



            TreeViewUtil.SelectTreeNode(treeView1,
                strSourceProjectName,
                '/');

            MessageBox.Show(this, "外部方案 '" + strSourceProjectName + "' 已经成功导入本系统。");
            return;
        END2:
            return;
        ERROR1:
            MessageBox.Show(this, strError);
            return;
        }