/// <summary>
        /// Returns a clone of the object.
        /// </summary>
        /// <param name="sessionScripting"> The session scripting.</param>
        /// <returns> A clone of the object.</returns>
        public static object Clone(ScriptingApplication sessionScripting)
        {
            if ( serializer == null )
            {
                // Initiate serializer.
                ScriptingApplicationSerializer init = new ScriptingApplicationSerializer();
            }

            XmlNode node = serializer.WriteXmlNode(typeof(ScriptingApplication), sessionScripting, "ScriptingApplication");
            XmlNode clone = node.Clone();
            return serializer.ReadXmlNode(typeof(ScriptingApplication), clone, "ScriptingApplication");
        }
 /// <summary>
 /// Creates a new ScriptingApplicationArgumentForm.
 /// </summary>
 /// <param name="file"> The scripting application package to run.</param>
 //        public ScriptingApplicationArgumentForm(string file) : this()
 //        {
 //            FileInfo fileInfo = new FileInfo(file);
 //            this.Text = "Scripting Application Form - " + fileInfo.Name.Replace(fileInfo.Extension, "");
 //            _packageFile = file;
 //            RunScriptingApplication(file);
 //        }
 /// <summary>
 /// Creates a new ScriptingApplicationArgumentForm.
 /// </summary>
 /// <param name="application"> The ScriptingApplication type.</param>
 /// <param name="arguments"> The ScriptingApplicationArgs type.</param>
 public ScriptingApplicationArgumentForm(ScriptingApplication application, ScriptingApplicationArgs arguments)
     : this()
 {
     if ( arguments == null )
     {
         _args = new ScriptingApplicationArgs();
     }
     else
     {
         _args = arguments;
     }
     _scrapp = application;
 }
コード例 #3
0
 /// <summary>
 /// Closes the command.
 /// </summary>
 public void Close()
 {
     _sessionScripting = null;
     parser = null;
 }
コード例 #4
0
        /// <summary>
        /// Loads an exising Session type.
        /// </summary>
        /// <param name="session"> Loads a session type in the ScriptingDataDesigner.</param>
        public void LoadSession(Session session)
        {
            ScriptingApplication sd = new ScriptingApplication();

            foreach (SessionRequest req in session.SessionRequests )
            {
                if ( req.RequestType == HttpRequestType.GET )
                {
                    GetWebRequest getRequest = new GetWebRequest((GetSessionRequest)req);
                    sd.AddWebRequest(getRequest);
                }
                else if ( req.RequestType == HttpRequestType.POST )
                {
                    PostWebRequest postRequest = new PostWebRequest((PostSessionRequest)req);
                    sd.AddWebRequest(postRequest);
                }
            }

            _scriptingData = sd;
        }
コード例 #5
0
 /// <summary>
 /// Creates a new Scripting Designer.
 /// </summary>
 /// <param name="fileName"> The file name to open.</param>
 public ScriptingDataDesigner(string fileName)
     : this()
 {
     currentScriptingApplicationName = fileName;
     _scriptingData = new ScriptingApplication();
     LoadFile(fileName);
 }
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            this.Clear();
            lstActions.Items.Clear();

            CookiesTransform tvalue = (CookiesTransform)base.WebTransform;

            // Load any tranform actions, if available
            if ( tvalue.CookieTransformActions.Length > 0 )
            {
                int i = 0;
                foreach ( TransformAction ta in  tvalue.CookieTransformActions )
                {
                    ListViewItem listItem = new ListViewItem();
                    listItem.Text = ta.Name;
                    listItem.SubItems.Add(ta.Description);

                    if ( ta is AddTransformAction )
                    {
                        Cookie ck = tvalue.GetCookie(ta.Name);
                        listItem.Tag = new CookieListItemArgs(ck, ta);
                    }
                    else
                    {
                        listItem.Tag = new CookieListItemArgs(null, ta);
                    }

                    lstActions.Items.Add(listItem);
                    i++;
                }
            }

            if ( _headerList.Count <= 0 )
            {
                // Load the header combo list.
                _headerList.AddRange(HeaderTransform.GetRestrictedHeaders);

                foreach ( WebHeader header in base.SessionScripting.WebRequests[base.SelectedWebRequestIndex].RequestHttpSettings.AdditionalHeaders )
                {
                    _headerList.Add(header.Name);
                }
            }

            WebRequest req = base.SessionScripting.WebRequests[base.SelectedWebRequestIndex];
            LoadHeaderList(_headerList);
            LoadFormValues(req);
            LoadCookieNames(req);
        }
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            this.Clear();
            lstActions.Items.Clear();

            FillFormTransform fillFormTransform = (FillFormTransform)base.WebTransform;

            // Load any tranform actions, if available
            if ( fillFormTransform.FormFields.Length > 0 )
            {
                foreach ( FormField formField in fillFormTransform.FormFields )
                {
                    ListViewItem listItem = new ListViewItem();
                    listItem.Text = formField.FieldName;
                    listItem.SubItems.Add(formField.Index.ToString());
                    listItem.SubItems.Add(formField.Description);
                    listItem.Tag = formField;

                    lstActions.Items.Add(listItem);
                }
            }

            if ( _headerList.Count <= 0 )
            {
                // Load the header combo list.
                _headerList.AddRange(HeaderTransform.GetRestrictedHeaders);

                foreach ( WebHeader header in base.SessionScripting.WebRequests[base.SelectedWebRequestIndex].RequestHttpSettings.AdditionalHeaders )
                {
                    _headerList.Add(header.Name);
                }
            }

            WebRequest req = base.SessionScripting.WebRequests[base.SelectedWebRequestIndex];
            LoadHeaderList(_headerList);
            LoadFormValues(req);
            LoadCookieNames(req);
        }
コード例 #8
0
        //        private void toolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        //        {
        //            if ( e.Button == tbSaveApplication )
        //            {
        //                if ( this.Parent.Parent is ScriptingDataDesigner )
        //                {
        //                    ScriptingDataDesigner designer = (ScriptingDataDesigner)this.Parent.Parent;
        //                    designer.SaveApplication();
        //                }
        //            }
        //
        //            if ( e.Button == tbArguments )
        //            {
        //                if ( this.Parent.Parent is ScriptingDataDesigner )
        //                {
        //                    ScriptingDataDesigner designer = (ScriptingDataDesigner)this.Parent.Parent;
        //                    designer.ShowScriptingArgumentsDesigner();
        //                }
        //            }
        //        }
        /// <summary>
        /// Loads the request.
        /// </summary>
        /// <param name="index"> The current request index.</param>
        /// <param name="scripting"> The scripting application.</param>
        /// <param name="request"> The current web request.</param>
        public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request)
        {
            base.LoadRequest (index, scripting, request);

            this.EditorText = "";
            string postData = string.Empty;
            if ( request.RequestType == HttpRequestType.POST )
            {
                postData = ((PostWebRequest)request).PostData;
                request.UpdateXmlEnvelope(postData);
            }
            if ( request.RequestType == HttpRequestType.PUT )
            {
                postData = ((PutWebRequest)request).PostData;
                request.UpdateXmlEnvelope(postData);
            }

            if ( request.XmlEnvelope != null )
            {
                this.EditorText = this.IndentFormatXml(request.XmlEnvelope);
            }
        }
コード例 #9
0
        /// <summary>
        /// Loads the request.
        /// </summary>
        /// <param name="index"> The selected web request index.</param>
        /// <param name="scripting"> The scripting application.</param>
        /// <param name="request"> The current web request.</param>
        public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request)
        {
            if ( request is PostWebRequest )
            {
                chkUsePostData.Visible = true;
                chkUsePostData.Checked = ((PostWebRequest)request).UsePostData;
            }
            else
            {
                chkUsePostData.Visible = false;
            }

            base.LoadRequest (index, scripting, request);
            txtUrl.Text = request.Url;
            txtRequestID.Text = request.ID;
            this.LoadHttpProperties(request.RequestHttpSettings);
        }
コード例 #10
0
 /// <summary>
 /// Loads a transform editor values.
 /// </summary>
 /// <param name="requestIndex"> The selected web request index.</param>
 /// <param name="scriptingData"> The session scripting data.</param>
 /// <param name="transform"> Loads a WebTransform.</param>
 public virtual void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
 {
     _requestIndex  = requestIndex;
     _transform = transform;
     _scripting = scriptingData;
 }
コード例 #11
0
        /// <summary>
        /// Loads the request.
        /// </summary>
        /// <param name="request"></param>
        public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request)
        {
            base.LoadRequest (index, scripting, request);

            this.SuspendLayout();
            tvTransforms.ContextMenu = this.mnuOutputMenu;

            pnTransformEditor.Controls.Clear();
            tvTransforms.Nodes.Clear();

            tvTransforms.Nodes.Add(new TreeNode("Transforms"));

            if ( request.OutputTransforms.Length > 0 )
            {
                // Load transforms
                WebTransformPageUIHelper.LoadTransforms(tvTransforms.Nodes[0],request.OutputTransforms);
            }

            tvTransforms.ExpandAll();
            tvTransforms.SelectedNode = tvTransforms.Nodes[0];
            this.ResumeLayout(false);
        }
コード例 #12
0
 /// <summary>
 /// Loads a WebRequest.
 /// </summary>
 /// <param name="request"> Loads a WebRequest.</param>
 public virtual void LoadRequest(int requestIndex, ScriptingApplication sessionScripting, WebRequest request)
 {
     _requestIndex = requestIndex;
     _scripting = sessionScripting;
     _request = request;
 }
コード例 #13
0
 /// <summary>
 /// Initiate the test.
 /// </summary>
 /// <param name="application"> The scripting application.</param>
 /// <param name="index"> The index.</param>
 public void TestRequestUntilIndex(ScriptingApplication application, int index)
 {
     _appClone = application.Clone();
     _startingIndex = index;
     scriptingCommand.ExecuteSessionUntilEnd(application.Clone(), index);
 }
コード例 #14
0
        /// <summary>
        /// Executes a session that executes until the end index and uses a scripting file. 
        /// </summary>
        /// <param name="application"> The scripting application.</param>
        /// <param name="endIndex"> The index where the last request executes.</param>
        /// <param name="scriptingFileLocation"> The scripting file location.</param>
        //        public void ExecuteScriptedSession(ScriptingApplication application, int endIndex, string scriptingFileLocation)
        //        {
        //            _sessionScripting = application;
        //            IVsaItems    items = _engine.Items;
        //
        //            // Load the script code
        //            // NOTE: For VB, the name of the item, "Script", must match the name of the Module,
        //            //       or adding global items won't work <sigh>
        //            IVsaCodeItem codeItem = (IVsaCodeItem)items.CreateItem("Script",
        //                VsaItemType.Code,
        //                VsaItemFlag.None);
        //
        //            StreamReader reader = new StreamReader(scriptingFileLocation);
        //            codeItem.SourceText = reader.ReadToEnd();
        //            reader.Close();
        //
        //            // Add the global "This" item
        //            IVsaGlobalItem  scommand = (IVsaGlobalItem)items.CreateItem("This",
        //                VsaItemType.AppGlobal,
        //                VsaItemFlag.None);
        //            scommand.TypeString = "Ecyware.GreenBlue.Engine.Scripting.ScriptingCommand";
        //
        //            // Add the global "MyScriptingApplication" item
        //            IVsaGlobalItem  sapplication = (IVsaGlobalItem)items.CreateItem("MyScriptingApplication",
        //                VsaItemType.AppGlobal,
        //                VsaItemFlag.None);
        //            sapplication.TypeString = "Ecyware.GreenBlue.Engine.Scripting.ScriptingApplication";
        //            
        ////			_engine.SetOption("print", true);
        //
        ////			// Set the JS output stream once for this appdomain
        ////			if( _jsStream == null )
        ////			{
        ////				StreamWriter    writer = new StreamWriter(@"c:\jsout.txt");
        ////				writer.AutoFlush = true;
        ////				_jsStream = writer;
        ////				Microsoft.JScript.ScriptStream.Out = _jsStream;
        ////			}
        //
        //            try
        //            {
        //                // Run the script
        //                if ( _engine.Compile() )
        //                {
        //                    _engine.Run();
        //                    ExecuteSessionUntilEnd(application, endIndex);
        //                }
        //            }
        //            catch ( Exception ex )
        //            {
        //                System.Windows.Forms.MessageBox.Show(ex.ToString());
        //            }
        //        }
        //
        //
        /// <summary>
        /// Executes a session that executes until the end index.
        /// </summary>
        /// <param name="application"> The scripting application.</param>
        /// <param name="endIndex"> The index where the last request executes.</param>
        public void ExecuteSessionUntilEnd(ScriptingApplication application, int endIndex)
        {
            ScriptingApplication temp = application.Clone();
            temp.ClearWebRequests();

            // if endIndex is 0, we want to include it.
            for ( int i=0;i<=endIndex;i++ )
            {
                // add to new scripting data.
                temp.AddWebRequest(application.WebRequests[i]);
            }

            // Replace Scripting Data with current.
            _sessionScripting = temp;

            // Start from zero.
            IsRunning = true;
            ExecuteRequest(temp.WebRequests[0],0);
        }
コード例 #15
0
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            this.Clear();
            RequestTransform requestTransform = (RequestTransform)base.WebTransform;

            TransformValue = requestTransform.UpdateTransformAction.Value;
            txtTransformDescription.Text = requestTransform.UpdateTransformAction.Description;

            #region Request Fields
            if ( _requestFields.Count <= 0 )
            {
                _requestFields.Add(new NameValueObject("Change Complete Url", "Url"));
                _requestFields.Add(new NameValueObject("Change Url Hostname", "ChangeUrlHostname"));
                _requestFields.Add(new NameValueObject("Change Url Path", "ChangeUrlPath"));
                _requestFields.Add(new NameValueObject("Set Request ID", "ID"));
                _requestFields.Add(new NameValueObject("Set Basic Authentication Username", "Username"));
                _requestFields.Add(new NameValueObject("Set Basic Authentication Password", "Password"));

                this.cmbRequestField.DataSource = _requestFields;
                this.cmbRequestField.DisplayMember = "Name";
                this.cmbRequestField.ValueMember = "Value";
            }
            #endregion

            if ( requestTransform.RequestFieldName != null )
            {
                cmbRequestField.SelectedValue = requestTransform.RequestFieldName;
            }

            this.cmbTransformValue.SelectedIndex = this.GetTransformValueComboIndex(TransformValue);

            #region Headers Dialog
            if ( _headerList.Count <= 0 )
            {
                // Load the header combo list.
                _headerList.AddRange(HeaderTransform.GetRestrictedHeaders);

                foreach ( WebHeader header in base.SessionScripting.WebRequests[base.SelectedWebRequestIndex].RequestHttpSettings.AdditionalHeaders )
                {
                    _headerList.Add(header.Name);
                }
            }

            WebRequest req = base.SessionScripting.WebRequests[base.SelectedWebRequestIndex];
            LoadHeaderList(_headerList);
            LoadFormValues(req);
            LoadCookieNames(req);
            #endregion
        }
コード例 #16
0
        /// <summary>
        /// Loads the request.
        /// </summary>
        /// <param name="index"> The current request index.</param>
        /// <param name="scripting"> The scripting application.</param>
        /// <param name="request"> The current web request.</param>
        public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request)
        {
            base.LoadRequest (index, scripting, request);

            try
            {
                //_httpRequestType = request.RequestType;
                _currentRequestUri = new Uri(request.Url);

                if ( request.Form.Elements.Length > 0 )
                {
                    HtmlFormTagCollection forms = new HtmlFormTagCollection(1);
                    _form = request.Form.WriteHtmlFormTag();
                    forms.Add(request.Form.Name, _form);

                    // Load tree
                    LoadFormTree(forms);
                }
                else
                {
                    DisplayNoDataMessage();
                }
            }
            catch ( Exception ex )
            {
                MessageBox.Show(ex.ToString(), AppLocation.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            this.Clear();
            lvValues.Items.Clear();

            GmailSmtpTransform gmtransform = (GmailSmtpTransform)transform;

            if ( gmtransform.Transport  != null )
            {
                GmailTransport transport = (GmailTransport)gmtransform.Transport;
                this.txtBcc.Text = transport.Bcc;
                this.txtCc.Text = transport.Cc;
                if ( transport.Format ==  System.Web.Mail.MailFormat.Html )
                {
                    this.rbHTML.Checked = true;
                }
                if ( transport.Format ==  System.Web.Mail.MailFormat.Text )
                {
                    this.rbText.Checked = true;
                }
                this.txtFrom.Text = transport.From;
                this.txtPassword.Text = transport.Password;
                this.txtUsername.Text = transport.Username;
                this.txtTo.Text = transport.To;
                this.txtSubject.Text = transport.Subject;
            }

            // Load any tranform value, if available
            if ( gmtransform.QueryCommandActions.Length > 0 )
            {
                foreach ( QueryCommandAction action in gmtransform.QueryCommandActions )
                {
                    ListViewItem listItem = new ListViewItem();
                    listItem.Text = action.Description;
                    listItem.Tag = action;

                    lvValues.Items.Add(listItem);
                }
            }

            if ( _headerList.Count <= 0 )
            {
                // Load the header combo list.
                _headerList.AddRange(HeaderTransform.GetRestrictedHeaders);

                foreach ( WebHeader header in base.SessionScripting.WebRequests[base.SelectedWebRequestIndex].RequestHttpSettings.AdditionalHeaders )
                {
                    _headerList.Add(header.Name);
                }
            }

            //this.cmbTransformValue.SelectedIndex = this.GetTransformValueComboIndex(queryTransform);

            WebRequest req = base.SessionScripting.WebRequests[base.SelectedWebRequestIndex];
            LoadHeaderList(_headerList);
            LoadFormValues(req);
            LoadCookieNames(req);
        }
コード例 #18
0
        /// <summary>
        /// Saves the application to store.
        /// </summary>
        /// <param name="fileName"> The filename.</param>
        public void SaveApplicationToStore(string fileName)
        {
            FileInfo fi = new FileInfo(fileName);
            string filePath = AppLocation.DocumentFolder + "\\" + fi.Name;

            try
            {
                File.Copy(fileName, filePath);
                string xml = AppLocation.GetMIMEType(fileName);

                if ( xml.CompareTo("text/xml") == 0 )
                {
                    string packageFileName = AppLocation.DocumentFolder + "\\" + fi.Name.Replace(fi.Extension,"") + ".gbscr";
                    ScriptingApplication app = new ScriptingApplication();
                    app.Load(filePath);
                    ScriptingApplicationPackage.CreatePackage(app, null, packageFileName, false);
                    File.Delete(filePath);
                }
            }
            catch ( IOException ex )
            {
                System.Windows.Forms.MessageBox.Show("There is already a file with name " + fi.Name + " in the local store.",AppLocation.ApplicationName, MessageBoxButtons.OK,MessageBoxIcon.Warning);
            }
            catch ( Exception ex )
            {
                System.Windows.Forms.MessageBox.Show(ex.Message,AppLocation.ApplicationName, MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            ResponseResultTransform rtransform = (ResponseResultTransform)base.WebTransform;

            this.cmbTransports.SelectedIndex = GetTransportValueComboIndex(rtransform.Transport);

            if ( rtransform != null )
            {
                this.chkUseSession.Checked = rtransform.UseSession;
                this.txtSessionName.Text = rtransform.SessionName;
                _transport = rtransform.Transport;
            }
        }
        /// <summary>
        /// Opens a package from a web instance.
        /// </summary>
        /// <param name="fileName"> The package file name.</param>
        public void OpenPackageWeb(string fileName)
        {
            C1ZipFile zipFile = new C1ZipFile();
            //  package = new ScriptingApplicationPackage();

            try
            {
                zipFile.Open(fileName);

                // Application
                C1ZipEntry entry = zipFile.Entries[0];
                // Get entry name and convert to guid
                // if invalid GUID, throw exception
                string name = entry.FileName;
                string applicationXml = string.Empty;
                string applicationArgumentsXml = string.Empty;

                // Get Scripting Application Xml.
                Guid g = new Guid(name);
                StreamReader reader = new StreamReader(entry.OpenReader(),System.Text.Encoding.UTF8);
                applicationXml= reader.ReadToEnd();
                reader.Close();

                if ( zipFile.Entries.Count > 1 )
                {
                    // Arguments
                    entry = zipFile.Entries[1];
                    reader = new StreamReader(entry.OpenReader(),System.Text.Encoding.UTF8);
                    applicationArgumentsXml = reader.ReadToEnd();

                    if ( applicationArgumentsXml.ToLower() != "none" )
                    {
                        _arguments = ScriptingApplicationArgs.FromXml(applicationArgumentsXml);
                    }
                    else
                    {
                        _arguments = null;
                    }

                    reader.Close();
                }

                // Get Custom Transforms
                int start = 2;
                for ( int i=2;i<zipFile.Entries.Count;i++ )
                {
                    entry = zipFile.Entries[i];

                    if ( entry.FileName == "CustomTransformsSeparator" )
                    {
                        start = i+1;
                        break;
                    }

                    // Add File References to Application Startup
                    // string location = System.Windows.Forms.Application.StartupPath + Path.DirectorySeparatorChar + entry.FileName;
            //					if ( !File.Exists(location) )
            //					{
            //						zipFile.Entries.Extract(i, location);
            //					}
                    // Add WebTransform Entry in Configuration.
                    // if exists don't add.
                    // RegisterWebTransform(location);
                    // ScriptingApplicationSerializer.UpdateSerializer();
                }

                // Generate scripting application.
                XmlDocument document = new XmlDocument();
                document.LoadXml(applicationXml);
                _application = ScriptingApplication.Decrypt(document);
                //	_application = ScriptingApplication.FromXml(applicationXml);
            //
            //				for ( int i=start;i<zipFile.Entries.Count;i++ )
            //				{
            //					entry = zipFile.Entries[i];
            //
            //					// Add File References to Internet Cache
            //					string location = Utils.AppLocation.InternetTemp + Path.DirectorySeparatorChar + _application.Header.ApplicationID + Path.DirectorySeparatorChar + entry.FileName;
            //					if ( File.Exists(location) )
            //					{
            //						File.Delete(location);
            //					}
            //					zipFile.Entries.Extract(i, location);
            //				}
            }
            catch
            {
                throw;
            }
            finally
            {
                zipFile.Close();
            }
        }
        /// <summary>
        /// Runs the scripting application as a Windows Form application.
        /// </summary>
        /// <param name="file"> The ScriptingApplication or ScriptingApplicationPackage to run.</param>
        public void RunScriptingApplication(string file)
        {
            FileInfo fileInfo = new FileInfo(file);
            _packageFile = file;
            this.Text = "Scripting Application Form - " + fileInfo.Name.Replace(fileInfo.Extension, "");
            string contentType = AppLocation.GetMIMEType(file);

            if ( contentType.IndexOf("xml") == -1 )
            {
                ScriptingApplicationPackage package = new ScriptingApplicationPackage(file);
                _args = package.ScriptingApplicationArguments;
                _scrapp = package.ScriptingApplication;
            }
        }
        /// <summary>
        /// Creates a new ScriptingApplicationPackage.
        /// </summary>
        /// <param name="application"> The scripting application.</param>
        /// <param name="arguments"> The application arguments.</param>
        /// <param name="filePath"> The output file path.</param>
        /// <param name="doEncrypt"> Sets the encrypttion setting for a scripting application.</param>
        public static void CreatePackage(ScriptingApplication application, ScriptingApplicationArgs arguments, string filePath, bool doEncrypt)
        {
            try
            {
                if ( application.Header.ApplicationID == null )
                {
                    application.Header.ApplicationID = System.Guid.NewGuid().ToString();
                }

                // Get all FileReference elements.
                FileReference[] fileReferences = application.GetFileReferences();
                string applicationPath = System.Windows.Forms.Application.UserAppDataPath;

                string temp = applicationPath + "/temp/";

                if ( !Directory.Exists(temp) )
                {
                    Directory.CreateDirectory(temp);
                }

                C1.C1Zip.C1ZipFile zipFile = new C1.C1Zip.C1ZipFile();
                zipFile.Create(filePath);
                zipFile.Open(filePath);

                string argumentsFileName = application.Header.ApplicationID + "-applicationArguments.xml";

                FileReference argumentsFileReference = new FileReference(argumentsFileName);
                application.Header.ScriptingApplicationArgumentsReference = argumentsFileReference;

                // Add Scripting Application
                string xml = string.Empty;
                if ( doEncrypt )
                {
                    xml = application.Encrypt();
                }
                else
                {
                    xml = application.ToXml();
                }

                MemoryStream mem = new MemoryStream(System.Text.Encoding.UTF8.GetByteCount(xml));
                StreamWriter writer =  new StreamWriter(mem, System.Text.Encoding.UTF8);
                writer.Write(xml);
                writer.Flush();
                mem.Position = 0;
                zipFile.Entries.Add(writer.BaseStream, application.Header.ApplicationID);
                writer.Close();

                string argsXml = "None";
                if ( arguments != null )
                {
                    // Add Scripting Application Arguments
                    argsXml = arguments.ToXml();
                }
                mem = new MemoryStream(System.Text.Encoding.UTF8.GetByteCount(argsXml));
                writer =  new StreamWriter(mem, System.Text.Encoding.UTF8);
                writer.Write(argsXml);
                writer.Flush();
                mem.Position = 0;
                zipFile.Entries.Add(writer.BaseStream, argumentsFileName);
                writer.Close();

                FileReference[] customTransforms = application.GetCustomTransforms();

                // add custom transforms
                foreach ( FileReference reference in customTransforms )
                {
                    if ( File.Exists(reference.FileName) )
                    {
                        FileInfo fileInfo = new FileInfo(reference.FileName);
                        zipFile.Entries.Add(reference.FileName, fileInfo.Name);
                    }
                }

                MemoryStream stream = new MemoryStream();
                stream.Write(new byte[] {0}, 0, 1);
                zipFile.Entries.Add(stream, "CustomTransformsSeparator");
                stream.Close();

                // add file references that are not custom transforms
                foreach ( FileReference reference in fileReferences )
                {
                    if ( File.Exists(reference.FileName) )
                    {
                        FileInfo fileInfo = new FileInfo(reference.FileName);
                        zipFile.Entries.Add(reference.FileName, fileInfo.Name);
                    }
                }

                zipFile.Close();
            }
            catch
            {
                throw;
            }
        }
コード例 #23
0
 /// <summary>
 /// Shows the scripting data as xml.
 /// </summary>
 /// <param name="scriptingData"> The ScriptingData type.</param>
 public void ShowScriptingDataXml(ScriptingApplication scriptingData)
 {
     this.EditorText = scriptingData.ToXml();
 }
コード例 #24
0
 /// <summary>
 /// Loads the request.
 /// </summary>
 /// <param name="request"></param>
 public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request)
 {
     base.LoadRequest (index, scripting, request);
     this.SetCookies(request.Cookies);
 }
コード例 #25
0
        /// <summary>
        /// Saves the changes in the page.
        /// </summary>
        /// <param name="sender"> The sender object.</param>
        /// <param name="e"> The event arguments.</param>
        private void tvSessionTree_BeforeSelect(object sender, System.Windows.Forms.TreeViewCancelEventArgs e)
        {
            if ( tvSessionTree.SelectedNode != null )
            {
                Type pageType = (Type)tvSessionTree.SelectedNode.Tag;
                BaseScriptingDataPage page = GetPageControl(pageType);

                if ( pageType == typeof(ScriptingMainPage) )
                {
                    // Save scripting application
                    ScriptingMainPage control = (ScriptingMainPage)page;
                    ScriptingApplication newApplication = control.LoadScriptingApplication();

                    if ( newApplication != null )
                    {
                        _scriptingData = newApplication;
                    }
                }
                else if ( pageType == typeof(WebRequestPage) )
                {
                    // Update current changes
                    _scriptingData.UpdateWebRequest(tvSessionTree.SelectedNode.Index, page.WebRequest);
                }
                else
                {
                    // Update current changes
                    _scriptingData.UpdateWebRequest(tvSessionTree.SelectedNode.Parent.Index, page.WebRequest);
                }
            }
        }
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            this.Clear();
            lstActions.Items.Clear();

            SecurityTransform securityTransform = (SecurityTransform)base.WebTransform;

            // Load any tranform actions, if available
            if ( securityTransform.SecurityTransformActions.Length > 0 )
            {

                foreach ( SecurityTransformAction action in securityTransform.SecurityTransformActions )
                {
                    ListViewItem listItem = new ListViewItem();
                    listItem.Text = action.RequestStateDataType.ToString();
                    listItem.SubItems.Add(action.TestValue.Value);
                    listItem.Tag = action;

                    lstActions.Items.Add(listItem);
                }
            }

            //			if ( _headerList.Count <= 0 )
            //			{
            //				// Load the header combo list.
            //				_headerList.AddRange(HeaderTransform.GetRestrictedHeaders);
            //
            //				foreach ( WebHeader header in base.SessionScripting.WebRequests[base.SelectedWebRequestIndex].RequestHttpSettings.AdditionalHeaders )
            //				{
            //					_headerList.Add(header.Name);
            //				}
            //			}

            WebRequest req = base.SessionScripting.WebRequests[base.SelectedWebRequestIndex];
            //LoadHeaderList(_headerList);
            //LoadFormValues(req);
            //LoadCookieNames(req);
        }
コード例 #27
0
        /// <summary>
        /// Loads a scripting file.
        /// </summary>
        /// <param name="fileName"> The file name to load.</param>
        public void LoadFile(string fileName)
        {
            string contentType = AppLocation.GetMIMEType(fileName);

            // xml file
            if ( contentType.IndexOf("xml") > -1 )
            {
                _scriptingData.Load(fileName);
            }
            else
            {
                ScriptingApplicationPackage package
                    = new ScriptingApplicationPackage(fileName);
                _scriptingData = package.ScriptingApplication;
                _scriptingArgumentsDef = package.ScriptingApplicationArguments;
            }
        }
コード例 #28
0
        /// <summary>
        /// Loads the request.
        /// </summary>
        /// <param name="index"> The selected web request index.</param>
        /// <param name="scripting"> The scripting data.</param>
        /// <param name="request"> The web request.</param>
        public override void LoadRequest(int index, ScriptingApplication scripting ,Ecyware.GreenBlue.Engine.Scripting.WebRequest request)
        {
            base.LoadRequest (index, scripting, request);

            this.SuspendLayout();

            tvTransforms.ContextMenu = this.mnuInputMenu;

            // Clear
            pnTransformEditor.Controls.Clear();
            tvTransforms.Nodes.Clear();

            //			if ( index == 0 )
            //			{
            //				tvTransforms.Nodes.Add(new TreeNode("There is no previous web result to process."));
            //			}
            //			else
            //			{

                tvTransforms.Nodes.Add(new TreeNode("Transforms"));

                if ( request.InputTransforms.Length > 0 )
                {
                    // Load transforms
                    WebTransformPageUIHelper.LoadTransforms(tvTransforms.Nodes[0],request.InputTransforms);
                }

                this.Focus();
                tvTransforms.ExpandAll();
            //	}

            tvTransforms.SelectedNode = tvTransforms.Nodes[0];
            this.ResumeLayout(false);
        }
コード例 #29
0
        public override void LoadTransformEditorValues(int requestIndex, ScriptingApplication scriptingData, WebTransform transform)
        {
            base.LoadTransformEditorValues (requestIndex, scriptingData, transform);

            this.Clear();
            lstActions.Items.Clear();

            QueryTransform queryTransform = (QueryTransform)base.WebTransform;

            this.cmbTransports.SelectedIndex = GetTransportValueComboIndex(queryTransform.Transport);

            if ( queryTransform.Transport != null )
            {
                _transport = queryTransform.Transport;
            }

            // Load any tranform value, if available
            if ( queryTransform.QueryCommandActions.Length > 0 )
            {
                foreach ( QueryCommandAction action in queryTransform.QueryCommandActions )
                {
                    ListViewItem listItem = new ListViewItem();
                    listItem.Text = action.Description;
                    listItem.Tag = action;

                    lstActions.Items.Add(listItem);
                }
            }

            if ( _headerList.Count <= 0 )
            {
                // Load the header combo list.
                _headerList.AddRange(HeaderTransform.GetRestrictedHeaders);

                foreach ( WebHeader header in base.SessionScripting.WebRequests[base.SelectedWebRequestIndex].RequestHttpSettings.AdditionalHeaders )
                {
                    _headerList.Add(header.Name);
                }
            }

            //this.cmbTransformValue.SelectedIndex = this.GetTransformValueComboIndex(queryTransform);

            WebRequest req = base.SessionScripting.WebRequests[base.SelectedWebRequestIndex];
            LoadHeaderList(_headerList);
            LoadFormValues(req);
            LoadCookieNames(req);
        }
コード例 #30
0
 /// <summary>
 /// Creates a new ScriptingCommand.
 /// </summary>
 /// <param name="sessionScripting"> The ScriptingData to load.</param>
 public ScriptingCommand(ScriptingApplication sessionScripting)
     : this()
 {
     _sessionScripting = sessionScripting;
 }