Пример #1
0
        public ActionResult DeleteConfirmed(long id)
        {
            ClientMember clientMember = db.ClientMembers.Find(id);

            db.ClientMembers.Remove(clientMember);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
        // GET: ClientMember/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientMember clientMember = db.ClientMembers.Find(id);

            if (clientMember == null)
            {
                return(HttpNotFound());
            }
            return(View(clientMember));
        }
Пример #3
0
        public ActionResult Edit([Bind(Include = "clientMemberID,clientID,name,age,healthStateID,need")] ClientMember clientMember)
        {
            if (ModelState.IsValid)
            {
                db.Entry(clientMember).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var isAdmin = user.isAdmin();

            ViewBag.clientID      = new SelectList(db.Clients.Where(c => c.userID == user.userID || isAdmin).DecodeClients(), "clientID", "name", clientMember.clientID);
            ViewBag.healthStateID = new SelectList(db.HealthStates, "healthStateID", "healthStateType", clientMember.healthStateID);
            return(View(clientMember));
        }
Пример #4
0
        // GET: ClientMember/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClientMember clientMember = db.ClientMembers.Find(id);

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

            var isAdmin = user.isAdmin();

            ViewBag.clientID      = new SelectList(db.Clients.Where(c => c.userID == user.userID || isAdmin).DecodeClients(), "clientID", "name", clientMember.clientID);
            ViewBag.healthStateID = new SelectList(db.HealthStates, "healthStateID", "healthStateType", clientMember.healthStateID);
            return(View(clientMember));
        }
Пример #5
0
        public override void Update(GameTime gameTime)
        {
            foreach (var client in ServerSide.ConnectClients.ConnectedClients.Values)
            {
                if (client.Connected)
                {
                    try
                    {
                        NetworkStream ns      = client.GetStream();
                        var           message = ServerSide.RecvCommand(ns);

                        if (message == GameAction.Ready)
                        {
                            var key = ServerSide.RecvShortString(ns);

                            if (!PlayingClients.ContainsKey(key))
                            {
                                client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
                                Console.WriteLine("client address: " + client.Client.RemoteEndPoint.ToString() + "name:" + key + " playing");
                                PlayingClients.TryAdd(key, new ClientMember(client, key, client.GetStream()));                        //, sw, sr));
                                Console.WriteLine("initing " + key + " background transfer");
                                InitClient(key);


                                var pt = Parallel.ForEach <ClientMember>(PlayingClients.Values, (cl) =>
                                {
                                    if (fighter.Value != null)
                                    {
                                        var datString = key + "," + fighter.Value.Angle + "," + fighter.Value.Location.X + "," + fighter.Value.Location.Y + ",";
                                        gameObjects.TryAdd(key, fighter.Value);
                                        ServerSide.SendData(GameAction.NewPlayer, datString, cl.Ns);
                                    }
                                });

                                while (!pt.IsCompleted)
                                {
                                }

                                break;
                            }
                        }
                        //   ns.Close();
                    }
                    catch { Console.WriteLine("problem"); }
                }
            }



            var p = Parallel.ForEach <ClientMember>(PlayingClients.Values, (client) =>
            {
                if (client.status == "loaded")
                {
                    try
                    {
                        client.Ns = client.Client.GetStream();
                    }
                    catch { }

                    if (client.Ns.DataAvailable)
                    {
                        try
                        {
                            var message = ServerSide.RecvCommand(client.Ns);
                            var key     = ServerSide.RecvShortString(client.Ns);

                            if (message == GameAction.Accelerate)
                            {
                                ((StarFighter)gameObjects[key]).Accelerate();
                            }
                            if (message == GameAction.Deaccelerate)
                            {
                                ((StarFighter)gameObjects[key]).Deaccelerate();
                            }
                            if (message == GameAction.TurnLeft)
                            {
                                ((StarFighter)gameObjects[key]).TurnLeft();
                            }
                            if (message == GameAction.TurnRight)
                            {
                                ((StarFighter)gameObjects[key]).TurnRight();
                            }

                            client.ns.Read(new byte[ClientSide.Client.ReceiveBufferSize], 0, ClientSide.Client.ReceiveBufferSize);
                        }
                        catch { }
                    }

                    var fighters = gameObjects.Keys.OfType <StarFighter>();

                    foreach (var fighter in fighters)
                    {
                        var datString = fighter.ID + "," + fighter.Angle + "," + fighter.Location.X + "," + fighter.Location.Y + ",";
                        ServerSide.SendData(GameAction.Update, datString, client.Ns);
                    }
                }
            });

            while (!p.IsCompleted)
            {
            }
            newPlayer = false;

            foreach (var obj in gameObjects)
            {
                obj.Value.Update(gameTime);
            }


            //foreach (var player in gameObjects.Values.OfType<StarFighter>())
            //{
            //    foreach (var bullet in gameObjects.Values.OfType<Projectile>())
            //    {
            //        var delx = player.Size.Width;
            //        var dely = player.Size.Height;
            //        if (bullet.InBounds(new BoundF(player.Location.X - delx, player.Location.Y - dely, player.Location.X + delx, player.Location.Y + dely)))
            //        {
            //            if (!bullet.ID.Contains(player.ID))
            //            {
            //                var id = bullet.ID.Split(',').Last();
            //                bullet.ToBeDestroyed = true;
            //                if (player.IsDead.IsNotTrue())
            //                {
            //                    player.IsDead = true;
            //                    scores[id]++;
            //                }
            //            }
            //        }
            //    }

            //}


            //var keys = gameObjects.Keys.ToArray<string>();
            //for (int i = 0; i < keys.Count<string>(); i++)
            //{
            //    var ass = gameObjects[keys[i]];
            //    if (ass.GetType() == typeof(Asteroid))
            //    {
            //        //  ((IGame2DProperties)ass).Location = ((IGame2DProperties)ass).KeepInBounds(bound).Location;
            //    }

            //}



            //var fighters = gameObjects.Values.OfType<StarFighter>();
            //foreach (var client in PlayingClients)
            //{
            //    if (client.Value.status == "loaded")
            //    {
            //        foreach (var fighter in fighters)
            //        {
            //            SendString("upfi", client.Value.key, client.Value.key + "," + fighter.Angle + "," + fighter.Location.X + "," + fighter.Location.Y);
            //            // SendObject("upfi", client.Value.key, client.Value.key + "," + fighter.Angle + "," + fighter.Location.X + "," + fighter.Location.Y);
            //        }
            //    }
            //}

            // if (delClient)
            {
                var lst = new List <string>();
                foreach (var client in PlayingClients)
                {
                    if (!client.Value.Client.Connected)
                    {
                        lst.Add(client.Key);
                        client.Value.status = "disconnected";
                        delClient           = true;
                    }
                }

                if (delClient)
                {
                    foreach (var key in lst)
                    {
                        var c = new ClientMember(null, "", null);
                        var f = default(IGameBehavior);
                        PlayingClients.TryRemove(key, out c);
                        if (gameObjects.ContainsKey(key))
                        {
                            gameObjects.TryRemove(key, out f);
                        }
                    }
                    //    delClient = false;

                    //  tasks[1] = Task.Run(() =>{
                    for (int i = 0; i < ServerSide.ConnectClients.ConnectedClients.Count; i++)
                    {
                        try
                        {
                            if (!ServerSide.ConnectClients.ConnectedClients[i].Connected)
                            {
                                // disconnect clients
                                var key = ServerSide.ConnectClients.ConnectedClients[i].Client.RemoteEndPoint.ToString();
                                var t   = new TcpClient();
                                ServerSide.ConnectClients.ConnectedClients.TryRemove(i, out t);//.TryTake(out ServerSide.ConnectClients.ConnectedClients.ElementAt(i) );
                                i--;
                                Console.WriteLine("client " + key + " disconnected");
                            }
                        }
                        catch { }
                    }
                    delClient = false;
                }
                //  Console.WriteLine("ConnectReadyCheck Close..");
                // });
            }

            if (GameInput.isKeyDown(Keys.Escape))
            {
                RunAgain = false;
                GameWindow.AudioPlayer.Item1.StopTrack("background");
                GameWindow.CurrentScene = NextScene;
                GameWindow.View.Init();
                gameObjects.Clear();
            }
        }
Пример #6
0
    public ClientMasterInfo Update(ClientMasterInfo clientMasterInfo)
    {
        string query =
            "UPDATE [dbo].[ClientMaster] "
            + "SET  "
            + " [CompanyName] = @CompanyName "
            + ", [CompanyType] = @CompanyType "
            + ", [RegPlace] = @RegPlace "
            + ", [RegNo] = @RegNo "
            + ", [TaxCodeNo] = @TaxCodeNo "
            + ", [OrganizationCode] = @OrganizationCode "
            + ", [SocialUnifiedCreditCode] = @SocialUnifiedCreditCode "
            + ", [ExternalDebtNo] = @ExternalDebtNo "
            + ", [RegCapitalCurrency] = @RegCapitalCurrency "
            + ", [RegCapital] = @RegCapital "
            + ", [RegShareCurrency] = @RegShareCurrency "
            + ", [RegShare] = @RegShare "
            + ", [NotRegCapitalCurrency] = @NotRegCapitalCurrency "
            + ", [NotRegCapital] = @NotRegCapital "
            + ", [TotalCreditor] = @TotalCreditor "
            + ", [Website] = @Website "
            + ", [Director] = @Director "
            + ", [DirectorIdenNo] = @DirectorIdenNo "
            + ", [DirectorPhone] = @DirectorPhone "
            + ", [DirectorAddress] = @DirectorAddress "
            + ", [GenManager] = @GenManager "
            + ", [GenManagerIdenNo] = @GenManagerIdenNo "
            + ", [GenManagerPhone] = @GenManagerPhone "
            + ", [GenManagerAddress] = @GenManagerAddress "
            + ", [Secretary] = @Secretary "
            + ", [SecretaryIdenNo] = @SecretaryIdenNo "
            + ", [SecretaryPhone] = @SecretaryPhone "
            + ", [SecretaryAddress] = @SecretaryAddress "
            + ", [Supervisor] = @Supervisor "
            + ", [SupervisorIdenNo] = @SupervisorIdenNo "
            + ", [SupervisorPhone] = @SupervisorPhone "
            + ", [SupervisorAddress] = @SupervisorAddress "
            + ", [Admin] = @Admin "
            + ", [AdminIdenNo] = @AdminIdenNo "
            + ", [AdminPhone] = @AdminPhone "
            + ", [AdminAddress] = @AdminAddress "
            + ", [ContactEmail] = @ContactEmail "
            + ", [LegalRepresentative] = @LegalRepresentative "
            + ", [Relationship] = @Relationship "
            + ", [EntrustAgent] = @EntrustAgent "
            + ", [CreateUser] = @CreateUser "
            + ", [CreateDate] = @CreateDate "
            + ", [LastModifiedUser] = @LastModifiedUser "
            + ", [LastModifiedDate] = @LastModifiedDate "
            + "WHERE ClientID = @ClientID ";

        db.Execute(query, clientMasterInfo, transaction);

        // Delete record
        List <int>    clientShareholderRowNoList  = new List <int>();
        List <string> responsibleStaffStaffIDList = new List <string>();
        List <string> currencyCodeList            = new List <string>();
        List <int>    memberListToBeDeleted       = new List <int>();
        List <int>    courtJudgeListToBeDeleted   = new List <int>();

        foreach (ClientShareholderInfo clientShareholderInfo in clientMasterInfo.ClientShareholderList)
        {
            clientShareholderRowNoList.Add(clientShareholderInfo.RowNo);
        }

        foreach (ResponsibleStaffInfo responsibleStaffInfo in clientMasterInfo.ResponsibleStaffList)
        {
            responsibleStaffStaffIDList.Add(responsibleStaffInfo.StaffID);
        }

        foreach (CurrencyInfo currencyInfo in clientMasterInfo.CurrencyList)
        {
            currencyCodeList.Add(currencyInfo.CurrencyCode);
        }

        foreach (ClientMemberInfo info in clientMasterInfo.ClientMemberList)
        {
            memberListToBeDeleted.Add(info.RowNo);
        }
        foreach (ClientCourtJudgeInfo info in clientMasterInfo.ClientCourtJudgeList)
        {
            courtJudgeListToBeDeleted.Add(info.RowNo);
        }

        this.DeleteResponsibleStaffNotInTheList(responsibleStaffStaffIDList, clientMasterInfo.ClientID);
        this.DeleteCurrencyNotInTheList(currencyCodeList, clientMasterInfo.ClientID);



        ClientShareholder cs = new ClientShareholder(this.db, transaction);

        cs.DeleteClientShareholderNotInTheList(clientShareholderRowNoList, clientMasterInfo.ClientID);
        foreach (ClientShareholderInfo clientShareholderInfo in clientMasterInfo.ClientShareholderList)
        {
            clientShareholderInfo.ClientID         = clientMasterInfo.ClientID;
            clientShareholderInfo.CreateUser       = clientMasterInfo.LastModifiedUser;
            clientShareholderInfo.CreateDate       = DateTime.Now;
            clientShareholderInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser;
            clientShareholderInfo.LastModifiedDate = DateTime.Now;
            cs.Save(clientShareholderInfo);
        }


        foreach (ResponsibleStaffInfo responsibleStaffInfo in clientMasterInfo.ResponsibleStaffList)
        {
            responsibleStaffInfo.CreateUser       = clientMasterInfo.LastModifiedUser;
            responsibleStaffInfo.CreateDate       = DateTime.Now;
            responsibleStaffInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser;
            responsibleStaffInfo.LastModifiedDate = DateTime.Now;
            this.SaveResponsibleStaffInfo(responsibleStaffInfo, clientMasterInfo.ClientID);
        }

        foreach (CurrencyInfo currencyInfo in clientMasterInfo.CurrencyList)
        {
            currencyInfo.CreateUser       = clientMasterInfo.LastModifiedUser;
            currencyInfo.CreateDate       = DateTime.Now;
            currencyInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser;
            currencyInfo.LastModifiedDate = DateTime.Now;
            this.SaveCurrencyInfo(currencyInfo, clientMasterInfo.ClientID);
        }

        ClientMember cm = new ClientMember(this.db, transaction);

        cm.deleteClientMemberTypeNotInList(memberListToBeDeleted, clientMasterInfo.ClientID);
        if (clientMasterInfo.ClientMemberList != null)
        {
            foreach (ClientMemberInfo info in clientMasterInfo.ClientMemberList)
            {
                info.ClientID         = clientMasterInfo.ClientID;
                info.CreateUser       = clientMasterInfo.LastModifiedUser;
                info.CreateDate       = DateTime.Now;
                info.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                info.LastModifiedDate = DateTime.Now;
                cm.Save(info);
            }
        }

        //Court Judge
        ClientCourtJudge ClientCourtJudge = new ClientCourtJudge(this.db, transaction);

        ClientCourtJudge.DeleteClientCourtJudgeNotInTheList(courtJudgeListToBeDeleted, clientMasterInfo.ClientID);
        if (clientMasterInfo.ClientCourtJudgeList != null)
        {
            foreach (ClientCourtJudgeInfo info in clientMasterInfo.ClientCourtJudgeList)
            {
                info.ClientID         = clientMasterInfo.ClientID;
                info.CreateUser       = clientMasterInfo.LastModifiedUser;
                info.CreateDate       = DateTime.Now;
                info.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                info.LastModifiedDate = DateTime.Now;
                ClientCourtJudge.Save(info);
            }
        }

        return(clientMasterInfo);
    }
Пример #7
0
    public ClientMasterInfo Insert(ClientMasterInfo clientMasterInfo)
    {
        string query = "INSERT INTO [dbo].[ClientMaster] "
                       + " ( [CompanyName] "
                       + ",[CompanyType] "
                       + ",[RegPlace] "
                       + ",[RegNo] "
                       + ",[TaxCodeNo] "
                       + ",[OrganizationCode] "
                       + ",[SocialUnifiedCreditCode] "
                       + ",[ExternalDebtNo] "
                       + ",[RegCapitalCurrency] "
                       + ",[RegCapital] "
                       + ",[RegShareCurrency] "
                       + ",[RegShare] "
                       + ",[NotRegCapitalCurrency] "
                       + ",[NotRegCapital] "
                       + ",[TotalCreditor] "
                       + ",[Website] "
                       + ",[Director] "
                       + ",[DirectorIdenNo] "
                       + ",[DirectorPhone] "
                       + ",[DirectorAddress] "
                       + ",[GenManager] "
                       + ",[GenManagerIdenNo] "
                       + ",[GenManagerPhone] "
                       + ",[GenManagerAddress] "
                       + ",[Secretary] "
                       + ",[SecretaryIdenNo] "
                       + ",[SecretaryPhone] "
                       + ",[SecretaryAddress] "
                       + ",[Supervisor] "
                       + ",[SupervisorIdenNo] "
                       + ",[SupervisorPhone] "
                       + ",[SupervisorAddress] "
                       + ",[Admin] "
                       + ",[AdminIdenNo] "
                       + ",[AdminPhone] "
                       + ",[AdminAddress] "
                       + ",[ContactEmail] "
                       + ",[LegalRepresentative] "
                       + ",[Relationship] "
                       + ",[EntrustAgent] "
                       + ",[CreateUser] "
                       + ",[CreateDate] "
                       + ",[LastModifiedUser] "
                       + ",[LastModifiedDate] "
                       + ") "
                       + "VALUES ( @CompanyName "
                       + ",@CompanyType "
                       + ",@RegPlace "
                       + ",@RegNo "
                       + ",@TaxCodeNo "
                       + ",@OrganizationCode "
                       + ",@SocialUnifiedCreditCode "
                       + ",@ExternalDebtNo "
                       + ",@RegCapitalCurrency "
                       + ",@RegCapital "
                       + ",@RegShareCurrency "
                       + ",@RegShare "
                       + ",@NotRegCapitalCurrency "
                       + ",@NotRegCapital "
                       + ",@TotalCreditor "
                       + ",@Website "
                       + ",@Director "
                       + ",@DirectorIdenNo "
                       + ",@DirectorPhone "
                       + ",@DirectorAddress "
                       + ",@GenManager "
                       + ",@GenManagerIdenNo "
                       + ",@GenManagerPhone "
                       + ",@GenManagerAddress "
                       + ",@Secretary "
                       + ",@SecretaryIdenNo "
                       + ",@SecretaryPhone "
                       + ",@SecretaryAddress "
                       + ",@Supervisor "
                       + ",@SupervisorIdenNo "
                       + ",@SupervisorPhone "
                       + ",@SupervisorAddress "
                       + ",@Admin "
                       + ",@AdminIdenNo "
                       + ",@AdminPhone "
                       + ",@AdminAddress "
                       + ",@ContactEmail "
                       + ",@LegalRepresentative "
                       + ",@Relationship "
                       + ",@EntrustAgent "
                       + ",@CreateUser "
                       + ",@CreateDate "
                       + ",@LastModifiedUser "
                       + ",@LastModifiedDate "
                       + ");select SCOPE_IDENTITY(); ";

        int    id        = ((List <int>)db.Query <int>(query, clientMasterInfo, transaction))[0];
        string tmpString = string.Format("00000000{0}", id);

        clientMasterInfo.ClientID = "C" + tmpString.Substring(tmpString.Length - 8);
        if (clientMasterInfo.ClientShareholderList != null)
        {
            ClientShareholder cs = new ClientShareholder(this.db, transaction);
            foreach (ClientShareholderInfo clientShareholderInfo in clientMasterInfo.ClientShareholderList)
            {
                clientShareholderInfo.ClientID         = clientMasterInfo.ClientID;
                clientShareholderInfo.CreateUser       = clientMasterInfo.LastModifiedUser;
                clientShareholderInfo.CreateDate       = DateTime.Now;
                clientShareholderInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                clientShareholderInfo.LastModifiedDate = DateTime.Now;
                cs.Save(clientShareholderInfo);
            }
        }



        if (clientMasterInfo.ResponsibleStaffList != null)
        {
            foreach (ResponsibleStaffInfo responsibleStaffInfo in clientMasterInfo.ResponsibleStaffList)
            {
                responsibleStaffInfo.ClientID         = clientMasterInfo.ClientID;
                responsibleStaffInfo.CreateUser       = clientMasterInfo.LastModifiedUser;
                responsibleStaffInfo.CreateDate       = DateTime.Now;
                responsibleStaffInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                responsibleStaffInfo.LastModifiedDate = DateTime.Now;
                this.InsertResponsibleStaff(responsibleStaffInfo);
            }
        }

        if (clientMasterInfo.CurrencyList != null)
        {
            foreach (CurrencyInfo currencyInfo in clientMasterInfo.CurrencyList)
            {
                currencyInfo.ClientID         = clientMasterInfo.ClientID;
                currencyInfo.CreateUser       = clientMasterInfo.LastModifiedUser;
                currencyInfo.CreateDate       = DateTime.Now;
                currencyInfo.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                currencyInfo.LastModifiedDate = DateTime.Now;
                this.InsertCurrency(currencyInfo);
            }
        }

        //Client Member
        if (clientMasterInfo.ClientMemberList != null)
        {
            ClientMember cm = new ClientMember(this.db, transaction);
            foreach (ClientMemberInfo info in clientMasterInfo.ClientMemberList)
            {
                info.ClientID         = clientMasterInfo.ClientID;
                info.CreateUser       = clientMasterInfo.LastModifiedUser;
                info.CreateDate       = DateTime.Now;
                info.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                info.LastModifiedDate = DateTime.Now;
                cm.Save(info);
            }
        }
        //Court Judge
        if (clientMasterInfo.ClientCourtJudgeList != null)
        {
            ClientCourtJudge ClientCourtJudge = new ClientCourtJudge(this.db, transaction);
            foreach (ClientCourtJudgeInfo info in clientMasterInfo.ClientCourtJudgeList)
            {
                info.ClientID         = clientMasterInfo.ClientID;
                info.CreateUser       = clientMasterInfo.LastModifiedUser;
                info.CreateDate       = DateTime.Now;
                info.LastModifiedUser = clientMasterInfo.LastModifiedUser;
                info.LastModifiedDate = DateTime.Now;
                ClientCourtJudge.Save(info);
            }
        }


        return(clientMasterInfo);
    }