本文整理汇总了C#中acUI.acUI类的典型用法代码示例。如果您正苦于以下问题:C# acUI.acUI类的具体用法?C# acUI.acUI怎么用?C# acUI.acUI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
acUI.acUI类属于命名空间,在下文中一共展示了acUI.acUI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DeleteClouds
public static string DeleteClouds(string sDeleteArray)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = "";
if (sDeleteArray.Length < 36)
return "";
sDeleteArray = ui.QuoteUp(sDeleteArray);
DataTable dt = new DataTable();
// get a list of ids that will be deleted for the log
sSql = "select cloud_id, cloud_name, provider from clouds where cloud_id in (" + sDeleteArray + ")";
if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
throw new Exception(sErr);
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
sSql = "delete from clouds where cloud_id in (" + sDeleteArray + ")";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception(sErr);
//refresh the cloud account list in the session
if (!ui.PutCloudAccountsInSession(ref sErr))
throw new Exception(sErr);
oTrans.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
//reget the cloud providers class in the session
ui.SetCloudProviders(ref sErr);
if (!string.IsNullOrEmpty(sErr))
throw new Exception("Error: Unable to load Cloud Providers XML." + sErr);
// if we made it here, so save the logs
foreach (DataRow dr in dt.Rows)
{
ui.WriteObjectDeleteLog(Globals.acObjectTypes.Cloud, dr["cloud_id"].ToString(), dr["cloud_name"].ToString(), dr["provider"].ToString() + " Cloud Deleted.");
}
return sErr;
}
开发者ID:you8,项目名称:cato,代码行数:51,代码来源:cloudEdit.aspx.cs
示例2: DeleteCredentials
public static string DeleteCredentials(string sDeleteArray)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = "";
if (sDeleteArray.Length < 36)
return "";
sDeleteArray = ui.QuoteUp(sDeleteArray);
DataTable dt = new DataTable();
// get a list of credential_ids that will be deleted for the log
sSql = "select credential_name,credential_id from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
"and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
{
throw new Exception(sErr);
}
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
//delete asset_credential
sSql = "delete from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
"and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception(sErr);
}
oTrans.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
// if we made it here, so save the logs
foreach (DataRow dr in dt.Rows)
{
ui.WriteObjectDeleteLog(Globals.acObjectTypes.Credential, dr["credential_id"].ToString(), dr["credential_name"].ToString(), "Credential Deleted");
}
return sErr;
}
开发者ID:you8,项目名称:cato,代码行数:50,代码来源:sharedCredentialEdit.aspx.cs
示例3: DeleteAccounts
public static string DeleteAccounts(string sDeleteArray)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = "";
if (sDeleteArray.Length < 36)
return "";
sDeleteArray = ui.QuoteUp(sDeleteArray);
DataTable dt = new DataTable();
// get a list of ids that will be deleted for the log
sSql = "select account_id, account_name, provider, login_id from cloud_account where account_id in (" + sDeleteArray + ")";
if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
throw new Exception(sErr);
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
sSql = "delete from cloud_account where account_id in (" + sDeleteArray + ")";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception(sErr);
//refresh the cloud account list in the session
if (!ui.PutCloudAccountsInSession(ref sErr))
throw new Exception(sErr);
oTrans.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
// if we made it here, so save the logs
foreach (DataRow dr in dt.Rows)
{
ui.WriteObjectDeleteLog(Globals.acObjectTypes.CloudAccount, dr["account_id"].ToString(), dr["account_name"].ToString(), dr["provider"].ToString() + " Account for LoginID [" + dr["login_id"].ToString() + "] Deleted");
}
return sErr;
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:47,代码来源:cloudAccountEdit.aspx.cs
示例4: GetRegistry
public XDocument GetRegistry(string sObjectID, ref string sErr)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
try
{
string sXML = "";
string sSQL = "select registry_xml from object_registry where object_id = '" + sObjectID + "'";
if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
throw new Exception("Error: Could not look up Registry XML." + sErr);
if (!string.IsNullOrEmpty(sXML))
{
XDocument xd = XDocument.Parse(sXML);
if (xd == null)
{
throw new Exception("Error: Unable to parse XML.");
}
return xd;
}
else
{
//if the object_id is a guid, it's an object registry... add one if it's not there.
if (ui.IsGUID(sObjectID))
{
sSQL = "insert into object_registry values ('" + sObjectID + "', '<registry />')";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Error: Could not create Registry." + sErr);
XDocument xd = XDocument.Parse("<registry />");
return xd;
}
else
throw new Exception("Error: Could not look up Registry XML.");
}
}
catch (Exception ex)
{
throw ex;
}
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:45,代码来源:uiMethods.asmx.cs
示例5: 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;
}
}
开发者ID:you8,项目名称:cato,代码行数:44,代码来源:api.asmx.cs
示例6: DeleteDomains
public static string DeleteDomains(string sDeleteArray)
{
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = "";
if (sDeleteArray.Length < 36)
return "";
sDeleteArray = ui.QuoteUp(sDeleteArray);
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
//delete domains
sSql = "delete from ldap_domain where ldap_domain in (" + sDeleteArray.ToString() + ")";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception(sErr);
}
oTrans.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
// if we made it here, so save the logs
ui.WriteObjectDeleteLog(Globals.acObjectTypes.Domain, sDeleteArray.ToString(), sDeleteArray.ToString(), "Domain(s) Deleted");
return sErr;
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:36,代码来源:ldapEdit.aspx.cs
示例7: wmCreateNewTaskVersion
public string wmCreateNewTaskVersion(string sTaskID, string sMinorMajor)
{
acUI.acUI ui = new acUI.acUI();
try
{
string sNewVersionGUID = CopyTask((sMinorMajor == "Major" ? 1 : 2), sTaskID, "", "");
if (!string.IsNullOrEmpty(sNewVersionGUID))
{
ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewVersionGUID, sNewVersionGUID, "");
}
return sNewVersionGUID;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:20,代码来源:taskMethods.asmx.cs
示例8: wmAddStep
public string wmAddStep(string sTaskID, string sCodeblockName, string sItem)
{
dataAccess dc = new dataAccess();
FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
acUI.acUI ui = new acUI.acUI();
try
{
string sUserID = ui.GetSessionUserID();
string sStepHTML = "";
string sErr = "";
string sSQL = "";
string sNewStepID = "";
if (!ui.IsGUID(sTaskID))
throw new Exception("Unable to add step. Invalid or missing Task ID. [" + sTaskID + "]" + sErr);
//now, the sItem variable may have a function name (if it's a new command)
//or it may have a guid (if it's from the clipboard)
//so, if it's a guid after stripping off the prefix, it's from the clipboard
//the function has a fn_ or clip_ prefix on it from the HTML. Strip it off.
//FIX... test the string to see if it BEGINS with fn_ or clip_
//IF SO... cut off the beginning... NOT a replace operation.
if (sItem.StartsWith("fn_")) sItem = sItem.Remove(0, 3);
if (sItem.StartsWith("clip_")) sItem = sItem.Remove(0, 5);
//NOTE: !! yes we are adding the step with an order of -1
//the update event on the client does not know the index at which it was dropped.
//so, we have to insert it first to get the HTML... but the very next step
//will serialize and update the entire sortable...
//immediately replacing this -1 with the correct position
if (ui.IsGUID(sItem))
{
sNewStepID = sItem;
//copy from the clipboard (using the root_step_id to get ALL associated steps)
sSQL = "insert into task_step (step_id, task_id, codeblock_name, step_order, step_desc," +
" commented, locked, output_parse_type, output_row_delimiter, output_column_delimiter," +
" function_name, function_xml, variable_xml)" +
" select step_id, '" + sTaskID + "'," +
" case when codeblock_name is null then '" + sCodeblockName + "' else codeblock_name end," +
"-1,step_desc," +
"0,0,output_parse_type,output_row_delimiter,output_column_delimiter," +
"function_name,function_xml,variable_xml" +
" from task_step_clipboard" +
" where user_id = '" + sUserID + "'" +
" and root_step_id = '" + sItem + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to add step." + sErr);
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, sItem,
"Added Command from Clipboard to Codeblock:" + sCodeblockName);
}
else
{
//add a new command
sNewStepID = ui.NewGUID();
//NOTE: !! yes we are doing some command specific logic here.
//Certain commands have different 'default' values for delimiters, etc.
//sOPM: 0=none, 1=delimited, 2=parsed
string sOPM = "0";
switch (sItem)
{
case "sql_exec":
sOPM = "1";
break;
case "win_cmd":
sOPM = "1";
break;
case "dos_cmd":
sOPM = "2";
break;
case "cmd_line":
sOPM = "2";
break;
case "http":
sOPM = "2";
break;
case "parse_text":
sOPM = "2";
break;
case "read_file":
sOPM = "2";
break;
}
sSQL = "insert into task_step (step_id, task_id, codeblock_name, step_order," +
" commented, locked, output_parse_type, output_row_delimiter, output_column_delimiter," +
" function_name, function_xml)" +
" select '" + sNewStepID + "'," +
"'" + sTaskID + "'," +
(string.IsNullOrEmpty(sCodeblockName) ? "NULL" : "'" + sCodeblockName + "'") + "," +
"-1," +
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs
示例9: wmCopyTask
public string wmCopyTask(string sCopyTaskID, string sTaskCode, string sTaskName)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = null;
// checks that cant be done on the client side
// is the name unique?
string sTaskNameInUse = "";
if (!dc.sqlGetSingleString(ref sTaskNameInUse, "select task_id from task where task_name = '" + sTaskName.Replace("'", "''") + "' limit 1", ref sErr))
{
throw new Exception(sErr);
}
else
{
if (!string.IsNullOrEmpty(sTaskNameInUse))
{
return "Task Name [" + sTaskName + "] already in use. Please choose another name.";
}
}
// checks that cant be done on the client side
// is the name unique?
string sTaskCodeInUse = "";
if (!dc.sqlGetSingleString(ref sTaskCodeInUse, "select task_id from task where task_code = '" + sTaskCode.Replace("'", "''") + "' limit 1", ref sErr))
{
throw new Exception(sErr);
}
else
{
if (!string.IsNullOrEmpty(sTaskCodeInUse))
{
return "Task Code [" + sTaskCode + "] already in use. Please choose another code.";
}
}
string sNewTaskGUID = CopyTask(0, sCopyTaskID, sTaskName.Replace("'", "''"), sTaskCode.Replace("'", "''"));
if (!string.IsNullOrEmpty(sNewTaskGUID))
{
ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskGUID, sTaskName, "Copied from " + sCopyTaskID);
}
// success, return the new task_id
return sNewTaskGUID;
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:46,代码来源:taskMethods.asmx.cs
示例10: 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
//{
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:cloudAccountEdit.aspx.cs
示例11: wmApproveTask
public string wmApproveTask(string sTaskID, string sMakeDefault)
{
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 = "";
//check to see if this is the first task to be approved.
//if it is, we will make it default.
sSQL = "select count(*) from task" +
" where original_task_id = " +
" (select original_task_id from task where task_id = '" + sTaskID + "')" +
" and task_status = 'Approved'";
int iCount = 0;
if (!dc.sqlGetSingleInteger(ref iCount, sSQL, ref sErr))
{
throw new Exception("Unable to count Tasks in this family.." + sErr);
}
if (iCount == 0)
sMakeDefault = "1";
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
//flag all the other tasks as not default if this one is meant to be
if (sMakeDefault == "1")
{
sSQL = "update task set" +
" default_version = 0" +
" where original_task_id =" +
" (select original_task_id from (select original_task_id from task where task_id = '" + sTaskID + "') as x)";
oTrans.Command.CommandText = sSQL;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception("Unable to update task [" + sTaskID + "]." + sErr);
}
sSQL = "update task set" +
" task_status = 'Approved'," +
" default_version = 1" +
" where task_id = '" + sTaskID + "';";
}
else
{
sSQL = "update task set" +
" task_status = 'Approved'" +
" where task_id = '" + sTaskID + "'";
}
oTrans.Command.CommandText = sSQL;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception("Unable to update task [" + sTaskID + "]." + sErr);
}
oTrans.Commit();
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, "Status", "Development", "Approved");
if (sMakeDefault == "1")
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, "Default", "Set as Default Version.");
}
else
{
throw new Exception("Unable to update task. Missing or invalid task id. [" + sTaskID + "]");
}
}
catch (Exception ex)
{
throw ex;
}
return "";
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:82,代码来源:taskMethods.asmx.cs
示例12: wmDeleteTaskParam
public string wmDeleteTaskParam(string sType, string sID, string sParamID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
string sErr = "";
string sSQL = "";
string sTable = "";
if (sType == "ecosystem")
sTable = "ecosystem";
else if (sType == "task")
sTable = "task";
if (!string.IsNullOrEmpty(sParamID) && ui.IsGUID(sID))
{
// need the name and values for logging
string sXML = "";
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 xName = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/name");
string sName = (xName == null ? "" : xName.Value);
XElement xValues = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/values");
string sValues = (xValues == null ? "" : xValues.ToString());
// add security log
ui.WriteObjectDeleteLog(Globals.acObjectTypes.Parameter, "", sID, "");
if (sType == "task") { ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sID, "Deleted Parameter:[" + sName + "]", sValues); };
if (sType == "ecosystem") { ui.WriteObjectChangeLog(Globals.acObjectTypes.Ecosystem, sID, "Deleted Parameter:[" + sName + "]", sValues); };
}
//do the whack
ft.RemoveNodeFromXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", "//parameter[@id = \"" + sParamID + "\"]");
return "";
}
else
{
throw new Exception("Invalid or missing Task or Parameter ID.");
}
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:55,代码来源:taskMethods.asmx.cs
示例13: wmExportTasks
public string wmExportTasks(string sTaskArray)
{
acUI.acUI ui = new acUI.acUI();
ImportExport.ImportExportClass ie = new ImportExport.ImportExportClass();
string sErr = "";
//pretty much just call the ImportExport function
try
{
//what are we gonna call the final file?
string sUserID = ui.GetSessionUserID();
string sFileName = sUserID + "_backup";
string sPath = Server.MapPath("~/temp/");
if (sTaskArray.Length < 36)
return "";
sTaskArray = ui.QuoteUp(sTaskArray);
if (!ie.doBatchTaskExport(sPath, sTaskArray, sFileName, ref sErr))
{
throw new Exception("Unable to export Tasks." + sErr);
}
if (sErr == "")
return sFileName + ".zip";
else
return sErr;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:34,代码来源:taskMethods.asmx.cs
示例14: 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)
{
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs
示例15: 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 "";
}
开发者ID:remotesyssupport,项目名称:cato,代码行数:94,代码来源:taskMethods.asmx.cs
示例16: wmToggleStep
public void wmToggleStep(string sS
|
请发表评论