public static string GetShortUrl(string url) { WebClient wc = new WebClient(); wc.QueryString.Set("url_long", url); wc.QueryString.Set("source", "1681459862"); string urlPost = "http://api.t.sina.com.cn/short_url/shorten.json"; var stream = wc.OpenRead(urlPost); if (stream == null) { return(null); } StreamReader sr = new StreamReader(stream); string jsonstr = sr.ReadToEnd(); sr.Close(); if (jsonstr.Contains("\"error_code\"")) { LogRunMan.AddLog("短连接生成", EnumListLog.LogLevel.ERROR, DateTime.Now, jsonstr); return(null); } string result = Regex.Match(jsonstr, "(?<=\"url_short\":\").*?(?=\",)").Value; return(result); }
public ActionResult Refresh(string guid, int id) { string logName = "刷新页面停留时间"; string reJson = ""; try { #region 获得参数信息 int sourceId = 0; int.TryParse(PageTools.CookieSourceId, out sourceId); string mobile = PageTools.CookieMobile; LogTrack lt = new LogTrack(); FarmMonitor.BLL.LogTrackMan ltMan = new BLL.LogTrackMan(); if (id > 0) { lt = ltMan.GetEntity(id); } else { lt = ltMan.GetEntity(guid); } #endregion #region 更新数据 if (lt != null) { lt.RefreshTime = DateTime.Now; ltMan.Update(lt); reJson = string.Format(json, "1", "success", "", lt.Id); } else { reJson = string.Format(json, "2", "fail", "", 0); LogRunMan.AddLog(logName, WeDo.Log.Model.EnumListLog.LogLevel.INFO, null, "刷新对象为空"); } #endregion } catch (Exception ex) { LogExceptionMan.AddLog(logName, WeDo.Log.Model.EnumListLog.LogLevel.ERROR, ex); reJson = string.Format(json, "2", "error", "", 0); } return(Content(reJson)); }
public ActionResult DownloadTable() { FormFieldMan formFieldMan = new FormFieldMan(); CampaignInfoMan campaignInfoMan = new CampaignInfoMan(); #region 数据传输 var formId = Request["formId"]; var fields = formFieldMan.GetExportListByForm(Convert.ToInt32(formId)); if (fields == null || fields.Count == 0) { return (Content("<script>alert('表单信息没有找到!');window.location.href='/Report/Report?formId=" + formId + "'</script>")); } var campaignId = Request["campaignId"]; if (string.IsNullOrEmpty(campaignId)) { campaignId = "0"; } var time1 = Request["timeStart"]; var time2 = Request["timeEnd"]; DateTime startTime = Convert.ToDateTime("1990-01-01"); DateTime endTime = Convert.ToDateTime("2090-01-01"); if (!string.IsNullOrEmpty(time1)) { startTime = Convert.ToDateTime(time1); } if (!string.IsNullOrEmpty(time2)) { endTime = Convert.ToDateTime(time2); } var name = Request.Params["name"]; if (string.IsNullOrEmpty(name)) { name = ""; } var mobile = Request.Params["mobile"]; if (string.IsNullOrEmpty(mobile)) { mobile = ""; } //来源渠道 var sourceId = Request.Params["sourceId"]; if (string.IsNullOrEmpty(sourceId)) { sourceId = "0"; } //是否导出 var isExport = Request.Params["isExport"]; if (string.IsNullOrEmpty(isExport)) { isExport = "0"; } #endregion var ciMan = new CustomerInfoMan(); var list0 = ciMan.GetListBySearch(Convert.ToInt32(campaignId), Convert.ToInt32(formId), name, mobile, Convert.ToInt32(sourceId), Convert.ToInt32(isExport), startTime, endTime); var list = list0.ToList(); if (list == null || list.Count == 0) { return (Content("<script>alert('客户信息没有找到!');window.location.href='/Report/Report?formId=" + formId + "'</script>")); } #region 创建表格 DataTable dt = new DataTable(); dt.Columns.Add("活动名称", typeof(string)); foreach (var f in fields) { dt.Columns.Add(f.Name, typeof(string)); if (f.ParentId == 88) { dt.Columns.Add("经销商省份", typeof(string)); dt.Columns.Add("经销商城市", typeof(string)); } } dt.Columns.Add("创建日期", typeof(string)); dt.Columns.Add("来源", typeof(string)); dt.Columns.Add("IP", typeof(string)); dt.Columns.Add("URL", typeof(string)); dt.Columns.Add("唯一标识", typeof(string)); DealerInfoMan diMan = new DealerInfoMan(); SysCityMan cityMan = new SysCityMan(); WXSourceMan sourceMan = new WXSourceMan(); foreach (var customer in list) { Type t = customer.GetType(); var dtRow = dt.NewRow(); dtRow["活动名称"] = campaignInfoMan.CampaignName(customer.CampaignId); foreach (FormField f in fields) { var field = t.GetProperty(f.Code); if (field == null) { dtRow[f.Name] = ""; LogRunMan.AddLog("客户信息导出", EnumListLog.LogLevel.INFO, DateTime.Now, "列名" + f.Code + "没有匹配数据"); } else { if (f.ParentId == 88) { var dealerCode = field.GetValue(customer); var dealer = diMan.GetByCode(dealerCode.ToString()) ?? new DealerInfo(); var province = ""; var city = ""; if (dealer.CityId != 0) { city = cityMan.GetEntity(dealer.CityId).ShortName; } if (dealer.ProvinceId != 0) { province = cityMan.GetEntity(dealer.ProvinceId).ShortName; } dtRow["经销商省份"] = province; dtRow["经销商城市"] = city; } dtRow[f.Name] = field.GetValue(customer); } } dtRow["创建日期"] = customer.CreateTime; var source = sourceMan.GetEntity(customer.SourceId) ?? new WXSource(); dtRow["来源"] = source.SourceName; dtRow["IP"] = customer.IP; dtRow["URL"] = customer.ApplyUrl; dtRow["唯一标识"] = customer.UniqueNo; dt.Rows.Add(dtRow); } ciMan.UpdateToExport(list0); #endregion ExcelHelper.ExportExcel(dt, "客户信息", System.Web.HttpContext.Current); return(Content("<script>alert('导出成功!');window.location.href='/Report/Report?formId=" + formId + "'</script>")); }