本文整理汇总了C#中acUI.acUI.unpackJSON方法的典型用法代码示例。如果您正苦于以下问题:C# acUI.acUI.unpackJSON方法的具体用法?C# acUI.acUI.unpackJSON怎么用?C# acUI.acUI.unpackJSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类acUI.acUI
的用法示例。
在下文中一共展示了acUI.acUI.unpackJSON方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: wmRunTask
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;
}
}
示例2: SaveKeyPair
public static string SaveKeyPair(string sKeypairID, string sAccountID, string sName, string sPK, string sPP)
{
acUI.acUI ui = new acUI.acUI();
if (string.IsNullOrEmpty(sName))
return "KeyPair Name is Required.";
//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.)
sPK = ui.unpackJSON(sPK);
bool bUpdatePK = false;
if (sPK != "-----BEGIN RSA PRIVATE KEY-----\n**********\n-----END RSA PRIVATE KEY-----")
{
//we want to make sure it's not just the placeholder, but DOES have the wrapper.
//and 61 is the lenght of the wrapper with no content... effectively empty
if (sPK.StartsWith("-----BEGIN RSA PRIVATE KEY-----\n") && sPK.EndsWith("\n-----END RSA PRIVATE KEY-----"))
{
//now, is there truly something in it?
string sContent = sPK.Replace("-----BEGIN RSA PRIVATE KEY-----", "").Replace("-----END RSA PRIVATE KEY-----", "").Replace("\n", "");
if (sContent.Length > 0)
bUpdatePK = true;
else
return "Private Key contained within:<br />-----BEGIN RSA PRIVATE KEY-----<br />and<br />-----END RSA PRIVATE KEY-----<br />cannot be blank.";
}
else
{
return "Private Key must be contained within:<br />-----BEGIN RSA PRIVATE KEY-----<br />and<br />-----END RSA PRIVATE KEY-----";
}
}
bool bUpdatePP = false;
if (sPP != "!2E4S6789O")
bUpdatePP = true;
//all good, keep going
dataAccess dc = new dataAccess();
string sSQL = null;
string sErr = null;
try
{
if (string.IsNullOrEmpty(sKeypairID))
{
//empty id, it's a new one.
string sPKClause = "";
if (bUpdatePK)
sPKClause = "'" + dc.EnCrypt(sPK) + "'";
string sPPClause = "null";
if (bUpdatePP)
sPPClause = "'" + dc.EnCrypt(sPP) + "'";
sSQL = "insert into cloud_account_keypair (keypair_id, account_id, keypair_name, private_key, passphrase)" +
" values ('" + ui.NewGUID() + "'," +
"'" + sAccountID + "'," +
"'" + sName.Replace("'", "''") + "'," +
sPKClause + "," +
sPPClause +
")";
}
else
{
string sPKClause = "";
if (bUpdatePK)
sPKClause = ", private_key = '" + dc.EnCrypt(sPK) + "'";
string sPPClause = "";
if (bUpdatePP)
sPPClause = ", passphrase = '" + dc.EnCrypt(sPP) + "'";
sSQL = "update cloud_account_keypair set" +
" keypair_name = '" + sName.Replace("'", "''") + "'" +
sPKClause + sPPClause +
" where keypair_id = '" + sKeypairID + "'";
}
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception(sErr);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
//// add security log
//// since this is not handled as a page postback, theres no "Viewstate" settings
//// so 2 options either we keep an original setting for each value in hid values, or just get them from the db as part of the
//// update above, since we are already passing in 15 or so fields, lets just get the values at the start and reference them here
//if (sMode == "edit")
//{
// ui.WriteObjectChangeLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, sOriginalName, sAccountName);
//}
//else
//{
//.........这里部分代码省略.........
示例3: wmUpdateTaskParam
public string wmUpdateTaskParam(string sType, string sID, string sParamID,
string sName, string sDesc,
string sRequired, string sPrompt, string sEncrypt, string sPresentAs, string sValues)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
if (!ui.IsGUID(sID))
throw new Exception("Invalid or missing ID.");
string sErr = "";
string sSQL = "";
//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.)
sDesc = ui.unpackJSON(sDesc).Trim();
//normalize and clean the values
sRequired = (dc.IsTrue(sRequired) ? "true" : "false");
sPrompt = (dc.IsTrue(sPrompt) ? "true" : "false");
sEncrypt = (dc.IsTrue(sEncrypt) ? "true" : "false");
sName = sName.Trim().Replace("'", "''");
string sTable = "";
string sXML = "";
string sParameterXPath = "//parameter[@id = \"" + sParamID + "\"]"; //using this to keep the code below cleaner.
if (sType == "ecosystem")
sTable = "ecosystem";
else if (sType == "task")
sTable = "task";
bool bParamAdd = false;
//bool bParamUpdate = false;
//if sParamID is empty, we are adding
if (string.IsNullOrEmpty(sParamID))
{
sParamID = "p_" + ui.NewGUID();
sParameterXPath = "//parameter[@id = \"" + sParamID + "\"]"; //reset this if we had to get a new id
//does the task already have parameters?
sSQL = "select parameter_xml from " + sTable + " where " + sType + "_id = '" + sID + "'";
if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
throw new Exception(sErr);
string sAddXML = "<parameter id=\"" + sParamID + "\" required=\"" + sRequired + "\" prompt=\"" + sPrompt + "\" encrypt=\"" + sEncrypt + "\">" +
"<name>" + sName + "</name>" +
"<desc>" + sDesc + "</desc>" +
"</parameter>";
if (string.IsNullOrEmpty(sXML))
{
//XML doesn't exist at all, add it to the record
sAddXML = "<parameters>" + sAddXML + "</parameters>";
sSQL = "update " + sTable + " set " +
" parameter_xml = '" + sAddXML + "'" +
" where " + sType + "_id = '" + sID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception(sErr);
bParamAdd = true;
}
else
{
//XML exists, add the node to it
ft.AddNodeToXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", "//parameters", sAddXML);
bParamAdd = true;
}
}
else
{
//update the node values
ft.SetNodeValueinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath + "/name", sName);
ft.SetNodeValueinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath + "/desc", sDesc);
//and the attributes
ft.SetNodeAttributeinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, "required", sRequired);
ft.SetNodeAttributeinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, "prompt", sPrompt);
ft.SetNodeAttributeinXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", sParameterXPath, "encrypt", sEncrypt);
bParamAdd = false;
}
// not clean at all handling both tasks and ecosystems in the same method, but whatever.
if (bParamAdd)
{
if (sType == "task") { ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sID, "Parameter", "Added Parameter:" + sName ); };
if (sType == "ecosystem") { ui.WriteObjectAddLog(Globals.acObjectTypes.Ecosystem, sID, "Parameter", "Added Parameter:" + sName); };
}
else
{
// would be a lot of trouble to add the from to, why is it needed you have each value in the log, just scroll back
// so just add a changed message to the log
if (sType == "task") { dc.addSecurityLog(ui.GetSessionUserID(), Globals.SecurityLogTypes.Object, Globals.SecurityLogActions.ObjectModify, Globals.acObjectTypes.Task, sID, "Parameter Changed:[" + sName + "]", ref sErr); };
if (sType == "ecosystem") { dc.addSecurityLog(ui.GetSessionUserID(), Globals.SecurityLogTypes.Object, Globals.SecurityLogActions.ObjectModify, Globals.acObjectTypes.Ecosystem, sID, "Parameter Changed:[" + sName + "]", ref sErr); };
//.........这里部分代码省略.........
示例4: wmUpdateTaskDetail
public string wmUpdateTaskDetail(string sTaskID, string sColumn, string sValue)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
try
{
string sUserID = ui.GetSessionUserID();
if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
{
string sErr = "";
string sSQL = "";
//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.)
sValue = ui.unpackJSON(sValue);
string sOriginalTaskID = "";
sSQL = "select original_task_id from task where task_id = '" + sTaskID + "'";
if (!dc.sqlGetSingleString(ref sOriginalTaskID, sSQL, ref sErr))
throw new Exception("Unable to get original_task_id for [" + sTaskID + "]." + sErr);
if (sOriginalTaskID == "")
return "Unable to get original_task_id for [" + sTaskID + "].";
// bugzilla 1074, check for existing task_code and task_name
if (sColumn == "task_code" || sColumn == "task_name")
{
sSQL = "select task_id from task where " +
sColumn.Replace("'", "''") + "='" + sValue.Replace("'", "''") + "'" +
" and original_task_id <> '" + sOriginalTaskID + "'";
string sValueExists = "";
if (!dc.sqlGetSingleString(ref sValueExists, sSQL, ref sErr))
throw new Exception("Unable to check for existing names [" + sTaskID + "]." + sErr);
if (!string.IsNullOrEmpty(sValueExists))
return sValue + " exists, please choose another value.";
}
if (sColumn == "task_code" || sColumn == "task_name")
{
//changing the name or code updates ALL VERSIONS
string sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
sSQL = "update task set " + sSetClause + " where original_task_id = '" + sOriginalTaskID + "'";
}
else
{
string sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
//some columns on this table allow nulls... in their case an empty sValue is a null
if (sColumn == "concurrent_instances" || sColumn == "queue_depth")
{
if (sValue.Replace(" ", "").Length == 0)
sSetClause = sColumn + " = null";
else
sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
}
//some columns are checkboxes, so make sure it is a db appropriate value (1 or 0)
//some columns on this table allow nulls... in their case an empty sValue is a null
if (sColumn == "concurrent_by_asset")
{
if (dc.IsTrue(sValue))
sSetClause = sColumn + " = 1";
else
sSetClause = sColumn + " = 0";
}
sSQL = "update task set " + sSetClause + " where task_id = '" + sTaskID + "'";
}
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to update task [" + sTaskID + "]." + sErr);
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, sColumn, sValue);
}
else
{
throw new Exception("Unable to update task. Missing or invalid task [" + sTaskID + "] id.");
}
}
catch (Exception ex)
{
throw ex;
}
return "";
}
示例5: wmUpdateStep
public string wmUpdateStep(string sStepID, string sFunction, string sXPath, string sValue)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sSQL = "";
//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.)
sValue = ui.unpackJSON(sValue);
//if the function type is "_common" that means this is a literal column on the step table.
if (sFunction == "_common")
{
sValue = sValue.Replace("'", "''"); //escape single quotes for the SQL insert
sSQL = "update task_step set " +
sXPath + " = '" + sValue + "'" +
" where step_id = '" + sStepID + "';";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
throw new Exception(sErr);
}
}
else
{
//XML processing
//get the xml from the step table and update it
string sXMLTemplate = "";
sSQL = "select function_xml from task_step where step_id = '" + sStepID + "'";
if (!dc.sqlGetSingleString(ref sXMLTemplate, sSQL, ref sErr))
{
throw new Exception("Unable to get XML data for step [" + sStepID + "].");
}
XDocument xDoc = XDocument.Parse(sXMLTemplate);
if (xDoc == null)
throw new Exception("XML data for step [" + sStepID + "] is invalid.");
XElement xRoot = xDoc.Element("function");
if (xRoot == null)
throw new Exception("XML data for step [" + sStepID + "] does not contain 'function' root node.");
try
{
XElement xNode = xRoot.XPathSelectElement(sXPath);
if (xNode == null)
throw new Exception("XML data for step [" + sStepID + "] does not contain '" + sXPath + "' node.");
xNode.SetValue(sValue);
}
catch (Exception)
{
try
{
//here's the deal... given an XPath statement, we simply cannot add a new node if it doesn't exist.
//why? because xpath is a query language. It doesnt' describe exactly what to add due to wildcards and //foo syntax.
//but, what we can do is make an ssumption in our specific case...
//that we are only wanting to add because we changed an underlying command XML template, and there are existing commands.
//so... we will split the xpath into segments, and traverse upward until we find an actual node.
//once we have it, we will need to add elements back down.
//string[] nodes = sXPath.Split('/');
//foreach (string node in nodes)
//{
// //try to select THIS one, and stick it on the backwards stack
// XElement xNode = xRoot.XPathSelectElement("//" + node);
// if (xNode == null)
// throw new Exception("XML data for step [" + sStepID + "] does not contain '" + sXPath + "' node.");
//}
XElement xFoundNode = null;
ArrayList aMissingNodes = new ArrayList();
//of course this skips the full path, but we've already determined it's no good.
string sWorkXPath = sXPath;
while (sWorkXPath.LastIndexOf("/") > -1)
{
aMissingNodes.Add(sWorkXPath.Substring(sWorkXPath.LastIndexOf("/") + 1));
sWorkXPath = sWorkXPath.Substring(0, sWorkXPath.LastIndexOf("/"));
xFoundNode = xRoot.XPathSelectElement(sWorkXPath);
if (xFoundNode != null)
{
//Found it! stop looping
break;
}
}
//now that we know where to start (xFoundNode), we can use that as a basis for adding
foreach (string sNode in aMissingNodes)
{
//.........这里部分代码省略.........
示例6: wmRunTask
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;
}
}
示例7: wmUpdateEcoTemplateDetail
public string wmUpdateEcoTemplateDetail(string sEcoTemplateID, string sColumn, string sValue)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
try
{
string sUserID = ui.GetSessionUserID();
if (ui.IsGUID(sEcoTemplateID) && ui.IsGUID(sUserID))
{
string sErr = "";
string sSQL = "";
//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.)
sValue = ui.unpackJSON(sValue);
// check for existing name
if (sColumn == "ecotemplate_name")
{
sSQL = "select ecotemplate_id from ecotemplate where " +
" ecotemplate_name = '" + sValue.Replace("'", "''") + "'" +
" and ecotemplate_id <> '" + sEcoTemplateID + "'";
string sValueExists = "";
if (!dc.sqlGetSingleString(ref sValueExists, sSQL, ref sErr))
throw new Exception("Unable to check for existing names [" + sEcoTemplateID + "]." + sErr);
if (!string.IsNullOrEmpty(sValueExists))
return sValue + " exists, please choose another value.";
}
string sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
//some columns on this table allow nulls... in their case an empty sValue is a null
if (sColumn == "ecotemplate_desc")
{
if (sValue.Replace(" ", "").Length == 0)
sSetClause = sColumn + " = null";
else
sSetClause = sColumn + "='" + sValue.Replace("'", "''") + "'";
}
sSQL = "update ecotemplate set " + sSetClause + " where ecotemplate_id = '" + sEcoTemplateID + "'";
//}
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to update Eco Template [" + sEcoTemplateID + "]." + sErr);
ui.WriteObjectChangeLog(Globals.acObjectTypes.EcoTemplate, sEcoTemplateID, sColumn, sValue);
}
else
{
throw new Exception("Unable to update Eco Template. Missing or invalid id [" + sEcoTemplateID + "].");
}
}
catch (Exception ex)
{
throw ex;
}
return "";
}
示例8: wmSendErrorReport
public void wmSendErrorReport(string sMessage, string sPageDetails)
{
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sTo = (string)ui.GetSessionObject("admin_email", "Security");
if (!string.IsNullOrEmpty(sTo) && !string.IsNullOrEmpty(sMessage))
{
string sFrom = "[email protected]" + Server.MachineName.ToString();
sMessage = ui.unpackJSON(sMessage);
ui.SendEmailMessage(sTo, sFrom, "UI Error Report", sMessage + Environment.NewLine + Environment.NewLine + sPageDetails, ref sErr);
}
return;
}
示例9: wmSaveSchedule
public void wmSaveSchedule(string sScheduleID,
string sMonths, string sDays, string sHours, string sMinutes, string sDaysOrWeeks,
string sParameterXML, int iDebugLevel)
{
/*
* JUST AS A REMINDER:
* There is no parameter 'merging' happening here. This is a Scheduled Plan ...
* it has ALL the parameters it needs to pass to the CE.
*
* */
acUI.acUI ui = new acUI.acUI();
try
{
if (sScheduleID.Length == 0 || sMonths.Length == 0 || sDays.Length == 0 || sHours.Length == 0 || sMinutes.Length == 0 || sDaysOrWeeks.Length == 0)
throw new Exception("Missing Schedule ID or invalid timetable.");
//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
PrepareAndEncryptParameterXML(ref sParameterXML);
dataAccess dc = new dataAccess();
string sSQL = null;
string sErr = null;
//whack all plans for this schedule, it's been changed
sSQL = "delete from action_plan where schedule_id = '" + sScheduleID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception(sErr);
//figure out a label
string sDesc = "";
string sLabel = wmGenerateScheduleLabel(sMonths, sDays, sHours, sMinutes, sDaysOrWeeks, ref sDesc);
sSQL = "update action_schedule set" +
" months = '" + sMonths + "'," +
" days = '" + sDays + "'," +
" hours = '" + sHours + "'," +
" minutes = '" + sMinutes + "'," +
" days_or_weeks = '" + sDaysOrWeeks + "'," +
" label = " + (!string.IsNullOrEmpty(sLabel) ? "'" + sLabel + "'" : "null") + "," +
" descr = " + (!string.IsNullOrEmpty(sDesc) ? "'" + sDesc + "'" : "null") + "," +
" parameter_xml = " + (!string.IsNullOrEmpty(sParameterXML) ? "'" + sParameterXML + "'" : "null") + "," +
" debug_level = " + (iDebugLevel > -1 ? iDebugLevel.ToString() : "null") +
" where schedule_id = '" + sScheduleID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr)) { throw new Exception(sErr); }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例10: wmSavePlan
public void wmSavePlan(int iPlanID, string sParameterXML, int iDebugLevel)
{
/*
* JUST AS A REMINDER:
* There is no parameter 'merging' happening here. This is a Plan ...
* it has ALL the parameters it needs to pass to the CE.
*
* */
acUI.acUI ui = new acUI.acUI();
try
{
if (iPlanID < 1)
throw new Exception("Missing Action Plan ID.");
//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
PrepareAndEncryptParameterXML(ref sParameterXML);
dataAccess dc = new dataAccess();
string sSQL = null;
string sErr = null;
sSQL = "update action_plan" +
" set parameter_xml = " + (!string.IsNullOrEmpty(sParameterXML) ? "'" + sParameterXML + "'" : "null") + "," +
" debug_level = " + (iDebugLevel > -1 ? iDebugLevel.ToString() : "null") +
" where plan_id = " + iPlanID.ToString();
if (!dc.sqlExecuteUpdate(sSQL, ref sErr)) { throw new Exception(sErr); }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例11: wmSaveActionParameterXML
public void wmSaveActionParameterXML(string sActionID, string sActionDefaultsXML)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
taskMethods tm = new taskMethods();
try
{
string sUserID = ui.GetSessionUserID();
if (ui.IsGUID(sActionID) && ui.IsGUID(sUserID))
{
string sErr = "";
string sSQL = "";
//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.)
sActionDefaultsXML = ui.unpackJSON(sActionDefaultsXML);
//we gotta peek into the XML and encrypt any newly keyed values
PrepareAndEncryptParameterXML(ref sActionDefaultsXML);
//so, like when we read it, we gotta spin and compare, and build an XML that only represents *changes*
//to the defaults on the task.
//what is the task associated with this action?
sSQL = "select t.task_id" +
" from ecotemplate_action ea" +
" join task t on ea.original_task_id = t.original_task_id" +
" and t.default_version = 1" +
" where ea.action_id = '" + sActionID + "'";
string sTaskID = "";
if (!dc.sqlGetSingleString(ref sTaskID, sSQL, ref sErr))
throw new Exception(sErr);
if (!ui.IsGUID(sTaskID))
throw new Exception("Unable to find Task ID for Action.");
string sOverrideXML = "";
XDocument xTPDoc = new XDocument();
XDocument xADDoc = new XDocument();
//get the parameter XML from the TASK
string sTaskParamXML = tm.wmGetParameterXML("task", sTaskID, "");
if (!string.IsNullOrEmpty(sTaskParamXML))
{
xTPDoc = XDocument.Parse(sTaskParamXML);
if (xTPDoc == null)
throw new Exception("Task Parameter XML data is invalid.");
XElement xTPParams = xTPDoc.XPathSelectElement("/parameters");
if (xTPParams == null)
throw new Exception("Task Parameter XML data does not contain 'parameters' root node.");
}
//we had the ACTION defaults handed to us
if (!string.IsNullOrEmpty(sActionDefaultsXML))
{
xADDoc = XDocument.Parse(sActionDefaultsXML);
if (xADDoc == null)
throw new Exception("Action Defaults XML data is invalid.");
XElement xADParams = xADDoc.XPathSelectElement("/parameters");
if (xADParams == null)
throw new Exception("Action Defaults XML data does not contain 'parameters' root node.");
}
//spin the nodes in the ACTION xml, then dig in to the task XML and UPDATE the value if found.
//(if the node no longer exists, delete the node from the action XML)
//and action "values" take precedence over task values.
//this does a regular loop because we can't remove from an IEnumerable
int x = xADDoc.XPathSelectElements("//parameter").Count();
for (int i = (x-1); i>=0; i--)
{
XElement xDefault = xADDoc.XPathSelectElements("//parameter").ElementAt(i);
//look it up in the task param xml
XElement xADName = xDefault.XPathSelectElement("name");
string sADName = (xADName == null ? "" : xADName.Value);
XElement xADValues = xDefault.XPathSelectElement("values");
//string sValues = (xValues == null ? "" : xValues.ToString());
//now we have the name of the parameter, go find it in the TASK param XML
XElement xTaskParam = xTPDoc.XPathSelectElement("//parameter/name[. = '" + sADName + "']/.."); //NOTE! the /.. gets the parent of the name node!
//if it doesn't exist in the task params, remove it from this document
if (xTaskParam == null)
{
xDefault.Remove();
continue;
}
//and the "values" collection will be the 'next' node
XElement xTaskParamValues = xTaskParam.XPathSelectElement("values");
//so... it might be
//.........这里部分代码省略.........
示例12: wmRunRepeatedly
public void wmRunRepeatedly(string sTaskID, string sActionID, string sEcosystemID,
string sMonths, string sDays, string sHours, string sMinutes, string sDaysOrWeeks,
string sParameterXML, int iDebugLevel)
{
acUI.acUI ui = new acUI.acUI();
try
{
string sCloudAccountID = ui.GetSelectedCloudAccountID();
if (sTaskID.Length == 0 || sMonths.Length == 0 || sDays.Length == 0 || sHours.Length == 0 || sMinutes.Length == 0 || sDaysOrWeeks.Length == 0)
throw new Exception("Missing or invalid Schedule timing or Task ID.");
//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
PrepareAndEncryptParameterXML(ref sParameterXML);
dataAccess dc = new dataAccess();
string sSQL = null;
string sErr = null;
//figure out a label and a description
string sDesc = "";
string sLabel = wmGenerateScheduleLabel(sMonths, sDays, sHours, sMinutes, sDaysOrWeeks, ref sDesc);
sSQL = "insert into action_schedule (schedule_id, task_id, action_id, ecosystem_id, account_id," +
" months, days, hours, minutes, days_or_weeks, label, descr, parameter_xml, debug_level)" +
" values (" +
" '" + ui.NewGUID() + "'," +
" '" + sTaskID + "'," +
(!string.IsNullOrEmpty(sActionID) ? " '" + sActionID + "'" : "''") + "," +
(!string.IsNullOrEmpty(sEcosystemID) ? " '" + sEcosystemID + "'" : "''") + "," +
(!string.IsNullOrEmpty(sCloudAccountID) ? " '" + sCloudAccountID + "'" : "''") + "," +
" '" + sMonths + "'," +
" '" + sDays + "'," +
" '" + sHours + "'," +
" '" + sMinutes + "'," +
" '" + sDaysOrWeeks + "'," +
(!string.IsNullOrEmpty(sLabel) ? " '" + sLabel + "'" : "null") + "," +
(!string.IsNullOrEmpty(sDesc) ? " '" + sDesc + "'" : "null") + "," +
(!string.IsNullOrEmpty(sParameterXML) ? " '" + sParameterXML + "'" : "null") + "," +
(iDebugLevel > -1 ? iDebugLevel.ToString() : "null") +
")";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr)) { throw new Exception(sErr); }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例13: wmRunLater
public void wmRunLater(string sTaskID, string sActionID, string sEcosystemID, string sRunOn, string sParameterXML, int iDebugLevel)
{
acUI.acUI ui = new acUI.acUI();
dataAccess dc = new dataAccess();
try
{
string sCloudAccountID = ui.GetSelectedCloudAccountID();
if (sTaskID.Length == 0 || sRunOn.Length == 0)
throw new Exception("Missing Action Plan date or Task ID.");
//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
PrepareAndEncryptParameterXML(ref sParameterXML);
string sSQL = null;
string sErr = null;
sSQL = "insert into action_plan (task_id, action_id, ecosystem_id, account_id," +
" run_on_dt, parameter_xml, debug_level, source)" +
" values (" +
" '" + sTaskID + "'," +
(!string.IsNullOrEmpty(sActionID) ? " '" + sActionID + "'" : "''") + "," +
(!string.IsNullOrEmpty(sEcosystemID) ? " '" + sEcosystemID + "'" : "''") + "," +
(!string.IsNullOrEmpty(sCloudAccountID) ? " '" + sCloudAccountID + "'" : "''") + "," +
" str_to_date('" + sRunOn + "', '%m/%d/%Y %H:%i')," +
(!string.IsNullOrEmpty(sParameterXML) ? " '" + sParameterXML + "'" : "null") + "," +
(iDebugLevel > -1 ? iDebugLevel.ToString() : "null") + "," +
" 'manual'" +
")";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr)) { throw new Exception(sErr); }
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例14: PrepareAndEncryptParameterXML
//this one is used by several functions...
//it looks in the XML for anything to encrypt or rearrange
//because we can't do everything on the client.
public void PrepareAndEncryptParameterXML(ref string sParameterXML)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
if (!string.IsNullOrEmpty(sParameterXML))
{
XDocument xDoc = XDocument.Parse(sParameterXML);
if (xDoc == null)
throw new Exception("Parameter XML data is invalid.");
XElement xParams = xDoc.XPathSelectElement("/parameters");
if (xParams == null)
throw new Exception("Parameter XML data does not contain 'parameters' root node.");
//now, all we're doing here is:
// a) encrypting any new values
// b) moving any oev values from an attribute to a value
// a) encrypt new values
foreach (XElement xToEncrypt in xDoc.XPathSelectElements("//parameter/values/value[@do_encrypt='true']"))
{
xToEncrypt.Value = dc.EnCrypt(xToEncrypt.Value);
xToEncrypt.SetAttributeValue("do_encrypt", null);
}
//b) unbase64 any oev's and move them to values
foreach (XElement xToEncrypt in xDoc.XPathSelectElements("//parameter/values/value[@oev='true']"))
{
xToEncrypt.Value = ui.unpackJSON(xToEncrypt.Value);
xToEncrypt.SetAttributeValue("oev", null);
}
sParameterXML = xDoc.ToString(SaveOptions.DisableFormatting);
}
}