Esempio n. 1
0
        public static DTO OperateOnAccount(AccOperationController accOperationController, Account account, DTO dto)
        {
            DTO answer = null;

            if (account != null)
            {
                if (accOperationController == null)
                {
                    accOperationController = new AccOperationController(account);
                }
                answer = accOperationController.performOperation(dto);
            }
            return(answer);
        }
Esempio n. 2
0
        public void connectionHandling()
        {
            Console.WriteLine("Tworze watek dla polaczenia");
            int max = 65565;

            Byte[] bytes = new Byte[max];
            int    i;
            bool   loged = false;
            AccConnectionController accConnectionController = new AccConnectionController(db);
            AccOperationController  accOperationController  = null;
            Account account = null;
            DTO     answer;

            while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
            {
                string     className  = ByteParser.byteToType(bytes);
                DtoFactory dtoFactory = new DtoFactory();
                DTO        dto        = dtoFactory.getDTO(className);
                dto.fromByteArray(bytes);
                answer = null;
                if (dto != null)
                {
                    if (loged == false)
                    {
                        answer = DTOUtil.Login(accConnectionController, ref account, ref loged, dto);
                    }
                    else if (loged == true && dto.getOperationType() == 1)
                    {
                        answer = DTOUtil.Login(accConnectionController, ref account, ref loged, dto);
                    }
                    else
                    {
                        if (dto.getOperationType() == 5)
                        {
                            answer = DTOUtil.Logout(dto, ref account, ref loged);
                        }
                        else
                        {
                            answer = DTOUtil.OperateOnAccount(accOperationController, account, dto);
                        }
                    }
                }
                byte[] data = answer.toByteArray();
                stream.Write(data, 0, data.Length);
            }
            client.Close();
        }