示例#1
0
        public List <ThreatReportViewModel> GetAllReportHistory(int regId)
        {
            List <ThreatReportViewModel> model = new List <ThreatReportViewModel>();

            try {
                Get_Connection();
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection  = connection;
                cmd.CommandText = string.Format("SELECT  * FROM threatreporttable,threatnotificationtable WHERE ThreatReportNotificationId = ThreatReportNotification_Id AND RegistrationId = '{0}'",
                                                regId);
                MySqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    var threatModel = new Threat();


                    threatModel.ThreatReport_Id = (long)Int32.Parse(reader["ThreatReport_Id"].ToString());
                    threatModel.Level_Of_Threat = reader["Level_of_Threat"].ToString();
                    threatModel.ReportDate      = reader["ReportDate"].ToString();


                    var modelobj = new ThreatReportViewModel();
                    modelobj.Threat = threatModel;
                    model.Add(modelobj);
                }

                connection.Close();
                return(model);
            }
            catch (MySqlException e)
            {
                string MessageString = "Read error occurred  / entry not found loading the Column details: "
                                       + e.ErrorCode + " - " + e.Message + "; \n\nPlease Continue";
                //MessageBox.Show(MessageString, "SQL Read Error");
                connection.Close();
                return(model);
            }
        }
示例#2
0
        public bool reportathreat(ThreatReportViewModel modelobj)
        {
            var      outputTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pakistan Standard Time");
            DateTime date           = TimeZoneInfo.ConvertTime(DateTime.Now, outputTimeZone);

            Get_Connection();
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection  = connection;
                cmd.CommandText = "INSERT INTO threatnotificationtable(RegistrationId, Level_of_Threat, Threat_status, ReportDate, ProcessThreat_status) VALUES (@g1d, @g2d,@g3d,@g4d,@g5d)";
                cmd.Parameters.AddWithValue("@g1d", modelobj.Users.Registration_Id);
                cmd.Parameters.AddWithValue("@g2d", modelobj.ThreatNotification.Level_Of_Threat);
                if (modelobj.ThreatNotification.Status.Equals("True"))
                {
                    cmd.Parameters.AddWithValue("@g3d", "Yes");
                }
                else
                {
                    cmd.Parameters.AddWithValue("@g3d", "No");
                }

                cmd.Parameters.AddWithValue("@g4d", date);
                cmd.Parameters.AddWithValue("@g5d", "Pending");
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                connection.Close();
                return(true);
            }
            catch (MySqlException e)
            {
                string MessageString = "Read error occurred  / entry not found loading the Column details: "
                                       + e.ErrorCode + " - " + e.Message + "; \n\nPlease Continue";
                //MessageBox.Show(MessageString, "SQL Read Error");
                connection.Close();
                return(false);
            }
        }