Exemple #1
0
 public void PushContent(SubmitDocument doc)
 {
     _contents.Add(new DisplayContent
     {
         Document = doc
     });
     // 变化按钮文字
     RefreshButtonText();
 }
Exemple #2
0
        public void Refresh(List <ActionInfo> actions)
        {
            // 先刷新当前文档
            SubmitDocument current = this.MessageDocument as SubmitDocument;

            if (current != null)
            {
                current.Refresh(actions);
            }

            // 然后刷新正在排队的文档
            foreach (var content in _contents)
            {
                content.Document?.Refresh(actions);
            }
        }
Exemple #3
0
        static void MessageNotifyOverflow(List <ActionInfo> actions)
        {
            // 检查超额图书
            List <string> overflow_titles = new List <string>();
            int           i = 1;

            actions.ForEach(item =>
            {
                if (item.Action == "borrow" && item.SyncErrorCode == "overflow")
                {
                    var pii = GetPiiString(item.Entity);
                    overflow_titles.Add($"{i++}) {SubmitDocument.ShortTitle(item.Entity.Title)} [{pii}]");
                }
            });
            if (overflow_titles.Count > 0)
            {
                PageShelf.TrySetMessage(null, $"下列图书发生超额借阅:\r\n{StringUtil.MakePathList(overflow_titles, "\r\n")}");
            }
        }
Exemple #4
0
        public static SubmitDocument Build(List <ActionInfo> actions,
                                           double baseFontSize,
                                           string style)
        {
            SubmitDocument doc = new SubmitDocument();

            doc.BaseFontSize = baseFontSize;
            doc.BuildStyle   = style;

            // 保存起来
            doc._actions.Clear();
            doc._actions.AddRange(actions);

            bool display_transfer = StringUtil.IsInList("transfer", style);

            // 第一部分,总结信息
            List <string> names = new List <string>();
            {
                actions.ForEach((o) =>
                {
                    if (o.Operator != null)
                    {
                        names.Add(string.IsNullOrEmpty(o.Operator.PatronName) ? o.Operator.PatronBarcode : o.Operator.PatronName);
                    }
                });
                StringUtil.RemoveDupNoSort(ref names);
            }

            int return_count = actions.FindAll((o) => { return(o.Action == "return"); }).Count;
            int borrow_count = actions.FindAll((o) => { return(o.Action == "borrow"); }).Count;

            // 修改了 currentLocation 并且向内转移的数量
            int change_currentLocation_count = actions
                                               .FindAll((o) =>
            {
                return(o.Action.StartsWith("transfer") &&
                       string.IsNullOrEmpty(o.CurrentShelfNo) == false &&
                       o.TransferDirection == "in");
            })
                                               .Count;

            // 修改了 location 的数量。这个意味着发生了调拨
            int change_location_count = actions
                                        .FindAll(o => { return(o.Action.StartsWith("transfer") && string.IsNullOrEmpty(o.Location) == false); })
                                        .Count;

            // (工作人员)普通下架。特点是去向不明,但至少知道这些图书是离开书柜了
            int transferout_count = actions
                                    .FindAll(o => { return(o.Action.StartsWith("transfer") && o.TransferDirection == "out"); })
                                    .Count;

            // 总结一下涉及到的门
            var door_names = ShelfData.GetDoorName(actions);

            /*
             * int succeed_count = actions.FindAll((o) => { return o.ResultType == "succeed" || string.IsNullOrEmpty(o.ResultType); }).Count;
             * int error_count = items.FindAll((o) => { return o.ResultType == "error"; }).Count;
             * int warning_count = items.FindAll((o) => { return o.ResultType == "warning"; }).Count;
             * int information_count = 0;
             * if (display_transfer == false)
             *  information_count = items.FindAll((o) => { return o.ResultType == "information" && o.Operation != "transfer"; }).Count;
             * else
             *  information_count = items.FindAll((o) => { return o.ResultType == "information"; }).Count;
             *
             * // 检查超额图书
             * List<string> overflow_titles = new List<string>();
             * items.ForEach(item =>
             * {
             *  if (item.Operation == "borrow" && item.ErrorCode == "overflow")
             *      overflow_titles.Add($"{ShortTitle(item.Entity.Title)} [{item.Entity.PII}]");
             * });
             */

            {
                var p = new Paragraph();
                p.FontFamily    = new FontFamily("微软雅黑");
                p.FontSize      = baseFontSize;
                p.TextAlignment = TextAlignment.Center;
                p.Foreground    = Brushes.Gray;
                // p.TextIndent = -20;
                p.Margin = new Thickness(0, 0, 0, baseFontSize /*18*/);
                doc.Blocks.Add(p);

                if (borrow_count
                    + return_count
                    + change_currentLocation_count
                    + change_location_count
                    + transferout_count > 0)
                {
                    List <string> lines = new List <string>();
                    if (return_count > 0)
                    {
                        lines.Add($"还书 {return_count}");
                    }
                    if (borrow_count > 0)
                    {
                        lines.Add($"借书 {borrow_count}");
                    }

REDO:
                    if (display_transfer && change_currentLocation_count > 0)
                    {
                        lines.Add($"上架 {change_currentLocation_count}");
                    }
                    if (display_transfer && change_location_count > 0)
                    {
                        lines.Add($"调拨 {change_location_count}");
                    }
                    if (display_transfer && transferout_count > 0)
                    {
                        lines.Add($"下架 {transferout_count}");
                    }

                    if (lines.Count == 0 && display_transfer == false)
                    {
                        display_transfer = true;

                        // 修正 style,便于 Refresh() 时候使用新的 style
                        StringUtil.SetInList(ref style, "transfer", true);
                        doc.BuildStyle = style;
                        goto REDO;
                    }

                    p.Inlines.Add(new Run
                    {
                        Text = $"{StringUtil.MakePathList(names)}",
                        //Background = Brushes.DarkRed,
                        //Foreground = Brushes.White
                        FontFamily = new FontFamily("楷体"),
                        FontSize   = baseFontSize * 5.5, // 3.5,
                        // FontWeight = FontWeights.Bold,
                        Foreground = Brushes.White,
                    });

                    if (door_names.Count > 0)
                    {
                        p.Inlines.Add(new Run
                        {
                            Text = $"\r\n({StringUtil.MakePathList(door_names)})",
                            //Background = Brushes.DarkRed,
                            Foreground = Brushes.Green,
                            // FontFamily = new FontFamily("楷体"),
                            FontSize = baseFontSize * 2.0,    // 1.0
                            // FontWeight = FontWeights.Bold,
                        });
                    }

                    p.Inlines.Add(new Run
                    {
                        Text = $"\r\n{StringUtil.MakePathList(lines, ", ")}\r\n",
                        //Background = Brushes.DarkRed,
                        //Foreground = Brushes.White
                        FontSize   = baseFontSize * 3.0, // * 1.2,
                        Foreground = Brushes.White,
                    });

                    App.CurrentApp.SpeakSequence(StringUtil.MakePathList(lines, ", "));
                }

#if NO
                if (error_count > 0)
                {
                    p.Inlines.Add(new Run
                    {
                        Text       = $" 错误 {error_count} ",
                        Background = Brushes.DarkRed,
                        Foreground = Brushes.White
                    });
                }
                if (warning_count > 0)
                {
                    p.Inlines.Add(new Run
                    {
                        Text       = $" 警告 {warning_count} ",
                        Background = Brushes.DarkGoldenrod,
                        Foreground = Brushes.White
                    });
                }
                if (information_count > 0)
                {
                    p.Inlines.Add(new Run
                    {
                        Text       = $" 信息 {information_count} ",
                        Background = Brushes.Gray,
                        Foreground = Brushes.White
                    });
                }
                if (succeed_count > 0)
                {
                    p.Inlines.Add(new Run
                    {
                        Text       = $" 成功 {succeed_count} ",
                        Background = Brushes.DarkGreen,
                        Foreground = Brushes.White
                    });
                }
#endif
            }

#if NO
            // 第二部分,列出超额的信息
            if (overflow_titles.Count > 0)
            {
                var p = BuildOverflowParagraph(overflow_titles);
                doc.Blocks.Add(p);
            }
#endif
            // 检查超额图书
            List <string> overflow_titles = new List <string>();
            actions.ForEach(item =>
            {
                if (item.Action == "borrow" && item.SyncErrorCode == "overflow")
                {
                    overflow_titles.Add($"{ShortTitle(item.Entity.Title)} [{ShelfData.GetPiiString(item.Entity)}]");
                }
            });

            // 显示超额的信息
            if (overflow_titles.Count > 0)
            {
                var p = doc.BuildOverflowParagraph(overflow_titles);
                // p.Tag = "#overflow";
                doc.Blocks.Add(p);

                // 语音提醒
                App.CurrentApp.SpeakSequence("警告:借书超额");
            }
            else
            {
                // 超额信息的占位符
                var p = new Paragraph();
                p.FontSize = 0.1;
                p.Margin   = new Thickness();
                p.Padding  = new Thickness();
                p.Tag      = OVERFLOW_ID; // "#overflow";
                doc.Blocks.Add(p);
            }

            // 第三部分,列出每一笔操作
            int index = 0;
            foreach (var action in actions)
            {
                var p = BuildParagraph(action, index, baseFontSize, style);
                if (p != null)
                {
                    doc.Blocks.Add(p);
                    index++;
                }
            }

#if NO
            // 构造提示语音
            List <string> speaks = new List <string>();
            if (overflow_titles.Count > 0)
            {
                speaks.Add($"警告:有 {overflow_titles.Count} 册图书超越许可册数,请放回书柜,谢谢");
            }

            if (speaks.Count == 0)
            {
                speaks.Add("操作完成"); // TODO:可否增加姓名和借还册数?例如 王立文借书 5 册成功
            }
            speak = StringUtil.MakePathList(speaks, "; ");
#endif

            return(doc);
        }