Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 5
0
        public IWindow OpenWindowWithData(Type windowTypeToOpen, DataBaseEntry data)
        {
            IWindow window = this.OpenWindow(windowTypeToOpen);
            WindowWithDataComponent windowWithDataComponent = window as WindowWithDataComponent;

            windowWithDataComponent.InitFromData(data);
            return(window);
        }
Exemplo n.º 6
0
 //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);
     }
 }
Exemplo n.º 7
0
 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);
     }
 }
Exemplo n.º 8
0
 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);
     }
 }
Exemplo n.º 9
0
 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);
     }
 }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
        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;
 }
Exemplo n.º 13
0
 public void FinishDataBaseEntry(DataBaseEntry entry)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 14
0
        //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();
        }
Exemplo n.º 15
0
 void IServiceCallback.FinishDataBaseEntry(DataBaseEntry entry)
 {
     //Ignore
 }