示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("ServiceCenterId,Name,CompanyType,Location,CategoryType,ContactNumber,Timings,CertifiedBy")] ServiceCenter serviceCenter)
        {
            if (id != serviceCenter.ServiceCenterId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(serviceCenter);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ServiceCenterExists(serviceCenter.ServiceCenterId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryType"] = new SelectList(_context.Categories, "Category1", "Category1", serviceCenter.CategoryType);
            ViewData["CompanyType"]  = new SelectList(_context.Companies, "Name", "Name", serviceCenter.CompanyType);
            return(View(serviceCenter));
        }
示例#2
0
        private static int _DoFileCallback(LuaState luaState)
        {
            // Use asset manager to replace original dofile process.
            // - mouguangyi
            try {
                var fileName = LuaLib.LuaToString(luaState, 1);
                using (var asset = ServiceCenter.GetService <IAssetManager>().Load(fileName + ".txt", AssetType.BYTES)) {
                    var chunk = asset.Cast <byte[]>();
                    if (null == chunk)
                    {
                        throw new Exception("Can't load lua script: " + fileName);
                    }
                    else
                    {
                        int oldTop = LuaLib.LuaGetTop(luaState);
                        if (0 == LuaLib.LuaLLoadBuffer(luaState, chunk, fileName))
                        {
                            if (0 != LuaLib.LuaPCall(luaState, 0, -1, 0))
                            {
                                _ThrowExceptionFromError(luaState, oldTop);
                            }
                        }
                        else
                        {
                            _ThrowExceptionFromError(luaState, oldTop);
                        }
                    }
                }
            } catch (Exception e) {
                Logger <ILuaRuntime> .X(e);
            }

            return(0);
        }
示例#3
0
        public void SetSpriteAtlasAsync(string path, string name, string defaultPath = "", Action callback = null)
        {
            _Clear();

            if (!string.IsNullOrEmpty(path))
            {
                this.image.enabled = false;
                ServiceCenter.GetService <IAssetManager>().LoadAsync(path, AssetType.SPRITEATLAS, asset =>
                {
                    this.asset = asset;
                    var sprite = _GetSpriteInAtlas(this.asset, name);
                    if (null != sprite)
                    {
                        this.image.enabled = true;
                        this.image.sprite  = sprite;
                    }
                    else
                    {
                        _SetSpriteAsync(defaultPath, null);
                    }

                    if (null != callback)
                    {
                        callback();
                    }
                });
            }
        }
示例#4
0
        public object[] DoFile(string fileName)
        {
            // Use asset manager to replace original load file process.
            // - mouguangyi
            try {
                using (var asset = ServiceCenter.GetService <IAssetManager>().Load(fileName + ".txt", AssetType.BYTES)) {
                    var chunk = asset.Cast <byte[]>();
                    if (null == chunk)
                    {
                        throw new Exception("Can't load lua script: " + fileName);
                    }
                    else
                    {
                        int oldTop = LuaLib.LuaGetTop(this.luaState);
                        if (0 == LuaLib.LuaLLoadBuffer(this.luaState, chunk, fileName))
                        {
                            if (0 == LuaLib.LuaPCall(this.luaState, 0, -1, 0))
                            {
                                return(_PopValues(this.luaState, oldTop));
                            }
                        }

                        _ThrowExceptionFromError(this.luaState, oldTop);
                    }
                }
            } catch (Exception e) {
                Logger <ILuaRuntime> .X(e);
            }

            return(null);
        }
示例#5
0
        public ActionResult DeleteConfirmed(int id)
        {
            ServiceCenter servicecenter = db.ServiceCenters.Find(id);

            db.ServiceCenters.Remove(servicecenter);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
        public void CheckGameVersion()
        {
            stCheckVerisonCmd checkVersion;

            checkVersion.data    = 0;
            checkVersion.version = GameVersion;
            var server = ServiceCenter.GetService <IGiantFreeServer>();

            server.SendMessage(stCheckVerisonCmd.byCmd, stCheckVerisonCmd.byParam, CmdSerializer.StructToBytes(checkVersion));
        }
示例#7
0
        internal override void _Install(ServiceCenter center)
        {
            var service = Create();

            if (null != service)
            {
                var args = new ServiceArgs();
                Arguments(args);
                center._AddRunner(new ServiceRunner <T>(center, args, service, this.EnableLog));
            }
        }
示例#8
0
        private void SendUserGameTime()
        {
            UserResponseGameTimeCmd cmd;
            ulong serverTime = this.GetServerTime();

            cmd.userTmpID = this.loginModule.UserTmpID;
            cmd.gameTime  = serverTime;
            var server = ServiceCenter.GetService <IGiantFreeServer>();

            server.SendMessage(UserResponseGameTimeCmd.byCmd, UserResponseGameTimeCmd.byParam, CmdSerializer.StructToBytes(cmd));
        }
示例#9
0
        public override void Load()
        {
            var prefabData = this.ObjectData as ScenePrefabData;

            this.recycleObject = _GetRecyclePool().Pick <GameObject>(prefabData.Path);
            if (null == this.recycleObject)
            {
                this.asset         = ServiceCenter.GetService <IAssetManager>().Load(prefabData.Path, AssetType.PREFAB);
                this.recycleObject = GameObject.Instantiate(this.asset.Cast <GameObject>()) as GameObject;
            }
            _Init(this.recycleObject, prefabData);
        }
示例#10
0
 public ActionResult Edit([Bind(Include = "Id,Name,Code,Password,DistrictId,UpazilaId")] ServiceCenter servicecenter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicecenter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DistrictId = new SelectList(db.Districts, "Id", "Name", servicecenter.DistrictId);
     ViewBag.UpazilaId  = new SelectList(db.Upazilas, "Id", "Name", servicecenter.UpazilaId);
     return(View(servicecenter));
 }
        public ActionResult Create([Bind(Include = "ServiceCenterId,Name,Code,Password,DistrictId,ThanaId")] ServiceCenter servicecenter)
        {
            if (ModelState.IsValid)
            {
                db.ServiceCenters.Add(servicecenter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictId = new SelectList(db.Districts, "DistrictId", "Name", servicecenter.DistrictId);
            ViewBag.ThanaId    = new SelectList(db.Thanas, "ThanaId", "Name", servicecenter.ThanaId);
            return(View(servicecenter));
        }
示例#12
0
        public async Task <IActionResult> Create([Bind("ServiceCenterId,Name,CompanyType,Location,CategoryType,ContactNumber,Timings,CertifiedBy")] ServiceCenter serviceCenter)
        {
            if (ModelState.IsValid)
            {
                _context.Add(serviceCenter);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryType"] = new SelectList(_context.Categories, "Category1", "Category1", serviceCenter.CategoryType);
            ViewData["CompanyType"]  = new SelectList(_context.Companies, "Name", "Name", serviceCenter.CompanyType);
            return(View(serviceCenter));
        }
示例#13
0
        // GET: /ServinceCenter/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceCenter servicecenter = db.ServiceCenters.Find(id);

            if (servicecenter == null)
            {
                return(HttpNotFound());
            }
            return(View(servicecenter));
        }
示例#14
0
        public void Load(Vector3 position, Quaternion orientation)
        {
            using (var asset = ServiceCenter.GetService <IAssetManager>().Load(levelPath + ".bytes", AssetType.BYTES)) {
                var bytes = asset.Cast <byte[]>();
                using (var stream = new MemoryStream(bytes)) {
                    // Parse data
                    var levelData = SceneLevelData.Deserialize(stream, this.validateData);
                    _InitData(levelData);

                    _LoadAllChunks();
                    this.currentChunk = _FindChunk(position.x, position.z);
                    this.currentChunk.OnEnter();
                }
            }
        }
示例#15
0
        private Sprite _LoadSpriteFromAtlas(string spritePath, string spriteName)
        {
            using (var asset = ServiceCenter.GetService <IAssetManager>().Load(spritePath, AssetType.SPRITEATLAS)) {
                var sprites = asset.Cast <Sprite[]>();
                for (var i = 0; i < sprites.Length; ++i)
                {
                    if (sprites[i].name == spriteName)
                    {
                        return(sprites[i]);
                    }
                }
            }

            return(null);
        }
示例#16
0
        public override void Enter(StateMachine stateMachine)
        {
            this.completed = false;

            var chunk = stateMachine.Model as SceneChunk;

            chunk._Objects = new List <SceneObject>();
            ServiceCenter.GetService <IAssetManager>().LoadAsync(chunk._ChunkRefData.Path + ".bytes", AssetType.BYTES, asset =>
            {
                if (null != asset)
                {
                    var stream = new MemoryStream(asset.Cast <byte[]>());
                    SceneChunkData.DeserializeAsync(stream, chunk._ValidateData, chunkData =>
                    {
                        stream.Close();
                        stream.Dispose();
                        for (var i = 0; i < chunkData.Objects.Count; ++i)
                        {
                            var go = new GameObject();
                            go.transform.SetParent(chunk._ChunkRoot.transform);

                            var objectData  = chunkData.Objects[i];
                            SceneObject obj = null;
                            switch (objectData.Type)
                            {
                            case SceneObjectType.PREFAB:
                                obj     = new ScenePrefab(objectData, go);
                                go.name = "_Prefab";
                                break;

                            case SceneObjectType.LIGHTMODIFIER:
                                obj     = new SceneLightModifier(objectData, go);
                                go.name = "_LightModifier";
                                break;

                            default:
                                go.name = "_SceneObject";
                                break;
                            }
                            chunk._Objects.Add(obj);
                        }

                        this.completed = true;
                    });
                }
                asset.Dispose();
            });
        }
示例#17
0
        // GET: /ServinceCenter/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServiceCenter servicecenter = db.ServiceCenters.Find(id);

            if (servicecenter == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DistrictId = new SelectList(db.Districts, "Id", "Name", servicecenter.DistrictId);
            ViewBag.UpazilaId  = new SelectList(db.Upazilas, "Id", "Name", servicecenter.UpazilaId);
            return(View(servicecenter));
        }
示例#18
0
        public ActionResult Create([Bind(Include = "Id,Name,Code,Password,DistrictId,UpazilaId")] ServiceCenter servicecenter)
        {
            servicecenter.Code     = CodeGenaretor();
            servicecenter.Password = servicecenter.Code;

            if (ModelState.IsValid)
            {
                db.ServiceCenters.Add(servicecenter);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DistrictId = new SelectList(db.Districts, "Id", "Name", servicecenter.DistrictId);
            ViewBag.UpazilaId  = new SelectList(db.Upazilas, "Id", "Name", servicecenter.UpazilaId);
            return(View(servicecenter));
        }
示例#19
0
        public void LoadAsync(Vector3 position, Quaternion orientation, LevelLoadPolicy policy, Action handler)
        {
            this.policy = policy;

            ServiceCenter.GetService <IAssetManager>().LoadAsync(levelPath + ".bytes", AssetType.BYTES, asset =>
            {
                if (null != asset)
                {
                    var stream = new MemoryStream(asset.Cast <byte[]>());
                    SceneLevelData.DeserializeAsync(stream, this.validateData, levelData =>
                    {
                        stream.Close();
                        stream.Dispose();

                        _InitData(levelData);

                        switch (this.policy)
                        {
                        case LevelLoadPolicy.ALL:
                            _LoadAllChunksAsync(() =>
                            {
                                this.currentChunk = _FindChunk(position.x, position.z);
                                this.currentChunk.OnEnter();
                                _NotifyCompleted(handler);
                            });
                            break;

                        case LevelLoadPolicy.SURROUNDING:
                            // Start to load related chunks
                            this.currentChunk = _FindChunk(position.x, position.z);
                            if (null != this.currentChunk)
                            {
                                this.currentChunk.LoadAsync((target, message) =>
                                {
                                    this.currentChunk.OnEnter();
                                    _NotifyCompleted(handler);
                                });
                            }

                            _LoadNearChunksAsync(this.currentChunk.Index);
                            break;
                        }
                    });
                }
                asset.Dispose();
            });
        }
示例#20
0
 public ServiceCenterIEF(ServiceCenter obj, my_db_for_db_2Entities _db)
 {
     InitializeComponent();
     db = _db;
     addressBindingSource.DataSource       = db.Address.ToList();
     serviceCenterBindingSource.DataSource = db.ServiceCenter.ToList();
     if (obj == null)
     {
         serviceCenterBindingSource.DataSource = new ServiceCenter();
         db.ServiceCenter.Add(serviceCenterBindingSource.Current as ServiceCenter);
     }
     else
     {
         serviceCenterBindingSource.DataSource = obj;
         db.ServiceCenter.Attach(serviceCenterBindingSource.Current as ServiceCenter);
     }
 }
示例#21
0
        private bool _SetSprite(string path)
        {
            _Clear();

            if (!string.IsNullOrEmpty(path))
            {
                this.asset = ServiceCenter.GetService <IAssetManager>().Load(path, AssetType.TEXTURE);
                var texture = this.asset.Cast <Texture2D>();
                if (null != texture)
                {
                    this.image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                    return(true);
                }
            }

            return(false);
        }
示例#22
0
        public void SetSpriteAtlas(string path, string name, string defaultPath = "")
        {
            _Clear();

            if (!string.IsNullOrEmpty(path))
            {
                this.asset = ServiceCenter.GetService <IAssetManager>().Load(path, AssetType.SPRITEATLAS);
                var sprite = _GetSpriteInAtlas(this.asset, name);
                if (null != sprite)
                {
                    this.image.sprite = sprite;
                }
                else
                {
                    _SetSprite(defaultPath);
                }
            }
        }
示例#23
0
        static IServiceProvider GetServiceProvider(HttpContextBase context)
        {
            if (context?.Items[ContextKey] is IServiceProvider sp)
            {
                return(sp);
            }

            var container = new ServiceContainer(ServiceCenter.Default(context));

            if (context != null)
            {
                var cachedErrorLog = new ErrorLog[1];
                container.AddService(typeof(ErrorLog), delegate
                {
                    return(cachedErrorLog[0] ?? (cachedErrorLog[0] = ErrorLogFactory()));
                });

                context.Items[ContextKey] = container;
            }

            return(container);
        }
示例#24
0
        private static int _SearcherCallback(LuaState luaState)
        {
            try {
                var fileName = LuaLib.LuaToString(luaState, 1);
                using (var asset = ServiceCenter.GetService <IAssetManager>().Load(fileName + ".txt", AssetType.BYTES)) {
                    var chunk = asset.Cast <byte[]>();
                    if (null == chunk)
                    {
                        throw new Exception("Can't load lua script: " + fileName);
                    }
                    else if (0 != LuaLib.LuaLLoadBuffer(luaState, chunk, fileName))
                    {
                        var err = LuaLib.LuaToString(luaState, -1);
                        throw new Exception(err);
                    }
                }
            } catch (Exception e) {
                Logger <ILuaRuntime> .X(e);
            }

            return(1);
        }
示例#25
0
        public void Load()
        {
            using (var asset = ServiceCenter.GetService <IAssetManager>().Load(this.chunkRefData.Path + ".bytes", AssetType.BYTES)) {
                var bytes = asset.Cast <byte[]>();
                if (null != bytes)
                {
                    this.objects = new List <SceneObject>();
                    using (var stream = new MemoryStream(bytes)) {
                        var chunkData = SceneChunkData.Deserialize(stream, this.validateData);
                        for (var i = 0; i < chunkData.Objects.Count; ++i)
                        {
                            var go = new GameObject();
                            go.transform.SetParent(this.chunkRoot.transform);

                            var         objectData = chunkData.Objects[i];
                            SceneObject obj        = null;
                            switch (objectData.Type)
                            {
                            case SceneObjectType.PREFAB:
                                obj     = new ScenePrefab(objectData, go);
                                go.name = "_Prefab";
                                break;

                            case SceneObjectType.LIGHTMODIFIER:
                                obj     = new SceneLightModifier(objectData, go);
                                go.name = "_LightModifier";
                                break;

                            default:
                                go.name = "_SceneObject";
                                break;
                            }
                            this.objects.Add(obj);
                            obj.Load();
                        }
                    }
                }
            }
        }
示例#26
0
        public override void LoadAsync(Action handler)
        {
            var prefabData = this.ObjectData as ScenePrefabData;

            this.recycleObject = _GetRecyclePool().Pick <GameObject>(prefabData.Path);
            if (null != this.recycleObject)
            {
                _Init(this.recycleObject, prefabData);
                NotifyLoaded(handler);
            }
            else
            {
                ServiceCenter.GetService <IAssetManager>().LoadAsync(prefabData.Path, AssetType.PREFAB, asset =>
                {
                    this.asset         = asset;
                    this.recycleObject = GameObject.Instantiate(this.asset.Cast <GameObject>()) as GameObject;

                    _Init(this.recycleObject, prefabData);
                    NotifyLoaded(handler);
                });
            }
        }
示例#27
0
        public ActionResult InsertServiceCenter(int districtId, int upazilaId, string serviceCenterName)
        {
            var centerName = db.ServiceCenters.FirstOrDefault(x => x.Name == serviceCenterName);


            if (centerName == null)
            {
                ServiceCenter aServiceCenter = new ServiceCenter();
                aServiceCenter.Name       = serviceCenterName;
                aServiceCenter.DistrictId = districtId;
                aServiceCenter.UpazilaId  = upazilaId;
                aServiceCenter.Code       = CodeGenaretor();
                aServiceCenter.Password   = PasswordGenaretor();
                db.ServiceCenters.Add(aServiceCenter);
                db.SaveChanges();
                ViewBag.ServiceCenter = aServiceCenter;
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
        static void Main(string[] args)
        {
            ServiceCenter service = new ServiceCenter();
            Account       acc1    = service.CreateAccount("sash", "yachik", "*****@*****.**", 900000, new GenerateByRandom(), new CreateGoldAccount());
            Account       acc2    = service.CreateAccount("sasha", "yik", "*****@*****.**", 780000, new GenerateByRandom(), new CreatePlatinumAccount());
            Account       acc3    = service.CreateAccount("sasha", "yacik", "*****@*****.**", 9000, new GenerateByRandom(), new CreatePlatinumAccount());
            Account       acc     = service.CreateAccount("sasha", "yachnik", "[email protected]", 560000, new GenerateByRandom(), new CreateBaseAccount());

            Console.WriteLine(acc.Balance);
            Console.WriteLine(acc.NumberAcc);

            service.Deposite(acc.NumberAcc, 2000);
            Console.WriteLine(acc.Balance);

            service.Withdrow(acc.NumberAcc, 1000);
            Console.WriteLine(acc.Balance);

            Account newAcc = service.GetById(acc1.NumberAcc);

            Console.WriteLine(newAcc);

            acc.CloseAccount();
            Console.WriteLine(acc.Status);
        }
示例#29
0
        //private HeartBeatMsg heartBeatMsg;
        public TcpConnection()
        {
            //GameWorld.Instance.OnApplicationQuit(Disconnect);
            new ServiceTask(new[]
            {
                typeof(IByteStorage),
                typeof(INetworkManager)
            }).Start().Continue(t =>
            {
                _iNetworkManager = ServiceCenter.GetService <INetworkManager>();


                _iSocketChannel = _iNetworkManager.Create("tcp") as ISocketChannel;
                _iSocketChannel.Setup(this);
                _iSocketChannel.OnChannelStateChange = OnServerStateChange;

                if (ServiceEventHandler != null)
                {
                    ServiceEventHandler();
                }
                //  MsgHandler.Send((int)usercmd.MsgTypeCmd.Login, new usercmd.MsgLogin());
                return(null);
            });
        }
示例#30
0
        private void _SetSpriteAsync(string path, Action <bool> callback)
        {
            _Clear();

            if (!string.IsNullOrEmpty(path))
            {
                this.image.enabled = false;
                ServiceCenter.GetService <IAssetManager>().LoadAsync(path, AssetType.TEXTURE, asset =>
                {
                    this.asset  = asset;
                    var texture = asset.Cast <Texture2D>();
                    if (null != texture)
                    {
                        this.image.enabled = true;
                        this.image.sprite  = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                    }

                    if (null != callback)
                    {
                        callback(null != texture);
                    }
                });
            }
        }