本文整理汇总了C#中acUI.acUI.WriteObjectChangeLog方法的典型用法代码示例。如果您正苦于以下问题:C# acUI.acUI.WriteObjectChangeLog方法的具体用法?C# acUI.acUI.WriteObjectChangeLog怎么用?C# acUI.acUI.WriteObjectChangeLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类acUI.acUI
的用法示例。
在下文中一共展示了acUI.acUI.WriteObjectChangeLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: wmUpdateStep
//.........这里部分代码省略.........
{
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)
{
xFoundNode.Add(new XElement(sNode));
}
//now we should be good to stick the value on the final node.
XElement xNode = xRoot.XPathSelectElement(sXPath);
if (xNode == null)
throw new Exception("XML data for step [" + sStepID + "] does not contain '" + sXPath + "' node.");
xNode.SetValue(sValue);
//xRoot.Add(new XElement(sXPath, sValue));
//xRoot.SetElementValue(sXPath, sValue);
}
catch (Exception)
{
throw new Exception("Error Saving Step [" + sStepID + "]. Could not find and cannot create the [" + sXPath + "] property in the XML.");
}
}
sSQL = "update task_step set " +
" function_xml = '" + xDoc.ToString(SaveOptions.DisableFormatting).Replace("'", "''") + "'" +
" where step_id = '" + sStepID + "';";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
throw new Exception(sErr);
}
}
sSQL = "select task_id, codeblock_name, step_order from task_step where step_id = '" + sStepID + "'";
DataRow dr = null;
if (!dc.sqlGetDataRow(ref dr, sSQL, ref sErr))
throw new Exception(sErr);
if (dr != null)
{
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, dr["task_id"].ToString(), sFunction,
"Codeblock:" + dr["codeblock_name"].ToString() +
" Step Order:" + dr["step_order"].ToString() +
" Command Type:" + sFunction +
" Property:" + sXPath +
" New Value: " + sValue);
}
return "";
}
示例2: wmRemoveTaskAttributeGroup
public string wmRemoveTaskAttributeGroup(string sTaskID, string sGroupID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sSQL = "";
sSQL = "select laa.attribute_name from task_asset_attribute taa " +
"join lu_asset_attribute_value laav " +
"on taa.attribute_value_id = laav.attribute_value_id " +
"join lu_asset_attribute laa " +
"on laa.attribute_id = laav.attribute_id " +
"where attribute_group_id = '" + sGroupID + "'";
string sAttributeGroupName = "";
if (!dc.sqlGetSingleString(ref sAttributeGroupName, sSQL, ref sErr))
{
throw new Exception(sErr);
}
sSQL += "delete from task_asset_attribute" +
" where task_id = '" + sTaskID + "'" +
" and attribute_group_id = '" + sGroupID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
throw new Exception(sErr);
}
//From bugzilla 917 - not a huge fan of doing this on every change...
sSQL = "exec refresh_asset_task 'task','" + sTaskID + "';";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
throw new Exception(sErr);
}
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, "", "Attribute Group " + sAttributeGroupName + " Removed");
return "";
}
示例3: 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 "";
}
示例4: SaveAsset
//.........这里部分代码省略.........
// bugzilla 1126 if the password has not changed leave it as is.
string sPasswordUpdate = null;
if (sCredPassword == "($%#[email protected]!&")
// password has not been touched
sPasswordUpdate = "";
else
// updated password
sPasswordUpdate = ",password = '" + dc.EnCrypt(sCredPassword) + "'";
// bugzilla 1260
// same for privileged_password
if (sPrivilegedPassword == "($%#[email protected]!&")
// password has not been touched
sPriviledgedPasswordUpdate = "";
else
{
// updated password
// bugzilla 1352 priviledged password can be blank, so if it is, set it to null
if (sPrivilegedPassword.Length == 0)
sPriviledgedPasswordUpdate = ",privileged_password = null";
else
sPriviledgedPasswordUpdate = ",privileged_password = '" + dc.EnCrypt(sPrivilegedPassword) + "'";
}
sSql = "update asset_credential " +
"set username = '" + sCredUsername + "'" + sPasswordUpdate + sPriviledgedPasswordUpdate + ",domain = '" + sDomain + "'," +
"shared_or_local = '" + sShared + "',shared_cred_desc = '" + sCredentialDescr + "'" +
"where credential_id = " + sCredentialID;
if (!dc.sqlExecuteUpdate(sSql, ref sErr))
throw new Exception(sErr);
// add security log
ui.WriteObjectChangeLog(Globals.acObjectTypes.Asset, sAssetID, sAssetName.Trim().Replace("'", "''") + "Changed credential", sOriginalUserName, sCredUsername);
}
else
{
// user selected a shared credential
// remove the local credential if one exists
if (sOriginalCredentialID.Length > 0)
{
sSql = "delete from asset_credential where credential_id = '" + sOriginalCredentialID + "' and shared_or_local = '1'";
if (!dc.sqlExecuteUpdate(sSql, ref sErr))
throw new Exception(sErr);
// add security log
ui.WriteObjectDeleteLog(Globals.acObjectTypes.Asset, sAssetID, sAssetName.Trim().Replace("'", "''"), "Credential deleted" + sOriginalCredentialID + " " + sOriginalUserName);
}
sCredentialID = "'" + sCredentialID + "'";
}
// checks that cant be done on the client side
// is the name unique?
string sInuse = "";
if (sMode == "edit")
sSql = "select asset_id from asset where asset_name = '" + sAssetName.Trim() + "' and asset_id <> '" + sAssetID + "' limit 1";
else
sSql = "select asset_id from asset where asset_name = '" + sAssetName.Trim() + "' limit 1";
if (!dc.sqlGetSingleString(ref sInuse, sSql, ref sErr))
throw new Exception(sErr);
示例5: wmAddTaskAttribute
public string wmAddTaskAttribute(string sTaskID, string sGroupID, string sAttributeID, string sAttributeValueID)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sSQL = "";
//the group_id might be empty, in which case we need a new guid
if (string.IsNullOrEmpty(sGroupID))
{
sGroupID = ui.NewGUID();
}
sSQL += "insert into task_asset_attribute" +
" (task_id, attribute_group_id, attribute_value_id)" +
" values (" +
" '" + sTaskID + "'," +
" '" + sGroupID + "'," +
" '" + sAttributeValueID + "'" +
")";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
throw new Exception(sErr);
}
//From bugzilla 917 - not a huge fan of doing this on every change...
sSQL = "exec refresh_asset_task 'task','" + sTaskID + "';";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
{
throw new Exception(sErr);
}
// need the name of the attribute added for the log
sSQL = "select laa.attribute_name + ' :: ' + laav.attribute_value as [Attribute] from lu_asset_attribute_value laav " +
"join lu_asset_attribute laa " +
"on laav.attribute_id = laa.attribute_id " +
"where laav.attribute_value_id = '" + sAttributeValueID + "'";
string sAttributeName = "";
if (!dc.sqlGetSingleString(ref sAttributeName, sSQL, ref sErr))
{
throw new Exception(sErr);
}
ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sTaskID, "", "Attribute Value " + sAttributeName + " Added");
return sGroupID;
}
示例6: 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.");
}
}
示例7: SaveDomain
public static string SaveDomain(object[] oAsset)
{
// we are passing in 4 elements, if we have 16 go
if (oAsset.Length != 4) return "Incorrect list of attributes:" + oAsset.Length.ToString();
string sEditDomain = oAsset[0].ToString();
string sDomain = oAsset[1].ToString().Replace("'", "''");
string sAddress = oAsset[2].ToString().Replace("'", "''");
string sMode = oAsset[3].ToString();
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sSql = null;
string sErr = null;
// before updating or adding make sure the domain name is available
if (sEditDomain != sDomain)
{
try
{
sSql = "select ldap_domain from ldap_domain where ldap_domain = '" + sDomain + "'";
string sDomainExists = "";
if (!dc.sqlGetSingleString(ref sDomainExists, sSql, ref sErr))
{
throw new Exception(sErr);
}
else
{
if (!string.IsNullOrEmpty(sDomainExists))
{
return "Domain name exists, choose another name.";
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
try
{
dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);
// update the user fields.
if (sMode == "edit")
{
// if the domain name changed update all of the asset_credential's using this domain
if (sDomain != sEditDomain){
sSql = "update asset_credential set domain = '" + sDomain + "' where domain = '" + sEditDomain + "'";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception(sErr);
}
}
sSql = "update ldap_domain set ldap_domain = '" + sDomain + "'," + "address = '" + sAddress + "' where ldap_domain = '" + sEditDomain + "'";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception(sErr);
}
}
else
{
sSql = "insert into ldap_domain (ldap_domain,address)" +
" values ('" + sDomain + "'," +
"'" + sAddress + "')";
oTrans.Command.CommandText = sSql;
if (!oTrans.ExecUpdate(ref sErr))
{
throw new Exception(sErr);
}
}
oTrans.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
// add security log
if (sMode == "edit")
{
ui.WriteObjectChangeLog(Globals.acObjectTypes.Domain, sEditDomain, sEditDomain, sEditDomain, sDomain);
}
else
{
ui.WriteObjectAddLog(Globals.acObjectTypes.Domain, sDomain, sDomain, "Domain Created");
}
// no errors to here, so return an empty string
//.........这里部分代码省略.........
示例8: wmAddObjectTag
public void wmAddObjectTag(string sObjectID, string sObjectType, string sTagName)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sSQL = "";
int iObjectType = Int32.Parse(sObjectType);
//fail on missing values
if (iObjectType < 0) { throw new Exception("Invalid Object Type."); }
if (string.IsNullOrEmpty(sObjectID) || string.IsNullOrEmpty(sTagName))
throw new Exception("Missing or invalid Object ID or Tag Name.");
sSQL += "insert into object_tags" +
" (object_id, object_type, tag_name)" +
" values (" +
" '" + sObjectID + "'," +
" " + iObjectType.ToString() + "," +
" '" + sTagName + "'" +
")";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception(sErr);
//get the enum type from an integer value
acObjectTypes ot = (acObjectTypes)Enum.ToObject(typeof(acObjectTypes), iObjectType);
ui.WriteObjectChangeLog(ot, sObjectID, "", "Tag [" + sTagName + "] added.");
return;
}
示例9: 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 "";
}
示例10: wmSaveActionParameterXML
//.........这里部分代码省略.........
//note we don't care about dirty unencrypted values... they'll compare down below just fine.
//is it encrypted?
bool bEncrypted = false;
if (xTaskParam.Attribute("encrypt") != null)
bEncrypted = dc.IsTrue(xTaskParam.Attribute("encrypt").Value);
if (bEncrypted)
{
foreach (XElement xVal in xADValues.XPathSelectElements("value"))
{
if (xVal.HasAttributes) {
//a) is it an oev? unpackJSON it (that's just an obfuscation wrapper)
if (xVal.Attribute("oev") != null)
{
if (dc.IsTrue(xVal.Attribute("oev").Value))
{
xVal.Value = ui.unpackJSON(xVal.Value);
xVal.SetAttributeValue("oev", null);
}
}
//b) is it do_encrypt? (remove the attribute to keep the db clutter down)
if (xVal.Attribute("do_encrypt") != null)
{
xVal.Value = dc.EnCrypt(xVal.Value);
xVal.SetAttributeValue("do_encrypt", null);
}
}
}
}
//now that the encryption is sorted out,
// if the combined values of the parameter happens to match what's on the task
// we just remove it.
//we're doing combined because of lists (the whole list must match for it to be a dupe)
//it's easy to look at all the values in a node with the node.Value property.
//but we'll have to manually concatenate all the oev attributes
string sTaskVals = "";
string sDefVals = "";
if (bEncrypted)
{
// the task document already has the oev obfuscated
foreach (XAttribute xa in xTaskParamValues.Elements("value").Attributes("oev"))
{
sTaskVals += xa.Value;
}
//but the XML we just got from the client doesn't... it's in the value.
foreach (XElement xe in xADValues.Elements("value"))
{
sDefVals += ui.packJSON(xe.Value);
}
if (sTaskVals.Equals(sDefVals))
{
xDefault.Remove();
continue;
}
}
else
{
if (xTaskParamValues.Value.Equals(xADValues.Value))
{
xDefault.Remove();
continue;
}
}
}
//done
sOverrideXML = xADDoc.ToString(SaveOptions.DisableFormatting);
//FINALLY, we have an XML that represents only the differences we wanna save.
sSQL = "update ecotemplate_action set" +
" parameter_defaults = '" + sOverrideXML + "'" +
" where action_id = '" + sActionID + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception("Unable to update Eco Template Action [" + sActionID + "]." + sErr);
ui.WriteObjectChangeLog(Globals.acObjectTypes.EcoTemplate, sActionID, sActionID, "Action default parameters updated: [" + sOverrideXML + "]");
}
else
{
throw new Exception("Unable to update Eco Template Action. Missing or invalid Action ID.");
}
}
catch (Exception ex)
{
throw ex;
}
return;
}
示例11: 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;
}
示例12: wmRemoveObjectTag
public void wmRemoveObjectTag(string sObjectID, string sObjectType, string sTagName)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
string sSQL = "";
int iObjectType = Int32.Parse(sObjectType);
//fail on missing values
if (iObjectType < 0) { throw new Exception("Invalid Object Type."); }
if (string.IsNullOrEmpty(sObjectID) || string.IsNullOrEmpty(sTagName))
throw new Exception("Missing or invalid Object ID or Tag Name.");
sSQL += "delete from object_tags" +
" where" +
" object_id = '" + sObjectID + "'" +
" and" +
" tag_name = '" + sTagName + "'";
if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
throw new Exception(sErr);
//get the enum type from an integer value
acObjectTypes ot = (acObjectTypes)Enum.ToObject(typeof(acObjectTypes), iObjectType);
ui.WriteObjectChangeLog(ot, sObjectID, "", "Tag [" + sTagName + "] removed.");
return;
}
示例13: wmAddEcosystemObjects
public void wmAddEcosystemObjects(string sEcosystemID, string sCloudID, string sObjectType, string sObjectIDs)
{
dataAccess dc = new dataAccess();
acUI.acUI ui = new acUI.acUI();
string sErr = "";
if (string.IsNullOrEmpty(sEcosystemID) || string.IsNullOrEmpty(sObjectType) || string.IsNullOrEmpty(sObjectIDs))
throw new Exception("Missing or invalid Ecosystem ID, Cloud Object Type or Object ID.");
ArrayList aObjectIDs = new ArrayList(sObjectIDs.Split(','));
foreach (string sObjectID in aObjectIDs)
{
string sSQL = "insert into ecosystem_object " +
" (ecosystem_id, cloud_id, ecosystem_object_id, ecosystem_object_type, added_dt)" +
" values (" +
" '" + sEcosystemID + "'," +
" '" + sCloudID + "'," +
" '" + sObjectID + "'," +
" '" + sObjectType + "'," +
" now() " +
")";
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) {
// do nothing
}
else
throw new Exception(sErr);
}
}
ui.WriteObjectChangeLog(acObjectTypes.Ecosystem, sEcosystemID, "", "Objects Added : {" + sObjectIDs + "}");
return;
}
示例14: 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 + "'}";
}
示例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 "";
}