public static string SelectUNnormalPriceSTrans(EUNnormalPriceS rqInfo)
        {
            string guidStrJianJclFirst = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
            string resultFileName = @"E:\PPrice\jianjcl" + guidStrJianJclFirst + ".xml";
            if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(resultFileName)))
            { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(resultFileName)); }

            XmlTextWriter result = new XmlTextWriter(resultFileName, null);
            try
            {
                if (rqInfo.Success == true)
                {
                    result.WriteStartElement("BasicUnNormalPrice");
                    result.WriteStartElement("UnNormalPrices");
                    NPPrice port = new NPPrice();
                    if (rqInfo.listunpbi != null && rqInfo.listunpbi.Count > 0)
                    {
                        for (int i = 0; i < rqInfo.listunpbi.Count; i++)
                        {
                            port = (NPPrice)rqInfo.listunpbi[i];
                            result.WriteStartElement("UnNormalPrice");
                            // 特价运价ID|航司|出发|到达|销售开始日期|销售结束日期|旅行开始日期|旅行结束日期|舱位等级|舱位|票面价|折扣|运价基础|...|运价来源|修改时间
                            string listValue = port.ID + "|" + port.AirCompany + "|" + port.DepartCode + "|" + port.ArriveCode.ToString() + "|" + port.SaleBeginTime.ToString() + "|" + port.SaleEndTime.ToString() + "|" + port.TravelBeginTime.ToString() + "|" + port.TravelEndTime.ToString() + "|" + port.Price.ToString() + "|" + 0 + "|" + port.PriceBase.ToString() + "|" + port.Agio + "|" + port.PriceSource + "|" + port.AdvanceStartDay.ToString() + "|" + port.AdvanceEndDay.ToString() + "||||" + port.ApplyFlightNumber.ToString() + "|" + port.WeekNum + "|" + port.AddTime.ToString() + "|" + port.Cabin.ToString() + "|" + port.NotApplyFlightNumber.ToString() + "|||" + port.ApplyIntervalTime.ToString() + "|" + port.ModifyTime.ToString() + "|" + port.Status.ToString();

                            result.WriteString(listValue);
                            result.WriteEndElement();
                            listValue = null;
                        }
                    }
                    result.WriteEndElement();
                    result.WriteEndElement();
                    result.Flush();
                    result.Close();
                    GC.Collect();
                    XmlDocument xml = new XmlDocument();
                    xml.Load(resultFileName);
                    return xml.OuterXml;
                }
                else
                {
                    return "<BasicUnNormalPrice><UnNormalPrices><BasicUnNormalPrice><Error Code='900001'>" + rqInfo.Msg.ToString() + "</Error></BasicUnNormalPrice></UnNormalPrices></BasicUnNormalPrice>";
                }
            }
            catch (Exception ex) {  return "<BasicUnNormalPrice><UnNormalPrices><BasicUnNormalPrice><Error Code='900001'>" + ex.Message.ToString() + "</Error></BasicUnNormalPrice></UnNormalPrices></BasicUnNormalPrice>"; }
            finally
            {
                File.Delete(resultFileName);
                GC.Collect();
            }
        }

 

posted on 2014-01-07 11:16  王洪洪  阅读(1590)  评论(0编辑  收藏  举报