public static T AddComponentWithData <T>(GameObject gameObject, DataBaseEntry data) where T : DataComponent { T result = gameObject.AddComponent(typeof(T)) as T; result.InitFromData(data); return(result); }
public void addEntries() { bool yes = true; InstanceContext context = new InstanceContext(this); ServiceReference1.ServiceClient Proxy = new ServiceReference1.ServiceClient(context); string[] lines = System.IO.File.ReadAllLines(@"C:\Users\duncanc\Documents\WriteLines.txt"); //Proxy.AddAppletEntry(z); for (int i = 0; i < 5000; i++) { DataBaseEntry x; string[] parts = lines[0].Split(':'); if (yes) { x = new DataBaseEntry(parts[0], "SessionUnlock", parts[2], parts[3], parts[4], parts[5], DateTime.Now, false, false, new TimeSpan(0, 0, 0)); } else { x = new DataBaseEntry(parts[0], "SessionLock", parts[2], parts[3], parts[4], parts[5], DateTime.Now, false, false, new TimeSpan(0, 5, 0)); } yes = !yes; Proxy.AddAppletEntry(x); } }
public static DataBaseEntry CreateEntry(string text) { var entry = new DataBaseEntry(CreateID(), text, DateTime.Now); entries.Add(entry); return(entry); }
public IWindow OpenWindowWithData(Type windowTypeToOpen, DataBaseEntry data) { var window = OpenWindow(windowTypeToOpen); var dataComponentWindow = window as WindowWithDataComponent; dataComponentWindow.InitFromData(data); return(window); }
public IWindow OpenWindowWithData(Type windowTypeToOpen, DataBaseEntry data) { IWindow window = this.OpenWindow(windowTypeToOpen); WindowWithDataComponent windowWithDataComponent = window as WindowWithDataComponent; windowWithDataComponent.InitFromData(data); return(window); }
//Assigns ETA and UserID to DataBaseEntry and returns it public void FinishDataBaseEntry(DataBaseEntry entry) { //Confirms deviceID is correct and prevents duplicate entry if (this.deviceID == entry.DeviceID && sessionID == entry.SessionID) { entry.UserID = this.userID; entry.UserName = userName; c.AddAppletEntryAsync(entry); } }
public void Load(X360IO io) { IO = io; IO.Stream.Position = 0x0; Magic = IO.Reader.ReadUInt32(); Entries = new List<DataBaseEntry>(); while (IO.Stream.Position < IO.Stream.Length) { DataBaseEntry entry = new DataBaseEntry(); entry.Load(IO); Entries.Add(entry); } }
public void Load(X360IO io) { IO = io; IO.Stream.Position = 0x0; Magic = IO.Reader.ReadUInt32(); Entries = new List <DataBaseEntry>(); while (IO.Stream.Position < IO.Stream.Length) { DataBaseEntry entry = new DataBaseEntry(); entry.Load(IO); Entries.Add(entry); } }
public void PopulateListBox() { updateDatabase(); deleteRow(i); int rowCount = noofrows(); for (int i = 1; i <= rowCount; i++) { var entry = new DataBaseEntry { Id = returnID(i), Name = SelectName(i) } Items.Add(entry); } }
public void addDevices() { InstanceContext context = new InstanceContext(this); ServiceReference1.ServiceClient Proxy = new ServiceReference1.ServiceClient(context); System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\duncanc\Documents\WriteLines.txt"); for (int i = 0; i < 80; i++) { string name = RandomNameGenerator.NameGenerator.Generate(RandomNameGenerator.Gender.Male); const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random r = new Random(); string ID = new string(Enumerable.Repeat(chars, 20).Select(s => s[r.Next(s.Length)]).ToArray()); string deviceID = new string(Enumerable.Repeat(chars, 20).Select(s => s[r.Next(s.Length)]).ToArray()); string deviceName = new string(Enumerable.Repeat(chars, 8).Select(s => s[r.Next(s.Length)]).ToArray()); Device devSuc = new Device(deviceID, deviceName, ID, name, false); Proxy.AddDevice(devSuc); string sessionID = new string(Enumerable.Repeat(chars, 20).Select(s => s[r.Next(s.Length)]).ToArray()); DataBaseEntry z = new DataBaseEntry(name, "SessionUnlock", ID, deviceID, deviceName, sessionID, DateTime.Now, false, false, new TimeSpan(0, 0, 0)); file.WriteLine(z.UserName + ":" + z.EventType + ":" + z.UserID + ":" + z.DeviceID + ":" + z.MachineName + ":" + z.SessionID + ":" + z.TimeOfEvent + ":" + z.AutomaticLock + ":" + z.RemoteAccess + ":" + z.ETA); } }
protected override void OnSessionChange(SessionChangeDescription changeDescription) { try { Trace.WriteLine("Session Changed. Details: " + changeDescription.Reason); InstanceContext iC = new InstanceContext(this); c = new ServiceClient(iC); c.ChannelFactory.Faulted += new EventHandler(ChannelFactory_Faulted); DataBaseEntry dBE = new DataBaseEntry(); dBE.EventType = changeDescription.Reason.ToString(); dBE.DeviceID = deviceID; dBE.MachineName = machineName; dBE.SessionID = changeDescription.SessionId.ToString(); dBE.TimeOfEvent = DateTime.Now; dBE.AutomaticLock = (changeDescription.Reason == SessionChangeReason.SessionUnlock || changeDescription.Reason == SessionChangeReason.SessionLogon) ? false:true; dBE.RemoteAccess = (changeDescription.Reason == SessionChangeReason.RemoteConnect || changeDescription.Reason == SessionChangeReason.RemoteDisconnect); dBE.ETA = new TimeSpan(0, 20, 0); try { c.AddServiceEntry(dBE); } catch (CommunicationException cError) { if (c.State == CommunicationState.Faulted) { ChannelFactory_Faulted(this, new EventArgs()); } } } catch (Exception e) { } }
public void InitFromData(DataBaseEntry data) { this.Data = data; }
public void FinishDataBaseEntry(DataBaseEntry entry) { //throw new NotImplementedException(); }
//Called when any of the ETA buttons are clicked or when hotkeys are used (terrible, I know) private async void allETABtn_Click(object sender, EventArgs e) { //Determine ETA switch (((Button)sender).Text) { case "ETA 1": ETA = new TimeSpan(0, int.Parse(txtETA1.Text), 0); break; case "ETA 2": ETA = new TimeSpan(0, int.Parse(txtETA2.Text), 0); break; case "ETA 3": ETA = new TimeSpan(0, int.Parse(txtETA3.Text), 0); break; default: //TO DO: Think of best default break; } //Create device and send to API try { //Create device DataBaseEntry dBE = new DataBaseEntry(); dBE.EventType = "SessionLock"; dBE.UserID = userID; dBE.UserName = userName; dBE.DeviceID = deviceID; dBE.MachineName = machineName; dBE.TimeOfEvent = DateTime.Now; dBE.AutomaticLock = false; dBE.RemoteAccess = false; dBE.ETA = ETA; try { c.RegisterClient(deviceID, false); //Send to API c.AddAppletEntry(dBE); } catch (CommunicationException cError) { if (c.State == CommunicationState.Faulted) { ChannelFactory_Faulted(this, new EventArgs()); } else { throw (cError); } } } catch (Exception ex) { MessageBox.Show("Program encountered the following error: " + e.GetType() + " " + ex.Message, "Progam Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } //Lock machine LockWorkStation(); }
void IServiceCallback.FinishDataBaseEntry(DataBaseEntry entry) { //Ignore }