コード例 #1
0
        public async void GetControlLogs()
        {
            try
            {
                IsBusy = true;

                if (Dbcontext == null)
                {
                    Dbcontext = new ServiceReference1.Service1Client(ServiceReference1.Service1Client.EndpointConfiguration.BasicHttpBinding_IService1);
                }

                var result = Dbcontext.GetOfficeInternalControlLogs(Application.Current.Properties["UN"].ToString(),
                                                                    Application.Current.Properties["PW"].ToString(), Application.Current.Properties["Ucid"].ToString(), IniControlId);
                ObservableCollection <InternalControlLogsCls> temp = new ObservableCollection <InternalControlLogsCls>();
                InternalControlLogsCls log;

                if (result != null)
                {
                    InternalControlName = result.Name;

                    if (result.Logs != null && result.Logs.Length > 0)
                    {
                        foreach (ServiceReference1.InternalControlOfficeLogData logdata in result.Logs)
                        {
                            log = new InternalControlLogsCls();
                            if (logdata.Id != null)
                            {
                                log.Id = (int)logdata.Id;
                            }
                            log.AoNr    = logdata.AoNr;
                            log.Created = logdata.Created;
                            if (logdata.Created != null)
                            {
                                log.CreatedString = logdata.Created.ToString("yyyy-MM-dd H:mm");
                            }
                            if (logdata.Employee != null)
                            {
                                log.CreatedByName = logdata.Employee.FName + " " + logdata.Employee.LName;
                            }
                            if (!string.IsNullOrWhiteSpace(logdata.RegNr))
                            {
                                log.RegNr = logdata.RegNr.ToUpper();
                            }
                            if (logdata.VehicleBrand != null)
                            {
                                log.VehicleBrand = logdata.VehicleBrand.Name;
                            }

                            if (logdata.IsPartSaved == true)
                            {
                                log.Icon        = "warning.png";
                                log.IsPartSaved = true;
                            }
                            else
                            {
                                log.Icon        = "info.png";
                                log.IsPartSaved = false;
                            }
                            temp.Add(log);
                        }

                        AllLogs = new ObservableCollection <InternalControlLogsCls>(temp.OrderByDescending(ro => ro.Created));
                    }
                }

                IsBusy = false;
            }
            catch (Exception e)
            {
                IsBusy = false;
                await Application.Current.MainPage.DisplayAlert("Fel", e.Message, "Stäng");
            }
        }