示例#1
0
        private void ExportCommandFunc()
        {
            if (!DeviceTrafficLogViewModels.Any())
            {
                Messenger.Default.Send(new NotificationMessage("没有数据可以导出!"), Tokens.DeviceTrafficLogPage_ShowNotification);
                return;
            }

            var dt = DataHelper <DeviceTrafficLogViewModel> .ListToDataTable(DeviceTrafficLogViewModels.ToList());

            dt.Columns.Remove("TrafficID");
            dt.Columns.Remove("RecordType");
            dt.Columns.Remove("RecordUploadTime");
            dt.Columns.Remove("AuthenticationType");
            dt.Columns.Remove("IsInDesignMode");
            dt.Columns.Remove("DeviceId");

            dt.Columns["DeviceUserID"].SetOrdinal(3);
            dt.Columns["AuthenticationString"].SetOrdinal(4);
            dt.Columns["RecordTime"].SetOrdinal(6);

            dt.Columns["DeviceCode"].ColumnName           = "设备编号";
            dt.Columns["DeviceType"].ColumnName           = "设备类型";
            dt.Columns["DeviceSN"].ColumnName             = "设备序列号";
            dt.Columns["DeviceUserID"].ColumnName         = "人员工号";
            dt.Columns["AuthenticationString"].ColumnName = "验证方式";
            dt.Columns["Remark"].ColumnName     = "验证结果";
            dt.Columns["RecordTime"].ColumnName = "记录时间";

            Messenger.Default.Send(new OpenWindowMessage()
            {
                DataContext = dt
            }, Tokens.DeviceTrafficLogPage_OpenExportView);
        }
示例#2
0
        private void ProcessQueryPage(int pageIndex)
        {
            try
            {
                var conditions = new Hashtable();
                if (!TryGetConditions(pageIndex, PageSize, out conditions))
                {
                    return;
                }

                DispatcherHelper.CheckBeginInvokeOnUI(async() =>
                {
                    string message = "";

                    var controller = await DialogCoordinator.Instance.ShowProgressAsync(this, "查询数据", "查询数据中,请稍等");
                    controller.SetIndeterminate();

                    await Task.Run(() =>
                    {
                        try
                        {
                            Log.Info("同步数据中..");
                            var devices = new List <DeviceController>();
                            if (!string.IsNullOrWhiteSpace(DeviceCode))
                            {
                                var queriedDevice = ApplicationManager.GetInstance().AuthorizationDevices.First(x => x.Code == DeviceCode);
                                devices.Add(queriedDevice);
                            }
                            else
                            {
                                devices = ApplicationManager.GetInstance().AuthorizationDevices;
                            }

                            string[] messages;
                            var resultTypes = new DeviceServiceClient().SyncDeviceTrafficLogs(devices.ToArray(), out messages);
                            message         = MessageHandler.GenerateDeviceMessage(resultTypes, messages, "同步数据成功!", "同步数据失败!");
                            Log.Info(message);
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex);
                        }

                        try
                        {
                            Log.Info("查询数据中..");
                            int totalCount             = 0;
                            DeviceTrafficLogViewModels = QueryData(conditions, out totalCount);
                            if (totalCount % PageSize == 0)
                            {
                                TotalPage = (totalCount / PageSize).ToString();
                            }
                            else
                            {
                                TotalPage = ((totalCount / PageSize) + 1).ToString();
                            }
                            RaisePropertyChanged(null);
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ex);
                        }
                    });

                    await controller.CloseAsync();

                    if (!DeviceTrafficLogViewModels.Any())
                    {
                        Messenger.Default.Send(new NotificationMessage("查询数据结果为空"), Tokens.DeviceTrafficLogPage_ShowNotification);
                    }
                });
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }