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


C# dataAccess类代码示例

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


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

示例1: DeleteClouds

        public static string DeleteClouds(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = null;
            string sErr = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();
            // get a list of ids that will be deleted for the log
            sSql = "select cloud_id, cloud_name, provider from clouds where cloud_id in (" + sDeleteArray + ")";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
                throw new Exception(sErr);

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

                sSql = "delete from clouds where cloud_id in (" + sDeleteArray + ")";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);

                //refresh the cloud account list in the session
                if (!ui.PutCloudAccountsInSession(ref sErr))
                    throw new Exception(sErr);

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            //reget the cloud providers class in the session
            ui.SetCloudProviders(ref sErr);
            if (!string.IsNullOrEmpty(sErr))
                throw new Exception("Error: Unable to load Cloud Providers XML." + sErr);

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.Cloud, dr["cloud_id"].ToString(), dr["cloud_name"].ToString(), dr["provider"].ToString() + " Cloud Deleted.");
            }

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

示例2: DeleteCredentials

        public static string DeleteCredentials(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = null;
            string sErr = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();
            // get a list of credential_ids that will be deleted for the log
            sSql = "select credential_name,credential_id from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
                    "and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            try
            {

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

                //delete asset_credential
                sSql = "delete from asset_credential where credential_id in (" + sDeleteArray.ToString() + ") " +
                        "and credential_id not in (select distinct credential_id from asset where credential_id is not null)";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.Credential, dr["credential_id"].ToString(), dr["credential_name"].ToString(), "Credential Deleted");
            }

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

示例3: DeleteAccounts

        public static string DeleteAccounts(string sDeleteArray)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            string sSql = null;
            string sErr = "";

            if (sDeleteArray.Length < 36)
                return "";

            sDeleteArray = ui.QuoteUp(sDeleteArray);

            DataTable dt = new DataTable();
            // get a list of ids that will be deleted for the log
            sSql = "select account_id, account_name, provider, login_id from cloud_account where account_id in (" + sDeleteArray + ")";
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
                throw new Exception(sErr);

            try
            {

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

                sSql = "delete from cloud_account where account_id in (" + sDeleteArray + ")";
                oTrans.Command.CommandText = sSql;
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);

                //refresh the cloud account list in the session
                if (!ui.PutCloudAccountsInSession(ref sErr))
                    throw new Exception(sErr);

                oTrans.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            // if we made it here, so save the logs
            foreach (DataRow dr in dt.Rows)
            {
                ui.WriteObjectDeleteLog(Globals.acObjectTypes.CloudAccount, dr["account_id"].ToString(), dr["account_name"].ToString(), dr["provider"].ToString() + " Account for LoginID [" + dr["login_id"].ToString() + "] Deleted");
            }

            return sErr;
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:47,代码来源:cloudAccountEdit.aspx.cs

示例4: GetRegistry

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

            try
            {
                string sXML = "";

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

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

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

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

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

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

示例6: GetKeyPairs

        public static string GetKeyPairs(string sID)
        {
            dataAccess dc = new dataAccess();
            string sSql = null;
            string sErr = null;
            string sHTML = "";

            sSql = "select keypair_id, keypair_name, private_key, passphrase" +
                " from cloud_account_keypair" +
                " where account_id = '" + sID + "'";

            DataTable dt = new DataTable();
            if (!dc.sqlGetDataTable(ref dt, sSql, ref sErr))
            {
                throw new Exception(sErr);
            }

            if (dt.Rows.Count > 0)
            {
                sHTML += "<ul>";
                foreach (DataRow dr in dt.Rows)
                {
                    string sName = dr["keypair_name"].ToString();

                    //DO NOT send these back to the client.
                    string sPK = (object.ReferenceEquals(dr["private_key"], DBNull.Value) ? "false" : "true");
                    string sPP = (object.ReferenceEquals(dr["passphrase"], DBNull.Value) ? "false" : "true");
                    //sLoginPassword = "($%#[email protected]!&";

                    sHTML += "<li class=\"ui-widget-content ui-corner-all keypair\" id=\"kp_" + dr["keypair_id"].ToString() + "\" has_pk=\"" + sPK + "\" has_pp=\"" + sPP + "\">";
                    sHTML += "<span class=\"keypair_label pointer\">" + sName + "</span>";
                    sHTML += "<span class=\"keypair_icons pointer\"><img src=\"../images/icons/fileclose.png\" class=\"keypair_delete_btn\" /></span>";
                    sHTML += "</li>";
                }
                sHTML += "</ul>";
            }
            else
            {
                sHTML += "";
            }

            return sHTML;
        }
开发者ID:remotesyssupport,项目名称:cato,代码行数:43,代码来源:cloudAccountEdit.aspx.cs

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

示例8: wmDatasetTemplateChange

        public string wmDatasetTemplateChange(string sStepID, string sTemplateID)
        {
            dataAccess dc = new dataAccess();

            try
            {
                XDocument xGlobals = XDocument.Load(Server.MapPath("~/pages/luDatasetTemplates.xml"));

                if (xGlobals == null)
                {
                    throw new Exception("Could not load templates.");
                }
                else
                {

                    // we have the step_id and the template_id
                    // get the entire <function... section and replace it in the db for this step_id
                    var xFunctionXml = (from node in xGlobals.Descendants("template")
                                        where (string)node.Attribute("template_id") == sTemplateID
                                        select node).Single().Element("function");

                    if (xFunctionXml == null)
                    {
                        // could not find the value, now what?
                        throw new Exception("Template settings null for template id: " + sTemplateID);
                    }
                    else
                    {
                        // now we need the template_id somehow
                        string sSQL = "";
                        string sErr = "";
                        sSQL = "update task_step set function_xml = '" + xFunctionXml.ToString() + "' where step_id = '" + sStepID + "'";

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

                }

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

示例9: wmCopyTask

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

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

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

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

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

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

示例10: wmToggleStep

        public void wmToggleStep(string sStepID, string sVisible)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            sVisible = (sVisible == "1" ? "1" : "0");

            try
            {
                if (ui.IsGUID(sStepID))
                {
                    string sErr = "";
                    dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

                    string sUserID = ui.GetSessionUserID();

                    //is there a row?
                    int iRowCount = 0;
                    dc.sqlGetSingleInteger(ref iRowCount, "select count(*) from task_step_user_settings" +
                                " where user_id = '" + sUserID + "'" +
                                " and step_id = '" + sStepID + "'", ref sErr);

                    if (iRowCount == 0)
                    {
                        oTrans.Command.CommandText = "insert into task_step_user_settings" +
                            " (user_id, step_id, visible, breakpoint, skip)" +
                            " values ('" + sUserID + "','" + sStepID + "', " + sVisible + ", 0, 0)";

                        if (!oTrans.ExecUpdate(ref sErr))
                            throw new Exception("Unable to toggle step (0) [" + sStepID + "]." + sErr);
                    }
                    else
                    {
                        oTrans.Command.CommandText = " update task_step_user_settings set visible = '" + sVisible + "'" +
                            " where step_id = '" + sStepID + "'";
                        if (!oTrans.ExecUpdate(ref sErr))
                            throw new Exception("Unable to toggle step (1) [" + sStepID + "]." + sErr);
                    }

                    oTrans.Commit();

                    return;
                }
                else
                {
                    throw new Exception("Unable to toggle step. Missing or invalid step_id.");
                }

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

示例11: wmTaskSearch

        public string wmTaskSearch(string sSearchText)
        {
            try
            {
                dataAccess dc = new dataAccess();
                string sErr = "";
                string sWhereString = "";

                if (sSearchText.Length > 0)
                {
                    sWhereString = " and (a.task_name like '%" + sSearchText +
                                   "%' or a.task_desc like '%" + sSearchText +
                                   "%' or a.task_code like '%" + sSearchText + "%' ) ";
                }

                string sSQL = "select a.original_task_id, a.task_id, a.task_name, a.task_code," +
                    " left(a.task_desc, 255) as task_desc, a.version" +
                       " from task a  " +
                       " where default_version = 1" +
                       sWhereString +
                       " order by task_name, default_version desc, version";

                DataTable dt = new DataTable();
                if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

                string sHTML = "<hr />";
                if (dt.Rows.Count == 0)
                {
                    sHTML += "No results found";
                }
                else
                {
                    int iRowsToGet = dt.Rows.Count;
                    if (iRowsToGet >= 100)
                    {
                        sHTML += "<div>Search found " + dt.Rows.Count + " results.  Displaying the first 100.</div>";
                        iRowsToGet = 99;
                    }
                    sHTML += "<ul id=\"search_task_ul\" class=\"search_dialog_ul\">";

                    for (int i = 0; i < iRowsToGet; i++)
                    {
                        string sTaskName = dt.Rows[i]["task_name"].ToString().Replace("\"", "\\\"");
                        string sLabel = dt.Rows[i]["task_code"].ToString() + " : " + sTaskName;
                        string sDesc = dt.Rows[i]["task_desc"].ToString().Replace("\"", "").Replace("'", "");

                        sHTML += "<li class=\"ui-widget-content ui-corner-all search_dialog_value\" tag=\"task_picker_row\"" +
                            " original_task_id=\"" + dt.Rows[i]["original_task_id"].ToString() + "\"" +
                            " task_label=\"" + sLabel + "\"" +
                            "\">";
                        sHTML += "<div class=\"step_header_title search_dialog_value_name\">" + sLabel + "</div>";

                        sHTML += "<div class=\"step_header_icons\">";

                        //if there's a description, show a tooltip
                        if (!string.IsNullOrEmpty(sDesc))
                            sHTML += "<img src=\"../images/icons/info.png\" class=\"search_dialog_tooltip trans50\" title=\"" + sDesc + "\" />";

                        sHTML += "</div>";
                        sHTML += "<div class=\"clearfloat\"></div>";
                        sHTML += "</li>";
                    }
                }
                sHTML += "</ul>";

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

示例12: wmStopTask

        public void wmStopTask(string sInstance)
        {
            dataAccess dc = new dataAccess();

            try
            {
                if (sInstance != "")
                {
                    string sErr = "";
                    string sSQL = "update task_instance set task_status = 'Aborting'" +
                        " where task_instance = '" + sInstance + "'" +
                        " and task_status in ('Processing');";

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

                    sSQL = "update task_instance set task_status = 'Cancelled'" +
                        " where task_instance = '" + sInstance + "'" +
                        " and task_status in ('Submitted','Queued')";

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

                    return;
                }
                else
                {
                    throw new Exception("Unable to stop task. Missing or invalid task_instance.");
                }

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

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

示例14: wmRunTask

        public string wmRunTask(string sTaskID, string sEcosystemID, string sAccountID, string sAssetID, string sParameterXML, int iDebugLevel)
        {
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();
            uiMethods um = new uiMethods();

            //we encoded this in javascript before the ajax call.
            //the safest way to unencode it is to use the same javascript lib.
            //(sometimes the javascript and .net libs don't translate exactly, google it.)
            sParameterXML = ui.unpackJSON(sParameterXML).Replace("'", "''");

            //we gotta peek into the XML and encrypt any newly keyed values
            um.PrepareAndEncryptParameterXML(ref sParameterXML);

            try
            {
                string sUserID = ui.GetSessionUserID();

                if (ui.IsGUID(sTaskID) && ui.IsGUID(sUserID))
                {

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

                    string sSQL = "call addTaskInstance ('" + sTaskID + "','" +
                        sUserID + "',NULL," +
                        iDebugLevel + ",NULL,'" +
                        sParameterXML + "','" +
                        sEcosystemID + "','" +
                        sAccountID + "')";

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

                    return sInstance;
                }
                else
                {
                    throw new Exception("Unable to run task. Missing or invalid task [" + sTaskID + "] or asset [" + sAssetID + "] id.");
                }

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

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


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