本文整理汇总了C#中acUI.acUI.NewGUID方法的典型用法代码示例。如果您正苦于以下问题:C# acUI.acUI.NewGUID方法的具体用法?C# acUI.acUI.NewGUID怎么用?C# acUI.acUI.NewGUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类acUI.acUI
的用法示例。
在下文中一共展示了acUI.acUI.NewGUID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyTask
private string CopyTask(int iMode, string sSourceTaskID, string sNewTaskName, string sNewTaskCode)
{
//iMode 0=new task, 1=new major version, 2=new minor version
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sSQL = "";
string sNewTaskID = ui.NewGUID();
int iIsDefault = 0;
string sTaskName = "";
double dVersion = 1.000;
double dMaxVer = 0.000;
string sOTID = "";
//do it all in a transaction
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
//figure out the new name and selected version
oTrans.Command.CommandText = "select task_name, version, original_task_id from task where task_id = '" + sSourceTaskID + "'";
DataRow dr = null;
if (!oTrans.ExecGetDataRow(ref dr, ref sErr))
throw new Exception("Unable to find task for ID [" + sSourceTaskID + "]." + sErr);
sTaskName = dr["task_name"].ToString();
dVersion = Convert.ToDouble(dr["version"]);
sOTID = dr["original_task_id"].ToString();
//figure out the new version
switch (iMode)
{
case 0:
sTaskName = sNewTaskName;
iIsDefault = 1;
dVersion = 1.000;
sOTID = sNewTaskID;
break;
case 1:
//gotta get the highest version
sSQL = "select max(version) from task where task_id = '" + sOTID + "'";
dc.sqlGetSingleDouble(ref dMaxVer, sSQL, ref sErr);
if (sErr != "")
{
oTrans.RollBack();
throw new Exception(sErr);
}
dVersion = dMaxVer + 1;
break;
case 2:
sSQL = "select max(version) from task where task_id = '" + sOTID + "'" +
" and cast(version as unsigned) = " + Convert.ToInt32(dVersion);
dc.sqlGetSingleDouble(ref dMaxVer, sSQL, ref sErr);
if (sErr != "")
{
oTrans.RollBack();
throw new Exception(sErr);
}
dVersion = dMaxVer + 0.001;
break;
default: //a iMode is required
throw new Exception("A mode required for this copy operation." + sErr);
}
//if we are versioning, AND there are not yet any 'Approved' versions,
//we set this new version to be the default
//(that way it's the one that you get taken to when you pick it from a list)
if (iMode > 0)
{
sSQL = "select case when count(*) = 0 then 1 else 0 end" +
" from task where original_task_id = '" + sOTID + "'" +
" and task_status = 'Approved'";
dc.sqlGetSingleInteger(ref iIsDefault, sSQL, ref sErr);
if (sErr != "")
{
oTrans.RollBack();
throw new Exception(sErr);
}
}
//start copying
oTrans.Command.CommandText = "create temporary table _copy_task" +
" select * from task where task_id = '" + sSourceTaskID + "'";
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception(sErr);
//update the task_id
oTrans.Command.CommandText = "update _copy_task set" +
" task_id = '" + sNewTaskID + "'," +
" original_task_id = '" + sOTID + "'," +
" version = '" + dVersion + "'," +
" task_name = '" + sTaskName + "'," +
" default_version = " + iIsDefault.ToString() + "," +
" task_status = 'Development'," +
//.........这里部分代码省略.........
示例2: wmCopyStepToClipboard
public void wmCopyStepToClipboard(string sStepID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
try
{
if (ui.IsGUID(sStepID))
{
// should also do this whole thing in a transaction.
string sUserID = ui.GetSessionUserID();
string sErr = "";
//stuff gets new ids when copied into the clpboard.
//what way when adding, we don't have to loop
//(yes, I know we have to loop here, but adding is already a long process
//... so we can better afford to do it here than there.)
string sNewStepID = ui.NewGUID();
//it's a bit hokey, but if a step already exists in the clipboard,
//and we are copying that step again,
//ALWAYS remove the old one.
//we don't want to end up with lots of confusing copies
string sSQL = "delete from task_step_clipboard" +
" where user_id = '" + sUserID + "'" +
" and src_step_id = '" + sStepID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to clean clipboard." + sErr);
sSQL = " insert into task_step_clipboard" +
" (user_id, clip_dt, src_step_id, root_step_id, step_id, function_name, function_xml, step_desc," +
" output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml)" +
" select '" + sUserID + "', now(), step_id, '" + sNewStepID + "', '" + sNewStepID + "'," +
" function_name, function_xml, step_desc," +
" output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml" +
" from task_step" +
" where step_id = '" + sStepID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to copy step [" + sStepID + "]." + sErr);
//now, if the step we just copied has embedded steps,
//we need to get them too, but stick them in the clipboard table
//in a hidden fashion. (So they are preserved there, but not visible in the list.)
//we are doing it in a recursive call since the nested steps may themselves have nested steps.
AlsoCopyEmbeddedStepsToClipboard(sUserID, sStepID, sNewStepID, sNewStepID, ref sErr);
return;
}
else
{
throw new Exception("Unable to copy step. Missing or invalid step_id.");
}
}
catch (Exception ex)
{
throw ex;
}
}
示例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: AlsoCopyEmbeddedStepsToClipboard
private void AlsoCopyEmbeddedStepsToClipboard(string sUserID, string sSourceStepID, string sRootStepID, string sNewParentStepID, ref string sErr)
{
dataAccess dc = new dataAccess();
FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();
acUI.acUI ui = new acUI.acUI();
//get all the steps that have the calling stepid as a parent (codeblock)
string sSQL = "select step_id" +
" from task_step" +
" where codeblock_name = '" + sSourceStepID + "'";
DataTable dt = new DataTable();
if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
throw new Exception(sErr);
foreach (DataRow dr in dt.Rows)
{
string sThisStepID = dr["step_id"].ToString();
string sThisNewID = ui.NewGUID();
//put them in the table
sSQL = "delete from task_step_clipboard" +
" where user_id = '" + sUserID + "'" +
" and src_step_id = '" + sThisStepID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to clean embedded steps of [" + sSourceStepID + "]." + sErr);
sSQL = " insert into task_step_clipboard" +
" (user_id, clip_dt, src_step_id, root_step_id, step_id, function_name, function_xml, step_desc," +
" output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml, codeblock_name)" +
" select '" + sUserID + "', now(), step_id, '" + sRootStepID + "', '" + sThisNewID + "'," +
" function_name, function_xml, step_desc," +
" output_parse_type, output_row_delimiter, output_column_delimiter, variable_xml, '" + sNewParentStepID + "'" +
" from task_step" +
" where step_id = '" + sThisStepID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to copy embedded steps of [" + sSourceStepID + "]." + sErr);
//we need to update the "action" XML of the parent too...
/*OK here's the deal..I'm out of time
This should not be hardcoded, it should be smart enough to find an XML node with a specific
value and update that node.
I just don't know enought about xpath to figure it out, and don't have time to do it before
I gotta start chilling at tmo.
So, I've hardcoded it to the known cases so it will work.
Add a new dynamic command type that has embedded steps, and this will probably no longer work.
*/
ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
" and step_id = '" + sNewParentStepID + "'", "//action[text() = '" + sThisStepID + "']", sThisNewID);
ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
" and step_id = '" + sNewParentStepID + "'", "//else[text() = '" + sThisStepID + "']", sThisNewID);
ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
" and step_id = '" + sNewParentStepID + "'", "//positive_action[text() = '" + sThisStepID + "']", sThisNewID);
ft.SetNodeValueinXMLColumn("task_step_clipboard", "function_xml", "user_id = '" + sUserID + "'" +
" and step_id = '" + sNewParentStepID + "'", "//negative_action[text() = '" + sThisStepID + "']", sThisNewID);
//END OF HARDCODED HACK
// and check this one for children too
AlsoCopyEmbeddedStepsToClipboard(sUserID, sThisStepID, sRootStepID, sThisNewID, ref sErr);
}
}
示例5: SaveCloud
public static string SaveCloud(string sMode, string sCloudID, string sCloudName, string sProvider, string sAPIUrl)
{
// for logging
string sOriginalName = null;
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = null;
//if we are editing get the original values
if (sMode == "edit")
{
}
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
// update the user fields.
if (sMode == "edit")
{
sSql = "select cloud_name from clouds " +
"where cloud_id = '" + sCloudID + "'";
if (!dc.sqlGetSingleString(ref sOriginalName, sSql, ref sErr))
throw new Exception("Error getting original cloud name:" + sErr);
sSql = "update clouds set" +
" cloud_name = '" + sCloudName + "'," +
" provider = '" + sProvider + "'," +
" api_url = '" + sAPIUrl + "'" +
" where cloud_id = '" + sCloudID + "'";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception("Error updating cloud: " + sErr);
ui.WriteObjectChangeLog(Globals.acObjectTypes.Cloud, sCloudID, sCloudName, sOriginalName, sCloudName);}
else
{
sCloudID = ui.NewGUID();
sSql = "insert into clouds (cloud_id, cloud_name, provider, api_url)" +
" values ('" + sCloudID + "'," +
"'" + sCloudName + "'," +
"'" + sProvider + "'," +
"'" + sAPIUrl + "')";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception("Error creating cloud: " + sErr);
ui.WriteObjectAddLog(Globals.acObjectTypes.Cloud, sCloudID, sCloudName, "Cloud Created");
}
oTrans.Commit();
//update the cloud providers class in the session
CloudProviders cp = ui.GetCloudProviders();
cp[sProvider].RefreshClouds();
ui.UpdateCloudProviders(cp);
}
catch (Exception ex)
{
throw new Exception("Error: General Exception: " + ex.Message);
}
// no errors to here, so return an empty string
return "{'cloud_id':'" + sCloudID + "'}";
}
示例6: 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++;
}
//.........这里部分代码省略.........
示例7: SaveCredential
public static string SaveCredential(object[] oAsset)
{
// we are passing in 16 elements, if we have 16 go
if (oAsset.Length != 8) return "Incorrect list of attributes:" + oAsset.Length.ToString();
string sCredentialID = oAsset[0].ToString();
string sCredentialName = oAsset[1].ToString().Replace("'", "''");
string sUserName = oAsset[2].ToString().Replace("'", "''");
string sCredentialDesc = oAsset[3].ToString().Replace("'", "''");
string sPassword = oAsset[4].ToString();
string sDomain = oAsset[5].ToString();
string sMode = oAsset[6].ToString();
string sPrivilegedPassword = oAsset[7].ToString();
// for logging
string sOriginalUserName = null;
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = null;
//if we are editing get the original values
if (sMode == "edit")
{
sSql = "select username from asset_credential " +
"where credential_id = '" + sCredentialID + "'";
if (!dc.sqlGetSingleString(ref sOriginalUserName, sSql, ref sErr))
{
throw new Exception(sErr);
}
}
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
// update the user fields.
if (sMode == "edit")
{
// only update the passwword if it has changed
string sNewPassword = "";
if (sPassword != "($%#[email protected]!&")
{
sNewPassword = ",password = '" + dc.EnCrypt(sPassword) + "'";
}
// bugzilla 1260
// same for privileged_password
string sPriviledgedPasswordUpdate = null;
if (sPrivilegedPassword == "($%#[email protected]!&")
{
// password has not been touched
sPriviledgedPasswordUpdate = "";
}
else
{
// updated password
sPriviledgedPasswordUpdate = ",privileged_password = '" + dc.EnCrypt(sPrivilegedPassword) + "'";
}
sSql = "update asset_credential set" +
" credential_name = '" + sCredentialName + "'," +
" username = '" + sUserName + "'," +
" domain = '" + sDomain.Replace("'", "''") + "'," +
" shared_cred_desc = '" + sCredentialDesc + "'" +
sNewPassword +
sPriviledgedPasswordUpdate +
" where credential_id = '" + sCredentialID + "'";
}
else
{
// if the priviledged password is empty just set it to null
string sPrivilegedPasswordUpdate = "NULL";
if (sPrivilegedPassword.Length != 0)
{
sPrivilegedPasswordUpdate = "'" + dc.EnCrypt(sPrivilegedPassword) + "'";
};
sSql = "insert into asset_credential (credential_id, credential_name, username, password, domain, shared_cred_desc, shared_or_local, privileged_password)" +
" values (" + "'" + ui.NewGUID() + "'," +
"'" + sCredentialName.Replace("'", "''") + "'," +
"'" + sUserName.Replace("'", "''") + "'," +
"'" + dc.EnCrypt(sPassword) + "'," +
"'" + sDomain.Replace("'", "''") + "'," +
"'" + sCredentialDesc.Replace("'", "''") + "'," +
"'0'," + sPrivilegedPasswordUpdate + ")";
}
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
{
if (sErr == "key_violation")
throw new Exception("A Credential with that name already exists. Please select another name.");
else
throw new Exception(sErr);
}
oTrans.Commit();
//.........这里部分代码省略.........
示例8: SaveAccount
public static string SaveAccount(string sMode, string sAccountID, string sAccountName, string sAccountNumber, string sProvider,
string sLoginID, string sLoginPassword, string sLoginPasswordConfirm, string sIsDefault, string sAutoManageSecurity)
{
// for logging
string sOriginalName = "";
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = "";
string sErr = "";
//if we are editing get the original values
if (sMode == "edit")
{
}
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
// update the user fields.
if (sMode == "edit")
{
sSql = "select account_name from cloud_account " +
"where account_id = '" + sAccountID + "'";
if (!dc.sqlGetSingleString(ref sOriginalName, sSql, ref sErr))
throw new Exception("Error getting original account name:" + sErr);
// only update the passwword if it has changed
string sNewPassword = "";
if (sLoginPassword != "($%#[email protected]!&")
{
sNewPassword = ", login_password = '" + dc.EnCrypt(sLoginPassword) + "'";
}
sSql = "update cloud_account set" +
" account_name = '" + sAccountName + "'," +
" account_number = '" + sAccountNumber + "'," +
" provider = '" + sProvider + "'," +
" is_default = '" + sIsDefault + "'," +
" auto_manage_security = '" + sAutoManageSecurity + "'," +
" login_id = '" + sLoginID + "'" +
sNewPassword +
" where account_id = '" + sAccountID + "'";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception("Error updating account: " + sErr);
ui.WriteObjectChangeLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, sOriginalName, sAccountName);}
else
{
//now, for some reason we were having issues with the initial startup of apache
//not able to perform the very first database hit.
//this line serves as an inital db hit, but we aren't trapping it or showing the error
dc.TestDBConnection(ref sErr);
//if there are no rows yet, make this one the default even if the box isn't checked.
if (sIsDefault == "0")
{
int iExists = -1;
sSql = "select count(*) as cnt from cloud_account";
if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
{
System.Threading.Thread.Sleep(300);
if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
{
System.Threading.Thread.Sleep(300);
if (!dc.sqlGetSingleInteger(ref iExists, sSql, ref sErr))
throw new Exception("Unable to count Cloud Accounts: " + sErr);
}
}
if (iExists == 0)
sIsDefault = "1";
}
sAccountID = ui.NewGUID();
sSql = "insert into cloud_account (account_id, account_name, account_number, provider, is_default, login_id, login_password, auto_manage_security)" +
" values ('" + sAccountID + "'," +
"'" + sAccountName + "'," +
"'" + sAccountNumber + "'," +
"'" + sProvider + "'," +
"'" + sIsDefault + "'," +
"'" + sLoginID + "'," +
"'" + dc.EnCrypt(sLoginPassword) + "'," +
"'" + sAutoManageSecurity + "')";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
throw new Exception("Error creating account: " + sErr);
ui.WriteObjectAddLog(Globals.acObjectTypes.CloudAccount, sAccountID, sAccountName, "Account Created");
}
//if "default" was selected, unset all the others
if (dc.IsTrue(sIsDefault))
{
oTrans.Command.CommandText = "update cloud_account set is_default = 0 where account_id <> '" + sAccountID + "'";
//.........这里部分代码省略.........
示例9: DrawRegistryNode
private string DrawRegistryNode(XElement xeNode, string sXPath)
{
acUI.acUI ui = new acUI.acUI();
string sHTML = "";
string sNodeLabel = xeNode.Name.ToString();
IDictionary<string, int> dictNodes = new Dictionary<string, int>();
//if a node has children we'll draw it with some hierarchical styling.
//AND ALSO if it's editable, even if it has no children, we'll still draw it as a container.
if (xeNode.HasElements)
{
string sGroupID = ui.NewGUID();
sHTML += "<div class=\"ui-widget-content ui-corner-bottom registry_section\" id=\"" + sGroupID + "\">"; //this section
sHTML += " <div class=\"ui-state-default registry_section_header\" xpath=\"" + sXPath + "\">"; //header
sHTML += " <div class=\"registry_section_header_title editable\" id=\"" + ui.NewGUID() + "\">" + sNodeLabel + "</div>";
sHTML += "<div class=\"registry_section_header_icons\">"; //step header icons
sHTML += "<span class=\"registry_node_add_btn pointer\"" +
" xpath=\"" + sXPath + "\">" +
"<img style=\"width:10px; height:10px;\" src=\"../images/icons/edit_add.png\"" +
" alt=\"\" title=\"Add another...\" /></span>";
sHTML += "<span class=\"registry_node_remove_btn pointer\" xpath_to_delete=\"" + sXPath + "\" id_to_remove=\"" + sGroupID + "\">";
sHTML += "<img style=\"width:10px; height:10px;\" src=\"../images/icons/fileclose.png\"" +
" alt=\"\" title=\"Remove\" /></span>";
sHTML += "</div>"; //end step header icons
sHTML += " </div>"; //end header
foreach (XElement xeChildNode in xeNode.Nodes())
{
string sChildNodeName = xeChildNode.Name.ToString();
string sChildXPath = sXPath + "/" + xeChildNode.Name.ToString();
//here's the magic... are there any children nodes here with the SAME NAME?
//if so they need an index on the xpath
if (xeNode.XPathSelectElements(sChildNodeName).Count() > 1)
{
//since the document won't necessarily be in perfect order,
//we need to keep track of same named nodes and their indexes.
//so, stick each array node up in a lookup table.
//is it already in my lookup table?
int iLastIndex = 0;
dictNodes.TryGetValue(sChildNodeName, out iLastIndex);
if (iLastIndex == 0)
{
//not there, add it
iLastIndex = 1;
dictNodes.Add(sChildNodeName, iLastIndex);
}
else
{
//there, increment it and set it
iLastIndex++;
dictNodes[sChildNodeName] = iLastIndex;
}
sChildXPath = sChildXPath + "[" + iLastIndex.ToString() + "]";
}
sHTML += DrawRegistryNode(xeChildNode, sChildXPath);
}
sHTML += "</div>"; //end section
}
else
{
sHTML += DrawRegistryItem(xeNode, sXPath);
}
return sHTML;
}
示例10: wmCreateEcotemplate
public string wmCreateEcotemplate(string sName, string sDescription)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSQL = null;
string sErr = null;
try
{
sSQL = "select ecotemplate_name from ecotemplate where ecotemplate_name = '" + sName + "'";
string sExists = "";
if (!dc.sqlGetSingleString(ref sExists, sSQL, ref sErr))
{
throw new Exception(sErr);
}
else
{
if (!string.IsNullOrEmpty(sExists))
{
return "Eco Template exists - choose another name.";
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
try
{
string sNewID = ui.NewGUID();
sSQL = "insert into ecotemplate (ecotemplate_id, ecotemplate_name, ecotemplate_desc)" +
" values ('" + sNewID + "'," +
" '" + sName + "'," +
(string.IsNullOrEmpty(sDescription) ? " null" : " '" + sDescription + "'") + ")";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception(sErr);
ui.WriteObjectAddLog(acObjectTypes.Ecosystem, sNewID, sName, "Ecotemplate created.");
return sNewID;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
示例11: DrawRegistryItem
private string DrawRegistryItem(XElement xe, string sXPath)
{
acUI.acUI ui = new acUI.acUI();
string sHTML = "";
string sEncrypt = "false";
if (xe.Attribute("encrypt") != null)
sEncrypt = xe.Attribute("encrypt").Value;
//if the node value is empty or encrypted, we still need something to click on to edit the value
string sNodeValue = (sEncrypt == "true" ? "(********)" : (xe.Value == "" ? "(empty)" : xe.Value));
string sNodeLabel = xe.Name.ToString();
string sGroupID = ui.NewGUID();
sHTML += "<div class=\"ui-widget-content ui-corner-tl ui-corner-bl registry_node\" xpath=\"" + sXPath + "\" id=\"" + sGroupID + "\">";
sHTML += "<span class=\"registry_node_label editable\" id=\"" + ui.NewGUID() + "\">" + sNodeLabel +
"</span> : <span class=\"registry_node_value editable\" id=\"" + ui.NewGUID() + "\" encrypt=\"" + sEncrypt + "\">" + sNodeValue + "</span>" + Environment.NewLine;
sHTML += "<div class=\"registry_section_header_icons\">"; //step header icons
sHTML += "<span class=\"registry_node_add_btn pointer\"" +
" xpath=\"" + sXPath + "\">" +
"<img style=\"width:10px; height:10px;\" src=\"../images/icons/edit_add.png\"" +
" alt=\"\" title=\"Add another...\" /></span>";
sHTML += "<span class=\"registry_node_remove_btn pointer\" xpath_to_delete=\"" + sXPath + "\" id_to_remove=\"" + sGroupID + "\">";
sHTML += "<img style=\"width:10px; height:10px;\" src=\"../images/icons/fileclose.png\"" +
" alt=\"\" title=\"Remove\" /></span>";
sHTML += "</div>";
sHTML += "</div>";
return sHTML;
}
示例12: wmAddEcotemplateAction
public void wmAddEcotemplateAction(string sEcoTemplateID, string sActionName, string sOTID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
if (string.IsNullOrEmpty(sEcoTemplateID) || string.IsNullOrEmpty(sActionName) || string.IsNullOrEmpty(sOTID))
throw new Exception("Missing or invalid EcoTemplate ID, Action Name or Task.");
string sSQL = "insert into ecotemplate_action " +
" (action_id, action_name, ecotemplate_id, original_task_id)" +
" values (" +
" '" + ui.NewGUID() + "'," +
" '" + sActionName + "'," +
" '" + sEcoTemplateID + "'," +
" '" + sOTID + "'" +
")";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
//don't throw an error if its just a PK collision. That just means it's already there.
if (sErr.IndexOf("Duplicate entry") == 0)
throw new Exception(sErr);
}
ui.WriteObjectChangeLog(acObjectTypes.EcoTemplate, sEcoTemplateID, "", "Action Added : [" + sActionName + "]");
return;
}
示例13: 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);
}
}
示例14: 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," +
//.........这里部分代码省略.........
示例15: SaveAsset
public static string SaveAsset(object[] oAsset)
{
// check the # of elements in the array
if (oAsset.Length != 19) return "Incorrect number of Asset Properties:" + oAsset.Length.ToString();
string sAssetID = oAsset[0].ToString();
string sAssetName = oAsset[1].ToString().Replace("'", "''");
string sDbName = oAsset[2].ToString().Replace("'", "''");
string sPort = oAsset[3].ToString();
string sConnectionType = oAsset[4].ToString();
string sIsConnection = "0"; // oAsset[5].ToString();
string sAddress = oAsset[5].ToString().Replace("'", "''");
// mode is edit or add
string sMode = oAsset[6].ToString();
string sCredentialID = oAsset[7].ToString();
string sCredUsername = oAsset[8].ToString().Replace("'", "''");
string sCredPassword = oAsset[9].ToString().Replace("'", "''");
string sShared = oAsset[10].ToString();
string sCredentialName = oAsset[11].ToString().Replace("'", "''");
string sCredentialDescr = oAsset[12].ToString().Replace("'", "''");
string sDomain = oAsset[13].ToString().Replace("'", "''");
string sCredentialType = oAsset[14].ToString();
string sAssetStatus = oAsset[15].ToString();
string sPrivilegedPassword = oAsset[16].ToString();
string sTagArray = oAsset[17].ToString();
string sConnString = oAsset[18].ToString().Replace("'", "''");
// for logging
string sOriginalAssetName = "";
string sOriginalPort = "";
string sOriginalDbName = "";
string sOriginalAddress = "";
string sOriginalConnectionType = "";
string sOriginalUserName = "";
string sOriginalConnString = "";
string sOriginalCredentialID = "";
string sOriginalAssetStatus = "";
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = null;
//if we are editing get the original values
//this is getting original values for logging purposes
if (sMode == "edit")
{
DataRow dr = null;
sSql = "select a.asset_name, a.asset_status, a.port, a.db_name, a.address, a.db_name, a.connection_type, a.conn_string, ac.username, a.credential_id," +
" case when a.is_connection_system = '1' then 'Yes' else 'No' end as is_connection_system " +
" 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)
{
sOriginalAssetName = dr["asset_name"].ToString();
sOriginalPort = (object.ReferenceEquals(dr["port"], DBNull.Value) ? "" : dr["port"].ToString());
sOriginalDbName = (object.ReferenceEquals(dr["db_name"], DBNull.Value) ? "" : dr["db_name"].ToString());
sOriginalAddress = (object.ReferenceEquals(dr["address"], DBNull.Value) ? "" : dr["address"].ToString());
sOriginalConnectionType = (object.ReferenceEquals(dr["connection_type"], DBNull.Value) ? "" : dr["connection_type"].ToString());
sOriginalUserName = (object.ReferenceEquals(dr["username"], DBNull.Value) ? "" : dr["username"].ToString());
sOriginalConnString = (object.ReferenceEquals(dr["conn_string"], DBNull.Value) ? "" : dr["conn_string"].ToString());
sOriginalCredentialID = (object.ReferenceEquals(dr["credential_id"], DBNull.Value) ? "" : dr["credential_id"].ToString());
sOriginalAssetStatus = dr["asset_status"].ToString();
}
}
}
//NOTE NOTE NOTE!
//the following is a catch 22.
//if we're adding a new asset, we will need to figure out the credential first so we can save the credential id on the asset
//but if it's a new local credential, it gets the asset id as it's name.
//so.........
//if it's a new asset, go ahead and get the new guid for it here so the credential add will work.
if (sMode == "add")
sAssetID = ui.NewGUID();
//and move on...
// there are three CredentialType's
// 1) 'selected' = user selected a different credential, just save the credential_id
// 2) 'new' = user created a new shared or local credential
// 3) 'existing' = same credential, just update the username,description ad password
string sPriviledgedPasswordUpdate = null;
if (sCredentialType == "new")
{
if (sPrivilegedPassword.Length == 0)
sPriviledgedPasswordUpdate = "NULL";
else
sPriviledgedPasswordUpdate = "'" + dc.EnCrypt(sPrivilegedPassword) + "'";
//if it's a local credential, the credential_name is the asset_id.
//if it's shared, there will be a name.
//.........这里部分代码省略.........