예제 #1
0
        public static object LoadBillText()
        {
            BillType type;
            int      session, number;

            ParseBill2(out session, out type, out number);

            string format = "html";

            string version   = HttpContext.Current.Request["version"];
            string compareto = HttpContext.Current.Request["compareto"];

            if (version == null)
            {
                string[][] statuses = Bills.GetBillTextStatusCodes(type);
                foreach (string[] s in statuses)
                {
                    if (System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, format, s[0], null)))
                    {
                        version = s[0];
                    }
                }
                if (version == null)
                {
                    if (format == "html")
                    {
                        format = "txt";
                        foreach (string[] s in statuses)
                        {
                            if (System.IO.File.Exists(Bills.GetBillTextFileName(session, type, number, format, s[0], null)))
                            {
                                version = s[0];
                            }
                        }
                        if (version == null)
                        {
                            return(TextNotAvailable());
                        }
                    }
                }

                compareto = null;
            }
            else
            {
                foreach (char c in version)
                {
                    if (!char.IsLetter(c) && !char.IsDigit(c))
                    {
                        throw new UserException("Invalid bill version code.");
                    }
                }

                if (compareto != null)
                {
                    foreach (char c in compareto)
                    {
                        if (!char.IsLetter(c) && !char.IsDigit(c))
                        {
                            throw new UserException("Invalid bill version code (compareto).");
                        }
                    }
                }
            }

            try {
                object ret = Bills.LoadBillText(session, type, number, format, version, compareto);
                if (ret is string)
                {
                    Hashtable x = new Hashtable();
                    x["text"] = ret;
                    ret       = x;
                }
                return(ret);
            } catch (System.IO.IOException e) {
                Console.Error.WriteLine(e);
                return(TextNotAvailable());
            }
        }