Ejemplo n.º 1
0
        private void CalcTime()
        {
            WsUserModel usu = GetCurUser();

            if (usu != null)
            {
                IActivityDAL dalAct = new ActivityImpl();
                string[]     t      = dalAct.GetCurTime(usu.idActivityAssistance).Split(':');
                int          hr     = Convert.ToInt32(t[0]);
                int          mm     = Convert.ToInt32(t[1]);
                int          ss     = Convert.ToInt32(t[2]);
                string       actualTime;
                object       res;
                for (int h = hr; h < 3; h++)
                {
                    if (usu.idActivityAssistance == -5)
                    {
                        break;
                    }
                    for (int m = mm; m < 60; m++)
                    {
                        for (int s = ss; s < 60; s++)
                        {
                            if (usu.idActivityAssistance != -5)
                            {
                                actualTime = FixTime(h) + ":" + FixTime(m) + ":" + FixTime(s);
                                res        = dalAct.UpdateTime(actualTime, usu.idActivityAssistance);
                                if (res != null)
                                {
                                    Clients.AllExcept(GetExcepts(usu)).UpdateTime(res);
                                }
                                Thread.Sleep(1000);
                            }
                        }
                        ss = 0;
                    }
                    mm = 0;
                }
                if (usu.idActivityAssistance != -5)
                {
                    actualTime = "03:00:00";
                    res        = dalAct.UpdateTime(actualTime, usu.idActivityAssistance);
                    if (res != null)
                    {
                        Clients.AllExcept(GetExcepts(usu)).UpdateTime(res);
                    }
                    bool res2 = dalAct.StopTime(usu.idActivityAssistance, usu.user.idUser);
                    if (res2)
                    {
                        usu.idActivityAssistance = -5;
                        Clients.AllExcept(GetExcepts(usu)).StopCurActivitie(res);
                    }
                }
                try {
                    Thread.CurrentThread.Abort();
                } catch (Exception e) {
                }
            }
        }
Ejemplo n.º 2
0
        public void ChangeTime(int id)
        {
            WsUserModel usu = GetCurUser();

            if (usu != null)
            {
                if (id != usu.idActivityAssistance && usu.idActivityAssistance != -5)
                {
                    IActivityDAL dalAct = new ActivityImpl();
                    bool         res    = dalAct.StopTime(id, usu.user.idUser);
                    if (res)
                    {
                        usu.idActivityAssistance = -5;
                        Clients.AllExcept(GetExcepts(usu)).StopCurActivitie(res);
                    }
                }
                else
                {
                    usu.idActivityAssistance = id;
                    if (usu.thread == null || usu.idActivityAssistance == -5)
                    {
                        if (usu.thread != null)
                        {
                            try {
                                usu.thread.Abort();
                                usu.thread = null;
                            } catch (Exception e) {
                            }
                        }
                        usu.thread = new Thread(CalcTime);
                        usu.thread.Start();
                    }
                    else
                    {
                        try {
                            usu.thread.Abort();
                            usu.thread = null;
                            Clients.AllExcept(GetExcepts(usu)).UpdateTime(new { stop = true });
                        } catch (Exception e) {
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void StopSessionActivity(int id)
        {
            WsUserModel usu = GetCurUser();

            if (usu != null)
            {
                IActivityDAL dalAct = new ActivityImpl();
                bool         res    = dalAct.StopTime(id, usu.user.idUser);
                if (res)
                {
                    if (usu.thread != null)
                    {
                        try {
                            usu.thread.Abort();
                            usu.thread = null;
                            Clients.AllExcept(GetExcepts(usu)).UpdateTime(new { stop = true });
                        } catch (Exception e) {
                        }
                    }
                    usu.idActivityAssistance = -5;
                    Clients.AllExcept(GetExcepts(usu)).StopCurActivitie(res);
                }
            }
        }