private bool IsValidPermutation(int[] permutation, SessionTable sessionTable, int frame) { int[] t = new int[permutation.Length]; for (int i = 0; i < permutation.Length; ++i) { t[permutation[i]] = sessionTable[i, frame]; } HashSet <int> used = new HashSet <int>(); for (int i = 0; i < t.Length; ++i) { if (t[i] == -1) { continue; } if (i == 0) { used.Add(t[i]); continue; } if (t[i] == t[i - 1]) { continue; } else { if (used.Contains(t[i])) { return(false); } used.Add(t[i]); } } return(true); }
// rabbit is virtual character with character id of largest // stay in session 0 in all time frame // so other session can use session 0 as a public static void AddRabbit(Story story) { var rabbit = new Character("RABBIT", 1, "", story.Characters.Count); story.rabbitId = rabbit.Id = story.Characters.Count; story.Characters.Add(rabbit); var characters = new HashSet <int>(); characters.Add(rabbit.Id); story.sessionToCharacteres.Add(rabbitSession, characters); var newSessionTable = new SessionTable(story.Characters.Count, story.FrameCount); story._sessionToLocation.Add(rabbitSession, story.LocationRoot.Id); // copy old one for (int id = 0; id < story.Characters.Count - 1; ++id) { for (int frame = 0; frame < story.TimeStamps.Length - 1; ++frame) { newSessionTable[id, frame] = story.SessionTable[id, frame]; } } for (int frame = 0; frame < story.TimeStamps.Length - 1; ++frame) { newSessionTable[rabbit.Id, frame] = rabbitSession; } story.SessionTable = newSessionTable; }
public SessionRepository(String storageConnectionString) { StorageAccount = CloudStorageAccount.Parse(storageConnectionString); TableClient = StorageAccount.CreateCloudTableClient(); SessionTable = TableClient.GetTableReference("Sessions"); SessionTable.CreateIfNotExists(); }
void insertSession(object obj) { lock (singletonLock) { try { deleteAllSession(); Hashtable hash = (Hashtable)obj; string encryptSessionKey = Encryption.Encrypt("" + hash [DatabaseManager.SESSIONKEY]); string encryptUserId = Encryption.Encrypt("" + hash [DatabaseManager.USER_ID]); var p = new SessionTable { UserId = encryptUserId, SessionKey = encryptSessionKey }; int isSuccess = connection.Update(p); if (isSuccess == 0) { connection.Insert(p); } } catch (Exception ex) { Debug.LogWarning(ex.Message); } } }
public ActionResult DeleteConfirmed(int id) { SessionTable sessionTable = db.SessionTables.Find(id); db.SessionTables.Remove(sessionTable); db.SaveChanges(); return(RedirectToAction("Index")); }
internal void PopulateSessions(string tableName) { var table = new SessionTable(tableName, this.Db); foreach (var session in this.Sessions) { table.Add(session); } }
public async Task <ISessionData> GetSession(Guid sessionId) { TableQuery <SessionTableEntry> query = new TableQuery <SessionTableEntry>() .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, sessionId.ToString())); var results = await SessionTable.ExecuteQuerySegmentedAsync(query, null); return(results.FirstOrDefault()); }
public ActionResult Edit([Bind(Include = "SessionID,Name,Start_Date,End_Date,Description")] SessionTable sessionTable) { if (ModelState.IsValid) { db.Entry(sessionTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sessionTable)); }
public ActionResult Create([Bind(Include = "SessionID,Name,Start_Date,End_Date,Description")] SessionTable sessionTable) { if (ModelState.IsValid) { db.SessionTables.Add(sessionTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sessionTable)); }
public ActionResult DeleteConfirmed(int id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } SessionTable sessionTable = db.SessionTables.Find(id); db.SessionTables.Remove(sessionTable); db.SaveChanges(); return(RedirectToAction("Index")); }
private void PriceEditor_Load(object sender, EventArgs e) { // select default... radioButton1.Checked = true; day_of_week_type = -1; { advanced_offset = this.Width - groupBox1.Location.X; Size tmp = this.Size; tmp.Width = groupBox1.Location.X; groupBox1.Location = new Point(groupBox1.Location.X + advanced_offset, groupBox1.Location.Y); dataGridView1.Size = new Size(dataGridView1.Size.Width + advanced_offset, dataGridView1.Size.Height); dataGridView1.KeyPress += new KeyPressEventHandler(dataGridView1_KeyPress); dataGridView1.PreviewKeyDown += new PreviewKeyDownEventHandler(dataGridView1_PreviewKeyDown); //tmp.Width -= 982 - 562; this.Size = tmp; } checkBoxAdvancedOptions.Checked = false; //monthCalendar1.SelectionMode = mcSelectionMode.One; sessions = new SessionTable(); sessions.Columns.Add("original_row", typeof(DataRow)); sessions.Columns.Add("original_relation_row", typeof(DataRow)); sessions.Columns[SessionTable.NameColumn].Unique = false; sessions.Columns.Add("session_macro_session_name", typeof(String)); session_macros = new SessionMacroTable(); session_macros.Columns.Add("original_row", typeof(DataRow)); session_macros.Columns[SessionMacroTable.NameColumn].Unique = false; game_groups = new PackGroupTable(); game_groups.Columns.Add("original_row", typeof(DataRow)); game_groups.Columns[PackGroupTable.NameColumn].Unique = false; listBox3.DataSource = session_macros; listBox3.DisplayMember = SessionMacroTable.NameColumn; listBox1.DataSource = sessions; listBox1.DisplayMember = SessionTable.NameColumn; listBox2.DataSource = game_groups; listBox2.DisplayMember = PackGroupTable.NameColumn; foreach (DataRow row in ControlList.schedule.session_macros.Rows) { DataRow newrow = session_macros.AddClonedRow(row, true); newrow["original_row"] = row; } radioButtonNoIncrement.Checked = true; dataGridView1.CellValueChanged += new DataGridViewCellEventHandler(dataGridView1_CellValueChanged); }
public static void ClassInit(TestContext context) { CloudStorageEmulatorShepherd shepherd = new CloudStorageEmulatorShepherd(); shepherd.Start(); StorageAccount = CloudStorageAccount.Parse(DevelopmentStorageAccountConnectionString); TableClient = StorageAccount.CreateCloudTableClient(); SessionTable = TableClient.GetTableReference("Sessions"); SessionPlayerTable = TableClient.GetTableReference("SessionPlayers"); SessionTable.DeleteIfExists(); SessionPlayerTable.DeleteIfExists(); }
protected void PopulateTable() { tableSource = new MWC.iOS.AL.DaysTableSource(); SessionTable.Source = tableSource; SessionTable.ReloadData(); tableSource.DayClicked += delegate(object sender, MWC.iOS.AL.DayClickedEventArgs e) { LoadSessionDayScreen(e.DayName, e.Day); }; if (AppDelegate.IsPad) { PopulateiPadTables(); } }
// GET: SessionTables/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SessionTable sessionTable = db.SessionTables.Find(id); if (sessionTable == null) { return(HttpNotFound()); } return(View(sessionTable)); }
/// <summary> /// Removes session. /// </summary> /// <param name="p_session">Session ID.</param> /// <param name="logWriter">Log writer.</param> public void RemoveSession(string p_session) { lock (SessionTable) { if (SessionTable.Contains(p_session) == false) { WriteLog(String.Format("session[{0}]: {1}", p_session, "doesn't exist"), true); return; } SessionTable.Remove(p_session); } WriteLog(String.Format("session[{0}]: {1}", p_session, "removed"), true); }
// when close button is pressed! private void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { if (e.CloseReason == CloseReason.UserClosing) { DialogResult result = MessageBox.Show("Do you really want to LogOut?", "Warning!", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { DataClasses1DataContext db = new DataClasses1DataContext(); UserLogIN q22 = (from UserLogIN in db.UserLogINs where UserLogIN.Id == uID select UserLogIN).Single(); q22.LastLogoutTime = DateTime.Now; db.SubmitChanges(); MessageBox.Show("You are Logged out\nLast LoginTime : " + q22.LastLoginTime.ToString() + "\nLast LogOut Time : " + q22.LastLogoutTime.ToString()); SessionTable dt = new SessionTable(); dt.UserID = uID; dt.LogInTime = (DateTime)q22.LastLoginTime; dt.LogOutTime = DateTime.Now; db.SessionTables.InsertOnSubmit(dt); db.SubmitChanges(); parent.Visible = true; for (int i = 0; i < arrTrackIndex; i++) { arrTrackOfOpenedForm[i].Dispose(); } //this.Dispose(); //Application.Exit(); } else { e.Cancel = true; } } else { e.Cancel = true; } } catch { MessageBox.Show("Invalid Input!"); } }
protected void LinkButton2_Click(object sender, EventArgs e) { SessionTable st = new SessionTable(); st.Sessiontitle = TextBox1.Text; st.TakenBy = TextBox2.Text; st.Date = DateTime.Today; st.Time = TextBox4.Text; st.SessionDesc = TextBox5.Text; Fileupload1.SaveAs(Server.MapPath("~/Dashboard/SessionPic/" + Fileupload1.FileName)); st.Uploadpic = "/Dashboard/SessionPic/" + Fileupload1.FileName; dl.da.SessionTables.InsertOnSubmit(st); dl.da.SubmitChanges(); Response.Write("<script>alert('Registration successfully')</script>"); TextBox1.Text = TextBox2.Text = TextBox3.Text = TextBox4.Text = TextBox5.Text = ""; }
// GET: SessionTables/Details/5 public ActionResult Details(int?id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SessionTable sessionTable = db.SessionTables.Find(id); if (sessionTable == null) { return(HttpNotFound()); } return(View(sessionTable)); }
// GET: SessionTables/Edit/5 public ActionResult Edit(int?id) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SessionTable sessionTable = db.SessionTables.Find(id); if (sessionTable == null) { return(HttpNotFound()); } ViewBag.UserID = new SelectList(db.UserTables, "UserID", "FullName", sessionTable.UserID); return(View(sessionTable)); }
public async Task <bool> ReservePlayerColour(Guid sessionId, String sessionEtag, PlayerColour colour) { ISessionData sessionData = await GetSession(sessionId); SessionTableEntry session = sessionData as SessionTableEntry; if (!session.IsColourUsed(colour)) { if (session.ETag == sessionEtag) { try { session.AddUsedColour(colour); // Write entry back (fails on write conflict) TableOperation insertOperation = TableOperation.Replace(session); await SessionTable.ExecuteAsync(insertOperation); return(true); } catch (StorageException exception) { if (exception.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed) { throw new ConcurrencyException(); } else { throw exception; } } } else { throw new ConcurrencyException(); } } else { return(false); } }
public ActionResult Edit(SessionTable sessionTable) { if (string.IsNullOrEmpty(Convert.ToString(Session["UserName"]))) { return(RedirectToAction("Login", "Home")); } int userid = Convert.ToInt32(Convert.ToString(Session["UserID"])); sessionTable.UserID = userid; if (ModelState.IsValid) { db.Entry(sessionTable).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.UserTables, "UserID", "FullName", sessionTable.UserID); return(View(sessionTable)); }
public async Task IntegrationTestSetSessionPhase_WithCreateCommandQueueTable() { // Arrange SessionRepository repository = new SessionRepository(DevelopmentStorageAccountConnectionString); Guid validGuid = new Guid("ADECC70C-7964-4648-9E4C-F4C71EA4502A"); ISession sessionDetails = await repository.SetupSession(validGuid, "CreatingUser"); // Act await repository.SetSessionPhase(validGuid, sessionDetails.PhaseId, SessionPhase.Reinforcements); // Assert TableOperation operation = TableOperation.Retrieve <SessionTableEntry>(validGuid.ToString(), "CreatingUser"); TableResult result = await SessionTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(SessionTableEntry)); SessionTableEntry resultStronglyTyped = result.Result as SessionTableEntry; Assert.AreNotEqual(sessionDetails.PhaseId, resultStronglyTyped.PhaseId); Assert.AreEqual(SessionPhase.Reinforcements, resultStronglyTyped.PhaseType); }
public async Task <IEnumerable <ISessionData> > GetSessions() { // Doing a full query like this is very expensive, as if we ever need to support more than a couple of sessions // then we should probably maintain a list of open sessions in the database List <SessionTableEntry> results = new List <SessionTableEntry>(); TableQuery <SessionTableEntry> query = new TableQuery <SessionTableEntry>(); // Initialize the continuation token to null to start from the beginning of the table. TableContinuationToken continuationToken = null; // Loop until the continuation token comes back as null do { var queryResults = await SessionTable.ExecuteQuerySegmentedAsync(query, continuationToken); continuationToken = queryResults.ContinuationToken; results.AddRange(queryResults.Results); }while (continuationToken != null); return(results); }
public async Task IntegrationTestSetSessionPhase() { // Arrange SessionRepository repository = new SessionRepository(DevelopmentStorageAccountConnectionString); Guid validGuid = new Guid("46DAC828-3EFC-45E2-9294-B39AE9403DAA"); ISession sessionDetails = await repository.SetupSession(validGuid, "CreatingUser"); // Act await repository.SetSessionPhase(validGuid, sessionDetails.PhaseId, SessionPhase.SpoilsOfWar); // Assert TableOperation operation = TableOperation.Retrieve <SessionTableEntry>(validGuid.ToString(), "CreatingUser"); TableResult result = await SessionTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(SessionTableEntry)); SessionTableEntry resultStronglyTyped = result.Result as SessionTableEntry; Assert.AreNotEqual(sessionDetails.PhaseId, resultStronglyTyped.PhaseId); Assert.AreEqual(SessionPhase.SpoilsOfWar, resultStronglyTyped.PhaseType); }
public async Task SetSessionPhase(Guid sessionId, Guid currentPhaseId, SessionPhase newPhase) { ISessionData sessionData = await GetSession(sessionId); SessionTableEntry session = sessionData as SessionTableEntry; if (session.PhaseId == currentPhaseId) { try { session.PhaseId = Guid.NewGuid(); session.RawPhaseType = (Int32)newPhase; // Increase the round number (if required) if (newPhase == SessionPhase.Victory) { session.RawRound += 1; } // Write entry back (fails on write conflict) TableOperation insertOperation = TableOperation.Replace(session); await SessionTable.ExecuteAsync(insertOperation); } catch (StorageException exception) { if (exception.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed) { throw new ConcurrencyException(); } else { throw exception; } } } else { throw new ConcurrencyException(); } }
public async Task <Guid> CreateSession(String userId, PlayerColour colour) { Guid newSessionGuid = Guid.NewGuid(); // Create a new table to store all the data for this session var dataTable = GetTableForSessionData(newSessionGuid); await dataTable.CreateIfNotExistsAsync(); // Create a new table entry SessionTableEntry newSession = new SessionTableEntry(userId, newSessionGuid); // Kick off the insert operation TableOperation insertOperation = TableOperation.Insert(newSession); await SessionTable.ExecuteAsync(insertOperation); // Add the player to the session await ReservePlayerColour(newSessionGuid, newSession.ETag, colour); await JoinSession(newSessionGuid, userId, colour); // Return the new session GUID return(newSessionGuid); }
public async Task IntegrationTestReservePlayerColour() { // Arrange SessionRepository repository = new SessionRepository(DevelopmentStorageAccountConnectionString); Guid validGuid = new Guid("E5894BE3-6074-4516-93FB-BC851C1E4246"); ISessionData sessionData = await repository.SetupSession(validGuid, "CreatingUser"); // Act bool isReserved = await repository.ReservePlayerColour(validGuid, sessionData.CurrentEtag, PlayerColour.Blue); // Assert Assert.AreEqual(true, isReserved); TableOperation operation = TableOperation.Retrieve <SessionTableEntry>(validGuid.ToString(), "CreatingUser"); TableResult result = await SessionTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(SessionTableEntry)); SessionTableEntry resultStronglyTyped = result.Result as SessionTableEntry; Assert.IsTrue(resultStronglyTyped.IsColourUsed(PlayerColour.Blue)); Assert.AreNotEqual(resultStronglyTyped.CurrentEtag, sessionData.CurrentEtag); }
public async Task IntegrationTestCreateSession() { // Arrange SessionRepository repository = new SessionRepository(DevelopmentStorageAccountConnectionString); String dummyUserId = "DummyUserId"; // Act Guid newSessionGuid = await repository.CreateSession(dummyUserId, PlayerColour.Black); // Assert Assert.IsNotNull(newSessionGuid); var dataTable = repository.GetTableForSessionData(newSessionGuid); TableOperation operation = TableOperation.Retrieve <SessionTableEntry>(newSessionGuid.ToString(), dummyUserId); TableResult result = await SessionTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(SessionTableEntry)); SessionTableEntry resultStronglyTyped = result.Result as SessionTableEntry; Assert.AreEqual(dummyUserId, resultStronglyTyped.OwnerId); Assert.AreEqual(Guid.Empty, resultStronglyTyped.PhaseId); Assert.AreEqual(SessionPhase.NotStarted, resultStronglyTyped.PhaseType); Assert.IsTrue(resultStronglyTyped.IsColourUsed(PlayerColour.Black)); operation = TableOperation.Retrieve <NationTableEntry>(newSessionGuid.ToString(), "Nation_" + dummyUserId); result = await dataTable.ExecuteAsync(operation); Assert.IsNotNull(result.Result); Assert.IsInstanceOfType(result.Result, typeof(NationTableEntry)); NationTableEntry resultPlayerStronglyTyped = result.Result as NationTableEntry; Assert.AreEqual(newSessionGuid, resultPlayerStronglyTyped.SessionId); Assert.AreEqual(dummyUserId, resultPlayerStronglyTyped.UserId); Assert.AreEqual(Guid.Empty, resultPlayerStronglyTyped.CompletedPhase); }
public SnapshotSelector(ScheduleCurrents currents) { this.currents = currents; this.schedule = currents.Schedule; schedule.Clear(); this.schedule.snapshot = true; try { DataTable tmp = new SessionTable(); tmp.Prefix = ((DataTable)this.schedule.sessions).Prefix; tmp.TableName = ((DataTable)this.schedule.sessions).TableName; tmp.Columns[SessionTable.NameColumn].Unique = false; DsnSQLUtil.FillDataTable(schedule.schedule_dsn, tmp, null, null); snapshot_sessions = new DataView(tmp, null, SessionTable.PrimaryKey, DataViewRowState.CurrentRows); InitializeComponent(); } catch { this.schedule.snapshot = false; } }
void insertSession (object obj) { lock (singletonLock) { try { deleteAllSession(); Hashtable hash = (Hashtable)obj; string encryptSessionKey = Encryption.Encrypt ("" + hash [DatabaseManager.SESSIONKEY]); string encryptUserId = Encryption.Encrypt ("" + hash [DatabaseManager.USER_ID]); var p = new SessionTable{ UserId = encryptUserId, SessionKey = encryptSessionKey }; int isSuccess = connection.Update(p); if (isSuccess == 0 ) { connection.Insert(p); } } catch(Exception ex) { Debug.LogWarning (ex.Message); } } }
//------------------------------------------------------------------------------------------------------------------------- // //------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Adds session. /// </summary> /// <param name="p_session">Session ID.</param> /// <param name="p_responsor">Session object.</param> /// <param name="logWriter">Log writer.</param> public void AddSession(string p_session, MailResponsor p_responsor) { SessionTable.Add(p_session, p_responsor); WriteLog(String.Format("session[{0}]: {1}", p_session, "added"), true); }