Example #1
0
 public static extern bool GetLastInputInfo(ref TagLastInputInfo moment);
Example #2
0
 //Timerul pentru systemul de inactivitate
 private void idleTimer_Tick(object sender, EventArgs e)
 {
     TagLastInputInfo lastInput = new TagLastInputInfo();
     lastInput.cbSize = (uint)Marshal.SizeOf(lastInput);
     lastInput.dwTime = 0;
     if (GetLastInputInfo(ref lastInput))
     {
         int idleTime = Environment.TickCount - lastInput.dwTime;
         //label14.Text = ((float)(idleTime / 1000.0)).ToString() + " s";
         bool passed = (int)(idleTime / 1000.0) > inactivTimeValue;
         if (activityStarted && passed)
         {
             idleTime = 0;
             activityStarted = false;
             idleTimer.Stop();
             Conexiune.ActivityStop(user.Id, inactivTimeValue);
             chooseProjectButton.Enabled = true;
             saveActivityButton.Enabled = false;
             ActivityBox box = new ActivityBox();
             Activity activity = new Activity();
             activity.User_id = user.Id;
             activity.Project_id = selectedProject.Id;
             activity.Start_time = DateTime.Now;
             activity.Description = string.Format("[Aplicatie]: Activitate oprită. Motiv: inactiv > {0} minute", inactivTimeValue / 60);
             activity.Duration = 0;
             activity.Task_id = 0;
             activity.Type = 0;
             Conexiune.ActivityInsert(activity);
             workTimer.Stop();
             pauseTimer.Start();
             statusProjectLabel.Text = "PAUZĂ";
             statusProjectLabel.ForeColor = Color.Red;
             box.HeaderColor = Color.Red;
             box.HeaderText = "PAUZĂ";// +nowTime;
             startActivityButton.Enabled = true;
             pauseActivityButton.Enabled = true;
             string moment = BoxDateTime(DateTime.Now);
             box.DateText = moment.Substring(0, 5);
             box.TimeText = moment.Substring(6);
             box.BodyText = string.Format("[Aplicatie]: Activitate oprită. Motiv: inactiv > {0} minute", inactivTimeValue / 60);
             int count = myActPanel.Controls.Count;
             Point p1 = new Point(3, 3 + count * 85);
             Point p2 = new Point(3, 3 + (nBox++) * 85);
             box.Location = (count > nBox) ? p1 : p2;
             myActPanel.Controls.Add(box.ShowControl);
             myActPanel.Controls[myActPanel.Controls.Count - 1].Focus();
         }
     }
 }