public void unregistercourses() { Unregister fm1 = new Unregister(); if (fm1.ShowDialog() == DialogResult.OK) { try { string sql = ("DELETE FROM StudentCourses where StudentId = '" + fm1.StudentId + "' and CourseNum = '" + fm1.Coursenum + "'and semester = '" + fm1.Semester + "'"); List <DbParameter> newlist = new List <DbParameter>(); char[] seps = { ',' }; string[] parts = sql.Split(seps); SqlParameter p1 = new SqlParameter("@StudentId", SqlDbType.VarChar, 10); SqlParameter p2 = new SqlParameter("@CourseNum", SqlDbType.VarChar, 20); SqlParameter p3 = new SqlParameter("@Semester", SqlDbType.VarChar, 20); p1.Value = parts[0]; p2.Value = parts[1]; p3.Value = parts[2]; newlist.Add(p1); newlist.Add(p2); newlist.Add(p3); int x = idac.InsertUpdateDelete(sql, newlist); MessageBox.Show("You have been unregisterd from this course"); } catch (Exception) { throw; } } }
public SessionTcp(string userId, TcpClient client, Unregister unregister) { m_id = Guid.NewGuid().ToString(); m_userId = userId; m_client = client; m_unregisterEvent = unregister; }
public MongoDbEnlistmentScope(IClientSessionHandle sessionHandle, Unregister unregister) { _sessionHandle = sessionHandle; _unregister = unregister; }
private void UnregistrationFromTunnel() { try { if (ApplicationInfo.UserLoginMode != "I" && this.ipwIPPortMain.Connected) { string str = new Unregister().Pack(ApplicationInfo.UserLoginID, ApplicationInfo.UserSessionID, 1, ""); this.ipwIPPortMain.DataToSend = str + this.ipwIPPortMain.EOL; } } catch (Exception ex) { this.ShowError("UnregistrationFromTunnel", ex); } }
// 2 Functionalities // ***Funtionality 1. Send the User to the back of the signup List // Remove a User based off of membershipID from the signupList in Training based off of trainingID // Update All TrainingUserItems to account for the removed user // ReAdd the user to the end of the signup List // Body Fields: trainingID, membershipID, SendToTheBack(boolean) True // Response: Success or Not Success. // ***Funtionality 2. Fully delete the TrainingUserItem from the signupList from the training based off of trainingID // Fully delete the trainingID found in trainingCamps from User based off of membershipID // Body Fields: trainingID, membershipID, SendToTheBack(boolean) False // Response: Success or Not Success. // DELETE api/<controller>/5 public HttpResponseMessage Delete([FromBody] Unregister unregister) { // Find the training by trainingID. (setup) var getFilterTraining = Builders <Training> .Filter.Eq("trainingID", unregister.trainingID); // Find the user by membership ID. (setup) var getFilterUser = Builders <User> .Filter.Eq("membershipID", unregister.membershipID); if (getFilterTraining != null && getFilterUser != null) { // Get the training, by the filter Training trainingFound = MongoConnections.getMongoTrainingCollection().Find(getFilterTraining).FirstOrDefault(); // Get the user, by the filter User userFound = MongoConnections.getMongoUsersCollection().Find(getFilterUser).FirstOrDefault(); // if the User already has the trainingID in trainingCamps if (userFound.trainingCamps.Contains(unregister.trainingID)) { if (unregister.sendToTheBack) { // Get the full list of TrainingUserItems List <TrainingUserItem> signupListFromTraining = trainingFound.signupList; int counter = 0; int oldPlaceOnList = 0; // Grab only the one we want to update foreach (TrainingUserItem trainingUserItem in signupListFromTraining) { if (trainingUserItem.membershipID == unregister.membershipID) { //memberfound! Update it! oldPlaceOnList = signupListFromTraining[counter].placeInQueue; signupListFromTraining[counter].placeInQueue = trainingFound.currentTrainingUserCount + 1; break; } counter++; } counter = 0; //update the others based off the user added to the back of the signup list foreach (TrainingUserItem trainingUserItem in signupListFromTraining) { if (trainingUserItem.placeInQueue > oldPlaceOnList) { signupListFromTraining[counter].placeInQueue--; } counter++; } var updateCurrentTrainingUserCountTraining = Builders <Training> .Update.Set("signupList", signupListFromTraining); MongoConnections.getMongoTrainingCollection().UpdateOne(getFilterTraining, updateCurrentTrainingUserCountTraining); return(Request.CreateResponse(HttpStatusCode.OK, "User has been sent to the back with new priority: " + trainingFound.currentTrainingUserCount)); } else { // Get the full list of TrainingUserItems List <TrainingUserItem> signupListFromTraining = trainingFound.signupList; int counter = 0; int oldPlaceOnList = 0; // Grab only the one we want to update foreach (TrainingUserItem trainingUserItem in signupListFromTraining) { if (trainingUserItem.membershipID == unregister.membershipID) { //memberfound! Delete it! oldPlaceOnList = trainingUserItem.placeInQueue; signupListFromTraining.RemoveAt(counter); break; } counter++; } counter = 0; //update the others based off the user added to the back of the signup list foreach (TrainingUserItem trainingUserItem in signupListFromTraining) { if (trainingUserItem.placeInQueue > oldPlaceOnList) { signupListFromTraining[counter].placeInQueue--; } counter++; } var updateSignUpListTraining = Builders <Training> .Update.Set("signupList", signupListFromTraining); MongoConnections.getMongoTrainingCollection().UpdateOne(getFilterTraining, updateSignUpListTraining); //deincrementSizeOfTraining var updateCurrentTrainingUserCountTraining = Builders <Training> .Update.Set("currentTrainingUserCount", trainingFound.currentTrainingUserCount - 1); MongoConnections.getMongoTrainingCollection().UpdateOne(getFilterTraining, updateCurrentTrainingUserCountTraining); counter = 0; //remove the training out of the User's training list foreach (String training in userFound.trainingCamps) { userFound.trainingCamps.RemoveAt(counter); counter++; break; } var updateUserTrainingCamps = Builders <User> .Update.Set("trainingCamps", userFound.trainingCamps); MongoConnections.getMongoUsersCollection().UpdateOne(getFilterUser, updateUserTrainingCamps); //Functionality 2 full remove return(Request.CreateResponse(HttpStatusCode.OK, "User has been unregistered")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "User is not even signed up to this training")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Something is incorrect with the request")); } }
/// <summary> /// Initializes if needed, issues updates. /// </summary> public override void UpdateAfterSimulation() { MainLock.MainThread_ReleaseExclusive(); try { switch (ManagerStatus) { case Status.Not_Initialized: Init(); return; case Status.Initialized: if (ServerSettings.ServerSettingsLoaded) { Log.DebugLog("Server settings loaded"); Start(); } return; case Status.Terminated: return; } Dictionary <Action, uint> Unregister = null; if (AddRemoveActions.Count != 0) { try { AddRemoveActions.PopHeadInvokeAll(); } catch (Exception ex) { Log.AlwaysLog("Exception in AddRemoveActions: " + ex, Logger.severity.ERROR); } } if (ExternalRegistrations.Count != 0) { try { ExternalRegistrations.PopHeadInvokeAll(); } catch (Exception ex) { Log.AlwaysLog("Exception in ExternalRegistrations: " + ex, Logger.severity.ERROR); } } foreach (KeyValuePair <uint, List <Action> > pair in UpdateRegistrar) { if (Globals.UpdateCount % pair.Key == 0) { foreach (Action item in pair.Value) { try { Profiler.StartProfileBlock(item); item.Invoke(); Profiler.EndProfileBlock(); } catch (Exception ex2) { if (Unregister == null) { Unregister = new Dictionary <Action, uint>(); } if (!Unregister.ContainsKey(item)) { Log.AlwaysLog("Script threw exception, unregistering: " + ex2, Logger.severity.ERROR); Logger.DebugNotify("A script has been terminated", 10000, Logger.severity.ERROR); Unregister.Add(item, pair.Key); } } } } } if (Unregister != null) { foreach (KeyValuePair <Action, uint> pair in Unregister) { UnRegisterForUpdates(pair.Value, pair.Key); } } } catch (Exception ex) { Log.AlwaysLog("Exception: " + ex, Logger.severity.FATAL); ManagerStatus = Status.Terminated; } finally { Globals.UpdateCount++; float instantSimSpeed = Globals.UpdateDuration / (float)(DateTime.UtcNow - m_lastUpdate).TotalSeconds; if (instantSimSpeed > 0.01f && instantSimSpeed < 1.1f) { Globals.SimSpeed = Globals.SimSpeed * 0.9f + instantSimSpeed * 0.1f; } //Log.DebugLog("instantSimSpeed: " + instantSimSpeed + ", SimSpeed: " + Globals.SimSpeed); m_lastUpdate = DateTime.UtcNow; MainLock.MainThread_AcquireExclusive(); } }