/// <summary>
        /// 导出报表类型:Sales by HMNUM
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public String ExportReportByHMList(ReportsModel model)
        {
            using (PermaisuriCMSEntities db = new PermaisuriCMSEntities())
            {
                var adapter       = (IObjectContextAdapter)db;
                var objectContext = adapter.ObjectContext;
                objectContext.CommandTimeout = 5 * 60; // value in seconds

                List <ReportByProductModel> list = new List <ReportByProductModel>();

                String OrderType = "asc";
                String OrderBy   = "UnitsSold";
                if (model.OrderType > 0)
                {
                    OrderType = "desc";
                }
                if (model.OrderBy > 0)
                {
                    switch (model.OrderBy)
                    {
                    case 1:    //order by SKUOrder
                        OrderBy = "HMNUM";
                        break;

                    case 2:    //order by SKUName
                        OrderBy = "HMName";
                        break;

                    case 3:    //  SalesTotal
                        OrderBy = "SalesTotal";
                        break;

                    case 4:    // UnitesSold
                        OrderBy = "UnitsSold";
                        break;

                    case 5:    //AvgAmount
                        OrderBy = "AvgAmount";
                        break;

                    default:
                        OrderBy = "UnitsSold";
                        break;
                    }
                }
                var res = db.Excel_ReportByHM_SP(model.HMNUM, model.HMName, model.Channel, model.Brand,
                                                 model.StartTime, model.EndTime, OrderBy, OrderType).AsEnumerable();

                StringBuilder sw = new StringBuilder("HMNUM,HMNUM Name,Sales Totals ,Units Sold,Avg.Sale Amount");
                sw.AppendLine();

                //直接从DB读取转化为String返回去,少了一层实体类的转化,减少性能损耗....
                // Lee 2013年10月17日17:14:00
                foreach (Excel_ReportByHM_SP_Result r in res)
                {
                    sw.Append(r.HMNUM).Append(",");
                    sw.Append(r.HMName.Replace(",", "-")).Append(",");
                    sw.Append(r.SalesTotal.ConvertToNotNull().ToString("C", new CultureInfo("en-US")).Replace(",", "")).Append(",");
                    sw.Append(r.UnitsSold).Append(",");
                    sw.Append(r.AvgAmont.ConvertToNotNull().ToString("C", new CultureInfo("en-US")).Replace(",", "")).Append(",");
                    sw.AppendLine();
                }
                return(sw.ToString());
            }
        }