public static bool Validate (BaseRestPostModel model, WebDbContext db , out Xiake  account,params string[] includies)
 {
     IQueryable<Xiake > query = includies.Aggregate<string, IQueryable<Xiake >>(db.Xiakes , (current, include) => current.Include(include));
     var acc = query.FirstOrDefault(a => a.Id  == model.XiakeID); 
     account = acc;
     if(acc == null)
         throw new JsonException(Resources.ErrorReLogin);
     if(! XCodeHelper.ValidateXCode(model, acc.Token))
         throw new JsonException(Resources.ErrorReLogin);
     return true;
 }
Beispiel #2
0
        public JsonResult XiakeJoin (XiakeJoinPostModel model)
        {
            var result = new XiakeJoinPostResult();
            using(WebDbContext db = DbContextFactory.CreateDbContext())
            {
                var disableLogin = (bool)HttpContext.Application.Get(ApplicationCacheKeys.DISABLE_LOGIN);
                if(disableLogin)
                { 
                    throw new JsonException(HttpContext.Application.Get(ApplicationCacheKeys.DISABLE_LOGIN_REASON).ToString());
                }

                var disableRegister = (bool)HttpContext.Application.Get(ApplicationCacheKeys.DISABLE_REGISTER);
                if (disableRegister)
                { 
                    throw new JsonException(HttpContext.Application.Get(ApplicationCacheKeys.DISABLE_REGISTER_REASON).ToString());
                }

                var xiake = new Xiake
                {
                    XiakeName = model.XiakeName,
                    Password = model.Password,
                    QQ = model.QQ,
                    Mail = model.Mail,
                    Tel = model.Tel,
                    CreateTime = DateTime.Now,
                    RegisterIp = Request.UserHostAddress,
                    Credits = 0,
                    IsAuthorized = true,
                    IsFrozen = false,
                    Token = TokenHelper.MakeToken(),
                    LoginCount = 1,
                    LastLoginTime = DateTime.Now,
                    LastLoginIp = Request.UserHostAddress,
                    UserType = model.XiakeType,
                    Level = XiakeLevel.Guest,
                    Status = XiakeStatus.Enabled,
                    LastReadGonggaoId = 0
                };
                db.Xiakes.Add(xiake);
                db.SaveChanges();
                result.Token = xiake.Token;
                result.XiakeID = xiake.Id;
                result.XiakeNmae = xiake.XiakeName;
                result.Type = xiake.UserType;
                result.Level = xiake.Level;
                result.Token = TokenHelper.MakeToken();
            }
            return new JsonResult {Data = result};
        }
Beispiel #3
0
        private static void MakeInitData ()
        {
            using (var db = DbContextFactory.CreateDbContext())
            {

                var u_admin = new Xiake()
                {
                    Credits = new XiakeCredits(){ FreeCredits=0, FreezeCredits=3},
                    IsAuthorized = true,
                    IsFrozen = false,
                    XiakeName = XiakeNames.MZ_NAME,
                    Password = "******",
                    UserType = XiakeType.Mengzhu,
                    Status = XiakeStatus.Enabled,
                    QQ = "12398845",
                    Mail = "*****@*****.**",
                    Tel = "18681225002",
                    LastLoginTime = DateTime.Now,
                    InviteStorage = new InviteStorage()
                    {
                        
                    }
                };
               
               
  db.Xiakes.Add(u_admin);
                var settings = new ConfigSettings();
                settings.VersionSet.LastVersion = "1.0.0.0";
                var setdata = new Settings();
                setdata.ConfigData = settings.GetXmlString();

                db.Settingses.Add( setdata );
                try
                {
                    db.SaveChanges();
                } catch(Exception e)
                {
                    
                    throw;
                }
                
            }
        }
Beispiel #4
0
        public LoginXiakeData XiakeJoin(string xiakeName, string password, string qq, string mail, string tel, XiakeType xiakeType,string inviteCode)
        {
            var result = new LoginXiakeData();
            using (WebDbContext db = DbContextFactory.CreateDbContext())
            { 
                var settins = ConfigSettings.GetConfigSettings(  db.Settingses.FirstOrDefault().ConfigData);

                if(settins != null && settins.SystemStatusSet.IsDisableRegister)
                {
                    throw new FaultException(settins.SystemStatusSet.DisableRegisterReason);
                }
                if(settins != null && settins.SystemStatusSet.IsDisableSystem)
                {
                    throw new FaultException(settins.SystemStatusSet.DisableSystemReason);
                }

                if(settins.InviteSet.IsEnableInvite && settins.InviteSet.IsRejectNoInviteRegister &&
                   string.IsNullOrEmpty(inviteCode))
                {
                    throw new FaultException("Sorry, 没有邀请码不可注册!");
                }

                if (db.Xiakes.Any(a => a.XiakeName.Equals(xiakeName)))
                {
                    throw new FaultException("用户名已被使用中,请更换");
                }

                if(db.Xiakes.Any(a => a.Mail.Equals(mail)))
                {
                    throw new FaultException("邮箱已被使用中,请更换");
                }

                if (db.Xiakes.Any(a => a.Tel.Equals(tel)))
                {
                    throw new FaultException("手机已被使用中,请更换");
                }

                if (db.Xiakes.Any(a => a.QQ.Equals(qq)))
                {
                    throw new FaultException("QQ已被使用中,请更换");
                }

                var ip = WcfHelper.GetClientIp();
                
                var xiake = new Xiake
                {
                    XiakeName = xiakeName,
                    Password = password,
                    QQ = qq,
                    Mail = mail,
                    Tel = tel, 
                    RegisterIp = ip,
                    Credits =  new XiakeCredits()
                    {
                        FreeCredits=0,
                        FreezeCredits = 0
                    },
                    InviteStorage = new InviteStorage(),
                    IsAuthorized = true,
                    IsFrozen = false, 
                    LoginCount = 1,
                    LastLoginTime = DateTime.Now,
                    LastLoginIp = ip,
                    UserType = xiakeType,
                    Level = XiakeLevel.Guest,
                    Status = XiakeStatus.Enabled,
                    LastReadGonggaoId = 0
                };
                db.Xiakes.Add(xiake);

                var gift = 
                        xiakeType == XiakeType.Biaoju
                            ? settins.CreditsPolicySet.GifrForBiaoju
                            : settins.CreditsPolicySet.GiftForZhanggui;
                if(gift > 0)
                {
                    var charge = new Charge()
                    {
                        ChargeMode = ChargeMode.ByOwner,
                        Comments="新会员赠送",
                        Handler= xiake,
                        PayType= PayType.ByPresent,
                        TargetXiake= xiake,
                        Value = gift
                    };
                
                    xiake.Credits.FreeCredits = charge.Value;
                    db.Charges.Add(charge); 
                }

                if(!string.IsNullOrEmpty(inviteCode))
                {
                    var masterId = InviteCodeHelper.GetXiakeIdWithInviteCode(inviteCode);
                    var master = db.Xiakes.FirstOrDefault(a => a.Id == masterId);
                    if(master == null)
                    {
                        throw new FaultException("Sorry, 邀请码错误!");
                    }
                    var invite = new Invite() {Slave = xiake , Master = master};
                    db.Invites.Add(invite);
                    
                   
                }
                //if(settins.InviteSet.IsEnableInvite)
                //{
                //    var inviteStorage = new InviteStorage() {Credits = 0, Xiake = xiake};
                //    db.InviteStorages.Add(inviteStorage);
                //}
                
                
                db.SaveChanges(); 
                result.ID  = xiake.Id;
                result.Name  = xiake.XiakeName;
                result.XiakeType  = xiake.UserType;
                result.XiakeLevel  = xiake.Level;
                result.Token = Guid.NewGuid().ToString();
                
            }
            return result;
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("准备创建模拟数据,请先删除原始数据库,回车后继续...");
            Console.ReadLine();
            var db = DbContextFactory.CreateDbContext();

            #region 创建管理员帐号
            Console.WriteLine("请输入管理员帐号名称");
            var adminName = Console.ReadLine().Trim();
            var u_admin = new Xiake()
            { 
                Credits = new XiakeCredits(),
                IsAuthorized = true,
                IsFrozen = false,
                XiakeName = adminName,
                Password = "******",
                UserType = XiakeType.Mengzhu,
                Status = XiakeStatus.Enabled,
                QQ = "12345",
                Mail = "*****@*****.**",
                Tel = "18686225002",
                LastLoginTime = DateTime.Now
            };
            db.Xiakes.Add(u_admin);
            var inte = new InviteStorage() {Credits = 0, Xiake = u_admin};
            db.InviteStorages.Add(inte);
            Console.WriteLine("管理员帐号:admin password: ok1234 ");
            #endregion
            #region 创建服务器列表
            {
                Console.WriteLine("请输入服务器URL (net.tcp://xxx:1981/)");
                var url = Console.ReadLine();
                if(string.IsNullOrEmpty(url))
                    url = "net.tcp://*****:*****@qq.com",
                    Tel = "18686225003",
                    LastLoginTime = DateTime.Now 
                };
                db.Xiakes.Add(u_shop);
                var inte2 = new InviteStorage() {Credits = 0, Xiake = u_shop};
                db.InviteStorages.Add(inte2);
                Console.WriteLine("店铺帐号: shop1 , ok1234");
                #endregion
                #region 创建店铺
    {
                
                    //创建三个店铺
                    db.Dianpus.Add(new Dianpu()
                    { 
                        Bangpai= BangpaiType.Taobao,
                        Name="江山水货店",
                        Url="http://js.taobao.com",
                        Zhanggui= u_shop
                    });
                    db.Dianpus.Add(new Dianpu()
                    { 
                        Bangpai = BangpaiType.Taobao,
                        Name = "丽水山货店",
                        Url = "http://ls.taobao.com",
                        Zhanggui = u_shop
                    });
                    db.Dianpus.Add(new Dianpu()
                    {  
                        Bangpai = BangpaiType.Taobao,
                        Name = "温州水货店",
                        Url = "http://wz.taobao.com",
                        Zhanggui = u_shop
                    });
                }
                #endregion
                #region 创建一个刷手帐号
                var u_customer = new Xiake()
                { 
                    Credits = new XiakeCredits(),
                    IsAuthorized = true,
                    IsFrozen = false,
                    XiakeName = "customer",
                    Password = "******",
                    UserType = XiakeType.Biaoju,
                    Status = XiakeStatus.Enabled,
                    QQ = "123456",
                    Mail = "*****@*****.**",
                    Tel = "18686225003",
                    LastLoginTime = DateTime.Now 
              
                };
            
                    db.Xiakes.Add(u_customer);
                    var inte3 = new InviteStorage() { Credits = 0, Xiake = u_customer };
                    db.InviteStorages.Add(inte3);
                Console.WriteLine("刷手: custmoer , ok1234");
            
                #endregion
                #region 创建镖
                var appBiao = new Biao();
                {
                
                    var rundata = string.Format("{0}@{1:D}=1;{2:D}=2;{3:D}=3", "刷单", JubenType.TaobaoCollect , JubenType.TaobaoBuy, JubenType.TaobaoPay);
                    for(var i = 0; i < 120; i++)
                    {
                        var biao = new Biao()
                        {
                            Dianpu = u_shop.Dianpus.First(), 
                            GoodsId = "ASDFASDF321234ASDf",
                            PlanCount = 10,
                            Price = 10,
                            RealCount = 0,
                            Zhanggui = u_shop,
                         
                            Salary = 3,
                            SearchWord= "男 内衣 " + i.ToString(), 
                            Sku = "XL;红色",
                            YqBindPhone = true ,
                            YqBindSfz = false,
                            YqManualCheck = false,
                            YqMonthCount = 10,
                            YqRegisterDate= DateTime.Now,
                            YqUserLevel = 200,
                            YqWeekCount = 5,
                            Steps = rundata,
                            IsEnable = true,
                            Bangpai  = BangpaiType.Taobao,
                            AllowXiakeType = AllowXiakeType.Both
                        };
                        db.Biaos.Add(biao);
                        appBiao = biao;
                    }
                 
                }
                #endregion
                #region 创建镖师
                Biaoshi BS = null;
                {
                
                    for(var i = 0; i < 5; i++)
                    {
                         var biaoshi = new Biaoshi()
                        {
                            Biaoju = u_customer, 
                            Bangpai = BangpaiType.Taobao,
                            Title = "Hai" + i.ToString()
                        };
                        db.Biaoshis.Add(biaoshi);
                        BS = biaoshi;
                    } 
                }
                #endregion
            
                #region 创建帮助
                {
                    var trf = @"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset134 \'ce\'a2\'c8\'ed\'d1\'c5\'ba\'da;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch sdfasdfsd}\li0\ri0\sa0\sb0\fi0\ql\par}  }  }";
                    var help1 = new Help()
                    {
                        Group = "帐户",
                        SortNum = 0,
                        Title = "怎么注册帐号?", 
                        UpdatedTime= DateTime.Now,
                        RtfData = trf  };
                    db.Helps.Add(help1);
               
                    var help2 = new Help()
                    {
                        Group = "帐户",
                        SortNum = 0,
                        Title = "我为什么不能注册帐号?",
                        UpdatedTime = DateTime.Now,
                        RtfData = trf
                    };
                    db.Helps.Add(help2);
                    var help3 = new Help()
                    {
                        Group = "刷单",
                        SortNum = 0,
                        Title = "我要怎么样才可以刷单?",
                        UpdatedTime = DateTime.Now,
                        RtfData = trf
                    };
                    db.Helps.Add(help3);

                    var help4 = new Help()
                    {
                        Group = "刷单",
                        SortNum = 0,
                        Title = "刷单要钱吗?",
                        UpdatedTime = DateTime.Now,
                        RtfData = trf
                    };
                    db.Helps.Add(help4);

                }

                #endregion

                #region 创建公告
                {
                    var trf = @"{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2{\fonttbl{\f0\fcharset0 Times New Roman;}{\f2\fcharset134 \'ce\'a2\'c8\'ed\'d1\'c5\'ba\'da;}}{\colortbl\red0\green0\blue0;\red255\green255\blue255;}\loch\hich\dbch\pard\plain\ltrpar\itap0{\lang1033\fs18\f2\cf0 \cf0\ql{\f2 {\ltrch welcome!}\li0\ri0\sa0\sb0\fi0\ql\par}  }  }";
                    var gg = new Gonggao() {    RtfData = trf};
                    db.Gonggaos.Add(gg);
                }
                #endregion

                #region 创建任务
                {
                    var biaos = u_shop.Biaos.ToArray();


                    for(var i = 0; i < 100; i++)
                    {
                        var biao = biaos[RandomObj.Next(0, biaos.Length)];
                        var rw = new Renwu()
                        {
                            Biao = biao ,
                            Biaoju = u_customer,
                            Biaoshi = u_customer.Biaoshis.First(), 
                            RunTime = DateTime.Now.AddMinutes(2) ,
                            NextStep= JubenType.TaobaoCollect,
                            Steps = "刷单@2=0;1=1;3=0;",
                            Bangpai = biao.Bangpai 
                        };
                        db.Renwus.Add(rw);
                    }
                }
                #endregion
                #region 创建定单
                {
                    for(var i = 0; i < 200; i++)
                    {
                        var biaoshi = u_customer.Biaoshis.First();
                        var dan = new Dingdan()
                        {
                            BiaojuMarkInfo = "ok",
                            BiaojuMarkType = MarkType.Blue,
                            Biaoshi = biaoshi,
                            DateTime = DateTime.Now,
                            Dianpu = u_shop.Dianpus.First(),
                            Goods = "男士内衣" + i.ToString(),
                            Price = 32,
                            Salary = 5,
                            Bangpai = biaoshi.Bangpai
                        };
                        db.Dingdans.Add(dan);
                    }
                }
                #endregion
                #region 创建验证
                {
                    for (var i = 0; i < 5; i++)
                    {
                        var biao = appBiao;
                        var biaoshi = BS;

                        var val = new Validation()
                        {
                            Biao = biao,
                            Biaoshi = biaoshi, 
                            Details = "xxxxx xxx",
                            Zhanggui = biao.Zhanggui,

                        };
                        db.Validations.Add(val);
                    }

                }
                #endregion
                #region 创建付款
                for(var i = 0; i < 100; i++)
                {
                    var pay = new Pay()
                    {
                        Organization = "中国银行",
                        AccountTitle = "12341 2342 32323",
                        Account = "黄药帅" + i ,
                        Price = 32 + i,
                        Credits = 20 + i,
                        Xiake = u_shop
                    };
                    db.Pays.Add(pay);
                }
                #endregion

                #region 创建错误日志
            
                for(var i = 0; i < 10; i++)
                {

                    var log = new JubenErrorLog()
                    {
                        JubenType = JubenType.TaobaoBuy,
                        JubenErrorType = JubenErrorType.Exception,
                        Logs = "asdfsd, asdfa, asdfas",
                        Xiake = u_customer,
                        JubenName = "okokas" + i.ToString()
                    };
                    db.JubenErrorLogs.Add(log);
                }

                for (var i = 0; i < 80; i++)
                {

                    var log = new JubenErrorLog()
                    {
                        JubenType = JubenType.TaobaoGetGoods,
                        JubenErrorType = JubenErrorType.UnCorrect,
                        Logs = "asdfsd, asdfa, asdfas",
                        Xiake = u_shop,
                        JubenName = "ohaisdf as" + i.ToString()
                    };
                    db.JubenErrorLogs.Add(log);
                }

                #endregion 
            }
            
            db.SaveChanges();            
            Console.WriteLine("任务完成");
            Console.ReadLine();
            


        }