Skip to content

Commit

Permalink
add all
Browse files Browse the repository at this point in the history
  • Loading branch information
freshmenyuan committed Dec 10, 2014
1 parent ffb0047 commit e135354
Show file tree
Hide file tree
Showing 25 changed files with 20,336 additions and 3 deletions.
22 changes: 22 additions & 0 deletions Customer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#coding:utf8

class Customer:

def __init__(self,ID, Name,Country,City):

self.ID = ID
self.Name = Name
self.Country = Country
self.City = City

def getID(self):
return self.ID

def getName(self):
return self.Name

def getCountry(self):
return self.Country

def getCity(self):
return self.City
26 changes: 26 additions & 0 deletions CustomerTable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#coding:utf8

from azure.storage import TableService, Entity

class CustomerTable:

def __init__(self):
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')

def insert(self,ID,Name,Country,City):
task = {'PartitionKey': 'Customer',
'RowKey': ID,
'Name' : Name ,
'Country' : Country,
'City' : City}
try:
self.table_service.insert_entity('Customer', task)
except:
print"azure.WindowsAzureConflictError: Customer Conflict"
def listAll(self):
tasks = self.table_service.query_entities('Customer', "PartitionKey eq 'Customer'")
i=0
for task in tasks:
i=i+1
print("Name: %s, Country: %s, City: %s") %(task.Name,task.Country,task.City)
print("Total Customer: %s") %(i)
Binary file added CustomerTable.pyc
Binary file not shown.
70 changes: 70 additions & 0 deletions Iterator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#coding:utf8
import json
import urllib2
from azure.storage import TableService, Entity

class Iterator:
def __init__(self,table):
self.DataCollector = []
self.i=0
self.Table=table
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
self.task = self.table_service.query_entities(self.Table, None, None, 100)

if table=="Customer":
self.i=self.i+100
print(self.i)
for line in self.task:
self.DataCollector.append({'ID': line.RowKey,
'Name' : line.Name ,
'Country' : line.Country,
'City' : line.City})
self.iteratorCustomer(self.task)

if table=="Order":
self.i=self.i+100
print(self.i)
for line in self.task:
self.DataCollector.append({'ID': line.RowKey,
'CustomerID' : line.CustomerID,
'ProductID' : line.ProductID,
'Datetime' : line.Datetime,
'TotalPrice' : line.TotalPrice})
self.iteratorOrder(self.task)

def iteratorCustomer(self,task):
try:
data = self.table_service.query_entities(self.Table, None, None, 100,
task.x_ms_continuation['NextPartitionKey'],
task.x_ms_continuation['NextRowKey'])
self.i=self.i+len(data)
print(self.i)
for line in data:
self.DataCollector.append({'ID': line.RowKey,
'Name' : line.Name ,
'Country' : line.Country,
'City' : line.City})
self.iteratorCustomer(data)
except:
pass

def iteratorOrder(self,task):
try:
data = self.table_service.query_entities(self.Table, None, None, 100,
task.x_ms_continuation['NextPartitionKey'],
task.x_ms_continuation['NextRowKey'])
self.i=self.i+len(data)
print(self.i)
for line in data:
self.DataCollector.append({'ID': line.RowKey,
'CustomerID' : line.CustomerID,
'ProductID' : line.ProductID,
'Datetime' : line.Datetime,
'TotalPrice' : line.TotalPrice})
self.iteratorOrder(data)
except:
pass

def getDatas(self):
return self.DataCollector
Binary file added Iterator.pyc
Binary file not shown.
24 changes: 24 additions & 0 deletions Order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#coding:utf8

class Order:

def __init__(self,ID,CustomerID,ProductID,Datetime,TotalPrice):
self.ID = ID
self.CustomerID = CustomerID
self.ProductID = ProductID
self.Datetime = Datetime
self.TotalPrice = TotalPrice
def getID(self):
return self.ID

def getCustomerID(self):
return self.CustomerID

def getProductID(self):
return self.ProductID

def getDatetime(self):
return self.Datetime

def getTotalPrice(self):
return self.TotalPrice
72 changes: 72 additions & 0 deletions OrderTable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#coding:utf8

from azure.storage import TableService, Entity
import json

class OrderTable:

def __init__(self):
self.table_service = TableService(account_name='portalvhdspbrd34f2fnbl',
account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')

def insert(self,ID,CustomerID,ProductID,Datetime,TotalPrice):
task = {'PartitionKey': 'Order',
'RowKey': ID,
'CustomerID' : CustomerID,
'ProductID' : ProductID,
'Datetime' : Datetime,
'TotalPrice' : TotalPrice}
try:
self.table_service.insert_entity('Order', task)
except:
print"azure.WindowsAzureConflictError: Order Conflict"


def listAll(self):
task1 = self.table_service.query_entities('Order', None, None, 1000)
task2 = self.table_service.query_entities('Order', None, None, 1000,
task1.x_ms_continuation['NextPartitionKey'],
task1.x_ms_continuation['NextRowKey'])
task3 = self.table_service.query_entities('Order', None, None, 1000,
task2.x_ms_continuation['NextPartitionKey'],
task2.x_ms_continuation['NextRowKey'])
task4 = self.table_service.query_entities('Order', None, None, 1000,
task3.x_ms_continuation['NextPartitionKey'],
task3.x_ms_continuation['NextRowKey'])
'''
task5 = self.table_service.query_entities('Order', None, None, 1000,
task4.x_ms_continuation['NextPartitionKey'],
task4.x_ms_continuation['NextRowKey'])
task6 = self.table_service.query_entities('Order', None, None, 1000,
task5.x_ms_continuation['NextPartitionKey'],
task5.x_ms_continuation['NextRowKey'])
task7 = self.table_service.query_entities('Order', None, None, 1000,
task6.x_ms_continuation['NextPartitionKey'],
task6.x_ms_continuation['NextRowKey'])
task8 = self.table_service.query_entities('Order', None, None, 1000,
task7.x_ms_continuation['NextPartitionKey'],
task7.x_ms_continuation['NextRowKey'])
task9 = self.table_service.query_entities('Order', None, None, 1000,
task8.x_ms_continuation['NextPartitionKey'],
task8.x_ms_continuation['NextRowKey'])
task10 = self.table_service.query_entities('Order', None, None, 1000,
task9.x_ms_continuation['NextPartitionKey'],
task9.x_ms_continuation['NextRowKey'])
'''
i=0
for task in task1:
i=i+1
'''
print("ID: %s, CustomerID: %s, ProductID: %s, Datetime: %s, TotalPrice: %s") %(task.RowKey,
task.CustomerID,task.ProductID,task.Datetime,task.TotalPrice)
'''
print(task.TotalPrice)
for task in task2:
i=i+1
print(task.TotalPrice)
print("Total Order: %s") %(i)

def TableInfo(self):
info=self.table_service.query_tables()
for i in info:
print(i.name)
Binary file added OrderTable.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion PointOfSaleApplication
Submodule PointOfSaleApplication deleted from d087ea
22 changes: 22 additions & 0 deletions ReceiveMessageFromQueue.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#coding:utf8

from azure.storage import QueueService
from azure.servicebus import ServiceBusService, Message, Queue
class ReceiveMessage:

def __init__(self):
self.messages = None

def message(self):

try:
queue_service = QueueService(account_name='portalvhdspbrd34f2fnbl',account_key='y48JkXg+VcHQRCgsylJf4xV4Fd0AuJNkQKSwGhAR+BppHnFhkI+UHPOS/oYaTo0rqFCGQkEBW+thNFZNB9W8yg==')
#queue_service.create_queue('taskqueue')
self.messages = queue_service.get_messages('taskqueue')
for message in messages:
''' print(message.message_text)'''
self.queue_service.delete_message('taskqueue', message.message_id, message.pop_receipt)
except:
pass

return self.messages
Binary file added ReceiveMessageFromQueue.pyc
Binary file not shown.
9 changes: 9 additions & 0 deletions ReportA.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

{"Country": "Country", "TotalPrice": 0, "CustomerNumber": 0}
{"Country": "United Kingdom", "TotalPrice": 49371795, "CustomerNumber": 9956}
{"Country": "Country", "TotalPrice": 1, "CustomerNumber": 1}
{"Country": "United Kingdom", "TotalPrice": 49371795, "CustomerNumber": 9956}
{"Country": "Country", "TotalPrice": 1, "CustomerNumber": 1}
{"Country": "United Kingdom", "TotalPrice": 49371795, "CustomerNumber": 9956}
{"Country": "Country", "TotalPrice": 1, "CustomerNumber": 1}
{"Country": "United Kingdom", "TotalPrice": 49371795, "CustomerNumber": 9956}
3 changes: 3 additions & 0 deletions ReportB.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

{"Country": "Country", "AverageOrderPrice": 1}
{"Country": "United Kingdom", "AverageOrderPrice": 4958}
Loading

0 comments on commit e135354

Please sign in to comment.