当前位置: 首页>>代码示例>>C#>>正文


C# dataAccess.IsTrue方法代码示例

本文整理汇总了C#中dataAccess.IsTrue方法的典型用法代码示例。如果您正苦于以下问题:C# dataAccess.IsTrue方法的具体用法?C# dataAccess.IsTrue怎么用?C# dataAccess.IsTrue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dataAccess的用法示例。


在下文中一共展示了dataAccess.IsTrue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadAccount

        public static string LoadAccount(string sID)
        {
            dataAccess dc = new dataAccess();
            string sSql = null;
            string sErr = null;

            string sAccountName = null;
            string sAccountNumber = null;
            string sProvider = null;
            string sIsDefault = null;
            string sAutoManage = null;
            string sLoginID = null;
            string sLoginPassword = null;

            sSql = "select account_id, account_name, account_number, provider, login_id, is_default, auto_manage_security" +
                " from cloud_account where account_id = '" + sID + "'";

            StringBuilder sb = new StringBuilder();
            DataRow dr = null;
            if (!dc.sqlGetDataRow(ref dr, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (dr != null)
                {
                    sAccountName = (object.ReferenceEquals(dr["account_name"], DBNull.Value) ? "" : dr["account_name"].ToString());
                    sAccountNumber = (object.ReferenceEquals(dr["account_number"], DBNull.Value) ? "" : dr["account_number"].ToString());
                    sProvider = (object.ReferenceEquals(dr["provider"], DBNull.Value) ? "" : dr["provider"].ToString());
                    sIsDefault = (object.ReferenceEquals(dr["is_default"], DBNull.Value) ? "0" : (dc.IsTrue(dr["is_default"].ToString()) ? "1" : "0"));
                    sAutoManage = (object.ReferenceEquals(dr["auto_manage_security"], DBNull.Value) ? "" : dr["auto_manage_security"].ToString());
                    sLoginID = (object.ReferenceEquals(dr["login_id"], DBNull.Value) ? "" : dr["login_id"].ToString());
                    sLoginPassword = "($%#[email protected]!&";

                    // Return the object as a JSON

                    sb.Append("{");
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAccountName", sAccountName);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAccountNumber", sAccountNumber);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sProvider", sProvider);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sIsDefault", sIsDefault);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sAutoManage", sAutoManage);
                    sb.AppendFormat("\"{0}\" : \"{1}\",", "sLoginID", sLoginID);
                    sb.AppendFormat("\"{0}\" : \"{1}\"", "sLoginPassword", sLoginPassword);
                    sb.Append("}");

                }
                else
                {
                    sb.Append("{}");
                }

            }

            return sb.ToString();
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:57,代码来源:cloudAccountEdit.aspx.cs

示例2: 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 + "'";
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:cloudAccountEdit.aspx.cs

示例3: 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

示例4: 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); };
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs

示例5: 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++;
                            }
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs

示例6: wmRerunTask

        public string wmRerunTask(int iInstanceID, string sClearLog)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (iInstanceID > 0 && ui.IsGUID(sUserID))
                {

                    string sInstance = "";
                    string sErr = "";
                    string sSQL = "";

                    if (dc.IsTrue(sClearLog))
                    {
                        sSQL = "delete from task_instance_log" +
                            " where task_instance = '" + iInstanceID.ToString() + "'";

                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                        {
                            throw new Exception("Unable to clear task instance log for [" + iInstanceID.ToString() + "]." + sErr);
                        }
                    }
                    sSQL = "update task_instance set task_status = 'Submitted'," +
                        " submitted_by = '" + sUserID + "'" +
                        " where task_instance = '" + iInstanceID.ToString() + "'";

                    if (!dc.sqlGetSingleString(ref sInstance, sSQL, ref sErr))
                    {
                        throw new Exception("Unable to rerun task instance [" + iInstanceID.ToString() + "]." + sErr);
                    }

                    return sInstance;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task instance [" + iInstanceID.ToString() + "]");
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:49,代码来源:taskMethods.asmx.cs

示例7: wmGetParameters

        public string wmGetParameters(string sType, string sID, bool bEditable, bool bSnipValues)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sErr = "";
                string sParameterXML = "";
                string sSQL = "";
                string sTable = "";

                if (sType == "ecosystem")
                    sTable = "ecosystem";
                else if (sType == "task")
                    sTable = "task";

                sSQL = "select parameter_xml from " + sTable + " where " + sType + "_id = '" + sID + "'";

                if (!dc.sqlGetSingleString(ref sParameterXML, sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

                if (sParameterXML != "")
                {
                    XDocument xDoc = XDocument.Parse(sParameterXML);
                    if (xDoc == null)
                        throw new Exception("Parameter XML data for " + sType + " [" + sID + "] is invalid.");

                    XElement xParams = xDoc.XPathSelectElement("/parameters");
                    if (xParams == null)
                        throw new Exception("Parameter XML data for " + sType + " [" + sID + "] does not contain 'parameters' root node.");

                    string sHTML = "";

                    foreach (XElement xParameter in xParams.XPathSelectElements("parameter"))
                    {
                        string sPID = xParameter.Attribute("id").Value;
                        string sName = xParameter.Element("name").Value;
                        string sDesc = xParameter.Element("desc").Value;

                        bool bEncrypt = false;
                        if (xParameter.Attribute("encrypt") != null)
                            bEncrypt = dc.IsTrue(xParameter.Attribute("encrypt").Value);

                        sHTML += "<div class=\"parameter\">";
                        sHTML += "  <div class=\"ui-state-default parameter_header\">";

                        sHTML += "<div class=\"step_header_title\"><span class=\"parameter_name";
                        sHTML += (bEditable ? " pointer" : ""); //make the name a pointer if it's editable
                        sHTML += "\" id=\"" + sPID + "\">";
                        sHTML += sName;
                        sHTML += "</span></div>";

                        sHTML += "<div class=\"step_header_icons\">";
                        sHTML += "<img class=\"parameter_help_btn pointer trans50\"" +
                            " src=\"../images/icons/info.png\" alt=\"\" style=\"width: 12px; height: 12px;\"" +
                            " title=\"" + sDesc.Replace("\"", "") + "\" />";

                        if (bEditable)
                        {
                            sHTML += "<img class=\"parameter_remove_btn pointer\" remove_id=\"" + sPID + "\"" +
                                " src=\"../images/icons/fileclose.png\" alt=\"\" style=\"width: 12px; height: 12px;\" />";
                        }

                        sHTML += "</div>";
                        sHTML += "</div>";

                        sHTML += "<div class=\"ui-widget-content ui-corner-bottom clearfloat parameter_detail\">";

                        //desc - a short snip is shown here... 75 chars.

                        //if (!string.IsNullOrEmpty(sDesc))
                        //    if (bSnipValues)
                        //        sDesc = ui.GetSnip(sDesc, 75);
                        //    else
                        //        sDesc = ui.FixBreaks(sDesc);
                        //sHTML += "<div class=\"parameter_desc hidden\">" + sDesc + "</div>";

                        //values
                        XElement xValues = xParameter.XPathSelectElement("values");
                        if (xValues != null)
                        {
                            foreach (XElement xValue in xValues.XPathSelectElements("value"))
                            {
                                string sValue = (string.IsNullOrEmpty(xValue.Value) ? "" : xValue.Value);

                                //only show stars IF it's encrypted, but ONLY if it has a value
                                if (bEncrypt && !string.IsNullOrEmpty(sValue))
                                    sValue = "********";
                                else
                                    if (bSnipValues)
                                        sValue = ui.GetSnip(xValue.Value, 64);
                                    else
                                        sValue = ui.FixBreaks(xValue.Value);

                                sHTML += "<div class=\"ui-widget-content ui-corner-tl ui-corner-bl parameter_value\">" + sValue + "</div>";
                            }
                        }
//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs

示例8: wmGetMergedParameterXML


//.........这里部分代码省略.........

                XElement xDefParams = xDefDoc.XPathSelectElement("/parameters");
                if (xDefParams == null)
                    throw new Exception("Defaults XML data does not contain 'parameters' root node.");
            }

            //spin the nodes in the DEFAULTS xml, then dig in to the task XML and UPDATE the value if found.
            //(if the node no longer exists, delete the node from the defaults xml IF IT WAS AN ACTION)
            //and default "values" take precedence over task values.
            foreach (XElement xDefault in xDefDoc.XPathSelectElements("//parameter"))
            {
                //nothing to do if it's empty
                if (xDefault == null)
                    break;

                //look it up in the task param xml
                XElement xDefName = xDefault.XPathSelectElement("name");
                string sDefName = (xDefName == null ? "" : xDefName.Value);
                XElement xDefValues = xDefault.XPathSelectElement("values");

                //nothing to do if there is no values node...
                if (xDefValues == null)
                    break;
                //or if it contains no values.
                if (!xDefValues.HasElements)
                    break;
                //or if there is no parameter name
                if (string.IsNullOrEmpty(sDefName))
                    break;

                //so, we have some valid data in the defaults xml... let's merge!

                //we have the name of the parameter... go find it in the TASK param XML
                XElement xTaskParam = xTPDoc.XPathSelectElement("//parameter/name[. = '" + sDefName + "']/..");  //NOTE! the /.. gets the parent of the name node!

                //if it doesn't exist in the task params, remove it from this document, permanently
                //but only for action types... instance data is historical and can't be munged
                if (xTaskParam == null && sType == "action")
                {
                    ft.RemoveNodeFromXMLColumn("ecotemplate_action", "parameter_defaults", "action_id = '" + sID + "'", "//parameter/name[. = '" + sDefName + "']/..");
                    continue;
                }

                //is this an encrypted parameter?
                string sEncrypt = "";
                if (xTaskParam.Attribute("encrypt") != null)
                    sEncrypt = xTaskParam.Attribute("encrypt").Value;

                //and the "values" collection will be the 'next' node
                XElement xTaskParamValues = xTaskParam.XPathSelectElement("values");

                string sPresentAs = xTaskParamValues.Attribute("present_as").Value;
                if (sPresentAs == "dropdown")
                {
                    //dropdowns get a "selected" indicator
                    string sValueToSelect = xDefValues.XPathSelectElement("value").Value;

                    //find the right one by value and give it the "selected" attribute.
                    XElement xVal = xTaskParamValues.XPathSelectElement("value[. = '" + sValueToSelect + "']");
                    if (xVal != null)
                        xVal.SetAttributeValue("selected", "true");
                }
                else if (sPresentAs == "list")
                {
                    //first, a list gets ALL the values replaced...
                    xTaskParamValues.ReplaceNodes(xDefValues);
               	}
                else
                {
                    //IMPORTANT NOTE:
                    //remember... both these XML documents came from wmGetObjectParameterXML...
                    //so any encrypted data IS ALREADY OBFUSCATED and base64'd in the oev attribute.

                    //it's a single value, so just replace it with the default.
                    XElement xVal = xTaskParamValues.XPathSelectElement("value[1]");
                    if (xVal != null)
                    {
                        //if this is an encrypted parameter, we'll be replacing (if a default exists) the oev attribute
                        //AND the value... don't want them to get out of sync!
                        if (dc.IsTrue(sEncrypt))
                        {
                            if (xDefValues.XPathSelectElement("value") != null)
                                if (xDefValues.XPathSelectElement("value").Attribute("oev") != null)
                                {
                                    xVal.SetAttributeValue("oev", xDefValues.XPathSelectElement("value").Attribute("oev").Value);
                                    xVal.Value = xDefValues.XPathSelectElement("value").Value;
                                }
                        }
                        else
                        {
                            //not encrypted, just replace the value.
                            if (xDefValues.XPathSelectElement("value") != null)
                                xVal.Value = xDefValues.XPathSelectElement("value").Value;
                        }
                    }
                }
            }

            return xTPDoc.ToString(SaveOptions.DisableFormatting); ;
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs

示例9: wmUpdateRegistryValue

        public void wmUpdateRegistryValue(string sObjectID, string sXPath, string sValue, string sEncrypt)
        {
            dataAccess dc = new dataAccess();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();

            //fail on missing values
            if (string.IsNullOrEmpty(sXPath))
                throw new Exception("Missing XPath to update.");

            //masked means update an attribute AND encrypt the value
            sEncrypt = (dc.IsTrue(sEncrypt) ? "true" : "false");
            sValue = (dc.IsTrue(sEncrypt) ? dc.EnCrypt(sValue) : sValue);

            //update
            if (sObjectID == "global") sObjectID = "1";
            ft.SetNodeValueinXMLColumn("object_registry", "registry_xml", "object_id = '" + sObjectID + "'", sXPath, sValue);
            ft.SetNodeAttributeinXMLColumn("object_registry", "registry_xml", "object_id = '" + sObjectID + "'", sXPath, "encrypt", sEncrypt);

            return;
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:20,代码来源:uiMethods.asmx.cs

示例10: wmSetScheduler

        public string wmSetScheduler(string sSetToStatus)
        {
            acUI.acUI ui = new acUI.acUI();
            if (!ui.UserIsInRole("Administrator"))
            {
                return "Only an Administrator can perform this action.";
            }
            else
            {
                if (sSetToStatus == "")
                {
                    return "Unable to set Scheduler - 'on' or 'off' status argument is required.";
                }

                dataAccess dc = new dataAccess();
                string sErr = null;

                /*
                 Simply flips the switch on all pollers and logservers to either on or off based on the argument.
                 */
                string sStatus = (dc.IsTrue(sSetToStatus) ? "on" : "off");

                try
                {
                    if (!dc.sqlExecuteUpdate("update scheduler_settings set mode_off_on = '" + sStatus + "'", ref sErr)) { throw new Exception(sErr); }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }

                // add security log
                dc.addSecurityLog(ui.GetSessionUserID(), SecurityLogTypes.Security, SecurityLogActions.ConfigChange, acObjectTypes.None, "", "Scheduler set to [" + sStatus + "]", ref sErr);

                // no errors to here, so return an empty string
                return "";
            }
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:38,代码来源:uiMethods.asmx.cs

示例11: wmSaveActionParameterXML


//.........这里部分代码省略.........
                    int x = xADDoc.XPathSelectElements("//parameter").Count();
                    for (int i = (x-1); i>=0; i--)
                    {
                        XElement xDefault = xADDoc.XPathSelectElements("//parameter").ElementAt(i);

                        //look it up in the task param xml
                        XElement xADName = xDefault.XPathSelectElement("name");
                        string sADName = (xADName == null ? "" : xADName.Value);
                        XElement xADValues = xDefault.XPathSelectElement("values");
                        //string sValues = (xValues == null ? "" : xValues.ToString());

                        //now we have the name of the parameter, go find it in the TASK param XML
                        XElement xTaskParam = xTPDoc.XPathSelectElement("//parameter/name[. = '" + sADName + "']/..");  //NOTE! the /.. gets the parent of the name node!

                        //if it doesn't exist in the task params, remove it from this document
                        if (xTaskParam == null)
                        {
                            xDefault.Remove();
                            continue;
                        }

                        //and the "values" collection will be the 'next' node
                        XElement xTaskParamValues = xTaskParam.XPathSelectElement("values");

                        //so... it might be
                        //a) just an oev (original encrypted value) so de-base64 it
                        //b) a value flagged for encryption

                        //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)
开发者ID:remotesyssupport,项目名称:cato,代码行数:66,代码来源:uiMethods.asmx.cs


注:本文中的dataAccess.IsTrue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。