Beispiel #1
0
        public AjaxResCode SetVersion()
        {
            var ScanVersionlist             = HwPushCon.Hw_ScanVersion.ToList();
            List <Hw_ScanVersion> SvListNoV = ScanVersionlist.Where(x => x.V == null).ToList();

            List <Hw_ScanVersion> ScanVersionList = DecryptByModel <List <Hw_ScanVersion> >();
            List <Hw_ScanVersion> NewVersionList  = new List <Hw_ScanVersion>();

            int i = 0;

            ScanVersionList.ForEach(x =>
            {
                if (SvListNoV.Where(m => m.Bg == x.Bg && m.Sg == x.Sg).Count() == 0)
                {
                    NewVersionList.Add(x);
                    i++;
                }
            });

            HwPushCon = new HwPushContext();
            HwPushCon.Hw_ScanVersion.AddRange(NewVersionList);
            HwPushCon.SaveChangesAsync();


            AjaxResCode arc = new AjaxResCode();

            arc.Data    = i;
            arc.Message = "添加成功";

            return(arc);
        }
Beispiel #2
0
        public AjaxResCode UpdateIMEI()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                HwPushCon = new HwPushContext();
                var IQqqinfo = HwPushCon.Hw_Users.Where(x => x.QQNumber == this.QQNumber);
                var qqinfo   = IQqqinfo.FirstOrDefault();
                if (qqinfo != null)
                {
                    long reqIMEI = long.Parse(ResultStr);
                    if (IQqqinfo.Where(x => x.Id == qqinfo.Id).Update(x => new Hw_Users {
                        IMEI = reqIMEI
                    }) > 0)
                    {
                        HwPushCon.SaveChanges();
                        return(GetQQInfo());
                    }
                }
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #3
0
        public AjaxResCode SetIMEI()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                string[] results    = ResultStr.Split('|');
                int      id         = int.Parse(results[0]);
                long?    newIMEI    = long.Parse(results[1]);
                int      IsResource = 0;
                if (results.Length > 2)
                {
                    IsResource = int.Parse(results[2]);
                }
                HwPushCon = new HwPushContext();

                var Iusv = HwPushCon.Hw_UserVersionLibrary.Where(x => x.id == id).Update(x => new Hw_UserVersionLibrary {
                    IMEI = newIMEI, IsResource = IsResource
                });

                res.Data = Iusv;
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #4
0
        public AjaxResCode UpdateVersion()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                res.Data = 0;
                Mate8RequestBody Version = DecryptByModel <Mate8RequestBody>();
                rules            rule    = Version.rules;


                Hw_Users u = UsersByQ(QQNumber);
                Hw_UserVersionLibrary Uvl = new Hw_UserVersionLibrary
                {
                    UId        = u.Id,
                    DeviceName = rule.DeviceName,
                    D_version  = rule.D_version,
                    Json       = ResultStr,
                    IsResource = 0,
                    IMEI       = u.IMEI,
                    version    = rule.FirmWare.Split('B')[1].Substring(0, 3),
                    FirmWare   = rule.FirmWare
                };

                HwPushCon = new HwPushContext();

                var Iusv = HwPushCon.Hw_UserVersionLibrary.Where(x => x.UId == Uvl.UId && x.DeviceName == Uvl.DeviceName && x.D_version == Uvl.D_version);
                if (Iusv.Count() == 0)
                {
                    HwPushCon.Hw_UserVersionLibrary.Add(Uvl);
                    if (HwPushCon.SaveChanges() > 0)
                    {
                        res.Data = Uvl.id;
                    }
                }
                else
                {
                    Hw_UserVersionLibrary OldUvl = Iusv.FirstOrDefault();
                    if (OldUvl.IMEI == null)
                    {
                        res.Data = OldUvl.id;
                    }
                }
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #5
0
        public AjaxResCode GetLatestVersion()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                HwPushCon = new HwPushContext();
                var maxver = HwPushCon.Hw_LatestVersion.Where(x => x.DeviceName == ResultStr).Max(m => m.version);
                res.Data = maxver;
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #6
0
        public AjaxResCode GetQQInfo()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                if (!string.IsNullOrWhiteSpace(Ver))
                {
                    int verint = int.Parse(Ver.Replace(".", ""));
                    if (verint < 104)
                    {
                        res.Message    = Ver + "以下版本停用";
                        res.ResultCode = -1;
                        return(res);
                    }
                }
                else
                {
                    res.Message    = "PublicKey.rsa 证书已失效,请重新打开软件";
                    res.ResultCode = -2;
                    return(res);
                }


                HwPushCon = new HwPushContext();
                var qqinfo = HwPushCon.Hw_Users.Where(x => x.QQNumber == this.QQNumber).FirstOrDefault();
                if (qqinfo == null)
                {
                    res.Message    = this.QQNumber + ".rsa 证书已失效,请重新打开软件";
                    res.ResultCode = -2;
                    return(res);
                }
                qqinfo.PrivateKey = "";
                qqinfo.PublicKey  = "";
                qqinfo.QQInfo     = "";

                res.Data       = EncryptByModel(qqinfo);
                res.Message    = "成功";
                res.ResultCode = 1000;
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #7
0
        public AjaxResCode GetQunInfo()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                HwPushCon = new HwPushContext();
                var qqqunlist = HwPushCon.Hw_QunInfo.ToList();

                res.Data    = qqqunlist;
                res.Message = "成功";
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #8
0
        public AjaxResCode GetModelVersion()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                HwPushCon = new HwPushContext();
                var Hw_PhoneModelList = HwPushCon.Hw_PhoneModel.ToList();


                res.Data = EncryptByModel(Hw_PhoneModelList);
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #9
0
        public AjaxResCode GetVersion()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                HwPushCon = new HwPushContext();
                var VersionLibraryQ = HwPushCon.Hw_UserVersionLibrary.Where(x => x.DeviceName == ResultStr && x.IsResource == 1 && x.IMEI != null);
                var maxversion      = VersionLibraryQ.Max(m => m.version);
                var Uvl             = VersionLibraryQ.Where(x => x.version == maxversion).OrderBy(x => Guid.NewGuid()).Take(1).FirstOrDefault();
                res.Data = EncryptByModel(Uvl);
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #10
0
        public AjaxResCode RegQQ()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                var    qqnumber  = this.QQNumber;
                string qqinfostr = this.ResultStr;

                myinfo my_info = DecryptByModel <myinfo>();
                if (my_info != null && qqnumber > 0)
                {
                    string[] rsa = RsaHelper.GenerateKeys();
                    HwPushCon = new HwPushContext();
                    HwPushCon.Hw_Users.Add(new Hw_Users
                    {
                        QQNumber      = qqnumber,
                        UserName      = my_info.result.nick,
                        PrivateKey    = rsa[0],
                        PublicKey     = rsa[1],
                        PrivateKeyMd5 = rsa[2],
                        PublicKeyMd5  = rsa[3],
                        QQInfo        = qqinfostr
                    });
                    HwPushCon.SaveChanges();

                    res.Data       = rsa[0];
                    res.Message    = "注册成功,生成Key";
                    res.ResultCode = 1;
                }
                else
                {
                    res.Data       = "";
                    res.Message    = "注册失败,无法生成Key";
                    res.ResultCode = 2;
                }
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #11
0
        public AjaxResCode GetValidVersion()
        {
            AjaxResCode res = new AjaxResCode();

            try
            {
                HwPushCon = new HwPushContext();
                var ValidVersion = HwPushCon.Hw_UserVersionLibrary.Where(x => x.IsResource == 1 && x.IMEI != null).OrderBy(y => y.FirmWare);
                var s            = ValidVersion.GroupBy(x => x.DeviceName, (x, v) => new
                {
                    FirmWare = v.Max(y => y.FirmWare)
                }).Distinct().ToList();

                res.Data = EncryptByModel(s);
            }
            catch (Exception ee)
            {
                res.Message = ee.Message;
            }
            return(res);
        }
Beispiel #12
0
 protected Hw_Users UsersByQ(long QQNumber)
 {
     HwPushCon = new HwPushContext(); return(HwPushCon.Hw_Users.Where(m => m.QQNumber == QQNumber).FirstOrDefault());
     //return MemoryCacheHelper.GetOrSetCache<Hw_Users>("PublicKey" + QQNumber, delegate () { HwPushCon = new HwPushContext(); return HwPushCon.Hw_Users.Where(m => m.QQNumber == QQNumber).FirstOrDefault(); });
 }