Example #1
0
        public static void UpdateIssue(IConfigurationRoot configuration, IssueRuleType Issue, MySqlConnection myConnection, DateTime UpdateTime)
        {
            try
            {
                ConnectionState State = myConnection.State;
                if (State == ConnectionState.Closed)
                {
                    myConnection.Open();
                }

                string query = "UPDATE issue SET Resolved=@Resolved, UpdateDate=@UpdateDate WHERE IssueID = @IssueID and Type=@Type ";

                MySqlCommand myCommand = new MySqlCommand(query, myConnection);
                myCommand.Parameters.AddWithValue("@Resolved", "True");
                myCommand.Parameters.AddWithValue("@UpdateDate", UpdateTime);
                myCommand.Parameters.AddWithValue("@IssueID", Issue.IssueRule);
                myCommand.Parameters.AddWithValue("@Type", Issue.IssueType);

                object result = myCommand.ExecuteScalar();
            }
            catch (Exception e)
            {
                string error = "Exception Occre while updating table:" + e.Message + "\t" + e.GetType();
            }
        }
Example #2
0
        public static List <IssueRuleType> GetServiceIssues(IConfigurationRoot configuration, int ServiceID, MySqlConnection myConnection)
        {
            try
            {
                List <IssueRuleType> Issues = new List <IssueRuleType>();
                DbDataReader         myReader;

                ConnectionState State = myConnection.State;
                if (State == ConnectionState.Closed)
                {
                    myConnection.Open();
                }

                string query = "SELECT IssueID, Type from issue WHERE ServiceID =@ServiceID";

                MySqlCommand myCommand = new MySqlCommand(query, myConnection);
                myCommand.Parameters.AddWithValue("@ServiceID", ServiceID);
                myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                    IssueRuleType IssueRuleType = new IssueRuleType();
                    IssueRuleType.IssueRule = myReader.GetString(0);
                    IssueRuleType.IssueType = myReader.GetString(1);
                    Issues.Add(IssueRuleType);
                }

                myReader.Dispose();

                return(Issues);
            }
            catch (Exception e)
            {
                string error = "Exception Occre while selecting from table:" + e.Message + "\t" + e.GetType();
                List <IssueRuleType> vide = new List <IssueRuleType>();
                return(vide);
            }
        }