예제 #1
0
        public void Notify()
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare(queue: "Bitcoin",
                                         durable: false,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    var consumer = new EventingBasicConsumer(channel);
                    consumer.Received += (model, ea) =>
                    {
                        var  body = ea.Body;
                        var  data = Encoding.UTF8.GetString(body);
                        Stoc stoc = JsonConvert.DeserializeObject <Stoc>(data);
                        Console.WriteLine(" [x] Received {0}", stoc.Name + " : " + stoc.Value);

                        //connectionSignalR.InvokeAsync("PushNotify", stoc);
                        //-------------------------
                    };
                    channel.BasicConsume(queue: "Vivek",
                                         autoAck: true,
                                         consumer: consumer);
                }
        }
예제 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            string message = "";

            Cerere cerere_de_selectat = (Cerere)dataGridView3.SelectedRows[0].DataBoundItem;
            var    lista_cereri       = serviceCentru.GetAllCereri();
            Cerere cerere             = null;

            foreach (var i in lista_cereri)
            {
                if (i.Id == cerere_de_selectat.Id)
                {
                    cerere = i;
                }
            }

            if (cerere != null && cerere.Efectuata != true)
            {
                var stoc = serviceCentru.GetAllStocuri();

                int grupa;

                Stoc stocBun = null;

                foreach (var i in stoc)
                {
                    if (cerere.Grupa == i.Grupa && cerere.RH == i.RH)
                    {
                        stocBun = i;
                        if (cerere.CantitateGlobuleRosii <= i.GlobuleRosii &&
                            cerere.CantitatePlasma <= i.Plasma &&
                            cerere.CantitateTrombocite <= i.Trombocite &&
                            cerere.CantitateSange <= i.TotalSange)
                        {
                            message = "Cantitatea este suficienta pentru a implini cererea";
                        }
                        else
                        {
                            message = "Ne pare rau dar nu este suficient sange pentru cererea dumneavoastra. \n Notificati donatori sau trimiteti cantitatea de sange din stoc.";
                        }
                    }
                }

                if (stocBun != null)
                {
                    CentruService cService = new CentruService();

                    CentruTransfuzie ctr = cService.GetCentruTransfuzieByName(username);

                    CerereForm formCerere = new CerereForm(message, cerere, stocBun, ctr, this);

                    formCerere.Show();
                    loadStocSange();
                }
            }
            else
            {
                MessageBox.Show("Cererea a fost deja completata.");
            }
        }
예제 #3
0
        public IActionResult Push(Stoc stoc)
        {
            RabbitMQPush rabbitMq = new RabbitMQPush(stoc);

            rabbitMq.Push();
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public IActionResult Push(Stoc stoc)
        {
            UpdateDummyList(stoc);
            RabbitMQPost rabbitMq = new RabbitMQPost(stoc);

            Console.WriteLine(rabbitMq.Post());
            return(RedirectToAction("Index"));
        }
예제 #5
0
 public void UpdateStoc(Stoc stoc)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork())
     {
         unitOfWork.StocRepo.Update(stoc);
         unitOfWork.Save();
     }
 }
예제 #6
0
 public CerereForm(string message, Cerere cerere, Stoc stoc, CentruTransfuzie centru)
 {
     this.message = message;
     this.cerere  = cerere;
     this.stoc    = stoc;
     this.centru  = centru;
     InitializeComponent();
 }
        private void refreshBtn_Click(object sender, EventArgs e)
        {
            var stocList = Stoc.GetAllGroupedByProdus().Where(p => p.Cantitate < p.ProdusObject.StocMinim);
            var report   = new StocReport();

            report.objectDataSource.DataSource = stocList;
            reportViewer.Report = report;
            reportViewer.RefreshReport();
        }
예제 #8
0
        public void GetAtllStocTest()
        {
            var target = Stoc.GetAll();

            if (target == null)
            {
                Assert.Fail();
            }
        }
예제 #9
0
        public void CreateValueObject(Medicament m)
        {
            this.numeMedicament = new NumeMedicament(new Text(m.strNumeMedicament));
            this.stoc           = new Stoc(new Number(m.inStoc));
            this.distribuitor   = new DistribuitorM(new Text(m.strDistribuitor));

            this.pretVanzare    = new PretVanzare(new RealNumber(m.fPretVanzare));
            this.pretCumparare  = new PretCumparare(new RealNumber(m.fPretVanzare));
            this.adresaFarmacie = new Locatie(new Text(m.strLocatie));
        }
예제 #10
0
        public void EliminareSangeStoc()
        {
            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                List <PungaSangeTraseu> all = GetAllPungaSangeTraseu();
                bool modificat = false;
                all.ForEach(p =>
                {
                    PungaSange pungaSange = unitOfWork.PungaSangeRepo.GetBy(punga => punga.Id.Equals(p.Id));


                    if (p.StocCentru)
                    {
                        Analiza analiza = unitOfWork.AnalizaRepo.GetBy(a => a.PungaSange.Equals(p.Id));
                        Stoc stoc       = unitOfWork.StocRepo.GetBy(s => s.RH.Equals(analiza.Rh) && s.Grupa.Equals(analiza.Grupa));
                        var dp          = p.DataPrelevarii.AddMonths(12);
                        var dpok        = DateTime.Compare(p.DataPrelevarii.AddMonths(12), DateTime.Now);
                        if (DateTime.Compare(p.DataPrelevarii.AddMonths(12), DateTime.Now) < 0 && !pungaSange.EliminatPlasma)
                        {
                            stoc.Plasma = stoc.Plasma - p.CantitatePlasma;
                            pungaSange.EliminatPlasma = true;
                            modificat = true;
                        }
                        if (DateTime.Compare(p.DataPrelevarii.AddDays(5), DateTime.Now) < 0 && !pungaSange.EliminatTrombocite)
                        {
                            stoc.Trombocite = stoc.Trombocite - p.CantitateTrombocite;
                            pungaSange.EliminatTrombocite = true;
                            modificat = true;
                        }
                        if (DateTime.Compare(p.DataPrelevarii.AddDays(42), DateTime.Now) < 0 && !pungaSange.EliminatGlobuleRosii)
                        {
                            stoc.GlobuleRosii = stoc.GlobuleRosii - p.CantitateGlobuleRosii;
                            pungaSange.EliminatGlobuleRosii = true;
                            modificat = true;
                        }
                        if (pungaSange.EliminatPlasma && pungaSange.EliminatGlobuleRosii && pungaSange.EliminatTrombocite && !pungaSange.EliminatSange)
                        {
                            stoc.TotalSange          = stoc.TotalSange - pungaSange.CantitateSange;
                            pungaSange.EliminatSange = true;
                        }
                        unitOfWork.PungaSangeRepo.Update(pungaSange);
                        unitOfWork.StocRepo.Update(stoc);
                        unitOfWork.Save();
                    }
                });
                if (modificat == true)
                {
                    throw new ValidationException("O parte din sange a expirat. Stocul a fost updatat!");
                }
            }
        }
예제 #11
0
        public void InsertStocTest()
        {
            var target = new Stoc
            {
                IdPozitieFacturaIntrare = 28,
                IdProdus  = 2,
                Cantitate = 30.123123m
            };

            if (target.Save().Status == StatusEnum.Errors)
            {
                Assert.Fail();
            }
        }
예제 #12
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Stoc = await _context.Stoc.FirstOrDefaultAsync(m => m.ID == id);

            if (Stoc == null)
            {
                return(NotFound());
            }
            return(Page());
        }
예제 #13
0
        public void UpdateStocTest()
        {
            var target = new Stoc
            {
                IdPozitieFacturaIntrare = 1,
                IdProdus  = 1,
                Cantitate = 30,
                ID        = 1
            };

            if (target.Save().Status == StatusEnum.Errors)
            {
                Assert.Fail();
            }
        }
예제 #14
0
 private void LoadData()
 {
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca bancile...";
     Banca.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca delegatii...";
     Delegat.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca drepturile...";
     Drept.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca facturile...";
     FacturaIntrare.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca facturile...";
     FacturaIesire.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca firmele...";
     Firma.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     Plata.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PlataFactura.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PozitieFacturaIesire.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     PozitieFacturaIntrare.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca produsele...";
     Produs.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca rolurile...";
     Rol.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca platile...";
     RolDrept.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca stocurile...";
     Stoc.GetAll();
     progressBar.Invoke(new UpdateDelegate(UpdateProgressBar));
     runningOperationLbl.Text = "Se incarca utilizatorii...";
     Utilizator.GetAll();
 }
예제 #15
0
        public void SalvareFacturaIesireCuPozitiiTest()
        {
            FacturaIesire target = new FacturaIesire
            {
                CotaTva = 19,
                Data    = DateTime.Now,
                IdFirma = 2,
                Numar   = "xxx",
                Serie   = "xxx"
            };
            List <PozitieFacturaIesire> pozitiiList = new List <PozitieFacturaIesire>();
            var stoc = Stoc.GetAll().Where(p => p.ID == 27).First();

            stoc.Cantitate -= 100;
            pozitiiList.Add(new PozitieFacturaIesire
            {
                Cantitate  = 100,
                IdStoc     = 27,
                PretUnitar = 55,
            });
            var stoc1 = Stoc.GetAll().Where(p => p.ID == 26).First();

            stoc1.Cantitate -= 10;
            pozitiiList.Add(new PozitieFacturaIesire
            {
                Cantitate  = 10,
                IdStoc     = 26,
                PretUnitar = 55,
            });
            var stoc2 = Stoc.GetAll().Where(p => p.ID == 25).First();

            stoc2.Cantitate -= 10;
            pozitiiList.Add(new PozitieFacturaIesire
            {
                Cantitate  = 10,
                IdStoc     = 25,
                PretUnitar = 55,
            });

            PersistenceResult actual = target.Save(pozitiiList);

            if (actual.Status == StatusEnum.Errors)
            {
                Assert.Fail();
            }
        }
예제 #16
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Stoc = await _context.Stoc.FindAsync(id);

            if (Stoc != null)
            {
                _context.Stoc.Remove(Stoc);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
예제 #17
0
 public async Task <string> Push([FromBody] Stoc stock)
 {
     for (int i = 0; i <= 10; i++)
     {
         await Task.Delay(1500).ContinueWith((a) =>
         {
             stock = new Stoc
             {
                 ID    = i,
                 Name  = "Vivek",
                 Value = i * 100
             };
             RabbitMQPost rabbitMq = new RabbitMQPost(stock);
             Console.WriteLine(rabbitMq.Post());
         });
     }
     return("success");
 }
예제 #18
0
        public void UpdateStoc(PungaSangeTraseu pungaSange)
        {
            using (UnitOfWork unitOfWork = new UnitOfWork())
            {
                string  err     = "";
                Analiza analiza = unitOfWork.AnalizaRepo.GetBy(a => a.PungaSange.Equals(pungaSange.Id));
                Stoc    stoc    = unitOfWork.StocRepo.GetBy(s => s.RH.Equals(analiza.Rh) && s.Grupa.Equals(analiza.Grupa));
                if (pungaSange.DataPrelevarii.AddMonths(12) > DateTime.Now)
                {
                    stoc.Plasma = pungaSange.CantitatePlasma;
                }
                else
                {
                    err += "Plasma este expirata!\n ";
                }
                if (pungaSange.DataPrelevarii.AddDays(5) > DateTime.Now)
                {
                    stoc.Trombocite = pungaSange.CantitateTrombocite;
                }
                else
                {
                    err += "Trombocitele sunt expirate!\n";
                }
                if (pungaSange.DataPrelevarii.AddDays(42) > DateTime.Now)
                {
                    stoc.GlobuleRosii = pungaSange.CantitateGlobuleRosii;
                }
                else
                {
                    err += "Globulelele rosii sunt expirate!\n";
                }

                stoc.TotalSange         = pungaSange.CantitateSange;
                stoc.TermenPlasma       = 12;
                stoc.TermenGlobuleRosii = 42;
                stoc.TermenTrombocite   = 5;
                unitOfWork.StocRepo.Update(stoc);
                unitOfWork.Save();
                if (!err.Equals(""))
                {
                    throw new ValidationException(err);
                }
            }
        }
예제 #19
0
        static void Main(string[] args)
        {
            var factory = new ConnectionFactory()
            {
                HostName = "localhost"
            };

            using (var connection = factory.CreateConnection())
                using (var channel = connection.CreateModel())
                {
                    //Trigger The SignalR
                    Connect().Wait();

                    channel.QueueDeclare(queue: "Ethereum",
                                         durable: false,
                                         exclusive: false,
                                         autoDelete: false,
                                         arguments: null);

                    var consumer = new EventingBasicConsumer(channel);
                    consumer.Received += (model, ea) =>
                    {
                        var  body = ea.Body;
                        var  data = Encoding.UTF8.GetString(body);
                        Stoc stoc = JsonConvert.DeserializeObject <Stoc>(data);
                        Console.WriteLine(" [x] Received {0}", stoc.Name + " : " + stoc.Value);

                        connectionSignalR.InvokeAsync("PushNotify", stoc);
                        //-------------------------
                    };
                    channel.BasicConsume(queue: "Ethereum",
                                         autoAck: true,
                                         consumer: consumer);

                    Console.WriteLine(" Press [enter] to exit.");
                    Console.ReadLine();
                }
        }
예제 #20
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            string EanID = Request.Form["LP"].ToString();
            var    data  = (from listaproduse in _context.Produs select listaproduse).ToList();

            ListaProduse = data;
            Stoc objStoc = new Stoc();

            foreach (Produs produs in ListaProduse)
            {
                if (EanID.Equals(produs.ID.ToString()))
                {
                    objStoc.Produs      = produs.Nume;
                    Receptie.EAN        = produs;
                    Receptie.EAN_Produs = produs.EAN;
                    break;
                }
            }

            _context.Receptie.Add(Receptie);
            await _context.SaveChangesAsync();

            objStoc.EAN       = Receptie.EAN;
            objStoc.Cantitate = Receptie.Cantitate;
            objStoc.Furnizor  = Receptie.Furnizor;
            objStoc.SSCC      = Receptie.SSCC;
            objStoc.Adresa    = "În curs de stocare";
            objStoc.Receptie  = Receptie;
            _context.Stoc.Add(objStoc);
            await _context.SaveChangesAsync();

            return(RedirectToPage("../Stocuri/Index"));
        }
예제 #21
0
 public RabbitMQPost(Stoc _data)
 {
     this.data = _data;
 }
예제 #22
0
        public void UpdateDummyList(Stoc stoc)
        {
            int index = stocList.FindIndex(st => st.ID == stoc.ID);

            stocList[index] = stoc;
        }
예제 #23
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            if (SelectedProdus == null)
            {
                return;
            }
            if (SelectedProdus.CantitateDisponibila() == 0)
            {
                MessageBox.Show("Produsul '" + produs.Nume + "' nu este disponibil!");
                return;
            }
            decimal cantitate = 0m;

            decimal.TryParse(cantitateTbox.Text, out cantitate);
            if (cantitate <= 0)
            {
                MessageBox.Show("Introduceti o cantitate!");
                return;
            }
            if (cantitate > produs.CantitateDisponibila())
            {
                MessageBox.Show("Ati ales o cantitate mai mare decat cantitatea disponibila!");
                return;
            }
            decimal pretUnitar = 0;

            decimal.TryParse(pretUnitarTbox.Text, out pretUnitar);
            bool   verifiedErrorsFlag = false;
            string cantitateString    = cantitate.ToString("0.00");
            List <PozitieFacturaIesire> pozitiiNoiList = new List <PozitieFacturaIesire>();

            while (cantitate > 0)
            {
                var pozitieIesireNoua = new PozitieFacturaIesire();
                pozitieIesireNoua.IdFacturaIesire = 2;// pt a evita avertismentele
                pozitieIesireNoua.PretUnitar      = pretUnitar;
                var stocDisponibil = Stoc.GetAll().Where(p => p.Cantitate > 0 && p.IdProdus == produs.ID).First();
                pozitieIesireNoua.IdStoc    = stocDisponibil.ID;
                pozitieIesireNoua.Cantitate = stocDisponibil.Cantitate;
                if (!verifiedErrorsFlag)
                {
                    verifiedErrorsFlag = true;
                    var errors = pozitieIesireNoua.GetErrorString();
                    if (errors.Trim() != string.Empty)
                    {
                        MessageBox.Show(errors);
                        return;
                    }
                }
                if (stocDisponibil.Cantitate >= cantitate)
                {
                    stocDisponibil.Cantitate   -= cantitate;
                    pozitieIesireNoua.Cantitate = cantitate;
                    cantitate = 0;
                }
                else
                {
                    cantitate -= stocDisponibil.Cantitate;
                    stocDisponibil.Cantitate = 0;
                }
                pozitiiNoiList.Add(pozitieIesireNoua);
                pozitiiOut.Add(pozitieIesireNoua);
            }
            DataGridViewRow row = new DataGridViewRow();

            row.CreateCells(dataGrid, produs.Nume, cantitateString, pretUnitar.ToString("0.00"));
            row.Tag = pozitiiNoiList;
            dataGrid.Rows.Add(row);
            RefreshCantitateDisponibila();
        }
예제 #24
0
        public IActionResult Detail(int ID)
        {
            Stoc stoc = stocList.FirstOrDefault(s => s.ID == ID);

            return(View(stoc));
        }
예제 #25
0
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            // recuperare lista EANuri din bdd
            var datap = (from listaproduse in _context.Produs select listaproduse).ToList();

            ListaProduse = datap;

            var data = (from listastoc in _context.Stoc where listastoc.Comanda == null select listastoc).ToList();

            ListaStoc = data;
            string stocID = Request.Form["LP"].ToString();

            foreach (Stoc stoc in ListaStoc)
            {
                //identificam stocul ales
                if (stocID.Equals(stoc.ID.ToString()))
                {
                    //recuperam produsul stocului
                    foreach (Produs produs in ListaProduse)
                    {
                        if (produs.Nume.Equals(stoc.Produs))
                        {
                            Comanda.EAN = produs;
                            break;
                        }
                    }

                    // modificam stocul care ramane. Daca nu ramane nicio cantitate, stergem
                    // linia
                    decimal cantitate = stoc.Cantitate - Comanda.Cantitate;
                    decimal livrata   = stoc.Cantitate;
                    if (cantitate <= 0)
                    {
                        // s-a consumat tot paletul
                        _context.Stoc.Remove(stoc);
                        await _context.SaveChangesAsync();

                        // setez cantitatea pt rescriere pe comanda - caz comandat>livrat
                        cantitate = stoc.Cantitate;
                    }
                    else
                    {
                        stoc.Cantitate = cantitate;
                        _context.Stoc.Update(stoc);
                        await _context.SaveChangesAsync();

                        // setez cantitatea pt rescriere pe comanda - caz comandat=livrat
                        cantitate = Comanda.Cantitate;
                        livrata   = cantitate;
                    }
                    // scriem comanda
                    Comanda.Livrata = livrata;
                    _context.Comanda.Add(Comanda);
                    await _context.SaveChangesAsync();

                    // scriem stocul comandat. Daca avem o cantitate negativa inseamna
                    // ca nu a fost suficient stocul pt cant comandata. Livram cat este
                    Stoc newStoc = new Stoc();
                    newStoc.EAN       = Comanda.EAN;
                    newStoc.Produs    = stoc.Produs;
                    newStoc.Furnizor  = stoc.Furnizor;
                    newStoc.SSCC      = stoc.SSCC;
                    newStoc.Adresa    = "În curs de expediere";
                    newStoc.Client    = Comanda.Client;
                    newStoc.Receptie  = stoc.Receptie;
                    newStoc.Comanda   = Comanda;
                    newStoc.Cantitate = Comanda.Livrata;
                    _context.Stoc.Add(newStoc);
                    await _context.SaveChangesAsync();

                    break;
                }
            }

            return(RedirectToPage("../Stocuri/Index"));
        }
예제 #26
0
 public RabbitMQPush(Stoc _data)
 {
     this.data = _data;
 }
예제 #27
0
 public CerereForm(string message, Cerere cerere, Stoc stoc, CentruTransfuzie centru, FormCentru parentForm) : this(message, cerere, stoc, centru)
 {
     this.parentForm = parentForm;
 }
예제 #28
0
 public Task PushNotify(Stoc stocData)
 {
     return(Clients.Group(stocData.Name).SendAsync("ChangeStocValue", stocData));
 }
예제 #29
0
 public void GetAllStocGroupedByProdus()
 {
     var list = Stoc.GetAllGroupedByProdus();
 }