コード例 #1
0
        /// <summary>
        /// Print on stop
        /// </summary>
        void PrintLending()
        {
            var label = LabelTemplates.GetLendingLabel(_lending.ToList());

            var profile = _repository.Profiles.First();
            var device  = _repository.MobileDevices.First();

            if (device.PrinterAddress == null)
            {
                var message = Resources.GetString(Resource.String.message_setup_printer);
                UserDialogs.Instance.Alert(message);
                return;
            }

            var title = Resources.GetString(Resource.String.message_printing);

            UserDialogs.Instance.ShowLoading(title);

            var address = device.PrinterAddress;

            new Task(new Action(() =>
            {
                var result = PrinterUtils.Print(label, address);

                Activity.RunOnUiThread(() =>
                {
                    UserDialogs.Instance.HideLoading();

                    if (result.Status != PrintStatus.Success)
                    {
                        UserDialogs.Instance.Alert(result.Message);
                    }
                });
            })).Start();
        }
コード例 #2
0
        /// <summary>
        /// Set profile printer
        /// </summary>
        /// <returns><c>true</c>, if profile printer was set, <c>false</c> otherwise.</returns>
        /// <param name="address">Address.</param>
        void SetProfilePrinter(string address)
        {
            UserDialogs.Instance.ShowLoading();

            new Task(new Action(() =>
            {
                var printResult = PrinterUtils.SetDefaultPrinterSettings(address);

                Activity.RunOnUiThread(() =>
                {
                    UserDialogs.Instance.HideLoading();

                    switch (printResult.Status)
                    {
                    case PrintStatus.Success:

                        ProfileService.SetCurrentPrinter(_repository, address);

                        UserDialogs.Instance.Alert(Resources.GetString(Resource.String.message_printer_setup));
                        _fragmentActionListener.Pop();
                        break;

                    default:
                        UserDialogs.Instance.Alert(Resources.GetString(Resource.String.message_print_setup_failed));
                        break;
                    }
                });
            })).Start();
        }
コード例 #3
0
        /// <summary>
        /// Print the Load and Itinerary report
        /// </summary>
        void PrintLoadAndItineryReport()
        {
            var profile    = _repository.Profiles.First();
            var device     = _repository.MobileDevices.First();
            var subscriber = _repository.Subscribers.Find(profile.SubscriberID);

            var driverStock = _repository.DriverStock.Where(x => x.TrailerNumber == profile.CurrentTrailerNumber).ToList();

            var label = LabelTemplates.GetEndOfDayLabel(profile.CurrentRunNumber, _calls.ToList(), profile.CurrentTrailerNumber,
                                                        profile.SubscriberID, driverStock, subscriber);

            if (device.PrinterAddress == null)
            {
                var message = Resources.GetString(Resource.String.message_setup_printer);
                UserDialogs.Instance.Alert(message);
                return;
            }

            var address = device.PrinterAddress;

            var title = Resources.GetString(Resource.String.message_printing);

            UserDialogs.Instance.ShowLoading(title);

            Task.Run(() =>
            {
                var result = PrinterUtils.Print(label, address);

                if (result.Status == PrintStatus.Success)
                {
                    //result = PrinterUtils.Print(itineraryLabel, address);

                    Activity.RunOnUiThread(() =>
                    {
                        UserDialogs.Instance.HideLoading();

                        if (result.Status != PrintStatus.Success)
                        {
                            UserDialogs.Instance.Alert(result.Message);
                        }
                    });
                }
                else
                {
                    Activity.RunOnUiThread(() =>
                    {
                        UserDialogs.Instance.HideLoading();

                        if (result.Status != PrintStatus.Success)
                        {
                            UserDialogs.Instance.Alert(result.Message);
                        }
                    });
                }
            });
        }
コード例 #4
0
        /// <summary>
        /// Print
        /// </summary>
        /// <param name="adapterPosition">Adapter position.</param>
        void OnPrint(int adapterPosition)
        {
            var docket  = _dockets[adapterPosition];
            var profile = _repository.Profiles.First();
            var device  = _repository.MobileDevices.First();

            if (device.PrinterAddress == null)
            {
                var message = Resources.GetString(Resource.String.message_setup_printer);
                UserDialogs.Instance.Alert(message);
                return;
            }

            var address = device.PrinterAddress;

            var title = Resources.GetString(Resource.String.message_printing);

            UserDialogs.Instance.ShowLoading(title);

            var lendingStatus = _repository.LendingStatus
                                .Where(x => x.CustomerAccountNumber == docket.CustomerAccountNumber)
                                .ToList();

            var signaturePath = docket.SignaturePath;

            var docketItems = _repository.DeliveryDocketItems
                              .Where(x => x.HasValue && x.DeliveryDocketID == docket.DocketID)
                              .OrderBy(x => x.Description).ToList();

            var label = LabelTemplates.GetDocketLabel(docket, docketItems, lendingStatus);

            Task.Run(() =>
            {
                var result = PrinterUtils.Print(label, address, signaturePath);

                Activity.RunOnUiThread(() =>
                {
                    UserDialogs.Instance.HideLoading();

                    if (result.Status != PrintStatus.Success)
                    {
                        UserDialogs.Instance.Alert(result.Message);
                    }
                });
            });
        }
コード例 #5
0
        /// <summary>
        /// Print docket
        /// </summary>
        bool PrintDocket()
        {
            Activity.RunOnUiThread(ShowPrintingMessage);

            using (var repository = new Repository())
            {
                // check we have a printer set up
                var device = repository.MobileDevices.First();
                var docket = repository.DeliveryDockets.Find(_docketId);

                // get lending status
                var lendingStatus = repository.LendingStatus
                                    .Where(x => x.CustomerAccountNumber == docket.CustomerAccountNumber)
                                    .ToList();

                // get label
                var docketItems = repository.DeliveryDocketItems
                                  .Where(x => x.HasValue && x.DeliveryDocketID == docket.DocketID)
                                  .OrderBy(x => x.Description).ToList();

                var label = LabelTemplates.GetDocketLabel(docket, docketItems, lendingStatus);

                // get the printer address
                var address = device.PrinterAddress;

                if (String.IsNullOrWhiteSpace(address))
                {
                    Activity.RunOnUiThread(UserDialogs.Instance.HideLoading);
                    return(false);
                }

                // print
                var result = PrinterUtils.Print(label, address, docket.SignaturePath);

                // hide loading
                Activity.RunOnUiThread(UserDialogs.Instance.HideLoading);

                return(result.Status == PrintStatus.Success);
            }
        }