Exemplo n.º 1
0
        private void btnTempTest_Click(object sender, System.EventArgs e)
        {
            //frmMain.msg.clear();
            frmMain.labStatus.Text = "";
            if (lstTemp.CheckedItems.Count < 1)
            {
                frmMain.labStatus.Text = "no template be selected in list.";
                return;
            }

            XmlDocument xmldoc2 = getXMLTemplate();

            if (xmldoc2 == null)
            {
                frmMain.labStatus.Text = "XML file is not valid.";
                return;
            }
            XmlNodeList nodeList = xmldoc2.SelectNodes("config/template");

            //create new IPara
            IPara ipara = frmMain.CreateIPara();

            //set filed value
            ipara = frmMain.CreateSampleFiled(ipara);

            //テンプレートごとに出力処理
            txtTempTest.Text = "";
            for (int loopj = 0; loopj < nodeList.Count; loopj++)
            {
                ipara.TemplateNode = nodeList[loopj];
                string stitle = "";
                if (nodeList[loopj].Attributes["title"] != null)
                {
                    stitle = nodeList[loopj].Attributes["title"].InnerText;
                    if (nodeList[loopj].Attributes["language"] != null)
                    {
                        stitle = "[" + nodeList[loopj].Attributes["language"].InnerText + "] " + nodeList[loopj].Attributes["title"].InnerText;
                    }
                }
                txtTempTest.AppendText("##################################################\r\n");
                txtTempTest.AppendText("# " + stitle + "\r\n");
                txtTempTest.AppendText("##################################################\r\n");
                string sFileTxt = ClassExt.CreateClsFromTempString(ipara);
                if (sFileTxt != null)
                {
                    txtTempTest.AppendText(sFileTxt);
                }
                else
                {
                    txtTempTest.AppendText("  this file is Canceled by ipara\r\n");
                }
            }
            frmMain.labStatus.Text = "only the selected template is created.";
        }
Exemplo n.º 2
0
        private void JSTestRun_main()
        {
            //Start do something
            if (MessageBox.Show("Start RunJscript?", "Msg...", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            //create new IPara
            IPara ipara = frmMain.CreateIPara();

            //set filed value
            ipara = frmMain.CreateSampleFiled(ipara);
            ipara = ClassExt.TreateFieldANDJScript(ipara);

            System.Text.StringBuilder sbJSTxt = (System.Text.StringBuilder)ipara.SystemVarious["StringBuilderJScriptTxt"];
            string sJSTxtHead = (string)ipara.SystemVarious["JScriptTxtHEAD"];
            string sJSTxtEnd  = (string)ipara.SystemVarious["JScriptTxtEND"];

            jspage = (PageJSDebugPage)tabControl1.SelectedTab.Controls[0];
            frmMain.msg.clear();
            frmMain.msg.Focus();
            frmMain.labStatus.Text = "RunJscript.";
            MainTime = System.DateTime.Now;
            frmMain.msg.println("Start:" + MainTime);
            string ErrorString = "";

            for (int i = 0; i < jspage.numRunCnt.Value; i++)
            {
                if ((int)(i / 100) == i / 100)
                {
                    frmMain.labStatus.Text = "RunCount:" + i;
                }
                string sJS;
                //not check for include define JS()
                if (jspage.chkAddJS.Checked)
                {
                    sJS = sbJSTxt.ToString() + "\r\n" + sJSTxtHead + "\r\n" + jspage.txtJS.Text + "\r\n" + sJSTxtEnd;
                }
                else
                {
                    sJS = jspage.txtJS.Text;
                }

                bool   isReset = jspage.chkReset.Checked;
                object obj     = cc.Eval.JSEvaluateToObject(sJS, isReset, out ErrorString);
                Application.DoEvents();
                if (btnCancel.Text.Equals("Cancel..."))
                {
                    frmMain.msg.println("User Cancel.");
                    return;
                }
                if (i == 0)
                {
                    if (ErrorString != null)
                    {
                        frmMain.msg.println(ErrorString, Color.Red);
                        break;
                    }
                    if (obj == null)
                    {
                        frmMain.msg.println("Run JScript error, no value return.");
                        break;
                    }
                    frmMain.msg.println("Return Type:" + obj.GetType());
                    if (!obj.GetType().FullName.Equals("Microsoft.JScript.JSObject"))
                    {
                        frmMain.msg.println("Return Value:" + obj);
                    }
                    else
                    {
                        GetScriptObjectValue((Microsoft.JScript.ScriptObject)obj, "");
                    }
                }
            }
            frmMain.labStatus.Text = "RunCount:" + jspage.numRunCnt.Value;
            frmMain.msg.println("End:" + System.DateTime.Now + "(elapsed:" + (int)((System.DateTime.Now - MainTime).TotalMilliseconds / 1000) + " Seconds)");
        }