Beispiel #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) {
                }
            }
        }