Exemple #1
0
        // 专业借还流程
        // operationType 操作类型
        public ActionResult Circulate(string code, string state)
        {
            string strError = "";
            int    nRet     = 0;

            // 获取当前sessionInfo,里面有选择的图书馆和帐号等信息
            // -1 出错
            // 0 成功
            nRet = this.GetSessionInfo(code, state,
                                       out SessionInfo sessionInfo,
                                       out strError);
            if (nRet == -1)
            {
                ViewBag.Error = strError;
                return(View());
            }

            // 当前帐号不存在,尚未选择图书馆
            if (sessionInfo.ActiveUser == null)
            {
                ViewBag.RedirectInfo = dp2WeiXinService.GetSelLibLink(state, "/Library/Circulate");
                return(View());
            }

            // public帐号不支持专业借还
            if (sessionInfo.ActiveUser.userName == WxUserDatabase.C_Public)
            {
                ViewBag.RedirectInfo = dp2WeiXinService.GetLinkHtml("专业借还", "/Library/Circulate", true);
                return(View());
            }

            // 是否校验条码
            ViewBag.verifyBarcode = sessionInfo.ActiveUser.verifyBarcode;
            ViewBag.audioType     = sessionInfo.ActiveUser.audioType;

            // 关注馆藏地,转成显示格式
            ViewBag.Location = SubLib.ParseToView(sessionInfo.ActiveUser.selLocation);

            // 需要有借还权限
            bool canBorrow = true;
            bool canReturn = true;

            if (sessionInfo.ActiveUser.rights.Contains("borrow") == false)
            {
                canBorrow = false;
            }
            if (sessionInfo.ActiveUser.rights.Contains("return") == false)
            {
                canReturn = false;
            }
            ViewBag.canBorrow = canBorrow;
            ViewBag.canReturn = canReturn;
            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            ViewBag.version = version.ToString();
            return(View(sessionInfo.ActiveUser));
        }
Exemple #2
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);
        }
Exemple #3
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());
        }
Exemple #4
0
        // 借还窗
        public ActionResult Charge2(string code, string state)
        {
            string strError = "";
            int    nRet     = 0;

            // 获取当前sessionInfo,里面有选择的图书馆和帐号等信息
            // -1 出错
            // 0 成功
            nRet = this.GetSessionInfo(code, state,
                                       out SessionInfo sessionInfo,
                                       out strError);
            if (nRet == -1)
            {
                ViewBag.Error = strError;
                return(View());
            }

            // 当前帐号不存在,尚未选择图书馆
            if (sessionInfo.ActiveUser == null)
            {
                ViewBag.RedirectInfo = dp2WeiXinService.GetSelLibLink(state, "/Library/Charge2");
                return(View());
            }

            bool canBorrow = true;
            bool canReturn = true;

            if (sessionInfo.ActiveUser.userName == WxUserDatabase.C_Public)
            {
                canBorrow            = false;
                canReturn            = false;
                ViewBag.RedirectInfo = dp2WeiXinService.GetLinkHtml("借还窗", "/Library/Charge2", true);
                return(View());
            }
            if (sessionInfo.ActiveUser.type == WxUserDatabase.C_Type_Worker)
            {
                if (sessionInfo.ActiveUser.rights.Contains("borrow") == false)
                {
                    canBorrow = false;
                }
                if (sessionInfo.ActiveUser.rights.Contains("return") == false)
                {
                    canReturn = false;
                }
            }
            else
            {
                //读者如果有权限可以借还,但都不可以还书。
                if (sessionInfo.ActiveUser.rights.Contains("return") == false)
                {
                    canReturn = false;
                }

                ViewBag.patronBarcode = sessionInfo.ActiveUser.readerBarcode;
            }

            if (canBorrow == false)
            {
                ViewBag.canBorrow = "disabled";
            }
            if (canReturn == false)
            {
                ViewBag.canReturn = "disabled";
            }

            //设到ViewBag里
            string userName = "";

            if (sessionInfo.ActiveUser.type == WxUserDatabase.C_Type_Worker)
            {
                userName         = sessionInfo.ActiveUser.userName;
                ViewBag.isPatron = 0;
            }
            else
            {
                userName         = sessionInfo.ActiveUser.readerBarcode;
                ViewBag.isPatron = 1;
            }

            ViewBag.userName      = userName;
            ViewBag.userId        = sessionInfo.ActiveUser.id;
            ViewBag.Location      = SubLib.ParseToView(sessionInfo.ActiveUser.selLocation);
            ViewBag.verifyBarcode = sessionInfo.ActiveUser.verifyBarcode;
            ViewBag.audioType     = sessionInfo.ActiveUser.audioType;
            return(View(sessionInfo.ActiveUser));
        }
Exemple #5
0
	public Subtitles (SubLib.Core.Domain.Subtitles subtitles) : base(subtitles.Collection, subtitles.Properties) {
		LoadModelFromCollection();
	}
Exemple #6
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());
        }
	private void GetStyleMarkup (SubLib.Core.Domain.Style subtitleStyle, ref string prefix, ref string suffix) {
		if (subtitleStyle.Italic) {
			prefix += "<i>";
			suffix = "</i>" + suffix;
		}

		if (subtitleStyle.Bold) {
			prefix += "<b>";
			suffix = "</b>" + suffix;
		}

		if (subtitleStyle.Underline) {
			prefix += "<u>";
			suffix = "</u>" + suffix;
		}
	}
Exemple #8
0
	private bool SaveFile (SubLib.Core.Domain.Subtitles subtitles, FileProperties properties, SubtitleTextType textType) {
		try {
			SubtitleSaver saver = new SubtitleSaver();
			saver.Save(subtitles, properties, textType);
			return true;
		}
		catch (Exception e) {
			Console.Error.WriteLine("Caught exception saving backup file: " + e);
			return false;
		}
	}
	private void RenderTextCell (CellRendererText renderer, TreeIter iter, SubtitleText subtitleText, SubLib.Core.Domain.Style subtitleStyle) {

		/* If there's no text, return empty text without line count */
		if (subtitleText.IsEmpty) {
			renderer.Text = String.Empty;
			return;
		}

		string textMarkup = String.Empty;
		string stylePrefix = String.Empty;
		string styleSuffix = String.Empty;
		GetStyleMarkup(subtitleStyle, ref stylePrefix, ref styleSuffix);

		bool first = true;
		bool viewLineLengths = Base.Config.PrefsViewLineLengths;
		foreach (string line in subtitleText) {
			textMarkup += (first ? String.Empty : "\n") + stylePrefix + GLib.Markup.EscapeText(line) + styleSuffix + (viewLineLengths ? " <span size=\"small\"><sup>(" + line.Length + ")</sup></span>" : String.Empty);
			if (first)
				first = false;
		}

		renderer.Markup = textMarkup;
	}
    /// <summary>Sets font with bold and italic if applicable.</summary>
    private void SetFont (SubLib.Core.Domain.Style style) {
    	Pango.FontDescription font = Pango.FontDescription.FromString(this.textFont + (style.Bold ? " bold" : String.Empty) + (style.Italic ? " italic" : String.Empty) + " " + this.textFontSize);
		this.textView.ModifyFont(font);
    }
Exemple #11
0
        // 内务
        public ActionResult Charge2(string code, string state)
        {
            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, "/Library/Charge2");
                return(View());
            }

            //绑定的工作人员账号 需要有权限
            string weixinId = ViewBag.weixinId;//(string)Session[WeiXinConst.C_Session_WeiXinId];
            string libId    = ViewBag.LibId;

            bool canBorrow = true;
            bool canReturn = true;


            if (activeUser == null)
            {
                strError = "当前活动帐户不存在";
                goto ERROR1;
            }

            //WxUserItem user = sessionInfo.Active;// WxUserDatabase.Current.GetWorker(weixinId, ViewBag.LibId);
            // 未绑定
            if (activeUser == null || activeUser.userName == "public")
            {
                canBorrow            = false;
                canReturn            = false;
                ViewBag.RedirectInfo = dp2WeiXinService.GetLinkHtml("借还窗", "/Library/Charge2", true);
                return(View());
            }
            if (activeUser.type == WxUserDatabase.C_Type_Worker)
            {
                if (activeUser.rights.Contains("borrow") == false)
                {
                    canBorrow = false;
                }
                if (activeUser.rights.Contains("return") == false)
                {
                    canReturn = false;
                }
            }
            else
            {
                //读者如果有权限可以借还,但都不可以还书。
                if (activeUser.rights.Contains("return") == false)
                {
                    canReturn = false;
                }

                ViewBag.patronBarcode = activeUser.readerBarcode;
            }



            if (canBorrow == false)
            {
                ViewBag.canBorrow = "disabled";
            }
            if (canReturn == false)
            {
                ViewBag.canReturn = "disabled";
            }

            LibEntity lib = dp2WeiXinService.Instance.GetLibById(libId);

            if (lib == null)
            {
                strError = "未找到id为" + libId + "的图书馆";
                goto ERROR1;
            }
            // 是否校验条码
            //ViewBag.verifyBarcode = lib.verifyBarcode;

            //设到ViewBag里
            string userName = "";

            if (activeUser.type == WxUserDatabase.C_Type_Worker)
            {
                userName         = activeUser.userName;
                ViewBag.isPatron = 0;
            }
            else
            {
                userName         = activeUser.readerBarcode;
                ViewBag.isPatron = 1;
            }

            ViewBag.userName = userName;
            ViewBag.userId   = activeUser.id;

            // 关注馆藏去掉前面
            //string clearLocs = "";
            //if (string.IsNullOrEmpty(user.selLocation) == false)
            //{
            //    string[] selLoc = user.selLocation.Split(new char[] { ',' });
            //    foreach (string loc in selLoc)
            //    {
            //        string tempLoc = "";
            //        int nIndex = loc.IndexOf('/');
            //        if (nIndex > 0)
            //            tempLoc = loc.Substring(nIndex+1);

            //        if (clearLocs != "")
            //            clearLocs += ",";

            //        clearLocs += tempLoc;
            //    }
            //}
            ViewBag.Location = SubLib.ParseToView(activeUser.selLocation);

            ViewBag.verifyBarcode = activeUser.verifyBarcode;
            ViewBag.audioType     = activeUser.audioType;
            return(View(activeUser));


ERROR1:
            ViewBag.Error = strError;
            return(View());
        }
Exemple #12
0
        // 专业借还流程
        // operationType 操作类型
        public ActionResult Circulate(string code, string state)
        {
            string     strError   = "";
            int        nRet       = 0;
            WxUserItem activeUser = null;

            try
            {
                // 检查当前是否已经选择了图书馆绑定了帐号

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

                // 得到该微信用户绑定的账号
                if (activeUser == null || activeUser.userName == "public")
                {
                    ViewBag.RedirectInfo = dp2WeiXinService.GetLinkHtml("专业借还", "/Library/Circulate", true);
                    return(View());
                }


                //===

                // 是否校验条码
                ViewBag.verifyBarcode = activeUser.verifyBarcode;
                ViewBag.audioType     = activeUser.audioType;

                // 关注馆藏地,转成显示格式
                ViewBag.Location = SubLib.ParseToView(activeUser.selLocation);


                //===
                // 需要有权限
                bool canBorrow = true;
                bool canReturn = true;
                // 如果没有借还权限,不能操作
                if (activeUser != null)
                {
                    if (activeUser.rights.Contains("borrow") == false)
                    {
                        canBorrow = false;
                    }
                    if (activeUser.rights.Contains("return") == false)
                    {
                        canReturn = false;
                    }
                }

                // 放到ViewBag里,传到页面
                ViewBag.canBorrow = canBorrow;
                ViewBag.canReturn = canReturn;

                //// 没有权限时出现提示
                //if (canBorrow == false && operationType == C_ope_borrow)
                //{
                //    strError = "当前帐户"+userName+"没有借书权限";
                //    goto ERROR1;
                //}
                //if (canReturn == false && operationType == C_ope_return)
                //{
                //    strError = "当前帐户" + userName + "没有还书权限";
                //    goto ERROR1;
                //}

                //// 操作类型与输入框类型
                //ViewBag.operation = operationType;
                //if (operationType== C_ope_borrow)
                //    ViewBag.inputType = "1"; //1表示读者证条码,2表示册条码

                string  a       = "test";
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
                ViewBag.version = version.ToString();
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                goto ERROR1;
            }

            return(View(activeUser));

ERROR1:
            ViewBag.Error = strError;
            return(View());
        }
Exemple #13
0
	private void AddExtraSubtitles (SubLib.Core.Domain.Subtitles translation) {
		int extraCount = translation.Collection.Count - subtitles.Collection.Count;
		if (extraCount > 0)
			subtitles.AddExtra(extraCount);
	}