コード例 #1
0
        private bool CreateInterfaceFolder()
        {
            if (_targetInterface != null)
            {
                return(false);
            }

            string name = this.textBoxInterfaceName.Text.Trim();
            string desc = this.textBoxInterfaceDescription.Text.Trim();

            if (!CheckInterfaceName(name))
            {
                return(false);
            }

            panelProcess.Visible    = true;
            this.buttonNext.Enabled = this.buttonPrev.Enabled = this.buttonCancel.Enabled = false;

            bool result = false;

            _targetInterface = _interfaceMgt.AddInterfaceToFolder(_sourceDevice, name, desc);

            if (_targetInterface != null)
            {
                Program.Log.Write("{Interface} Create interface folder succeed : " + _targetInterface.FolderPath);

                if (ScriptControl.UpdateInterface(_targetInterface, Program.ConfigMgt.Config))
                {
                    Program.Log.Write("{Interface} Update interface scripts succeed : " + _targetInterface.FolderPath);

                    result = true;
                }
                else
                {
                    Program.Log.Write(LogType.Warning, "{Interface} Update interface scripts failed : " + GCError.LastErrorInfor);
                    Program.Log.Write(GCError.LastError);

                    MessageBox.Show(this, "Update interface scripts failed.\r\n\r\n" + GCError.LastErrorInfor,
                                    "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                Program.Log.Write(LogType.Warning, "{Interface} Create interface folder failed : " + GCError.LastErrorInfor);
                Program.Log.Write(GCError.LastError);

                MessageBox.Show(this, "Create interface folder failed.\r\n\r\n" + GCError.LastErrorInfor,
                                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            this.buttonNext.Enabled = this.buttonPrev.Enabled = this.buttonCancel.Enabled = true;
            panelProcess.Visible    = false;

            return(result);
        }