static public MlbEntity GetAgent(SqlCommand command,
                                         string ticketName,
                                         string ticketcode,
                                         string flightdate,
                                         string flightcode)
        {
            //return null;

            DataRow row = DbUtility.GetDataRow(command, SP_GET_AGENT,
                                               SqlHelper.BuildParameter("ticketName", ticketName),
                                               SqlHelper.BuildParameter("ticketcode", ticketcode),
                                               SqlHelper.BuildParameter("flightdate", flightdate),
                                               SqlHelper.BuildParameter("flightcode", flightcode));

            if (row == null)
            {
                return(null);
            }
            MlbEntity me = new MlbEntity()
            {
                Id = (int)row["Id"], ticsellagt = row["ticsellagt"].ToString()
            };

            return(me);
        }
        public static MlbEntity GetAgent(SqlCommand command,
            string ticketName,
            string ticketcode,
            string flightdate,
            string flightcode)
        {
            //return null;

            DataRow row = DbUtility.GetDataRow(command, SP_GET_AGENT,
                SqlHelper.BuildParameter("ticketName", ticketName),
               SqlHelper.BuildParameter("ticketcode", ticketcode),
               SqlHelper.BuildParameter("flightdate", flightdate),
               SqlHelper.BuildParameter("flightcode", flightcode));
            if (row == null)
                return null;
            MlbEntity me = new MlbEntity() { Id = (int)row["Id"], ticsellagt = row["ticsellagt"].ToString() };
            return me;
        }
示例#3
0
        public void parseMLB()
        {
            StreamReader fileReader = File.OpenText(this.filename);
            string       flightcode = "", flightdate = "", ticketName = "", ticketcode = "", ticsellagt = "", fltsegment = "";
            string       s           = "";
            string       ticketseat  = "";
            string       ticketstat  = "";
            string       str10       = "";
            string       ticbuydate  = "";
            bool         flag        = false;
            int          insertCount = 0;
            int          num3        = 0;

            string line = fileReader.ReadLine();

            SqlConnection connection = DbUtility.GetConnection();

            connection.Open();
            SqlCommand command = connection.CreateCommand();

            while (line != null)
            {
                line = fileReader.ReadLine();
                if (line == null)
                {
                    continue;
                }

                line = line.Trim();
                if (line.Length <= 5)
                {
                    continue;
                }
                ShowProcessingText(line);

                if (line.Substring(0, 4).ToLower() == ">mlb")
                {
                    flag       = true;
                    flightcode = line.Split(new char[] { '/' })[1].ToUpper();
                    line       = fileReader.ReadLine();
                    line       = fileReader.ReadLine();
                    if (line.Trim().Length != 0)
                    {
                        flightdate = line.Split(new char[] { '/' })[1].Substring(0, 7);
                    }
                    continue;
                }
                if (line.Substring(0, 5) == "TOTAL")
                {
                    flag = false;
                    continue;
                }
                if ((line.Substring(line.Length - 3, 3) == "* +") || (line.Substring(line.Length - 3, 3) == "* -"))
                {
                    line = line.Substring(0, line.Length - 3).Trim();
                }
                if (((line.Substring(line.Length - 1, 1) == "+") || (line.Substring(line.Length - 1, 1) == "-")) || (line.Substring(line.Length - 1, 1) == "*"))
                {
                    line = line.Substring(0, line.Length - 1).Trim();
                }
                if ((line.Length == 6) && flag)
                {
                    fltsegment = line;
                }
                if ((line.Length <= 50) || !flag)
                {
                    continue;
                }
                s = line.Substring(6, 1).Trim();
                if (int.Parse(s) < 1)
                {
                    continue;
                }
                ticketName = line.Substring(7, 15).Trim();
                ticketcode = line.Substring(0x18, 5).Trim();
                ticketseat = line.Substring(30, 1).Trim();
                ticketstat = line.Substring(0x20, 4).Trim();
                str10      = line.Substring(0x26, 6).Trim();
                ticbuydate = line.Substring(0x2d, 7).Trim();
                if (ticbuydate.Length < 7)
                {
                    ticbuydate = flightdate;
                }
                if (line.Length == 0x4b)
                {
                    ticsellagt = line.Substring(0x45, 6);
                }
                else
                {
                    ticsellagt = str10;
                }


                MlbEntity entity = MlbManager.GetAgent(command, ticketName, ticketcode, flightdate, flightcode);
                if (entity == null)
                {
                    if (int.Parse(s) == 1)
                    {
                        MlbManager.Insert(command,
                                          flightdate,
                                          flightcode,
                                          fltsegment,
                                          ticketName,
                                          ticketseat,
                                          ticketcode,
                                          ticketstat,
                                          ticbuydate,
                                          ticsellagt);

                        insertCount++;
                        goto Label_066E;
                    }
                    try
                    {
                        for (num3 = 1; num3 <= int.Parse(s); num3++)
                        {
                            MlbManager.Insert(command, flightdate, flightcode, fltsegment, ticketName + "#" + num3.ToString(), ticketseat, ticketcode, ticketstat, ticbuydate, ticsellagt);
                            insertCount++;
                        }
                        goto Label_066E;
                    }
                    catch (SqlException exception)
                    {
                        MessageBox.Show(string.Concat(new object[] { "代号: ", exception.ErrorCode, ": ", exception.Message, "\n发现无法处理的错误,此行数据将被丢弃,根据新版本解决方案,解析将继续进行\n纠错用SQL指令内容: ", command.CommandText }), "错误:" + exception.ErrorCode, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        continue;
                    }
                }

                if (entity.ticsellagt.Trim() == "PEK1E")
                {
                    /*
                     * int num = entity.Id;
                     * command.CommandText = "UPDATE mlbtable SET ticsellagt='" + ticsellagt + "' WHERE Id=" + num.ToString();
                     * command.CommandType = System.Data.CommandType.Text;
                     * command.ExecuteNonQuery();
                     */
                    MlbManager.Update_ticsellagt(command, entity.Id, ticsellagt);
                }
                Label_066E :;
            }// End While
            connection.Close();
            fileReader.Close();

            /*
             * if (insertCount > 0)
             * {
             *  MessageBox.Show("MLB数据库共提取" + insertCount.ToString() + "条记录", "MLB解析完毕", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             * }
             * else
             * {
             *  MessageBox.Show("MLB数据库未搜索到任何新记录", "MLB解析完毕", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             * }
             */
        }