static void Main(string[] args) { Console.WriteLine("################### TESTING API ####################"); string api_session; auth _auth = new auth(); string conference_url = "https://openstacksummitoctober2015tokyo.sched.org"; string api_key = "47dfbdc49d82ff16669df259952656fa"; api_session = _auth.login(conference_url, api_key); Console.WriteLine("Session Value: " + api_session); sessions _sessions = new sessions(); foreach (Session s in _sessions.all(conference_url, api_key)) { Console.WriteLine("Title: " + s.name); Console.WriteLine("Description: " + s.description); } Console.ReadLine(); }
public async Task <ActionResult> DeleteConfirmed(int id) { sessions sessions = await db.session.FindAsync(id); db.session.Remove(sessions); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create([Bind(Include = "Id,date_of_session,filmname,time_of_session,hallname,hallId,filmId,price_of_tickets")] sessions sessions) { if (ModelState.IsValid) { var film = db.films.Where(c => c.Id == sessions.filmId).FirstOrDefault(); if (DateTime.Parse(sessions.date_of_session) >= DateTime.Parse(film.release_date)) { string todaydate = DateTime.Today.ToString("yyyy.MM.dd"); int dd = DateTime.Parse(todaydate).CompareTo(DateTime.Parse(sessions.date_of_session)); if (dd <= 0) { db.session.Add(sessions); await db.SaveChangesAsync(); hall current_hall = db.halls .Where(d => d.Id == sessions.hallId).FirstOrDefault(); film current_film = db.films .Where(d => d.Id == sessions.filmId).FirstOrDefault(); int number_rows = current_hall.number_of_rows; int number_seats = current_hall.number_of_seats_in_a_row; for (int i = 1; i < number_rows + 1; i++) { for (int j = 1; j < number_seats + 1; j++) { places place = new places(); { place.sessionsId = sessions.Id; place.number_of_row = i; place.number_of_seat_in_a_row = j; place.status = "Свободно"; //place.date_of_operation = DateTime.Now; }; db.places_list.Add(place); await db.SaveChangesAsync(); } } return(RedirectToAction("Index")); } else { ModelState.AddModelError("date_of_session", "Неверная дата начала сеанса. Введите коррекную дату(Нельзя задать прошедший день)"); } } else { ModelState.AddModelError("date_of_session", "Неверная дата начала сеанса. Введите коррекную дату(позднее даты релиза фильма)"); } } ViewBag.filmId = new SelectList(db.films, "Id", "film_name", sessions.filmId); ViewBag.hallId = new SelectList(db.halls, "Id", "hall_name", sessions.hallId); return(View(sessions)); }
//Peek into a running stopwatch public long PeekSession(sessions session) { Stopwatch stopwatch = stopWatches[(int)session]; if (stopwatch.IsRunning) { return(stopwatch.ElapsedMilliseconds); } else { return(-1); } }
public async Task <ActionResult> Edit([Bind(Include = "Id,date_of_session,filmname,time_of_session,hallname,hallId,filmId,price_of_tickets")] sessions sessions) { if (ModelState.IsValid) { db.Entry(sessions).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.filmId = new SelectList(db.films, "Id", "film_name", sessions.filmId); ViewBag.hallId = new SelectList(db.halls, "Id", "hall_name", sessions.hallId); return(View(sessions)); }
public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sessions sessions = await db.session.FindAsync(id); var film = db.films.Where(c => c.Id == sessions.filmId).FirstOrDefault(); ViewBag.film_name = film.film_name; var hall = db.halls.Where(c => c.Id == sessions.hallId).FirstOrDefault(); ViewBag.hall_name = hall.hall_name; if (sessions == null) { return(HttpNotFound()); } return(View(sessions)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } sessions sessions = await db.session.FindAsync(id); if (sessions == null) { return(HttpNotFound()); } SelectList films = new SelectList(db.films, "Id", "film_name"); ViewBag.films = films; SelectList halls = new SelectList(db.halls, "Id", "hall_name"); ViewBag.halls = halls; return(View(sessions)); }
//Stop a specific session public long StopSession(sessions session) { return(StopStopWatch(stopWatches[(int)session])); }
//Start a specific session public void StartSession(sessions session) { StartStopWatch(stopWatches[(int)session]); }
static void Main(string[] args) { schedInterface.auth _auth = new auth(); schedInterface.openstackEvents _events = new openstackEvents(); schedInterface.osettings _settings = new osettings(); schedInterface.events _eventsDB = new events(); functions _functions = new functions(); olocations _olocations = new olocations(); locations _locations = new locations(); osessions _osessions = new osessions(); sessions _sessions = new sessions(); speakers _speakers = new speakers(); event_types _types = new event_types(); Console.WriteLine("Begin Process..."); //Console.WriteLine("Getting Authorization..."); //Console.WriteLine(_auth.auth_justin(_settings.client_id(), _settings.client_secret())); //Console.ReadLine(); List <OpenStackEvent> evs = _events.push_events(); Console.WriteLine("Event Count:" + evs.Count.ToString()); foreach (OpenStackEvent ev in evs) { Console.WriteLine(ev.name); if (ev.active) { schedInterface.Event e = new Event(); e.event_end = _functions.ConvertUnixTimeStamp(ev.end_date.ToString()); e.event_start = _functions.ConvertUnixTimeStamp(ev.start_date.ToString()); e.interval = 5; e.last_update = DateTime.Now; e.openstack_id = ev.id; e.title = ev.name; if (e.event_start != null) { if (Convert.ToDateTime(e.event_end) > DateTime.Now) { e.offset = ev.time_zone.offset != null?Convert.ToInt32(ev.time_zone.offset) : 0; // check to see if it exists if (_eventsDB.find_by_openstack_id(Convert.ToInt32(e.openstack_id)).id > 0) { e.id = _eventsDB.find_by_openstack_id(Convert.ToInt32(e.openstack_id)).id; e = _eventsDB.appupdate(e); Console.WriteLine(" Updated..."); } else { e = _eventsDB.add(e); Console.WriteLine(" Added..."); } // Get Event TYpes and push them Console.WriteLine("Updating Event Types..."); Console.WriteLine(""); List <OpenStackEventType> oTypes = _events.push_event_types(Convert.ToInt32(e.openstack_id)); Console.WriteLine(oTypes.Count + " Types Found..."); Int32 tcnt = 0; foreach (OpenStackEventType oty in oTypes) { EventType ety = new EventType(); ety.title = oty.name; ety.event_type_id = oty.id; ety.event_id = e.id; //Console.WriteLine(ety.title + "..."); _types.addUpdate(ety); tcnt++; drawTextProgressBar(tcnt, oTypes.Count); } List <EventType> etypes = _types.by_event(e.id); // get locations and push them List <OpenStackLocation> locs = _olocations.get_by_event(Convert.ToInt32(e.openstack_id)); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(locs.Count + " Locations Found...."); Int32 lcnt = 0; foreach (OpenStackLocation l in locs) { Location lo = new Location(); //Console.WriteLine("Processing " + l.name); lo.title = l.name; lo.sched_id = l.id.ToString(); lo.event_id = e.id; _locations.add(lo); lcnt++; drawTextProgressBar(lcnt, locs.Count); } // now get the speakers Console.WriteLine(""); Console.WriteLine("Getting Speakers... (Processing Pages...)"); Console.WriteLine(""); OpenSpeaker openspeaker = new OpenSpeaker(); openspeaker = _speakers.refresh(Convert.ToInt32(e.openstack_id), "1"); drawTextProgressBar(0, openspeaker.last_page); foreach (Speaker speak in openspeaker.data) { speak.event_id = e.id; _speakers.add(speak); } Int32 cursp = 0; while (cursp <= openspeaker.last_page) { cursp++; drawTextProgressBar(cursp, openspeaker.last_page); openspeaker = _speakers.refresh(Convert.ToInt32(e.openstack_id), cursp.ToString()); foreach (Speaker speak in openspeaker.data) { speak.event_id = e.id; _speakers.add(speak); } } // now get the sessions Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Getting Sessions...."); Console.WriteLine(""); OpenStack op = new OpenStack(); Int32 total_count = 0; op = _osessions.refresh(Convert.ToInt32(e.openstack_id), "1"); Console.WriteLine("Processing Pages from API"); List <Session> fromAPI = new List <Session>(); List <OpenStackSession> allsessions = new List <OpenStackSession>(); allsessions.AddRange(op.data); drawTextProgressBar(0, op.last_page); Int32 cur = 1; while (cur <= op.last_page) { drawTextProgressBar(cur, op.last_page); // get the next records cur++; op = _osessions.refresh(Convert.ToInt32(e.openstack_id), cur.ToString()); allsessions.AddRange(op.data); } Int32 cursess = 0; Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Session Count:" + op.total.ToString()); Console.WriteLine("Processing Session Records..."); drawTextProgressBar(cursess, allsessions.Count); foreach (OpenStackSession sess in allsessions) { if (!string.IsNullOrEmpty(sess.title)) { fromAPI.Add(_sessions.add(_osessions.parse(sess, e, etypes), e.id)); } cursess++; drawTextProgressBar(cursess, allsessions.Count); } //Console.WriteLine(""); //Console.WriteLine(""); //Console.WriteLine("Finding Sessions to Remove..."); //// find sessions that have been removed and delete them from the database //List<Session> fromDB = _sessions.by_event(e.id); //Int32 dcnt = 0; //var result = fromDB.Where(p => !fromAPI.Any(p2 => p2.id == p.event_key)); //// iterate through them and delete them //foreach (var item in result) //{ // Console.WriteLine("Removing Session: " + item.event_key + " " + item.name); // //if (_sessions.remove(item.event_key)) // //{ // // drawTextProgressBar(dcnt, result.Count()); // //} // //dcnt++; //} } } } } }
// REV 1 - COMPLETE 10.19.15 @ 12:26AM static void Main(string[] args) { events _events = new events(); twitter _twitter = new twitter(); templates _templates = new templates(); terminals _terminals = new terminals(); Console.WriteLine("######### BEGIN FNSIGN UPDATER v.1.0 #########"); Console.WriteLine(""); Console.WriteLine("######### GETTING EVENTS THAT NEED TO BE UPDATED #########"); Console.WriteLine(""); List <Event> evs = _events.need_updating(); Console.WriteLine(evs.Count.ToString() + " need updating...."); Console.WriteLine(""); sessions _sessions = new sessions(); foreach (Event e in evs) { Console.WriteLine("Finding Sessions for " + e.title); Console.WriteLine(""); if (!string.IsNullOrEmpty(e.url)) { List <Session> sess = _sessions.all(e.url, e.api_key); Console.WriteLine(sess.Count.ToString() + " Sessions Found..."); Console.WriteLine(""); // look for deletions List <Session> dbsess = _sessions.by_event(e.id); foreach (Session d in dbsess) { List <Session> found = sess.Where(x => x.event_key == d.event_key).ToList(); if (found.Count == 0) { // remove the session Console.WriteLine("Session ID: " + d.id + " NOT FOUND"); Console.WriteLine("Removing Session: " + d.name + "..."); _sessions.delete(d.internal_id); } else { Console.WriteLine("Session ID: " + d.id + " FOUND"); } } foreach (Session s in sess) { // now we loop through the sessions and insert or update them if (s.event_type != "Japanese Language") { _sessions.add(s, e.id); } } _sessions.clean_summit(); } Console.WriteLine(""); Console.WriteLine("Finding Tweets for Global Event Tag..."); Console.WriteLine(""); if (!string.IsNullOrEmpty(e.t_username)) { Console.WriteLine("Finding Tweets for @" + e.t_username); Console.WriteLine(""); _twitter.fetch(e.t_username, 50, true, e.id, 0); } if (e.hashtags != null) { foreach (string h in e.hashtags) { Console.WriteLine("Finding Tweets for #" + h); Console.WriteLine(""); _twitter.fetch(h, 50, e.id, 0); } } Console.WriteLine("Now let's check for the templates associated with " + e.title); Console.WriteLine(""); foreach (Template t in _templates.all_by_event(e.id)) { if (!string.IsNullOrEmpty(t.t_username)) { Console.WriteLine("Fetching Twitter records for @" + t.t_username); Console.WriteLine(""); _twitter.fetch(t.t_username, 50, true, e.id, t.id); } if (t.hashtags != null) { Console.WriteLine("Fetching Records for Hashtags..."); Console.WriteLine(""); foreach (string h in t.hashtags) { Console.WriteLine("Fetching tweets for #" + h); Console.WriteLine(""); _twitter.fetch(h, 50, e.id, t.id); } } } Console.WriteLine(""); Console.WriteLine("Updating Event Last Updated Time..."); _events.update(e); Console.WriteLine("Complete..."); Console.WriteLine("Moving to next event..."); Console.WriteLine(""); // here we need to update the last update time } Console.WriteLine("Check for Offline Terminals..."); Console.WriteLine(""); List <Terminal> terms = _terminals.offline_terminals(); if (terms.Count() > 0) { Console.WriteLine(terms.Count() + " Offline, updating their status..."); Console.WriteLine(""); foreach (Terminal t in terms) { Console.WriteLine("Taking " + t.title + " Offline"); Console.WriteLine(""); _terminals.offline(t.id); } } else { Console.WriteLine("All Terminals are Online..."); Console.WriteLine(""); } Console.WriteLine("######### FNSIGN v.1.0 UPDATER COMPLETE #########"); }
private void ReportFilm_OnClick(object sender, RoutedEventArgs e) { try { using (MsSqlContext db = new MsSqlContext()) { var film = db.films.Include(c => c.Sessions).ToList(); var dest = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/Отчёт по продажам билетов на фильм.pdf"; var file = new FileInfo(dest); file.Directory.Create(); var pdf = new PdfDocument(new PdfWriter(dest)); var document = new Document(pdf, PageSize.A2.Rotate()); var font = PdfFontFactory.CreateFont(FONT, PdfEncodings.IDENTITY_H); float[] columnWidths = { 10, 10, 10, 8 }; var table = new Table(UnitValue.CreatePercentArray(columnWidths)); var cell = new Cell(1, 4) .Add(new Paragraph("Отчёт по фильмам")) .SetFont(font) .SetFontSize(13) .SetFontColor(DeviceGray.WHITE) .SetBackgroundColor(DeviceGray.BLACK) .SetWidth(600) .SetTextAlignment(TextAlignment.CENTER); table.AddHeaderCell(cell); Cell[] headerFooter = { new Cell().SetFont(font).SetWidth(100).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Фильм")), new Cell().SetFont(font).SetWidth(100).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Количество сеансов")), new Cell().SetFont(font).SetWidth(100).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Количество купленных билетов")), new Cell().SetFont(font).SetWidth(100).SetBackgroundColor(new DeviceGray(0.75f)).Add(new Paragraph("Общая сумма")) }; foreach (var hfCell in headerFooter) { table.AddHeaderCell(hfCell); } int Count_of_places = 0; int all_places = 0; float Summ_price = 0; for (int i = 0; i < film.Count; i++) { Summ_price = 0; table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).SetFont(font).Add(new Paragraph(film[i].film_name))); table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).SetFont(font).Add(new Paragraph($"{film[i].Sessions.Count}"))); for (int f = 0; f <= film[i].Sessions.Count - 1; f++) { ICollection <sessions> sess = film[i].Sessions; sessions buff_ses = sess.ElementAt(f); var places_list = db.places_list.Where(c => c.status == "Куплено").Where(c => c.sessionsId == buff_ses.Id).ToList(); Count_of_places = places_list.Count; all_places = all_places + Count_of_places; Summ_price = Count_of_places * buff_ses.price_of_tickets + Summ_price; } table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).SetFont(font).Add(new Paragraph(all_places.ToString()))); table.AddCell(new Cell().SetTextAlignment(TextAlignment.CENTER).SetFont(font).Add(new Paragraph(Summ_price.ToString()))); all_places = 0; } document.Add(table); document.Close(); var p = new Process { StartInfo = new ProcessStartInfo(dest) { UseShellExecute = true } }; p.Start(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static void Main(string[] args) { events events = new events(); twitter twitter = new twitter(); templates templates = new templates(); terminals terminals = new terminals(); Console.WriteLine("######### BEGIN FNSIGN UPDATER v.1.0 #########"); Console.WriteLine(""); Console.WriteLine("######### GETTING EVENTS THAT NEED TO BE UPDATED #########"); Console.WriteLine(""); List <Event> eventList = events.need_updating() .Where <Event>((Func <Event, bool>)(x => !string.IsNullOrEmpty(x.api_key) && !string.IsNullOrEmpty(x.url))) .ToList <Event>(); Console.WriteLine(eventList.Count.ToString() + " need updating...."); Console.WriteLine(""); sessions sessions = new sessions(); foreach (Event ev in eventList) { Console.WriteLine("Finding Sessions for " + ev.title); Console.WriteLine(""); List <Session> sessionList = sessions.getSessionsFromAPI(ev.url, ev.api_key, ev.api_type); Console.WriteLine(sessionList.Count.ToString() + " Sessions Found..."); Console.WriteLine(""); foreach (Session s in sessionList) { sessions.add(s, ev.id); } //Remove those sessions which stopped coming from api IList <string> incomingSessionIds = sessionList.Select(x => x.event_key).ToList(); List <Session> notComingAnymoreSessions = sessions.by_event(ev.id).Where(x => !incomingSessionIds.Contains(x.event_key)).ToList <Session>(); foreach (var item in notComingAnymoreSessions) { sessions.delete(int.Parse(item.id)); } Console.WriteLine(""); Console.WriteLine("Finding Tweets for Global Event Tag..."); Console.WriteLine(""); if (!string.IsNullOrEmpty(ev.t_username)) { Console.WriteLine("Finding Tweets for @" + ev.t_username); Console.WriteLine(""); twitter.fetch(ev.t_username, 50, true, ev.id, 0); } if (ev.hashtags != null) { foreach (string hashtag in ev.hashtags) { Console.WriteLine("Finding Tweets for #" + hashtag); Console.WriteLine(""); twitter.fetch(hashtag, 50, ev.id, 0); } } Console.WriteLine("Now let's check for the templates associated with " + ev.title); Console.WriteLine(""); foreach (Template template in templates.all_by_event(ev.id)) { if (!string.IsNullOrEmpty(template.t_username)) { Console.WriteLine("Fetching Twitter records for @" + template.t_username); Console.WriteLine(""); twitter.fetch(template.t_username, 50, true, ev.id, template.id); } if (template.hashtags != null) { Console.WriteLine("Fetching Records for Hashtags..."); Console.WriteLine(""); foreach (string hashtag in template.hashtags) { Console.WriteLine("Fetching tweets for #" + hashtag); Console.WriteLine(""); twitter.fetch(hashtag, 50, ev.id, template.id); } } } Console.WriteLine(""); Console.WriteLine("Updating Event Last Updated Time..."); events.update(ev); Console.WriteLine("Complete..."); Console.WriteLine("Moving to next event..."); Console.WriteLine(""); } Console.WriteLine("Check for Offline Terminals..."); Console.WriteLine(""); List <Terminal> source = terminals.offline_terminals(); if (source.Count <Terminal>() > 0) { Console.WriteLine(source.Count <Terminal>().ToString() + " Offline, updating their status..."); Console.WriteLine(""); foreach (Terminal terminal in source) { Console.WriteLine("Taking " + terminal.title + " Offline"); Console.WriteLine(""); terminals.offline(terminal.id); } } else { Console.WriteLine("All Terminals are Online..."); Console.WriteLine(""); } Console.WriteLine("######### FNSIGN v.1.0 UPDATER COMPLETE #########"); }