Exemplo n.º 1
0
        /// <summary>
        /// 增加检疫记录
        /// </summary>
        public int AddQuarantineRecord(Quarantine q)
        {
            //每头牛做增加操作时调用本方法
            QuarantineBLL qBLL = new QuarantineBLL();

            return(qBLL.InsertQurantine(q));
        }
Exemplo n.º 2
0
        public ActionResult SaveTask(string id)
        {
            try
            {
                Quarantine quarantine       = new Quarantine();
                int        PastureID        = UserBLL.Instance.CurrentUser.Pasture.ID;
                string     QuarantineType   = Request.Form["quarantineType"];
                string     QuarantineDate   = Request.Form["quarantineDate"];
                string     QuarantineMethod = Request.Form["quarantineMethod"];
                string     DoctorID         = Request.Form["doctorID"];
                string     Result           = Request.Form["result"];
                string     EarNum           = Request.Form["DisplayEarNum"];

                quarantine.PastureID        = PastureID;
                quarantine.QuarantineType   = QuarantineType;
                quarantine.QuarantineDate   = Convert.ToDateTime(QuarantineDate);
                quarantine.QuarantineMethod = QuarantineMethod;
                quarantine.DoctorID         = Convert.ToInt32(DoctorID);
                quarantine.Result           = Convert.ToInt32(Result);
                quarantine.EarNum           = CowBLL.ConvertDislayEarNumToEarNum(EarNum, PastureID);

                //增加检疫记录
                bllTask.AddQuarantineRecord(quarantine);

                //更新检疫记录
                DairyTask task = bllTask.GetTaskByID(Convert.ToInt32(id));//To-do please get taskID
                bllTask.CompleteQuarantine(task);

                return(View("~/Views/Task/Index.cshtml"));
            }
            catch (Exception)
            {
                return(View("~/Views/Task/TaskError.cshtml"));
            }
        }
Exemplo n.º 3
0
        public async Task<IActionResult> Edit(Guid id, Quarantine quarantine)
        {
            
            if (id != quarantine.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    this.repository.Quarantine.Update(quarantine);
                    await this.repository.SaveAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!QuarantineExists(quarantine.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                var CreatedAt = quarantine.CreatedAt;
                return RedirectToAction("DetailsByDate",new{ date= CreatedAt });
            }
            return View(quarantine);
        }
Exemplo n.º 4
0
        private void SaveQuarantineToTable(string filename,DateTime uploadDate)
        {
            CsvParserOptions csvParserOptions = new CsvParserOptions(true, ',');
            CsvQuarantineMapping csvMapper = new CsvQuarantineMapping();
            CsvParser<QuarantineViewModel> csvParser = new CsvParser<QuarantineViewModel>(csvParserOptions, csvMapper);

            var result = csvParser.ReadFromFile(filename, Encoding.ASCII).ToList();

            foreach (var item in result)
            {
                var q = new Quarantine
                {
                    Munisipio = item.Result.Munisipio,
                    KuarentenaObrigatorio = item.Result.KuarentenaObrigatorio,
                    AutoKuarentena = item.Result.AutoKuarentena,
                    PassaQuarentena = item.Result.PassaQuarentena,
                    CreatedAt = uploadDate
                    //Total = item.Result.Total
                };

                this.repository.Quarantine.Add(q);
            }

            this.repository.Save();
        }
Exemplo n.º 5
0
 public IActionResult Quarantine(Quarantine uc)
 {
     _aux.Add(uc);
     _aux.SaveChanges();
     ViewBag.message = uc.Name + " your Request has been Sent.";
     return(View());
 }
Exemplo n.º 6
0
        public ScanManager(VirustotalClient client, DatabaseManager database, Quarantine quarantine, List <FileScan> scans)
        {
            this.client     = client;
            this.database   = database;
            this.quarantine = quarantine;
            this.Scans      = scans;

            this.quarantine.OnScanUpdated += scan => this.OnScanUpdated?.Invoke(scan);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Инициализация внутренних компонентов ядра
        /// ВАЖНО! Менеджер обнаруженных вирусов должен быть запущен раньше чем менеджер задач сканирования
        /// </summary>
        static void InitKernelComponents()
        {
            API.Init();

            ScannerResponseHandler.Init();
            FoundVirusesManager.Init();
            ScanTasks.Init();
            Quarantine.InitStorage();
        }
Exemplo n.º 8
0
        private void Quarantinefrm_Load(object sender, EventArgs e)
        {
            List <string> t = Quarantine.Filelist();

            foreach (string it in t)
            {
                listBox1.Items.Add(it);
            }
        }
Exemplo n.º 9
0
        public App()
        {
            this.config = this.ParseConfig("config.json");

            this.client      = new VirustotalClient(this.config.ApiUrl, this.config.ApiKey);
            this.database    = new DatabaseManager(this.config.DatabaseFile);
            this.quarantine  = new Quarantine(this.config.QuarantinePath, this.config.QuarantineKey);
            this.scanManager = new ScanManager(this.client, this.database, this.quarantine, this.database.GetScans());

            this.Exit += this.HandleExit;

            this.SetupDatabasePersist();
        }
Exemplo n.º 10
0
        public Quarantine WrapQuarantineItem(DataRow row)
        {
            Quarantine q = new Quarantine();

            q.ID               = Convert.ToInt32(row["ID"]);
            q.PastureID        = Convert.ToInt32(row["PastureID"]);
            q.Result           = Convert.ToInt32(row["Result"]);
            q.QuarantineDate   = Convert.ToDateTime(row["QuarantineDate"]);
            q.QuarantineType   = row["QuarantineType"].ToString();
            q.QuarantineMethod = row["QuarantineMethod"].ToString();
            q.EarNum           = Convert.ToInt32(row["EarNum"]);
            q.DoctorID         = Convert.ToInt32(row["DoctorID"]);
            return(q);
        }
Exemplo n.º 11
0
        public static void InfectedByMany(string infections, string filename)
        {
            if (SettingsManager.Silence)
            {
                Quarantine.Store(filename, infections);
            }
            else
            {
                Virus vi = new Virus(infections, filename, AVEngine.NothingScanner);

                InfectionFrm frm = new InfectionFrm(vi, true);
                frm.ShowDialog();
            }
        }
 public bool ToCsv(Quarantine quarantine)
 {
     try
     {
         string csv = $"{quarantine.link}";
         csv = csv + Environment.NewLine;
         File.AppendAllText(_csvFilePath, csv.ToString());
         return(true);
     }
     catch (Exception ex)
     {
         ErrorCode = ex.ToString();
         return(false);
     }
 }
        //Processes Emails
        private void ProcessStandardEmail()
        {
            //Validates URL's and replaces them with <URL Quarantined> and saves to Quarantine.csv
            var MessageHeaderText = MessageHeaderTextBox.ToString();
            var MessageBodyText   = MessageBodyTextBox.ToString();

            string[] splitMessageBodyText = MessageBodyTextBox.ToString().Split(' ');

            for (int i = 4; i < splitMessageBodyText.Length; i++)
            {
                Uri result;

                bool isUri = Uri.TryCreate(splitMessageBodyText[i], UriKind.Absolute, out result) &&
                             (result.Scheme == Uri.UriSchemeHttp || result.Scheme == Uri.UriSchemeHttps);

                if (isUri == true)
                {
                    Quarantine quarantine = new Quarantine()
                    {
                        link = splitMessageBodyText[i]
                    };

                    Database.Quarantine_Database.SaveToQuarantine save1 = new Database.Quarantine_Database.SaveToQuarantine();

                    if (!save1.ToCsv(quarantine))
                    {
                        MessageBox.Show("Error while saving\n" + save1.ErrorCode);
                    }
                    else
                    {
                        save1 = null;
                    }

                    MessageBodyText = MessageBodyText.Replace(splitMessageBodyText[i], "<URL Quarantined>");
                }
            }
            MessagesProcessor msgProcessor = new MessagesProcessor()
            {
                msgType = MessageHeaderText,
                msgBody = MessageBodyText
            };

            File.AppendAllText("C:/VS Database/ProcessedMessages.json", JsonConvert.SerializeObject(msgProcessor));
            MessageBox.Show("Message Processed Successfully:" + Environment.NewLine + "Message Type - " + MessageHeaderText + Environment.NewLine + "Message Body - " + MessageBodyText);
        }
Exemplo n.º 14
0
 public static void Infected(Virus infection)
 {
     KavprotVoice.SpeakAsync("This file was infected by " + infection.Name);
     AVEngine.EventsManager.CallVirusDetected();
     KavprotRemoteControl.SendPacket(SettingsManager.ApplicationAdress, SettingsManager.MobileAdress, KavprotRemoteControl.BuildARCPacket("SHOWTEXT", "ALDATA", SettingsManager.ApplicationAdress, "0005", Encoding.UTF8.GetBytes("File name : " + infection.Location + " \r\n Infection : " + infection.Name)));
     KavprotManager.LastThreat = infection.Name;
     if (SettingsManager.Silence)
     {
         if (infection.Scanner.Name == "HASH-TYPE-SCANNER")
         {
             Alert.Attack("Virus Detected " + infection.Name, "Kavprot smart security detected a virus by the Hash scan system (" + infection.Location + "). sometimes false-positive alert can happen by any antivirus software for more informations visit : http://www.arsslensoft.tk/AVL/FPAlert.html", ToolTipIcon.Warning, true);
         }
         else
         {
             Quarantine.Store(infection.Location, infection.Name);
         }
     }
     else
     {
         if (infection.Name != "KavProtSensor.UnPackableArchive")
         {
             if (SettingsManager.Silence)
             {
                 if (infection.Location.Contains(Environment.SystemDirectory))
                 {
                     AVEngine.AlertVirus();
                     InfectionFrm inf = new InfectionFrm(infection);
                     inf.ShowDialog();
                 }
                 else
                 {
                     Quarantine.Store(infection.Location, infection.Name);
                 }
             }
             else
             {
                 AVEngine.AlertVirus();
                 InfectionFrm inf = new InfectionFrm(infection);
                 inf.ShowDialog();
             }
         }
     }
 }
Exemplo n.º 15
0
 public int InsertQurantine(Quarantine quarantine)
 {
     return(this.quarantineDAL.InsertQuarantineRecord(quarantine.PastureID, quarantine.QuarantineDate.Date, quarantine.QuarantineType, quarantine.QuarantineMethod, quarantine.Result, quarantine.EarNum, quarantine.DoctorID));
 }
Exemplo n.º 16
0
 private void buttonX1_Click(object sender, EventArgs e)
 {
     Quarantine.Activate(listBox1.SelectedItem.ToString());
 }
        private void ProcessSIREmail()
        {
            //Validates URL's and replaces them with <URL Quarantined> and saves to Quarantine.csv
            var MessageHeaderText = MessageHeaderTextBox.ToString();
            var MessageBodyText   = MessageBodyTextBox.ToString();

            string[] splitMessageBodyText = MessageBodyTextBox.ToString().Split(' ');

            for (int i = 4; i < splitMessageBodyText.Length; i++)
            {
                Uri result;

                bool isUri = Uri.TryCreate(splitMessageBodyText[i], UriKind.Absolute, out result) &&
                             (result.Scheme == Uri.UriSchemeHttp || result.Scheme == Uri.UriSchemeHttps);

                if (isUri == true)
                {
                    Quarantine quarantine = new Quarantine()
                    {
                        link = splitMessageBodyText[i]
                    };

                    Database.Quarantine_Database.SaveToQuarantine save1 = new Database.Quarantine_Database.SaveToQuarantine();

                    if (!save1.ToCsv(quarantine))
                    {
                        MessageBox.Show("Error while saving\n" + save1.ErrorCode);
                    }
                    else
                    {
                        save1 = null;
                    }

                    MessageBodyText = MessageBodyText.Replace(splitMessageBodyText[i], "<URL Quarantined>");
                }
            }
            MessagesProcessor msgProcessor = new MessagesProcessor()
            {
                msgType = MessageHeaderText,
                msgBody = MessageBodyText
            };

            File.AppendAllText("C:/VS Database/ProcessedMessages.json", JsonConvert.SerializeObject(msgProcessor));
            MessageBox.Show("Message Processed Successfully:" + Environment.NewLine + "Message Type - " + MessageHeaderText + Environment.NewLine + "Message Body - " + MessageBodyText);

            //Saves SI to SIReportsDB.csv
            Database.SIReports_Database.SaveSIReportsToFile save4 = new Database.SIReports_Database.SaveSIReportsToFile();

            string[] NOIArray1w =
            { "Raid",
              "Terrorism" };

            var noi1w      = splitMessageBodyText[12];
            var noifound1w = Array.Exists(NOIArray1w, s => s.Equals(noi1w));

            string[] NOIArray2w =
            { "Staff Attack",
              "Device Damage",
              "Customer Attack",
              "Staff Abuse",
              "Bomb Threat",
              "Suspicious Incident",
              "Sport Injury" };

            var noi2w      = splitMessageBodyText[12] + " " + splitMessageBodyText[13];
            var noifound2w = Array.Exists(NOIArray2w, s => s.Equals(noi2w));

            string[] NOIArray3w =
            { "Theft of Properties",
              "Personal Info Leak" };

            var noi3w      = splitMessageBodyText[12] + " " + splitMessageBodyText[13] + " " + splitMessageBodyText[14];
            var noifound3w = Array.Exists(NOIArray3w, s => s.Equals(noi3w));

            if (noifound1w == true)
            {
                SIReports siReports = new SIReports()
                {
                    SportCentreCode  = splitMessageBodyText[8],
                    NatureOfIncident = splitMessageBodyText[12]
                };

                if (!save4.ToCsv(siReports))
                {
                    MessageBox.Show("Error while saving\n" + save4.ErrorCode);
                }
                else
                {
                    save4 = null;
                }
            }

            if (noifound2w == true)
            {
                SIReports siReports = new SIReports()
                {
                    SportCentreCode  = splitMessageBodyText[8],
                    NatureOfIncident = splitMessageBodyText[12] + " " + splitMessageBodyText[13]
                };

                if (!save4.ToCsv(siReports))
                {
                    MessageBox.Show("Error while saving\n" + save4.ErrorCode);
                }
                else
                {
                    save4 = null;
                }
            }

            if (noifound3w == true)
            {
                SIReports siReports = new SIReports()
                {
                    SportCentreCode  = splitMessageBodyText[8],
                    NatureOfIncident = splitMessageBodyText[12] + " " + splitMessageBodyText[13] + " " + splitMessageBodyText[14]
                };

                if (!save4.ToCsv(siReports))
                {
                    MessageBox.Show("Error while saving\n" + save4.ErrorCode);
                }
                else
                {
                    save4 = null;
                }
            }
        }
Exemplo n.º 18
0
 public Country(string name, Quarantine quarantine, CovidTest covidtest)
 {
     this.name       = name;
     this.quarantine = quarantine;
     this.covidtest  = covidtest;
 }