本文整理汇总了C#中acUI.acUI.packJSON方法的典型用法代码示例。如果您正苦于以下问题:C# acUI.acUI.packJSON方法的具体用法?C# acUI.acUI.packJSON怎么用?C# acUI.acUI.packJSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类acUI.acUI
的用法示例。
在下文中一共展示了acUI.acUI.packJSON方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: wmGetTaskParam
public string wmGetTaskParam(string sType, string sID, string sParamID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
if (!ui.IsGUID(sID))
throw new Exception("Invalid or missing ID.");
try
{
string sTable = "";
if (sType == "ecosystem")
sTable = "ecosystem";
else if (sType == "task")
sTable = "task";
//default values if adding - get overridden if there is a record
string sName = "";
string sDesc = "";
string sRequired = "false";
string sPrompt = "true";
string sEncrypt = "false";
string sValuesHTML = "";
string sPresentAs = "value";
if (!string.IsNullOrEmpty(sParamID))
{
string sErr = "";
string sXML = "";
string sSQL = "select parameter_xml" +
" from " + sTable +
" where " + sType + "_id = '" + sID + "'";
if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
throw new Exception("Unable to get parameter_xml. " + sErr);
if (sXML != "")
{
XDocument xd = XDocument.Parse(sXML);
if (xd == null) throw new Exception("XML parameter data is invalid.");
XElement xParameter = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]");
if (xParameter == null) return "Error: XML does not contain parameter.";
XElement xName = xParameter.XPathSelectElement("name");
if (xName == null) return "Error: XML does not contain parameter name.";
XElement xDesc = xParameter.XPathSelectElement("desc");
if (xDesc == null) return "Error: XML does not contain parameter description.";
sName = xName.Value;
sDesc = xDesc.Value;
if (xParameter.Attribute("required") != null)
sRequired = xParameter.Attribute("required").Value;
if (xParameter.Attribute("prompt") != null)
sPrompt = xParameter.Attribute("prompt").Value;
if (xParameter.Attribute("encrypt") != null)
sEncrypt = xParameter.Attribute("encrypt").Value;
XElement xValues = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/values");
if (xValues != null)
{
if (xValues.Attribute("present_as") != null)
sPresentAs = xValues.Attribute("present_as").Value;
int i = 0;
IEnumerable<XElement> xVals = xValues.XPathSelectElements("value");
foreach (XElement xVal in xVals)
{
//since we can delete each item from the page it needs a unique id.
string sPID = "pv" + ui.NewGUID();
string sValue = xVal.Value;
string sObscuredValue = "";
if (dc.IsTrue(sEncrypt))
{
// 1) obscure the ENCRYPTED value and make it safe to be an html attribute
// 2) return some stars so the user will know a value is there.
sObscuredValue = "oev=\"" + ui.packJSON(sValue) + "\"";
sValue = "";
}
sValuesHTML += "<div id=\"" + sPID + "\">" +
"<textarea class=\"param_edit_value\" rows=\"1\" " + sObscuredValue + ">" + sValue + "</textarea>";
if (i > 0)
{
string sHideDel = (sPresentAs == "list" || sPresentAs == "dropdown" ? "" : " hidden");
sValuesHTML += " <img class=\"param_edit_value_remove_btn pointer " + sHideDel + "\" remove_id=\"" + sPID + "\"" +
" src=\"../images/icons/fileclose.png\" alt=\"\" />";
}
sValuesHTML += "</div>";
i++;
}
//.........这里部分代码省略.........
示例2: LoadAssetData
public static string LoadAssetData(string sAssetID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = null;
string sAssetName = null;
string sPort = null;
string sDbName = null;
string sAddress = null;
string sConnectionType = null;
string sUserName = null;
string sSharedOrLocal = null;
string sCredentialID = null;
string sPassword = null;
string sDomain = null;
string sAssetStatus = null;
string sPrivilegedPassword = null;
string sSharedCredName = null;
string sSharedCredDesc = null;
string sConnString = null;
DataRow dr = null;
sSql = "select a.asset_name, a.asset_status, a.port, a.db_name, a.conn_string," +
" a.address, a.connection_type, ac.username, ac.password, ac.privileged_password, ac.domain, ac.shared_cred_desc, ac.credential_name, a.credential_id," +
" case when ac.shared_or_local = '0' then 'Shared' else 'Local' end as shared_or_local" +
" from asset a " +
" left outer join asset_credential ac on ac.credential_id = a.credential_id " +
" where a.asset_id = '" + sAssetID + "'";
if (!dc.sqlGetDataRow(ref dr, sSql, ref sErr))
{
throw new Exception(sErr);
}
else
{
if (dr != null)
{
sAssetName = dr["asset_name"].ToString();
sPort = (object.ReferenceEquals(dr["port"], DBNull.Value) ? "" : dr["port"].ToString());
sDbName = (object.ReferenceEquals(dr["db_name"], DBNull.Value) ? "" : dr["db_name"].ToString());
sAddress = (object.ReferenceEquals(dr["address"], DBNull.Value) ? "" : dr["address"].ToString().Replace("\\\\", "||"));
sAddress = sAddress.Replace("\\", "|");
sConnectionType = (object.ReferenceEquals(dr["connection_type"], DBNull.Value) ? "" : dr["connection_type"].ToString());
sUserName = (object.ReferenceEquals(dr["username"], DBNull.Value) ? "" : dr["username"].ToString());
sConnString = (object.ReferenceEquals(dr["conn_string"], DBNull.Value) ? "" : dr["conn_string"].ToString());
sSharedOrLocal = (object.ReferenceEquals(dr["shared_or_local"], DBNull.Value) ? "" : dr["shared_or_local"].ToString());
sCredentialID = (object.ReferenceEquals(dr["credential_id"], DBNull.Value) ? "" : dr["credential_id"].ToString());
sPassword = (object.ReferenceEquals(dr["password"], DBNull.Value) ? "" : "($%#[email protected]!&");
sDomain = (object.ReferenceEquals(dr["domain"], DBNull.Value) ? "" : dr["domain"].ToString());
sAssetStatus = dr["asset_status"].ToString();
sPrivilegedPassword = (object.ReferenceEquals(dr["privileged_password"], DBNull.Value) ? "" : "($%#[email protected]!&");
sSharedCredName = (object.ReferenceEquals(dr["credential_name"], DBNull.Value) ? "" : dr["credential_name"].ToString());
sSharedCredDesc = (object.ReferenceEquals(dr["shared_cred_desc"], DBNull.Value) ? "" : dr["shared_cred_desc"].ToString());
}
}
// Return the asset object as a JSON
StringBuilder sbAssetValues = new StringBuilder();
sbAssetValues.Append("{");
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sAssetName", ui.packJSON(sAssetName));
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sPort", sPort);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sDbName", sDbName);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sAddress", sAddress);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sConnectionType", sConnectionType);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sUserName", sUserName);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sConnString", ui.packJSON(sConnString));
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sSharedOrLocal", sSharedOrLocal);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sCredentialID", sCredentialID);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sPassword", sPassword);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sDomain", sDomain);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sPriviledgedPassword", sPrivilegedPassword);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sSharedCredName", sSharedCredName);
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\",", "sSharedCredDesc", ui.packJSON(sSharedCredDesc));
//last value, no comma on the end
sbAssetValues.AppendFormat("\"{0}\" : \"{1}\"", "sAssetStatus", sAssetStatus);
sbAssetValues.Append("}");
return sbAssetValues.ToString();
}
示例3: wmGetObjectParameterXML
public string wmGetObjectParameterXML(string sType, string sID, string sFilterByEcosystemID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
try
{
string sErr = "";
string sParameterXML = "";
string sSQL = "";
if (sType == "instance")
{
//if sID is a guid, it's a task_id ... get the most recent run
//otherwise assume it's a task_instance and try that.
if (ui.IsGUID(sID))
sSQL = "select parameter_xml from task_instance_parameter where task_instance = " +
"(select max(task_instance) from task_instance where task_id = '" + sID + "')";
else if (ui.IsGUID(sFilterByEcosystemID)) //but if there's an ecosystem_id, limit it to that
sSQL = "select parameter_xml from task_instance_parameter where task_instance = " +
"(select max(task_instance) from task_instance where task_id = '" + sID + "')" +
" and ecosystem_id = '" + sFilterByEcosystemID + "'";
else
sSQL = "select parameter_xml from task_instance_parameter where task_instance = '" + sID + "'";
}
else if (sType == "action")
{
sSQL = "select parameter_defaults from ecotemplate_action where action_id = '" + sID + "'";
}
else if (sType == "plan")
{
sSQL = "select parameter_xml from action_plan where plan_id = " + sID;
}
else if (sType == "schedule")
{
sSQL = "select parameter_xml from action_schedule where schedule_id = '" + sID + "'";
}
else if (sType == "task")
{
sSQL = "select parameter_xml from task where task_id = '" + sID + "'";
}
if (!dc.sqlGetSingleString(ref sParameterXML, sSQL, ref sErr))
{
throw new Exception(sErr);
}
if (!string.IsNullOrEmpty(sParameterXML))
{
XDocument xDoc = XDocument.Parse(sParameterXML);
if (xDoc == null)
throw new Exception("Parameter XML data for [" + sType + ":" + sID + "] is invalid.");
XElement xParams = xDoc.XPathSelectElement("/parameters");
if (xParams == null)
throw new Exception("Parameter XML data for[" + sType + ":" + sID + "] does not contain 'parameters' root node.");
//NOTE: some values on this document may have a "encrypt" attribute.
//If so, we will:
// 1) obscure the ENCRYPTED value and make it safe to be an html attribute
// 2) return some stars so the user will know a value is there.
foreach (XElement xEncryptedValue in xDoc.XPathSelectElements("//parameter[@encrypt='true']/values/value"))
{
//if the value is empty, it still gets an oev attribute
string sVal = (string.IsNullOrEmpty(xEncryptedValue.Value) ? "" : ui.packJSON(xEncryptedValue.Value));
xEncryptedValue.SetAttributeValue("oev", sVal);
//but it only gets stars if it has a value
if (!string.IsNullOrEmpty(sVal))
xEncryptedValue.Value = "********";
}
return xDoc.ToString(SaveOptions.DisableFormatting);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
//it may just be there are no parameters
return "";
}
示例4: 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
//.........这里部分代码省略.........