Ejemplo n.º 1
0
        public void UpdateInfo(ChanState info)
        {
            Extension       = info.Extension;
            AgentID         = info.AgentID;
            LoginState      = info.LoginState;
            CallState       = info.CallState;
            RecordState     = info.RecordState;
            RecordReference = info.RecordReference;
            DirectionFlag   = info.DirectionFlag;
            CallerID        = info.CallerID;
            CalledID        = info.CalledID;
            StartRecordTime = info.StartRecordTime;
            StopRecordTime  = info.StopRecordTime;
            RecordLength    = info.RecordLength;

            StrLoginState      = LoginState.ToString();
            StrCallState       = CallState.ToString();
            StrRecordState     = RecordState.ToString();
            StrDirection       = DirectionFlag.ToString();
            StrStartRecordTime = StartRecordTime.ToString("yyyy-MM-dd HH:mm:ss");
            StrStopRecordTime  = StopRecordTime.ToString("yyyy-MM-dd HH:mm:ss");
            StrRecordLength    = RecordLength.ToString();

            Info = info;
        }
Ejemplo n.º 2
0
        public virtual ActionResult ChangePassword(PasswordChangeModel model)
        {
            //添加验证修改密码不能与原密码一致
            if (model.OldPassword == model.Password)
            {
                return(JsonTips("error", FStr.NewPassowrdMustNotEqualToOld));
            }

            var        IsLogin  = Request["IsLogin"];
            LoginState resState = AppManager.Instance.StateProvider.ChangePassword(model);

            if (LoginState.OK == resState)
            {
                //修改默认的初始密码跳转到登录页, 首页修改密码后跳转到桌面
                //if (IsLogin != null && IsLogin.ToUpper() == "TRUE")
                //    return JsonTipsLang("success", null, "Password_Change_Success", new { Url = Url.Action("Logout", "Account") });
                //return JsonTipsLang("success", null, "Password_Change_Success", new { Url = Url.Action("StartPage", "Home") });

                //修改默认的初始密码跳转到登录页
                AppManager.Instance.Logout(User.Identity.Name);
                this.ClearLoginModel();
                return(JsonTipsLang("success", null, FStr.PasswordChangeSucceed, new { Url = Url.Action("Logout", "Account") }));
            }
            return(JsonTipsLang("error", null, resState.ToString()));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sends the current presence information to the server
 /// </summary>
 public void SendCurrentPresence(LoginState loginState)
 {
     if (m_currentPresence == null)
     {
         m_currentPresence = new AvailableRequest();
     }
     m_currentPresence.Status = loginState.ToString();
     SendCurrentPresence(m_currentPresence);
 }
Ejemplo n.º 4
0
 private void SetLoginState(LoginState state)
 {
     UnityUtility.CTrace.Singleton.debug("设置状态SetLoginState[{0}]", state.ToString());
     m_loginState = state;
 }
Ejemplo n.º 5
0
    int GetResult(string strDate,
                  bool bForce,
                  out string strError)
    {
        strError = "";
        int nRet = 0;

        if (string.IsNullOrEmpty(strDate) == true)
        {
            strDate = this.TreeView1.SelectedNodePath;
        }

        // 保存起来
        if (string.IsNullOrEmpty(strDate) == false)
        {
            this.TreeView1.SelectedNodePath = strDate;
        }

        this.Page.Title = (string)this.GetLocalResourceObject("统计图") + " - " + GetDateName(strDate);

        SeriesChartType type = SeriesChartType.Line;

        if (string.IsNullOrEmpty(this.DropDownList_chartType.Text) == false)
        {
            type = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), this.DropDownList_chartType.Text, true);
        }

        LoginState loginstate = GlobalUtil.GetLoginState(this.Page);
        string     strRole    = loginstate.ToString().ToLower(); // notlogin public reader librarian

        string      strDataFilename = PathUtil.MergePath(sessioninfo.GetTempDir(), "~statis_chat_data_" + strRole);
        XmlDocument dom             = new XmlDocument();

        if (bForce == false && File.Exists(strDataFilename) == true)
        {
            try
            {
                dom.Load(strDataFilename);
            }
            catch (Exception ex)
            {
                strError = "文件装入XMLDOM时出错: " + ex.Message;
                return(-1);
            }

            // 日期范围也要对得上才行
            string strFileRange = DomUtil.GetElementText(dom.DocumentElement, "range");
            if (strFileRange != strDate)
            {
                bForce = true;
                dom    = new XmlDocument();
            }
            else
            {
                bForce = false;
            }
        }
        else
        {
            bForce = true;
        }


        if (bForce == true)
        {
            RangeStatisInfo info   = null;
            string          strXml = "";

            ModifyDateString(ref strDate);

            LibraryChannel channel = sessioninfo.GetChannel(true);
            try
            {
                long lRet = //sessioninfo.Channel.
                            channel.GetStatisInfo(strDate,
                                                  "list",
                                                  out info,
                                                  out strXml,
                                                  out strError);
                if (lRet == -1)
                {
                    return(-1);
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            string strTemplateFilename = app.CfgDir + "\\statis_template.xml";
            if (File.Exists(strTemplateFilename) == true)
            {
                string strTargetXml = "";
                nRet = StatisViewControl.FilterXmlFile(
                    strRole, // notlogin public reader librarian
                    strXml,
                    strTemplateFilename,
                    true,
                    out strTargetXml,
                    out strError);
                if (nRet == -1)
                {
                    return(-1);
                }

                strXml = strTargetXml;
            }

            try
            {
                dom.LoadXml(strXml);
            }
            catch (Exception ex)
            {
                strError = "XML装入DOM时出错: " + ex.Message;
                return(-1);
            }

            DomUtil.SetElementText(dom.DocumentElement, "range", strDate);

            DomUtil.SetElementText(dom.DocumentElement, "startDate", info.StartDate);
            DomUtil.SetElementText(dom.DocumentElement, "endDate", info.EndDate);

            dom.Save(strDataFilename);
        }


        List <string> selected_itemspaths = this.StatisEntryControl1.GetSelectedItems();

        string strTotalXmlFilename = PathUtil.MergePath(app.DataDir, "~statis_entry_" + strRole + ".xml");

        nRet = SetEntryPanel(dom.DocumentElement.OuterXml,
                             strTotalXmlFilename,
                             out strError);
        if (nRet == -1)
        {
            return(-1);
        }

        // 如果首次访问的时候没有指定统计指标
        if (this.IsPostBack == false && selected_itemspaths.Count == 0)
        {
            selected_itemspaths.Add("出纳");
            this.StatisEntryControl1.SelectItems(selected_itemspaths);
        }


#if NO
        string strLibraryCode = this.DropDownList_libraryCode.Text;
        if (strLibraryCode == "<所有分馆>")
        {
            strLibraryCode = "";
        }
#endif
        string strLibraryCode = (string)this.Page.Session["librarycode"];

        this.Chart1.ChartAreas.Clear();

        this.Chart1.Series.Clear();

        Legend legend = new Legend();
        // legend.Name = strName;
        legend.Docking       = Docking.Bottom;
        legend.IsTextAutoFit = true;
        Font default_font = GetDefaultFont();
        if (default_font != null)
        {
            legend.Font = default_font;
        }
        this.Chart1.Legends.Add(legend);

        XmlNodeList nodes = null;

        if (string.IsNullOrEmpty(strLibraryCode) == true)
        {
            nodes = dom.DocumentElement.SelectNodes("category/item");
        }
        else
        {
            nodes = dom.DocumentElement.SelectNodes("library[@code='" + strLibraryCode + "']/category/item");
        }
        int nCount = 0;

        int    nArea       = 1;
        string strAreaName = "";
        if ((nCount % 100) == 0)
        {
            strAreaName = CreateChartArea(nArea++);
        }

        int      nMaxPoints   = 0;
        string   strStartDate = DomUtil.GetElementText(dom.DocumentElement, "startDate");
        string   strEndDate   = DomUtil.GetElementText(dom.DocumentElement, "endDate");
        DateTime start_date   = DateTimeUtil.Long8ToDateTime(strStartDate);
        DateTime end_date     = DateTimeUtil.Long8ToDateTime(strEndDate);
        DateTime now          = DateTime.Now;

        foreach (XmlNode node in nodes)
        {
            string strName = GetItemPath(node);

            string strPath = MakePath(strName);
            if (MatchPath(selected_itemspaths, strPath) == false)
            {
                continue;
            }

            string strValue = DomUtil.GetAttr(node, "value");

            Series series = new Series(strName);
            series.ChartType         = type; //  SeriesChartType.Line;
            series.ChartArea         = strAreaName;
            series.BorderWidth       = 3;
            series.IsVisibleInLegend = true;

            DateTime current_date = start_date;
            string[] values       = strValue.Split(new char[] { ',' });
            int      i            = 0;
            foreach (string v in values)
            {
                // 2012/11/16
                if (current_date <= end_date &&
                    current_date <= now)
                {
                }
                else
                {
                    break;
                }

                if (i == 0)
                {
                    goto CONTINUE;
                }
                double d = 0;
                if (string.IsNullOrEmpty(v) == false)
                {
                    double.TryParse(v, out d);
                }
                series.Points.AddXY(current_date, d);

                current_date = current_date.AddDays(1);
CONTINUE:
                i++;
            }

            while (current_date <= end_date &&
                   current_date <= now)
            {
                series.Points.AddXY(current_date, 0);
                current_date = current_date.AddDays(1);
                i++;
            }

            if (i > nMaxPoints)
            {
                nMaxPoints = i;
            }
            this.Chart1.Series.Add(series);
            nCount++;
        }

        this.Chart1.ChartAreas[0].AxisX.Minimum = start_date.ToOADate();
        this.Chart1.ChartAreas[0].AxisX.Maximum = end_date.ToOADate();

        if (nMaxPoints <= 32 && this.Chart1.ChartAreas.Count > 0)
        {
            this.Chart1.ChartAreas[0].AxisX.Interval = 1;
        }

        if (this.CheckBox_3D.Checked == true)
        {
            this.Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
        }

        return(0);
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string strStatisColumnVisible = GetStatisColumnVisible();

        LoginState loginstate = GlobalUtil.GetLoginState(this.Page);
        string     strRole    = loginstate.ToString().ToLower(); // notlogin public reader librarian

        if (StringUtil.IsInList("all", strStatisColumnVisible) == true ||
            (loginstate == LoginState.Librarian && StringUtil.IsInList("librarian", strStatisColumnVisible) == true) ||
            (loginstate == LoginState.Reader && StringUtil.IsInList("reader", strStatisColumnVisible) == true) ||
            (loginstate == LoginState.Public && StringUtil.IsInList("public", strStatisColumnVisible) == true) ||
            (loginstate == LoginState.NotLogin && StringUtil.IsInList("notlogin", strStatisColumnVisible) == true)
            )
        {
            // 2015/4/3
            // 尚未登录的情况下,需要一点额外处理
            if (loginstate == LoginState.NotLogin)
            {
                sessioninfo.UserID   = "public";
                sessioninfo.IsReader = false;
            }
        }
        else
        {
            Response.Write("必须是 " + strStatisColumnVisible + " 状态才能使用statischart.aspx");
            Response.End();

            /*
             * // 是否登录?
             * if (sessioninfo.UserID == "")
             * {
             *  sessioninfo.LoginCallStack.Push(Request.RawUrl);
             *  Response.Redirect("login.aspx", true);
             *  return;
             * }*/
        }

        string strSideBarFile = Server.MapPath("./statis_sidebar.xml");

        if (File.Exists(strSideBarFile) == true)
        {
            this.SideBarControl1.CfgFile = strSideBarFile;
        }
        else
        {
            this.SideBarControl1.Visible = false;
        }

        this.Chart1.ChartAreas[0].AxisX.IsLabelAutoFit = true;
        this.Chart1.ChartAreas[0].AxisX.Interval       = 1;

        if (this.IsPostBack == true)
        {
            if (string.IsNullOrEmpty(this.HiddenField_imageWidth.Value) == false)
            {
                string[] parts     = this.HiddenField_imageWidth.Value.Split(new char[] { ',' });
                string   strWidth  = parts[0];
                string   strHeight = "";
                if (parts.Length >= 2)
                {
                    strHeight = parts[1];
                }
                double w = 0;
                if (double.TryParse(strWidth, out w) == false ||
                    w == 0)
                {
                    throw new Exception("字符串格式不正确 this.HiddenField_imageWidth.Value = '" + this.HiddenField_imageWidth.Value + "' 左边部分应该为数字");
                }

                if (w <= 0)
                {
                    w = 500;
                }

                w = Math.Min(w, 2000);

                double h = w * 0.46;

                if (string.IsNullOrEmpty(strHeight) == false)
                {
                    if (double.TryParse(strHeight, out h) == false ||
                        h == 0)
                    {
                        throw new Exception("字符串格式不正确 this.HiddenField_imageWidth.Value = '" + this.HiddenField_imageWidth.Value + "' 逗号右边部分应该为数字");
                    }
                    if (h <= 0)
                    {
                        h = 500;
                    }

                    h = Math.Min(h, 1000);
                }

                this.Chart1.Width  = new Unit(w, UnitType.Pixel);
                this.Chart1.Height = new Unit(h, UnitType.Pixel);
            }
        }

        FillChartTypeList(this.DropDownList_chartType);
        if (this.IsPostBack == false)
        {
            this.DropDownList_chartType.Text = "Line";
        }

        // 这是尚未宏兑现的原始 XML 文件
        string strDataFileName = this.Request["datafile"];

        if (String.IsNullOrEmpty(strDataFileName) == true)
        {
            strDataFileName = "statis_timerange.xml";
        }

        // 进行宏兑现
        MacroDataFile(strDataFileName, strDataFileName + ".1");

        if (string.IsNullOrEmpty(this.TreeView1.XmlFileName) == true || this.IsPostBack == false
            // 如果数据文件名和参数中的不吻合,需要重新设置数据集
            || PathUtil.PureName(this.TreeView1.XmlFileName).ToLower() != (strDataFileName + ".1").ToLower()
            )
        {
            string strSourceFileName = app.DataDir + "/cfgs/" + strDataFileName;
            this.TreeView1.XmlFileName = strSourceFileName + ".1";
            if (File.Exists(this.TreeView1.XmlFileName) == false)
            {
                BuildDefaultDataXmlFile(strSourceFileName);
                MacroDataFile(strSourceFileName, this.TreeView1.XmlFileName);
            }
            this.Session["__timerange_data_filename__"] = this.TreeView1.XmlFileName; // 补充保存在Session中,备用。因为在_Init()阶段是得不到隐藏字段的值的
        }

        string strDate = "";

        if (this.IsPostBack == false)
        {
            strDate = this.Page.Request["date"];
            if (string.IsNullOrEmpty(strDate) == true)
            {
                strDate = DateTimeUtil.DateTimeToString8(DateTime.Now).Substring(0, 6); // 当前月份
            }
        }
        else
        {
            strDate = this.TreeView1.SelectedNodePath;
        }

        /*
         * if (this.IsPostBack == false
         *  && string.IsNullOrEmpty(this.HiddenField_entryItems.Value) == false)
         * {
         *  this.StatisEntryControl1.SelectItems(StringUtil.SplitList(this.HiddenField_entryItems.Value));
         * }
         * */

        /*
         * if (String.IsNullOrEmpty(strDate) == true
         *  && this.TreeView1.SelectedNode != null)
         * {
         *  XmlDocument dom = (XmlDocument)this.TimeDataSource.GetXmlDocument();
         *  XmlNode node = dom.SelectSingleNode(this.TreeView1.SelectedNode.DataPath);
         *  if (node != null)
         *  {
         *      strDate = DomUtil.GetAttr(node, "date");
         *  }
         * }
         * */

        string strError = "";

        if (string.IsNullOrEmpty(strDate) == false)
        {
            int nRet = GetResult(strDate,
                                 false,
                                 out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }
        }
        return;

ERROR1:
        this.Page.Response.Write(HttpUtility.HtmlEncode(strError));
        this.Page.Response.End();
        return;
    }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新状态信息
        /// </summary>
        public void UpdateState()
        {
            if (Info == null)
            {
                return;
            }
            switch (ObjType)
            {
            case ConstValue.RESOURCE_AGENT:
            case ConstValue.RESOURCE_EXTENSION:
                if (Info.ChanObjID <= 0)
                {
                    LoginState  = LoginState.LogOff;
                    CallState   = CallState.Idle;
                    RecordState = RecordState.None;
                }
                else
                {
                    if (ChanState != null)
                    {
                        Extension       = ChanState.Extension;
                        AgentID         = ChanState.AgentID;
                        LoginState      = ChanState.LoginState;
                        CallState       = ChanState.CallState;
                        RecordState     = ChanState.RecordState;
                        RecordReference = ChanState.RecordReference;
                        DirectionFlag   = ChanState.DirectionFlag;
                        CallerID        = ChanState.CallerID;
                        CalledID        = ChanState.CalledID;
                        StartRecordTime = ChanState.StartRecordTime;
                        StopRecordTime  = ChanState.StopRecordTime;
                        DealRecordLength(ChanState);
                    }
                }
                break;
            }
            StrIcon       = Icon;
            StrLoginState = LoginState == LoginState.LogOff
                ? string.Empty
                : App.GetLanguageInfo(
                string.Format("BID{0}{1}", S2102Consts.BID_LOGSTATE, ((int)LoginState).ToString("000")),
                LoginState.ToString());
            StrCallState = CallState == CallState.Idle ? string.Empty : App.GetLanguageInfo(
                string.Format("BID{0}{1}", S2102Consts.BID_CALLSTATE, ((int)CallState).ToString("000")),
                CallState.ToString());
            StrRecordState = RecordState == RecordState.None ? string.Empty : App.GetLanguageInfo(
                string.Format("BID{0}{1}", S2102Consts.BID_RECORDSTATE, ((int)RecordState).ToString("000")),
                RecordState.ToString());
            StrDirection = DirectionFlag == 1
                ? App.GetLanguageInfo("2102014", "Callin")
                : App.GetLanguageInfo("2102015", "Callout");
            StrStartRecordTime = StartRecordTime > DateTime.Parse("2014/1/1")
                ? StartRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")
                : string.Empty;
            StrStopRecordTime = StopRecordTime > DateTime.Parse("2014/1/1")
                ? StopRecordTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")
                : string.Empty;
            StrRecordLength = RecordLength > 0 ? Converter.Second2Time(RecordLength) : "00:00:00";

            Background = Brushes.Transparent;
            if (LoginState == LoginState.LogOn)
            {
                Background = Brushes.Wheat;
                if (ListUserParams != null)
                {
                    var userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_VOCLOGINSTATE);
                    if (userParam != null)
                    {
                        try
                        {
                            Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                            Background = new SolidColorBrush(color);
                        }
                        catch { }
                    }
                }
            }
            if (RecordState == RecordState.Recoding)
            {
                Background = Brushes.Thistle;
                if (DirectionFlag == 1)
                {
                    Background = Brushes.Thistle;
                }
                else
                {
                    Background = Brushes.Violet;
                }
                if (ListUserParams != null)
                {
                    var userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_VOCRECORDSTATE);
                    if (userParam != null)
                    {
                        try
                        {
                            Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                            Background = new SolidColorBrush(color);
                        }
                        catch { }
                    }
                    if (DirectionFlag == 1)
                    {
                        userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_CALLINSTATE);
                        if (userParam != null)
                        {
                            try
                            {
                                Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                                Background = new SolidColorBrush(color);
                            }
                            catch { }
                        }
                    }
                    else
                    {
                        userParam = ListUserParams.FirstOrDefault(p => p.ParamID == S2102Consts.UP_COLOR_CALLOUTSTATE);
                        if (userParam != null)
                        {
                            try
                            {
                                Color color = Utils.GetColorFromRgbString(userParam.ParamValue);
                                Background = new SolidColorBrush(color);
                            }
                            catch { }
                        }
                    }
                }
            }

            IsLogged    = LoginState == LoginState.LogOn;
            IsRecording = RecordState == RecordState.Recoding;

            if (IsRecording)
            {
                try
                {
                    StrRecordLength = Converter.Second2Time(RecordLength);
                }catch {}
            }
            else
            {
                StrRecordLength = string.Empty;
            }

            try
            {
                StrVoiceFormat = ((EVLVoiceFormat)VoiceFormat).ToString();
            }catch {}
        }
Ejemplo n.º 8
0
 internal KeeperStartLoginException(LoginState loginState, string message)
     : base(string.IsNullOrEmpty(message) ? loginState.ToString() : message)
 {
     LoginState = loginState;
 }
Ejemplo n.º 9
0
        protected override void RenderContents(HtmlTextWriter output)
        {
            string strError = "";
            int    nRet     = 0;

#if NO
            if (this.XmlFilename == "")
            {
                strError = "<span class='comment'>"
                           + this.GetString("尚未指定日期参数") // "(尚未指定日期参数)"
                           + "</span>";
                goto ERROR1;
            }
#endif
            if (String.IsNullOrEmpty(this.Xml) == true)
            {
                /*
                 * strError = "<span class='comment'>"
                 + this.GetString("尚未指定日期参数")  // "(尚未指定日期参数)"
                 + "</span>";
                 + goto ERROR1;
                 * */
                strError = "<span class='comment'>"
                           + this.DateRange + " " + this.GetString("没有统计信息")
                           + "</span>";
                goto ERROR1;
            }


            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string strTemplateFilename = app.CfgDir + "\\statis_template.xml";

            if (File.Exists(strTemplateFilename) == true)
            {
                string strTargetXml = "";

                LoginState loginstate = Global.GetLoginState(this.Page);

                // 利用模板文件过滤统计事项,并将事项按照模板顺序排序
                nRet = StatisViewControl.FilterXmlFile(
                    loginstate.ToString().ToLower(), // notlogin public reader librarian
                    this.Xml,
                    strTemplateFilename,
                    false,
                    out strTargetXml,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.Xml = strTargetXml;
            }



            string strDate = "";

            strDate = this.DateRange;

            try
            {
                dom = new XmlDocument();
                dom.LoadXml(this.Xml);
            }
            catch (Exception ex)
            {
                strError = "XML字符串装入DOM时出错:" + ex.Message;
                goto ERROR1;
            }

#if NO
            if (nRet == 0)
            {
                strError = "<span class='comment'>" + strDate
                           + this.GetString("没有统计信息")
                           + "</span>";
                goto ERROR1;
            }
#endif

            output.Write("<table class='statis' >");// border='1'

            // 标题行
            output.Write("<tr class='tabletitle'><td colspan='2'>" + strDate + " "
                         + this.GetString("实时统计信息")
                         + "</td></tr>");

            // 注释行
            if (this.RangeStatisInfo != null)
            {
                string strComment = GetCommentString(this.RangeStatisInfo);
                output.Write("<tr class='comment'><td colspan='2'>" + strComment + "</td></tr>");
            }


            XmlNodeList categorys = this.dom.DocumentElement.SelectNodes("category");
            for (int i = 0; i < categorys.Count; i++)
            {
                XmlNode category = categorys[i];

                string strCategory = DomUtil.GetAttr(category, "name");

                // 2009/7/31
                string strCategoryCaption = this.GetStringEx(strCategory);
                if (String.IsNullOrEmpty(strCategoryCaption) == true)
                {
                    strCategoryCaption = strCategory;
                }

                output.Write("<tr class='category'><td colspan='2'>");
                output.Write(strCategoryCaption);
                output.Write("</td></tr>");

                XmlNodeList items = category.SelectNodes("item");

                for (int j = 0; j < items.Count; j++)
                {
                    XmlNode item = items[j];

                    string strItemName  = DomUtil.GetAttr(item, "name");
                    string strItemValue = DomUtil.GetAttr(item, "value");

                    // 2009/7/31
                    string strItemNameCaption = this.GetStringEx(strItemName);
                    if (String.IsNullOrEmpty(strItemNameCaption) == true)
                    {
                        strItemNameCaption = strItemName;
                    }


                    output.Write("<tr class='content'><td class='name'>");
                    output.Write(strItemNameCaption);
                    output.Write("</td><td class='value'>");
                    output.Write(strItemValue);
                    output.Write("</td></tr>");
                }
            }
            output.Write("</table>");

            return;

ERROR1:
            output.Write(strError);
        }
Ejemplo n.º 10
0
        protected override void Render(HtmlTextWriter writer)
        {
            string strError = "";
            int    nRet     = 0;

            LiteralControl table = (LiteralControl)this.FindControl("table");

#if NO
            DropDownList list = (DropDownList)this.FindControl("librarycode");
#endif

            if (String.IsNullOrEmpty(this.Xml) == true)
            {
                /*
                 * strError = "<span class='comment'>"
                 + this.GetString("尚未指定日期参数")  // "(尚未指定日期参数)"
                 + "</span>";
                 + goto ERROR1;
                 * */
                strError = this.DateRange + " " + this.GetString("没有统计信息");
                goto ERROR1;
            }

            OpacApplication app         = (OpacApplication)this.Page.Application["app"];
            SessionInfo     sessioninfo = (SessionInfo)this.Page.Session["sessioninfo"];

            string strTemplateFilename = app.CfgDir + "\\statis_template.xml";
#if NO
            string strLibraryCode = list.Text;
            if (strLibraryCode == "<所有分馆>")
            {
                strLibraryCode = "";
            }
#endif
            string strLibraryCode = (string)this.Page.Session["librarycode"];

            List <string> codes = app.GetAllLibraryCodes();
            bool          bExistsTemplateFile = false;
            if (File.Exists(strTemplateFilename) == true)
            {
                bExistsTemplateFile = true;

                string     strTargetXml = "";
                LoginState loginstate   = GlobalUtil.GetLoginState(this.Page);

                // 利用模板文件过滤统计事项,并将事项按照模板顺序排序
                nRet = StatisViewControl.FilterXmlFile(
                    strLibraryCode,
                    loginstate.ToString().ToLower(), // notlogin public reader librarian
                    this.Xml,
                    strTemplateFilename,
                    false,
                    out strTargetXml,
                    // out exist_codes,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.Xml = strTargetXml;
            }

            string strDate = "";
            strDate = this.DateRange;

            try
            {
                dom = new XmlDocument();
                dom.LoadXml(this.Xml);
            }
            catch (Exception ex)
            {
                strError = "XML字符串装入DOM时出错:" + ex.Message;
                goto ERROR1;
            }

#if NO
            // 如果没有过滤,则需要在这里获得馆代码
            if (File.Exists(strTemplateFilename) == false)
            {
                XmlNodeList nodes = dom.DocumentElement.SelectNodes("library");
                foreach (XmlNode node in nodes)
                {
                    string strCode = DomUtil.GetAttr(node, "code");
                    exist_codes.Add(strCode);
                }
            }
#endif
            // 如果没有过滤,则需要在这里把特定馆代码的片段提升到根下
            if (bExistsTemplateFile == false &&
                string.IsNullOrEmpty(strLibraryCode) == false)
            {
                XmlNode node = dom.DocumentElement.SelectSingleNode("library[@code='" + strLibraryCode + "']");
                if (node != null)
                {
                    dom.DocumentElement.InnerXml = node.InnerXml;
                }
                else
                {
                    dom.DocumentElement.InnerXml = "";
                }
            }

            StringBuilder text = new StringBuilder(4096);

            text.Append("<div class='statisframe'><table class='statis' >");// border='1'

            string strLibraryCodeText = "";
            if (String.IsNullOrEmpty(strLibraryCode) == true)
            {
                if (codes.Count == 0)
                {
                    strLibraryCodeText = "";
                }
                else
                {
                    strLibraryCodeText = this.GetString("全部分馆") + " ";
                }
            }
            else
            {
                strLibraryCodeText = strLibraryCode + " ";
            }
            List <string> column_titles = new List <string>();

            DateTime start_date = DateTimeUtil.Long8ToDateTime(this.RangeStatisInfo.StartDate);
            DateTime end_date   = DateTimeUtil.Long8ToDateTime(this.RangeStatisInfo.EndDate);
            DateTime now        = DateTime.Now;
            if (this.IsRange == true)
            {
                DateTime current_date = start_date;
                while (current_date <= end_date &&
                       current_date <= now)
                {
                    column_titles.Add(GetDateString(current_date, current_date == start_date));
                    current_date = current_date.AddDays(1);
                }
            }


            string strColspan = "";
            strColspan = " colspan='" + (column_titles.Count + 2).ToString() + "' ";

            // 标题行
            text.Append("<tr class='tabletitle'><td " + strColspan + ">" + strLibraryCodeText + strDate + " "
                        + this.GetString("实时统计信息")
                        + "</td></tr>");

            // 注释行
            if (this.RangeStatisInfo != null)
            {
                string strComment = GetCommentString(this.RangeStatisInfo);
                text.Append("<tr class='comment'><td " + strColspan + ">" + strComment + "</td></tr>");
            }

            // 栏目标题行
            string strColumnLine = "";
            if (this.IsRange == true)
            {
                StringBuilder line = new StringBuilder(4096);
                foreach (string s in column_titles)
                {
                    line.Append("<td class='day'>" + s + "</td>");
                }
                strColumnLine = "<tr class='column'><td class='rowtitle'>统计指标</td><td class='rowtitle'>合计</td>"
                                + line.ToString()
                                + "</tr>";
            }
            else
            {
                strColumnLine = "<tr class='column'><td class='rowtitle'>统计指标</td><td class='rowtitle'>合计</td>"
                                + "</tr>";
            }
            text.Append(strColumnLine);

            XmlNodeList categorys = this.dom.DocumentElement.SelectNodes("category");
            for (int i = 0; i < categorys.Count; i++)
            {
                XmlNode category = categorys[i];

                string strCategory = DomUtil.GetAttr(category, "name");

                // 2009/7/31
                string strCategoryCaption = this.GetStringEx(strCategory);
                if (String.IsNullOrEmpty(strCategoryCaption) == true)
                {
                    strCategoryCaption = strCategory;
                }

                text.Append("<tr class='category'><td " + strColspan + ">");
                text.Append(strCategoryCaption);
                text.Append("</td></tr>");

                XmlNodeList items = category.SelectNodes("item");

                for (int j = 0; j < items.Count; j++)
                {
                    XmlNode item = items[j];

                    string strItemName  = DomUtil.GetAttr(item, "name");
                    string strItemValue = DomUtil.GetAttr(item, "value");

                    // 2009/7/31
                    string strItemNameCaption = this.GetStringEx(strItemName);
                    if (String.IsNullOrEmpty(strItemNameCaption) == true)
                    {
                        strItemNameCaption = strItemName;
                    }

                    if (this.IsRange == false)
                    {
                        text.Append("<tr class='content'><td class='name'>");
                        text.Append(strItemNameCaption);
                        text.Append("</td><td class='value'>");
                        text.Append(strItemValue);
                        text.Append("</td></tr>");
                    }
                    else
                    {
                        string[] values = strItemValue.Split(new char[] { ',' });
                        text.Append("<tr class='content'><td class='name'>");
                        text.Append(strItemNameCaption);
                        text.Append("</td>");

                        int      k            = 0;
                        DateTime current_date = start_date;
                        foreach (string v in values)
                        {
                            if (current_date <= end_date &&
                                current_date <= now)
                            {
                            }
                            else
                            {
                                break;  // 比今天还要靠后的就不显示了
                            }
                            string strClass = "day";
                            if (k == 0)
                            {
                                strClass = "value";
                            }

                            text.Append("<td class='" + strClass + "'>");
                            text.Append(string.IsNullOrEmpty(v) == false ? v : "&nbsp;");
                            text.Append("</td>");

                            if (k != 0) // 第一次出现是合计值, 不是普通日子的值
                            {
                                current_date = current_date.AddDays(1);
                            }

                            k++;
                        }

                        while (current_date <= end_date &&
                               current_date <= now)
                        {
                            text.Append("<td class='day'>&nbsp;</td>");
                            current_date = current_date.AddDays(1);
                        }
                        text.Append("</tr>");
                    }
                }
            }

            if (this.IsRange == true && column_titles.Count > 3)
            {
                // 底部再来一次栏目标题行
                text.Append(strColumnLine);
            }

            text.Append("</table></div>");

            table.Text = text.ToString();
            base.Render(writer);
            return;

ERROR1:
            table.Text = "<span class='comment'>"
                         + HttpUtility.HtmlEncode(strError)
                         + "</span>";
            base.Render(writer);
        }