コード例 #1
0
ファイル: Person.ascx.cs プロジェクト: SparkDevNetwork/Rock
        /// <summary>
        /// Handles sending the selected labels off to the selected printer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void mdReprintLabels_PrintClick(object sender, EventArgs e)
        {
            var personId = hfPersonId.ValueAsInt();

            if (personId == 0)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(cblLabels.SelectedValue))
            {
                nbReprintLabelMessages.Visible = true;
                nbReprintLabelMessages.Text    = "Please select at least one label.";
                return;
            }

            if (ddlPrinter.SelectedValue == null || ddlPrinter.SelectedValue == None.IdValue)
            {
                nbReprintLabelMessages.Visible = true;
                nbReprintLabelMessages.Text    = "Please select a printer.";
                return;
            }

            // Get the person Id from the Guid
            var selectedAttendanceIds = hfCurrentAttendanceIds.Value.SplitDelimitedValues().AsIntegerList();

            var fileGuids = cblLabels.SelectedValues.AsGuidList();

            var reprintLabelOptions = new ReprintLabelOptions
            {
                PrintFrom = PrintFrom.Server,
                ServerPrinterIPAddress = ddlPrinter.SelectedValue
            };

            // Now, finally, re-print the labels.
            List <string> messages = ZebraPrint.ReprintZebraLabels(fileGuids, personId, selectedAttendanceIds, nbReprintMessage, this.Request, reprintLabelOptions);

            nbReprintMessage.Visible = true;
            nbReprintMessage.Text    = messages.JoinStrings("<br>");

            mdReprintLabels.Hide();
        }
コード例 #2
0
        /// <summary>
        /// Handles sending the selected labels off to the selected printer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void mdReprintLabels_PrintClick(object sender, EventArgs e)
        {
            var personId = hfPersonId.ValueAsInt();

            if (personId == 0)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(cblLabels.SelectedValue))
            {
                nbReprintLabelMessages.Visible = true;
                nbReprintLabelMessages.Text    = "Please select at least one label.";
                return;
            }

            var selectedPrinterGuid = ddlPrinter.SelectedValue.AsGuidOrNull();

            if (!selectedPrinterGuid.HasValue)
            {
                nbReprintLabelMessages.Visible = true;
                nbReprintLabelMessages.Text    = "Please select a printer.";
                return;
            }

            var selectedAttendanceIds = hfCurrentAttendanceIds.Value.SplitDelimitedValues().AsIntegerList();

            var fileGuids = cblLabels.SelectedValues.AsGuidList();

            ReprintLabelOptions reprintLabelOptions;

            string selectedPrinterIPAddress;

            if (selectedPrinterGuid == Guid.Empty)
            {
                reprintLabelOptions = new ReprintLabelOptions
                {
                    PrintFrom = PrintFrom.Client
                };
            }
            else
            {
                selectedPrinterIPAddress = new DeviceService(new RockContext()).GetSelect(selectedPrinterGuid.Value, s => s.IPAddress);

                reprintLabelOptions = new ReprintLabelOptions
                {
                    PrintFrom = PrintFrom.Server,
                    ServerPrinterIPAddress = selectedPrinterIPAddress
                };
            }

            CheckinManagerHelper.SaveSelectedLabelPrinterToCookie(selectedPrinterGuid);

            // Now, finally, re-print the labels.
            List <string> messages = ZebraPrint.ReprintZebraLabels(fileGuids, personId, selectedAttendanceIds, nbReprintMessage, this.Request, reprintLabelOptions);

            nbReprintMessage.Visible = true;
            nbReprintMessage.Text    = messages.JoinStrings("<br>");

            mdReprintLabels.Hide();
        }