protected void Ok_Click(object sender, EventArgs e) { int userId = int.Parse(Request["userId"]); URChannelsService channelService = new URChannelsService(); foreach (Soft soft in UserSofts) { List <ChannelRight> channelRights = new List <ChannelRight>(); if (Request["hiddencateids_" + soft.ID.ToString()] != "-1") { channelRights.AddRange(Request["hiddencateids_" + soft.ID.ToString()].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(p => new ChannelRight { ChannelID = Convert.ToInt32(p), ChannelType = ChannelTypeOptions.Category }).ToList()); channelRights.AddRange(Request["hiddenchannelids_" + soft.ID.ToString()].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(p => new ChannelRight { ChannelID = Convert.ToInt32(p), ChannelType = ChannelTypeOptions.Customer }).ToList()); channelService.AddUserChannelRights(userId, soft.ID, channelRights); } } Response.Redirect(ReturnUrl); }
protected string BindData(int _uid, int _softid) { URChannelsService channelService = new URChannelsService(); List <Channel> channels = channelService.GetChannels(_softid, false); List <ChannelRight> channelRights = channelService.GetUserChannelRights(_uid, _softid); StringBuilder jsonBuilder = new StringBuilder("["); foreach (Channel chl in channels) { bool selected = channelRights.Exists(a => a.ChannelType == chl.ChannelType && a.ChannelID == chl.ID); jsonBuilder.AppendFormat("{{\"id\":\"{0}_{1}\",\"pId\":\"{2}_{3}\",\"name\":\"{4}\",\"val\":{5},\"type\":{6},\"checked\":{7}}}," , (int)chl.ChannelType, chl.ID, (int)chl.ParentChannelType, chl.ParentID, (chl.Platform == 0 ? chl.Name : chl.Name + "(" + chl.Platform + ")").Replace("\"", ""), chl.ID, (int)chl.ChannelType, selected.ToString().ToLower()); } nodeStr = jsonBuilder.ToString().TrimEnd(',') + "]"; return(nodeStr); }
/// <summary> /// 已选择的用户ID列表 /// </summary> /// <returns></returns> protected void GetChannelUserIds() { int softId = Convert.ToInt32(Request["softId"]); int channelId = Convert.ToInt32(Request["channelId"]); ChannelTypeOptions channelType = (ChannelTypeOptions)Convert.ToInt32(Request["channelType"]); List <int> userIds = new URChannelsService().GetUserIds(softId, new ChannelRight { ChannelID = channelId, ChannelType = channelType }); StringBuilder jsonBuilder = new StringBuilder("["); userIds.ForEach((a) => { jsonBuilder.AppendFormat("{0},", a); }); string result = jsonBuilder.ToString().TrimEnd(',') + "]"; Response.Clear(); Response.ContentType = "text/json"; Response.Write(result); Response.End(); }
/// <summary> /// 渠道商管理的渠道树获取 /// </summary> /// <param name="context"></param> /// <returns></returns> public Result GetTree(HttpContext context) { int softId = Convert.ToInt32(context.Request["softs"]); bool showChannelId = Convert.ToInt32(context.Request["showChannelId"]) > 0 ? true : false; List <Channel> channels = new URChannelsService().GetChannels(softId, showChannelId); var jsonBuilder = new StringBuilder("["); foreach (Channel chl in channels) { jsonBuilder.AppendFormat( "{{\"id\":\"{0}_{1}\",\"pId\":\"{2}_{3}\",\"name\":\"{4}\",\"open\":false,\"val\":{5}," + "\"type\":{6},\"checked\":false,\"softid\":\"{7}\",\"drag\":{8}}}," , chl.ChannelType, chl.ID, chl.ParentChannelType, chl.ParentID, (chl.Platform == 0 ? chl.Name : chl.Name + "(" + chl.Platform + ")").Replace("\"", ""), chl.ID, (int)chl.ChannelType, softId, (!(chl.ChannelType == ChannelTypeOptions.Category)).ToString().ToLower()); } string nodes = jsonBuilder.ToString().TrimEnd(',') + "]"; return(Result.GetSuccessedResult(nodes, true)); }
/// <summary> /// 共用的用户留存量 /// </summary> /// <param name="softId"></param> /// <param name="platform"></param> /// <param name="channelId"></param> /// <param name="period"></param> /// <param name="fromDate"></param> /// <param name="toDate"></param> /// <returns></returns> public List <Sjqd_StatChannelRetainedUsers> GetStatRetainedUsers(int softId, int platform, int channelId, net91com.Stat.Core.PeriodOptions period, DateTime fromDate, DateTime toDate, ChannelTypeOptions channelType, URLoginService loginService) { string cmdText; if (channelId > 0 || loginService.LoginUser.AccountType == UserTypeOptions.Channel || loginService.LoginUser.AccountType == UserTypeOptions.ChannelPartner) { List <int> rangeChannelIds = null; if (loginService == null) { rangeChannelIds = new URChannelsService().GetChannelIds(softId, channelType, new int[] { channelId }); } else { rangeChannelIds = channelId > 0 ? loginService.GetAvailableChannelIds(softId, channelType, new int[] { channelId }) : loginService.GetAvailableChannelIds(softId); } if (rangeChannelIds.Count == 0) { return(new List <Sjqd_StatChannelRetainedUsers>()); } string channelIdsString = string.Join(",", rangeChannelIds.Select(a => a.ToString()).ToArray()); //因为有些质量低的渠道不存在留存用户,造成之前的方法在聚合时原始新增量会少 cmdText = string.Format( @"select 0 ChannelID,B.StatDate,B.OriginalDate,{0} Period,{1} SoftID,{2} Platform,A.NewUserCount OriginalNewUserCount,B.RetainedUserCount from (select StatDate,SUM(NewUserCount) NewUserCount from U_StatChannelUsers where SoftID={1} and Platform={2} and Period={0} and StatDate between {3} and {4} and ChannelID IN ({5}) group by StatDate) A inner join (select StatDate,OriginalDate,SUM(RetainedUserCount) RetainedUserCount from U_StatRetainedUsers where SoftID={1} and Platform={2} and Period={0} and OriginalDate between {3} and {4} and ChannelID IN ({5}) GROUP BY StatDate,OriginalDate) B on A.StatDate=B.OriginalDate order by B.OriginalDate desc,B.StatDate desc", (int)period, softId, platform, fromDate.ToString("yyyyMMdd"), toDate.ToString("yyyyMMdd"), channelIdsString); } else { if (platform != 0) { cmdText = string.Format( "select *,0 ChannelID from U_StatRetainedUsers where SoftID={1} and Platform={2} and Period={0} and OriginalDate between {3} and {4} and ChannelID=-1 order by OriginalDate desc ,StatDate desc" , (int)period, softId, platform, fromDate.ToString("yyyyMMdd"), toDate.ToString("yyyyMMdd")); } else //不区分平台 { cmdText = string.Format( @"select * ,0 ChannelID, 0 Platform from (select StatDate,OriginalDate,Period,SoftID,sum(OriginalNewUserCount) OriginalNewUserCount,sum(RetainedUserCount) RetainedUserCount from U_StatRetainedUsers where SoftID={1} and Period={0} and OriginalDate between {2} and {3} and ChannelID=-1 group by StatDate,OriginalDate,Period,SoftID) as temp order by OriginalDate desc ,StatDate desc" , (int)period, softId, fromDate.ToString("yyyyMMdd"), toDate.ToString("yyyyMMdd")); } } if (period == net91com.Stat.Core.PeriodOptions.Daily) { if ((toDate - fromDate).Days > 31) { fromDate = toDate.AddDays(-31); } } List <Sjqd_StatChannelRetainedUsers> retainedUsers = new List <Sjqd_StatChannelRetainedUsers>(); using (IDataReader reader = MySqlHelper.ExecuteReader(statdbConn, cmdText)) { while (reader.Read()) { retainedUsers.Add(RetainedUserBind(reader)); } } return(retainedUsers); }