public bool Put(int id, [FromBody] Dispecer korisnik) { Dispeceri dispeceri = (Dispeceri)HttpContext.Current.Application["dispeceri"]; string path = "~/App_Data/Dispeceri.txt"; path = HostingEnvironment.MapPath(path); foreach (var item in dispeceri.dispecers) { if (item.Id == id) { item.KorisnickoIme = korisnik.KorisnickoIme; item.Lozinka = korisnik.Lozinka; item.Ime = korisnik.Ime; item.Prezime = korisnik.Prezime; item.JMBG = korisnik.JMBG; item.Pol = korisnik.Pol; item.Uloga = korisnik.Uloga; item.Telefon = korisnik.Telefon; item.Email = korisnik.Email; item.Voznja = korisnik.Voznja; StringBuilder sb = new StringBuilder(); sb.Append(item.Id + ";" + item.KorisnickoIme + ";" + item.Lozinka + ";" + item.Ime + ";" + item.Prezime + ";" + item.Pol + ";" + item.JMBG + ";" + item.Telefon + ";" + item.Email + ";" + item.Uloga + ";" + item.Voznja + "\n"); string[] arrLine = File.ReadAllLines(path); arrLine[item.Id - 1] = sb.ToString(); File.WriteAllLines(path, arrLine); File.WriteAllLines(path, File.ReadAllLines(path).Where(l => !string.IsNullOrWhiteSpace(l))); dispeceri = new Dispeceri("~/App_Data/Dispeceri.txt"); HttpContext.Current.Application["dispeceri"] = dispeceri; return(true); } } return(false); }
public static List <Korisnik> GetAdministratoreIzFajla(string fileName) { List <Korisnik> retVal = new List <Korisnik>(); using (StreamReader sr = new StreamReader(fileName)) { string line; while ((line = sr.ReadLine()) != null) { Dispecer novi = new Dispecer(); string[] info = line.Split(';'); novi.UserName = info[0]; novi.Password = info[1]; novi.Ime = info[2]; novi.Prezime = info[3]; novi.JMBG = info[4]; novi.Pol = info[5] == "M" ? Enums.Pol.MALE : Enums.Pol.FEMALE; novi.Telefon = info[6]; novi.Email = info[7]; retVal.Add(novi); } } return(retVal); }
public static void ReadFromTxt() { FileStream stream = new FileStream(@"C:\Users\Wicked Witch\source\repos\web-pr-48-2015\WebProjekat\App_Data\dispeceri.txt", FileMode.Open); StreamReader sr = new StreamReader(stream); string line = ""; while ((line = sr.ReadLine()) != null) { string[] tokens = line.Split(','); Enum.TryParse(tokens[4], out Pol pol); Dispecer d = new Dispecer(); d.IdKorisnik = Int32.Parse(tokens[0]); d.KorisnickoIme = tokens[1]; d.Lozinka = tokens[2]; d.Ime = tokens[3]; d.Prezime = tokens[4]; d.Pol = Int32.Parse(tokens[5]); d.Jmbg = Decimal.Parse(tokens[6]); d.KontaktTelefon = tokens[7]; d.Email = tokens[8]; DispeceriList.Add(d); } sr.Close(); stream.Close(); }
public List <Dispecer> IzcitajDispecereIzBaze() { string path = @"..\App_Data\BazaDispecera.txt"; List <Dispecer> izcitan = new List <Dispecer>(); FileStream stream = new FileStream(path, FileMode.Open); StreamReader sr = new StreamReader(stream); string line = ""; while ((line = sr.ReadLine()) != null) { string[] tokens = line.Split(';'); Enum.TryParse(tokens[5], out Pol pol); Enum.TryParse(tokens[9], out Uloga uloga); if (uloga == Uloga.dispecer) { Dispecer d = new Dispecer(Int32.Parse(tokens[0]), tokens[1], tokens[2], tokens[3], tokens[4], pol, tokens[6], tokens[7], tokens[8]); listaDispecera.Add(d); izcitan.Add(d); } } sr.Close(); stream.Close(); return(izcitan); }
public List <string> AddDriveDispecer([FromBody] VoznjaPomocna k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml"); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Voznje.xml"); string ss2 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml"); List <Dispecer> users = xml.ReadDispecer(ss); List <Voznja> drives = xml.ReadDrives(ss1); List <Vozac> vozaci = xml.ReadDrivers(ss2); bool g = true; Korisnik c = new Dispecer(); Voznja drive = new Voznja(); List <Tuple <Point, string> > prosledi = new List <Tuple <Point, string> >(); foreach (Vozac v in vozaci) { if (!v.Zauzet && v.Auto.TA == (Enums.TipAutomobila) int.Parse(k.tipAuta) && !v.Blokiran) { Point pos = new Point(Double.Parse(v.Lok.Xkoordinate), Double.Parse(v.Lok.Ykoordinate)); prosledi.Add(new Tuple <Point, string>(pos, v.KorisnickoIme)); } } NajkracaUdaljenost nk = new NajkracaUdaljenost(); List <string> ret = new List <string>(); if (!prosledi.Any()) { foreach (Dispecer u in users) { if (u.KorisnickoIme == k.korisnicko) { c = u; Adresa a = new Adresa(k.Street); Lokacija l = new Lokacija(k.XCoord, k.YCoord, a); drive.Mus = new Musterija(); drive.LokacijaZaDolazak = l; if (k.tipAuta != "") { drive.TipAuta = (Enums.TipAutomobila) int.Parse(k.tipAuta); } drive.Iznos = 0; drive.Kom = new Komentar(); drive.DatumIVremePorudzbine = String.Format("{0:F}", DateTime.Now);; drive.Odrediste = new Lokacija(); drive.Disp = (Dispecer)c; drive.Stat = Enums.StatusVoznje.Kreirana_NaCekanju; drive.Voz = new Vozac(); break; } } drives.Add(drive); xml.WriteDrives(drives, ss1); } else { ret = nk.OrderByDistance(prosledi, new Point(Double.Parse(k.XCoord), Double.Parse(k.YCoord))); } return(ret); }
// POST: api/Dispecer public HttpResponseMessage Post([FromBody]Dispecer dispecer) { string ime = dispecer.Ime; HttpResponseMessage mess = new HttpResponseMessage(); //mora postojati ako je izmjena podataka if (Korisnici.ListaDispecera.FirstOrDefault(d => dispecer.KorisnickoIme == d.KorisnickoIme)!=null) { int ind = Korisnici.ListaDispecera.IndexOf(Korisnici.ListaDispecera.FirstOrDefault(d => dispecer.KorisnickoIme == d.KorisnickoIme)); //ne postoji korisnicko ime do sad dispecer.Uloga = Uloge.Dispecer; dispecer.Voznje = Korisnici.ListaDispecera[ind].Voznje; Korisnici.ListaDispecera[ind]=dispecer; if (File.Exists(Korisnici.PutanjaDispeceri)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<Dispecer>)); using (StreamWriter writer = new StreamWriter(Korisnici.PutanjaDispeceri, false)) { xmlSerializer.Serialize(writer, Korisnici.ListaDispecera); } } System.Web.HttpContext.Current.Session["mojaSesija"] = dispecer; mess.StatusCode = HttpStatusCode.OK; return mess; } else { // postoji korisnicko ime vec mess.StatusCode = HttpStatusCode.NotAcceptable; return mess; } }
public JsonResult SetDispatcher(int id, string token, int idDisa) { if (Authorize.IsAllowedToAccess(token, TipNaloga.Vozac | TipNaloga.Dispecer)) { Voznja tmpV = MainStorage.Instanca.Voznje.FirstOrDefault(x => x.ID == id); if (tmpV != null) { Dispecer tmpDispecer = MainStorage.Instanca.Dispeceri.FirstOrDefault(x => x.ID == idDisa); if (tmpDispecer != null) { tmpV.DispecerID = idDisa; MainStorage.Instanca.UpdateVoznju(tmpV); return(Json("OK")); } else { return(Json("ERROR_DISPATCHER_ID_DOES_NOT_EXIST")); } } else { return(Json("ERROR_RIDE_ID_DOES_NOT_EXIST")); } } else { return(Helper.ForbidenAccessJson()); } }
public ActionResult Index(string filter, string sort) { Dispecer dispecer = Session["User"] as Dispecer; string filterMode = filter; var voz = from s in (HttpContext.Application["voznje"] as Dictionary <string, Voznja>).Values select s; if (filter != null) { voz = Helpers.Functions.GetFilteredData(voz, filter); } else { filter = ""; } if (sort != null) { voz = Helpers.Functions.GetSortedData(voz, sort); } else { sort = ""; } KorisnikVoznjeVM model = new KorisnikVoznjeVM() { Korisnik = dispecer, Voznje = voz, Status = filterMode, }; return(View("DispecerView", model)); }
public ActionResult UspesnaVoznja(string datumVoznje, string vozac, string musterija) { Korisnik k123 = (Korisnik)Session["korisnikUser"]; if (k123 == null) { k123 = new Korisnik(); Session["korisnikUser"] = k123; } foreach (Korisnik kor in Baza.registrovaniKorisnici.Values) { if (kor.username == k123.username && kor.uloga == Enumi.Uloga.VOZAC) { Voznja vo = new Voznja(); bool ret = false; if (musterija != "-") { ret = true; foreach (Voznja v in Baza.registrovaniKorisnici[musterija].voznje) { if (datumVoznje == v.datum.ToString()) { v.statusVoznje = Enumi.StatusVoznje.USPESNA; vo = v; AzurirajVoznju(vo, k123.username); } } } foreach (Voznja v in Baza.vozaci[vozac].voznje) { if (datumVoznje == v.datum.ToString()) { if (v.dispecer == null) { Dispecer d = new Dispecer("-", "-", "-", "-", Enumi.Pol.MUSKI, "-", "-", "-"); v.dispecer = d; AzurirajVoznju(v, k123.username); } v.statusVoznje = Enumi.StatusVoznje.USPESNA; if (!ret) { vo = v; AzurirajVoznju(vo, k123.username); } } } return(View("UspesnaVoznja", vo)); } } Greska o = new Greska("Doslo je do greske!"); return(View("Greska", o)); }
public void ChangeToFile(Dispecer k) { string path = HostingEnvironment.MapPath("~/App_Data/dispeceri.txt"); var file = File.ReadAllLines(path); file[k.Id] = k.Id + ";" + k.KorisnickoIme + ";" + k.Lozinka + ";" + k.Ime + ";" + k.Prezime + ";" + k.Pol + ";" + k.JMBG + ";" + k.Kontakt + ";" + k.Email + ";" + k.Uloga; File.WriteAllLines(path, file); }
public bool AdminLogged(Dispecer a, string pw) { if (a != null && pw == a.Kime) { return(true); } return(false); }
public HttpResponseMessage FormirajVoznju([FromBody] JToken jToken) { var lokacijastart = jToken.Value <string>("Ulica"); var broj = jToken.Value <int>("Broj"); var mesto = jToken.Value <string>("NaseljenoMesto"); var pozivniBroj = jToken.Value <int>("PozivniBroj"); var autoTip = jToken.Value <string>("TipVozila"); var usernameUlogovanog = jToken.Value <string>("Username"); if (lokacijastart == "" || mesto == "") { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } if (lokacijastart == null || mesto == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } Voznja v = new Voznja(); v.VremePorudzbine = DateTime.Now; v.ZeljeniTipAutomobila = (Enums.TipAutomobila)System.Enum.Parse(typeof(Enums.TipAutomobila), autoTip); Dispecer d = ListeKorisnika.Instanca.Dispeceri.Find(x => x.Username.Equals(usernameUlogovanog)); v.Dispecer = d.Username; v.StartLokacija.Adresa.Ulica = lokacijastart; v.StartLokacija.Adresa.Broj = broj; v.StartLokacija.Adresa.NaseljenoMesto = mesto; v.StartLokacija.Adresa.PozivniBrojMesta = pozivniBroj; v.IDVoznje = (ListeKorisnika.Instanca.Voznje.Count + 1); v.Status = Enums.StatusVoznje.Formirana; foreach (var item in ListeKorisnika.Instanca.Vozaci) { if (!item.Zauzet) { v.Vozac.Username = item.Username; break; } } if (v.Vozac.Username != null) { Vozac taj = ListeKorisnika.Instanca.Vozaci.Find(x => x.Username.Equals(v.Vozac.Username)); ListeKorisnika.Instanca.Vozaci.Remove(taj); taj.Zauzet = true; taj.Voznje.Add(v); ListeKorisnika.Instanca.Vozaci.Add(taj); ListeKorisnika.Instanca.Voznje.Add(v); return(Request.CreateResponse(HttpStatusCode.OK, v)); } else { return(Request.CreateResponse(HttpStatusCode.Conflict)); } }
public IHttpActionResult Post(Dispecer korisnik) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } UlogovaniKorisnici.Dispecer = new Dispecer(korisnik.KorisnickoIme, korisnik.Lozinka, korisnik.Ime, korisnik.Prezime, korisnik.Pol, korisnik.Jmbg, korisnik.KontaktTelefon, korisnik.Email, korisnik.Uloga); return(CreatedAtRoute("DefaultApi", new { korisnickoIme = korisnik.KorisnickoIme }, korisnik)); }
public bool DodajVoznjuDisp([FromBody] KonacnaVoznja k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml"); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Voznje.xml"); string ss2 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml"); List <Dispecer> users = xml.ReadDispecer(ss); List <Voznja> drives = xml.ReadDrives(ss1); List <Vozac> vozaci = xml.ReadDrivers(ss2); bool g = true; Korisnik c = new Dispecer(); Voznja drive = new Voznja(); foreach (Dispecer u in users) { if (u.KorisnickoIme == k.korisnickoImeAdmin) { c = u; Adresa a = new Adresa(k.voznja.Street); Lokacija l = new Lokacija(k.voznja.XCoord, k.voznja.YCoord, a); drive.Musterija = new Musterija(); drive.LokacijaDolaskaTaksija = l; if (k.voznja.tipAuta != "") { drive.ZeljeniAutomobil = (TipAutomobila)int.Parse(k.voznja.tipAuta); } drive.Iznos = 0; drive.Komentar = new Komentar(); drive.DatumPorudzbine = String.Format("{0:F}", DateTime.Now); drive.Odrediste = new Lokacija(); drive.DispecerFormirao = (Dispecer)c; drive.StatusVoznje = StatusVoznje.Formirana; } } foreach (Vozac v in vozaci) { if (v.KorisnickoIme == k.korisnickoImeVozac) { v.Zauzet = true; drive.VozacPrihvatio = v; break; } } drives.Add(drive); xml.WriteDrivers(vozaci, ss2); xml.WriteDrives(drives, ss1); return(true); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); string pom = ""; string[] res; Pol gender; if (File.Exists(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\Dispeceri.txt")) { StreamReader sr = new StreamReader(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\Dispeceri.txt"); while ((pom = sr.ReadLine()) != null) { res = pom.Split('_'); if (res[4] == "MUSKI") { gender = Pol.MUSKI; } else { gender = Pol.ZENSKI; } Dispecer d = new Dispecer(res[0], res[1], res[2], res[3], gender, res[5], res[6], res[7]); Database.registrovaniKorisnici.Add(res[0], d); } //OBRISI //Korisnik k = new Korisnik("petar", "petar", "Petar", "Varga", Pol.MUSKI, "1508996800056", "0695057788", "*****@*****.**"); //Database.registrovaniKorisnici.Add(k.korisnickoIme, k); //Korisnik k2 = new Korisnik("zarko", "dsa", "Zarko", "Mihajlovic", Pol.MUSKI, "1904997800054", "0645177899", "*****@*****.**"); //k2.uloga = Uloga.VOZAC; //Vozac v = new Vozac(k2, null, null); //Automobil a = new Automobil(v, "2011", "NS-053-ZJ", "1", TipAutomobila.PUTNICKI_AUTOMOBIL); //v.automobil = a; //a.vozac = v; //Database.registrovaniKorisnici.Add(k2.korisnickoIme, k2); //Database.vozaci.Add(v.korisnickoIme, v); //Database.slobodniVozaci.Add(v.korisnickoIme, v); //OVO!!!!!!!!!!! sr.Close(); UcitajBazu(); } }
public HttpResponseMessage Sortiraj(string usernameIflagovi) { string[] splitovano = usernameIflagovi.Split('_'); string username = splitovano[0]; int flag1 = Int32.Parse(splitovano[1]); int flag2 = Int32.Parse(splitovano[2]); int flag3 = Int32.Parse(splitovano[3]); List <Voznja> sortirane = new List <Voznja>(); Korisnik k = ListeKorisnika.Instanca.NadjiKorisnika(username); if (k.Uloga == Enums.Uloga.Musterija) { Musterija m = ListeKorisnika.Instanca.Musterije.Find(x => x.Username.Equals(username)); sortirane = m.Voznje; } else if (k.Uloga == Enums.Uloga.Vozac) { Vozac v = ListeKorisnika.Instanca.Vozaci.Find(x => x.Username.Equals(username)); sortirane = k.Voznje; } else { Dispecer d = ListeKorisnika.Instanca.Dispeceri.Find(x => x.Username.Equals(username)); if (flag3 == 0) { sortirane = d.Voznje; } else { sortirane = ListeKorisnika.Instanca.Voznje; } } if (flag1 == 1 && flag2 == 0) { sortirane = sortirane.OrderByDescending(x => x.VremePorudzbine).ToList(); } else if (flag1 == 0 && flag2 == 1) { sortirane = sortirane.OrderByDescending(x => x.Komentar.OcenaVoznje).ToList(); } else if (flag1 == 1 && flag2 == 1) { sortirane = sortirane.OrderByDescending(x => x.VremePorudzbine).ThenByDescending(x => x.Komentar.OcenaVoznje).ToList(); } else { } return(Request.CreateResponse(HttpStatusCode.OK, sortirane)); }
public Korisnik Get(string KorisnickoIme) { Dispecer k = null; foreach (Dispecer item in Dispeceri.list.Values) { if (KorisnickoIme.Equals(item.KorisnickoIme)) { k = item; break; } } return(k); }
public bool PostIzmena([FromBody] Dispecer dispecer) { Korisnik user = (Korisnik)HttpContext.Current.Session["user"]; if (user == null) { user = new Korisnik(); HttpContext.Current.Session["user"] = user; } Dispeceri users = (Dispeceri)HttpContext.Current.Application["dispeceri"]; foreach (var item in users.list) { if (dispecer.KorisnickoIme == item.KorisnickoIme) { item.Email = dispecer.Email; item.Ime = dispecer.Ime; item.JMBG = dispecer.JMBG; item.KontaktTelefon = dispecer.KontaktTelefon; item.Lozinka = dispecer.Lozinka; item.Pol = dispecer.Pol; item.Prezime = dispecer.Prezime; item.Uloga = Enums.Uloga.Dispecer; string path = "~/App_Data/Dispeceri.txt"; path = HostingEnvironment.MapPath(path); string line = item.Id.ToString() + ':' + item.KorisnickoIme + ':' + item.Lozinka + ':' + item.Ime + ':' + item.Prezime + ':' + item.Pol + ':' + item.JMBG + ':' + item.KontaktTelefon + ':' + item.Email + ':' + item.Uloga; string[] arrLine = File.ReadAllLines(path); arrLine[item.Id] = line; File.WriteAllLines(path, arrLine); Dispeceri dispeceri2 = new Dispeceri("~/App_Data/Dispeceri.txt"); HttpContext.Current.Application["dispeceri"] = dispeceri2; return(true); } } return(false); }
private void UpisIzmjenaDispTxt(Dispecer k) { string[] lines = System.IO.File.ReadAllLines(@"C:\Users\user\Desktop\WebTaxi\WebAPI\WebAPI\App_Data\Dispeceri.txt"); string allString = ""; for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains(k.Id.ToString())) { allString += k.Id.ToString() + '|' + k.KorisnickoIme + '|' + k.Lozinka + '|' + k.Ime + '|' + k.Prezime + '|' + k.Pol + '|' + k.JMBG + '|' + k.KontaktTelefon + '|' + k.Email + '|' + k.Uloga; lines[i] = allString; } } System.IO.File.WriteAllLines(@"C:\Users\user\Desktop\WebTaxi\WebAPI\WebAPI\App_Data\Dispeceri.txt", lines); }
// PUT api/Dispecer/1 edit public bool Put(int id, [FromBody] Dispecer dispecer) { foreach (Dispecer d in Dispeceri.dispeceri.Values) { if (d.Id == id) { Dispeceri.dispeceri.Remove(d.Id); Dispecer disp = new Dispecer(dispecer.Id, dispecer.KorisnickoIme, dispecer.Lozinka, dispecer.Ime, dispecer.Prezime, dispecer.Pol, dispecer.JMBG, dispecer.KontaktTelefon, dispecer.Email, dispecer.Uloga); Dispeceri.dispeceri.Add(disp.Id, disp); UpisIzmenaDispTxt(dispecer); return(true); } } return(false); }
// PUT api/korisnik/5 public bool Put(int id, [FromBody] Dispecer korisnik) { foreach (Dispecer kor in Dispeceri.dispeceri.Values) { if (kor.Id == id) { Dispeceri.dispeceri.Remove(kor.Id); Dispecer d = new Dispecer(korisnik.Id, korisnik.KorisnickoIme, korisnik.Lozinka, korisnik.Ime, korisnik.Prezime, korisnik.Pol, korisnik.JMBG, korisnik.KontaktTelefon, korisnik.Email, korisnik.Uloga); Dispeceri.dispeceri.Add(d.Id, d); UpisIzmjenaDispTxt(korisnik); return(true); } } return(false); }
private void UpisIzmenaDispTxt(Dispecer k) { string path = System.Web.Hosting.HostingEnvironment.MapPath(@"~/App_Data/Dispeceri.txt"); string[] lines = System.IO.File.ReadAllLines(path); string allString = ""; for (int i = 0; i < lines.Length; i++) { if (lines[i].Contains(k.Id.ToString())) { allString += k.Id.ToString() + '|' + k.KorisnickoIme + '|' + k.Lozinka + '|' + k.Ime + '|' + k.Prezime + '|' + k.Pol + '|' + k.JMBG + '|' + k.KontaktTelefon + '|' + k.Email + '|' + k.Uloga; lines[i] = allString; } } System.IO.File.WriteAllLines(path, lines); }
public static Dispecer Dispecer(SqlDataReader reader) { Dispecer dispecer = new Dispecer { Id = (int)reader["id_vozac"], KorisnickoIme = (string)reader["korisnicko_ime"], Lozinka = (string)reader["lozinka"], Ime = (string)reader["ime"], Prezime = (string)reader["prezime"], JMBG = (decimal)reader["jmbg"], Email = (string)reader["email"], KontaktTelefon = (string)reader["kontakt_telefon"], Pol = (Enums.Pol)((int)reader["pol"]) }; return(dispecer); }
public bool ObradiVoznjuDisp([FromBody] KonacnaVoznjaDisp k) { string ss = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml"); string ss1 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Voznje.xml"); string ss2 = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml"); List <Dispecer> users = xml.ReadDispecer(ss); List <Voznja> drives = xml.ReadDrives(ss1); List <Vozac> vozaci = xml.ReadDrivers(ss2); Dispecer c = new Dispecer(); Vozac vozac = new Vozac(); Voznja voznja = new Voznja(); foreach (Dispecer u in users) { if (u.KorisnickoIme == k.korisnickoImeAdmin) { c = u; } } foreach (Vozac v in vozaci) { if (v.KorisnickoIme == k.korisnickoImeVozac) { v.Zauzet = true; vozac = v; break; } } foreach (Voznja vo in drives) { if (DateTime.Parse(vo.DatumIVremePorudzbine) == DateTime.Parse(k.voznja.DatumIVremePorudzbine) && (vo.Mus.KorisnickoIme == k.voznja.Mus.KorisnickoIme || vo.Disp.KorisnickoIme == k.voznja.Disp.KorisnickoIme)) { vo.Voz = vozac; vo.Disp = c; vo.Stat = Enums.StatusVoznje.Obradjena; } } xml.WriteDrivers(vozaci, ss2); xml.WriteDrives(drives, ss1); return(true); }
public ActionResult IzmeniPodatke(string ime, string prezime, string pol, string korisnickoIme, string lozinka, string jmbg, string brojTelefona, string email) { Dispecer dispecer = new Dispecer(); Pol p = Pol.MUSKI; if (pol == "MUSKI") { p = Pol.MUSKI; } else if (pol == "ZENSKI") { p = Pol.ZENSKI; } foreach (Dispecer d in Korisnici.ListaDispecera) { if (d.KorisnickoIme == korisnickoIme) { d.Ime = ime; d.Prezime = prezime; d.Pol = p; d.Lozinka = lozinka; d.Jmbg = jmbg; d.KontaktTelefon = brojTelefona; d.Email = email; dispecer = d; } } foreach (Korisnik k in Korisnici.ListaKorisnika) { if (k.KorisnickoIme == dispecer.KorisnickoIme) { k.Ime = ime; k.Prezime = prezime; k.Pol = p; k.Lozinka = lozinka; k.Jmbg = jmbg; k.KontaktTelefon = brojTelefona; k.Email = email; } } return(View("PrikazDispecera", dispecer)); }
public HttpResponseMessage PretraziPoVozacu() { var jToken = JToken.Parse(Request.RequestUri.ToString().Split('?').Last()); var usernameDispecera = jToken.Value <string>("usernameDispecera"); var ime = jToken.Value <string>("ime"); var prezime = jToken.Value <string>("prezime"); var flag = jToken.Value <int>("flag"); List <Voznja> rezultatPretrage = new List <Voznja>(); Dispecer d = ListeKorisnika.Instanca.Dispeceri.Find(x => x.Username.Equals(usernameDispecera)); List <Voznja> voznje = new List <Voznja>(); if (flag == 0) { voznje = d.Voznje; } else { voznje = ListeKorisnika.Instanca.Voznje; } if (ime != "" || prezime != "") { foreach (var item in voznje) { if (item.Vozac != null) { Vozac voz = ListeKorisnika.Instanca.Vozaci.Find(x => x.Username.Equals(item.Vozac.Username)); if (voz.Ime.Equals(ime) || voz.Prezime.Equals(prezime)) { rezultatPretrage.Add(item); } } } } if (rezultatPretrage.Count != 0) { return(Request.CreateResponse(HttpStatusCode.OK, rezultatPretrage)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
public ActionResult VoznjaObradjena(Voznja v) { Voznja updated = (HttpContext.Application["voznje"] as Dictionary <string, Voznja>)[v.ID]; Vozac vozac = ((HttpContext.Application["korisnici"] as Dictionary <string, Korisnik>)[v.Vozac.UserName] as Vozac); vozac.Voznje.Add(updated); updated.Vozac = v.Vozac; Helpers.Functions.ZauzmiVozaca(v.Vozac.UserName); updated.Status = Enums.StatusVoznje.OBRADJENA; Dispecer disp = Session["User"] as Dispecer; updated.Dispecer = disp; disp.Voznje.Add(updated); return(RedirectToAction("Index")); }
public ActionResult FormiranaVoznja(Voznja voznja) { voznja.DatumIVreme = DateTime.Now; voznja.ID = voznja.DatumIVreme.GetHashCode().ToString(); voznja.Status = Enums.StatusVoznje.FORMIRANA; Dispecer disp = Session["User"] as Dispecer; voznja.Dispecer = disp; disp.Voznje.Add(voznja); Vozac vozac = ((HttpContext.Application["korisnici"] as Dictionary <string, Korisnik>)[voznja.Vozac.UserName] as Vozac); vozac.Voznje.Add(voznja); Helpers.Functions.ZauzmiVozaca(vozac.UserName); Dictionary <string, Voznja> voznje = HttpContext.Application["voznje"] as Dictionary <string, Voznja>; voznje.Add(voznja.ID, voznja); return(RedirectToAction("Index")); }
public void UcitajKorisnikauBazu(Dispecer k) { string path = @"..\App_Data\BazaDispecera.txt"; StringBuilder sb = new StringBuilder(); sb.Append(k.Id).Append(";").Append(k.KorisnickoIme).Append(k.Lozinka).Append(";").Append(";").Append(k.Ime).Append(";").Append(k.Prezime).Append(";").Append(k.PolKorisnika).Append(";").Append(k.Jmbg).Append(";").Append(k.KontaktTelefon).Append(";").Append(k.Email).Append(";").Append(k.UlogaKorisnika).Append(";\n"); // Add text to the file. if (!File.Exists(path)) { File.WriteAllText(path, sb.ToString()); } else { File.AppendAllText(path, sb.ToString()); } // Open the file to read from. string readText = File.ReadAllText(path); Console.WriteLine(readText); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); string pom = ""; string[] res; Enumi.Pol gender; if (File.Exists($"{HttpRuntime.AppDomainAppPath}\\App_Data\\Dispeceri.txt")) { StreamReader sr = new StreamReader($"{HttpRuntime.AppDomainAppPath }\\App_Data\\Dispeceri.txt"); while ((pom = sr.ReadLine()) != null) { res = pom.Split('_'); if (res[4] == "MUSKI") { gender = Enumi.Pol.MUSKI; } else { gender = Enumi.Pol.ZENSKI; } Dispecer d = new Dispecer(res[0], res[1], res[2], res[3], gender, res[5], res[6], res[7]); Baza.registrovaniKorisnici.Add(res[0], d); } sr.Close(); UcitajBazu(); } }