示例#1
0
        public bool SetProcessFlag(string interfaceName, string[] guidList)
        {
            if (guidList == null || interfaceName == null)
            {
                return(false);
            }

            if (interfaceName.Length < 1)
            {
                Program.Log.Write(LogType.Warning, "Adapter interface name is a empty string.");
                return(false);
            }

            if (guidList.Length < 1)
            {
                Program.Log.Write(LogType.Warning, "Nothing in the GUID List.");
                return(true);
            }

            string strSql = RuleControl.GetSetProcessFlagSQL(interfaceName, guidList);

            bool result = false;
            //SafeDBConnection cn = SafeDBConnection.Instance;
            OleDbConnection cnn = new OleDbConnection(Program.ConfigMgt.Config.DataDBConnection);

            try
            {
                //OleDbCommand cmd = new OleDbCommand(strSql,cn.Connection);
                OleDbCommand cmd = new OleDbCommand(strSql, cnn);
                cmd.CommandType = CommandType.Text;

                //cn.Open();
                cnn.Open();
                int count = cmd.ExecuteNonQuery();
                //cn.Close();
                cnn.Close();

                Program.Log.Write("Update process flag success. Interface Name: " + interfaceName + ", Number of rows affected: " + count.ToString());

                result = true;
            }
            catch (Exception err)
            {
                Program.Log.Write(LogType.Warning, "Update process flag failed.");
                DumpDataBaseError(err, strSql);
            }
            finally
            {
                //if (!result) cn.Close();
                if (!result)
                {
                    cnn.Close();
                }
            }

            return(result);
        }