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


C# dataAccess.sqlGetSingleString方法代码示例

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


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

示例1: 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);
            }
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:50,代码来源:uiMethods.asmx.cs

示例2: wmCopyTask

        public string wmCopyTask(string sCopyTaskID, string sTaskCode, string sTaskName)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sErr = null;

            // checks that cant be done on the client side
            // is the name unique?
            string sTaskNameInUse = "";
            if (!dc.sqlGetSingleString(ref sTaskNameInUse, "select task_id from task where task_name = '" + sTaskName.Replace("'", "''") + "' limit 1", ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (!string.IsNullOrEmpty(sTaskNameInUse))
                {
                    return "Task Name [" + sTaskName + "] already in use.  Please choose another name.";
                }
            }

            // checks that cant be done on the client side
            // is the name unique?
            string sTaskCodeInUse = "";
            if (!dc.sqlGetSingleString(ref sTaskCodeInUse, "select task_id from task where task_code = '" + sTaskCode.Replace("'", "''") + "' limit 1", ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (!string.IsNullOrEmpty(sTaskCodeInUse))
                {
                    return "Task Code [" + sTaskCode + "] already in use.  Please choose another code.";
                }
            }

            string sNewTaskGUID = CopyTask(0, sCopyTaskID, sTaskName.Replace("'", "''"), sTaskCode.Replace("'", "''"));

            if (!string.IsNullOrEmpty(sNewTaskGUID))
            {
                ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskGUID, sTaskName, "Copied from " + sCopyTaskID);
            }

            // success, return the new task_id
            return sNewTaskGUID;
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:46,代码来源:taskMethods.asmx.cs

示例3: wmDeleteTaskParam

        public string wmDeleteTaskParam(string sType, string sID, string sParamID)
        {
            dataAccess dc = new dataAccess();

            acUI.acUI ui = new acUI.acUI();
            FunctionTemplates.HTMLTemplates ft = new FunctionTemplates.HTMLTemplates();

            string sErr = "";
            string sSQL = "";
            string sTable = "";

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

            if (!string.IsNullOrEmpty(sParamID) && ui.IsGUID(sID))
            {
                // need the name and values for logging
                string sXML = "";

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

                if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
                    throw new Exception("Unable to get parameter_xml.  " + sErr);

                if (sXML != "")
                {
                    XDocument xd = XDocument.Parse(sXML);
                    if (xd == null) throw new Exception("XML parameter data is invalid.");

                    XElement xName = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/name");
                    string sName = (xName == null ? "" : xName.Value);
                    XElement xValues = xd.XPathSelectElement("//parameter[@id = \"" + sParamID + "\"]/values");
                    string sValues = (xValues == null ? "" : xValues.ToString());

                    // add security log
                    ui.WriteObjectDeleteLog(Globals.acObjectTypes.Parameter, "", sID, "");

                    if (sType == "task") { ui.WriteObjectChangeLog(Globals.acObjectTypes.Task, sID, "Deleted Parameter:[" + sName + "]", sValues); };
                    if (sType == "ecosystem") { ui.WriteObjectChangeLog(Globals.acObjectTypes.Ecosystem, sID, "Deleted Parameter:[" + sName + "]", sValues); };
                }

                //do the whack
                ft.RemoveNodeFromXMLColumn(sTable, "parameter_xml", sType + "_id = '" + sID + "'", "//parameter[@id = \"" + sParamID + "\"]");

                return "";
            }
            else
            {
                throw new Exception("Invalid or missing Task or Parameter ID.");
            }
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:55,代码来源:taskMethods.asmx.cs

示例4: wmSaveTaskUserSetting

        public void wmSaveTaskUserSetting(string sTaskID, string sSettingKey, string sSettingValue)
        {
            dataAccess dc = new dataAccess();

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

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
                {
                    //1) get the settings
                    //2) update/add the appropriate value
                    //3) update the settings to the db

                    string sSettingXML = "";
                    string sErr = "";
                    string sSQL = "select settings_xml from users where user_id = '" + sUserID + "'";

                    if (!dc.sqlGetSingleString(ref sSettingXML, sSQL, ref sErr))
                    {
                        throw new Exception("Unable to get settings for user." + sErr);
                    }

                    if (sSettingXML == "")
                        sSettingXML = "<settings><debug><tasks></tasks></debug></settings>";

                    XDocument xDoc = XDocument.Parse(sSettingXML);
                    if (xDoc == null) throw new Exception("XML settings data for user is invalid.");

                    //we have to analyze the doc and see if the appropriate section exists.
                    //if not, we need to construct it
                    if (xDoc.Element("settings").Descendants("debug").Count() == 0)
                        xDoc.Element("settings").Add(new XElement("debug"));

                    if (xDoc.Element("settings").Element("debug").Descendants("tasks").Count() == 0)
                        xDoc.Element("settings").Element("debug").Add(new XElement("tasks"));

                    XElement xTasks = xDoc.Element("settings").Element("debug").Element("tasks");

                    //to search by attribute we must get back an array and we shouldn't have an array anyway
                    //so to be safe and clean, delete all matches and just add back the one we want
                    xTasks.Descendants("task").Where(
                        x => (string)x.Attribute("task_id") == sTaskID).Remove();

                    //add it
                    XElement xTask = new XElement("task");
                    xTask.Add(new XAttribute("task_id", sTaskID));
                    xTask.Add(new XAttribute(sSettingKey, sSettingValue));

                    xTasks.Add(xTask);

                    sSQL = "update users set settings_xml = '" + xDoc.ToString(SaveOptions.DisableFormatting) + "'" +
                        " where user_id = '" + sUserID + "'";
                    if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    {
                        throw new Exception("Unable to save Task User Setting." + sErr);
                    }

                    return;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task [" + sTaskID + "] or unable to get current user.");
                }

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

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

示例6: wmGetTaskVariables

        public string wmGetTaskVariables(string sTaskID)
        {
            dataAccess dc = new dataAccess();

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

            try
            {
                if (ui.IsGUID(sTaskID))
                {
                    string sErr = "";
                    string sHTML = "";

                    //VARIABLES
                    string sSQL = "select distinct var_name from (" +
                        "select ExtractValue(function_xml, '//function/counter[1]') as var_name" +
                        " from task_step" +
                        " where task_id = '" + sTaskID + "'" +
                        " and function_name = 'loop'" +
                        " UNION" +
                        " select ExtractValue(variable_xml, '//variable/name[1]') as var_name" +
                        " from task_step" +
                        " where task_id = '" + sTaskID + "'" +
                        " UNION" +
                        " select ExtractValue(function_xml, '//variable/name[1]') as var_name" +
                        " from task_step" +
                        " where task_id = '" + sTaskID + "'" +
                        " and function_name in ('set_variable','substring')" +
                        " ) foo" +
                        " where ifnull(var_name,'') <> ''" +
                        " order by var_name";

                    DataTable dtVars = new DataTable();
                    dtVars.Columns.Add("var_name");
                    DataTable dtStupidVars = new DataTable();
                    if (!dc.sqlGetDataTable(ref dtStupidVars, sSQL, ref sErr))
                        throw new Exception("Unable to get variables for task." + sErr);

                    if (dtStupidVars.Rows.Count > 0)
                    {
                        foreach (DataRow drStupidVars in dtStupidVars.Rows)
                        {
                            if (drStupidVars["var_name"].ToString().IndexOf(' ') > -1)
                            {
                                //split it on the space
                                string[] aVars = drStupidVars["var_name"].ToString().Split(' ');
                                foreach (string sVar in aVars)
                                {
                                    dtVars.Rows.Add(sVar);
                                }
                            }
                            else
                            {
                                dtVars.Rows.Add(drStupidVars["var_name"].ToString());
                            }
                        }
                    }

                    //now that we've manually added some rows, resort it
                    DataView dv = dtVars.DefaultView;
                    dv.Sort = "var_name";
                    dtVars = dv.ToTable();

                    //Finally, we have a table with all the vars!
                    if (dtVars.Rows.Count > 0)
                    {

                        sHTML += "<div target=\"var_picker_group_vars\" class=\"ui-widget-content ui-corner-all value_picker_group\"><img alt=\"\" src=\"../images/icons/expand.png\" style=\"width:12px;height:12px;\" /> Variables</div>";
                        sHTML += "<div id=\"var_picker_group_vars\" class=\"hidden\">";

                        foreach (DataRow drVars in dtVars.Rows)
                        {
                            sHTML += "<div class=\"ui-widget-content ui-corner-all value_picker_value\">" + drVars["var_name"].ToString() + "</div>";
                        }

                        sHTML += "</div>";
                    }

                    //PARAMETERS
                    sSQL = "select parameter_xml from task where task_id = '" + sTaskID + "'";

                    string sParameterXML = "";

                    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 task [" + sTaskID + "] is invalid.");

                        XElement xParams = xDoc.XPathSelectElement("/parameters");
                        if (xParams != null)
                        {
                            sHTML += "<div target=\"var_picker_group_params\" class=\"ui-widget-content ui-corner-all value_picker_group\"><img alt=\"\" src=\"../images/icons/expand.png\" style=\"width:12px;height:12px;\" /> Parameters</div>";
                            sHTML += "<div id=\"var_picker_group_params\" class=\"hidden\">";

//.........这里部分代码省略.........
开发者ID:remotesyssupport,项目名称:cato,代码行数:101,代码来源:taskMethods.asmx.cs

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

示例8: wmGetTaskIDFromName

        public string wmGetTaskIDFromName(string sTaskName)
        {
            dataAccess dc = new dataAccess();
            try
            {
                //this expects taskname:version syntax
                //if there is no : the default version is assumed
                string sErr = "";
                string sSQL = "";

                string[] aTNV = sTaskName.Split(':');
                if (aTNV.Length > 1)
                {
                    //there is a version
                    sSQL = "select task_id" +
                        " from task where task_name = '" + aTNV[0] + "'" +
                        " and version = '" + aTNV[1] + "'";
                }
                else
                {
                    //there is not, default
                    sSQL = "select task_id" +
                        " from task where task_name = '" + aTNV[0] + "'" +
                        " and default_version = 1";
                }

                string sID = "";

                if (!string.IsNullOrEmpty(sSQL))
                {
                    dc.sqlGetSingleString(ref sID, sSQL, ref sErr);
                    return sID;
                }

                return "";
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:you8,项目名称:cato,代码行数:41,代码来源:taskMethods.asmx.cs

示例9: wmGetTaskIDFromOTIDandVersion

        public string wmGetTaskIDFromOTIDandVersion(string sOTID, string sVersion)
        {
            if (string.IsNullOrEmpty(sOTID))
                return "";

            dataAccess dc = new dataAccess();
            try
            {
                string sErr = "";
                string sSQL = "";

                if (!string.IsNullOrEmpty(sVersion))
                {
                    //there is a version
                    sSQL = "select task_id" +
                        " from task where original_task_id = '" + sOTID + "'" +
                        " and version = '" + sVersion + "'";
                }
                else
                {
                    //there is not, default
                    sSQL = "select task_id" +
                        " from task where original_task_id = '" + sOTID + "'" +
                        " and default_version = 1";
                }

                string sID = "";

                if (!string.IsNullOrEmpty(sSQL))
                {
                    dc.sqlGetSingleString(ref sID, sSQL, ref sErr);
                    return sID;
                }

                return "";
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:you8,项目名称:cato,代码行数:41,代码来源:taskMethods.asmx.cs

示例10: SaveAsset


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

                // 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);
            else
                if (!string.IsNullOrEmpty(sInuse))
                    return "Asset Name '" + sAssetName + "' already in use, choose another." + sAssetID;

            try
            {
                dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                if (sMode == "edit")
                {
                    sSql = "update asset set asset_name = '" + sAssetName + "'," +
                        " asset_status = '" + sAssetStatus + "'," +
                        " address = '" + sAddress + "'" + "," +
                        " conn_string = '" + sConnString + "'" + "," +
                        " db_name = '" + sDbName + "'," +
                        " port = " + (sPort == "" ? "NULL" : "'" + sPort + "'") + "," +
                        " connection_type = '" + sConnectionType + "'," +
                        " is_connection_system = '" + (sIsConnection == "Yes" ? 1 : 0) + "'," +
                        " credential_id = " + sCredentialID +
                        " where asset_id = '" + sAssetID + "'";

                    oTrans.Command.CommandText = sSql;
                    if (!oTrans.ExecUpdate(ref sErr))
                        throw new Exception(sErr);

                }
                else
                {
                    sSql = "insert into asset (asset_id,asset_name,asset_status,address,conn_string,db_name,port,connection_type,is_connection_system,credential_id)" +
                    " values (" +
                    "'" + sAssetID + "'," +
开发者ID:you8,项目名称:cato,代码行数:67,代码来源:assetEdit.aspx.cs

示例11: GetCredentialNameFromID

        private static string GetCredentialNameFromID(string sCredentialID)
        {
            dataAccess dc = new dataAccess();
            string sCredentialName = "";
            string sSQL = "";
            string sErr = "";
            sSQL = "select username from asset_credential where credential_id = '" + sCredentialID + "'";
            if (!dc.sqlGetSingleString(ref sCredentialName, sSQL, ref sErr))
            {
                throw new Exception(sErr);
            }
            else
            {
                if (string.IsNullOrEmpty(sCredentialName))
                {
                    sCredentialName = "";
                }
            }

            return sCredentialName;
        }
开发者ID:you8,项目名称:cato,代码行数:21,代码来源:assetEdit.aspx.cs

示例12: 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();
//.........这里部分代码省略.........
开发者ID:you8,项目名称:cato,代码行数:101,代码来源:sharedCredentialEdit.aspx.cs

示例13: GetRegistry

        public XDocument GetRegistry(string sObjectID, ref string sErr)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            try
            {
                string sXML = "";

                string sSQL = "select registry_xml from object_registry where object_id = '" + sObjectID + "'";
                if (!dc.sqlGetSingleString(ref sXML, sSQL, ref sErr))
                    throw new Exception("Error: Could not look up Registry XML." + sErr);

               if (!string.IsNullOrEmpty(sXML))
                {
                    XDocument xd = XDocument.Parse(sXML);
                    if (xd == null)
                    {
                        throw new Exception("Error: Unable to parse XML.");
                    }

                    return xd;
                }
                else
                {
                    //if the object_id is a guid, it's an object registry... add one if it's not there.
                    if (ui.IsGUID(sObjectID))
                    {
                        sSQL = "insert into object_registry values ('" + sObjectID + "', '<registry />')";
                        if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                            throw new Exception("Error: Could not create Registry." + sErr);

                        XDocument xd = XDocument.Parse("<registry />");
                        return xd;
                    }
                    else
                        throw new Exception("Error: Could not look up Registry XML.");

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

示例14: wmCreateTag

        public string wmCreateTag(string sTagName, string sDescription)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSQL = null;
            string sErr = null;

            try
            {
                sSQL = "select tag_name from lu_tags where tag_name = '" + sTagName + "'";
                string sTagExists = "";
                if (!dc.sqlGetSingleString(ref sTagExists, sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }
                else
                {
                    if (!string.IsNullOrEmpty(sTagExists))
                    {
                        return "Tag exists - choose another name.";
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            try
            {
                sSQL = "insert into lu_tags (tag_name, tag_desc)" +
                    " values ('" + sTagName + "'," +
                    "'" + sDescription + "')";

                if (!dc.sqlExecuteUpdate(sSQL, ref sErr))
                    throw new Exception(sErr);

                ui.WriteObjectAddLog(acObjectTypes.None, sTagName, sTagName, "Tag created.");
            }
            catch (Exception ex)
            {

                throw new Exception(ex.Message);
            }

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

示例15: wmGetTaskMaxVersion

        public string wmGetTaskMaxVersion(string sTaskID, ref string sErr)
        {
            dataAccess dc = new dataAccess();
            try
            {

                string sSQL = "select max(version) as maxversion from task " +
                       " where original_task_id = " +
                       " (select original_task_id from task where task_id = '" + sTaskID + "')";

                string sMax = "";
                if (!dc.sqlGetSingleString(ref sMax, sSQL, ref sErr)) throw new Exception(sErr);

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


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