コード例 #1
0
        public ActionResult Add(FreeRecord fr)
        {
            string msg    = "";
            int    result = 0;
            long   id     = fr.ID;

            if (fr.ID > 0)
            {
                result = FreeRecordService.Update(fr);
                if (result > 0)
                {
                    msg = "更新成功";
                }
                else
                {
                    msg = "更新失败";
                }
            }
            else
            {
                result = 0;
                if (fr.UserID > 0 && fr.FreeID > 0)
                {
                    Users user = UsersService.GetInfo(fr.UserID);
                    if (user == null || user.ID <= 0)
                    {
                        msg = "用户ID不正确";
                    }
                    else
                    {
                        result = FreeRecordService.CheckAndInsert(fr.UserID, fr.FreeID, out id);
                        switch (result)
                        {
                        case 0: msg = "添加成功"; break;

                        case 1: msg = "赠品ID不正确"; break;

                        case 2: msg = "赠品已送完"; break;

                        case 3: msg = "活动已结束"; break;

                        case 4: msg = "已申请过赠品"; break;

                        case 5: msg = "添加失败"; break;

                        case 6: msg = "更新赠品失败"; break;

                        case 7: msg = "该用户今天已领过赠品"; break;

                        default: msg = "添加失败"; break;
                        }
                    }
                }
                else
                {
                    msg = "用户ID和赠品ID不能为空";
                }
            }
            return(Content("<script>alert('" + msg + "');window.location.href='" + Url.Content("~/record/add?id=") + id + "';</script>"));
        }
コード例 #2
0
ファイル: GGPKContainer.cs プロジェクト: nindrin/LibGGPK2
        /// <summary>
        /// Load GGPK
        /// </summary>
        /// <param name="path">Path to GGPK file</param>
        public GGPKContainer(string path, bool BundleMode = false)
        {
            // Open File
            fileStream = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
            Reader     = new BinaryReader(fileStream);
            Writer     = new BinaryWriter(fileStream);

            // Read ROOT Directory Record
            BaseRecord ggpk;

            while (!((ggpk = GetRecord()) is GGPKRecord))
            {
                ;
            }
            ggpkRecord         = ggpk as GGPKRecord;
            rootDirectory      = GetRecord(ggpkRecord.RootDirectoryOffset) as DirectoryRecord;
            rootDirectory.Name = "ROOT";

            // Build Linked FreeRecord List
            long NextFreeOffset = ggpkRecord.FirstFreeRecordOffset;

            while (NextFreeOffset > 0)
            {
                FreeRecord current = GetRecord(NextFreeOffset) as FreeRecord;
                LinkedFreeRecords.AddLast(current);
                NextFreeOffset = current.NextFreeOffset;
            }

            if (BundleMode)
            {
                return;
            }
            // Read Bundles
            var Bundles2DirectoryNameHash = MurmurHash2Unsafe.Hash("bundles2", 0);

            OriginalBundles2 = rootDirectory.Children.First(d => d.GetNameHash() == Bundles2DirectoryNameHash) as DirectoryRecord;
            if (OriginalBundles2.Children.FirstOrDefault(r => r.Name == "_.index.bin") is FileRecord _index)
            {
                IndexRecord = _index;
                fileStream.Seek(_index.DataBegin, SeekOrigin.Begin);
                Index        = new IndexContainer(Reader);
                FakeBundles2 = new BundleDirectoryNode("Bundles2", "", MurmurHash2Unsafe.Hash("bundles2", 0), (int)OriginalBundles2.Offset, OriginalBundles2.Length, this);
                rootDirectory.Children.Remove(OriginalBundles2);
                rootDirectory.Children.Add(FakeBundles2);
                foreach (var f in Index.Files)
                {
                    BuildBundleTree(f, FakeBundles2);
                }
            }
            foreach (var br in Index.Bundles)
            {
                RecordOfBundle[br] = (FileRecord)FindRecord(br.Name, OriginalBundles2);
            }
        }
コード例 #3
0
ファイル: FreeRecordService.cs プロジェクト: jilter/project
        public static int CheckAndInsert(long userid, int freeid, out long id)
        {
            id = 0;
            FreeProduct fp = FreeProductService.GetInfo(freeid);

            if (fp == null || fp.ID <= 0)
            {
                return(1);//赠品不存在
            }
            if (fp.RQty <= 0)
            {
                return(2);//赠品已送完
            }
            if (!fp.Status || fp.AddedTime < Convert.ToDateTime(DateTime.Now.ToShortDateString()))
            {
                return(3);//赠品活动已结束
            }
            FreeRecord fr = GetInfo(userid, freeid);

            if (fr != null)
            {
                return(4);//已领取该赠品
            }

            fr = GetTodayRecord(userid);
            if (fr != null)
            {
                return(7);//今天已领过其它赠品了
            }

            fr           = new FreeRecord();
            fr.UserID    = userid;
            fr.FreeID    = freeid;
            fr.FreeLink  = fp.Link;
            fr.Status    = fp.RQty > 0;
            fr.AddedTime = DateTime.Now;
            fr.ID        = Insert(fr);
            id           = fr.ID;
            if (fr.ID > 0)
            {
                fp.RQty = fp.RQty - 1;
                if (GetRecordCount(freeid) >= fp.Count * 2)
                {
                    fp.Status = true;
                }
                int result = FreeProductService.Update(fp);
                return(result > 0 ? 0 : 6);//0成功,6更新赠品信息失败
            }
            else
            {
                return(5);//添加失败
            }
        }
コード例 #4
0
        public ActionResult Add(long?id)
        {
            FreeRecord fr = new FreeRecord();

            if (id.HasValue && id > 0)
            {
                fr = FreeRecordService.GetInfo(id.Value);
                if (fr == null)
                {
                    fr = new FreeRecord();
                }
            }

            return(View(fr));
        }
コード例 #5
0
        /// <summary>
        /// Load GGPK
        /// </summary>
        /// <param name="path">Path to GGPK file</param>
        public GGPKContainer(string path, bool BundleMode = false, bool SteamMode = false, bool BuildTree = true)
        {
            // Steam Mode (No GGPK)
            if (SteamMode)
            {
                if (BundleMode)
                {
                    throw new NotSupportedException("BundleMode and SteamMode cannot be both true");
                }
                Environment.CurrentDirectory = Directory.GetParent(path).FullName;
                Index = new IndexContainer(path);
                if (BuildTree)
                {
                    rootDirectory = FakeBundles2 = new BundleDirectoryNode("Bundles2", "", MurmurHash2Unsafe.Hash("bundles2", 0), 0, 0, this);
                    foreach (var f in Index.Files)
                    {
                        BuildBundleTree(f, rootDirectory);
                    }
                }
                return;
            }

            // Open File
            fileStream = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
            Reader     = new BinaryReader(fileStream);
            Writer     = new BinaryWriter(fileStream);

            // Read ROOT Directory Record
            BaseRecord ggpk;

            while ((ggpk = GetRecord()) is not GGPKRecord)
            {
                ;
            }
            ggpkRecord         = ggpk as GGPKRecord;
            rootDirectory      = GetRecord(ggpkRecord.RootDirectoryOffset) as DirectoryRecord;
            rootDirectory.Name = "ROOT";

            // Build Linked FreeRecord List
            LinkedFreeRecords = new LinkedList <FreeRecord>();
            var NextFreeOffset = ggpkRecord.FirstFreeRecordOffset;

            while (NextFreeOffset > 0)
            {
                FreeRecord current = GetRecord(NextFreeOffset) as FreeRecord;
                LinkedFreeRecords.AddLast(current);
                NextFreeOffset = current.NextFreeOffset;
            }

            // Read Bundles
            OriginalBundles2 = rootDirectory.Children.FirstOrDefault(d => d.GetNameHash() == MurmurHash2Unsafe.Hash("bundles2", 0)) as DirectoryRecord;
            if (OriginalBundles2?.Children.FirstOrDefault(r => r.Name == "_.index.bin") is FileRecord _index)
            {
                IndexRecord = _index;
                if (BundleMode)
                {
                    return;
                }
                fileStream.Seek(_index.DataBegin, SeekOrigin.Begin);
                Index = new IndexContainer(Reader);
                if (BuildTree)
                {
                    FakeBundles2 = new BundleDirectoryNode("Bundles2", "", MurmurHash2Unsafe.Hash("bundles2", 0), (int)OriginalBundles2.Offset, OriginalBundles2.Length, this);
                    rootDirectory.Children.Remove(OriginalBundles2);
                    rootDirectory.Children.Add(FakeBundles2);
                    foreach (var f in Index.Files)
                    {
                        BuildBundleTree(f, FakeBundles2);
                    }
                }
                _RecordOfBundle = new Dictionary <LibBundle.Records.BundleRecord, FileRecord>(Index.Bundles.Length);
            } // else BundleMode = true;
        }
コード例 #6
0
ファイル: FreeRecordService.cs プロジェクト: jilter/project
 public static int Update(FreeRecord fr)
 {
     return(MySqlHelper.context.Update(fr));
 }
コード例 #7
0
ファイル: FreeRecordService.cs プロジェクト: jilter/project
        public static long Insert(FreeRecord fr)
        {
            FreeRecord newP = MySqlHelper.context.Insert(fr);

            return(newP.ID);
        }