public List <Eveniment> IncarcaListaDeEvenimente() { // List<string> marca = new List<string>(); List <Eveniment> e = new List <Eveniment>(); List <Masina> masina = new List <Masina>(); using (var cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename" + @"='C:\Users\Andrei\Documents\GitHub\pssc-proiect\IterfataUtilizator\App_Data\Users.mdf';Integrated Security=True")) { string _sql = @"SELECT * FROM [dbo].[ParcAuto] "; var cmd = new SqlCommand(_sql, cn); cn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string[] tokens = reader["DetaliiEveniment"].ToString().Split('"'); // marca.Add(tokens[13]); string tip = Regex.Match(tokens[8], @"\d+").Value; Masina m = new Masina(new PlainText(tokens[5]), (TipMasina)Enum.Parse(typeof(TipMasina), tip), new PlainText(tokens[13]), new PlainText(tokens[67]), new PlainText(tokens[19]), new PlainText(tokens[61]), new PlainText(tokens[25]), new PlainText(tokens[37]), new PlainText(tokens[51]), new PlainText(tokens[49]), new PlainText(tokens[43]), new PlainText(tokens[31])); string stare = Regex.Match(tokens[70], @"\d+").Value; //object detalii = JsonConvert.DeserializeObject<MasinaDes.RootObject>(reader["DetaliiEveniment"].ToString()); // object detalii = JsonConvert.DeserializeObject<List<Eveniment>>(String.Format("{0}", reader["DetaliiEveniment"])); m.stare = (StareMasina)Enum.Parse(typeof(StareMasina), stare); Eveniment ev = new Eveniment(new PlainText(reader["IdRadacina"].ToString()), (TipEveniment)Enum.Parse(typeof(TipEveniment), reader["TipEveniment"].ToString()), m); e.Add(ev); } } } return(e); }
public bool Trimite(Eveniment e) { var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); string message = e.Tip.ToString(); var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body); Console.WriteLine(" [x] Sent {0}", message); } Console.WriteLine(" Press [enter] to exit."); return(true); }
public ActionResult Create([Bind(Include = "ID_NumeEveniment,ID_NumeResursa,NumarZile,ID_Data,Ora,ID_TipPlata")] Eveniment eveniment, string[] selectedMembrii) { //if (eveniment.ID_NumeResursa == "Disponibil") // { // if (ModelState.IsValid) // { // string test = eveniment.ID_NumeResursa; // if (eveniment.Resurse.ID_Status == "Disponibil") // { if (selectedMembrii != null) { eveniment.Membriis = new List <Membrii>(); foreach (var membru in selectedMembrii) { var membruToAdd = db.Membriis.Find(membru); eveniment.Membriis.Add(membruToAdd); } } if (ModelState.IsValid) { db.Eveniments.Add(eveniment); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_TipPlata = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie", eveniment.ID_TipPlata); ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa", eveniment.ID_NumeResursa); PopulateAssignedMembriiDaa(eveniment); return(View(eveniment)); }
public static void Citeste() { string line = null; while ((line = sr.ReadLine()) != null) { string[] s = line.Split(';'); string idRadacina = s[0]; TipEveniment t; if (s[1] == "ImprumutareCarte") { t = TipEveniment.ImprumutareCarte; } else if (s[1] == "PrelungireTermen") { t = TipEveniment.PrelungireTermen; } else if (s[1] == "RestituireCarte") { t = TipEveniment.RestituireCarte; } else { t = TipEveniment.RezervareCarte; } string detalii = s[2]; Eveniment e = new Eveniment(idRadacina, t, detalii); events.Add(e); } sr.Close(); }
public void SalvareEvenimente(Eveniment evenimenteNoi) { string detalii = JsonConvert.SerializeObject(evenimenteNoi.Detalii); var tipEveniment = evenimenteNoi.Tip; var idEveniment = evenimenteNoi.Id.ToString(); var idRadacina = evenimenteNoi.IdRadacina.ToString(); }
public void SalvareEvenimente(Eveniment evenimenteNoi) { string detalii = JsonConvert.SerializeObject(evenimenteNoi.Detalii); var tipEveniment = evenimenteNoi.Tip; var idEveniment = evenimenteNoi.Id.ToString(); var idRadacina = evenimenteNoi.IdRadacina.ToString(); using (var cn = new SqlConnection(connection)) { string _sql = @"INSERT INTO [dbo].[CatalogProduse](IdEveniment,TipEveniment,DetaliiEveniment,IdRadacina)" + "VALUES (@idEveniment,@tipEveniment,@detalii,@IdRadacina)"; var cmd = new SqlCommand(_sql, cn); cmd.Parameters .Add(new SqlParameter("@idEveniment", SqlDbType.VarChar)) .Value = idEveniment; cmd.Parameters .Add(new SqlParameter("@tipEveniment", SqlDbType.VarChar)) .Value = tipEveniment; cmd.Parameters .Add(new SqlParameter("@detalii", SqlDbType.VarChar)) .Value = detalii; cmd.Parameters .Add(new SqlParameter("@IdRadacina", SqlDbType.VarChar)) .Value = idRadacina; cn.Open(); var reader = cmd.ExecuteReader(); } }
public static Eveniment Eveniment(string caleEveniment) { Eveniment e = new Eveniment(); if (File.Exists(CaleFisierInfoEveniment(caleEveniment))) { string[] linii = File.ReadAllLines(CaleFisierInfoEveniment(caleEveniment)); e.Id = int.Parse(linii[0]); e.Stare = linii[1]; e.Nume_Firma = linii[2]; e.Denumire = linii[3]; e.Tip = linii[4]; e.Data_Eveniment = DateTime.Parse(linii[5]); e.Note = ""; for (int i = 6; i < linii.Length; i++) { e.Note += linii[i]; e.Note += "\r\n"; } } e.Cai_Documente = new List <string>(); e.Cai_Documente = Directory.GetFiles(CaleDocumenteEveniment(caleEveniment)).ToList(); return(e); }
protected void PublicaEveniment(Eveniment eveniment) { _evenimenteNoi.Add(eveniment); if (EvenimentMeci != null) { EvenimentMeci(this, eveniment); } }
protected void PublicaEveniment(Eveniment eveniment) { _evenimenteNoi.Add(eveniment); if (EvenimentInscriere != null) { EvenimentInscriere(this, eveniment); } }
public ActionResult DeleteConfirmed(string id) { Eveniment eveniment = db.Eveniments.Find(id); db.Eveniments.Remove(eveniment); db.SaveChanges(); return(RedirectToAction("Index")); }
protected void PublicaEveniment(Eveniment eveniment) { events.Add(eveniment); if (Eveniment != null) { Eveniment(this, eveniment); } }
//Citeste un fisier XML si returneaza o lista de structuri Eveniment //Parametrii: //- numeFisier (string) = numele fisierului XML din care citesc public static List<Eveniment> citesteEvenimente(string numeFisier) { List<Eveniment> lista = new List<Eveniment>(); if (File.Exists(numeFisier) == true) { XmlDocument fisierXML = new XmlDocument(); fisierXML.Load(numeFisier); XmlNode root = fisierXML.SelectSingleNode("evenimente"); foreach (XmlNode elem in root.SelectNodes("eveniment")) { Eveniment ev = new Eveniment(); ev.id = Convert.ToInt32(elem.Attributes["id"].Value); ev.data = Convert.ToDateTime(elem.Attributes["data"].Value); switch (elem.Attributes["perioada"].Value) { case "Lunar": ev.perioada = PerioadaEveniment.Lunar; break; case "Saptamanal": ev.perioada = PerioadaEveniment.Saptamanal; break; case "OdataLaXZile": ev.perioada = PerioadaEveniment.OdataLaXZile; ev.xZile = Convert.ToInt32(elem.Attributes["xZile"].Value); break; case "AltTip": ev.perioada = PerioadaEveniment.AltTip; break; } switch (elem.Attributes["tipEveniment"].Value) { case "Cheltuiala": ev.tipEveniment = TipEveniment.Cheltuiala; break; case "Venit": ev.tipEveniment = TipEveniment.Venit; break; } ev.suma = Convert.ToInt32(elem.Attributes["suma"].Value); ev.detalii = elem.InnerText; lista.Add(ev); } } //else //MessageBox.Show("Fisierul " + numeFisier + " nu exista."); return lista; }
// GET: /Eveniment/Create public ActionResult Create() { var eveniment = new Eveniment(); eveniment.Membriis = new List <Membrii>(); PopulateAssignedMembriiDaa(eveniment); ViewBag.ID_TipPlata = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie"); ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa"); return(View()); }
public static async void Write(Eveniment e) { sr = new StreamReader("C:\\Users\\Cosmina\\Desktop\\PSSC-master\\Biblioteca\\evenimente.txt"); string s; s = sr.ReadToEnd(); sr.Close(); sw = new StreamWriter("C:\\Users\\Cosmina\\Desktop\\PSSC-master\\Biblioteca\\evenimente.txt"); sw.Write(s); sw.WriteLine(e.ToString()); sw.Close(); }
public ActionResult Edit([Bind(Include = "ID_NumeEveniment,ID_NumeResursa,NumarZile,ID_Data,Ora,ID_TipPlata")] Eveniment eveniment) { if (ModelState.IsValid) { db.Entry(eveniment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID_TipPlata = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie", eveniment.ID_TipPlata); ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa", eveniment.ID_NumeResursa); return(View(eveniment)); }
protected void PublicaEveniment(Eveniment eveniment) { _evenimenteNoi.Add(eveniment); //EvenimentMeci?.Invoke(this, eveniment); if (_magistralaEveniment != null) { _magistralaEveniment.Trimite(eveniment); } else { MagistralaEvenimente.Instanta.Value.Trimite(eveniment); } }
// GET: /Eveniment/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Eveniment eveniment = db.Eveniments.Find(id); if (eveniment == null) { return(HttpNotFound()); } return(View(eveniment)); }
public override Carte Proceseaza(ComandaRestituieCarte comanda) { for (int i = 0; i < MagistralaEvenimente.CartiUser.Count; i++) { if (MagistralaEvenimente.CartiUser[i].Titlu == comanda.Titlu) { MagistralaEvenimente.CartiUser.RemoveAt(i); } } Eveniment e = new Eveniment("0", TipEveniment.RestituireCarte, comanda.Titlu); SalvareEveniment.Write(e); return(null); }
// GET: /Eveniment/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Eveniment eveniment = db.Eveniments.Find(id); if (eveniment == null) { return(HttpNotFound()); } ViewBag.ID_TipPlata = new SelectList(db.Functies, "ID_NumeFunctie", "ID_NumeFunctie", eveniment.ID_TipPlata); ViewBag.ID_NumeResursa = new SelectList(db.Resurses, "ID_NumeResursa", "ID_NumeResursa", eveniment.ID_NumeResursa); return(View(eveniment)); }
private void PopulateAssignedMembriiDaa(Eveniment eveniment) { var allMembrii = db.Membriis; var evenimentMembru = new HashSet <string>(eveniment.Membriis.Select(c => c.ID_Username)); var viewModel = new List <AssignedMembriiDaa>(); foreach (var membru in allMembrii) { viewModel.Add(new AssignedMembriiDaa { ID_Username = membru.ID_Username, Assigned = evenimentMembru.Contains(membru.ID_Username) }); } ViewBag.Membrii = viewModel; }
public override Carte Proceseaza(ComandaRezervaCarte comanda) { Carte c = null; ProcesatorCautaCarte p = new ProcesatorCautaCarte(); ComandaCautaCarte cmd = new ComandaCautaCarte(); cmd.Titlu = comanda.Titlu; c = p.Proceseaza(cmd); c.Stare = StareCarte.Rezervata; MagistralaEvenimente.CartiUser.Add(c); Eveniment e = new Eveniment(c.Id.ToString(), TipEveniment.RezervareCarte, c.Titlu); SalvareEveniment.Write(e); return(null); }
public override Carte Proceseaza(ComandaImprumutaCarte comanda) { Carte c = null; ProcesatorCautaCarte p = new ProcesatorCautaCarte(); ComandaCautaCarte cmd = new ComandaCautaCarte(); cmd.Titlu = comanda.Titlu; c = p.Proceseaza(cmd); c.Stare = StareCarte.Imprumutata; c.DataImprumut = DateTime.Now; MagistralaEvenimente.CartiUser.Add(c); Eveniment e = new Eveniment(c.Id.ToString(), TipEveniment.ImprumutareCarte, c.Titlu); SalvareEveniment.Write(e); return(null); // trebuie verificat daca cartea e deja imprumutata }
static void Main(string[] args) { Eveniment ev = new Eveniment(); //crearea instantelor A a = new A(); B b = new B(); //adaugam rutinele de tratare la lisa de evenimente ev.activat += new DelegatTratareEveniment(handler); ev.activat += new DelegatTratareEveniment(a.AHandler); ev.activat += new DelegatTratareEveniment(b.BHandler); ev.Actiune(); //lansam evenimentul ev.activat -= new DelegatTratareEveniment(a.AHandler); //eliminarea unei rutine de tratare }
public void TrimiteEveniment(Eveniment e) { var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null); string message = JsonConvert.SerializeObject(e.Detalii).ToString(); var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body); // Console.WriteLine(" [x] Sent {0}", message); } }
public ActionResult AddEvents([DataSourceRequest] DataSourceRequest request, Events ev)//adaugare in tabela eveniment { if (ModelState.IsValid) { try { var evt = new Eveniment { Denumire = ev.Denumire, Data_Start = ev.Data_Start, Data_Sfarsit = ev.Data_Sfarsit, Activ = false, Id_MO = 2 }; pl.Eveniments.Add(evt); pl.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { ViewData["error"] = ex.Message; } finally { pl.Dispose(); } } else//daca modelul nu este vaid, vedem ce problema a aparut { var message = string.Join(" | ", ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, message)); } return(RedirectToAction("Index")); }
public void SalvareEvenimente(Eveniment evenimenteNoi) { string id = evenimenteNoi.Id.ToString(); string detalii = JsonConvert.SerializeObject(evenimenteNoi); var tipEveniment = evenimenteNoi.Tip; var idRadacina = evenimenteNoi.IdRadacina.ToString(); using (var con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename" + @"='C:\Users\Bianca\Documents\Proiectarea sistemelor software complexe\Proiect\Proiect\" + @"WebMvcLibrarie\App_Data\DatabaseCarti.mdf';Integrated Security=True")) { string sql = @"INSERT INTO [dbo].[Evenimente] VALUES (@id,@detalii,@tipEveniment,@idRad)"; var cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@detalii", detalii); cmd.Parameters.AddWithValue("@tipEveniment", tipEveniment.ToString()); cmd.Parameters.AddWithValue("@idRad", idRadacina); con.Open(); int nrinreg = cmd.ExecuteNonQuery(); } }
public override Carte Proceseaza(ComandaPrelungireTermen comanda) { Carte c = null; ProcesatorCautaCarte p = new ProcesatorCautaCarte(); ComandaCautaCarte cmd = new ComandaCautaCarte(); cmd.Titlu = comanda.Titlu; c = p.Proceseaza(cmd); c.Termen = c.Termen + 2; for (int i = 0; i < MagistralaEvenimente.CartiUser.Count; i++) { if (MagistralaEvenimente.CartiUser[i].Titlu == comanda.Titlu) { MagistralaEvenimente.CartiUser[i] = c; } } Eveniment e = new Eveniment(c.Id.ToString(), TipEveniment.PrelungireTermen, c.Titlu); SalvareEveniment.Write(e); return(null); }
public void SalvareEvenimente(Eveniment evenimentNoi) { // List<Eveniment> toateEvenimentele = IncarcaListaDeEvenimente(); // toateEvenimentele.AddRange(evenimentNoi); string detalii = JsonConvert.SerializeObject(evenimentNoi.Detalii); var tipEveniment = evenimentNoi.Tip; // detalii = var IdRadacina = evenimentNoi.IdRadacina.Id; var IdEveniment = evenimentNoi.Id.Id; ///Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Paul\Documents\GitHub\ProjectsAn4\AtelierAuto\AtelierAuto\App_Data\MecanicDatabase.mdf;Integrated Security=True using (var cn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename" + @"='C:\Users\Paul\Documents\GitHub\ProjectsAn4\AtelierAuto\AtelierAuto\App_Data\MecanicDatabase.mdf';Integrated Security=True")) //incerc si fara ' { string _sql = @"INSERT INTO [dbo].[Comanda](IdEveniment,TipEveniment,DetaliiEveniment,IdRadacina)" + "VALUES (@IdEveniment,@tipEveniment,@detalii,@IdRadacina)"; var cmd = new SqlCommand(_sql, cn); cmd.Parameters .Add(new SqlParameter("@tipEveniment", SqlDbType.VarChar)) .Value = tipEveniment; cmd.Parameters .Add(new SqlParameter("@detalii", SqlDbType.VarChar)) .Value = detalii; cmd.Parameters .Add(new SqlParameter("@IdRadacina", SqlDbType.VarChar)) .Value = IdRadacina; cmd.Parameters .Add(new SqlParameter("@IdEveniment", SqlDbType.VarChar)) .Value = IdRadacina; cn.Open(); var reader = cmd.ExecuteReader(); TrimiteNotificareaLaMecanic(); //RABBIT MQ //scrie in baza de date evenimentele// sau in fisier : scrie - continut - fisier } }
private void RedaEveniment(Eveniment e) { switch (e.Tip) { case TipEveniment.AdaugareCarte: AplicaAdaug(e.ToGeneric <Carte>()); break; case TipEveniment.CumparareCarte: AplicaCumpar(e.ToGeneric <Carte>()); break; case TipEveniment.ImprumutareCarte: AplicaImprumut(e.ToGeneric <Carte>()); break; case TipEveniment.RestituireCarte: AplicaRestituie(e.ToGeneric <Carte>()); break; default: throw new EvenimentNecunoscutExceptie(); } }
public void StergeEvenimente(Eveniment evenimenteNoi) { }
public void ActualizareEvenimente(Eveniment evenimenteNoi) { }
private Eveniment citesteEveniment(int id) { Eveniment ev = new Eveniment(); ev.id = id; ev.data = dtpData.Value; double sumaOut; if (!Double.TryParse(txtSuma.Text, out sumaOut)) { throw new InvalidEvenimentException("Suma lipseste sau este intr-un format incorect!"); } ev.suma = sumaOut; if (cmbPerioada.SelectedItem == null) { throw new InvalidEvenimentException("Tip perioada neselectat!"); } switch (cmbPerioada.SelectedItem.ToString()) { case "Lunar": ev.perioada = PerioadaEveniment.Lunar; break; case "Saptamanal": ev.perioada = PerioadaEveniment.Saptamanal; break; case "Odata la n zile": ev.perioada = PerioadaEveniment.OdataLaXZile; int xZileOut; if (!int.TryParse(txtOdataLa.Text, out xZileOut)) { throw new InvalidEvenimentException("Format incorect numar zile"); } ev.xZile = xZileOut; break; case "Alt tip": ev.perioada = PerioadaEveniment.AltTip; break; default: throw new Exception("Alegeti o perioada"); } if (cmbTipEveniment.SelectedItem == null) { throw new InvalidEvenimentException("Tip eveniment neselectat!"); } switch (cmbTipEveniment.SelectedItem.ToString()) { case "Cheltuiala": ev.tipEveniment = TipEveniment.Cheltuiala; break; case "Venit": ev.tipEveniment = TipEveniment.Venit; break; } ev.detalii = txtDetalii.Text; return ev; }