Beispiel #1
0
        public string GetLocationHtml(string locationXml, string currentLocation)
        {
            string html = "";

            if (String.IsNullOrEmpty(locationXml) == false)
            {
                string location = "";
                // 解析本帐户拥有的全部馆藏地
                List <SubLib> subLibs = SubLib.ParseSubLib(locationXml, true);
                foreach (SubLib subLib in subLibs)
                {
                    foreach (Location loc in subLib.Locations)
                    {
                        string locPath = "";
                        if (string.IsNullOrEmpty(subLib.libCode) == true)
                        {
                            locPath = loc.Name;
                        }
                        else
                        {
                            locPath = subLib.libCode + "/" + loc.Name;
                        }

                        if (location != "")
                        {
                            location += ",";
                        }

                        location += locPath;
                    }
                }

                string[] list = location.Split(new char[] { ',' });
                foreach (string one in list)
                {
                    string temp   = one;
                    int    nIndex = one.IndexOf("}");
                    if (nIndex != -1)
                    {
                        temp = one.Substring(nIndex + 1).Trim();
                    }

                    string sel = "";
                    if (currentLocation == temp)
                    {
                        sel = " selected ";
                    }
                    html += "<option value='" + one + "' " + sel + ">" + one + "</option>";
                }
            }
            html = "<select id='selLocation' name='selLocation' class='selArrowRight'>"
                   + "<option value=''>请选择</option>"
                   + html
                   + "</select>";

            return(html);
        }
Beispiel #2
0
        public ActionResult CtrlDemo()
        {
            //List<string> libList = new List<string>();
            //libList.Add("分馆一");
            //libList.Add("分馆二");
            //libList.Add("分馆三");
            //ViewBag.libList = libList;

            string xml = @"<item canborrow='no' itemBarcodeNullable='yes'>保存本库</item><item canborrow='no' itemBarcodeNullable='yes'>阅览室</item><item canborrow='yes' itemBarcodeNullable='yes'>流通库</item>
<library code='方洲小学'><item canborrow='yes' itemBarcodeNullable='yes'>图书总库</item></library>
<library code='星洲小学'><item canborrow='yes' itemBarcodeNullable='yes'>阅览室</item>
</library>";

            List <SubLib> subLibs = SubLib.ParseSubLib(xml, true);

            ViewBag.libList  = subLibs;
            ViewBag.bindLink = "<a href='www.dp2003.com'>尚未绑定帐户</a>";
            return(View());
        }
Beispiel #3
0
        public ActionResult Setting(string code, string state, string returnUrl)
        {
            string strError = "";
            int    nRet     = 0;

            // 检查当前是否已经选择了图书馆绑定了帐号
            WxUserItem activeUser = null;

            nRet = this.GetActive(code, state,
                                  out activeUser,
                                  out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
            if (nRet == 0)
            {
                ViewBag.RedirectInfo = dp2WeiXinService.GetSelLibLink(state, "/Patron/Setting");
                return(View());
            }



            string weixinId = ViewBag.weixinId; //(string)Session[WeiXinConst.C_Session_WeiXinId];

            ViewBag.returnUrl = returnUrl;


            string photoChecked = "";

            if (ViewBag.showPhoto == 1)
            {
                photoChecked = " checked='checked' ";
            }
            ViewBag.photoChecked = photoChecked;

            string coverChecked = "";

            if (ViewBag.showCover == 1)
            {
                coverChecked = " checked='checked' ";
            }
            ViewBag.coverChecked = coverChecked;

            // 检查是否绑定工作人员,决定界面上是否出现 打开监控功能
            ViewBag.info = "监控本馆消息";
            string tracingChecked = "";
            string maskChecked    = "";

            if (activeUser == null)
            {
                strError = "当前活动帐号不存在";
                goto ERROR1;
            }
            if (activeUser.type == WxUserDatabase.C_Type_Worker && activeUser.userName != "public")
            {
                ViewBag.workerId = activeUser.id;
                if (activeUser.tracing == "on" || activeUser.tracing == "on -mask")
                {
                    tracingChecked = " checked='checked' ";
                    maskChecked    = " checked='checked' ";
                    if (activeUser.tracing == "on -mask")
                    {
                        maskChecked = " ";
                    }
                }
            }
            ViewBag.tracingChecked = tracingChecked;
            ViewBag.maskChecked    = maskChecked;
            if (ViewBag.LibName == "[" + WeiXinConst.C_Dp2003LibName + "]")
            {
                ViewBag.info = "监控所有图书馆的消息";
            }



            ViewBag.subLibGray = "";
            // 未绑定帐户 ,todo 普通读者一样可选择关注馆藏地
            if (activeUser == null ||
                activeUser.userName == "public")
            //|| (activeUser.type==WxUserDatabase.C_Type_Worker && activeUser.userName=="public")
            //|| (activeUser.type==WxUserDatabase.C_Type_Patron && activeUser.rights.Contains("borrow") == false && activeUser.rights.Contains("return") == false))
            {
                //string bindUrl = "/Account/Bind?returnUrl=" + HttpUtility.UrlEncode(returnUrl);
                //string bindLink = "<a href='javascript:void(0)' onclick='gotoUrl(\"" + bindUrl + "\")'>尚未绑定帐户</a>。";
                //ViewBag.bindLink = bindLink;

                ViewBag.subLibGray = "color:#cccccc";
                return(View());
            }

            string accountInfo = "";

            if (activeUser.type == WxUserDatabase.C_Type_Worker)
            {
                accountInfo = "帐号:" + activeUser.userName;
            }
            else
            {
                accountInfo = "读者:" + activeUser.readerBarcode;
            }
            if (accountInfo != "")
            {
                accountInfo = "(" + accountInfo + ")";
            }
            ViewBag.accountInfo = accountInfo;
            ViewBag.userId      = activeUser.id;

            string locationXml = activeUser.location;

            if (String.IsNullOrEmpty(activeUser.location) == true &&
                activeUser.userName != "public")
            {
                // 从dp2服务器获取
                nRet = dp2WeiXinService.Instance.GetLocation(ViewBag.LibId,
                                                             activeUser,
                                                             out locationXml,
                                                             out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }


                //保存到微信用户库
                activeUser.location = locationXml;
                WxUserDatabase.Current.Update(activeUser);
            }


            // 解析本帐户拥有的全部馆藏地
            List <SubLib> subLibs = SubLib.ParseSubLib(locationXml, true);

            //上次选中的打上勾
            if (String.IsNullOrEmpty(activeUser.selLocation) == false)
            {
                string selLocation = SubLib.ParseToSplitByComma(activeUser.selLocation);
                if (selLocation != "")
                {
                    string[] selLocList = selLocation.Split(new char[] { ',' });
                    foreach (SubLib subLib in subLibs)
                    {
                        foreach (Location loc in subLib.Locations)
                        {
                            string locPath = subLib.libCode + "/" + loc.Name;
                            if (selLocList.Contains(locPath) == true)
                            {
                                subLib.Checked = "checked";
                                loc.Checked    = "checked";
                            }
                        }
                    }
                }
                // end
            }

            // todo 其实,可以用一个字段来表示馆藏地和选中的项,就量在xml的字段中加checked属性,
            // 但如果服务器更新了,刷的时候就全部覆盖了。
            // 现在还没做到服务器更新后,自动刷过来


            ViewBag.libList = subLibs;


            ViewBag.verifyBarcode = "";
            if (activeUser != null && activeUser.verifyBarcode == 1)
            {
                ViewBag.verifyBarcode = "checked";
            }

            ViewBag.audioType = 1;
            if (activeUser != null && activeUser.audioType > 0)
            {
                ViewBag.audioType = activeUser.audioType;
            }

            return(View());

ERROR1:
            ViewBag.Error = strError;
            return(View());
        }