Beispiel #1
0
        public string wmRunTask(string TaskXML, string ParameterXML)
        {
            acUI.acUI ui = new acUI.acUI();
            uiMethods um = new uiMethods();

            //we encoded this in javascript before the ajax call.
            TaskXML = ui.unpackJSON(TaskXML).Replace("'", "''");
            ParameterXML = ui.unpackJSON(ParameterXML).Replace("'", "''");

            //we gotta peek into the XML and encrypt any "encrypt" flagged values
            um.PrepareAndEncryptParameterXML(ref ParameterXML);

            try
            {
                //should be easy ... convert the XML into a real task
                // insert that task into the db
                // and launch it

                //the reason it goes into the db is for history's sake.
                //the "adhoc" tasks remain in the db, possibly hidden from the user
                //but at least for a while we retain a full record of what happened.

                //and, as a bonus, it's possible to take one of those ad-hoc tasks and "save" it as a regular task so it can be scheduled, etc.

                //will return a standard XML error document if there's a problem.
                //or a standard result XML if it's successful.

                Task t = new Task(TaskXML);

                //ok, now we have a task object.
                //call it's "create" method to save the whole thing in the db.
                t.Status = "adhoc";

                //t.Save();

                string sInstance = "";
                return "<result><task_instance>" + sInstance + "</task_instance></result>";
                //return "<result><error>Unable to parse and load TaskXML.</error></result>";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public string wmRunTask(string sTaskID, string sEcosystemID, string sAccountID, string sAssetID, string sParameterXML, int iDebugLevel)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            uiMethods um = new uiMethods();

            //we encoded this in javascript before the ajax call.
            //the safest way to unencode it is to use the same javascript lib.
            //(sometimes the javascript and .net libs don't translate exactly, google it.)
            sParameterXML = ui.unpackJSON(sParameterXML).Replace("'", "''");

            //we gotta peek into the XML and encrypt any newly keyed values
            um.PrepareAndEncryptParameterXML(ref sParameterXML);

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
                {

                    string sInstance = "";
                    string sErr = "";

                    string sSQL = "call addTaskInstance ('" + sTaskID + "','" +
                        sUserID + "',NULL," +
                        iDebugLevel + ",NULL,'" +
                        sParameterXML + "','" +
                        sEcosystemID + "','" +
                        sAccountID + "')";

                    if (!dc.sqlGetSingleString(ref sInstance, sSQL, ref sErr))
                    {
                        throw new Exception("Unable to run task [" + sTaskID + "]." + sErr);
                    }

                    return sInstance;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task [" + sTaskID + "] or asset [" + sAssetID + "] id.");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }