private void cmdOk_Click(object sender, RoutedEventArgs e)
        {
            if (cbShifts.SelectedIndex == -1)
            {
                cbShifts.Focus();
                return;
            }
            Shift shift = cbShifts.SelectedItem as Shift;

            if (null != shift)
            {
                TSBShift inst = ops.Shifts.Create(shift, _user).Value();
                if (null != inst)
                {
                    shift.AssignTo(inst);
                }
                var tsb    = ops.TSB.GetCurrent().Value();
                var plazas = (null != tsb) ? ops.TSB.GetTSBPlazas(tsb).Value() : null;
                ops.Shifts.ChangeShift(inst, plazas);
            }
            // Main Menu Page
            var page = new Menu.MainMenu();

            PageContentManager.Instance.Current = page;
        }
Exemple #2
0
 public TSBShift Create([FromBody] TSBShiftCreate value)
 {
     if (null == value)
     {
         return(null);
     }
     return(TSBShift.Create(value.Shift, value.User));
 }
Exemple #3
0
            public void ChangeShift(TSBShift shift)
            {
                if (null == shift)
                {
                    return;
                }
                NRestClient.Create(port: 9000).Execute(
                    RouteConsts.Shift.ChangeShift.Url, shift);

                // reset last update for reload new shirt.
                LastUpdated = DateTime.MinValue;
            }
Exemple #4
0
            public TSBShift GetCurrent()
            {
                TimeSpan ts = DateTime.Now - LastUpdated;

                if (ts.TotalMinutes >= 1)
                {
                    _current = NRestClient.Create(port: 9000).Execute <TSBShift>(
                        RouteConsts.Shift.GetCurrent.Url, new { });

                    LastUpdated = DateTime.Now;
                }
                return(_current);
            }
        public NDbResult ChangeShift([FromBody] TSBShift value)
        {
            NDbResult result;

            if (null == value)
            {
                result = new NDbResult <Shift>();
                result.ParameterIsNull();
            }
            else
            {
                result = TSBShift.ChangeShift(value);
                if (!result.errors.hasError)
                {
                    var plaza = ConfigManager.Instance.Plaza;
                    if (null != plaza)
                    {
                        var taApp  = plaza.TAApp;
                        var todApp = plaza.TODApp;
                        if (null != taApp && null != taApp.Http)
                        {
                            var http = taApp.Http;
                            NRestClient.WebProtocol protocol = (http.Protocol == "http") ?
                                                               NRestClient.WebProtocol.http : NRestClient.WebProtocol.https;
                            string hostName = http.HostName;
                            int    portNo   = http.PortNumber;
                            var    client   = new NRestClient(protocol, hostName, portNo);
                            if (null != client)
                            {
                                client.Execute2 <NRestResult>(RouteConsts.Notify.ShiftChanged.Url, new { });
                            }
                        }
                        if (null != todApp && null != todApp.Http)
                        {
                            var http = todApp.Http;
                            NRestClient.WebProtocol protocol = (http.Protocol == "http") ?
                                                               NRestClient.WebProtocol.http : NRestClient.WebProtocol.https;
                            string hostName = http.HostName;
                            int    portNo   = http.PortNumber;
                            var    client   = new NRestClient(protocol, hostName, portNo);
                            if (null != client)
                            {
                                client.Execute2 <NRestResult>(RouteConsts.Notify.ShiftChanged.Url, new { });
                            }
                        }
                    }
                }
            }
            return(result);
        }
        public NDbResult <TSBShift> Create([FromBody] TSBShiftCreate value)
        {
            NDbResult <TSBShift> result;

            if (null == value)
            {
                result = new NDbResult <TSBShift>();
                result.ParameterIsNull();
            }
            else
            {
                result = TSBShift.Create(value.Shift, value.User);
            }
            return(result);
        }
Exemple #7
0
            public NRestResult ChangeShift(TSBShift value, List <Plaza> plazas)
            {
                NRestResult ret;
                NRestClient client = NRestClient.CreateLocalClient();

                if (null == client)
                {
                    ret = new NRestResult();
                    ret.RestInvalidConfig();
                    return(ret);
                }

                if (null != value)
                {
                    // set date
                    value.Begin = DateTime.Now;
                    ret         = client.Execute(RouteConsts.Shift.ChangeShift.Url, value);
                    if (ret.Ok && null != plazas && plazas.Count > 0)
                    {
                        // send to server
                        SCWOperations server = SCWServiceOperations.Instance.Plaza;
                        var           inst   = new SCWChiefOfDuty();
                        inst.networkId     = 31; // TODO: network id required.
                        inst.plazaId       = Convert.ToInt32(plazas[0].SCWPlazaId);
                        inst.staffId       = value.UserId;
                        inst.staffTypeId   = 1;
                        inst.beginDateTime = value.Begin;
                        // send.
                        server.TOD.SaveChiefOfDuty(inst);
                    }
                }
                else
                {
                    ret = new NRestResult();
                    ret.ParameterIsNull();
                }
                return(ret);
            }
        public NDbResult <TSBShift> GetCurrent()
        {
            var result = TSBShift.GetTSBShift();

            return(result);
        }
Exemple #9
0
 public void ChangeShift([FromBody] TSBShift shift)
 {
     TSBShift.ChangeShift(shift);
 }
Exemple #10
0
 public TSBShift GetCurrent()
 {
     return(TSBShift.GetCurrent());
 }