using System; using System.Collections.Generic; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Text; using System.Web; namespace WX.CRM.WEB.ViewModel.Level2 { public class BatchOrder { /// /// 前缀 /// [DisplayName("前缀")] [Required(ErrorMessage = "前缀不能为空")] public string FirstName { get; set; } /// /// 渠道号 /// [DisplayName("渠道号")] [Required(ErrorMessage = "渠道号不能为空")] public string campaignId { get; set; } /// /// 尾号起始 /// [DisplayName("起始尾号")] [Required(ErrorMessage = "不能为空")] public string LastStartName { get; set; } /// /// 尾号结束 /// [DisplayName("结束尾号")] [Required(ErrorMessage = "不能为空")] public string LastEndName { get; set; } /// /// 产品代码 /// [DisplayName("产品")] [Required(ErrorMessage = "产品不能为空")] public string ProductCode { get; set; } /// /// 限定IP /// [DisplayName("限定IP")] [RegularExpression(@"^((0|(?:[1-9]\d{0,1})|(?:1\d{2})|(?:2[0-4]\d)|(?:25[0-5]))\.){3}((?:[1-9]\d{0,1})|(?:1\d{2})|(?:2[0-4]\d)|(?:25[0-5]))$", ErrorMessage = "IP格式错误")] public string IP { get; set; } /// /// 完整用户名 前缀+下划线+中间4位数+尾号 范例:JMD_1234001 /// public string FullName { get; private set; } public string ProductName { get; set; } public List GetList() { int start = Convert.ToInt32(this.LastStartName); int end = Convert.ToInt32(this.LastEndName); end = end < start ? start : end; List orderList = new List(); for (int i = start; i <= end; i++) { BatchOrder order = new BatchOrder(); order.FirstName = this.FirstName; order.campaignId = this.campaignId; order.LastStartName = this.LastStartName; order.LastEndName = this.LastEndName; order.IP = this.IP; order.ProductCode = this.ProductCode; order.FullName = this.FirstName + i.ToString(); order.ProductName = HttpUtility.UrlDecode(this.ProductName, Encoding.UTF8); orderList.Add(order); } return orderList; } public string getPara() { string para = string.Concat("FirstName=", this.FirstName, "&LastStartName=", this.LastStartName, "&LastEndName=", this.LastEndName, "&ProductCode=", this.ProductCode, "&campaignId=", this.campaignId, "&IP=", this.IP, "&ProductName=", this.ProductName); return para; } } }