public override bool Walk(ExpressionStatement node) { switch (node.Expression) { case ExpressionWithAnnotation ea: AssignmentHandler.HandleAnnotatedExpression(ea, null); return(false); case Comprehension comp: Eval.ProcessComprehension(comp); return(false); case CallExpression callex when callex.Target is NameExpression nex && !string.IsNullOrEmpty(nex.Name): Eval.LookupNameInScopes(nex.Name)?.AddReference(Eval.GetLocationOfName(nex)); return(true); case CallExpression callex when callex.Target is MemberExpression mex && !string.IsNullOrEmpty(mex.Name): var t = Eval.GetValueFromExpression(mex.Target)?.GetPythonType(); t?.GetMember(mex.Name)?.AddReference(Eval.GetLocationOfName(mex)); return(true); default: return(base.Walk(node)); } }
public void NoDocumentsLeft_SameIP() { var ai = new AssignmentHandler.AllocationInfo { StudentCount = 3 }; ai.Documents.Add(new List <Document> { new Document { Id = 1 }, new Document { Id = 2 } }); ai.Assignments.Add(1, new List <Assignment> { new Assignment { DocumentId = 1, Ip = "0.0.0.0" } }); ai.Assignments.Add(2, new List <Assignment> { new Assignment { DocumentId = 2, Ip = "0.0.0.0" } }); var docs = AssignmentHandler.CalcStudentDocuments(ai, "0.0.0.0", new Random(1)); Assert.True(docs.Count == 1); Assert.True(docs[0].Id == 1); }
private void Search() { try { AssignmentHandler h = new AssignmentHandler(); IList l = h.GetArrivalsAndDepartures(dateEdit1.DateTime, false); gridControl1.DataSource = l; if (l.Count == 0) { XtraMessageBox.Show("Nessuna partenza attesa", "Mesaggio", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { try { gridControl1.MainView.SaveLayoutToXml(fileLayout); } catch (Exception) { //non fa nulla } } } catch (Exception ex) { ErrorHandler.Show(ex); } }
private void CheckInputIsValid() { //qui verifico l'inoput preventivamente. //non lascio la validazione finale all'oggetto di dominio per come è costruita la gui //di devexpress //verifica delle date if (this.dtpOut.DateTime.Date <= this.dtpIn.DateTime.Date) { throw new Exception("L'intervallo date inserito non è valido"); } //verifico la possibilità di aggiungere una nuova assegnazione oppure //se la modifica di una assegnazione può essere fatta AssignmentHandler h = new AssignmentHandler(); int assignmentID = -1; if (!_isCreationOp) { Assignment a = _apt.GetSourceObject(_control.Storage) as Assignment; if (a == null) { throw new Exception("Impossibile otttenere il source object dall'appuntamento!! Contattare la noesis per la risoluzione del bug"); } assignmentID = a.Id; } FreeRoomCheck cc = h.IsRoomFree(this.dtpIn.DateTime.Date, this.dtpOut.DateTime.Date, chkResources.EditValue as WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource, assignmentID); if (!cc.IsFree) { throw new Exception(cc.Message); } }
public void TwoQuestions() { var ai = new AssignmentHandler.AllocationInfo { StudentCount = 3 }; ai.Documents.AddRange(new List <List <Document> > { new List <Document> { new Document { Id = 1 } }, new List <Document> { new Document { Id = 3 } }, }); var docs = AssignmentHandler.CalcStudentDocuments(ai, "0.0.0.0", new Random()); Assert.True(docs.Count == 2); Assert.True(docs[0].Id == 1); Assert.True(docs[1].Id == 3); }
private void RefreshGridDataSource() { _gridControl1.DataSource = null; AssignmentHandler hh = new AssignmentHandler(); _gridControl1.DataSource = hh.GetAssignmentsByBookingId(_parentBooking.Id); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { NPC = animator.gameObject; agent = NPC.GetComponent <UnityEngine.AI.NavMeshAgent>(); thisAnimator = NPC.GetComponent <Animator>(); assignmentScript = NPC.GetComponent <AssignmentHandler>(); myNumber = assignmentScript.GetAssignedNumber(); }
public void NoDocuments() { var ai = new AssignmentHandler.AllocationInfo(); var docs = AssignmentHandler.CalcStudentDocuments(ai, "0.0.0.0", new Random()); Assert.True(docs.Count == 0); }
public void TwoQuestions_ManyDocuments() { var ai = new AssignmentHandler.AllocationInfo { StudentCount = 18 }; ai.Documents.AddRange(new List <List <Document> > { new List <Document> { new Document { Id = 1 }, new Document { Id = 3 }, new Document { Id = 5 }, new Document { Id = 7 }, new Document { Id = 9 }, new Document { Id = 11 } }, new List <Document> { new Document { Id = 2 }, new Document { Id = 4 }, new Document { Id = 6 }, new Document { Id = 8 }, new Document { Id = 10 }, new Document { Id = 12 } }, }); var docs = AssignmentHandler.CalcStudentDocuments(ai, "0.0.0.0", new Random(1)); Assert.True(docs.Count == 2); Assert.True(docs[0].Id == 3); Assert.True(docs[1].Id == 2); }
private void LoadDataForCustomer(int customerId) { IList customerAssignments = new ArrayList(); AssignmentHandler h = new AssignmentHandler(); customerAssignments = h.GetAssignmentsByCustomerId(customerId); gridControl1.DataSource = customerAssignments; }
private void ProcessClassBody() { // Class is handled in a specific order rather than in the order of // the statement appearance. This is because we need all members // properly declared and added to the class type so when we process // methods, the class variables are all declared and constructors // are evaluated. // Process bases. foreach (var b in _class.Bases.Select(b => b.GetPythonType <IPythonClassType>()).ExcludeDefault()) { SymbolTable.Evaluate(b.ClassDefinition); } // Process imports foreach (var s in GetStatements <FromImportStatement>(_classDef)) { ImportHandler.HandleFromImport(s); } foreach (var s in GetStatements <ImportStatement>(_classDef)) { ImportHandler.HandleImport(s); } UpdateClassMembers(); // Process assignments so we get class variables declared. // Note that annotated definitions and assignments can be intermixed // and must be processed in order. Consider // class A: // x: int // x = 1 foreach (var s in GetStatements <Statement>(_classDef)) { switch (s) { case AssignmentStatement assignment: AssignmentHandler.HandleAssignment(assignment); break; case ExpressionStatement e: AssignmentHandler.HandleAnnotatedExpression(e.Expression as ExpressionWithAnnotation, null); break; } } UpdateClassMembers(); // Ensure constructors are processed so class members are initialized. EvaluateConstructors(_classDef); UpdateClassMembers(); // Process remaining methods. SymbolTable.EvaluateScope(_classDef); UpdateClassMembers(); }
protected AnalysisWalker(ExpressionEval eval) { Eval = eval; ImportHandler = new ImportHandler(this); AssignmentHandler = new AssignmentHandler(this); LoopHandler = new LoopHandler(this); ConditionalHandler = new ConditionalHandler(this); WithHandler = new WithHandler(this); TryExceptHandler = new TryExceptHandler(this); NonLocalHandler = new NonLocalHandler(this); }
public void NoDocument_ListsEmpty() { var ai = new AssignmentHandler.AllocationInfo { StudentCount = 1 }; ai.Documents.Add(new List <Document> ()); ai.Assignments.Add(1, new List <Assignment>()); var docs = AssignmentHandler.CalcStudentDocuments(ai, "0.0.0.0", new Random()); Assert.True(docs.Count == 0); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { machines = GameObject.FindGameObjectsWithTag("Machine"); NPC = animator.gameObject; thisAnimator = NPC.GetComponent <Animator>(); assignmentScript = NPC.GetComponent <AssignmentHandler>(); myNumber = assignmentScript.GetAssignedNumber(); machineScript = machines[myNumber].GetComponent <MachineEvent>(); Debug.Log("I'm doing laundry"); }
private void schedulerStorage1_AppointmentChanging(object sender, PersistentObjectCancelEventArgs e) { try { Nested_CheckSecurityForChanging(); //qui verifico che l'appuntamento può essere cambiato Appointment app = e.Object as Appointment; BookingResourceHandler bc = new BookingResourceHandler(); BookingResource res = bc.GetElementById(app.ResourceId.ToString()) as BookingResource; Assignment ass = app.GetSourceObject(schedulerStorage1) as Assignment; AssignmentHandler hh = new AssignmentHandler(); FreeRoomCheck cc = hh.IsRoomFree(app.Start, app.End, res, ass.Id); if (!cc.IsFree) { XtraMessageBox.Show(cc.Message, "Attenzione", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.Cancel = true; } //if (XtraMessageBox.Show("Il prezzo verra' cambiato di conseguenza. Continuare?", "Domanda", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) //{ // e.Cancel = true; // return; //} //Appointment app1 = e.Object as Appointment; //Assignment aas1 = app1.GetSourceObject(schedulerStorage1) as Assignment; //if (aas1.Booking.Confirmed) //{ // aas1.Booking.Payment.Total = aas1.Booking.Payment.Total + 10; //} } catch (AccessDeniedException) { ErrorHandler.Show("Impossibile accedere alla funzionalità richiesta. Accesso negato"); e.Cancel = true; } catch (Exception ex) { ErrorHandler.Show(ex); e.Cancel = true; } }
public override bool Walk(ExpressionStatement node) { switch (node.Expression) { case ExpressionWithAnnotation ea: AssignmentHandler.HandleAnnotatedExpression(ea, null); break; case Comprehension comp: Eval.ProcessComprehension(comp); break; } return(false); }
private void LoadCurrentBookingData() { dtpDate.DateTime = _currentBooking.Date; memoEdit1.Text = _currentBooking.Notes; cboTipo.EditValue = _currentBooking.BookingType; cboOp.EditValue = _currentBooking.Operator; colorEdit1.Color = Color.FromArgb(_currentBooking.Color); chkColorBookings.Checked = _currentBooking.ColorBookings; memoEdit2.Text = _currentBooking.Notes1; chkConfirm.Checked = _currentBooking.Confirmed; if (_currentBooking.Confirmed) { //Visualizzo il pannello del pagamento layoutControlGroup4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; //se è confermata avrà sicuramente un pagamento; lblRiepilogoSaldo.Text = String.Format("{0:c2}({1:c2})", _currentBooking.Payment.RestOfPayment, _currentBooking.Payment.ToPay); lblRiepilogoAcconto.Text = _currentBooking.Payment.Accont.ToString("c2"); spTassa.EditValue = _currentBooking.Payment.StayTax; spTotale.EditValue = _currentBooking.Payment.Total; if (_currentBooking.Payment.Accont != 0) { spAcconto.EditValue = _currentBooking.Payment.Accont; cboModAcconto.EditValue = _currentBooking.Payment.AccountPaymentType; dtpAcconto.EditValue = _currentBooking.Payment.AccontData; } if (_currentBooking.Payment.RestOfPayment != 0) { spSaldo.EditValue = _currentBooking.Payment.RestOfPayment; cboModSaldo.EditValue = _currentBooking.Payment.RestOfPaymentPaymentType; dtpSaldo.EditValue = _currentBooking.Payment.RestOfPaymentData; } } else { layoutControlGroup4.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } AssignmentHandler hh = new AssignmentHandler(); //prendo tutto dal db per la questione della cache IList k = hh.GetAssignmentsByBookingId(_currentBooking.Id); gridControl1.DataSource = k; //rinfresco SetImageAndDescriptionState(); }
public async Task <IActionResult> GetAssignment([FromBody] AssignRequest assignRequest) { IActionResult resp = NotFound(); try { var exam = await db.Exams.FirstOrDefaultAsync(e => e.Id == assignRequest.ExamId); var student = await db.Students.FirstOrDefaultAsync(s => s.Id == assignRequest.StudentId); var now = DateTime.UtcNow; if (exam != null && exam.AuthenticationCode == assignRequest.AuthenticationCode && student != null && student.Number == assignRequest.StudentNumber && (!exam.IsLimitedAccess || exam.IsLimitedAccess && exam.Start <= now && exam.Start.AddMinutes(exam.DurationMinutes) >= now)) { //ok, we believe that you are one of the students who should get a set of documents from this exam (one per question) var documents = await getDocumentsForStudent(exam, student, HttpContext.Connection.RemoteIpAddress?.ToString()); //notify prof that a student has been allocated something await sendNotification(exam, student, documents); //zip the files var ms = await AssignmentHandler.CreateZipArchive(documents, student.Name); resp = File(ms.ToArray(), "application/zip", $"{student.Name}.zip"); logger.LogTrace( $"{assignRequest} fulfilled with {string.Join(",", documents.Select(d => d.Id).ToList())}"); } else { logger.LogWarning($"{assignRequest} not a match or too early {exam?.IsLimitedAccess}"); if (exam?.IsLimitedAccess ?? false) { resp = BadRequest(); } } } catch (Exception ex) { logger.LogError(ex, assignRequest.ToString()); resp = StatusCode(statusCode: 500); } return(resp); }
private void schedulerStorage1_AppointmentDeleting(object sender, PersistentObjectCancelEventArgs e) { try { Nested_CheckSecurityForDeletion(); } catch (AccessDeniedException) { ErrorHandler.Show("Impossibile accedere alla funzionalità richiesta. Accesso negato"); e.Cancel = true; return; } //if (XtraMessageBox.Show("Sicuro di procedere alla cancellazione dell'assegnazione?", "Domanda", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //{ DevExpress.XtraScheduler.Appointment app = e.Object as DevExpress.XtraScheduler.Appointment; Assignment a = app.GetSourceObject(schedulerStorage1) as Assignment; IBooking b = a.Booking; //aggiorno lo stato della prenotaizone a.Booking.RemoveAssignment(a); if (b.Assignments.Count == 0) { //elimino l'intera prenotazione BookingHandler h = new BookingHandler(); h.Delete(b.BaseObject); } else { //elimino solo la assegnazione corrente ////i save on my db AssignmentHandler h = new AssignmentHandler(); h.Delete(a); } // return; //} //e.Cancel = true; }
public void OneDocument() { var ai = new AssignmentHandler.AllocationInfo { StudentCount = 1 }; ai.Documents.Add(new List <Document> { new Document { Id = 1 } }); var docs = AssignmentHandler.CalcStudentDocuments(ai, "0.0.0.0", new Random()); Assert.True(docs.Count == 1); Assert.True(docs[0].Id == 1); }
private async Task ProcessClassBody(CancellationToken cancellationToken = default) { // Class is handled in a specific order rather than in the order of // the statement appearance. This is because we need all members // properly declared and added to the class type so when we process // methods, the class variables are all declared and constructors // are evaluated. // Process bases. foreach (var b in _class.Bases.Select(b => b.GetPythonType <IPythonClassType>()).ExcludeDefault()) { await SymbolTable.EvaluateAsync(b.ClassDefinition, cancellationToken); } // Process imports foreach (var s in GetStatements <FromImportStatement>(_classDef)) { await FromImportHandler.HandleFromImportAsync(s, cancellationToken); } foreach (var s in GetStatements <ImportStatement>(_classDef)) { await ImportHandler.HandleImportAsync(s, cancellationToken); } UpdateClassMembers(); // Process assignments so we get class variables declared. foreach (var s in GetStatements <AssignmentStatement>(_classDef)) { await AssignmentHandler.HandleAssignmentAsync(s, cancellationToken); } foreach (var s in GetStatements <ExpressionStatement>(_classDef)) { await AssignmentHandler.HandleAnnotatedExpressionAsync(s.Expression as ExpressionWithAnnotation, null, cancellationToken); } UpdateClassMembers(); // Ensure constructors are processed so class members are initialized. await EvaluateConstructorsAsync(_classDef, cancellationToken); UpdateClassMembers(); // Process remaining methods. await SymbolTable.EvaluateScopeAsync(_classDef, cancellationToken); UpdateClassMembers(); }
private void schedulerStorage1_AppointmentsChanged(object sender, PersistentObjectsEventArgs e) { try { Nested_CheckSecurityForChanging(); } catch (Exception ex) { ErrorHandler.Show(ex); return; } foreach (DevExpress.XtraScheduler.Appointment app in e.Objects) { // DevExpress.XtraScheduler.Appointment app = e.Objects[0] as DevExpress.XtraScheduler.Appointment; //imposto per sicurezza il campo allday a true; app.AllDay = true; Assignment a = app.GetSourceObject(schedulerStorage1) as Assignment; //se ho cambiato risorsa dal calendario e non dal form //(il form tiene i valori sincronizzati) recupero la risorsa e la setto if (a.ResourceId != a.Resource.Id) { BookingResourceHandler h1 = new BookingResourceHandler(); WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource res = h1.GetElementById(a.ResourceId.ToString()) as WIN.SCHEDULING_APPLICATION.DOMAIN.Booking.BookingResource; a.Resource = res; app.SetValue(schedulerStorage1, "Resource", res); } ////i save on my db AssignmentHandler h = new AssignmentHandler(); try { h.SaveOrUpdate(a); } catch (Exception ex) { WIN.SCHEDULING_APP.GUI.Utility.ErrorHandler.Show(ex); } } }
public override bool Walk(ExpressionStatement node) { switch (node.Expression) { case ExpressionWithAnnotation ea: AssignmentHandler.HandleAnnotatedExpression(ea, null); return(false); case Comprehension comp: Eval.ProcessComprehension(comp); return(false); case CallExpression callex: Eval.ProcessCallForReferences(callex); return(true); default: return(base.Walk(node)); } }
private void rem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { Assignment a = gridView1.GetRow(gridView1.FocusedRowHandle) as Assignment; IBooking b = a.Booking; if (a != null) { //if (XtraMessageBox.Show("Rimuovere l'assegnazione selezionata?", "Domanda", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //{ Appointment app = GetAppointment(a); if (app != null) { _control.Storage.Appointments.Remove(app); } //dopo che viene eseguito l'evento posso procedere a verificare lo stato della prenotazione //se non ci sono altre assegnazioni posso chiudere il form (la prenotazione è stata cancellata dal //bookingControl //if (b.Assignments.Count == 0) // this.Close(); //else //ripristibno il data source della griglia //{ gridControl1.DataSource = null; AssignmentHandler hh = new AssignmentHandler(); //prendo tutto dal db per la questione della cache gridControl1.DataSource = hh.GetAssignmentsByBookingId(_currentBooking.Id); //} //} } else { XtraMessageBox.Show("Selezionare una assegnazione!", "Messaggio", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { ErrorHandler.Show(ex); } }
private async Task <List <Document> > getDocumentsForStudent(Exam exam, Student student, string ip) { List <Document> documents; if (!await db.Assignments.AnyAsync(a => a.StudentId == student.Id && db.Documents.Any(d => d.Id == a.DocumentId && db.Questions.Any(q => q.Id == d.QuestionId && q.ExamId == exam.Id)))) { //we need to do this in one student at a time, so if multiple students hit the server //at the same time, we'll still process them sequentially await slim.WaitAsync(); try { //now that we know we haven't already given you documents //figure out which documents to hand over documents = await AssignmentHandler.GetStudentDocuments(db, student, exam, ip, random); await saveDocuments(student, ip, documents); } finally { slim.Release(); } } else { //send them the same files again documents = await db.Documents.Where(d => db.Assignments.Any(a => a.DocumentId == d.Id && a.StudentId == student.Id && db.Questions.Any(q => d.QuestionId == q.Id && db.Exams.Any(e => e.Id == q.ExamId && e.Id == exam.Id)))).ToListAsync(); await saveDocuments(student, ip, documents); } return(documents); }
} //checked public void Delete() { AssignmentHandler assignmentHandler = new AssignmentHandler(); bool exit = false; while (!exit) { List <Term> terms = this.teacher.Role == (int)UserPermission.HeadSection ? handler.GetList(this.teacher.SubjectID) : handler.GetListTerm(); PrintTable(terms); string id = GetId2(); handler.DeleteTerm(id); terms.RemoveAt(handler.GetIndex(id, terms)); assignmentHandler.Delete(assignment => assignment.TermID == id); PrintTable(terms); Console.Clear(); PrintTable(terms); Console.Write("Bạn có muốn sửa tiếp không?(nhấn esc để thoát)"); ConsoleKeyInfo info = Console.ReadKey(); if (info.Key == ConsoleKey.Escape) { exit = true; } } } //checked
public override bool Walk(AssignmentStatement node) { AssignmentHandler.HandleAssignment(node); return(base.Walk(node)); }
public override bool Walk(NamedExpression node) { AssignmentHandler.HandleNamedExpression(node); return(base.Walk(node)); }
public override async Task <bool> WalkAsync(AssignmentStatement node, CancellationToken cancellationToken = default) { await AssignmentHandler.HandleAssignmentAsync(node, cancellationToken); return(await base.WalkAsync(node, cancellationToken)); }
public override async Task <bool> WalkAsync(ExpressionStatement node, CancellationToken cancellationToken = default) { await AssignmentHandler.HandleAnnotatedExpressionAsync(node.Expression as ExpressionWithAnnotation, null, cancellationToken); return(false); }