Example #1
0
    public void SpawnShelves()
    {
        shelfObjects = new GameObject[shelfDatas.Length];
        for (int i = 0; i < shelfDatas.Length; i++)
        {
            ShelfData  data = shelfDatas[i];
            GameObject newShelf;

            if (data.GetType() == typeof(EyeShelfData))
            {
                newShelf = Instantiate(eyeShelfPrefab, shelfParent);

                EyePartSpawner eyes = newShelf.GetComponentInChildren <EyePartSpawner>();
                eyes.eyeParts = ((EyeShelfData)data).eyeWhites;
            }
            else
            {
                //Works the shelves with all their needed data and setting them active
                newShelf = Instantiate(shelfPrefab, shelfParent);
            }

            newShelf.GetComponent <CustomizeShelf>().SetData(data, avatarCreator);
            newShelf.SetActive(i == 0);
            shelfObjects[i] = newShelf;



            //Instantiate new buttons where they need to be with the right data
            GameObject newButton = Instantiate(buttonPrefab, buttonParent);
            newButton.GetComponent <CustomizeTab>().setData(data, this, i);
        }
    }
Example #2
0
 public void setData(ShelfData data, ShelfManager shelfMan, int idx)
 {
     buttonText.text = data.shelfName;
     shelfManager    = shelfMan;
     buttonNumber    = idx;
     gameObject.name = data.shelfName + "Tab";
 }
Example #3
0
    public void SetData(ShelfData shelfData, AvatarCreator avatar)
    {
        //Name of the shelf being set
        gameObject.name = shelfData.shelfName + "Shelf";

        //Colour data
        colourPicker.colourList    = shelfData.colourList;
        colourPicker.bodyPartType  = shelfData.bodyPartType;
        colourPicker.avatarCreator = avatar;

        //Set up part-spawner
        bodyPartSpawner.avatarCreator = avatar;
        bodyPartSpawner.bodyPartType  = shelfData.bodyPartType;
        bodyPartSpawner.parts         = shelfData.sprites;

        //Set up grid
        grid.cellSize        = shelfData.gridSize;
        grid.constraintCount = shelfData.gridRows;
        grid.spacing         = shelfData.gridSpacing;
    }
Example #4
0
        /*
         * <root>
         * <operation>setSystemParameter</operation>
         * <category>circulation</category>
         * <name>rightsTable</name>
         * <value>...</value>
         * <libraryCodeList>
         * </libraryCodeList>
         * <operator>supervisor</operator>
         * <operTime>Fri, 28 Aug 2020 12:02:28 +0800</operTime>
         * <clientAddress via="net.pipe://localhost/dp2library/xe">localhost</clientAddress>
         * <version>1.08</version>
         * </root>
         * */
        static NormalResult TraceSetSystemParameter(
            XmlDocument domLog,
            ProcessInfo info)
        {
            try
            {
                string strCategory = DomUtil.GetElementText(domLog.DocumentElement, "category");
                string strName     = DomUtil.GetElementText(domLog.DocumentElement, "name");

                if (strCategory == "circulation" && strName == "rightsTable")
                {
                    // 获得读者借阅权限定义
                    var result = ShelfData.GetRightsTableFromServer();
                    if (result.Value == -1)
                    {
                        WpfClientInfo.WriteErrorLog($"同步获取读者借阅权限定义时出错: {result.ErrorInfo}");
                        // TODO: 延时后尝试重新获取?
                    }
                    else
                    {
                        string strOperTime = DomUtil.GetElementText(domLog.DocumentElement, "operTime");
                        // DateTime operTime = DateTimeUtil.FromRfc1123DateTimeString(strOperTime);

                        WpfClientInfo.WriteInfoLog($"更新读者权限定义。操作日志创建时间 {strOperTime}");
                    }
                }

                return(new NormalResult());
            }
            catch (Exception ex)
            {
                return(new NormalResult
                {
                    Value = -1,
                    ErrorInfo = $"TraceSetSystemParameter() 出现异常: {ex.Message}"
                });
            }
        }
Example #5
0
        // Borrow() API 恢复动作

        /*
         * <root>
         * <operation>borrow</operation> 操作类型
         * <readerBarcode>R0000002</readerBarcode> 读者证条码号
         * <itemBarcode>0000001</itemBarcode>  册条码号
         * <borrowDate>Fri, 08 Dec 2006 04:17:31 GMT</borrowDate> 借阅日期
         * <borrowPeriod>30day</borrowPeriod> 借阅期限
         * <no>0</no> 续借次数。0为首次普通借阅,1开始为续借
         * <operator>test</operator> 操作者
         * <operTime>Fri, 08 Dec 2006 04:17:31 GMT</operTime> 操作时间
         * <confirmItemRecPath>...</confirmItemRecPath> 辅助判断用的册记录路径
         *
         * <readerRecord recPath='...'>...</readerRecord>	最新读者记录
         * <itemRecord recPath='...'>...</itemRecord>	最新册记录
         * </root>
         * */
        // Return() API 恢复动作

        /*
         * <root>
         * <operation>return</operation> 操作类型
         * <action>return</action> 动作。有 return/lost/inventory/read/boxing 几种。恢复动作目前仅恢复 return 和 lost 两种,其余会忽略
         * <itemBarcode>0000001</itemBarcode> 册条码号
         * <readerBarcode>R0000002</readerBarcode> 读者证条码号
         * <operator>test</operator> 操作者
         * <operTime>Fri, 08 Dec 2006 04:17:45 GMT</operTime> 操作时间
         * <overdues>...</overdues> 超期信息 通常内容为一个字符串,为一个<overdue>元素XML文本片断
         *
         * <confirmItemRecPath>...</confirmItemRecPath> 辅助判断用的册记录路径
         *
         * <readerRecord recPath='...'>...</readerRecord>	最新读者记录
         * <itemRecord recPath='...'>...</itemRecord>	最新册记录
         *
         * </root>
         *
         * */
        static async Task <NormalResult> TraceBorrowOrReturn(
            XmlDocument domLog,
            ProcessInfo info)
        {
            try
            {
                string strOperation = DomUtil.GetElementText(domLog.DocumentElement, "operation");

                string strAction = DomUtil.GetElementText(domLog.DocumentElement, "action");

                string strReaderBarcode = DomUtil.GetElementText(domLog.DocumentElement,
                                                                 "readerBarcode");
                if (String.IsNullOrEmpty(strReaderBarcode) == true)
                {
                    return(new NormalResult
                    {
                        Value = -1,
                        ErrorInfo = "<readerBarcode>元素值为空"
                    });
                }

                string strOperTime = DomUtil.GetElementText(domLog.DocumentElement, "operTime");
                var    operTime    = DateTimeUtil.FromRfc1123DateTimeString(strOperTime);

                // 检查缓存的读者记录的最后更新时间
                var patron = LibraryChannelUtil.GetPatronItem(strReaderBarcode);
                if (patron == null || patron.LastWriteTime < operTime)
                {
                    DateTime now        = DateTime.Now;
                    var      get_result = GetReaderInfo(strReaderBarcode);
                    if (get_result.Value == 1)
                    {
                        UpdateLocalPatronRecord(get_result, now);
                    }
                }

                // 别处的还书动作兑现到 dp2ssl 本地动作库
                if (strOperation == "return" && strAction == "return")
                {
                    string borrowID = DomUtil.GetElementText(domLog.DocumentElement, "borrowID");
                    if (string.IsNullOrEmpty(borrowID) == false)
                    {
                        await ShelfData.ChangeDatabaseBorrowStateAsync(borrowID);
                    }
                }

                return(new NormalResult());
            }
            catch (Exception ex)
            {
                return(new NormalResult
                {
                    Value = -1,
                    ErrorInfo = $"TraceBorrowOrReturn() 出现异常: {ex.Message}"
                });
            }

            /*
             * // 读入册记录
             * string strConfirmItemRecPath = DomUtil.GetElementText(domLog.DocumentElement,
             *  "confirmItemRecPath");
             * string strItemBarcode = DomUtil.GetElementText(domLog.DocumentElement,
             *  "itemBarcode");
             * if (String.IsNullOrEmpty(strItemBarcode) == true)
             * {
             *  return new NormalResult
             *  {
             *      Value = -1,
             *      ErrorInfo = "<strItemBarcode>元素值为空"
             *  };
             * }
             *
             * string strBorrowDate = SQLiteUtil.GetLocalTime(DomUtil.GetElementText(domLog.DocumentElement,
             *  "borrowDate"));
             * string strBorrowPeriod = DomUtil.GetElementText(domLog.DocumentElement,
             *  "borrowPeriod");
             */
        }
Example #6
0
        static NormalResult Set(PatronItem patron,
                                Record record,
                                DateTime lastWriteTime)
        {
            XmlDocument dom = new XmlDocument();

            try
            {
                dom.LoadXml(record.RecordBody.Xml);
            }
            catch (Exception ex)
            {
                return(new NormalResult
                {
                    Value = -1,
                    ErrorInfo = $"读者记录装载进入 XMLDOM 时出错:{ex.Message}",
                    ErrorCode = "loadXmlError"
                });
            }

            // TODO: 如果 XML 记录尺寸太大,可以考虑删除一些无关紧要的元素以后进入 patron.Xml,避免溢出 SQLite 一条记录可以存储的最大尺寸

            string pii = DomUtil.GetElementText(dom.DocumentElement, "barcode");

            if (string.IsNullOrEmpty(pii))
            {
                pii = "@refID:" + DomUtil.GetElementText(dom.DocumentElement, "refID");
            }

            string cardNumber = DomUtil.GetElementText(dom.DocumentElement, "cardNumber");

            cardNumber = cardNumber.ToUpper();
            if (string.IsNullOrEmpty(cardNumber) == false)
            {
                cardNumber = "," + cardNumber + ",";
            }

            // 2020/7/17
            if (pii.StartsWith("@") == false)
            {
                string libraryCode = DomUtil.GetElementText(dom.DocumentElement, "libraryCode");
                var    ret         = ShelfData.GetOwnerInstitution(libraryCode + "/", out string isil, out string alternative);
                if (ret == true)
                {
                    // 应该是 xxx.xxx 形态
                    if (string.IsNullOrEmpty(isil) == false)
                    {
                        pii = isil + "." + pii;
                    }
                    else if (string.IsNullOrEmpty(alternative) == false)
                    {
                        pii = alternative + "." + pii;
                    }
                }
            }

            patron.PII           = pii;
            patron.RecPath       = record.Path;
            patron.Bindings      = cardNumber;
            patron.Xml           = record.RecordBody.Xml;
            patron.Timestamp     = record.RecordBody.Timestamp;
            patron.LastWriteTime = lastWriteTime;
            return(new NormalResult());
        }