Beispiel #1
0
        public static void RefreshLoads()
        {
            foreach (var pcinfo in WOLClass.getNetworkComputers())
            {
                string[] pc = pcinfo.Split(',');
                if (NetworkInfo.ContainsKey(pc[0]) == false)            //2
                {
                    if (OfflineNetworkInfo.ContainsKey(pc[0]) == false) //2
                    {
                        //New Online PC

                        /*
                         * if (AllIP.Contains(pc[2]))
                         * {
                         *  continue;
                         * }
                         */
                        NetworkItems NI = new NetworkItems();
                        NI.HostName   = NI.ShownName = pc[0];//2
                        NI.IP         = pc[0];
                        NI.PCStatu    = PCStatus.Online;
                        NI.MacAddress = pc[1];
                        NetworkInfo.Add(NI.IP, NI);
                        ALLNetworks.Add(NI.IP, NI);
                    }
                    else
                    {
                        //Offline but now Online
                        NetworkItems NI = OfflineNetworkInfo[pc[0]];// pc[2]];
                        NI.IP      = pc[0];
                        NI.PCStatu = PCStatus.Online;
                        if (NI.MacAddress == "" || string.IsNullOrEmpty(NI.MacAddress))
                        {
                            NI.MacAddress = pc[1];
                        }
                        NetworkInfo.Add(NI.IP, NI);
                        OfflineNetworkInfo.Remove(NI.IP);
                    }
                }
                else
                {
                    if (OfflineNetworkInfo.ContainsKey(pc[0]))       //2
                    {                                                //Offline but now Online
                        NetworkItems NI = OfflineNetworkInfo[pc[0]]; //2
                        NI.IP      = pc[0];
                        NI.PCStatu = PCStatus.Online;
                        if (NI.MacAddress == "" || string.IsNullOrEmpty(NI.MacAddress))
                        {
                            NI.MacAddress = pc[1];
                        }
                        OfflineNetworkInfo.Remove(NI.IP);
                    }
                    else
                    {
                        //Online but now Offline
                    }
                }
            }
        }
 public AddTime(ALEmanCafeServer ACS, NetworkItems NI)
 {
     InitializeComponent();
     this.TimeTextBox.KeyDown += new KeyEventHandler(TimeTextBox_KeyDown);
     this.ACS = ACS;
     this.NI  = NI;
     TimeTextBox.TextChanged += new EventHandler(TimeTextBox_TextChanged);
 }
        public SystemInofrmation(NetworkItems OM)
        {
            InitializeComponent();
            if (OM == null)
            {
                foreach (NetworkItems NI in NetworkItems.ALLNetworks.Values)
                {
                    string[] st = new string[8];
                    st[0] = NI.HostName;
                    st[1] = NI.UserName;
                    st[2] = NI.IP;
                    st[3] = NI.MacAddress;
                    st[4] = NI.MyOperatingSystem;
                    st[5] = NI.TotalMemory;
                    st[6] = NI.FreeMemory;
                    st[7] = NI.Harddisc;

                    ListViewItem LVI = new ListViewItem(st);
                    LVI.Text = LVI.ToolTipText = LVI.Name = st[0];

                    if (this.listView1.InvokeRequired)
                    {
                        this.listView1.BeginInvoke(new MethodInvoker(
                                                       () => this.listView1.Items.Add(LVI)));
                    }
                    else
                    {
                        this.listView1.Items.Add(LVI);
                    }
                }
            }
            else
            {
                string[] st = new string[8];
                st[0] = OM.HostName;
                st[1] = OM.UserName;
                st[2] = OM.IP;
                st[3] = OM.MacAddress;
                st[4] = OM.MyOperatingSystem;
                st[5] = OM.TotalMemory;
                st[6] = OM.FreeMemory;
                st[7] = OM.Harddisc;

                ListViewItem LVI = new ListViewItem(st);
                LVI.Text = LVI.ToolTipText = LVI.Name = st[0];

                if (this.listView1.InvokeRequired)
                {
                    this.listView1.BeginInvoke(new MethodInvoker(
                                                   () => this.listView1.Items.Add(LVI)));
                }
                else
                {
                    this.listView1.Items.Add(LVI);
                }
            }
        }
        public ChangePC(ALEmanCafeServer ACS, NetworkItems NI)
        {
            InitializeComponent();
            this.ACS = ACS;
            this.NI = NI;
            this.KeyDown += new KeyEventHandler(TimeTextBox_KeyDown);
            this.listView1.KeyDown += new KeyEventHandler(TimeTextBox_KeyDown);
            this.CancelCloseButton.KeyDown += new KeyEventHandler(TimeTextBox_KeyDown);
            this.OKButton.KeyDown += new KeyEventHandler(TimeTextBox_KeyDown);
            this.listView1.ItemActivate += new EventHandler(listView1_ItemActivate);
            if (this.listView1.InvokeRequired)
            {
                this.listView1.BeginInvoke(new MethodInvoker(
                    () =>
                    {
                        this.listView1.SmallImageList = new ImageList();
                        this.listView1.SmallImageList.ImageSize = new Size(31, 40);
                        this.listView1.SmallImageList.Images.Add("OnlineDisplay", Properties.Resources.OnlineDisplay);
                    }));
            }
            else
            {
                this.listView1.SmallImageList = new ImageList();
                this.listView1.SmallImageList.ImageSize = new Size(31, 40);
                this.listView1.SmallImageList.Images.Add("OnlineDisplay", Properties.Resources.OnlineDisplay);
            }

            foreach (NetworkItems NI2 in NetworkItems.IdleNetworks.Values)
            {
                if (NI2.Connected == false) continue;
                string[] st = new string[3];
                st[0] = NI2.ShownName;
                st[1] = NI2.IP;
                st[2] = NI2.UsedTime.ToString();
                ListViewItem LVI = new ListViewItem(st);
                LVI.Text = LVI.Name = NI2.ShownName;
                LVI.ToolTipText = "From " + NI.ShownName + " To " + NI2.ShownName;
                LVI.Tag = NI2;
                LVI.ImageKey = "OnlineDisplay";
                if (this.listView1.InvokeRequired)
                {
                    this.listView1.BeginInvoke(new MethodInvoker(
                        () => this.listView1.Items.Add(LVI)));
                }
                else
                {
                    this.listView1.Items.Add(LVI);
                }
            }

            this.listView1.ItemSelectionChanged += ListView1_ItemSelectionChanged;
        }
Beispiel #5
0
        public RemoteApplications(ALEmanCafeServer ACS, List <AppInfo> AIL, NetworkItems NI)
        {
            InitializeComponent();
            this.ACS = ACS;
            this.AIL = AIL;
            this.NI  = NI;
            //listView1.SmallImageList = new ImageList();
            //  int tname = 1;
            foreach (ALEmanCafe_Server.RemoteApplications.AppInfo AI in AIL)
            {
                string[] info = new string[4];
                info[0] = AI.AppName;
                info[1] = AI.AppTitle;
                info[2] = AI.AppPath;
                info[3] = AI.APPID.ToString();
                ListViewItem Lvi = new ListViewItem(info);
                Lvi.Name = Lvi.Text = Lvi.ToolTipText = AI.AppName;

                /*
                 * if (AI.AppICon != null)
                 *  if (this.listView1.InvokeRequired)
                 *  {
                 *      this.listView1.BeginInvoke(new MethodInvoker(
                 *          () => this.listView1.SmallImageList.Images.Add(tname.ToString(), AI.AppICon)));
                 *  }
                 *  else
                 *  {
                 *      this.listView1.SmallImageList.Images.Add(tname.ToString(), AI.AppICon);
                 *  }
                 *
                 * Lvi.ImageKey = tname.ToString();
                 * tname++;
                 */
                if (this.AppsView.InvokeRequired)
                {
                    this.AppsView.BeginInvoke(new MethodInvoker(
                                                  () => this.AppsView.Items.Add(Lvi)));
                }
                else
                {
                    this.AppsView.Items.Add(Lvi);
                }
            }
            if (AIL.Count <= 0)
            {
                this.TerminateSelected.Enabled = false;
            }
            AppsView.MouseClick += new MouseEventHandler(AppsView_MouseClick);
            AppsView.KeyDown    += new KeyEventHandler(AppsView_KeyPress);
        }
Beispiel #6
0
        public static void Loed()
        {
            NetworkInfo        = new Dictionary <string, NetworkItems>();
            OfflineNetworkInfo = new Dictionary <string, NetworkItems>();
            ALLNetworks        = new Dictionary <string, NetworkItems>();
            WOLClass.SetMyIP();
            //  List<string> notinsure = new List<string>();
            var gnc = WOLClass.getNetworkComputers();

            foreach (var pcinfo in gnc)
            {
                string[] pc = pcinfo.Split(',');

                /*
                 * if (pc[2].StartsWith("192.168"))
                 * {
                 *  notinsure.Add(pcinfo);
                 *  continue;
                 * }
                 */
                NetworkItems NI = new NetworkItems();
                NI.HostName   = NI.ShownName = pc[0];//2
                NI.IP         = pc[0];
                NI.PCStatu    = PCStatus.Online;
                NI.MacAddress = pc[1];
                //AllIP.Add(NI.IP);
                NetworkInfo.Add(NI.IP, NI);
                ALLNetworks.Add(NI.IP, NI);
            }

            /*
             * foreach (var pcinfo in notinsure)
             * {
             *  string[] pc = pcinfo.Split(',');
             *  if (AllIP.Contains(pc[2]))
             *  {
             *      continue;
             *  }
             *  NetworkItems NI = new NetworkItems();
             *  NI.HostName = pc[2];
             *  NI.IP = pc[0];
             *  NI.PCStatu = PCStatus.Online;
             *  NI.MacAddress = pc[1];
             *  NetworkInfo.Add(NI.HostName, NI);
             *  ALLNetworks.Add(NI.HostName, NI);
             * }
             */
        }
Beispiel #7
0
        public static void RemovePC(NetworkItems NI)
        {
            MySqlConnection conn = new MySqlConnection(Program.connStr);


            string s0 = "use `aleman_cafe_server`;  DELETE FROM `timers` WHERE hostname='" + NI.HostName + "';";;

            try
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand(s0, conn);
                cmd.ExecuteNonQuery();
            }
            catch { conn.Close(); return; }
            conn.Close();
        }
 private void OKButton_Click(object sender, EventArgs e)
 {
     if (this.listView1.SelectedItems.Count > 0)
     {
         string sip = this.listView1.SelectedItems[0].SubItems[1].Text;
         NetworkItems NI2 = NetworkItems.IdleNetworks[sip];
         if (NI2 != null)
         {
             if (NI2.Paid || NI2.UsedTime <= 0 || NI2.TimeStatu == NetworkItems.TimeStatus.None)
             {
                 ACS.ChangePC(NI, NI2);
                 this.Close();
             }
             else
                 MessageBox.Show(NI2.ShownName + " have old timer!", "PC cannot changed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     
     }
 }
Beispiel #9
0
        public static void CreateVertualMachine(PCStatus State)
        {
            NetworkItems NI = new NetworkItems();

            NI.HostName = NI.ShownName = "ALEman" + new Random().Next(1, 14);
            while (NetworkInfo.ContainsKey(NI.IP) || OfflineNetworkInfo.ContainsKey(NI.IP))
            {
                NI.HostName = NI.ShownName = "ALEman" + new Random().Next(1, 14);
            }

            NI.IP         = "192.168.1." + new Random().Next(2, 254);
            NI.PCStatu    = State;
            NI.MacAddress = "255-255-255-" + new Random().Next(200, 255);
            if (State == PCStatus.Online)
            {
                NetworkInfo.Add(NI.IP, NI);
            }
            else
            {
                OfflineNetworkInfo.Add(NI.IP, NI);
            }
            ALLNetworks.Add(NI.IP, NI);
        }
Beispiel #10
0
        public static bool LoadSystemlogTimers()
        {
            MySqlConnection conn = new MySqlConnection(Program.connStr);

            conn = new MySqlConnection(Program.connStr);
            conn.Open();
            string       s0  = "use `aleman_cafe_server`; SELECT * FROM `timers`";
            MySqlCommand cmd = new MySqlCommand(s0, conn);

            try
            {
                var      rdr = cmd.ExecuteReader();
                bool     CanUseInternet = true, Paid = false;
                uint     LimitedTime, UsedTime, RemainingTime;
                DateTime StartTime, StopedTime;
                long     PausedTime;
                string   IP = "", MacAddress = "", HostName, ShownName;

                while (rdr.Read())
                {
                    if (rdr.GetInt16(0) == 0)
                    {
                        CanUseInternet = false;
                    }
                    else
                    {
                        CanUseInternet = true;
                    }
                    if (rdr.GetInt16(1) == 0)
                    {
                        Paid = false;
                    }
                    else
                    {
                        Paid = true;
                    }
                    LimitedTime   = rdr.GetUInt32(2);
                    UsedTime      = rdr.GetUInt32(3);
                    RemainingTime = rdr.GetUInt32(4);
                    StartTime     = new DateTime(rdr.GetInt64(5));
                    StopedTime    = new DateTime(rdr.GetInt64(6));
                    IP            = rdr.GetString(7);
                    MacAddress    = rdr.GetString(8);
                    HostName      = rdr.GetString(9);
                    ShownName     = rdr.GetString(10);
                    PausedTime    = rdr.GetInt64(11);
                    if (StopedTime.Year.ToString() == "1" && StartTime.Year.ToString() != "1")
                    {
                        StopedTime = new DateTime(StartTime.AddMinutes(UsedTime).Ticks + PausedTime);
                    }
                    NetworkItems NI = new NetworkItems();
                    NI.IP             = IP;
                    NI.MacAddress     = MacAddress;
                    NI.CanUseInternet = CanUseInternet;
                    NI.HostName       = HostName;
                    NI.ShownName      = ShownName;
                    NI.Paid           = Paid;
                    NI.LimitedTime    = LimitedTime;
                    NI.UsedTime       = UsedTime;
                    NI.RemainingTime  = RemainingTime;
                    NI.PausedTime     = PausedTime;
                    NI.StartTime      = StartTime;
                    NI.StopedTime     = StopedTime;
                    if (rdr.GetString(11) == "0")
                    {
                        NI.TimeStatu = NetworkItems.TimeStatus.None;
                    }
                    else if (rdr.GetString(11) == "1")
                    {
                        NI.TimeStatu = NetworkItems.TimeStatus.Login;
                    }
                    else if (rdr.GetString(11) == "2")
                    {
                        NI.TimeStatu = NetworkItems.TimeStatus.Time;
                    }
                    else
                    {
                        NI.TimeStatu = NetworkItems.TimeStatus.None;
                    }
                    //   if (NI.TimeStatu != NetworkItems.TimeStatus.None && NI.StopedTime.Year.ToString() != "1")
                    //     NI.Paused = true;
                    //          MessageBox.Show(IP + ", " + MacAddress + ", " + NI.TimeStatu);
                    NetworkItems.OldTimers.Add(NI.IP, NI);
                }
                rdr.Close();
                conn.Close();
            }
            catch (Exception ee)
            {
                conn.Close();
                //  MessageBox.Show("There are an error and database cannot be loaded." + Environment.NewLine + ee.ToString(), "Database Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (MessageBox.Show("There are an error and database cannot be loaded, do you want to create new database?" + Environment.NewLine + (Program.isAdmin ? ee.ToString() : ee.Message), "Database Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                {
                    if (Program.isAdmin)
                    {
                        CreateDB();
                    }
                }
                return(false);
            }
            return(true);
        }
 public SendMessage(ALEmanCafeServer ACS, NetworkItems NI)
 {
     InitializeComponent();
     this.ACS = ACS;
     this.NI  = NI;
 }
        public RemoteManagement(ALEmanCafeServer ACS, NetworkItems NI)
        {
            InitializeComponent();
            this.ACS   = ACS;
            this.NI    = NI;
            this.NI.RM = this;
            this.RPort = Program.PPort;
            Program.PPort++;
            this.SPort = Program.PPort;
            Program.PPort++;
            //  this.ACS.writeamess("IP : " + NI.IP);
            this.ACS.SendPCStatus(NI, ALEmanCafeServer.MessageStatus.startremote, false, (uint)this.RPort, false, null, null, null, this.SPort);
            this.FormClosing  += new FormClosingEventHandler(RemoteManagement_FormClosing);
            pictureBox1.Paint += PictureBox1Paint;

            ReciverTimer           = new System.Timers.Timer(20);
            ReciverTimer.AutoReset = true;
            ReciverTimer.Elapsed  += new System.Timers.ElapsedEventHandler(RecieveInfos);

            /*
             * if (this.InvokeRequired)
             * {
             *  this.BeginInvoke(new MethodInvoker(
             *      () => ReciverTimer.Start()));
             * }
             * else
             * {
             *  ReciverTimer.Start();
             * }
             */
            SenderTimer           = new System.Timers.Timer(50);
            SenderTimer.AutoReset = true;
            SenderTimer.Elapsed  += new System.Timers.ElapsedEventHandler(SenderInfos);

            if (this.InvokeRequired)
            {
                this.BeginInvoke(new MethodInvoker(
                                     () =>
                {
                    ReciverTimer.Start();
                    SenderTimer.Start();
                    this.MouseDown             += new MouseEventHandler(RemoteManagement_MouseClick);
                    this.pictureBox1.MouseDown += new MouseEventHandler(RemoteManagement_MouseClick);
                    this.panel1.MouseDown      += new MouseEventHandler(RemoteManagement_MouseClick);
                    this.KeyDown += new KeyEventHandler(RemoteManagement_KeyDown);
                }));
            }
            else
            {
                ReciverTimer.Start();
                SenderTimer.Start();
                this.MouseDown             += new MouseEventHandler(RemoteManagement_MouseClick);
                this.pictureBox1.MouseDown += new MouseEventHandler(RemoteManagement_MouseClick);
                this.panel1.MouseDown      += new MouseEventHandler(RemoteManagement_MouseClick);
                this.KeyDown += new KeyEventHandler(RemoteManagement_KeyDown);
            }

            /*
             * this.MouseDown += new MouseEventHandler(RemoteManagement_MouseClick);
             * this.pictureBox1.MouseDown += new MouseEventHandler(RemoteManagement_MouseClick);
             * this.panel1.MouseDown += new MouseEventHandler(RemoteManagement_MouseClick);
             *
             * this.KeyDown += new KeyEventHandler(RemoteManagement_KeyDown);
             */
        }