示例#1
0
        //internal short OpenTemplet(string szFileName)
        //{
        //    if (string.IsNullOrEmpty(szFileName))
        //        return SystemData.ReturnValue.PARAM_ERROR;
        //    ScriptEditForm designEditForm = new ScriptEditForm(this.MainForm);
        //    designEditForm.FlagCode = Guid.NewGuid().ToString();
        //    this.MainForm.OpenScriptEditForm(designEditForm);

        //    return designEditForm.Open(szFileName) ?
        //        SystemData.ReturnValue.OK : SystemData.ReturnValue.FAILED;
        //}

        internal short OpenTemplet()
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Filter      = "脚本模板(*.vbs)|*.vbs|所有文件(*.*)|*.*";
            openDialog.FilterIndex = 1;
            if (openDialog.ShowDialog() != DialogResult.OK)
            {
                return(SystemData.ReturnValue.CANCEL);
            }

            ScriptEditForm designEditForm = new ScriptEditForm(this.MainForm);

            designEditForm.FlagCode = Guid.NewGuid().ToString();
            this.MainForm.OpenScriptEditForm(designEditForm);

            return(designEditForm.OpenScriptFile(openDialog.FileName) ?
                   SystemData.ReturnValue.OK : SystemData.ReturnValue.FAILED);
        }
示例#2
0
        internal short OpenScriptConfig(ScriptConfig scriptConfig)
        {
            if (scriptConfig == null)
            {
                return(SystemData.ReturnValue.FAILED);
            }

            ScriptEditForm scriptEditForm = this.GetScriptForm(scriptConfig);

            if (scriptEditForm != null)
            {
                scriptEditForm.Activate();
                return(SystemData.ReturnValue.OK);
            }
            scriptEditForm              = new ScriptEditForm(this.MainForm);
            scriptEditForm.FlagCode     = Guid.NewGuid().ToString();
            scriptEditForm.ScriptConfig = scriptConfig;

            this.MainForm.OpenScriptEditForm(scriptEditForm);

            string szScriptID = scriptConfig.SCRIPT_ID;
            string szHndfFile = string.Format("{0}\\Cache\\{1}.vbs"
                                              , GlobalMethods.Misc.GetWorkingPath(), szScriptID);

            string byteTempletData = null;

            if (szScriptID != string.Empty)
            {
                short shRet = ScriptConfigAccess.Instance.GetScriptSource(szScriptID, ref byteTempletData);
                if (shRet != SystemData.ReturnValue.OK)
                {
                    return(shRet);
                }
            }

            GlobalMethods.IO.WriteFileText(szHndfFile, byteTempletData);
            return(scriptEditForm.OpenScriptFile(szHndfFile) ?
                   SystemData.ReturnValue.OK : SystemData.ReturnValue.FAILED);
        }