예제 #1
0
        /// <summary>
        /// 根据渠道商获取渠道ID
        /// </summary>
        /// <returns></returns>
        private Result GetChannelsByCustomer(HttpContext context)
        {
            int id = Convert.ToInt32(context.Request["customerid"]);
            Sjqd_ChannelCustomers m = SjqdChannelCustomers_DataAccess.Instance.GetCustomerModulus(id);
            //父级系数
            decimal m1     = m.Modulus1;
            int     softid = Convert.ToInt32(context.Request["softs"]);
            var     list   = new List <object>();
            List <Sjqd_Channels> channelsList = SjqdChannels_DataAccess.Instance.GetChannelsByCustomID(id, softid);

            foreach (Sjqd_Channels item in channelsList)
            {
                list.Add(
                    new
                {
                    ID = item.AutoID,
                    item.Name,
                    Platform = item.Platform.ToString(),
                    item.Modulus1
                });
            }
            m1 = (m1 == 0m ? 1m : m1);
            var    sb  = new StringBuilder("{");
            string res = string.Format("\"m1\":\"{0}\",", m1.ToString());

            sb.Append(res);
            sb.Append("\"data\":");
            sb.Append(JsonConvert.SerializeObject(list));
            sb.Append("}");
            return(Result.GetSuccessedResult(sb.ToString(), true));
        }
예제 #2
0
        private Result AddCateCustom(HttpContext context)
        {
            var    loginService = new URLoginService();
            string name         = HttpUtility.HtmlEncode(context.Request["name"]);
            int    cateid       = Convert.ToInt32(context.Request["cateid"]);
            int    softid       = Convert.ToInt32(context.Request["softs"]);
            var    custom       = new Sjqd_ChannelCustomers();

            //默认值
            custom.IsRealtime = 0;
            custom.Name       = name;
            custom.ReportType = 0;
            custom.PID        = 0;
            custom.CID        = cateid;
            custom.SoftID     = softid;
            custom.AddTime    = DateTime.Now;
            int result = SjqdChannelCustomers_DataAccess.Instance.AddChannelCustomer(custom);

            if (result > 0)
            {
                loginService.AddLog("AddChannelCustomer",
                                    string.Format("添加渠道商(ID={0},SoftID={1},PID={2},CID={3},Name={4})", result, softid,
                                                  custom.PID, custom.CID, custom.Name));
                return(Result.GetSuccessedResult(result, "保存成功!", true));
            }
            else
            {
                return(Result.GetFailedResult("该名称渠道商已经存在,保存失败!"));
            }
        }
예제 #3
0
        /// <summary>
        ///     获取渠道商信息根据渠道商ID
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private Result GetCustomerById(HttpContext context)
        {
            int id = Convert.ToInt32(context.Request["id"]);
            Sjqd_ChannelCustomers obj = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(id);

            obj.Keyfornd  = CryptoHelper.DES_Encrypt(id.ToString());
            obj.Keyforout = CryptoHelper.DES_Encrypt(id.ToString(), "ndwebweb");
            var list = new List <int> {
                0, 1, 4, 7, 9
            };

            obj.Keyforout_RetainDic = new Dictionary <string, string>();
            for (int i = 0; i < list.Count; i++)
            {
                obj.Keyforout_RetainDic.Add(list[i].ToString(),
                                            CryptoHelper.DES_Encrypt(id + "&" + list[i], "$retain^"));
            }

            //这里做了个特殊处理创建一个临时result 序列化后再页面控制输出
            Result result = Result.GetSuccessedResult();

            result.data = obj;
            var timeConverter = new IsoDateTimeConverter();

            timeConverter.DateTimeFormat = "yyyy-MM-dd";
            string json = JsonConvert.SerializeObject(result, timeConverter);

            return(Result.GetSuccessedResult(json, true, true));
        }
예제 #4
0
        /// <summary>
        ///     设置渠道商系数参数
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private Result SetCustomerSwitch(HttpContext context)
        {
            var loginService = new URLoginService();
            int soft         = Convert.ToInt32(context.Request["softs"]);
            int id           = Convert.ToInt32(context.Request["id"]);
            int switchtype   = Convert.ToInt32(context.Request["switchtype"]);
            int switchvalue  = Convert.ToInt32(context.Request["switchvalue"]);
            //这里不要使用GetChannelCustomeById 方法 因为获取到的cid 就是标准的cid
            Sjqd_ChannelCustomers obj = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(id);

            //对外链接地址开关设置
            if (switchtype == 1)
            {
                obj.ReportType = switchvalue;
            }
            else if (switchtype == 2)
            {
                obj.ShowType = switchvalue;
            }
            if (SjqdChannelCustomers_DataAccess.Instance.UpdateChannelCustomer(obj) >= 0)
            {
                loginService.AddLog(string.Format("设置渠道商开关,softid:{3},customerid:{0},switchtype:{1},switchvalue:{2}", id,
                                                  switchtype, switchvalue, soft));

                return(Result.GetSuccessedResult("", "设置成功!", true));
            }
            else
            {
                return(Result.GetFailedResult("设置失败!"));
            }
        }
        public Result GetChart(HttpContext context)
        {
            DateTime  begintime = Convert.ToDateTime(context.Request["begintime"]);
            DateTime  endtime   = Convert.ToDateTime(context.Request["endtime"]);
            DataTable dtresult  = GetTable(context);
            var       lines     = new List <LineChartLine>();
            var       points    = new List <LineChartPoint>();

            for (int i = 0; i < dtresult.Rows.Count; i++)
            {
                points.Add(new LineChartPoint
                {
                    DataContext = "",
                    NumberType  = 1,
                    Description = "",
                    YValue      = Convert.ToInt32(dtresult.Rows[i]["newnum"]).ToString(),
                    XValue      = dtresult.Rows[i]["statdate"].ToString()
                });
            }
            lines.Add(new LineChartLine {
                Name = "新增用户", Points = points, Show = true
            });
            //若可以支持活跃
            int channelid = Convert.ToInt32(context.Request["channelid"]);
            Sjqd_ChannelCustomers customer = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(channelid);
            int showType = customer == null ? 0 : customer.ShowType;

            if (showType == 1)
            {
                var points2 = new List <LineChartPoint>();
                for (int i = 0; i < dtresult.Rows.Count; i++)
                {
                    points2.Add(new LineChartPoint
                    {
                        DataContext = "",
                        NumberType  = 1,
                        Description = "",
                        YValue      = Convert.ToInt32(dtresult.Rows[i]["activenum"]).ToString(),
                        XValue      = dtresult.Rows[i]["statdate"].ToString()
                    });
                }
                lines.Add(new LineChartLine {
                    Name = "活跃用户", Points = points2, Show = true
                });
            }
            var    line   = new LineChart(GetXLine(begintime, endtime), lines);
            string result = "{ x:" + line.GetXJson(p => { return(""); }) + ",y:" + line.GetYJson(p => { return(""); }) +
                            ",title:'" + "渠道新增" + "'}";

            return(Result.GetSuccessedResult(result, true));
        }
예제 #6
0
        /// <summary>
        /// 更新渠道商
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="canUpdateName">能修改名称</param>
        /// <returns></returns>
        public int UpdateChannelCustomer(Sjqd_ChannelCustomers customer, bool canUpdateName = false)
        {
            string cmdText = string.Format(
                @"update Cfg_ChannelCustomers set {0}Modulus1={1},PID={2},CID={3},ShowType={4},ReportType={5},MinViewTime='{6}' where ID={7}"
                , canUpdateName ? "`Name`='" + customer.Name.Replace("'", "''") + "'," : ""
                , customer.Modulus1
                , customer.PID
                , customer.CID
                , customer.ShowType
                , customer.ReportType
                , customer.MinViewTime.ToString("yyyy-MM-dd HH:mm:ss")
                , customer.ID);

            return(MySqlHelper.ExecuteNonQuery(StatDB_ConnString, cmdText));
        }
        /// <summary>
        ///     获取table中数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Result GetPage(HttpContext context)
        {
            DataTable dtresult = GetTable(context);
            var       dt       = new JQueryDataTableData();
            var       param    = new DataTablesRequest(context.Request);

            dt.sEcho         = param.sEcho;
            dt.iTotalRecords = dt.iTotalDisplayRecords = dtresult.Rows.Count;

            int channelid = Convert.ToInt32(context.Request["channelid"]);
            Sjqd_ChannelCustomers customer = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(channelid);
            int showType = customer == null ? 0 : customer.ShowType;

            dt.aaData = GetStringList(dtresult, showType);
            return(Result.GetSuccessedResult(dt, false));
        }
예제 #8
0
        /// <summary>
        ///     添加渠道商
        /// </summary>
        /// <returns></returns>
        private Result AddBatchCustomer(HttpContext context)
        {
            var    loginService = new URLoginService();
            string nameprefix   = HttpUtility.HtmlEncode(context.Request["nameprefix"]);
            int    begin        = Convert.ToInt32(context.Request["beginnum"]);
            int    end          = Convert.ToInt32(context.Request["endnum"]);

            if ((end - begin) >= 20)
            {
                end = begin + 19;
            }
            int id       = Convert.ToInt32(context.Request["parentcustomerid"]);
            int cid      = Convert.ToInt32(context.Request["cid"]);
            int soft     = Convert.ToInt32(context.Request["softs"]);
            int resultid = 0;

            Sjqd_ChannelCustomers obj = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(id);

            for (int i = begin; i <= end; i++)
            {
                string name   = nameprefix + i;
                var    custom = new Sjqd_ChannelCustomers();
                custom.IsRealtime = 0;
                custom.Name       = name;
                //默认值
                custom.ReportType = 0;
                custom.PID        = id;
                custom.CID        = cid;
                custom.SoftID     = soft;
                if (obj != null)
                {
                    custom.CID    = obj.CID;
                    custom.SoftID = obj.SoftID;
                }

                resultid = SjqdChannelCustomers_DataAccess.Instance.AddChannelCustomer(custom);
                if (resultid > 0)
                {
                    loginService.AddLog("AddChannelCustomer",
                                        string.Format("添加渠道商(ID={0},SoftID={1},PID={2},CID={3},Name={4})", resultid,
                                                      soft, custom.PID, custom.CID, custom.Name));
                }
            }
            return(Result.GetSuccessedResult(resultid, "添加成功!", true));
        }
예제 #9
0
        //添加同级渠道商
        private Result AddSameLevelCustomer(HttpContext context)
        {
            var    loginService      = new URLoginService();
            string name              = HttpUtility.HtmlEncode(context.Request["name"]);
            int    softid            = Convert.ToInt32(context.Request["softs"]);
            int    samelevelcustomer = Convert.ToInt32(context.Request["samelevelcustomerid"]);
            //获取来源目标的类型
            Sjqd_ChannelCustomers parentcustomer =
                SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(samelevelcustomer);

            if (parentcustomer.ID == 0)
            {
                return(Result.GetFailedResult("添加失败!"));
            }
            var custom = new Sjqd_ChannelCustomers();

            custom.IsRealtime = 0;
            custom.Name       = name;
            //默认值
            custom.ReportType = 0;
            custom.PID        = parentcustomer.PID;
            custom.CID        = parentcustomer.CID;
            custom.SoftID     = parentcustomer.SoftID;
            custom.AddTime    = DateTime.Now;
            //若不是顶级渠道商,需要将父级渠道商属性赋予
            if (custom.PID != 0)
            {
                Sjqd_ChannelCustomers obj = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(custom.PID);
            }
            int resultid = SjqdChannelCustomers_DataAccess.Instance.AddChannelCustomer(custom);

            if (resultid > 0)
            {
                loginService.AddLog("AddChannelCustomer",
                                    string.Format("添加渠道商(ID={0},SoftID={1},PID={2},CID={3},Name={4})", resultid, softid,
                                                  custom.PID, custom.CID, custom.Name));
                return(Result.GetSuccessedResult(resultid, "添加成功!", true));
            }
            else
            {
                return(Result.GetFailedResult("添加失败!"));
            }
        }
예제 #10
0
        /// <summary>
        /// 添加渠道商(关于山寨机参数在添加时候默认要设置成null的,保证继承关系)
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public int AddChannelCustomer(Sjqd_ChannelCustomers customer)
        {
            if (!new URLoginService().AvailableSofts.Exists(a => a.ID == customer.SoftID))
            {
                throw new NotRightException();
            }
            string cmdText = string.Format(@"insert into Cfg_ChannelCustomers(`Name`,IsRealtime,PID,CID,Modulus1,Modulus2,ReportType,AddTime,SoftID) 
                                                values('{0}',{1},{2},{3},{4},{5},{6},now(),{7});
                                             select ID from Cfg_ChannelCustomers where `Name`='{0}' and PID={2} and CID={3};"
                                           , customer.Name.Replace("'", "''")
                                           , customer.IsRealtime
                                           , customer.PID
                                           , customer.CID
                                           , customer.Modulus1
                                           , customer.Modulus2
                                           , customer.ReportType
                                           , customer.SoftID);
            object result = MySqlHelper.ExecuteScalar(StatDB_ConnString, cmdText);

            return(result == null || result == DBNull.Value ? 0 : Convert.ToInt32(result));
        }
예제 #11
0
        /// <summary>
        ///     添加渠道商
        /// </summary>
        /// <returns></returns>
        private Result AddCustomer(HttpContext context)
        {
            var    loginService = new URLoginService();
            string name         = HttpUtility.HtmlEncode(context.Request["name"]);
            int    id           = Convert.ToInt32(context.Request["parentcustomerid"]);
            int    cid          = Convert.ToInt32(context.Request["cid"]);
            int    soft         = Convert.ToInt32(context.Request["softs"]);
            var    custom       = new Sjqd_ChannelCustomers();

            custom.IsRealtime = 0;
            custom.Name       = name;
            //默认值
            custom.ReportType = 0;
            custom.PID        = id;
            custom.CID        = cid;
            custom.SoftID     = soft;
            custom.AddTime    = DateTime.Now;
            Sjqd_ChannelCustomers obj = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(id);

            if (obj != null)
            {
                custom.CID    = obj.CID;
                custom.SoftID = obj.SoftID;
            }
            int resultid = SjqdChannelCustomers_DataAccess.Instance.AddChannelCustomer(custom);

            if (resultid > 0)
            {
                loginService.AddLog("AddChannelCustomer",
                                    string.Format("添加渠道商(ID={0},SoftID={1},PID={2},CID={3},Name={4})", resultid, soft,
                                                  custom.PID, custom.CID, custom.Name));
                return(Result.GetSuccessedResult(resultid, "添加成功!", true));
            }
            else
            {
                return(Result.GetFailedResult("添加失败!"));
            }
        }
예제 #12
0
        /// <summary>
        /// 获取渠道系数和山寨机真实继承的系数(递归)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Sjqd_ChannelCustomers GetCustomerModulus(int id)
        {
            int tempId = id;

            while (true)
            {
                string cmdText = string.Format("select ID,PID,Modulus1 from Cfg_ChannelCustomers where ID={0}", tempId);
                using (IDataReader reader = MySqlHelper.ExecuteReader(StatDB_ConnString, cmdText))
                {
                    if (reader.Read())
                    {
                        Sjqd_ChannelCustomers customer = new Sjqd_ChannelCustomers(reader);
                        if (customer.Modulus1 == 0 && customer.PID > 0)
                        {
                            tempId = customer.PID;
                            continue;
                        }
                        customer.ID = id;
                        return(customer);
                    }
                    return(null);
                }
            }
        }
        /// <summary>
        ///     资源下载excel
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private Result GetExcel(HttpContext context)
        {
            DataTable             dtresult  = GetTable(context);
            int                   channelid = Convert.ToInt32(context.Request["channelid"]);
            Sjqd_ChannelCustomers customer  = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(channelid);
            int                   showType  = customer == null ? 0 : customer.ShowType;
            List <List <string> > result    = GetStringList(dtresult, showType);

            SetDownHead(context.Response, "新增量.xls");
            string html = string.Empty;

            string[] str = null;
            if (showType == 1)
            {
                str = new[] { "日期", "新增量", "活跃量" };
            }
            else
            {
                str = new[] { "日期", "新增量", "" }
            };
            html = GetTableHtml(str, result);
            return(Result.GetSuccessedResult(html, false, true));
        }
    }
예제 #14
0
        /// <summary>
        ///     更新渠道商系数和名称
        /// </summary>
        /// <returns></returns>
        private Result UpdateCustomer(HttpContext context)
        {
            //pc 产品列表
            var softList = new[] { 9, 105550, 72, 57, 68, 69 };

            var      loginService        = new URLoginService();
            int      soft                = Convert.ToInt32(context.Request["softs"]);
            int      id                  = Convert.ToInt32(context.Request["id"]);
            decimal  m1                  = Convert.ToDecimal(context.Request["m1"]);
            string   name                = HttpUtility.HtmlEncode(context.Request["name"]);
            int      showtype            = Convert.ToInt32(context.Request["showtype"]);
            DateTime minViewTime         = Convert.ToDateTime(context.Request["minviewtime"]);
            bool     needEditSonCustomer = Convert.ToBoolean(context.Request["needEditSonCustomer"]);
            //开放给外部
            int reporttype = Convert.ToInt32(context.Request["reporttype"]);


            //这里不要使用GetChannelCustomeById 方法 因为获取到的cid 就是标准的cid
            Sjqd_ChannelCustomers customer = SjqdChannelCustomers_DataAccess.Instance.GetChannelCustomer(id);

            //minviewtime 若没传 用其老的minviewtime
            if (context.Request["minviewtime"] == null)
            {
                minViewTime = customer.MinViewTime;
            }
            string   oldName             = customer.Name;
            int      oldreporttype       = customer.ReportType;
            int      oldmodulus_Shanzhai = customer.Modulus_Shanzhai;
            decimal  oldm1       = customer.Modulus1;
            int      oldShowType = customer.ShowType;
            DateTime oldmintime  = customer.MinViewTime;

            customer.MinViewTime = minViewTime;
            customer.Modulus1    = m1;
            customer.Name        = name;
            customer.ReportType  = reporttype;
            bool canUpdateName = true;

            //有传入就修改
            if (context.Request["showtype"] != null)
            {
                customer.ShowType = Convert.ToInt32(context.Request["showtype"]);
            }
            if (name != oldName &&
                SjqdChannelCustomers_DataAccess.Instance.GetCustomerCount(customer.CID, customer.PID, customer.Name) > 1)
            {
                return(Result.GetFailedResult("修改失败,已经存在对应名称渠道商!"));
            }
            if (SjqdChannelCustomers_DataAccess.Instance.UpdateChannelCustomer(customer, canUpdateName) >= 0)
            {
                loginService.AddLog(
                    "UpdateChannelCustomer"
                    ,
                    string.Format(
                        "修改渠道商(ID={0},SoftID={1},Name={2}(Old={3}),Modulus1={4}(Old={5}),MinViewTime={6}(Old={7}),ReportType={8}(Old={9}),ShowType={10}(Old={11})",
                        id, soft, name, oldName, m1, oldm1, oldmintime, minViewTime, oldmintime, customer.ReportType,
                        oldreporttype, customer.ShowType, oldShowType));
                return(Result.GetSuccessedResult("", "修改成功!", true));
            }
            else
            {
                return(Result.GetFailedResult("修改失败!"));
            }
        }
예제 #15
0
        /// <summary>
        /// 修改渠道商位置 返回2 表示名称相同的合并了, 返回1 表示没有出现名称相同,只是改了pid
        /// </summary>
        /// <param name="targetId"></param>
        /// <param name="targetType"></param>
        /// <param name="sourceId"></param>
        /// <returns></returns>
        public int ChangeChannelCustomerPosition(int targetId, int targetType, int sourceId)
        {
            Sjqd_ChannelCustomers sourceCustomer = GetChannelCustomer(sourceId);

            if (sourceCustomer == null)
            {
                throw new NotRightException();
            }

            if (!new URLoginService().AvailableSofts.Exists(a => a.ID == sourceCustomer.SoftID))
            {
                throw new NotRightException();
            }

            string cmdText;
            string customerIds = sourceId.ToString();
            string pid         = sourceId.ToString();

            while (true)
            {
                cmdText = string.Format("select ID from Cfg_ChannelCustomers where PID in ({0})", pid);
                using (IDataReader reader = MySqlHelper.ExecuteReader(StatDB_ConnString, cmdText))
                {
                    pid = string.Empty;
                    while (reader.Read())
                    {
                        pid += "," + reader["ID"].ToString();
                    }
                    if (pid == string.Empty)
                    {
                        break;
                    }
                    customerIds += pid.ToString();
                    pid          = pid.TrimStart(',');
                }
            }
            string commonCmdText = @"update Cfg_ChannelCustomers set CID={0} where ID in ({1}) and CID<>{0};";
            int    parentId;

            //移到某分类下
            if (targetType == 1)
            {
                cmdText = string.Format("select ID from Cfg_ChannelCustomers where PID=0 and CID={0} and `Name`='{1}'",
                                        targetId, sourceCustomer.Name.Replace("'", "''"));
                object result = MySqlHelper.ExecuteScalar(StatDB_ConnString, cmdText);
                cmdText = string.Format(commonCmdText, targetId, customerIds);
                if (result == null || result == DBNull.Value)
                {
                    cmdText += string.Format("update Cfg_ChannelCustomers set PID=0 where ID={0} and PID<>0;", sourceId);
                    MySqlHelper.ExecuteNonQuery(StatDB_ConnString, cmdText);
                    return(1);
                }
                parentId = Convert.ToInt32(result);
            }
            else
            {
                Sjqd_ChannelCustomers targetCustomer = GetChannelCustomer(targetId);
                if (targetCustomer == null || targetCustomer.SoftID != sourceCustomer.SoftID || targetId == sourceId)
                {
                    throw new NotRightException();
                }

                cmdText = string.Format("select ID from Cfg_ChannelCustomers where PID={0} and Name='{1}'", targetId,
                                        sourceCustomer.Name.Replace("'", "''"));
                object result = MySqlHelper.ExecuteScalar(StatDB_ConnString, cmdText);
                cmdText = string.Format(commonCmdText, targetCustomer.CID, customerIds);
                if (result == null || result == DBNull.Value)
                {
                    cmdText += string.Format("update Cfg_ChannelCustomers set PID={1} where ID={0} and PID<>{1};",
                                             sourceId, targetId);
                    MySqlHelper.ExecuteNonQuery(StatDB_ConnString, cmdText);
                    return(1);
                }
                parentId = Convert.ToInt32(result);
            }
            cmdText += string.Format(@"update Cfg_ChannelCustomers set PID={0} where PID={1};
	                                   update Cfg_Channels set CCID={0} where CCID={1};
                                       delete from Cfg_ChannelCustomers where ID={1}  
                                            and not exists(select * from Cfg_ChannelCustomers where PID={1}) 
                                            and not exists(select * from Cfg_Channels where CCID={1});", parentId,
                                     sourceId);
            MySqlHelper.ExecuteNonQuery(StatDB_ConnString, cmdText);
            return(2);
        }