예제 #1
0
    /// <summary>
    /// Определяет текущее состояние пользователя.
    /// </summary>
    protected virtual void DefineCurrentState()
    {
        SLService.SLService service = new SLService.SLService();
        IList<WorkEvent> mainAndLastWorkEvent = service.GetMainWorkAndLastEvent(Page.CurrentUser.ID.Value);
        WorkEvent TodayWorkEvent = mainAndLastWorkEvent[0];
        WorkEvent LastEvent = mainAndLastWorkEvent[1];

        if (TodayWorkEvent == null ||
            (TodayWorkEvent.BeginTime != TodayWorkEvent.EndTime))
        {
            State = ControlState.WorkFinished;
            return;
        }

        switch (LastEvent.EventType)
        {
            case WorkEventType.MainWork:
                State = ControlState.WorkGoes;
                break;

            case WorkEventType.TimeOff:
                State = LastEvent.BeginTime == LastEvent.EndTime
                            ? ControlState.Absent
                            : ControlState.WorkGoes;
                break;

            case WorkEventType.LanchTime:
                State = LastEvent.BeginTime == LastEvent.EndTime
                            ? ControlState.Feeding
                            : ControlState.WorkGoes;
                break;

            case WorkEventType.StudyEnglish:
                State = LastEvent.BeginTime == LastEvent.EndTime
                            ? ControlState.EnglishLesson
                            : ControlState.WorkGoes;
                break;
        }
    }
예제 #2
0
    /// <summary>
    /// Показывает временные отрезки.
    /// </summary>
    private void showTimes()
    {
        SLService.SLService service = new SLService.SLService();
        IDictionary<TimeKey, TimeSpan> timeDict = service.GetFullDayTimes(Page.CurrentUser.ID.Value);

        int hours = (int)timeDict[TimeKey.TodayWork].TotalHours;
        int minutes = (int)(timeDict[TimeKey.TodayWork] - new TimeSpan(hours, 0, 0)).TotalMinutes;
        lblTime.Text = String.Format(lblTime.Text, hours, minutes);

        // Время до окончания дня.
        hours = (int)timeDict[TimeKey.TodayRest].TotalHours;
        minutes = (int)(timeDict[TimeKey.TodayRest] - new TimeSpan(hours, 0, 0)).TotalMinutes;
        lblRemainToday.Text = String.Format(lblRemainToday.Text, hours, minutes);

        // Время окончания работы.
        DateTime endWork = DateTime.Now.Add(timeDict[TimeKey.TodayRest]);
        lblEndDay.Text = String.Format(lblEndDay.Text, endWork.ToShortTimeString());

        // Время до окончания недели.
        hours = (int)timeDict[TimeKey.WeekRest].TotalHours;
        minutes = (int)(timeDict[TimeKey.WeekRest] - new TimeSpan(hours, 0, 0)).TotalMinutes;
        lblRemainWeek.Text = String.Format(lblRemainWeek.Text, hours, minutes);

        // Время до окончания месяца.
        hours = (int)timeDict[TimeKey.MonthRest].TotalHours;
        minutes = (int)(timeDict[TimeKey.MonthRest] - new TimeSpan(hours, 0, 0)).TotalMinutes;
        lblRemainMonth.Text = String.Format(lblRemainMonth.Text, hours, minutes);
    }
예제 #3
0
    private void setUserWorkEvent(bool isOpenAction, WorkEventType eventType)
    {
        if (!WebHelpers.IsRequestIPAllowed())
            return;

        SLService.SLService service = new SLService.SLService();
        service.SetUserWorkEvent(Page.CurrentUser.ID.Value, isOpenAction, eventType);
    }
예제 #4
0
    /// <summary>
    /// Информировать последнего пользователя.
    /// </summary>
    private void informLastUser()
    {
        SLService.SLService service = new SLService.SLService();
        int usersCount = service.GetNumberOfActiveUsers();

        if (usersCount >= 0 && usersCount <= 2)
        {
            String scriptAllert = "<script type='text/javascript'> alert('";
            switch (usersCount)
            {
                case 0:
                    scriptAllert += "Вы последний уходите из офиса!";
                    break;

                case 1:
                    scriptAllert += "В офисе остался только один человек!";
                    break;

                case 2:
                    scriptAllert += "В офисе осталось только двое!";
                    break;
            }

            scriptAllert += "\\nУходя, выключите свет и кулер в столовой!'); </script>";
            Page.ClientScript.RegisterClientScriptBlock(GetType(),
                                                        "NewDay", scriptAllert);
        }
    }
예제 #5
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        SLService.SLService service = new SLService.SLService();
        gridViewUserDayEvents.DataSource = service.GetTodayWorkEventsOfUser(Page.CurrentUser.ID.Value);
        gridViewUserDayEvents.DataBind();

        showTimes();
    }
예제 #6
0
    /// <summary>
    /// ������������� ���������� ������������.
    /// </summary>
    private void informLastUser()
    {
        SLService.SLService service = new SLService.SLService();
        int usersCount = service.GetNumberOfActiveUsers();

        if (usersCount >= 0 && usersCount <= 2)
        {
            String scriptAllert = "<script type='text/javascript'> alert('";
            switch (usersCount)
            {
                case 0:
                    scriptAllert += "�� ��������� ������� �� �����!";
                    break;

                case 1:
                    scriptAllert += "� ����� ������� ������ ���� �������!";
                    break;

                case 2:
                    scriptAllert += "� ����� �������� ������ ����!";
                    break;
            }

            scriptAllert += "\\n�����, ��������� ���� � ����� � ��������!'); </script>";
            Page.ClientScript.RegisterClientScriptBlock(GetType(),
                                                        "NewDay", scriptAllert);
        }
    }