Beispiel #1
0
        public bool NewPackageSubscription(InvestmentCreateModel model, HttpPostedFileBase ReceiptFile, int userId)
        {
            try
            {
                if (ReceiptFile.IsImage())
                {
                    string fileExt     = Path.GetExtension(ReceiptFile.FileName);
                    string newFileName = (DBConstant.UploadReceiptPrefix + DateTime.UtcNow.ConvertToPlainDateTimeString() + Guid.NewGuid().ToString() + fileExt).ToLower();
                    new ImageController().Upload(ConfigurationManager.AppSettings["UploadReceiptPhotoPath"], ReceiptFile, newFileName);

                    var package = _investmentService.GetEntitledPackage(model.Amount);

                    UserPackage up = new UserPackage
                    {
                        PackageId        = package.PackageId,
                        UserId           = userId,
                        TotalAmount      = model.Amount,
                        CreatedTimestamp = DateTime.UtcNow,
                        ReceiptBank      = model.Bank,
                        ReceiptImagePath = newFileName,
                        ReceiptNo        = model.ReferenceNo ?? "",
                        InterestRate     = package.Rate,
                        StatusId         = (int)EStatus.Pending,
                    };

                    _investmentService.InsertUserPackage(up);
                    return(_investmentService.SaveChange(userId));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
            }
            return(false);
        }
Beispiel #2
0
    protected override void Awake()
    {
        base.Awake();
        contentLabel            = transform.Find("board/panel/label").GetComponent <UILabel>();
        scrollView              = transform.Find("board/panel").GetComponent <UIScrollView>();
        sanctuaryPackage        = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage;
        mailPackage             = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Mail) as MailPackage;
        userPackage             = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        playerViewList[0].name  = transform.Find("grid/player0/name").GetComponent <UILabel>();
        playerViewList[1].name  = transform.Find("grid/player1/name").GetComponent <UILabel>();
        playerViewList[2].name  = transform.Find("grid/player2/name").GetComponent <UILabel>();
        playerViewList[3].name  = transform.Find("grid/player3/name").GetComponent <UILabel>();
        playerViewList[0].level = transform.Find("grid/player0/level").GetComponent <UILabel>();
        playerViewList[1].level = transform.Find("grid/player1/level").GetComponent <UILabel>();
        playerViewList[2].level = transform.Find("grid/player2/level").GetComponent <UILabel>();
        playerViewList[3].level = transform.Find("grid/player3/level").GetComponent <UILabel>();
        playerViewList[0].blood = transform.Find("grid/player0/health").GetComponent <UIProgressBar>();
        playerViewList[1].blood = transform.Find("grid/player1/health").GetComponent <UIProgressBar>();
        playerViewList[2].blood = transform.Find("grid/player2/health").GetComponent <UIProgressBar>();
        playerViewList[3].blood = transform.Find("grid/player3/health").GetComponent <UIProgressBar>();
        //bind event
        UIButton button = transform.Find("closebtn").GetComponent <UIButton>();

        button.onClick.Add(new EventDelegate(Close));
        FacadeSingleton.Instance.RegisterEvent("OpenInvadeResult", OpenInvadeResult);
    }
Beispiel #3
0
 public UserPackageMinimalViewModel(UserPackage userPackage, string userId)
 {
     Id = userPackage.Id;
     UserPackageState = userPackage.UserPackageState;
     Package          = new PackageMinimalViewModel(userPackage.Package, userId);
     UserName         = userPackage.ApplicationUser.UserName;
 }
Beispiel #4
0
    public void Initialize(NDictionary args)
    {
        SanctuaryPackage sanctuaryPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage;
        int      configID = args.Value <int>("id");
        bool     isUnlock = args.Value <bool>("isunlock");
        UILabel  label    = transform.Find("label").GetComponent <UILabel>();
        BUILDING config   = ConfigDataStatic.GetConfigDataTable("BUILDING")[configID] as BUILDING;

        if (isUnlock == true)
        {
            label.text = string.Format("{0} Lv.{1}", config.BldgName, sanctuaryPackage.GetBulidingLevelByConfigID(configID));
        }
        else
        {
            UserPackage userPackage  = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
            int         curLevel     = userPackage.GetManorLevel();
            int         requireLevel = config.BldgLvLim;
            if (curLevel >= requireLevel)
            {
                label.text = string.Format("[90FF15]可解锁[-]");
            }
            else
            {
                label.text = string.Format("庄园Lv.{0} 解锁", requireLevel);
            }
        }
        name = config.BldgName;
    }
Beispiel #5
0
    private void Awake()
    {
        NEventListener listener = GetComponent <NEventListener>();

        listener.AddClick(OnClick);
        userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
    }
    protected override void Awake()
    {
        base.Awake();
        //get component
        coinLabel         = transform.Find("res/money/label").GetComponent <UILabel>();
        resLabel          = transform.Find("res/resource/label").GetComponent <UILabel>();
        elecLabel         = transform.Find("res/elec/label").GetComponent <UILabel>();
        taskLabel         = transform.Find("task/label").GetComponent <UILabel>();
        levelLabel        = transform.Find("player/level").GetComponent <UILabel>();
        healthProgressBar = transform.Find("status/health").GetComponent <UIProgressBar>();
        hungerProgressBar = transform.Find("status/hunger").GetComponent <UIProgressBar>();
        thirstProgressBar = transform.Find("status/thirst").GetComponent <UIProgressBar>();
        expProgressBar    = transform.Find("player/exp").GetComponent <UIProgressBar>();
        proProgress       = transform.Find("res/elec/progress").GetComponent <UIProgressBar>();
        userPackage       = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        itemPackage       = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;
        sanctuaryPackage  = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage;
        //bind event
        UIButton button = transform.Find("player").GetComponent <UIButton>();

        button.onClick.Add(new EventDelegate(OnPlayerInfo));
        RegisterEvent("RefreshUserState", RefreshUserState);
        RegisterEvent("RefreshPlayerLevel", RefreshPlayerLevel);
        RegisterEvent("RefreshProduceBar", RefreshProduceBar);
        RefreshProduceBar();
    }
Beispiel #7
0
    void OnGetJoinGroupResult(NetMsgDef msg)
    {
        TSCApplyGroup res     = TSCApplyGroup.ParseFrom(msg.mBtsData);
        string        title   = "加入失败";
        string        content = "";

        if (!res.Exist)
        {
            FacadeSingleton.Instance.OverlayerPanel("UIMsgBoxPanel");
            NDictionary args = new NDictionary();
            content = "该ID不存在";
            args.Add("title", title);
            args.Add("content", content);
            SendEvent("OpenMsgBox", args);
            return;
        }
        if (res.Full)
        {
            FacadeSingleton.Instance.OverlayerPanel("UIMsgBoxPanel");
            NDictionary args = new NDictionary();
            content = "该庄园人员上限已满";
            args.Add("title", title);
            args.Add("content", content);
            SendEvent("OpenMsgBox", args);
            return;
        }
        UserPackage userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;

        userPackage.SetGroupID(res.GroupId);
        SceneLoader.LoadScene("SLoading");
    }
Beispiel #8
0
    protected override void Awake()
    {
        base.Awake();
        //get component
        manorExpProgress = transform.Find("Manor/exp").GetComponent <UIProgressBar>();
        levelLabel       = transform.Find("Manor/level").GetComponent <UILabel>();
        IDLabel          = transform.Find("Manor/idlabel").GetComponent <UILabel>();
        mailTagLabel     = transform.Find("Mail/point/num").GetComponent <UILabel>();
        nameLabel        = transform.Find("Manor/name").GetComponent <UILabel>();
        mailTagGo        = transform.Find("Mail/point").gameObject;
        tableView        = transform.Find("Eventinfo/panel/tableview").GetComponent <NTableView>();
        //bind event
        UIButton button = transform.Find("News").GetComponent <UIButton>();

        button.onClick.Add(new EventDelegate(OnNews));
        button = transform.Find("Mail").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnMail));
        button = transform.Find("ranking").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnRanking));

        userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        mailPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Mail) as MailPackage;

        FacadeSingleton.Instance.RegisterRPCResponce((short)Cmd.GETMESSAGETAG, OnGetMessgeTag);
        FacadeSingleton.Instance.RegisterEvent("RefreshMailTag", RefreshMailTag);
        FacadeSingleton.Instance.RegisterEvent("RefreshManorLevel", InitView);
        FacadeSingleton.Instance.RegisterEvent("RefreshEvent", ShowEventIcon);
    }
Beispiel #9
0
        public int CreateUpdateUserPackage(User ObjUser, long PackageID, int StateId, string StateName, string code, long OldPackageID, string OldPackageName)
        {
            try
            {
                Package ObjNewPackage = this.GetObjPackage(PackageID);

                UserPackage objUserPackage = new UserPackage();
                objUserPackage.CrtdDT      = DateTime.Now;
                objUserPackage.PackageId   = ObjNewPackage.PackageId;
                objUserPackage.PackageName = ObjNewPackage.PackageName;

                objUserPackage.OldPackageID   = OldPackageID;
                objUserPackage.OldPackageName = OldPackageName;

                objUserPackage.UpgradeUID      = ObjUser.Id;
                objUserPackage.UpgradeUserName = ObjUser.EMail;
                objUserPackage.StateId         = StateId;
                objUserPackage.StateName       = StateName;
                objUserPackage.UpgradeToken    = code;
                int rs = this.CreateUserPackage(objUserPackage);
                return(rs);
            }
            catch (Exception e)
            {
                return((int)EnumCore.Result.action_false);
            }
        }
    protected override void Awake()
    {
        base.Awake();
        titleLabel     = transform.Find("title").GetComponent <UILabel>();
        preLevelLabel  = transform.Find("building/pre/level/label").GetComponent <UILabel>();
        nextLevelLabel = transform.Find("building/next/level/label").GetComponent <UILabel>();
        tableView      = transform.Find("upgradeeffect/microview/panel/tableview").GetComponent <NTableView>();
        levelLabel     = transform.Find("consume/level").GetComponent <UILabel>();
        preIcon        = transform.Find("building/pre/frame/icon").GetComponent <UISprite>();
        nextIcon       = transform.Find("building/next/frame/icon").GetComponent <UISprite>();
        pointGo        = transform.Find("okbtn/point").gameObject;
        Transform cellGroup = transform.Find("consume/costlist");

        for (int i = 0; i < cellGroup.childCount; i++)
        {
            CostCell  cell  = new CostCell();
            Transform trans = cellGroup.GetChild(i);
            cell.go    = trans.gameObject;
            cell.title = trans.Find("title").GetComponent <UILabel>();
            cell.value = trans.Find("value").GetComponent <UILabel>();
            costCellList.Add(cell);
        }

        //bind event
        UIButton button = transform.Find("okbtn").GetComponent <UIButton>();

        button.onClick.Add(new EventDelegate(OnUpgrade));
        button = transform.Find("closebtn").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(Close));

        sanctuaryPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage;
        itemPackage      = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;
        userPackage      = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
    }
Beispiel #11
0
    public void CalculateBuff()
    {
        mBuffInfoList.Clear();
        EventPackage eventPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Event) as EventPackage;
        UserPackage  userPackage  = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        //cooperation
        int num = userPackage.GetManorPersonNumber();

        if (num >= 2)
        {
            NBuffInfo buff = new NBuffInfo();
            buff.type     = NBuffType.Cooperation;
            buff.configID = num;
            mBuffInfoList.Add(buff);
        }
        //world event
        var infoList = eventPackage.GetCurEventList();

        foreach (var info in infoList)
        {
            NBuffInfo buff = new NBuffInfo();
            buff.type     = NBuffType.WorldEvent;
            buff.configID = info.configID;
            mBuffInfoList.Add(buff);
        }
    }
Beispiel #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="queueinfo"></param>
        /// <param name="filecache"></param>
        private static void packqueue(int id, FileQueue instance, MemoryMappedFile filecache)
        {
            instance.PackageQueues.Add(new Queue <UserPackage>());
            Task t = new Task(() => {
                bool first         = true;
                QueueInfo info     = instance.Queueinfos[id];
                long partoffset    = info.Offset;
                long currentoffset = 0;
                int packed         = 0;
                long cachemax      = instance._packsize * instance._maxcache;
                long pagesize      = Math.Min(cachemax, info.Length + info.Offset - partoffset);
                var accessor       = filecache.CreateViewAccessor(partoffset, pagesize, MemoryMappedFileAccess.Read);
                for (; packed < info.PackCount;)
                {
                    byte[] buffer   = new byte[instance._packsize];
                    int actrualsize = accessor.ReadArray(currentoffset, buffer, 0, instance._packsize);
                    UserPackage up  = buffer.Package(pid: packed, poffset: partoffset - info.Offset);
                    up.Reserved     = id;
                    packed++;
                    currentoffset += instance._packsize;
                    partoffset    += instance._packsize;

                    if (packed % instance.ProgressSensitive == 0)
                    {
                        instance.Progress?.Invoke(instance, new FileQueueArgs(id, info, new QueueInfo {
                            Offset    = info.Offset,
                            Length    = partoffset - info.Offset,
                            PackCount = packed
                        }));
                    }

                    if (currentoffset >= pagesize)
                    {
                        if (packed + 1 >= info.PackCount)
                        {
                            accessor.Dispose();
                            accessor = null;
                        }

                        currentoffset = 0;
                        pagesize      = Math.Min(cachemax, info.Length + info.Offset - partoffset);
                        accessor      = filecache.CreateViewAccessor(partoffset, pagesize, MemoryMappedFileAccess.Read);
                    }

                    //当打的包没有被取走时,停止打包
                    while (!instance.Add(id, up))
                    {
                        Thread.Sleep(5);
                        if (first)
                        {
                            first = false;
                            instance.Ready?.Invoke(instance, new FileQueueArgs(id, info, info));
                        }
                    }
                }
            });

            t.Start();
        }
Beispiel #13
0
    protected override void Awake()
    {
        base.Awake();
        //get component
        //player info
        bloodProgess   = transform.Find("playerinfo/status/health").GetComponent <UIProgressBar>();
        bloodLabel     = transform.Find("playerinfo/status/health/label").GetComponent <UILabel>();
        hungerProgress = transform.Find("playerinfo/status/hunger").GetComponent <UIProgressBar>();
        hungerLabel    = transform.Find("playerinfo/status/hunger/label").GetComponent <UILabel>();
        thirstProgress = transform.Find("playerinfo/status/thirst").GetComponent <UIProgressBar>();
        thirstLabel    = transform.Find("playerinfo/status/thirst/label").GetComponent <UILabel>();
        attackLabel    = transform.Find("property/panel/grid/attack/value").GetComponent <UILabel>();
        defenseLable   = transform.Find("property/panel/grid/defense/value").GetComponent <UILabel>();
        agileLabel     = transform.Find("property/panel/grid/agile/value").GetComponent <UILabel>();
        speedLabel     = transform.Find("property/panel/grid/speed/value").GetComponent <UILabel>();
        intellectLabel = transform.Find("property/panel/grid/intellect/value").GetComponent <UILabel>();
        healthLabel    = transform.Find("property/panel/grid/health/value").GetComponent <UILabel>();
        moodLabel      = transform.Find("property/panel/grid/mood/value").GetComponent <UILabel>();
        loadLabel      = transform.Find("property/panel/grid/load/value").GetComponent <UILabel>();
        resLabel       = transform.Find("playerinfo/res/resouce/label").GetComponent <UILabel>();
        moneyLabel     = transform.Find("playerinfo/res/money/label").GetComponent <UILabel>();
        elecLabel      = transform.Find("playerinfo/res/elec/label").GetComponent <UILabel>();
        interestLabel  = transform.Find("playerinfo/player/interest").GetComponent <UILabel>();
        sortNameLabel  = transform.Find("store/tabname").GetComponent <UILabel>();
        capLabel       = transform.Find("store/cap").GetComponent <UILabel>();
        expProgress    = transform.Find("playerinfo/player/exp").GetComponent <UIProgressBar>();
        expLabel       = transform.Find("playerinfo/player/exp/label").GetComponent <UILabel>();
        levelLabel     = transform.Find("playerinfo/player/level").GetComponent <UILabel>();
        nameLabel      = transform.Find("playerinfo/player/name").GetComponent <UILabel>();
        //equip
        //item
        tableView = transform.Find("store/itemview/tableview").GetComponent <NTableView>();
        //bind event
        UIButton button = transform.Find("closebtn").GetComponent <UIButton>();

        button.onClick.Add(new EventDelegate(Close));
        button = transform.Find("store/tabgroup/grid/tab0").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnTab0));
        button = transform.Find("store/tabgroup/grid/tab1").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnTab1));
        button = transform.Find("store/tabgroup/grid/tab2").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnTab2));
        button = transform.Find("equip/head").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnEquipHead));
        button = transform.Find("equip/chest").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnEquipChest));
        button = transform.Find("equip/weapon").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnEquipWeapon));
        button = transform.Find("equip/pants").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnEquipPants));
        button = transform.Find("equip/shoes").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(OnEquipShoes));

        FacadeSingleton.Instance.RegisterEvent("RefreshStoreHouse", RefreshStoreHouse);

        itemPackage      = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;
        userPackage      = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
        sanctuaryPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage;
    }
        public ActionResult DeleteConfirmed(int id)
        {
            UserPackage userPackage = db.UserPackages.Find(id);

            db.UserPackages.Remove(userPackage);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 protected override void Awake()
 {
     base.Awake();
     nameLabel        = transform.Find("name").GetComponent <UILabel>();
     valueLabel       = transform.Find("value").GetComponent <UILabel>();
     sanctuaryPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Sanctuary) as SanctuaryPackage;
     itemPackage      = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_Item) as ItemPackage;
     userPackage      = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
 }
        /// <summary>
        /// 将 MsgHead 转化为 byte[]
        /// </summary>
        /// <param name="mh"></param>
        //public static byte[] ToByteArray(this PackageHead mh) {
        //    return new byte[] {
        //         (byte)((mh.PACKID) & 0xFF),
        //          (byte)((mh.PACKID >> 8) & 0xFF),
        //           (byte)((mh.PACKID >> 16) & 0xFF),
        //            (byte)((mh.PACKID >> 24) & 0xFF),
        //             (byte)((mh.PACKSIZE) & 0xFF),
        //              (byte)((mh.PACKSIZE >> 8) & 0xFF),
        //               (byte)((mh.PACKSIZE >> 16) & 0xFF),
        //                (byte)((mh.PACKSIZE >> 24) & 0xFF),
        //    };
        //}

        /// <summary>
        /// 序列化 MsgHead 头部信息
        /// </summary>
        /// <param name="head"></param>
        public static string Info(this UserPackage head, string format = null)
        {
            string exp = string.IsNullOrEmpty(format) ? "< {0} - {1} : {2}   {3}>" : format;

            return(string.Format(exp,
                                 head.CID.ToString().PadRight(20),
                                 head.PACKID.ToString().PadRight(20),
                                 head.PACKSIZE.ToString().PadRight(20),
                                 head.TimeStamp.ToString()));
        }
        //return View(
        //[HttpGet]
        //[Route("getuserpackageamountlimitforwithdrawal/{userId}")]
        public string GetUserPackageAmountLimitForWithdrawal(int userId)
        {
            using (SleepingPartnermanagementTestingEntities dc = new SleepingPartnermanagementTestingEntities())
            {
                UserPackage userPackages = dc.UserPackages.Where(a => a.UserId.Value.Equals(userId)).FirstOrDefault();
                var         userPackagesAmountLimitValue = userPackages.PackagePrice.Value;

                return(userPackagesAmountLimitValue.ToString());
            }
            //return View();
        }
Beispiel #18
0
 public int CreateUserPackage(UserPackage ObjUserPackage)
 {
     try
     {
         db.UserPackages.Add(ObjUserPackage);
         return(db.SaveChanges());
     }
     catch (Exception e)
     {
         return((int)EnumCore.Result.action_false);
     }
 }
Beispiel #19
0
 public async Task <int> CreateUserPackageAsync(UserPackage ObjUserPackage)
 {
     try
     {
         db.UserPackages.Add(ObjUserPackage);
         return(await db.SaveChangesAsync());
     }
     catch (Exception e)
     {
         return((int)EnumCore.Result.action_false);
     }
 }
Beispiel #20
0
 public UserPackageMinimalViewModel2(UserPackage userPackage)
 {
     UserPackageId    = userPackage.Id;
     UserPackageState = userPackage.UserPackageState;
     //Package = new PackageMinimalViewModel(userPackage.Package);
     Id          = userPackage.Package.Id;
     Title       = userPackage.Package.Title;
     Description = userPackage.Package.Description;
     ImageUrl    = userPackage.Package.AbsoluteImageUrl;
     CoverUrl    = userPackage.Package.AbsoluteCoverUrl;
     CategoryId  = userPackage.Package.CategoryId;
 }
        // GET: UserPackages/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserPackage userPackage = db.UserPackages.Find(id);

            if (userPackage == null)
            {
                return(HttpNotFound());
            }
            return(View(userPackage));
        }
        /// <summary>
        /// 解析字节流生成包
        /// </summary>
        /// <param name="bytes"></param>
        /// <returns></returns>
        public static UserPackage UnPackage(this byte[] bytes)
        {
            UserPackage p = new UserPackage();

            p.CID        = BitConverter.ToInt32(bytes, 0);
            p.PACKID     = BitConverter.ToInt32(bytes, 4);
            p.PACKOFFSET = BitConverter.ToInt64(bytes, 8);
            p.PACKSIZE   = BitConverter.ToInt32(bytes, 16);
            p.TimeStamp  = BitConverter.ToDouble(bytes, 20);
            p.Reserved   = BitConverter.ToInt32(bytes, 28);
            p.DATA       = new byte[p.PACKSIZE];
            Array.Copy(bytes, 28, p.DATA, 0, p.PACKSIZE);
            return(p);
        }
        private UserPackage Mapper(IDataReader reader)
        {
            try {
                UserPackage _UserPackage = new UserPackage();
                if (reader[ID] != null && reader[ID] != DBNull.Value)
                {
                    _UserPackage.ID = Common.Conversion.ToLong(reader[ID]);
                }

                if (reader[USERID] != null && reader[USERID] != DBNull.Value)
                {
                    _UserPackage.UserId = Common.Conversion.ToLong(reader[USERID]);
                }

                if (reader[PACKAGEID] != null && reader[PACKAGEID] != DBNull.Value)
                {
                    _UserPackage.PackageId = Common.Conversion.ToInt(reader[PACKAGEID]);
                }

                if (reader[ISACTIVE] != null && reader[ISACTIVE] != DBNull.Value)
                {
                    _UserPackage.IsActive = Common.Conversion.ToBool(reader[ISACTIVE]);
                }

                if (reader[CREATEDBY] != null && reader[CREATEDBY] != DBNull.Value)
                {
                    _UserPackage.CreatedBy = Common.Conversion.ToString(reader[CREATEDBY]);
                }

                if (reader[CREATEDDATE] != null && reader[CREATEDDATE] != DBNull.Value)
                {
                    _UserPackage.CreatedDate = Common.Conversion.ToDateTime(reader[CREATEDDATE]);
                }

                if (reader[UPDATEDBY] != null && reader[UPDATEDBY] != DBNull.Value)
                {
                    _UserPackage.UpdatedBy = Common.Conversion.ToString(reader[UPDATEDBY]);
                }

                if (reader[UPDATEDDATE] != null && reader[UPDATEDDATE] != DBNull.Value)
                {
                    _UserPackage.UpdatedDate = Common.Conversion.ToDateTime(reader[UPDATEDDATE]);
                }

                return(_UserPackage);
            }
            catch (Exception exception) {
                throw exception;
            }
        }
        public void ValidInputTest_NegativeInput()
        {
            //arrange
            var clientInterface = new UserInput();
            var clientPackage   = new UserPackage();
            var input           = "-5";
            var expectedOutput  = 0;

            //act
            var output = clientInterface.ValidInput(input);

            //assert
            Assert.AreEqual(expectedOutput, output);
        }
Beispiel #25
0
        public string GetLastUpgradeToken(long UserID, long awaitPackageId)
        {
            UserPackage ObjUserPackage = db.UserPackages.Where(s => s.UpgradeUID.Value == UserID && s.PackageId.Value == awaitPackageId &&
                                                               s.StateId == (int)EnumCore.StateType.cho_duyet).OrderByDescending(s => s.Id).FirstOrDefault();

            if (ObjUserPackage != null)
            {
                return(ObjUserPackage.UpgradeToken);
            }
            else
            {
                return("");
            }
        }
        public ActionResult Details(UserPackageDetailViewModel model)
        {
            UserPackage userPackage = db.UserPackages.Find(model.Id);

            if (userPackage == null)
            {
                return(HttpNotFound());
            }

            userPackage.IsActive = false;
            db.SaveChanges();

            return(RedirectToAction("Details", new { Id = model.Id }));
        }
        public int DeleteUserPackage(UserPackage item)
        {
            try
            {
                db.UserPackages.Remove(item);
                db.SaveChanges();

                return((int)EnumCore.Result.action_true);
            }
            catch (Exception e)
            {
                return((int)EnumCore.Result.action_false);
            }
        }
        /// <summary>
        /// 将包转化为字节流以传输
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public static byte[] Serialize(this UserPackage package)
        {
            //byte[] tosend = new byte[32 + package.PACKSIZE];
            List <byte> result = new List <byte>(28 + (int)package.PACKSIZE);

            result.AddRange(BitConverter.GetBytes(package.CID));
            result.AddRange(BitConverter.GetBytes(package.PACKID));
            result.AddRange(BitConverter.GetBytes(package.PACKOFFSET));
            result.AddRange(BitConverter.GetBytes(package.PACKSIZE));
            result.AddRange(BitConverter.GetBytes(package.TimeStamp));
            result.AddRange(BitConverter.GetBytes(package.Reserved));
            result.AddRange(package.DATA);
            return(result.ToArray());
        }
Beispiel #29
0
 public void Send(byte[] data, IPEndPoint to = null)
 {
     if (to != null)
     {
         if (!_clients.ContainsKey(to))
         {
             throw new ArgumentException(string.Format("Client at {0} not Connected ! ", to));
         }
         UserPackage p = data.Package();
     }
     else
     {
         throw new ArgumentException("IP endPoint not define ! ");
     }
 }
Beispiel #30
0
    protected override void Awake()
    {
        base.Awake();
        //bind event
        UIButton button = transform.Find("closebtn").GetComponent <UIButton>();

        button.onClick.Add(new EventDelegate(Close));
        button = transform.Find("mask").GetComponent <UIButton>();
        button.onClick.Add(new EventDelegate(Close));
        nameLabel         = transform.Find("player/name").GetComponent <UILabel>();
        idLabel           = transform.Find("info/id/value").GetComponent <UILabel>();
        contributionLabel = transform.Find("info/contribution/value").GetComponent <UILabel>();

        userPackage = FacadeSingleton.Instance.RetrieveData(ConstVal.Package_User) as UserPackage;
    }