Пример #1
0
        string GetCommentString(RangeStatisInfo info)
        {
            string strResult = "";

            strResult += "<span class='comment'>"
                         + this.GetString("统计日期范围")
                         + ": "
                         + DateTimeUtil.AddHyphenToString8(info.StartDate, "/")
                         + " - "
                         + DateTimeUtil.AddHyphenToString8(info.EndDate, "/")
                         + "</span><br/>";
            strResult += "<span class='comment'>"
                         + this.GetString("所含天数")
                         + ": " + info.Days.ToString() + "</span><br/>";
            strResult += "<span class='comment'>"
                         + this.GetString("实际日期范围")
                         + ": "
                         + DateTimeUtil.AddHyphenToString8(info.RealStartDate, "/")
                         + " - "
                         + DateTimeUtil.AddHyphenToString8(info.RealEndDate, "/")
                         + "</span><br/>";
            strResult += "<span class='comment'>"
                         + this.GetString("实际所含天数")
                         + ": " + info.RealDays.ToString() + "</span><br/>";

            return(strResult);
        }
Пример #2
0
    protected void Calendar1_SelectionChanged(object sender,
                                              EventArgs e)
    {
        string strError = "";
        string strDate  = "";

        // Iterate through the SelectedDates collection and display the
        // dates selected in the Calendar control.
        foreach (DateTime day in Calendar1.SelectedDates)
        {
            /*
             * this.Page.Response.Redirect(app.LibraryServerUrl + "/statis.aspx?date=" + DateTimeUtil.DateTimeToString8(day),
             *  true);
             * */
            strDate = DateTimeUtil.DateTimeToString8(day);
            break;
        }

        if (String.IsNullOrEmpty(strDate) == false)
        {
            RangeStatisInfo info    = null;
            string          strXml  = "";
            LibraryChannel  channel = sessioninfo.GetChannel(true);
            try
            {
                long lRet = // sessioninfo.Channel.
                            channel.GetStatisInfo(strDate,
                                                  "",
                                                  out info,
                                                  out strXml,
                                                  out strError);
                if (lRet == -1)
                {
                    goto ERROR1;
                }
            }
            finally
            {
                sessioninfo.ReturnChannel(channel);
            }

            this.StatisViewControl1.Xml             = strXml;
            this.StatisViewControl1.DateRange       = strDate;
            this.StatisViewControl1.IsRange         = false;
            this.StatisViewControl1.RangeStatisInfo = info;

            DateTime current_date = DateTimeUtil.Long8ToDateTime(strDate);
            this.Calendar1.SelectedDate = current_date;
            this.Calendar1.TodaysDate   = current_date;
        }
        return;

ERROR1:
        this.Page.Response.Write(HttpUtility.HtmlEncode(strError));
        this.Page.Response.End();
        return;
    }
Пример #3
0
    int GetResult(
        // LibraryChannel channel,
        string strDate,
        out string strError)
    {
        strError = "";

        LibraryChannel channel = sessioninfo.GetChannel(true);

        try
        {
            RangeStatisInfo info   = null;
            string          strXml = "";
            long            lRet   = channel.GetStatisInfo(strDate,
                                                           strDate.Length == 8 ? "" : "list",
                                                           out info,
                                                           out strXml,
                                                           out strError);
            if (lRet == -1)
            {
                return(-1);
            }
            this.StatisViewControl1.Xml       = strXml;
            this.StatisViewControl1.DateRange = strDate;

            // 8字符的情况
            if (strDate.Length == 8)
            {
                DateTime current_date = DateTimeUtil.Long8ToDateTime(strDate);
                this.Calendar1.SelectedDate     = current_date;
                this.Calendar1.TodaysDate       = current_date;
                this.StatisViewControl1.IsRange = false;
            }
            else
            {
                this.StatisViewControl1.IsRange = true;
            }

            this.StatisViewControl1.RangeStatisInfo = info;
            return(0);
        }
        finally
        {
            sessioninfo.ReturnChannel(channel);
        }
    }
Пример #4
0
        string GetCommentString(RangeStatisInfo info)
        {
            string strResult = "";

            strResult += "<span class='comment'>"
                + this.GetString("统计日期范围")
                + ": "
                + DateTimeUtil.AddHyphenToString8(info.StartDate, "/")
                + " - "
                + DateTimeUtil.AddHyphenToString8(info.EndDate, "/")
                + "</span><br/>";
            strResult += "<span class='comment'>"
                + this.GetString("所含天数")
                + ": " + info.Days.ToString() + "</span><br/>";
            strResult += "<span class='comment'>"
                + this.GetString("实际日期范围")
                + ": "
                + DateTimeUtil.AddHyphenToString8(info.RealStartDate, "/")
                + " - "
                + DateTimeUtil.AddHyphenToString8(info.RealEndDate, "/")
                + "</span><br/>";
            strResult += "<span class='comment'>"
                + this.GetString("实际所含天数")
                + ": " + info.RealDays.ToString() + "</span><br/>";

            return strResult;
        }
Пример #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);
    }