holdingID'"; $result = ExecuteQuery($query); $symbol = GetMSSQLValue($result, 0, 4); if ($symbol) { $order = createOrder($sellInfo->userID, $symbol, ORDER_TYPE_SELL, $sellInfo->quantity, $sellInfo->holdingID); /*$order->openDate = "2008-05-30T19:27:30.78125+05:30"; $order->completionDate = "2008-05-30T19:27:30.890625+05:30";*/ $order->orderStatus = "open"; if ($order) { processSubmitOrder($order); $response = new sellEnhanced(); $response->sellEnhancedReturn = new OrderDataBean(); $response->sellEnhancedReturn = $order; ExecuteQuery("COMMIT TRAN"); } else { ExecuteQuery("ROLLBACK TRAN"); } } else { ExecuteQuery("ROLLBACK TRAN"); } CloseDatabase($dbhandle); } } return $response; } /** * This is the utility method to get the Top orders of a user. * @param userID is the userID of a particular user. * @return an array of OrderDataBean objects. */ function processGetTopOrders($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "SELECT TOP ".TOP_ORDERS." ORDERID, ORDERTYPE, ORDERSTATUS, OPENDATE, COMPLETIONDATE, QUANTITY, PRICE, ORDERFEE, QUOTE_SYMBOL FROM ORDERS WHERE ORDERS.ACCOUNT_ACCOUNTID = (select ACCOUNT.ACCOUNTID from ACCOUNT WITH (NOLOCK) WHERE ACCOUNT.PROFILE_USERID = '$userID') ORDER BY ORDERS.ORDERID DESC"; $result = ExecuteQuery($query); if($result) { $response = new getOrdersResponse(); $response->getOrdersReturn = new ArrayOfOrderDataBean(); $rawNo = 0; while(($orderID = GetMSSQLValue($result, $rawNo, 0))) { $response->getOrdersReturn->OrderDataBean[$rawNo] = new OrderDataBean(); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderID = $orderID; $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderType = GetMSSQLValue($result, $rawNo, 1); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderStatus = GetMSSQLValue($result, $rawNo, 2); $response->getOrdersReturn->OrderDataBean[$rawNo]-> openDate = formatDate(GetMSSQLValue($result, $rawNo, 3)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> completionDate = formatDate(GetMSSQLValue($result, $rawNo, 4)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> quantity = GetMSSQLValue($result, $rawNo, 5); $response->getOrdersReturn->OrderDataBean[$rawNo]-> price = GetMSSQLValue($result, $rawNo, 6); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderFee = GetMSSQLValue($result, $rawNo, 7); $response->getOrdersReturn->OrderDataBean[$rawNo]-> symbol = GetMSSQLValue($result, $rawNo, 8); $rawNo = $rawNo + 1; } } CloseDatabase($dbhandle); } return $response; } /** * This utility method get the holding information of a particualr holding. * @param holdingInfo holdingID, and the userID * @return a HoldingDataBean object, which the holding information. */ function processGetHolding($holdingInfo) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "Set NOCOUNT ON; SELECT HOLDING.ACCOUNT_ACCOUNTID, HOLDING.QUANTITY, HOLDING.PURCHASEPRICE, HOLDING.PURCHASEDATE, HOLDING.QUOTE_SYMBOL FROM HOLDING WITH(NOLOCK) WHERE HOLDING.HOLDINGID='$holdingInfo->holdingID' AND HOLDING.ACCOUNT_ACCOUNTID = (SELECT ACCOUNTID FROM ACCOUNT WHERE PROFILE_USERID = '$holdingInfo->userID')"; $result = ExecuteQuery($query); if ($result) { $response = new getHoldingResponse(); $response->getHoldingReturn = new HoldingDataBean(); $response->getHoldingReturn->holdingID = $holdingInfo->holdingID; $response->getHoldingReturn->quantity = GetMSSQLValue($result, 0, 1); $response->getHoldingReturn->purchasePrice = GetMSSQLValue($result, 0, 2); $response->getHoldingReturn->purchaseDate = formatDate(GetMSSQLValue($result, 0, 3)); $response->getHoldingReturn->quoteID = GetMSSQLValue($result, 0, 4); } CloseDatabase($dbhandle); } return $response; } /** * This utility method is used to register a new user into the system. * @param userInfo, information required to register a new user to the system. * @return an AccountDataBean object correspond to the registered user. */ function processRegister($userInfo) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $queryAccount = "INSERT INTO account (CREATIONDATE, OPENBALANCE, LOGOUTCOUNT, BALANCE, LASTLOGIN, LOGINCOUNT, PROFILE_USERID) VALUES (GetDate(), '$userInfo->openBalance', '0', '$userInfo->openBalance', GetDate(), '0', '$userInfo->userID'); SELECT ID=@@IDENTITY"; $queryAccountProfile = "INSERT INTO accountprofile VALUES ('$userInfo->address', '$userInfo->password', '$userInfo->userID', '$userInfo->email', '$userInfo->creditCard', '$userInfo->fullname')"; $result = ExecuteQuery($queryAccountProfile); if ($result) { $result = null; $result = ExecuteQuery($queryAccount); $accountID = GetMSSQLValue($result, 0, 0); if ($accountID) { $response = new registerResponse(); $response->registerReturn = new AccountDataBean(); $response->registerReturn->accountID = $accountID; $response->registerReturn->loginCount = 0; $response->registerReturn->logoutCount = 0; $response->registerReturn->balance = $userInfo->openBalance; $response->registerReturn->openBalance = $userInfo->openBalance; $response->registerReturn->profileID = $accountID; } } CloseDatabase($dbhandle); } return $response; } /** * This utility method is used to get MarketSummary information. * @return a getMarketSummary object with market summary information. */ function processGetMarketSummary() { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $queryTSIA = "Set NOCOUNT ON; select SUM(price)/count(*) as TSIA from quote where symbol like 's:1__'"; $queryOPENTSIA = "Set NOCOUNT ON; select SUM(open1)/count(*) as openTSIA from quote where symbol like 's:1__'"; $queryVolume = "Set NOCOUNT ON; SELECT SUM(volume) from quote where symbol like 's:1__'"; $queryGainers = "Set NOCOUNT ON; SELECT symbol, companyname, volume, price, open1, low, high, change1 from quote with (NOLOCK) where symbol like 's:1__' order by change1 desc"; $queryLosers = "Set NOCOUNT ON; SELECT symbol, companyname, volume, price, open1, low, high, change1 from quote with (NOLOCK) where symbol like 's:1__' order by change1"; $response = new getMarketSummaryResponse(); $response->getMarketSummaryReturn = new MarketSummaryDataBeanWS(); $result = ExecuteQuery($queryTSIA); if ($result) { $response->getMarketSummaryReturn->TSIA = GetMSSQLValue($result, 0, 0); $result = null; } $result = ExecuteQuery($queryOPENTSIA); if ($result) { $response->getMarketSummaryReturn->openTSIA = GetMSSQLValue($result, 0, 0); $result = null; } $result = ExecuteQuery($queryVolume); if($result) { $response->getMarketSummaryReturn->volume = GetMSSQLValue($result, 0, 0); $result = null; } $result = ExecuteQuery($queryGainers); if($result) { $response->getMarketSummaryReturn->topGainers = new ArrayOfQuoteDataBean(); $rawNo = 0; while(($symbol = GetMSSQLValue($result, $rawNo, 0)) && $rawNo < 5) { $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo] = new QuoteDataBean(); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->symbol = $symbol; $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->companyName = GetMSSQLValue($result, 0, 1); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->volume = GetMSSQLValue($result, 0, 2); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->price = GetMSSQLValue($result, 0, 3); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->open = GetMSSQLValue($result, 0, 4); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->low = GetMSSQLValue($result, 0, 5); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->high = GetMSSQLValue($result, 0, 6); $response->getMarketSummaryReturn->topGainers-> QuoteDataBean[$rawNo]->change = GetMSSQLValue($result, 0, 7); $rawNo = $rawNo + 1; } $result = null; } $result = ExecuteQuery($queryLosers); if($result) { $response->getMarketSummaryReturn->topLosers = new ArrayOfQuoteDataBean(); $rawNo = 0; while(($symbol = GetMSSQLValue($result, $rawNo, 0)) && $rawNo < 5) { $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo] = new QuoteDataBean(); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->symbol = $symbol; $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->companyName = GetMSSQLValue($result, 0, 1); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->volume = GetMSSQLValue($result, 0, 2); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->price = GetMSSQLValue($result, 0, 3); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->open = GetMSSQLValue($result, 0, 4); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->low = GetMSSQLValue($result, 0, 5); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->high = GetMSSQLValue($result, 0, 6); $response->getMarketSummaryReturn->topLosers-> QuoteDataBean[$rawNo]->change = GetMSSQLValue($result, 0, 7); $rawNo = $rawNo + 1; } $result = null; } /*$result = ExecuteQuery($querySummaryDate); if($result) { $response->getMarketSummaryReturn->summaryDate = GetMSSQLValue($result, 0, 0); $result = null; }*/ CloseDatabase($dbhandle); } return $response; } /** * This utility method is used to get accountID corresond to a particular userID. * @param userID userID. * @return the accountID of the user. */ function getAccountID($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "Set NOCOUNT ON; SELECT ACCOUNTID FROM dbo.ACCOUNT WITH (NOLOCK) WHERE PROFILE_USERID = '$userID'"; $result = ExecuteQuery($query); if($result) { $response = GetMSSQLValue($result, 0, 0); } CloseDatabase($dbhandle); } return $response; } /** * This utility method is used to create an order in the system. * @param userID userID * @param symbol symbol * @param orderType type of the order (buy|sell) * @param quantity amount (buy|sell) * @param holdingID holdingID of the order (apply for sell) * @return an OrderDataBean object. */ function createOrder($userID, $symbol, $orderType, $quantity, $holdingID) { $order = null; $order = new OrderDataBean(); $order->price = INITIAL_ORDER_PRICE; $order->orderType = $orderType; $order->orderStatus = "open"; $order->quantity = $quantity; $order->symbol = $symbol; if ($orderType == ORDER_TYPE_BUY) { $order->orderFee = BUY_ORDER_FEE; } elseif ($orderType == ORDER_TYPE_SELL) { $order->orderFee = SELL_ORDER_FEE; } $query = "INSERT INTO ORDERS (OPENDATE, ORDERFEE, PRICE, QUOTE_SYMBOL, QUANTITY, ORDERTYPE, ORDERSTATUS, ACCOUNT_ACCOUNTID, HOLDING_HOLDINGID) VALUES (GETDATE(), '$order->orderFee', '$order->price', '$order->symbol', '$order->quantity', '$orderType', 'open', '".getAccountID($userID)."', '$holdingID'); SELECT ID=@@IDENTITY"; $result = ExecuteQuery($query); if ($result) { $order->orderID = GetMSSQLValue($result, 0, 0); } return $order; } /** * This is the utility method to process a sell request. * After creating an order, it passes it to order processor for * further processing. * @param buyInfo contains buy operation information. * @return an order object correspond to the order. */ function processBuy($buyInfo) { $dbhandle = ConnectToDatabase(); $response = null; if ($dbhandle) { $status = ExecuteQuery("BEGIN TRAN"); $order = createOrder($buyInfo->userID, $buyInfo->symbol, ORDER_TYPE_BUY, $buyInfo->quantity, INITIAL_HOLDING_ID); /*$order->openDate = "2008-05-30T19:27:30.78125+05:30"; $order->completionDate = "2008-05-30T19:27:30.890625+05:30";*/ $order->orderStatus = "open"; if ($order) { processSubmitOrder($order); $response = new buyResponse(); $response->buyReturn = new OrderDataBean(); $response->buyReturn = $order; ExecuteQuery("COMMIT TRAN"); } else { ExecuteQuery("ROLLBACK TRAN"); } CloseDatabase($dbhandle); } return $response; } /** * This method is used by the ConfigWeb application to check the connectivity. * @return a QuoteDataBean object with nill */ function connectivityResponse() { $response = new getQuoteResponse(); $response->getQuoteReturn = new QuoteDataBean(); return $response; } /** * This is the utility method to process a getQuote request. * @param symbol symbol. * @return a QuoteDataBean object. */ function processGetQuote($symbol) { if ($symbol) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "Set NOCOUNT ON; SELECT symbol, companyname, volume, price, open1, low, high, change1 from quote with (ROWLOCK) where symbol = '$symbol'"; $result = ExecuteQuery($query); if ($result) { $response = new getQuoteResponse(); $response->getQuoteReturn = new QuoteDataBean(); $response->getQuoteReturn->symbol = GetMSSQLValue($result, 0, 0); $response->getQuoteReturn->companyName = GetMSSQLValue($result, 0, 1); $response->getQuoteReturn->volume = GetMSSQLValue($result, 0, 2); $response->getQuoteReturn->price = GetMSSQLValue($result, 0, 3); $response->getQuoteReturn->open = GetMSSQLValue($result, 0, 4); $response->getQuoteReturn->low = GetMSSQLValue($result, 0, 5); $response->getQuoteReturn->high = GetMSSQLValue($result, 0, 6); $response->getQuoteReturn->change = GetMSSQLValue($result, 0, 7); } CloseDatabase($dbhandle); } } else { $response = connectivityResponse(); } return $response; } /** * This is the utility method that update Account profile information. * @param profileInfo information that needs to be updated in the profile. * @return a AccountProfileDataBean object. */ function processUpdateAccountProfile($profileInfo) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "UPDATE accountprofile WITH (ROWLOCK) SET ADDRESS='$profileInfo->address', PASSWORD='$profileInfo->password', EMAIL='$profileInfo->email', CREDITCARD = '$profileInfo->creditCard', FULLNAME='$profileInfo->fullName' WHERE USERID= '$profileInfo->userID'"; $result = ExecuteQuery($query); if($result) { $response = new updateAccountProfileResponse(); $response->updateAccountProfileReturn = new AccountProfileDataBean(); $response->updateAccountProfileReturn->userID = $profileInfo->userID; $response->updateAccountProfileReturn->password = $profileInfo->password; $response->updateAccountProfileReturn->fullName = $profileInfo->fullName; $response->updateAccountProfileReturn->address = $profileInfo->address; $response->updateAccountProfileReturn->email = $profileInfo->email; $response->updateAccountProfileReturn->creditCard = $profileInfo->creditCard; } else { } CloseDatabase($dbhandle); } return $response; } /** * Is used to process a logout request * @param userID userID * @return logoutResponse object */ function processLogout($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "UPDATE dbo.account WITH (ROWLOCK) SET LOGOUTCOUNT = (LOGOUTCOUNT + 1) where PROFILE_USERID= '$userID'"; $result = ExecuteQuery($query); if($result) { $response = new logoutResponse(); } CloseDatabase($dbhandle); } return $response; } /** * This method is used to get the holdings of a particular user. * @param userID userID * @return an array of HoldingDataBean objects. */ function processGetHoldings($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "SELECT HOLDING.HOLDINGID, HOLDING.QUANTITY, HOLDING.PURCHASEPRICE, HOLDING.PURCHASEDATE, HOLDING.QUOTE_SYMBOL,HOLDING.ACCOUNT_ACCOUNTID from holding WHERE HOLDING.ACCOUNT_ACCOUNTID = (SELECT ACCOUNTID FROM ACCOUNT WHERE PROFILE_USERID = '$userID') ORDER BY HOLDING.HOLDINGID DESC"; $result = ExecuteQuery($query); if($result) { $response = new getHoldingsResponse(); $response->getHoldingsReturn = new ArrayOfHoldingDataBean(); $rawNo = 0; while(($holdingID = GetMSSQLValue($result, $rawNo, 0))) { $response->getHoldingsReturn->HoldingDataBean[$rawNo] = new HoldingDataBean(); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> holdingID = GetMSSQLValue($result, $rawNo, 0); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> quantity = GetMSSQLValue($result, $rawNo, 1); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> purchasePrice = GetMSSQLValue($result, $rawNo, 2); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> purchaseDate = formatDate(GetMSSQLValue($result, $rawNo, 3)); $response->getHoldingsReturn->HoldingDataBean[$rawNo]-> quoteID = GetMSSQLValue($result, $rawNo, 4); $rawNo = $rawNo + 1; } } CloseDatabase($dbhandle); } return $response; } /** * This method obtains the set of closed orders. * @param userID userID * @return an array of OrderDataBean objects */ function processGetClosedOrders($userID) { $dbhandle = ConnectToDatabase(); $response = null; if ($dbhandle) { $query = "Set NOCOUNT ON; SELECT ORDERID, ORDERTYPE, ORDERSTATUS, COMPLETIONDATE, OPENDATE, QUANTITY, PRICE, ORDERFEE, QUOTE_SYMBOL FROM orders WHERE ACCOUNT_ACCOUNTID = (select accountid from account WITH(NOLOCK) where profile_userid = '$userID') AND ORDERSTATUS = 'closed'"; $result = ExecuteQuery($query); if ($result) { $response = new getClosedOrdersResponse(); $response->getClosedOrdersReturn = new ArrayOfOrderDataBean(); $rawNo = 0; while(($orderID = GetMSSQLValue($result, $rawNo, 0))) { $response->getClosedOrdersReturn->OrderDataBean[$rawNo] = new OrderDataBean(); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderID = $orderID; $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderType = GetMSSQLValue($result, 0, 1); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderStatus = GetMSSQLValue($result, $rawNo, 2); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> completionDate = formatDate(GetMSSQLValue($result, $rawNo, 3)); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> openDate = formatDate(GetMSSQLValue($result, $rawNo, 4)); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> quantity = GetMSSQLValue($result, $rawNo, 5); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> price = GetMSSQLValue($result, $rawNo, 6); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> orderFee = GetMSSQLValue($result, $rawNo, 7); $response->getClosedOrdersReturn->OrderDataBean[$rawNo]-> symbol = GetMSSQLValue($result, $rawNo, 8); $rawNo = $rawNo + 1; } $query = "UPDATE orders SET ORDERSTATUS = 'completed' where ORDERSTATUS = 'closed' AND ACCOUNT_ACCOUNTID = (select accountid from account WITH (NOLOCK) where profile_userid = '$userID')"; ExecuteQuery($query); } CloseDatabase($dbhandle); } return $response; } /** * This method is a utility method which obtains the AccountProfileData of * a user. * @param userID userID * @return an AccountProfileDataBean object. */ function processGetAccountProfileData($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "Set NOCOUNT ON; SELECT accountprofile.USERID, accountprofile.PASSWORD, accountprofile.FULLNAME, accountprofile.ADDRESS, accountprofile.EMAIL, accountprofile.CREDITCARD FROM accountprofile WITH (NOLOCK) WHERE accountprofile.USERID = '$userID'"; $result = ExecuteQuery($query); if($result) { $response = new getAccountProfileDataResponse(); $response->getAccountProfileDataReturn = new AccountProfileDataBean(); $response->getAccountProfileDataReturn->userID = $userID; $response->getAccountProfileDataReturn->password = GetMSSQLValue($result, 0, 1); $response->getAccountProfileDataReturn->fullName = GetMSSQLValue($result, 0, 2); $response->getAccountProfileDataReturn->address = GetMSSQLValue($result, 0, 3); $response->getAccountProfileDataReturn->email = GetMSSQLValue($result, 0, 4); $response->getAccountProfileDataReturn->creditCard = GetMSSQLValue($result, 0, 5); } CloseDatabase($dbhandle); } return $response; } /** * This method is used to get the Account data of a particular user. * @param userID userID * @return an AccountDataBean object */ function processGetAccountData($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "Set NOCOUNT ON; SELECT account.ACCOUNTID, account.PROFILE_USERID, account.CREATIONDATE, account.OPENBALANCE, account.LOGOUTCOUNT, account.BALANCE, account.LASTLOGIN, account.LOGINCOUNT FROM account WHERE account.PROFILE_USERID = '$userID'"; $result = ExecuteQuery($query); if ($result) { $response = new getAccountDataResponse(); $response->getAccountDataReturn = new AccountDataBean(); $response->getAccountDataReturn->accountID = GetMSSQLValue($result, 0, 0); $response->getAccountDataReturn->profileID = GetMSSQLValue($result, 0, 1); $response->getAccountDataReturn->creationDate = formatDate(GetMSSQLValue($result, 0, 2)); $response->getAccountDataReturn->openBalance = GetMSSQLValue($result, 0, 3); $response->getAccountDataReturn->logoutCount = GetMSSQLValue($result, 0, 4); $response->getAccountDataReturn->balance = GetMSSQLValue($result, 0, 5); $response->getAccountDataReturn->lastLogin = formatDate(GetMSSQLValue($result, 0, 6)); $response->getAccountDataReturn->loginCount = GetMSSQLValue($result, 0, 7); } CloseDatabase($dbhandle); } return $response; } /** * This method is used to get the orders that a particular user has placed. * @param userID userID * @return an array of OrderDataBean objects. */ function processGetOrders($userID) { $dbhandle = ConnectToDatabase(); $response = null; if($dbhandle) { $query = "SELECT ORDERID, ORDERTYPE, ORDERSTATUS, OPENDATE, COMPLETIONDATE, QUANTITY, PRICE, ORDERFEE, QUOTE_SYMBOL FROM ORDERS WHERE ORDERS.ACCOUNT_ACCOUNTID = (select ACCOUNT.ACCOUNTID from ACCOUNT WITH (NOLOCK) WHERE ACCOUNT.PROFILE_USERID = '$userID') ORDER BY ORDERS.ORDERID DESC"; $result = ExecuteQuery($query); if($result) { $response = new getOrdersResponse(); $response->getOrdersReturn = new ArrayOfOrderDataBean(); $rawNo = 0; while(($orderID = GetMSSQLValue($result, $rawNo, 0))) { $response->getOrdersReturn->OrderDataBean[$rawNo] = new OrderDataBean(); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderID = $orderID; $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderType = GetMSSQLValue($result, $rawNo, 1); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderStatus = GetMSSQLValue($result, $rawNo, 2); $response->getOrdersReturn->OrderDataBean[$rawNo]-> openDate = formatDate(GetMSSQLValue($result, $rawNo, 3)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> completionDate = formatDate(GetMSSQLValue($result, $rawNo, 4)); $response->getOrdersReturn->OrderDataBean[$rawNo]-> quantity = GetMSSQLValue($result, $rawNo, 5); $response->getOrdersReturn->OrderDataBean[$rawNo]-> price = GetMSSQLValue($result, $rawNo, 6); $response->getOrdersReturn->OrderDataBean[$rawNo]-> orderFee = GetMSSQLValue($result, $rawNo, 7); $response->getOrdersReturn->OrderDataBean[$rawNo]-> symbol = GetMSSQLValue($result, $rawNo, 8); $rawNo = $rawNo + 1; } } CloseDatabase($dbhandle); } return $response; } /** * This method is used to process a login request. * @param userID userID * @param password password * @return an AccountDataBean object. */ function processLogin($userID, $password) { $dbhandle = ConnectToDatabase(); $response = null; if ($dbhandle) { $query = "Set NOCOUNT ON; SELECT ACCOUNTPROFILE.USERID, ACCOUNTPROFILE.PASSWORD, ACCOUNTPROFILE.FULLNAME, ACCOUNTPROFILE.ADDRESS, ACCOUNTPROFILE.EMAIL, ACCOUNTPROFILE.CREDITCARD FROM ACCOUNTPROFILE WITH (NOLOCK) WHERE ACCOUNTPROFILE.USERID = '$userID'"; $result = ExecuteQuery($query); if ($password == GetMSSQLValue($result, 0, 1)) { $query = "UPDATE ACCOUNT WITH (ROWLOCK) SET LOGINCOUNT = (LOGINCOUNT + 1), LASTLOGIN = CURRENT_TIMESTAMP where PROFILE_USERID = '$userID'; SELECT ACCOUNT.ACCOUNTID, ACCOUNT.CREATIONDATE, ACCOUNT.OPENBALANCE, ACCOUNT.LOGOUTCOUNT, ACCOUNT.BALANCE, ACCOUNT.LASTLOGIN, ACCOUNT.LOGINCOUNT FROM ACCOUNT WITH (ROWLOCK) WHERE ACCOUNT.PROFILE_USERID = '$userID'"; $result = null; $result = ExecuteQuery($query); if ($result) { $response = new loginResponse(); $response->loginReturn = new AccountDataBean(); $response->loginReturn->accountID = GetMSSQLValue($result, 0, 0); $response->loginReturn->creationDate = formatDate(GetMSSQLValue($result, 0, 1)); $response->loginReturn->openBalance = GetMSSQLValue($result, 0, 2); $response->loginReturn->logoutCount = GetMSSQLValue($result, 0, 3); $response->loginReturn->balance = GetMSSQLValue($result, 0, 4); $response->loginReturn->lastLogin = formatDate(GetMSSQLValue($result, 0, 5)); $response->loginReturn->loginCount = GetMSSQLValue($result, 0, 6); $response->loginReturn->profileID = $userID; } } CloseDatabase($dbhandle); } return $response; } /** * This function formats the incoming date into the format * yy-mm-ddThh-min-sec format */ function formatDate($dateString) { return date ("Y-m-d\TH:i:s.100", strtotime($dateString)); } ?>