Ejemplo n.º 1
0
        void CheckMessage(MSG msg)
        {
            if (msg.message == ".fire")
            {
                KeyValuePair<int, int> stat = new KeyValuePair<int, int>(0, 0);
                if (!stats.TryGetValue(msg.from, out stat))
                {

                }
                if (bullet == position)
                {
                    stats[msg.from] = new KeyValuePair<int, int>(stat.Key + 1, stat.Value);
                    irc.SendMessage(msg.to, msg.from + "'s brains are all over the walls!");
                    irc.KickUser(msg.to, msg.from, "You dead foo...");
                    Reload();
                    irc.SendMessage(msg.to, "Reloading");
                    return;
                }
                else
                {
                    stats[msg.from] = new KeyValuePair<int, int>(stat.Key, stat.Value + 1);
                    irc.SendMessage(msg.to, msg.from + " is lucky...this time.");
                    position++;
                }
            }
            else if (msg.message == ".reload")
            {
                Reload();
                irc.SendMessage(msg.to, "Reloading");
            }
        }
Ejemplo n.º 2
0
 void YoutubeSearch(object o)
 {
     try
     {
         MSG msg = new MSG(((MSG)o).ToString());
         WebClient wc = new WebClient();
         string str = wc.DownloadString("http://gdata.youtube.com/feeds/api/videos?fields-language=r2&q=" + Uri.EscapeUriString(msg.message.Substring(".youtube ".Length)) + "&fields=entry(media:group(media:title,media:content[@type='application/x-shockwave-flash'](@url)))&max-results=3");
         XmlDocument doc = new XmlDocument();
         str = str.Substring(str.IndexOf('>') + 1).Replace("media:", "");
         str = "<feed>" + str.Substring(str.IndexOf('>') + 1);
         doc.LoadXml(str);
         XmlNodeList nodeList = doc.DocumentElement.SelectNodes("//group");
         foreach (XmlNode node in nodeList)
         {
             if (node.ChildNodes[0].Attributes["url"] != null && !string.IsNullOrEmpty(node.ChildNodes[1].InnerText))
             {
                 string url = node.ChildNodes[0].Attributes["url"].Value;
                 url = url.Substring(0, url.IndexOf('?'));
                 url = url.Substring(url.Length - (11));
                 irc.SendMessage(msg.to, "(" + msg.message.Substring(".youtube ".Length) + ") * http://www.youtube.com/watch?v=" + url + " * - " + node.ChildNodes[1].InnerText);
             }
         }
     }
     catch { }
 }
 public override void AuthedCommand(MSG msg, int operLevel)
 {
     try
     {
         if (operLevel == 0)
         {
             msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
             if (msg.message.ToLower().StartsWith("register"))
             {
                 lastOper = msg.from;
                 irc.SendMessage("nickserv", msg.message);
                 if (msg.message.Split(' ').Length > 1)
                     logins[msg.to] = msg.message.Split(' ')[1];
             }
             else if (msg.message.ToLower().StartsWith("identify"))
             {
                 lastOper = msg.from;
                 irc.SendMessage("nickserv", msg.message);
                 if (msg.message.Split(' ').Length > 1)
                     logins[msg.to] = msg.message.Split(' ')[1];
             }
         }
     }
     catch { }
 }
Ejemplo n.º 4
0
        public static void ShowStudentInfo(int id, string ip, int port)
        {
            Student student = null;
            TcpClient eClient = new TcpClient();
            try
            {
                eClient = new TcpClient(ip, port);
                using (NetworkStream writerStream = eClient.GetStream())
                {
                    MSG message = new MSG();
                    message.stat = STATUS.GET_ACCOUNT_BY_ID;
                    BinaryFormatter formatter = new BinaryFormatter();
                    formatter.Serialize(writerStream, message);
                    formatter.Serialize(writerStream, id);
                    student = (Student)formatter.Deserialize(writerStream);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                eClient.Close();
            }

            if (student == null)
            {
                throw new ArgumentException(string.Format("Студента з id = {0} не iснує", id));
            }

            StudentInfoWindow sw = new StudentInfoWindow(string.Format("{0} {1} {2}", student.Lastname, student.Firstname, student.Patronymic),
                student.Group, student.Faculty, student.PhoneNumber, student.Email, student.Address, student.AverageMark);
            sw.ShowDialog();
        }
 public List<Student> InitStudentTable()
 {
     try
     {
         Configuration config = (App.Current as App).config;
         using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
         {
             using (NetworkStream writerStream = eClient.GetStream())
             {
                 MSG message = new MSG();
                 message.stat = STATUS.GET_STUDENTS;
                 BinaryFormatter formatter = new BinaryFormatter();
                 formatter.Serialize(writerStream, message);
                 formatter.Serialize(writerStream, (App.Current as App).instr.InstructorId);
                 bool fl = (bool)formatter.Deserialize(writerStream);
                 if (fl)
                 {
                     _studentsCollection = (List<Student>)formatter.Deserialize(writerStream);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Помилка", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     return _studentsCollection;
 }
Ejemplo n.º 6
0
	static void Main ()
	{
		InstructionsForm instructionsForm = new InstructionsForm ();
		instructionsForm.Show ();

		NativeWindow nw = new NativeWindow ();

		CreateParams cp = new CreateParams ();

		cp.Caption = "bug #80817";
		cp.X = 100;
		cp.Y = 100;
		cp.Width = 400;
		cp.Height = 600;
		cp.ClassStyle = (int) (ClassStyle.CS_VREDRAW | ClassStyle.CS_HREDRAW);
		cp.Style = (int) WindowStyles.WS_OVERLAPPEDWINDOW;

		// create the window.
		nw.CreateHandle (cp);
		ShowWindow (nw.Handle, WindowPlacementFlags.SW_SHOWNORMAL);
		UpdateWindow (nw.Handle);

		MSG msg = new MSG ();

		while (GetMessage (ref msg, 0, 0, 0) > 0) {
			TranslateMessage (ref msg);
			DispatchMessage (ref msg);
		}
	}
 public Dictionary<GroupRow, int> InitGroupTable()
 {
     _groupsCollection.Clear();
     foreach (var faculty in EnumDecoder.StringToFaculties)
     {
         try
         {
             Configuration config = (App.Current as App).config;
             using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
             {
                 using (NetworkStream writerStream = eClient.GetStream())
                 {
                     MSG message = new MSG();
                     message.stat = STATUS.GET_GROUP_BY_FACULTY;
                     BinaryFormatter formatter = new BinaryFormatter();
                     formatter.Serialize(writerStream, message); 
                     formatter.Serialize(writerStream, faculty.Value);
                     bool fl = (bool)formatter.Deserialize(writerStream);
                     if (fl)
                     {
                         foreach (var group in (Dictionary<string, int>)formatter.Deserialize(writerStream))
                         {
                             _groupsCollection.Add(new GroupRow(group.Key, faculty.Key), group.Value);
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Помилка", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     return _groupsCollection;
 }
Ejemplo n.º 8
0
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (PasswordBox.Password != PasswordRepeatBox.Password)
                    throw new Exception("Паролі не співпадають");
                Instructor instructor = new Instructor(LoginBox.Text, PasswordBox.Password, FirstNameBox.Text, LastNameBox.Text,
                    SecondNameBox.Text);
                Configuration config = (App.Current as App).config;
                using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
                {
                    using (NetworkStream writerStream = eClient.GetStream())
                    {
                        MSG message = new MSG();
                        message.stat = STATUS.ADD_INSTRUCTOR;
                        BinaryFormatter formatter = new BinaryFormatter();
                        formatter.Serialize(writerStream, message);
                        formatter.Serialize(writerStream, instructor);
                        bool fl = (bool)formatter.Deserialize(writerStream);
                        if (!fl)
                            MessageBox.Show("Помилка додавання облікового запису");
                        else
                        {
                            NavigationService nav = NavigationService.GetNavigationService(this);
                            nav.Navigate(new System.Uri("StartPage.xaml", UriKind.RelativeOrAbsolute));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
 private void UpdateSpecialities()
 {
     SpecialityGrid.Items.Clear();
     try
     {
         Configuration config = (App.Current as App).config;
         using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
         {
             using (NetworkStream writerStream = eClient.GetStream())
             {
                 MSG message = new MSG();
                 message.stat = STATUS.GET_SPECIALITIES;
                 BinaryFormatter formatter = new BinaryFormatter();
                 formatter.Serialize(writerStream, message);
                 if ((bool)formatter.Deserialize(writerStream))
                 {
                     _specialityCollection = (List<Speciality>)formatter.Deserialize(writerStream);
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
     foreach (var speciality in _specialityCollection)
     {
         SpecialityGrid.Items.Add(speciality);
     }
 }
Ejemplo n.º 10
0
 void CheckMessage(MSG msg)
 {
     if (msg.message.StartsWith(".udict") && msg.message.Split(' ').Length > 1)
     {
         Thread t = new Thread(new ParameterizedThreadStart(GetUDef));
         t.Start(msg);
     }
 }
Ejemplo n.º 11
0
 public override void AuthedCommand(MSG msg, int operLevel)
 {
     msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
     if (msg.message.StartsWith("add ") && msg.message.Split(' ').Length == 3)
     {
         oplist.Add(msg.message.Split(' ')[1], msg.message.Split(' ')[2]);
         EncFile.AppendText(server.Data + Path.DirectorySeparatorChar + "autoop.db", msg.message.Split(' ')[1] + " " + msg.message.Split(' ')[2] + "\n");
     }
 }
Ejemplo n.º 12
0
 void irc_OnMSGRecvd(MSG msg)
 {
     if (msg.message.ToLower().StartsWith(".decode "))
     {
         lastMeme[msg.fromUser + '@' + msg.fromHost] = DateTime.Now;
         Thread t = new Thread(new ParameterizedThreadStart(GenerateImage));
         t.Start(msg);
     }
 }
Ejemplo n.º 13
0
 public virtual void AuthedCommand(MSG msg, int operLevel)
 {
     msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
     if (msg.message.StartsWith("value "))
     {
         string s = GetPrivateValue(msg.message.Substring(msg.message.IndexOf(' ') + 1));
         if (!string.IsNullOrEmpty(s))
             irc.SendMessage(msg.from, msg.message.Substring(msg.message.IndexOf(' ') + 1) + " = " + s);
     }
 }
Ejemplo n.º 14
0
 void irc_OnPMRecvd(MSG msg)
 {
     //op channel pass
     if (msg.message.StartsWith("op ") && msg.message.Split(' ').Length == 3)
     {
         if (oplist.ContainsKey(msg.from) && oplist[msg.from] == msg.message.Split(' ')[2])
         {
             irc.SetChannelModes(msg.message.Split(' ')[1], "+o", msg.from);
         }
     }
 }
Ejemplo n.º 15
0
 static bool messageEnabled(MSG msg)
 {
     // WITHDRAWAL: INVALID_FROM_ACCT MAX_DAILY_WITHDRAWAL INVALID_ACCT_BALANCE
     // TRANSFER: INVALID_FROM_ACCT INVALID_TO_ACCT SAME_ACCOUNT INVALID_ACCT_BALANCE
     return
         msg != MSG.MAX_DAILY_WITHDRAWAL && msg != MSG.INVALID_FROM_ACCT && msg != MSG.INVALID_TO_ACCT && msg != MSG.SAME_ACCOUNT && msg != MSG.INVALID_ACCT_BALANCE ||
         msg == MSG.INVALID_FROM_ACCT ||
         msg == MSG.MAX_DAILY_WITHDRAWAL && !Session.hasMessage(MSG.INVALID_FROM_ACCT) ||
         msg == MSG.INVALID_TO_ACCT && !Session.hasMessage(MSG.INVALID_FROM_ACCT) ||
         msg == MSG.SAME_ACCOUNT && !Session.hasMessage(MSG.INVALID_FROM_ACCT) && !Session.hasMessage(MSG.INVALID_TO_ACCT) ||
         msg == MSG.INVALID_ACCT_BALANCE && !Session.hasMessage(MSG.MAX_DAILY_WITHDRAWAL) && !Session.hasMessage(MSG.INVALID_TO_ACCT) && !Session.hasMessage(MSG.SAME_ACCOUNT);
 }
Ejemplo n.º 16
0
		private void ThreadPreprocessMessageMethod(ref MSG msg, ref bool handled)
		{
			if (!handled)
			{
				if (msg.message == HotKeyWinApi.WmHotKey
					&& (int)(msg.wParam) == id)
				{
					OnHotKeyPressed();
					handled = true;
				}
			}
		}
Ejemplo n.º 17
0
 private void Login_Click(object sender, RoutedEventArgs e)
 {
     Configuration config = (App.Current as App).config;
     TcpClient eClient = new TcpClient();
     try
     {
         eClient = new TcpClient(config.IP.ToString(), config.Port);
         using (NetworkStream writerStream = eClient.GetStream())
         {
             MSG message = new MSG();
             message.stat = STATUS.LOGIN;
             BinaryFormatter formatter = new BinaryFormatter();
             formatter.Serialize(writerStream, message);
             formatter.Serialize(writerStream, LoginBox.Text);
             formatter.Serialize(writerStream, PasswordBox.Password);
             bool fl = (bool)formatter.Deserialize(writerStream);
             if (fl)
             {
                 Account ac = (Account)formatter.Deserialize(writerStream);
                 if (ac != null)
                 {
                     Instructor st;
                     if (ac is Instructor)
                     {
                         st = (Instructor)ac;
                         config.Login = LoginBox.Text;
                         config.Password = PasswordBox.Password;
                         (App.Current as App).SaveConfig();
                         (App.Current as App).instr = st;
                         NavigationService nav = NavigationService.GetNavigationService(this);
                         nav.Navigate(new System.Uri("MainWindow.xaml", UriKind.RelativeOrAbsolute));
                     }
                     else
                     {
                         MessageBox.Show("Невірний тип облікового запису");
                     }
                 }
             }
             else
             {
                 MessageBox.Show("Невірна комбінація");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         eClient.Close();
     }
 }
Ejemplo n.º 18
0
 void irc_OnMSGRecvd(MSG msg)
 {
     if (msg.message.StartsWith(".youtube "))
     {
         Thread t = new Thread(new ParameterizedThreadStart(YoutubeSearch));
         t.Start(msg);
     }
     else if (msg.message.StartsWith(".google ") || msg.message.StartsWith(".g "))
     {
         //Thread t = new Thread(new ParameterizedThreadStart(GoogleSearch));
         //t.Start(msg);
     }
 }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(SubjectNameBox.Text))
                MessageBox.Show("Потрібно вказати назву предмета");
            else
            {
                if (_cw == CurrentWindow.EditSubject && _oldSubjectName == SubjectNameBox.Text)
                {
                    this.Close();
                }
                else
                {

                    Configuration config = (App.Current as App).config;
                    TcpClient eClient = new TcpClient();
                    try
                    {
                        eClient = new TcpClient(config.IP.ToString(), config.Port);
                        using (NetworkStream writerStream = eClient.GetStream())
                        {
                            MSG message = new MSG();
                            message.stat = _cw == CurrentWindow.AddSubject ? STATUS.ADD_SUBJECT : STATUS.EDIT_SUBJECT;
                            BinaryFormatter formatter = new BinaryFormatter();
                            formatter.Serialize(writerStream, message);
                            formatter.Serialize(writerStream, SubjectNameBox.Text);
                            if (_cw == CurrentWindow.EditSubject)
                                formatter.Serialize(writerStream, _subjectId);
                            bool fl = (bool)formatter.Deserialize(writerStream);
                            if (!fl)
                            {
                                MessageBox.Show("Предмет вже існує", string.Concat("Помилка ",
                                    _cw == CurrentWindow.AddSubject ? "додавання" : "редагування", " предмета"), MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                            }
                            else
                            {
                                this.Close();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    finally
                    {
                        eClient.Close();
                    }
                }
            }
        }
Ejemplo n.º 20
0
		public bool ProcessEvent (IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg) {
			switch (kind) {
				case kEventHIObjectConstruct:
					IntPtr v = IntPtr.Zero;
					GetEventParameter (eventref, (uint)1751740265, (uint)1751740258, IntPtr.Zero, 4, IntPtr.Zero, ref v);
					return false;
				case kEventHIObjectInitialize:
					CallNextEventHandler (callref, eventref);
					return false;
				case kEventHIObjectDestruct:
					return false;
			}
			return false;
		}
Ejemplo n.º 21
0
        void GoogleSearch(object o)
        {
            MSG msg = new MSG(((MSG)o).ToString());
            msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
            try
            {
                WebClient wc = new WebClient();
                string str = wc.DownloadString("http://www.google.com/search?q=" + Uri.EscapeUriString(msg.message) + "&num=5&client=google-csbe&output=xml&cx=004809591179083466614:t_ax44dljjk");
                Console.WriteLine(str);
                Console.WriteLine();

            }
            catch { }
        }
Ejemplo n.º 22
0
        int IVsFilterKeys.TranslateAccelerator(MSG[] msg, uint flags, out Guid commandGroup, out uint command)
        {
            var hr = _filterKeys.TranslateAccelerator(msg, flags, out commandGroup, out command);
            if (ErrorHandler.Succeeded(hr)
                && _vsAdapter.IsReadOnly(_buffer.TextBuffer)
                && IsEditCommand(commandGroup, command))
            {
                commandGroup = Guid.Empty;
                command = 0;
                return VSConstants.E_FAIL;
            }

            return hr;
        }
Ejemplo n.º 23
0
 public override void AuthedCommand(MSG msg, int operLevel)
 {
     ReportTo = msg.from;
     msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
     if (msg.message.StartsWith("TalkValue "))
     {
         TalkValue = int.Parse(msg.message.Substring(msg.message.IndexOf(' ') + 1));
     }
     if (msg.message.StartsWith("value "))
     {
         string s = GetPrivateValue(msg.message.Substring(msg.message.IndexOf(' ') + 1));
         if (!string.IsNullOrEmpty(s))
             irc.SendMessage(msg.from, msg.message.Substring(msg.message.IndexOf(' ') + 1) + " = " + s);
     }
 }
Ejemplo n.º 24
0
        private void ComponentDispatcher_ThreadPreprocessMessage(ref MSG msg, ref bool handled)
        {
            var instanceOfApp = _mainWindow.GetType() == typeof (MainWindow);
            var mainWindow = _mainWindow as MainWindow;

            if (mainWindow == null || !instanceOfApp) return;

            if (msg.message == WM_HOTKEY)
            {
                // get the keys.
                Keys key = (Keys)(((int)msg.lParam >> 16) & 0xFFFF);
                ModifierKeys modifier = (ModifierKeys)((int)msg.lParam & 0xFFFF);
                // TODO Handle the hotkey press
                mainWindow.GlobalKeyPressed(key, modifier);
            }
        }
Ejemplo n.º 25
0
 private void OK_Click(object sender, RoutedEventArgs e)
 {
     if (int.Parse(SerialNumber.Text) < 1 || int.Parse(SerialNumber.Text) > CurPr.Events.Count + 1)
     {
         MessageBox.Show(string.Format("Порядковий номер івента повинен бути менше {0} і більше 0.",
             CurPr.Events.Count + 2));
     }
     else if (Name.Text == string.Empty)
         MessageBox.Show("Необхідно вказати заголовок");
     else 
     {
         Event ev = new Event(CurPr.ID, int.Parse(SerialNumber.Text), Name.Text, 
             DeadlineDate.SelectedDate == null ? DateTime.Now : DeadlineDate.SelectedDate.Value, Description.Text);
         try
         {
             Configuration config = (App.Current as App).config;
             using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
             {
                 using (NetworkStream writerStream = eClient.GetStream())
                 {
                     MSG message = new MSG();
                     if(curWindow == CurrentWindow.AddEvent)
                         message.stat = STATUS.ADD_EVENT;
                     else if (curWindow == CurrentWindow.EditEvent)
                     {
                         ev.ID = CurPr.Events[EventNumber].ID;
                         message.stat = STATUS.UPDATE_EVENT;
                     }
                     BinaryFormatter formatter = new BinaryFormatter();
                     formatter.Serialize(writerStream, message);
                     formatter.Serialize(writerStream, ev);
                     if (!(bool)formatter.Deserialize(writerStream))
                         MessageBox.Show("Помилка обробки івенту");
                     else
                     {
                         this.Close();
                     }
                 }
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Помилка обробки івенту");
         }   
     }
 }
 private void OKButton_Click(object sender, RoutedEventArgs e)
 {
     int code;
     if (SpecialityNameBox.Text == string.Empty)
     {
         MessageBox.Show("Необхідно вказати назву спеціальності");
     }
     else if (SpecialityCodeBox.Text == string.Empty)
     {
         MessageBox.Show("Необхідно вказати код спеціальності");
     }
     else if (!Int32.TryParse(SpecialityCodeBox.Text, out code))
     {
         MessageBox.Show("Код спеціальності повинен складатися тільки з цифр");
     }
     else
     {
         try
         {
             Configuration config = (App.Current as App).config;
             using (TcpClient eClient = new TcpClient(config.IP.ToString(), config.Port))
             {
                 using (NetworkStream writerStream = eClient.GetStream())
                 {
                     MSG message = new MSG();
                     if (_curWindow == CurrentWindow.EditSpeciality)
                     {
                         message.stat = STATUS.EDIT_SPECIALITY;
                     }
                     else
                     {
                         message.stat = STATUS.ADD_SPECIALITY;
                     }
                     BinaryFormatter formatter = new BinaryFormatter();
                     formatter.Serialize(writerStream, message);
                     formatter.Serialize(writerStream, new Speciality(SpecialityNameBox.Text, SpecialityCodeBox.Text, DirectionBox.Text));
                 }
             }
         }
         catch (Exception)
         {
             throw;
         }
         Close();
     }
 }
Ejemplo n.º 27
0
 public override void AuthedCommand(MSG msg, int operLevel)
 {
     msg.message = msg.message.Substring(msg.message.IndexOf(' ') + 1);
     if (msg.message == ".getsuggestion")
     {
         if (newSuggestions.Count == 0)
         {
             irc.SendMessage(msg.from, "Sorry, no new suggestions.");
             return;
         }
         MSG m = newSuggestions[0];
         newSuggestions.RemoveAt(0);
         irc.SendMessage(msg.from, m.ToString());
         oldSuggestions.Add(m);
         Save();
     }
 }
Ejemplo n.º 28
0
        //static void Main()
        //{
        //    // instantiate model and view components, so "controller" component can reference them
        //    GearModel model = new GearModel();
        //    GLView view = new GLView("Gears");

        //    // create "controller" component by specifying what are "model" and "view"
        //    GLController glCtrl = new GLGameController(model, view);

        //    // create window with given controller
        //    GLWindow glWin = new GLWindow("Gear Head", new Rectangle(10, 10, 400, 300), glCtrl);

        //    glWin.Show();

        //    // main message loop
        //    int exitCode;
        //    exitCode = mainMessageLoop(IntPtr.Zero);
        //}
	
        public static int mainMessageLoop(IntPtr hAccelTable)
        {
            MSG msg=new MSG();

            // loop until WM_QUIT(0) received
            while(User32.GetMessage(out msg, IntPtr.Zero, 0, 0) != 0)  
            {
                // now, handle window messages
                //if(!User32.TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
                {
                    User32.TranslateMessage(ref msg);
                    User32.DispatchMessage(ref msg);
                }
            }

            return (int)msg.wParam;                 // return nExitCode of PostQuitMessage()
        }
 public void ProcessMessageTest()
 {
     ActivityMonitor_Accessor target = new ActivityMonitor_Accessor(); // TODO: Initialize to an appropriate value
     Random rand = new Random();
     bool inDay = true;
     MSG m = new MSG("user", "user", "user", "#chan", "message");
     m.when = DateTime.Today;
     while (inDay)
     {
         target.ProcessMessage(m);
         m.when = m.when.AddSeconds(rand.Next() % 256);
         if (m.when.DayOfYear > DateTime.Today.DayOfYear)
             inDay = false;
     }
     target.WriteStatsToWWW("www");
     Assert.AreEqual(1, 1);
 }
Ejemplo n.º 30
0
 void CheckMessage(MSG msg)
 {
     if ((msg.message.StartsWith(".np") || msg.message.StartsWith(".similar") || msg.message.StartsWith(".lastfm")) && msg.message.Split(' ').Length > 1)
     {
         Thread t = new Thread(new ParameterizedThreadStart(GetLastFm));
         t.Start(msg);
     }
     else if (msg.message == ".np" && registrar.ContainsKey(msg.from))
     {
         Thread t = new Thread(new ParameterizedThreadStart(GetLastFm));
         t.Start(msg);
     }
     else if (msg.message.StartsWith(".reglastfm "))
     {
         registrar[msg.from] = msg.message.Split(' ')[1];
         Save();
     }
 }
Ejemplo n.º 31
0
        private void GenerateRows()
        {
            listViewProgramChecks.Items.Clear();
            if (_grouping)
            {
                MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems);
                MaintenanceCheck           mc  = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule);
                if (mc == null)
                {
                    return;
                }
                MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0
                                  ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG
                                  : MSG.MSG2;
                if (msg < MSG.MSG3)
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                else
                {
                    MaintenanceCheckComplianceGroup mccg =
                        mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                        mc.Grouping, mc.Resource);

                    int lastPerformanceGroupNum = mccg != null
                        ? mccg.LastComplianceGroupNum
                        : 0;
                    int countMinStepInMinCheck = Convert.ToInt32(mc.Interval.GetSubresource(mc.Resource)) / _minCheckResource;
                    foreach (MaintenanceCheck t in _maintenanceCheckItems)
                    {
                        ListViewItem listViewItem = new ListViewItem {
                            Text = t.Name
                        };

                        listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                        listViewItem.SubItems.Add(t.Cost.ToString());
                        listViewItem.SubItems.Add(t.ManHours.ToString());

                        for (int j = 1; j <= _countColumns; j++)
                        {
                            MaintenanceNextPerformance mnp =
                                t.GetPergormanceGroupWhereCheckIsSeniorByGroupNum(lastPerformanceGroupNum + j * countMinStepInMinCheck);
                            listViewItem.SubItems.Add(mnp != null ? "X" : "");
                        }
                        listViewProgramChecks.Items.Add(listViewItem);
                    }
                }
                mcc.Clear();
            }
            else
            {
                foreach (MaintenanceCheck t in _maintenanceCheckItems)
                {
                    ListViewItem listViewItem = new ListViewItem {
                        Text = t.Name
                    };

                    listViewItem.SubItems.Add(t.Interval.ToRepeatIntervalsFormat());
                    listViewItem.SubItems.Add(t.Cost.ToString());
                    listViewItem.SubItems.Add(t.ManHours.ToString());

                    Lifelength lastPerformance = t.LastPerformance != null
                        ? new Lifelength(t.LastPerformance.OnLifelength)
                        : Lifelength.Null;
                    int?last = lastPerformance.GetSubresource(_subResource);

                    listViewItem.SubItems.Add(last != null ? lastPerformance.ToString(_subResource, true) : "");

                    if (t.Schedule == _schedule)
                    {
                        Lifelength nextPerformance = lastPerformance + t.Interval;
                        int?       next            = nextPerformance.GetSubresource(_subResource);
                        listViewItem.SubItems.Add(next != null ? nextPerformance.ToString(_subResource, true) : "");
                    }
                    else
                    {
                        listViewItem.SubItems.Add("N/A");
                    }
                    listViewProgramChecks.Items.Add(listViewItem);
                }
            }
        }
 internal static extern IntPtr DispatchMessage(ref MSG lpmsg);
Ejemplo n.º 33
0
 private static extern int PeekMessage([MarshalAs(UnmanagedType.Struct)]
                                       ref MSG lpMsg, int hwnd, int wMsgFilterMin, int wMsgFilterMax, int wRemoveMsg);
 public static extern BOOL TranslateMDISysAccel(IntPtr hWndClient, ref MSG msg);
 // ReSharper disable once RedundantAssignment
 private void OnThreadFilterMessage(ref MSG msg, ref bool handled)
 {
     handled = KeyboardDriver.HandleMessage(msg.message, msg.wParam, msg.lParam);
 }
Ejemplo n.º 36
0
 public static extern IntPtr DispatchMessage([In] ref MSG msg);
Ejemplo n.º 37
0
 public static bool PeekMessage(out MSG message, WindowHandle window, uint minMessage, uint maxMessage, PeekMessageOptions options)
 {
     return(Imports.PeekMessageW(out message, window, minMessage, maxMessage, options));
 }
Ejemplo n.º 38
0
 public static extern IntPtr DispatchMessage(ref MSG lpmsg);
Ejemplo n.º 39
0
 private void UploadForm_Load(object sender, EventArgs e)
 {
     this.msg       = new MSG();
     this.cutUpload = new UploadFile();
 }
Ejemplo n.º 40
0
 public static extern bool PeekMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
Ejemplo n.º 41
0
 public static extern sbyte GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
Ejemplo n.º 42
0
 public static extern bool TranslateMessage(ref MSG lpMsg);
Ejemplo n.º 43
0
 public static bool DispatchMessage(ref MSG message)
 {
     return(Imports.DispatchMessageW(ref message));
 }
Ejemplo n.º 44
0
 public static bool TranslateMessage(ref MSG message)
 {
     return(Imports.TranslateMessage(ref message));
 }
Ejemplo n.º 45
0
        /// <summary>
        /// Выставляет колонки в списке чеков текущей программы обслуживания
        /// </summary>
        private void SetHeaders()
        {
            _min = Convert.ToInt32(_maintenanceCheckItems[0].Interval.GetSubresource(_subResource));

            foreach (MaintenanceCheck liminationItem in _maintenanceCheckItems)
            {
                _min = Math.Min(Convert.ToInt32(liminationItem.Interval.GetSubresource(_subResource)), _min);
                _max = Math.Max(Convert.ToInt32(liminationItem.Interval.GetSubresource(_subResource)), _max);
            }

            ColumnHeader column = new ColumnHeader {
                Text = "Name", TextAlign = HorizontalAlignment.Right, Width = 50
            };

            listViewProgramChecks.Columns.Add(column);
            column = new ColumnHeader {
                Text = "Interval", TextAlign = HorizontalAlignment.Left, Width = 130
            };
            listViewProgramChecks.Columns.Add(column);
            column = new ColumnHeader {
                Text = "Cost", TextAlign = HorizontalAlignment.Left, Width = 50
            };
            listViewProgramChecks.Columns.Add(column);
            column = new ColumnHeader {
                Text = "ManHours", TextAlign = HorizontalAlignment.Left, Width = 64
            };
            listViewProgramChecks.Columns.Add(column);

            if (_grouping)
            {
                //Определение кол-ва колонок списка
                if (_upperCheckTypeMinResource == -1)
                {
                    //Если это самая вышестоящий тип чеков
                    //то делится максимальный на минимальный интервал
                    _countColumns = _max / _min;
                }
                else
                {
                    //Если это самая НЕ вышестоящий тип чеков
                    //то делится минимальный ресурс вышестоящего типа на минимальный интервал
                    _countColumns = _upperCheckTypeMinResource / _min;
                }
                MaintenanceCheckCollection mcc = new MaintenanceCheckCollection(_maintenanceCheckItems);
                MaintenanceCheck           mc  = mcc.GetMinStepCheck(_maintenanceCheckItems[0].Schedule);
                if (mc == null)
                {
                    return;
                }
                MSG msg = mc.ParentAircraft != null && mc.ParentAircraft.MaintenanceProgramChangeRecords.Count > 0
                                  ? mc.ParentAircraft.MaintenanceProgramChangeRecords.GetLast().MSG
                                  : MSG.MSG2;
                if (msg < MSG.MSG3)
                {
                    for (int i = 1; i <= _countColumns; i++)
                    {
                        //ColumnHeader viewColumn = new ColumnHeader
                        //                              {
                        //                                  Text = i + " [" + (i*_min) + "]",
                        //                                  TextAlign = HorizontalAlignment.Center,
                        //                                  Width = 65
                        //
                        //                              };
                        //listViewProgramChecks.Columns.Add(viewColumn);
                        ColumnHeader viewColumn;
                        //выполняется проверка, достаточно ли расчитано "след.выполнений"
                        //что бы заполнить их данными названия колонок
                        if (mc.NextPerformances.Count >= i)
                        {
                            //Если кол-во расчитанных выполнений достаточно для заполнения
                            //названия тек. колонки, то название колонки берется из ресурса "след. выполнения"
                            int performanceSource =
                                Convert.ToInt32(mc.NextPerformances[i - 1].PerformanceSource.GetSubresource(mc.Resource));
                            MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance;
                            if (mnp != null)
                            {
                                string checkName = mnp.PerformanceGroup != null?mnp.PerformanceGroup.GetGroupName() : i.ToString();

                                viewColumn = new ColumnHeader
                                {
                                    Text      = checkName + " [" + performanceSource + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                            else
                            {
                                viewColumn = new ColumnHeader
                                {
                                    Text      = i + " [" + performanceSource + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                        }
                        else
                        {
                            //Если кол-во расчитанных выполнений недостаточно
                            //то название колонки расчитывается на освоне ресурса последнего выполнения
                            //данного чека и номера тек. колонки
                            viewColumn = new ColumnHeader
                            {
                                Text      = i + " [" + (i * _min) + "]",
                                TextAlign = HorizontalAlignment.Center,
                                Width     = 85
                            };
                        }
                        listViewProgramChecks.Columns.Add(viewColumn);
                    }
                }
                else
                {
                    MaintenanceCheckComplianceGroup mccg = mcc.GetLastComplianceCheckGroup(mc.Schedule, mc.ParentAircraftId,
                                                                                           mc.Grouping, mc.Resource);
                    if (mccg == null)
                    {
                        for (int i = 1; i <= _countColumns; i++)
                        {
                            MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance;
                            string checkName = mnp != null && mnp.PerformanceGroup != null
                                ? mnp.PerformanceGroup.GetGroupName()
                                : "";

                            ColumnHeader viewColumn = new ColumnHeader
                            {
                                Text      = checkName + " [" + (i * _min) + "]",
                                TextAlign = HorizontalAlignment.Center,
                                Width     = 65
                            };
                            listViewProgramChecks.Columns.Add(viewColumn);
                        }
                    }
                    else
                    {
                        MaintenanceCheck mic = mccg.GetMinIntervalCheck();
                        for (int i = 1; i <= _countColumns; i++)
                        {
                            ColumnHeader viewColumn;
                            //выполняется проверка, достаточно ли расчитано "след.выполнений"
                            //что бы заполнить их данными названия колонок
                            if (mic.NextPerformances.Count >= i)
                            {
                                //Если кол-во расчитанных выполнений достаточно для заполнения
                                //названия тек. колонки, то название колонки берется из ресурса "след. выполнения"
                                MaintenanceNextPerformance mnp = mc.NextPerformances[i - 1] as MaintenanceNextPerformance;
                                string checkName = mnp != null && mnp.PerformanceGroup != null
                                    ? mnp.PerformanceGroup.GetGroupName()
                                    : "";

                                int performanceSource =
                                    Convert.ToInt32(mic.NextPerformances[i - 1].PerformanceSource.GetSubresource(mic.Resource));
                                viewColumn = new ColumnHeader
                                {
                                    Text      = checkName + " [" + performanceSource + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                            else
                            {
                                //Если кол-во расчитанных выполнений недостаточно
                                //то название колонки расчитывается на освоне ресурса последнего выполнения
                                //данного чека и номера тек. колонки
                                int lastPerformaceSource =
                                    Convert.ToInt32(mic.LastPerformance.CalculatedPerformanceSource.GetSubresource(mic.Resource));
                                if (lastPerformaceSource == 0)
                                {
                                    lastPerformaceSource =
                                        Convert.ToInt32(mic.LastPerformance.OnLifelength.GetSubresource(mic.Resource));
                                }

                                viewColumn = new ColumnHeader
                                {
                                    Text      = " [" + (lastPerformaceSource + i * _min) + "]",
                                    TextAlign = HorizontalAlignment.Center,
                                    Width     = 85
                                };
                            }
                            listViewProgramChecks.Columns.Add(viewColumn);
                        }
                    }
                }
                mcc.Clear();
            }
            else
            {
                _countColumns = 2;
                //Если чеки НЕ группируются по части порогового значения
                //то выводится ресурс пред. и след. выполнения
                column = new ColumnHeader {
                    Text = "Last", TextAlign = HorizontalAlignment.Left, Width = 100
                };
                listViewProgramChecks.Columns.Add(column);
                column = new ColumnHeader {
                    Text = "Next", TextAlign = HorizontalAlignment.Left, Width = 100
                };
                listViewProgramChecks.Columns.Add(column);
            }
        }
        private void toAWholePiece()
        {
            killHwndOfXls();
            Queue <int> prefix_Of_Staffs_Queue = V_AR_RESULT.get_Prefix_Staffs(YearAndMonthStr);

            if (prefix_Of_Staffs_Queue.Count == 0)
            {
                ShowResult.show(lblResult, "尚未导入本月的考勤记录!", false);
                timerRestoreTheLblResult.Enabled = true;
                return;
            }
            MSG msg = new MSG();
            ApplicationClass app = new ApplicationClass();
            //追加Hwnd到队列中.
            int appHwnd = app.Hwnd;

            app.Visible = false;
            Workbook  wBook       = app.Workbooks.Add(true);
            Worksheet wSheet      = (Worksheet)wBook.Worksheets[1];
            string    _defaultDir = System.Windows.Forms.Application.StartupPath + "\\考勤汇总";
            int       seq         = prefix_Of_Staffs_Queue.Dequeue();
            int       lastSeq     = 0;

            while (prefix_Of_Staffs_Queue.Count >= 1)
            {
                lastSeq = prefix_Of_Staffs_Queue.Dequeue();
            }
            string _fileName = YearAndMonthStr + "_考勤汇总" + seq.ToString() + "-" + lastSeq.ToString() + ".xls";

            if (!xlsFilePath.Contains(":"))
            {
                //导出到Excel中
                xlsFilePath = FileNameDialog.getSaveFileNameWithDefaultDir("考勤汇总:", "*.xls|*.xls", _defaultDir, _fileName);
                if (!xlsFilePath.Contains(@"\"))
                {
                    return;
                }
            }
            //依据前缀和月份获取列表。
            //获取该月该考勤机的出勤人数。
            int AR_Num = V_AttendanceRecord.getARNumByYearAndMonth(YearAndMonthStr);

            if (AR_Num == 0)
            {
                MessageBox.Show("数据源为空,无法导出。", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            int rowMaxCount = AR_Num * 2 + 6;
            int colMaxCount = AttendanceR.get_AR_Days_Num(YearAndMonthStr);

            //写标题
            try
            {
                //每行格式设置,注意标题占一行。
                Range range = wSheet.get_Range(wSheet.Cells[1, 1], wSheet.Cells[rowMaxCount + 1, colMaxCount + 1]);
                //设置单元格为文本。
                range.NumberFormatLocal = "@";
                //水平对齐方式
                range.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                //第一行写考勤分析结果。
                wSheet.Cells[1, 1] = YearAndMonthStr + " 考勤分析结果" + seq.ToString() + "-" + lastSeq.ToString();
                //获取该日期详细的考勤记录。
                #region
                V_AttendanceRecord.AR_Properties aR_Properties = V_AttendanceRecord.getARProperties(YearAndMonthStr);
                //第三行:考勤时间
                wSheet.Cells[3, 1] = "考勤时间";
                wSheet.Cells[3, 3] = String.Format(@"{0} ~ {1}",
                                                   aR_Properties.Start_Date,
                                                   aR_Properties.End_Date);
                wSheet.Cells[3, 10] = "制表时间";
                wSheet.Cells[3, 12] = aR_Properties.Tabulation_date;
                #endregion
                List <int> dayList = V_AR_DETAIL.getMonthAL_By_YAndM(YearAndMonthStr);
                //需要统计有多少人。
                int total_num_of_AttendanceR = AttendanceR.get_Total_Num_Of_Staffs_By_YAndM(YearAndMonthStr);
                pb.Value          = 0;
                pb.Maximum        = dayList.Count + dayList.Count * total_num_of_AttendanceR;
                pb.Visible        = true;
                lblPrompt.Text    = _fileName + ":";
                lblPrompt.Visible = true;
                //写 此月与考勤相关的日。
                for (int i = 0; i <= dayList.Count - 1; i++)
                {
                    //写该月的具体有哪些日:1,2,3.与考勤相关。
                    wSheet.Cells[4, i + 1] = dayList[i].ToString();
                    pb.Value++;
                }
                //实际出勤天数.
                wSheet.Cells[4, dayList.Count + 1] = "实际出勤天数";
                //事假
                wSheet.Cells[4, dayList.Count + 2] = "事假";
                //未打卡
                wSheet.Cells[4, dayList.Count + 3] = "未打卡";
                //延点
                wSheet.Cells[4, dayList.Count + 4] = "延点(小时)";
                //迟到
                wSheet.Cells[4, dayList.Count + 5] = "迟到";
                //早退
                wSheet.Cells[4, dayList.Count + 6] = "早退";
                //餐补
                wSheet.Cells[4, dayList.Count + 7] = "餐补";
                string             AR_YEAR_AND_Month_Str = String.Empty;
                string             AR_Day = string.Empty;
                List <V_AR_DETAIL> v_AR_Detail_Specific_Day_List = null;
                for (int j = 1; j <= dayList.Count; j++)
                {
                    AR_YEAR_AND_Month_Str = aR_Properties.Start_Date.Substring(0, 8);
                    AR_Day = AR_YEAR_AND_Month_Str + dayList[j - 1].ToString().PadLeft(2, '0');
                    v_AR_Detail_Specific_Day_List = V_AR_DETAIL.get_V_AR_Detail_By_Specific_Day(AR_Day);
                    //按日取。
                    for (int i = 0; i <= v_AR_Detail_Specific_Day_List.Count - 1; i++)
                    {
                        V_AR_DETAIL v_AR_Detail = v_AR_Detail_Specific_Day_List[i];
                        if (j == 1)
                        {
                            //第五行写工号。
                            wSheet.Cells[5 + i * 2, 1] = "工号";
                            //获取原始的工号,没有前缀。
                            wSheet.Cells[5 + i * 2, 3] = "'" + v_AR_Detail.Job_number;
                            //9
                            wSheet.Cells[5 + i * 2, 9] = "姓名";
                            //11
                            wSheet.Cells[5 + i * 2, 11] = v_AR_Detail.Name;
                            //19
                            wSheet.Cells[5 + i * 2, 19] = "部门";
                            //21
                            wSheet.Cells[5 + i * 2, 21] = v_AR_Detail.Dept;
                            V_Summary_OF_AR       v_summary_of_ar = new V_Summary_OF_AR(v_AR_Detail.Job_number, YearAndMonthStr);
                            System.Data.DataTable dtARSummary     = v_summary_of_ar.getSummaryOFAR();
                            //实际出勤天数.
                            wSheet.Cells[6 + i * 2, dayList.Count + 1] = dtARSummary.Rows[0]["AR_DAYS"].ToString();
                            //事假
                            string vacatioin_total_time = dtARSummary.Rows[0]["VACATION_TOTAL_TIME"].ToString();
                            wSheet.Cells[6 + i * 2, dayList.Count + 2] = "0".Equals(vacatioin_total_time) ? "" : vacatioin_total_time;
                            string not_Finger_Print_num = dtARSummary.Rows[0]["NOT_FINGERPRINT_TIMES"].ToString();
                            //未打卡
                            wSheet.Cells[6 + i * 2, dayList.Count + 3] = "0".Equals(not_Finger_Print_num) ? "" : not_Finger_Print_num;
                            string delayTime = dtARSummary.Rows[0]["DELAY_TOTAL_TIME"].ToString();
                            //延点
                            wSheet.Cells[6 + i * 2, dayList.Count + 4] = "0.0".Equals(delayTime) ? "" : delayTime;
                            string come_late_Num = dtARSummary.Rows[0]["COME_LATE_NUM"].ToString();
                            //迟到
                            wSheet.Cells[6 + i * 2, dayList.Count + 5] = "0".Equals(come_late_Num) ? "" : come_late_Num;
                            string leave_early_num = dtARSummary.Rows[0]["LEAVE_EARLY_NUM"].ToString();
                            //早退
                            wSheet.Cells[6 + i * 2, dayList.Count + 6] = "0".Equals(leave_early_num) ? "" : leave_early_num;
                            //餐补
                            wSheet.Cells[6 + i * 2, dayList.Count + 7] = dtARSummary.Rows[0]["DINNER_SUBSIDY_NUM"].ToString();
                        }
                        System.Data.DataTable dt = V_AR_Time_Helper.getARTime(v_AR_Detail.Job_number, AR_Day);
                        string tempStr           = String.Empty;
                        int    length            = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1.ToString().Length;
                        for (int k = 0; k <= dt.Rows.Count - 1; k++)
                        {
                            //先设置颜色.
                            if ("0".Equals(dt.Rows[k]["FLAG"].ToString()))
                            {
                                if ("1".Equals(dt.Rows[k]["COME_LATE_NUM"].ToString())) //迟到
                                {
                                    //先计算单元格已有字符长度。
                                    length = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1.ToString().Length;
                                    //迟到
                                    tempStr = dt.Rows[k]["TIME"].ToString() + (k < dt.Rows.Count - 1 ? "\r\n" : "");
                                    ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 + tempStr;
                                    ((Range)wSheet.Cells[6 + i * 2, j]).Characters[length + 1, 5].Font.Color = -16776961;
                                    continue;
                                }
                                if ("1".Equals(dt.Rows[k]["LEAVE_EARLY_NUM"].ToString()))
                                {
                                    //先计算单元格已有字符长度。
                                    length = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1.ToString().Length;
                                    //早退
                                    tempStr = dt.Rows[k]["TIME"].ToString() + (k < dt.Rows.Count - 1 ? "\r\n" : "");
                                    ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 + tempStr;
                                    //写完即改变前景色。
                                    ((Range)wSheet.Cells[6 + i * 2, j]).Characters[length + 1, 5].Font.Color = -16776961;
                                    continue;
                                }
                                //先计算单元格已有字符长度。
                                length = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1.ToString().Length;
                                //正常
                                //正常上班点.
                                tempStr = dt.Rows[k]["TIME"].ToString() + (k < dt.Rows.Count - 1 ? "\r\n" : "");
                                ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 + tempStr;
                                ((Range)wSheet.Cells[6 + i * 2, j]).Characters[length + 1, 5].Font.Color = System.Drawing.Color.FromArgb(0, 0, 0).ToArgb();
                                continue;
                            }
                            //先计算单元格已有字符长度。
                            length = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1.ToString().Length;
                            //请假点。
                            tempStr = "<" + dt.Rows[k]["TIME"].ToString() + ">" + (k < (dt.Rows.Count - 1) ? "\r\n" : "");
                            ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 = ((Range)wSheet.Cells[6 + i * 2, j]).FormulaR1C1 + tempStr;
                            //((Range)wSheet.Cells[6 + i * 2, j]).Characters[length + 1, 5].Font.Bold = true;
                            //((Range)wSheet.Cells[6 + i * 2, j]).Characters[length + 1, 5].Font.ThemeColor = XlThemeColor.xlThemeColorDark1;
                            //((Range)wSheet.Cells[6 + i * 2, j]).Characters[length + 1, 5].Font.Color = -16776961;
                        }
                        pb.Value++;
                    }
                }
                rowMaxCount = wSheet.UsedRange.Rows.Count;
                //休息日,背景色变为浅绿色。
                for (int j = 1; j <= dayList.Count; j++)
                {
                    bool ifRestDay = false;
                    AR_YEAR_AND_Month_Str = aR_Properties.Start_Date.Substring(0, 8);
                    AR_Day    = AR_YEAR_AND_Month_Str + dayList[j - 1].ToString().PadLeft(2, '0');
                    ifRestDay = Have_A_Rest_Helper.ifDayOfRest(AR_Day);
                    if (ifRestDay)
                    {
                        //此列背景色改为:

                        /*
                         *  ange("AF102").Select
                         *  With Selection.Interior
                         *      .Pattern = xlSolid
                         *      .PatternColorIndex = xlAutomatic
                         *       .ThemeColor = xlThemeColorAccent3
                         *       .TintAndShade = 0.599993896298105
                         *      .PatternTintAndShade = 0
                         *  End With
                         * End Sub
                         */
                        Range rangeRestDay = wSheet.get_Range(wSheet.Cells[4, j], wSheet.Cells[rowMaxCount, j]);
                        rangeRestDay.Interior.Pattern             = XlPattern.xlPatternSolid;
                        rangeRestDay.Interior.PatternColorIndex   = XlPattern.xlPatternAutomatic;
                        rangeRestDay.Interior.ThemeColor          = XlThemeColor.xlThemeColorAccent3;
                        rangeRestDay.Interior.TintAndShade        = 0.599993896298105;
                        rangeRestDay.Interior.PatternTintAndShade = 0;
                    }
                }
                //合并第一行
                Range rangeTitle = wSheet.get_Range(wSheet.Cells[1, 1], wSheet.Cells[1, dayList.Count + 7]);
                rangeTitle.Merge();
                rangeTitle.HorizontalAlignment = XlHAlign.xlHAlignCenter;
                rangeTitle.VerticalAlignment   = XlVAlign.xlVAlignCenter;
                pb.Visible        = false;
                lblPrompt.Visible = false;
                //自动调整列宽
                //range.EntireColumn.AutoFit();
                //设置禁止弹出保存和覆盖的询问提示框
                app.DisplayAlerts          = false;
                app.AlertBeforeOverwriting = false;
                //保存excel文档并关闭
                wBook.SaveAs(xlsFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                wBook.Close(true, xlsFilePath, Type.Missing);
                //退出Excel程序
                app.Quit();
                //释放资源
                System.Runtime.InteropServices.Marshal.ReleaseComObject(range);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(wSheet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(wBook);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
                //调用GC的垃圾收集方法
                GC.Collect();
                GC.WaitForPendingFinalizers();
                ShowResult.show(lblResult, "存于: " + xlsFilePath, true);
                timerRestoreTheLblResult.Enabled = true;
                //生成工作安排表。
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "提示消息:", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Ejemplo n.º 47
0
 public static extern bool GetMessage(ref MSG lpMsg, Int32 hwnd, Int32 wMsgFilterMin, Int32 wMsgFilterMax);
Ejemplo n.º 48
0
 private static extern Int32 DispatchMessage(ref MSG lpMsg);
Ejemplo n.º 49
0
 public static extern bool TranslateMessage([In, Out] ref MSG msg);
 internal static extern int GetMessage(out MSG lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
        /// <summary>
        ///
        /// </summary>
        private void separateOutputAR()
        {
            string _defaultDir = System.Windows.Forms.Application.StartupPath + "\\考勤汇总";

            killHwndOfXls();
            Queue <int> prefix_Of_Staffs_Queue = V_AR_RESULT.get_Prefix_Staffs(YearAndMonthStr);

            if (prefix_Of_Staffs_Queue.Count == 0)
            {
                ShowResult.show(lblResult, "尚未导入本月的考勤记录!", false);
                timerRestoreTheLblResult.Enabled = true;
                return;
            }
            string prefix_Of_Staffs = string.Empty;

            //分几个工作表储存。
            while (prefix_Of_Staffs_Queue.Count > 0)
            {
                prefix_Of_Staffs = prefix_Of_Staffs_Queue.Dequeue().ToString();
                string _fileName = YearAndMonthStr + "_考勤汇总" + prefix_Of_Staffs.Substring(0, 1) + ".xls";
                if (!xlsFilePath.Contains(":"))
                {
                    //导出到Excel中
                    xlsFilePath = FileNameDialog.getSaveFileNameWithDefaultDir("考勤汇总:", "*.xls|*.xls", _defaultDir, _fileName);
                    if (!xlsFilePath.Contains(@"\"))
                    {
                        return;
                    }
                }
                else
                {
                    int index = xlsFilePath.LastIndexOf(string.Format(@"{0}_考勤汇总", YearAndMonthStr));
                    xlsFilePath = xlsFilePath.Remove(index) + _fileName;
                }
                //int index = xlsFilePath.LastIndexOf(string.Format(@"{0}_考勤汇总", YearAndMonthStr));
                //创建文件
                //DirectoryHelper.createFile(xlsFilePath);
                //xlsFilePath = xlsFilePath.Remove(index) + _fileName;
                MyExcel myExcel = new MyExcel(xlsFilePath);
                myExcel.create();
                myExcel.open();
                //追加Hwnd到队列中.
                hwndOfXls_Queue.Enqueue(myExcel.HwndOfApp);
                MSG msg = new MSG();
                //prefix_Of_Staffs = prefix_Of_Staffs_Queue.Dequeue().ToString();
                //依据前缀和月份获取列表。
                //获取第一张表
                Worksheet          _firstWS = myExcel.getFirstWorkSheetAfterOpen();
                Usual_Excel_Helper uEHelper = new Usual_Excel_Helper(_firstWS);
                uEHelper.clearAllContents(_firstWS.UsedRange);
                //清空该文档中的内容。
                Worksheet _secondWS = myExcel.getSecondWorksheetAfterOpen();
                uEHelper = new Usual_Excel_Helper(_secondWS);
                uEHelper.clearAllContents(_secondWS.UsedRange);
                Worksheet _thirdWS = myExcel.getThirdWorksheetAfterOpen();
                uEHelper = new Usual_Excel_Helper(_thirdWS);
                uEHelper.clearAllContents(_thirdWS.UsedRange);
                int machine_no = int.Parse(prefix_Of_Staffs.Substring(0, 1));
                //获取一个月内,某考勤机的考勤天数
                int nums_of_ar_days = GetARSummary.GetARSummary.get_nums_of_ar_days(machine_no, YearAndMonthStr);
                //考勤机的考勤天数
                int nums_of_staffs = GetARSummary.GetARSummary.get_nums_of_staffs(machine_no, YearAndMonthStr);
                System.Data.DataTable dt_Staff_Info       = GetARSummary.GetARSummary.get_Staff_info(YearAndMonthStr, machine_no);
                System.Data.DataTable dt_AR_Of_Each_Staff = GetARSummary.GetARSummary.get_AR_Of_Each_Staff(YearAndMonthStr, machine_no);
                System.Data.DataTable dt_AR_Summary       = GetARSummary.GetARSummary.Get_AR_Summary(YearAndMonthStr, machine_no);
                //隐藏 结果 label;
                lblResult.Visible = false;
                lblPrompt.Visible = true;
                lblPrompt.Text    = "考勤机" + prefix_Of_Staffs.Substring(0, 1) + ": 员工信息汇总中...";
                ExcelHelper.saveDtToExcelWithProgressBar(dt_Staff_Info, _firstWS, pb);
                lblPrompt.Text = "考勤机" + prefix_Of_Staffs.Substring(0, 1) + ": 考勤记录汇总中...";
                ExcelHelper.saveDtToExcelWithProgressBar(dt_AR_Of_Each_Staff, _secondWS, pb);
                lblPrompt.Text = "考勤机" + prefix_Of_Staffs.Substring(0, 1) + ": 汇总中...";
                ExcelHelper.saveDtToExcelWithProgressBar(dt_AR_Summary, _thirdWS, pb);
                Microsoft.Office.Interop.Excel.Range range_Src_AR;
                //目标 区域
                Microsoft.Office.Interop.Excel.Range range_desc_AR;
                //AR_Time 在D列存放
                Usual_Excel_Helper uEHelper_firstWS = new Usual_Excel_Helper(_firstWS);
                for (int i = 1; i <= nums_of_staffs; i++)
                {
                    range_Src_AR = ((Microsoft.Office.Interop.Excel.Range)_secondWS.Range[_secondWS.Cells[(i - 1) * (nums_of_ar_days) + 2, 4], _secondWS.Cells[i * nums_of_ar_days + 1]]);
                    range_Src_AR.Copy();
                    //第一张sheet,第4列
                    range_desc_AR = ((Microsoft.Office.Interop.Excel.Range)_firstWS.Cells[i + 1, 4]);
                    uEHelper_firstWS.pasteByTranspose(range_desc_AR);
                }
                //关闭excel
                myExcel.save();
                myExcel.close();
            }
            lblResult.Visible = true;
            lblPrompt.Visible = false;
        }
Ejemplo n.º 52
0
 public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, ref MSG lParam);
Ejemplo n.º 53
0
        public bool ProcessEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            Hwnd hwnd;
            bool client;

            GetEventParameter(eventref, kEventParamDirectObject, typeControlRef, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(IntPtr)), IntPtr.Zero, ref handle);
            hwnd = Hwnd.ObjectFromHandle(handle);

            if (hwnd == null)
            {
                return(false);
            }

            msg.hwnd = hwnd.Handle;
            client   = (hwnd.ClientWindow == handle ? true : false);

            switch (kind)
            {
            case kEventControlDraw: {
                IntPtr rgn    = IntPtr.Zero;
                HIRect bounds = new HIRect();

                GetEventParameter(eventref, kEventParamRgnHandle, typeQDRgnHandle, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(IntPtr)), IntPtr.Zero, ref rgn);

                if (rgn != IntPtr.Zero)
                {
                    Rect rbounds = new Rect();

                    GetRegionBounds(rgn, ref rbounds);

                    bounds.origin.x    = rbounds.left;
                    bounds.origin.y    = rbounds.top;
                    bounds.size.width  = rbounds.right - rbounds.left;
                    bounds.size.height = rbounds.bottom - rbounds.top;
                }
                else
                {
                    HIViewGetBounds(handle, ref bounds);
                }

                if (!hwnd.visible)
                {
                    if (client)
                    {
                        hwnd.expose_pending = false;
                    }
                    else
                    {
                        hwnd.nc_expose_pending = false;
                    }
                    return(false);
                }

                if (!client)
                {
                    DrawBorders(hwnd);
                }

                Driver.AddExpose(hwnd, client, bounds);

                return(true);
            }

            case kEventControlVisibilityChanged: {
                if (client)
                {
                    msg.message = Msg.WM_SHOWWINDOW;
                    msg.lParam  = (IntPtr)0;
                    msg.wParam  = (HIViewIsVisible(handle) ? (IntPtr)1 : (IntPtr)0);
                    return(true);
                }
                return(false);
            }

            case kEventControlBoundsChanged: {
                HIRect view_frame = new HIRect();

                HIViewGetFrame(handle, ref view_frame);
                if (!client)
                {
                    hwnd.X      = (int)view_frame.origin.x;
                    hwnd.Y      = (int)view_frame.origin.y;
                    hwnd.Width  = (int)view_frame.size.width;
                    hwnd.Height = (int)view_frame.size.height;
                    Driver.PerformNCCalc(hwnd);
                }

                msg.message = Msg.WM_WINDOWPOSCHANGED;
                msg.hwnd    = hwnd.Handle;

                return(true);
            }

            case kEventControlGetFocusPart: {
                short pcode = 0;
                SetEventParameter(eventref, kEventParamControlPart, typeControlPartCode, (uint)Marshal.SizeOf(typeof(short)), ref pcode);
                return(false);
            }

            case kEventControlDragEnter:
            case kEventControlDragWithin:
            case kEventControlDragLeave:
            case kEventControlDragReceive:
                return(Dnd.HandleEvent(callref, eventref, handle, kind, ref msg));
            }
            return(false);
        }
Ejemplo n.º 54
0
        public bool ProcessEvent(IntPtr callref, IntPtr eventref, IntPtr handle, uint kind, ref MSG msg)
        {
            QDPoint qdpoint       = new QDPoint();
            CGPoint point         = new CGPoint();
            Rect    window_bounds = new Rect();
            IntPtr  view_handle   = IntPtr.Zero;
            IntPtr  window_handle = IntPtr.Zero;
            bool    client        = true;
            ushort  button        = 0;
            Hwnd    hwnd;

            GetEventParameter(eventref, kEventParamMouseLocation, typeQDPoint, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(QDPoint)), IntPtr.Zero, ref qdpoint);
            GetEventParameter(eventref, kEventParamMouseButton, typeMouseButton, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(ushort)), IntPtr.Zero, ref button);

            if (button == 1 && ((Driver.ModifierKeys & Keys.Control) != 0))
            {
                button = 2;
            }

            point.x = qdpoint.x;
            point.y = qdpoint.y;

            if (FindWindow(qdpoint, ref window_handle) == 5)
            {
                return(true);
            }

            GetWindowBounds(handle, 33, ref window_bounds);
            HIViewFindByID(HIViewGetRoot(handle), new HIViewID(EventHandler.kEventClassWindow, 1), ref window_handle);

            point.x -= window_bounds.left;
            point.y -= window_bounds.top;

            HIViewGetSubviewHit(window_handle, ref point, true, ref view_handle);
            HIViewConvertPoint(ref point, window_handle, view_handle);

            hwnd = Hwnd.ObjectFromHandle(view_handle);

            if (hwnd != null)
            {
                client = (hwnd.ClientWindow == view_handle ? true : false);
            }

            if (XplatUICarbon.Grab.Hwnd != IntPtr.Zero)
            {
                hwnd   = Hwnd.ObjectFromHandle(XplatUICarbon.Grab.Hwnd);
                client = true;
            }
            if (hwnd == null)
            {
                return(true);
            }

            if (client)
            {
                qdpoint.x = (short)point.x;
                qdpoint.y = (short)point.y;

                Driver.ScreenToClient(hwnd.Handle, ref qdpoint);
            }
            else
            {
                point.x = qdpoint.x;
                point.y = qdpoint.y;
            }

            msg.hwnd   = hwnd.Handle;
            msg.lParam = (IntPtr)((ushort)point.y << 16 | (ushort)point.x);

            switch (kind)
            {
            case kEventMouseDown:
                UpdateMouseState(button, true);
                msg.message = (client ? Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((button - 1) * 3) + 1;
                msg.wParam  = Driver.GetMousewParam(0);
                if (ClickPending.Pending && (((DateTime.Now.Ticks - ClickPending.Time) < DoubleClickInterval) && (msg.hwnd == ClickPending.Hwnd) && (msg.wParam == ClickPending.wParam) && (msg.lParam == ClickPending.lParam) && (msg.message == ClickPending.Message)))
                {
                    msg.message          = (client ? Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((button - 1) * 3) + 3;
                    ClickPending.Pending = false;
                }
                else
                {
                    ClickPending.Pending = true;
                    ClickPending.Hwnd    = msg.hwnd;
                    ClickPending.Message = msg.message;
                    ClickPending.wParam  = msg.wParam;
                    ClickPending.lParam  = msg.lParam;
                    ClickPending.Time    = DateTime.Now.Ticks;
                }
                break;

            case kEventMouseUp:
                UpdateMouseState(button, false);
                msg.message = (client ? Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE) + ((button - 1) * 3) + 2;
                msg.wParam  = Driver.GetMousewParam(0);
                break;

            case kEventMouseDragged:
            case kEventMouseMoved:
                if (XplatUICarbon.Grab.Hwnd == IntPtr.Zero)
                {
                    IntPtr ht = IntPtr.Zero;
                    if (client)
                    {
                        ht = (IntPtr)HitTest.HTCLIENT;
                        NativeWindow.WndProc(msg.hwnd, Msg.WM_SETCURSOR, msg.hwnd, (IntPtr)HitTest.HTCLIENT);
                    }
                    else
                    {
                        ht = (IntPtr)NativeWindow.WndProc(hwnd.client_window, Msg.WM_NCHITTEST, IntPtr.Zero, msg.lParam).ToInt32();
                        NativeWindow.WndProc(hwnd.client_window, Msg.WM_SETCURSOR, msg.hwnd, ht);
                    }
                }
                msg.message = (client ? Msg.WM_MOUSEMOVE : Msg.WM_NCMOUSEMOVE);
                msg.wParam  = Driver.GetMousewParam(0);
                break;

            case kEventMouseWheelMoved:
            case kEventMouseScroll:
                UInt16 axis  = 0;
                Int32  delta = 0;

                GetEventParameter(eventref, kEventParamMouseWheelAxis, typeMouseWheelAxis, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(UInt16)), IntPtr.Zero, ref axis);
                GetEventParameter(eventref, kEventParamMouseWheelDelta, typeLongInteger, IntPtr.Zero, (uint)Marshal.SizeOf(typeof(Int32)), IntPtr.Zero, ref delta);

                if (axis == kEventMouseWheelAxisY)
                {
                    msg.hwnd    = XplatUICarbon.FocusWindow;
                    msg.message = Msg.WM_MOUSEWHEEL;
                    msg.wParam  = Driver.GetMousewParam(delta * 40);
                    return(true);
                }
                break;

            default:
                return(false);
            }
            Driver.mouse_position.X = (int)point.x;
            Driver.mouse_position.Y = (int)point.y;
            return(true);
        }
Ejemplo n.º 55
0
 private static extern bool TranslateMessage(ref MSG lpMsg);
Ejemplo n.º 56
0
        public static bool TranslateMessage(ref MSG msg)
        {
            IntPtr uStyle    = NativeMethods.GetWindowLong(msg.hwnd, SetWindowLongOffsets.GWL_STYLE);
            int    uChildRes = uStyle.ToInt32() & WindowMessages.WS_CHILD;
            int    nRes      = 0;

            if (uChildRes != 0)
            {
                IntPtr hWndParent = NativeMethods.GetParent(msg.hwnd);
                for (int i = 0; i < m_aPreMessages.Count; i++)
                {
                    var    uiManager   = m_aPreMessages[i];
                    IntPtr hTempParent = hWndParent;

                    while (hTempParent != IntPtr.Zero)
                    {
                        var paintHwnd = uiManager.GetPaintWindow();
                        if (msg.hwnd == paintHwnd || hTempParent == paintHwnd)
                        {
                            if (uiManager.TranslateAccelerator(msg))
                            {
                                return(true);
                            }

                            if (uiManager.PreMessageHandler(msg.message, msg.wParam, msg.lParam, ref nRes))
                            {
                                return(true);
                            }

                            return(false);
                        }
                        hTempParent = NativeMethods.GetParent(msg.hwnd);
                    }
                }
            }
            else
            {
                for (int i = 0; i < m_aPreMessages.Count; i++)
                {
                    var uiManager = m_aPreMessages[i];

                    var paintHwnd = uiManager.GetPaintWindow();
                    if (msg.hwnd == paintHwnd)
                    {
                        if (uiManager.TranslateAccelerator(msg))
                        {
                            return(true);
                        }

                        if (uiManager.PreMessageHandler(msg.message, msg.wParam, msg.lParam, ref nRes))
                        {
                            return(true);
                        }

                        return(false);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 57
0
 private static extern bool PeekMessage(ref MSG lpMsg, Int32 hwnd, Int32 wMsgFilterMin, Int32 wMsgFilterMax, PeekMessageOption wRemoveMsg);
Ejemplo n.º 58
0
 public static extern bool GetMessage(ref MSG message, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
Ejemplo n.º 59
0
        public void Service()
        {
            int       nc      = 0;
            bool      cliStop = false;
            string    MSG;
            string    thankMSG         = "Logged out";
            string    clientName       = childName;
            TcpClient clientConnection = serConnection;

            Console.Write("***Client {0,6} ", clientName);
            Console.WriteLine(" started ...");

            try
            {
                stream = clientConnection.GetStream();
                //MSG = childName + ": ";
                //MSG = MSG + "Echo service - " + "Send message or " + "just $$ to quit";
                //outBuff = Encoding.ASCII.GetBytes(MSG);
                //stream.Write(outBuff, 0, MSG.Length);
                nc = stream.Read(inBuff, 0, buffSize);

                while ((nc > 0) && (!cliStop))
                {
                    MSG = Encoding.ASCII.GetString(inBuff, 0, nc);

                    /**
                     *  STRING SEPERATORS
                     **/


                    string[] inMessage = MSG.Split(';');



                    if (MSG != EOB)
                    {
                        Console.WriteLine("Message From =>", clientName);
                        Console.WriteLine("            " + MSG);

                        string placeHolder = functionSwitch(MSG);
                        //getTutorials();

                        outBuff = Encoding.ASCII.GetBytes(placeHolder);
                        stream.Write(outBuff, 0, placeHolder.Length);



                        nc = stream.Read(inBuff, 0, buffSize);
                    }
                    else
                    {
                        //outBuff = Encoding.ASCII.GetBytes(thankMSG);

                        //stream.Write(outBuff, 0, thankMSG.Length);
                        //stream.Flush();

                        //Console.Write("***Client wants");
                        //Console.WriteLine(" to stop");

                        //cliStop = true;

                        Console.Write("***Client wants");
                        Console.WriteLine(" to stop");
                        cliStop = true;
                        outBuff = Encoding.ASCII.GetBytes(thankMSG);
                        stream.Write(outBuff, 0, thankMSG.Length);//break point
                        stream.Flush();
                    }
                }
                stream.Close();
                clientConnection.Close();
                Console.Write("***Client {0,6} ", clientName);
                Console.WriteLine("stopped!");
            }
            catch (Exception ex)
            {
                Console.Write("Err: Client {0,6} left ", clientName);
                Console.WriteLine(" or " + ex.Message);
            }
        }
 internal static extern bool TranslateMessage(ref MSG lpMsg);