code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
#import <Foundation/Foundation.h> #import "HTTPResponse.h" @class HTTPConnection; // // This class is a UnitTest for the delayResponeHeaders capability of HTTPConnection // @interface HTTPResponseTest : NSObject <HTTPResponse> { HTTPConnection *connection; dispatch_queue_t connectionQueue; BOOL readyToSendResponseHeaders; } - (id)initWithConnection:(HTTPConnection *)connection; @end
007xsq-sadsad
Samples/DynamicServer/HTTPResponseTest.h
Objective-C
bsd
398
#import "DynamicServerAppDelegate.h" #import "HTTPServer.h" #import "MyHTTPConnection.h" #import "DDLog.h" #import "DDTTYLogger.h" // Log levels: off, error, warn, info, verbose static const int ddLogLevel = LOG_LEVEL_VERBOSE; @implementation DynamicServerAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Configure our logging framework. // To keep things simple and fast, we're just going to log to the Xcode console. [DDLog addLogger:[DDTTYLogger sharedInstance]]; // Initalize our http server httpServer = [[HTTPServer alloc] init]; // Tell server to use our custom MyHTTPConnection class. [httpServer setConnectionClass:[MyHTTPConnection class]]; // Tell the server to broadcast its presence via Bonjour. // This allows browsers such as Safari to automatically discover our service. [httpServer setType:@"_http._tcp."]; // Normally there's no need to run our server on any specific port. // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. // However, for easy testing you may want force a certain port so you can just hit the refresh button. // [httpServer setPort:12345]; // Serve files from our embedded Web folder NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; DDLogVerbose(@"Setting document root: %@", webPath); [httpServer setDocumentRoot:webPath]; // Start the server (and check for problems) NSError *error; BOOL success = [httpServer start:&error]; if(!success) { DDLogError(@"Error starting HTTP Server: %@", error); } } @end
007xsq-sadsad
Samples/DynamicServer/DynamicServerAppDelegate.m
Objective-C
bsd
1,644
#import "HTTPResponseTest.h" #import "HTTPConnection.h" #import "HTTPLogging.h" // Log levels: off, error, warn, info, verbose // Other flags: trace static const int httpLogLevel = HTTP_LOG_LEVEL_OFF; // | HTTP_LOG_FLAG_TRACE; // // This class is a UnitTest for the delayResponeHeaders capability of HTTPConnection // @interface HTTPResponseTest (PrivateAPI) - (void)doAsyncStuff; - (void)asyncStuffFinished; @end @implementation HTTPResponseTest - (id)initWithConnection:(HTTPConnection *)parent { if ((self = [super init])) { HTTPLogTrace(); connection = parent; // Parents retain children, children do NOT retain parents connectionQueue = dispatch_get_current_queue(); dispatch_retain(connectionQueue); readyToSendResponseHeaders = NO; dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); dispatch_async(concurrentQueue, ^{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self doAsyncStuff]; [pool release]; }); } return self; } - (void)doAsyncStuff { // This method is executed on a global concurrent queue HTTPLogTrace(); [NSThread sleepForTimeInterval:5.0]; dispatch_async(connectionQueue, ^{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self asyncStuffFinished]; [pool release]; }); } - (void)asyncStuffFinished { // This method is executed on the connectionQueue HTTPLogTrace(); readyToSendResponseHeaders = YES; [connection responseHasAvailableData:self]; } - (BOOL)delayResponeHeaders { HTTPLogTrace2(@"%@[%p] %@ -> %@", THIS_FILE, self, THIS_METHOD, (readyToSendResponseHeaders ? @"NO" : @"YES")); return !readyToSendResponseHeaders; } - (void)connectionDidClose { // This method is executed on the connectionQueue HTTPLogTrace(); connection = nil; } - (UInt64)contentLength { HTTPLogTrace(); return 0; } - (UInt64)offset { HTTPLogTrace(); return 0; } - (void)setOffset:(UInt64)offset { HTTPLogTrace(); // Ignored } - (NSData *)readDataOfLength:(NSUInteger)length { HTTPLogTrace(); return nil; } - (BOOL)isDone { HTTPLogTrace(); return YES; } - (void)dealloc { HTTPLogTrace(); dispatch_release(connectionQueue); [super dealloc]; } @end
007xsq-sadsad
Samples/DynamicServer/HTTPResponseTest.m
Objective-C
bsd
2,238
// // main.m // DynamicServer // // Created by Robbie Hanson on 11/20/10. // Copyright 2010 Voalte. All rights reserved. // #import <Cocoa/Cocoa.h> int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); }
007xsq-sadsad
Samples/DynamicServer/main.m
Objective-C
bsd
250
#import <Cocoa/Cocoa.h> @class HTTPServer; @interface DynamicServerAppDelegate : NSObject <NSApplicationDelegate> { HTTPServer *httpServer; NSWindow *window; } @property (assign) IBOutlet NSWindow *window; @end
007xsq-sadsad
Samples/DynamicServer/DynamicServerAppDelegate.h
Objective-C
bsd
220
#import "MyHTTPConnection.h" #import "HTTPDynamicFileResponse.h" #import "HTTPResponseTest.h" #import "HTTPLogging.h" // Log levels: off, error, warn, info, verbose // Other flags: trace static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE; @implementation MyHTTPConnection - (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path { // Use HTTPConnection's filePathForURI method. // This method takes the given path (which comes directly from the HTTP request), // and converts it to a full path by combining it with the configured document root. // // It also does cool things for us like support for converting "/" to "/index.html", // and security restrictions (ensuring we don't serve documents outside configured document root folder). NSString *filePath = [self filePathForURI:path]; // Convert to relative path NSString *documentRoot = [config documentRoot]; if (![filePath hasPrefix:documentRoot]) { // Uh oh. // HTTPConnection's filePathForURI was supposed to take care of this for us. return nil; } NSString *relativePath = [filePath substringFromIndex:[documentRoot length]]; if ([relativePath isEqualToString:@"/index.html"]) { HTTPLogVerbose(@"%@[%p]: Serving up dynamic content", THIS_FILE, self); // The index.html file contains several dynamic fields that need to be completed. // For example: // // Computer name: %%COMPUTER_NAME%% // // We need to replace "%%COMPUTER_NAME%%" with whatever the computer name is. // We can accomplish this easily with the HTTPDynamicFileResponse class, // which takes a dictionary of replacement key-value pairs, // and performs replacements on the fly as it uploads the file. NSString *computerName = [[NSHost currentHost] localizedName]; NSString *currentTime = [[NSDate date] description]; NSString *story = @"<br/><br/>" "I'll tell you a story <br/>" \ "About Jack a Nory; <br/>" \ "And now my story's begun; <br/>" \ "I'll tell you another <br/>" \ "Of Jack and his brother, <br/>" \ "And now my story is done. <br/>"; NSMutableDictionary *replacementDict = [NSMutableDictionary dictionaryWithCapacity:5]; [replacementDict setObject:computerName forKey:@"COMPUTER_NAME"]; [replacementDict setObject:currentTime forKey:@"TIME"]; [replacementDict setObject:story forKey:@"STORY"]; [replacementDict setObject:@"A" forKey:@"ALPHABET"]; [replacementDict setObject:@" QUACK " forKey:@"QUACK"]; HTTPLogVerbose(@"%@[%p]: replacementDict = \n%@", THIS_FILE, self, replacementDict); return [[[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path] forConnection:self separator:@"%%" replacementDictionary:replacementDict] autorelease]; } else if ([relativePath isEqualToString:@"/unittest.html"]) { HTTPLogVerbose(@"%@[%p]: Serving up HTTPResponseTest (unit testing)", THIS_FILE, self); return [[[HTTPResponseTest alloc] initWithConnection:self] autorelease]; } return [super httpResponseForMethod:method URI:path]; } @end
007xsq-sadsad
Samples/DynamicServer/MyHTTPConnection.m
Objective-C
bsd
3,358
<html> <head> <title>iPhone HTTP Server Example</title> </head> <body bgcolor="#FFFFFF"> <h1>Welcome to CocoaHTTPServer!</h1> You can customize this page for your app, make other pages, or even serve up dynamic content.<br/> <a href="http://code.google.com/p/cocoahttpserver/">CocoaHTTPServer Project Page</a><br/> </body> </html>
007xsq-sadsad
Samples/iPhoneHTTPServer/Web/index.html
HTML
bsd
333
// // main.m // iPhoneHTTPServer // // Created by Robbie Hanson on 11/25/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, nil); [pool release]; return retVal; }
007xsq-sadsad
Samples/iPhoneHTTPServer/main.m
Objective-C
bsd
372
#import "iPhoneHTTPServerViewController.h" @implementation iPhoneHTTPServerViewController @end
007xsq-sadsad
Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerViewController.m
Objective-C
bsd
98
#import <UIKit/UIKit.h> @class iPhoneHTTPServerViewController; @class HTTPServer; @interface iPhoneHTTPServerAppDelegate : NSObject <UIApplicationDelegate> { HTTPServer *httpServer; UIWindow *window; iPhoneHTTPServerViewController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet iPhoneHTTPServerViewController *viewController; @end
007xsq-sadsad
Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerAppDelegate.h
Objective-C
bsd
409
#import <UIKit/UIKit.h> @interface iPhoneHTTPServerViewController : UIViewController { } @end
007xsq-sadsad
Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerViewController.h
Objective-C
bsd
99
#import "iPhoneHTTPServerAppDelegate.h" #import "iPhoneHTTPServerViewController.h" #import "HTTPServer.h" #import "DDLog.h" #import "DDTTYLogger.h" // Log levels: off, error, warn, info, verbose static const int ddLogLevel = LOG_LEVEL_VERBOSE; @implementation iPhoneHTTPServerAppDelegate @synthesize window; @synthesize viewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Configure our logging framework. // To keep things simple and fast, we're just going to log to the Xcode console. [DDLog addLogger:[DDTTYLogger sharedInstance]]; // Create server using our custom MyHTTPServer class httpServer = [[HTTPServer alloc] init]; // Tell the server to broadcast its presence via Bonjour. // This allows browsers such as Safari to automatically discover our service. [httpServer setType:@"_http._tcp."]; // Normally there's no need to run our server on any specific port. // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. // However, for easy testing you may want force a certain port so you can just hit the refresh button. [httpServer setPort:12345]; // Serve files from our embedded Web folder NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; DDLogInfo(@"Setting document root: %@", webPath); [httpServer setDocumentRoot:webPath]; // Start the server (and check for problems) NSError *error; if(![httpServer start:&error]) { DDLogError(@"Error starting HTTP Server: %@", error); } // Add the view controller's view to the window and display. [window addSubview:viewController.view]; [window makeKeyAndVisible]; return YES; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end
007xsq-sadsad
Samples/iPhoneHTTPServer/Classes/iPhoneHTTPServerAppDelegate.m
Objective-C
bsd
1,851
<html> <head> <title>SimpleWebSocketServer</title> <script type="text/javascript" src="WebSocketTest.js"></script> <script type="text/javascript" src="WebSocketTest2.js"></script> </head> <body bgcolor="#FFFFFF"> <a href="javascript:WebSocketTest()">Does my browser support WebSockets?</a><br/> <br/> <a href="javascript:WebSocketTest2()">Open WebSocket and tell me what time it is.</a> </body> </html>
007xsq-sadsad
Samples/SimpleWebSocketServer/Web/index.html
HTML
bsd
402
function WebSocketTest2() { if ("WebSocket" in window) { var ws = new WebSocket("%%WEBSOCKET_URL%%"); ws.onopen = function() { // Web Socket is connected alert("websocket is open"); // You can send data now ws.send("Hey man, you got the time?"); }; ws.onmessage = function(evt) { alert("received: " + evt.data); }; ws.onclose = function() { alert("websocket is closed"); }; } else { alert("Browser doesn't support WebSocket!"); } }
007xsq-sadsad
Samples/SimpleWebSocketServer/Web/WebSocketTest2.js
JavaScript
bsd
467
function WebSocketTest() { if ("WebSocket" in window) { alert("WebSocket supported here! :)\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\n(based on Google sample code)"); } else { // Browser doesn't support WebSocket alert("WebSocket NOT supported here! :(\r\n\r\nBrowser: " + navigator.appName + " " + navigator.appVersion + "\r\n\r\n(based on Google sample code)"); } }
007xsq-sadsad
Samples/SimpleWebSocketServer/Web/WebSocketTest.js
JavaScript
bsd
417
#import <Foundation/Foundation.h> #import "HTTPConnection.h" @class MyWebSocket; @interface MyHTTPConnection : HTTPConnection { MyWebSocket *ws; } @end
007xsq-sadsad
Samples/SimpleWebSocketServer/MyHTTPConnection.h
Objective-C
bsd
156
#import "SimpleWebSocketServerAppDelegate.h" #import "HTTPServer.h" #import "MyHTTPConnection.h" #import "DDLog.h" #import "DDTTYLogger.h" // Log levels: off, error, warn, info, verbose static const int ddLogLevel = LOG_LEVEL_VERBOSE; @implementation SimpleWebSocketServerAppDelegate @synthesize window; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Configure our logging framework. // To keep things simple and fast, we're just going to log to the Xcode console. [DDLog addLogger:[DDTTYLogger sharedInstance]]; // Create server using our custom MyHTTPServer class httpServer = [[HTTPServer alloc] init]; // Tell server to use our custom MyHTTPConnection class. [httpServer setConnectionClass:[MyHTTPConnection class]]; // Tell the server to broadcast its presence via Bonjour. // This allows browsers such as Safari to automatically discover our service. [httpServer setType:@"_http._tcp."]; // Normally there's no need to run our server on any specific port. // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. // However, for easy testing you may want force a certain port so you can just hit the refresh button. [httpServer setPort:12345]; // Serve files from our embedded Web folder NSString *webPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Web"]; DDLogInfo(@"Setting document root: %@", webPath); [httpServer setDocumentRoot:webPath]; // Start the server (and check for problems) NSError *error; if(![httpServer start:&error]) { DDLogError(@"Error starting HTTP Server: %@", error); } } @end
007xsq-sadsad
Samples/SimpleWebSocketServer/SimpleWebSocketServerAppDelegate.m
Objective-C
bsd
1,652
#import <Cocoa/Cocoa.h> @class HTTPServer; @interface SimpleWebSocketServerAppDelegate : NSObject <NSApplicationDelegate> { HTTPServer *httpServer; NSWindow *window; } @property (assign) IBOutlet NSWindow *window; @end
007xsq-sadsad
Samples/SimpleWebSocketServer/SimpleWebSocketServerAppDelegate.h
Objective-C
bsd
226
#import "MyWebSocket.h" #import "HTTPLogging.h" // Log levels: off, error, warn, info, verbose // Other flags : trace static const int httpLogLevel = HTTP_LOG_LEVEL_WARN | HTTP_LOG_FLAG_TRACE; @implementation MyWebSocket - (void)didOpen { HTTPLogTrace(); [super didOpen]; [self sendMessage:@"Welcome to my WebSocket"]; } - (void)didReceiveMessage:(NSString *)msg { HTTPLogTrace2(@"%@[%p]: didReceiveMessage: %@", THIS_FILE, self, msg); [self sendMessage:[NSString stringWithFormat:@"%@", [NSDate date]]]; } - (void)didClose { HTTPLogTrace(); [super didClose]; } @end
007xsq-sadsad
Samples/SimpleWebSocketServer/MyWebSocket.m
Objective-C
bsd
589
// // main.m // SimpleWebSocketServer // // Created by Robbie Hanson on 4/20/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import <Cocoa/Cocoa.h> int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); }
007xsq-sadsad
Samples/SimpleWebSocketServer/main.m
Objective-C
bsd
268
#import <Foundation/Foundation.h> #import "WebSocket.h" @interface MyWebSocket : WebSocket { } @end
007xsq-sadsad
Samples/SimpleWebSocketServer/MyWebSocket.h
Objective-C
bsd
105
#import "MyHTTPConnection.h" #import "HTTPMessage.h" #import "HTTPResponse.h" #import "HTTPDynamicFileResponse.h" #import "GCDAsyncSocket.h" #import "MyWebSocket.h" #import "HTTPLogging.h" // Log levels: off, error, warn, info, verbose // Other flags: trace static const int httpLogLevel = HTTP_LOG_LEVEL_WARN; // | HTTP_LOG_FLAG_TRACE; @implementation MyHTTPConnection - (NSObject<HTTPResponse> *)httpResponseForMethod:(NSString *)method URI:(NSString *)path { HTTPLogTrace(); if ([path isEqualToString:@"/WebSocketTest2.js"]) { // The socket.js file contains a URL template that needs to be completed: // // ws = new WebSocket("%%WEBSOCKET_URL%%"); // // We need to replace "%%WEBSOCKET_URL%%" with whatever URL the server is running on. // We can accomplish this easily with the HTTPDynamicFileResponse class, // which takes a dictionary of replacement key-value pairs, // and performs replacements on the fly as it uploads the file. NSString *wsLocation; NSString *wsHost = [request headerField:@"Host"]; if (wsHost == nil) { NSString *port = [NSString stringWithFormat:@"%hu", [asyncSocket localPort]]; wsLocation = [NSString stringWithFormat:@"ws://localhost:%@%/service", port]; } else { wsLocation = [NSString stringWithFormat:@"ws://%@/service", wsHost]; } NSDictionary *replacementDict = [NSDictionary dictionaryWithObject:wsLocation forKey:@"WEBSOCKET_URL"]; return [[[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path] forConnection:self separator:@"%%" replacementDictionary:replacementDict] autorelease]; } return [super httpResponseForMethod:method URI:path]; } - (WebSocket *)webSocketForURI:(NSString *)path { HTTPLogTrace2(@"%@[%p]: webSocketForURI: %@", THIS_FILE, self, path); if([path isEqualToString:@"/service"]) { HTTPLogInfo(@"MyHTTPConnection: Creating MyWebSocket..."); return [[[MyWebSocket alloc] initWithRequest:request socket:asyncSocket] autorelease]; } return [super webSocketForURI:path]; } @end
007xsq-sadsad
Samples/SimpleWebSocketServer/MyHTTPConnection.m
Objective-C
bsd
2,180
#import <Cocoa/Cocoa.h> @class HTTPServer; @interface AppDelegate : NSObject { HTTPServer *httpServer; } @end
007xsq-sadsad
Samples/SimpleHTTPServer/AppDelegate.h
Objective-C
bsd
114
// // main.m // SimpleHTTPServer // // Created by Robert Hanson on 6/6/07. // Copyright Deusty Designs, LLC 2007. All rights reserved. // #import <Cocoa/Cocoa.h> int main(int argc, char *argv[]) { return NSApplicationMain(argc, (const char **) argv); }
007xsq-sadsad
Samples/SimpleHTTPServer/main.m
Objective-C
bsd
264
#import "AppDelegate.h" #import "HTTPServer.h" #import "DDLog.h" #import "DDTTYLogger.h" // Log levels: off, error, warn, info, verbose static const int ddLogLevel = LOG_LEVEL_VERBOSE; @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { // Configure our logging framework. // To keep things simple and fast, we're just going to log to the Xcode console. [DDLog addLogger:[DDTTYLogger sharedInstance]]; // Initalize our http server httpServer = [[HTTPServer alloc] init]; // Tell the server to broadcast its presence via Bonjour. // This allows browsers such as Safari to automatically discover our service. [httpServer setType:@"_http._tcp."]; // Normally there's no need to run our server on any specific port. // Technologies like Bonjour allow clients to dynamically discover the server's port at runtime. // However, for easy testing you may want force a certain port so you can just hit the refresh button. // [httpServer setPort:12345]; // Serve files from the standard Sites folder NSString *docRoot = [@"~/Sites" stringByExpandingTildeInPath]; DDLogInfo(@"Setting document root: %@", docRoot); [httpServer setDocumentRoot:docRoot]; NSError *error = nil; if(![httpServer start:&error]) { DDLogError(@"Error starting HTTP Server: %@", error); } } @end
007xsq-sadsad
Samples/SimpleHTTPServer/AppDelegate.m
Objective-C
bsd
1,344
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("CalculatorOperations")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CalculatorOperations")] [assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("32ce53b8-70a5-4d32-b5bd-36e8afefb235")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw1_cloud/CalculatorOperations/Properties/AssemblyInfo.cs
C#
asf20
1,452
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; namespace CalculatorWS { // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together. [ServiceContract] public interface ICalculator { [OperationContract] double add(double lOperand, double rOperand); [OperationContract] double sub(double lOperand, double rOperand); [OperationContract] double mul(double lOperand, double rOperand); [OperationContract] double div(double lOperand, double rOperand); } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorOperations/ICalculator.cs
C#
asf20
760
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("WCFServiceWebRole1")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("WCFServiceWebRole1")] [assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("6b49dc47-06b3-4798-b6b7-d60dc66924eb")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw1_cloud/WCFServiceWebRole1/Properties/AssemblyInfo.cs
C#
asf20
1,448
using System; using System.Diagnostics; using System.IO; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; namespace CalculatorWS { public class AzureLocalStorageTraceListener : XmlWriterTraceListener { public AzureLocalStorageTraceListener() : base(Path.Combine(AzureLocalStorageTraceListener.GetLogDirectory().Path, "CalculatorWS.svclog")) { } public static DirectoryConfiguration GetLogDirectory() { DirectoryConfiguration directory = new DirectoryConfiguration(); directory.Container = "wad-tracefiles"; directory.DirectoryQuotaInMB = 10; directory.Path = RoleEnvironment.GetLocalResource("CalculatorWS.svclog").RootPath; return directory; } } }
049011-cloud-2011
trunk/hw1_cloud/WCFServiceWebRole1/AzureLocalStorageTraceListener.cs
C#
asf20
846
using System; using System.Collections.Generic; using System.Linq; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; namespace CalculatorWS { public class WebRole : RoleEntryPoint { public override bool OnStart() { // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration(); diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1); diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory()); // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. return base.OnStart(); } } }
049011-cloud-2011
trunk/hw1_cloud/WCFServiceWebRole1/WebRole.cs
C#
asf20
957
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace CalculatorWS { public class CalculatorService : ICalculator { public double add(double lOperand, double rOperand) { return lOperand + rOperand; } public double sub(double lOperand, double rOperand) { return lOperand - rOperand; } public double mul(double lOperand, double rOperand) { return lOperand * rOperand; } public double div(double lOperand, double rOperand) { if (double.Equals(rOperand,0)) return 0; //This is our convension for dividing by 0 return lOperand / rOperand; } } }
049011-cloud-2011
trunk/hw1_cloud/WCFServiceWebRole1/CalculationService.svc.cs
C#
asf20
905
<%@ Application Codebehind="Global.asax.cs" Inherits="CalculatorWebRole.Global" Language="C#" %>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Global.asax
ASP.NET
asf20
101
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("CalculatorWebRole")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CalculatorWebRole")] [assembly: AssemblyCopyright("Copyright © 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("4059fd1d-b130-4693-a6b3-7ecc8865aee9")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Properties/AssemblyInfo.cs
C#
asf20
1,405
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.SessionState; namespace CalculatorWebRole { public class Global : System.Web.HttpApplication { void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Global.asax.cs
C#
asf20
1,200
using System; using System.Collections.Generic; using System.Linq; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; namespace CalculatorWebRole { public class WebRole : RoleEntryPoint { public override bool OnStart() { // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. return base.OnStart(); } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/WebRole.cs
C#
asf20
535
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="calculator.aspx.cs" Inherits="CalculatorWebRole.calculator" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <link rel="stylesheet" type="text/css" href="Styles/Site.css" /> <title>AOCalculator</title> </head> <body> <form id="CalculatorForm" runat="server"> <table> <tr> <td colspan="4"><asp:Label ID="lblDisplay" runat="server" Height="35px" Text="Label" Width="100%"></asp:Label> </td> </tr> <tr> <td><asp:Button ID="btn1" runat="server" CssClass="calcBtn" onclick="btn1_Click" Text="1" /></td> <td><asp:Button ID="btn2" runat="server" Text="2" CssClass="calcBtn" onclick="btn2_Click" /></td> <td><asp:Button ID="btn3" runat="server" Text="3" CssClass="calcBtn" onclick="btn3_Click" /></td> <td><asp:Button ID="addBtn" runat="server" Text="+" CssClass="calcBtn" onclick="addBtn_Click" /></td> </tr> <tr> <td><asp:Button ID="btn4" runat="server" Text="4" CssClass="calcBtn" onclick="btn4_Click" /></td> <td><asp:Button ID="btn5" runat="server" Text="5" CssClass="calcBtn" onclick="btn5_Click" /></td> <td><asp:Button ID="btn6" runat="server" Text="6" CssClass="calcBtn" onclick="btn6_Click" /></td> <td><asp:Button ID="subBtn" runat="server" Text="-" CssClass="calcBtn" onclick="subBtn_Click" /></td> </tr> <tr> <td><asp:Button ID="btn7" runat="server" Text="7" CssClass="calcBtn" onclick="btn7_Click" /></td> <td><asp:Button ID="btn8" runat="server" Text="8" CssClass="calcBtn" onclick="btn8_Click" /></td> <td><asp:Button ID="btn9" runat="server" Text="9" CssClass="calcBtn" onclick="btn9_Click" /></td> <td><asp:Button ID="multBtn" runat="server" Text="x" CssClass="calcBtn" onclick="mulBtn_Click" /></td> </tr> <tr> <td colspan="2"><asp:Button ID="clrBtn" runat="server" Text="clear" BackColor="Silver" Height="35px" Width="100%" style="margin-top: 0px" onclick="clrBtn_Click" /> </td> <td><asp:Button ID="btn0" runat="server" Text="0" CssClass="calcBtn" onclick="btn0_Click" /></td> <td><asp:Button ID="divBtn" runat="server" Text="/" CssClass="calcBtn" onclick="divBtn_Click" /></td> </tr> <tr> <td colspan="4"> <asp:Button ID="eqBtn" runat="server" Text="=" BackColor="Silver" Height="35px" Width="100%" onclick="eqBtn_Click" /> </td> </tr> </table> <asp:HiddenField ID="lOperand" runat="server" /> <asp:HiddenField ID="rOperand" runat="server" /> <asp:HiddenField ID="op" runat="server" /> </form> </body> </html>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/calculator.aspx
ASP.NET
asf20
2,963
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePasswordSuccess.aspx.cs" Inherits="CalculatorWebRole.Account.ChangePasswordSuccess" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Your password has been changed successfully. </p> </asp:Content>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/ChangePasswordSuccess.aspx
ASP.NET
asf20
534
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CalculatorWebRole.Account { public partial class ChangePassword : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/ChangePassword.aspx.cs
C#
asf20
355
<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="CalculatorWebRole.Account.Register" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser"> <LayoutTemplate> <asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder> <asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder> </LayoutTemplate> <WizardSteps> <asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server"> <ContentTemplate> <h2> Create a New Account </h2> <p> Use the form below to create a new account. </p> <p> Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <span class="failureNotification"> <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup"/> <div class="accountInfo"> <fieldset class="register"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label> <asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label> <asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server" ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User" ValidationGroup="RegisterUserValidationGroup"/> </p> </div> </ContentTemplate> <CustomNavigationTemplate> </CustomNavigationTemplate> </asp:CreateUserWizardStep> </WizardSteps> </asp:CreateUserWizard> </asp:Content>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/Register.aspx
ASP.NET
asf20
5,680
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CalculatorWebRole.Account { public partial class ChangePasswordSuccess : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/ChangePasswordSuccess.aspx.cs
C#
asf20
362
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; namespace CalculatorWebRole.Account { public partial class Register : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; } protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/"; } Response.Redirect(continueUrl); } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/Register.aspx.cs
C#
asf20
917
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="CalculatorWebRole.Account.ChangePassword" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Use the form below to change your password. </p> <p> New passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <asp:ChangePassword ID="ChangeUserPassword" runat="server" CancelDestinationPageUrl="~/" EnableViewState="false" RenderOuterTable="false" SuccessPageUrl="ChangePasswordSuccess.aspx"> <ChangePasswordTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="ChangeUserPasswordValidationGroup"/> <div class="accountInfo"> <fieldset class="changePassword"> <legend>Account Information</legend> <p> <asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword">Old Password:</asp:Label> <asp:TextBox ID="CurrentPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Old Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label> <asp:TextBox ID="NewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" CssClass="failureNotification" ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label> <asp:TextBox ID="ConfirmNewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm New Password is required." ToolTip="Confirm New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"/> <asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword" Text="Change Password" ValidationGroup="ChangeUserPasswordValidationGroup"/> </p> </div> </ChangePasswordTemplate> </asp:ChangePassword> </asp:Content>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/ChangePassword.aspx
ASP.NET
asf20
4,486
<%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CalculatorWebRole.Account.Login" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Log In </h2> <p> Please enter your username and password. <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account. </p> <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"> <LayoutTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="LoginUserValidationGroup"/> <div class="accountInfo"> <fieldset class="login"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:CheckBox ID="RememberMe" runat="server"/> <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label> </p> </fieldset> <p class="submitButton"> <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/> </p> </div> </LayoutTemplate> </asp:Login> </asp:Content>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/Login.aspx
ASP.NET
asf20
3,074
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CalculatorWebRole.Account { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Account/Login.aspx.cs
C#
asf20
475
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.ServiceModel; using Microsoft.WindowsAzure.ServiceRuntime; using CalculatorWS; namespace CalculatorWebRole { public partial class calculator : System.Web.UI.Page { /* * Calculator supported operations: number, operator, number, equal. * Punching the buttons in any other order wont work for now. */ private static ICalculator proxy = null; protected void Page_Load(object sender, EventArgs e) { if (proxy == null) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); string wsdlAddress = RoleEnvironment.GetConfigurationSettingValue("WSAddress"); EndpointAddress epAddress = new EndpointAddress(wsdlAddress); proxy = System.ServiceModel.ChannelFactory<ICalculator>.CreateChannel(binding, epAddress); } if (!Page.IsPostBack) { this.lblDisplay.Text = "0"; StoreInSession("restart", false); //this.PageTitleLabel.Text = RoleEnvironment.GetConfigurationSettingValue("GameTitle"); } this.btn0.Enabled = true; } protected void parseOperand(int operand) { if ((bool)GetFromSession("restart")) { lblDisplay.Text = "0"; StoreInSession("restart",false); } string parsedNum = lblDisplay.Text + operand.ToString(); lblDisplay.Text = double.Parse(parsedNum).ToString(); if (GetSessionString("op").Equals("Unknown")) StoreInSession("loperand", double.Parse(lblDisplay.Text)); else StoreInSession("roperand", double.Parse(lblDisplay.Text)); } private object GetFromSession(string keyName) { if (Request.RequestContext.HttpContext.Session[keyName] != null) { return Request.RequestContext.HttpContext.Session[keyName]; } return null; } private string GetSessionString(string keyName) { if (Request.RequestContext.HttpContext.Session[keyName] != null) { return Request.RequestContext.HttpContext.Session[keyName].ToString(); } return "Unknown"; } private double GetSessionDouble(string keyName) { if (Request.RequestContext.HttpContext.Session[keyName] != null) { return (double)Request.RequestContext.HttpContext.Session[keyName]; } return 0; } private void StoreInSession(string keyName, object value) { Request.RequestContext.HttpContext.Session.Add(keyName,value); } private void NumericOperation(string op) { if (!lblDisplay.Text.Equals(string.Empty)) StoreInSession("loperand", double.Parse(lblDisplay.Text)); StoreInSession("op", op); lblDisplay.Text = string.Empty; StoreInSession("restart",false); } protected void subBtn_Click(object sender, EventArgs e) { NumericOperation("sub"); } protected void addBtn_Click(object sender, EventArgs e) { NumericOperation("add"); } protected void mulBtn_Click(object sender, EventArgs e) { NumericOperation("mul"); } protected void divBtn_Click(object sender, EventArgs e) { NumericOperation("div"); this.btn0.Enabled = false; } protected void btn2_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn3_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn4_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn5_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn6_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn7_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn8_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn9_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn0_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected void btn1_Click(object sender, EventArgs e) { parseOperand(int.Parse((sender as Button).Text)); } protected bool allSet() { return (GetFromSession("loperand") != null && GetFromSession("roperand") != null && GetFromSession("op") != null); } protected void eqBtn_Click(object sender, EventArgs e) { if (allSet()) { if (GetSessionString("op").Equals("add")) lblDisplay.Text = proxy.add(GetSessionDouble("loperand"), GetSessionDouble("roperand")).ToString(); if (GetSessionString("op").Equals("sub")) lblDisplay.Text = proxy.sub(GetSessionDouble("loperand"), GetSessionDouble("roperand")).ToString(); if (GetSessionString("op").Equals("mul")) lblDisplay.Text = proxy.mul(GetSessionDouble("loperand"), GetSessionDouble("roperand")).ToString(); if (GetSessionString("op").Equals("div")) lblDisplay.Text = proxy.div(GetSessionDouble("loperand"), GetSessionDouble("roperand")).ToString(); Request.RequestContext.HttpContext.Session.Remove("op"); Request.RequestContext.HttpContext.Session.Remove("roperand"); StoreInSession("loperand",double.Parse(lblDisplay.Text)); StoreInSession("restart",true); } //clear(); } protected void clrBtn_Click(object sender, EventArgs e) { /* * Multiply by 0 to reset the calc */ NumericOperation("mul"); parseOperand(0); eqBtn_Click(null, null); } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/calculator.aspx.cs
C#
asf20
7,245
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CalculatorWebRole { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Default.aspx.cs
C#
asf20
341
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CalculatorWebRole._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>AOCalculator - Assaf's and Oshrit's Calculator</title> </head> <body> <h2> AOCalculator - Assaf's and Oshrit's Calculator </h2> <asp:Label ID="teamDetailsLabel" runat="server" Text="Team members:"> </asp:Label> <p> <b>Assaf Israel, ID 041707530</b><br /> <b>Oshrit Feder, ID 040832990</b><br /> </p> <p> Short bio:<br /> Assaf has a BSc in Computer Science from the Technion and started his MSc studies, <br /> Oshrit has a BSc in Computer Science from Tel Aviv university and currently a MBA 2012 Technion candidate<br /> We both love to eat cookies and this is our first Azure project! <br /><br /> Try out our <a href="calculator.aspx">calculator</a> </p> </body> </html>
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Default.aspx
ASP.NET
asf20
1,175
/* DEFAULTS ----------------------------------------------------------*/ body { background: #b6b7bc; font-size: .80em; font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; margin: 0px; padding: 0px; color: #696969; } a:link, a:visited { color: #034af3; } a:hover { color: #1d60ff; text-decoration: none; } a:active { color: #034af3; } p { margin-bottom: 10px; line-height: 1.6em; } /* HEADINGS ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #666666; font-variant: small-caps; text-transform: none; font-weight: 200; margin-bottom: 0px; } h1 { font-size: 1.6em; padding-bottom: 0px; margin-bottom: 0px; } h2 { font-size: 1.5em; font-weight: 600; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } /* this rule styles <h1> and <h2> tags that are the first child of the left and right table columns */ .rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2 { margin-top: 0px; } /* PRIMARY LAYOUT ELEMENTS ----------------------------------------------------------*/ .page { width: 960px; background-color: #fff; margin: 20px auto 0px auto; border: 1px solid #496077; } .header { position: relative; margin: 0px; padding: 0px; background: #4b6c9e; width: 100%; } .header h1 { font-weight: 700; margin: 0px; padding: 0px 0px 0px 20px; color: #f9f9f9; border: none; line-height: 2em; font-size: 2em; } .main { padding: 0px 12px; margin: 12px 8px 8px 8px; min-height: 420px; } .leftCol { padding: 6px 0px; margin: 12px 8px 8px 8px; width: 200px; min-height: 200px; } .footer { color: #4e5766; padding: 8px 0px 0px 0px; margin: 0px auto; text-align: center; line-height: normal; } /* TAB MENU ----------------------------------------------------------*/ div.hideSkiplink { background-color:#3a4f63; width:100%; } div.menu { padding: 4px 0px 4px 8px; } div.menu ul { list-style: none; margin: 0px; padding: 0px; width: auto; } div.menu ul li a, div.menu ul li a:visited { background-color: #465c71; border: 1px #4e667d solid; color: #dde4ec; display: block; line-height: 1.35em; padding: 4px 20px; text-decoration: none; white-space: nowrap; } div.menu ul li a:hover { background-color: #bfcbd6; color: #465c71; text-decoration: none; } div.menu ul li a:active { background-color: #465c71; color: #cfdbe6; text-decoration: none; } /* FORM ELEMENTS ----------------------------------------------------------*/ fieldset { margin: 1em 0px; padding: 1em; border: 1px solid #ccc; } fieldset p { margin: 2px 12px 10px 10px; } fieldset.login label, fieldset.register label, fieldset.changePassword label { display: block; } fieldset label.inline { display: inline; } legend { font-size: 1.1em; font-weight: 600; padding: 2px 4px 8px 4px; } input.textEntry { width: 320px; border: 1px solid #ccc; } input.passwordEntry { width: 320px; border: 1px solid #ccc; } div.accountInfo { width: 42%; } /* Calculator ----------------------------------------------------------*/ .calcBtn { height:35px; width: 35px; background-color:Silver; padding: 0px,0px,0px,0px; } /* MISC ----------------------------------------------------------*/ .clear { clear: both; } .title { display: block; float: left; text-align: left; width: auto; } .loginDisplay { font-size: 1.1em; display: block; text-align: right; padding: 10px; color: White; } .loginDisplay a:link { color: white; } .loginDisplay a:visited { color: white; } .loginDisplay a:hover { color: white; } .failureNotification { font-size: 1.2em; color: Red; } .bold { font-weight: bold; } .submitButton { text-align: right; padding-right: 10px; }
049011-cloud-2011
trunk/hw1_cloud/CalculatorWebRole/Styles/Site.css
CSS
asf20
4,451
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("ThumbnailWorker")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("ThumbnailWorker")] [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("1bbb8311-4bb2-432c-81ad-4311cf3355aa")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw3_cloud/ThumbnailWorker/Properties/AssemblyInfo.cs
C#
asf20
1,460
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Threading; using System.IO; using System.Data.Services.Client; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; using ThumbnailWorker; using SyncLibrary; namespace WorkerRole1 { public class WorkerRole : RoleEntryPoint { private CloudBlobContainer _blobContainer = null; private CloudQueue _queue = null; private CaptureTableService _captureTable = null; private WorkerTableService _workersTable = null; private string _wid = RoleEnvironment.CurrentRoleInstance.Id; private string captureSite(string url) { string outputPath = Environment.GetEnvironmentVariable("RoleRoot") + @"\approot"; string tempFilePath = Path.Combine(outputPath, ExtractDomainNameFromURL(url).Replace('.', '_') + ".png"); // TODO: use example filename generator Trace.TraceInformation("Starting capture on url " + url + ", output: " + tempFilePath); Trace.TraceInformation("Roleroot : " + Environment.GetEnvironmentVariable("RoleRoot") + @"\"); Trace.TraceInformation("Output dir: " + outputPath); Trace.TraceInformation("Output file: " + tempFilePath); var proc = new Process() { StartInfo = new ProcessStartInfo(Environment.GetEnvironmentVariable("RoleRoot") + @"\approot\CutyCapt.exe", string.Format(@"--url=""{0}"" --out=""{1}""", url, tempFilePath)) { UseShellExecute = false } }; proc.Start(); proc.WaitForExit(); if (File.Exists(tempFilePath)) { Trace.TraceInformation("Capture url " + url + " done."); return tempFilePath; } throw new CaptureError("Unable to create capture from URL: " + url); } public static string ExtractDomainNameFromURL(string Url) { if (!Url.Contains("://")) Url = "http://" + Url; return new Uri(Url).Host; } public override void Run() { /* * Setup */ var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); _blobContainer = initStorage(storageAccount); _queue = initQueue(storageAccount); _captureTable = initCaptureTable(storageAccount); _workersTable = initWorkersTable(storageAccount, _wid); /* * Main loop */ try { while (true) { /* * Batching messages handling to increase performance */ int numberOfMsg2Fetch = (int)Math.Floor(((double)_queue.RetrieveApproximateMessageCount()) / workersCount()) + 1; List<CloudQueueMessage> fetchedMessages = _queue.GetMessages(numberOfMsg2Fetch) .ToList<CloudQueueMessage>(); if (fetchedMessages.Count == 0 || (fetchedMessages.Count == 1 && fetchedMessages.First() == null)) { Thread.Sleep(TimeSpan.FromSeconds(3)); } else { Trace.TraceInformation("Worker " + _wid + " fetched " + fetchedMessages.Count + " messages from the queue."); fetchedMessages.ForEach(processMessage); } } } catch (Exception e) { Trace.TraceError("Fatal error occured: " + e.Message); Trace.TraceError("Trace: " + e.StackTrace); } finally { _workersTable.removeWorder(_wid); } } private void processMessage(CloudQueueMessage msg) { if (msg != null) { if (msg.DequeueCount < 3) // 3 Triels before discarding the message { string taskId = msg.AsString; Trace.TraceInformation("Worker " + _wid + " started working on task #" + taskId); string url = _captureTable.startProcessingCapture(taskId, _wid); string tempFilePath = null; try { tempFilePath = captureSite(url); } catch (CaptureError ce) { Trace.TraceWarning("Error!!! " + ce.Message); return; } CloudBlob blobRef = uploadCapture(tempFilePath); _captureTable.finishProcessingCapture(taskId, blobRef); Trace.TraceInformation("Worker " + _wid + " finished working on task #" + taskId); } _queue.DeleteMessage(msg); } } private int workersCount() { return _workersTable.workersCount(); } private CloudBlob uploadCapture(string tempFilePath) { FileInfo file = new FileInfo(tempFilePath); Trace.TraceInformation("Uploading capture... " + file.Name); string blobUri = Guid.NewGuid().ToString() + "_" + file.Name; var blob = _blobContainer.GetBlobReference(blobUri); blob.Properties.ContentType = "image/png"; blob.UploadFile(tempFilePath); Trace.TraceInformation("Upload capture blob done."); File.Delete(tempFilePath); return blob; } private CloudQueue initQueue(CloudStorageAccount storageAccount) { CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient(); CloudQueue queue = queueStorage.GetQueueReference("capturequeue"); try { queue.CreateIfNotExist(); } catch (StorageClientException e) { if (e.ErrorCode == StorageErrorCode.TransportError) { Trace.TraceError(string.Format("Connect failure! The most likely reason is that the local " + "Development Storage tool is not running or your storage account configuration is incorrect. " + "Message: '{0}'", e.Message)); System.Threading.Thread.Sleep(5000); } else { throw; } } Trace.TraceInformation("Queue initializaed"); return queue; } private CloudBlobContainer initStorage(CloudStorageAccount storageAccount) { CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobStorage.GetContainerReference("thumbnails"); try { container.CreateIfNotExist(); var permissions = container.GetPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Off; container.SetPermissions(permissions); } catch (StorageClientException e) { if (e.ErrorCode == StorageErrorCode.TransportError) { Trace.TraceError(string.Format("Connect failure! The most likely reason is that the local " + "Development Storage tool is not running or your storage account configuration is incorrect. " + "Message: '{0}'", e.Message)); System.Threading.Thread.Sleep(5000); } else { throw; } } return container; } public static CaptureTableService initCaptureTable(CloudStorageAccount storageAccount) { CloudTableClient.CreateTablesFromModel(typeof(CaptureTableService), storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials); return new CaptureTableService(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); } public static WorkerTableService initWorkersTable(CloudStorageAccount storageAccount, string wid) { CloudTableClient.CreateTablesFromModel(typeof(WorkerTableService), storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials); WorkerTableService wts = new WorkerTableService(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); /* * Registering worker */ wts.addWorker(wid); return wts; } public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // This code sets up a handler to update CloudStorageAccount instances when their corresponding // configuration settings change in the service configuration file. CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { // Provide the configSetter with the initial value configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); RoleEnvironment.Changed += (anotherSender, arg) => { if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>() .Any((change) => (change.ConfigurationSettingName == configName))) { // The corresponding configuration setting has changed, propagate the value if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))) { // In this case, the change to the storage account credentials in the // service configuration is significant enough that the role needs to be // recycled in order to use the latest settings. (for example, the // endpoint has changed) RoleEnvironment.RequestRecycle(); } } }; }); /* * Debug */ DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration(); // Transfer logs to storage every minute dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(10); dmc.Logs.BufferQuotaInMB = 10; // Transfer verbose, critical, etc. logs dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose; // Start up the diagnostic manager with the given configuration DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc); return base.OnStart(); } public override void OnStop() { _workersTable.removeWorder(_wid); base.OnStop(); } } }
049011-cloud-2011
trunk/hw3_cloud/ThumbnailWorker/WorkerRole.cs
C#
asf20
12,229
<%@ Application Codebehind="Global.asax.cs" Inherits="WebRole1.Global" Language="C#" %>
049011-cloud-2011
trunk/hw3_cloud/Website/Global.asax
ASP.NET
asf20
92
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1 { public partial class SiteMaster : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Site.Master.cs
C#
asf20
340
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Website")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("Website")] [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("fd3d9f92-900a-4fb9-af03-b35738f97424")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw3_cloud/Website/Properties/AssemblyInfo.cs
C#
asf20
1,403
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Stats.aspx.cs" Inherits="Website.Stats" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> <style type="text/css"> .style1 { text-decoration: underline; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <p class="style1"> <strong>Application Statistics</strong></p> <p> Active workers: <asp:Label ID="WorkersCount" runat="server" onload="WorkersCount_DataBinding" Text="0"></asp:Label> </p> <p> Captured URIs: <asp:Label ID="CapturesCount" runat="server" onload="CapturesCount_DataBinding" Text="0"></asp:Label> &nbsp;(Excluding pending)</p> <p> Pending URIs: <asp:Label ID="PendingURIs" runat="server" onload="PendingURIs_DataBinding" Text="0"></asp:Label> </p> <asp:GridView ID="WorkersStats" runat="server" AutoGenerateColumns="False" onload="WorkersStats_DataBinding" style="margin-top: 0px; text-align: center;"> <Columns> <asp:BoundField DataField="wid" HeaderText="Worker ID" /> <asp:BoundField DataField="imgCount" HeaderText="# Images" /> <asp:BoundField DataField="avgProcTime" HeaderText="Average image creation time [Sec]" /> </Columns> </asp:GridView> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/Stats.aspx
ASP.NET
asf20
1,561
<%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="SyncWebsite.About" %> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> About </h2> <p> Oshrit Feder & Assaf Israel <br /> Directory syncronizer using cloud storage. </p> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/About.aspx
ASP.NET
asf20
415
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.WindowsAzure.StorageClient; using System.Data.Services.Client; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.ServiceRuntime; using SyncLibrary; namespace Website { public partial class Stats : System.Web.UI.Page { private static CaptureTableService capturesTableService; private static WorkerTableService workersTableService; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { /* * Intialize only once */ var machineName = System.Environment.MachineName.ToLower(); var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); capturesTableService = CaptureTableService.initCaptureTable(account); workersTableService = WorkerTableService.initWorkersTable(account); } } catch (DataServiceRequestException ex) { Console.WriteLine("Unable to connect to the table storage server. Please check that the service is running.<br>" + ex.Message); } } protected void CapturesCount_DataBinding(object sender, EventArgs e) { this.CapturesCount.Text = capturesTableService.capturesCount().ToString(); } protected void WorkersCount_DataBinding(object sender, EventArgs e) { this.WorkersCount.Text = workersTableService.workersCount().ToString(); } protected void PendingURIs_DataBinding(object sender, EventArgs e) { this.PendingURIs.Text = capturesTableService.pendingCount().ToString(); } protected void WorkersStats_DataBinding(object sender, EventArgs e) { this.WorkersStats.DataSource = capturesTableService.getWorkersStats(); this.WorkersStats.DataBind(); } public List<WorkerStat> statsPerWorker() { List<WorkerStat> res = new List<WorkerStat>(); var workers = workersTableService.workers(); foreach(var w in workers) { // res.Add(capturesTableService.getWorkerStat(w.wid)); } return res; } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Stats.aspx.cs
C#
asf20
2,610
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.WindowsAzure.StorageClient; using System.Data.Services.Client; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.ServiceRuntime; using SyncLibrary; namespace SyncWebsite { public partial class LogsPage : System.Web.UI.Page { private static CaptureTableService captureTableContext; private static CloudBlobContainer container; private static IEnumerable<CaptureEntry> entries = null; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { /* * Intialize only once */ var machineName = System.Environment.MachineName.ToLower(); var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); captureTableContext = CaptureTableService.initCaptureTable(account); CloudBlobClient blob = new CloudBlobClient(account.BlobEndpoint, account.Credentials); container = blob.GetContainerReference("thumbnails"); } // this.ThumbnailView.DataSource = context.Captures; //Refresh at every read // this.dsThumbnails.EntitySetName = context.Capture; //Refresh at every read //this.ThumbnailView.DataBind(); } catch (DataServiceRequestException ex) { Console.WriteLine("Unable to connect to the table storage server. Please check that the service is running.<br>" + ex.Message); } } protected string GetSessionString(string keyName) { if (Request.RequestContext.HttpContext.Session[keyName] != null) { return Request.RequestContext.HttpContext.Session[keyName].ToString(); } return string.Empty; } protected object GetSessionObject(string keyName) { return Request.RequestContext.HttpContext.Session[keyName]; } private void StoreInSession(string keyName, object value) { Request.RequestContext.HttpContext.Session.Add(keyName, value); } protected void SearchSubmit_Click(object sender, EventArgs e) { this.ErrorLbl.Visible = (Boolean)false; string searchedURL = this.URLSearchText.Text; if (isValid(searchedURL)) { //IEnumerable<CaptureEntry> entries = from capture in context.Captures where capture.url == searchedURL select capture; entries = captureTableContext.getAllCapturesByUrl(searchedURL); /* CaptureEntry selectedCapture = (from capture in context.Captures where capture.url == searchedURL select capture).FirstOrDefault<CaptureEntry>(); */ //context.CapturesByID(searchedURL); //Refresh at every read // Handle url image // var cloudBlob = container.GetBlobReference(CaptureEntry.Uri.ToString()); // byte[] image = cloudBlob.DownloadByteArray(); //List<CaptureEntry> entriesList = new List<CaptureEntry>(entries); try { this.ThumbnailView.DataSource = entries.ToList(); this.ThumbnailView.DataBind(); } catch (DataServiceQueryException ex) { this.ErrorLbl.Visible = true; this.ErrorLbl.Text = "No data was found"; } } } private Boolean isValid(string url) { if (url == string.Empty) return false; else return true; } protected void ThumbnailView_PageIndexChanging(object sender, DetailsViewPageEventArgs e) { this.ThumbnailView.DataSource = entries.ToList(); this.ThumbnailView.PageIndex = e.NewPageIndex; this.ThumbnailView.DataBind(); } } }
049011-cloud-2011
trunk/hw3_cloud/Website/LogsPage.aspx.cs
C#
asf20
4,589
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="UploadPage.aspx.cs" Inherits="Website.UploadPage" %> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <div> <table> <tr><td>Select a file containing the urls to create captures for</td></tr> <tr><td><asp:FileUpload ID="FileUpload1" runat="server" Width="100%" /></td></tr> <tr><td><input id="Submit1" type="submit" value="Create thumbnails from file" /></td></tr> <tr><td><asp:Label ID="feedback" runat="server" Visible="false"></asp:Label></td></tr> </table> </div> <script language="javascript" type="text/javascript"> // <![CDATA[ // ]]> </script> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/UploadPage.aspx
ASP.NET
asf20
797
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.SessionState; using System.Data.Services.Client; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; using SyncLibrary; namespace WebRole1 { public class Global : System.Web.HttpApplication { void Application_Start(object sender, EventArgs e) { CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); }); /* * Intialize only once */ var machineName = System.Environment.MachineName.ToLower(); var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); CaptureTableService.initCaptureTable(account); WorkerTableService.initWorkersTable(account); } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Global.asax.cs
C#
asf20
1,942
using System; using System.Collections.Generic; using System.Linq; using System.Diagnostics; using System.Net; using System.Data.Services.Client; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; using SyncLibrary; namespace WebRole1 { public class WebRole : RoleEntryPoint { private CloudBlobContainer _blobContainer = null; private CloudQueue _queue = null; private CaptureTableService _captureTable = null; public override bool OnStart() { // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // This code sets up a handler to update CloudStorageAccount instances when their corresponding // configuration settings change in the service configuration file. CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { // Provide the configSetter with the initial value configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); RoleEnvironment.Changed += (anotherSender, arg) => { if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>() .Any((change) => (change.ConfigurationSettingName == configName))) { // The corresponding configuration setting has changed, propagate the value if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))) { // In this case, the change to the storage account credentials in the // service configuration is significant enough that the role needs to be // recycled in order to use the latest settings. (for example, the // endpoint has changed) RoleEnvironment.RequestRecycle(); } } }; }); /* * Setup */ var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); _blobContainer = initStorage(storageAccount); _queue = initQueue(storageAccount); _captureTable = initCaptureTable(storageAccount); return base.OnStart(); } private CloudQueue initQueue(CloudStorageAccount storageAccount) { CloudQueueClient queueStorage = storageAccount.CreateCloudQueueClient(); CloudQueue queue = queueStorage.GetQueueReference("capturequeue"); try { queue.CreateIfNotExist(); } catch (StorageClientException e) { if (e.ErrorCode == StorageErrorCode.TransportError) { Trace.TraceError(string.Format("Connect failure! The most likely reason is that the local " + "Development Storage tool is not running or your storage account configuration is incorrect. " + "Message: '{0}'", e.Message)); System.Threading.Thread.Sleep(5000); } else { throw; } } return queue; } private CloudBlobContainer initStorage(CloudStorageAccount storageAccount) { CloudBlobClient blobStorage = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobStorage.GetContainerReference("thumbnails"); try { container.CreateIfNotExist(); var permissions = container.GetPermissions(); permissions.PublicAccess = BlobContainerPublicAccessType.Off; container.SetPermissions(permissions); } catch (StorageClientException e) { if (e.ErrorCode == StorageErrorCode.TransportError) { Trace.TraceError(string.Format("Connect failure! The most likely reason is that the local " + "Development Storage tool is not running or your storage account configuration is incorrect. " + "Message: '{0}'", e.Message)); System.Threading.Thread.Sleep(5000); } else { throw; } } return container; } public static CaptureTableService initCaptureTable(CloudStorageAccount storageAccount) { CloudTableClient.CreateTablesFromModel(typeof(CaptureTableService), storageAccount.TableEndpoint.AbsoluteUri, storageAccount.Credentials); return new CaptureTableService(storageAccount.TableEndpoint.ToString(), storageAccount.Credentials); } } }
049011-cloud-2011
trunk/hw3_cloud/Website/WebRole.cs
C#
asf20
5,497
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePasswordSuccess.aspx.cs" Inherits="Website.Account.ChangePasswordSuccess" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Your password has been changed successfully. </p> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/Account/ChangePasswordSuccess.aspx
ASP.NET
asf20
524
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Website.Account { public partial class ChangePassword : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Account/ChangePassword.aspx.cs
C#
asf20
345
<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Website.Account.Register" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser"> <LayoutTemplate> <asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder> <asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder> </LayoutTemplate> <WizardSteps> <asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server"> <ContentTemplate> <h2> Create a New Account </h2> <p> Use the form below to create a new account. </p> <p> Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <span class="failureNotification"> <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup"/> <div class="accountInfo"> <fieldset class="register"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label> <asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label> <asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server" ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User" ValidationGroup="RegisterUserValidationGroup"/> </p> </div> </ContentTemplate> <CustomNavigationTemplate> </CustomNavigationTemplate> </asp:CreateUserWizardStep> </WizardSteps> </asp:CreateUserWizard> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/Account/Register.aspx
ASP.NET
asf20
5,670
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Website.Account { public partial class ChangePasswordSuccess : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Account/ChangePasswordSuccess.aspx.cs
C#
asf20
352
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; namespace Website.Account { public partial class Register : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; } protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/"; } Response.Redirect(continueUrl); } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Account/Register.aspx.cs
C#
asf20
907
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="Website.Account.ChangePassword" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Use the form below to change your password. </p> <p> New passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <asp:ChangePassword ID="ChangeUserPassword" runat="server" CancelDestinationPageUrl="~/" EnableViewState="false" RenderOuterTable="false" SuccessPageUrl="ChangePasswordSuccess.aspx"> <ChangePasswordTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="ChangeUserPasswordValidationGroup"/> <div class="accountInfo"> <fieldset class="changePassword"> <legend>Account Information</legend> <p> <asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword">Old Password:</asp:Label> <asp:TextBox ID="CurrentPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Old Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label> <asp:TextBox ID="NewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" CssClass="failureNotification" ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label> <asp:TextBox ID="ConfirmNewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm New Password is required." ToolTip="Confirm New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"/> <asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword" Text="Change Password" ValidationGroup="ChangeUserPasswordValidationGroup"/> </p> </div> </ChangePasswordTemplate> </asp:ChangePassword> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/Account/ChangePassword.aspx
ASP.NET
asf20
4,476
<%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Website.Account.Login" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Log In </h2> <p> Please enter your username and password. <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account. </p> <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"> <LayoutTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="LoginUserValidationGroup"/> <div class="accountInfo"> <fieldset class="login"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:CheckBox ID="RememberMe" runat="server"/> <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label> </p> </fieldset> <p class="submitButton"> <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/> </p> </div> </LayoutTemplate> </asp:Login> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/Account/Login.aspx
ASP.NET
asf20
3,064
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Website.Account { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Account/Login.aspx.cs
C#
asf20
465
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.WindowsAzure.StorageClient; using System.Data.Services.Client; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.ServiceRuntime; using SyncLibrary; namespace Website { public partial class DisplayImage : System.Web.UI.Page { private static CloudBlobContainer container; private static CloudBlobClient blob; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { /* * Intialize only once */ var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); blob = new CloudBlobClient(account.BlobEndpoint, account.Credentials); container = blob.GetContainerReference("thumbnails"); } } catch (DataServiceRequestException ex) { Console.WriteLine("Unable to connect to the table storage server. Please check that the service is running.<br>" + ex.Message); } String blobId = Request.QueryString["id"]; //Uri blobRef = new Uri(blobId); //blobId = blobRef.Segments[blobRef.Segments.Length - 1]; //var cloudBlob2 = blob.GetBlobReference(blobId); var cloudBlob = container.GetBlobReference(blobId); //byte[] imageBuf2 = cloudBlob2.DownloadByteArray(); byte[] imageBuf = cloudBlob.DownloadByteArray(); Response.ContentType = "image/jpeg"; Response.BinaryWrite(imageBuf); } } }
049011-cloud-2011
trunk/hw3_cloud/Website/DisplayImage.aspx.cs
C#
asf20
2,010
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="LogsPage.aspx.cs" Inherits="SyncWebsite.LogsPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <div> URL to search: <asp:TextBox ID="URLSearchText" runat="server"></asp:TextBox> <asp:Button ID="SearchSubmit" runat="server" Text="Search" onclick="SearchSubmit_Click" /> <asp:Label ID="ErrorLbl" runat="server" Text="Label" visible="false" ForeColor="Red"></asp:Label> <asp:DetailsView ID="ThumbnailView" runat="server" Caption="Thumbnail data" Height="250px" Width="276px" AutoGenerateRows="False" BorderStyle="None" EmptyDataText="No capture exists for the requested URL" GridLines="Horizontal" AllowPaging="True" onpageindexchanging="ThumbnailView_PageIndexChanging"> <Fields> <asp:ImageField HeaderText="Thumbnail:" DataImageUrlField="blobUri" DataImageUrlFormatString="DisplayImage.aspx?id={0}"> <ControlStyle Width="150px" height="150px" /> </asp:ImageField> <asp:BoundField DataField="blobUri" HeaderText="Webpage URL:" /> <asp:BoundField DataField="WorkerId" HeaderText="Responsible server name:" /> <asp:BoundField DataField="StartTime" HeaderText="Date taken:" /> </Fields> </asp:DetailsView> <!-- <asp:EntityDataSource ID="dsThumbnails" runat="server" EntitySetName="Captures" Where="it.url <= @URLSearchText"> <WhereParameters> <asp:ControlParameter ControlID="URLSearchText" Name="url" PropertyName="Text" Type="String" /> </WhereParameters> </asp:EntityDataSource> <asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="dsThumbnails"> </asp:QueryExtender> --> </div> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/LogsPage.aspx
ASP.NET
asf20
2,138
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SyncWebsite { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/Website/Default.aspx.cs
C#
asf20
335
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SyncWebsite._Default" %> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Welcome to Oshrit&#39;s and Assaf&#39;s Web-pages capturing service</h2> <br /> Use the menu above </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/Website/Default.aspx
ASP.NET
asf20
393
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DisplayImage.aspx.cs" Inherits="Website.DisplayImage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> </body> </html>
049011-cloud-2011
trunk/hw3_cloud/Website/DisplayImage.aspx
ASP.NET
asf20
374
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace SyncWebsite { public partial class About : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/Website/About.aspx.cs
C#
asf20
332
/* DEFAULTS ----------------------------------------------------------*/ body { background: #b6b7bc; font-size: .80em; font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; margin: 0px; padding: 0px; color: #696969; } a:link, a:visited { color: #034af3; } a:hover { color: #1d60ff; text-decoration: none; } a:active { color: #034af3; } p { margin-bottom: 10px; line-height: 1.6em; font-size: medium; margin-left: 40px; } /* HEADINGS ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #666666; font-variant: small-caps; text-transform: none; font-weight: 200; margin-bottom: 0px; } h1 { font-size: 1.6em; padding-bottom: 0px; margin-bottom: 0px; } h2 { font-size: 1.5em; font-weight: 600; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } /* this rule styles <h1> and <h2> tags that are the first child of the left and right table columns */ .rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2 { margin-top: 0px; } /* PRIMARY LAYOUT ELEMENTS ----------------------------------------------------------*/ .page { width: 960px; background-color: #fff; margin: 20px auto 0px auto; border: 1px solid #496077; } .header { position: relative; margin: 0px; padding: 0px; background: #4b6c9e; width: 100%; } .header h1 { font-weight: 700; margin: 0px; padding: 0px 0px 0px 20px; color: #f9f9f9; border: none; line-height: 2em; font-size: 2em; } .main { padding: 0px 12px; margin: 12px 8px 8px 8px; min-height: 420px; } .leftCol { padding: 6px 0px; margin: 12px 8px 8px 8px; width: 200px; min-height: 200px; } .footer { color: #4e5766; padding: 8px 0px 0px 0px; margin: 0px auto; text-align: center; line-height: normal; } /* TAB MENU ----------------------------------------------------------*/ div.hideSkiplink { background-color:#3a4f63; width:100%; } div.menu { padding: 4px 0px 4px 8px; } div.menu ul { list-style: none; margin: 0px; padding: 0px; width: auto; } div.menu ul li a, div.menu ul li a:visited { background-color: #465c71; border: 1px #4e667d solid; color: #dde4ec; display: block; line-height: 1.35em; padding: 4px 20px; text-decoration: none; white-space: nowrap; } div.menu ul li a:hover { background-color: #bfcbd6; color: #465c71; text-decoration: none; } div.menu ul li a:active { background-color: #465c71; color: #cfdbe6; text-decoration: none; } /* FORM ELEMENTS ----------------------------------------------------------*/ fieldset { margin: 1em 0px; padding: 1em; border: 1px solid #ccc; } fieldset p { margin: 2px 12px 10px 10px; } fieldset.login label, fieldset.register label, fieldset.changePassword label { display: block; } fieldset label.inline { display: inline; } legend { font-size: 1.1em; font-weight: 600; padding: 2px 4px 8px 4px; } input.textEntry { width: 320px; border: 1px solid #ccc; } input.passwordEntry { width: 320px; border: 1px solid #ccc; } div.accountInfo { width: 42%; } /* MISC ----------------------------------------------------------*/ .clear { clear: both; } .title { display: block; float: left; text-align: left; width: auto; } .loginDisplay { font-size: 1.1em; display: block; text-align: right; padding: 10px; color: White; } .loginDisplay a:link { color: white; } .loginDisplay a:visited { color: white; } .loginDisplay a:hover { color: white; } .failureNotification { font-size: 1.2em; color: Red; } .bold { font-weight: bold; } .submitButton { text-align: right; padding-right: 10px; }
049011-cloud-2011
trunk/hw3_cloud/Website/Styles/Site.css
CSS
asf20
4,306
using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.WindowsAzure; using SyncLibrary; using Microsoft.WindowsAzure.StorageClient; namespace Website { public partial class UploadPage : System.Web.UI.Page { static CloudStorageAccount account = null; static CaptureTableService context = null; static CloudQueue queue = null; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); CloudQueueClient queueStorage = account.CreateCloudQueueClient(); queue = queueStorage.GetQueueReference("capturequeue"); context = new CaptureTableService(account.TableEndpoint.ToString(), account.Credentials); } else { // Submitted // Parse file and put capture tasks on queue List<string> urlsToUpload = parseURLFile(this.FileUpload1.FileContent); generateTasks(urlsToUpload); // Message back the number of captures placed this.feedback.Text = "Number of sites to be captured : " + urlsToUpload.Count; this.feedback.Visible = true; } } private void generateTasks(List<string> urlsToUpload) { foreach (string url in urlsToUpload) { string requestId = context.addCaptureEntry(url); queue.AddMessage(new CloudQueueMessage(requestId)); } } private List<string> parseURLFile(System.IO.Stream stream) { List<string> urls = new List<string>(); StreamReader reader = new StreamReader(stream); string currentURL = null; while (!reader.EndOfStream) { currentURL = reader.ReadLine(); urls.Add(currentURL); } return urls; } } }
049011-cloud-2011
trunk/hw3_cloud/Website/UploadPage.aspx.cs
C#
asf20
2,342
<%@ Application Codebehind="Global.asax.cs" Inherits="WebRole1.Global" Language="C#" %>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Global.asax
ASP.NET
asf20
92
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1 { public partial class SiteMaster : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Site.Master.cs
C#
asf20
340
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("WebRole1")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("WebRole1")] [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("dea55a87-de9a-4f8b-bc2d-c7c87ce42c8b")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Properties/AssemblyInfo.cs
C#
asf20
1,405
<%@ Page Title="About Us" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebRole1.About" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> About </h2> <p> Put content here. </p> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/About.aspx
ASP.NET
asf20
441
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.SessionState; namespace WebRole1 { public class Global : System.Web.HttpApplication { void Application_Start(object sender, EventArgs e) { // Code that runs on application startup } void Application_End(object sender, EventArgs e) { // Code that runs on application shutdown } void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Global.asax.cs
C#
asf20
1,191
using System; using System.Collections.Generic; using System.Linq; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; namespace WebRole1 { public class WebRole : RoleEntryPoint { public override bool OnStart() { // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. return base.OnStart(); } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/WebRole.cs
C#
asf20
526
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePasswordSuccess.aspx.cs" Inherits="WebRole1.Account.ChangePasswordSuccess" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Your password has been changed successfully. </p> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/ChangePasswordSuccess.aspx
ASP.NET
asf20
525
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1.Account { public partial class ChangePassword : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/ChangePassword.aspx.cs
C#
asf20
346
<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="WebRole1.Account.Register" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser"> <LayoutTemplate> <asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder> <asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder> </LayoutTemplate> <WizardSteps> <asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server"> <ContentTemplate> <h2> Create a New Account </h2> <p> Use the form below to create a new account. </p> <p> Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <span class="failureNotification"> <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="RegisterUserValidationGroup"/> <div class="accountInfo"> <fieldset class="register"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label> <asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label> <asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server" ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match." ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User" ValidationGroup="RegisterUserValidationGroup"/> </p> </div> </ContentTemplate> <CustomNavigationTemplate> </CustomNavigationTemplate> </asp:CreateUserWizardStep> </WizardSteps> </asp:CreateUserWizard> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/Register.aspx
ASP.NET
asf20
5,671
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1.Account { public partial class ChangePasswordSuccess : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/ChangePasswordSuccess.aspx.cs
C#
asf20
353
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1.Account { public partial class Register : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; } protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/"; } Response.Redirect(continueUrl); } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/Register.aspx.cs
C#
asf20
908
<%@ Page Title="Change Password" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="WebRole1.Account.ChangePassword" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Change Password </h2> <p> Use the form below to change your password. </p> <p> New passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length. </p> <asp:ChangePassword ID="ChangeUserPassword" runat="server" CancelDestinationPageUrl="~/" EnableViewState="false" RenderOuterTable="false" SuccessPageUrl="ChangePasswordSuccess.aspx"> <ChangePasswordTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="ChangeUserPasswordValidationGroup"/> <div class="accountInfo"> <fieldset class="changePassword"> <legend>Account Information</legend> <p> <asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword">Old Password:</asp:Label> <asp:TextBox ID="CurrentPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Old Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label> <asp:TextBox ID="NewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" CssClass="failureNotification" ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label> <asp:TextBox ID="ConfirmNewPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="Confirm New Password is required." ToolTip="Confirm New Password is required." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:RequiredFieldValidator> <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword" CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry." ValidationGroup="ChangeUserPasswordValidationGroup">*</asp:CompareValidator> </p> </fieldset> <p class="submitButton"> <asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"/> <asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword" Text="Change Password" ValidationGroup="ChangeUserPasswordValidationGroup"/> </p> </div> </ChangePasswordTemplate> </asp:ChangePassword> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/ChangePassword.aspx
ASP.NET
asf20
4,477
<%@ Page Title="Log In" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="WebRole1.Account.Login" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Log In </h2> <p> Please enter your username and password. <asp:HyperLink ID="RegisterHyperLink" runat="server" EnableViewState="false">Register</asp:HyperLink> if you don't have an account. </p> <asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false"> <LayoutTemplate> <span class="failureNotification"> <asp:Literal ID="FailureText" runat="server"></asp:Literal> </span> <asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification" ValidationGroup="LoginUserValidationGroup"/> <div class="accountInfo"> <fieldset class="login"> <legend>Account Information</legend> <p> <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label> <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox> <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" CssClass="failureNotification" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label> <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator> </p> <p> <asp:CheckBox ID="RememberMe" runat="server"/> <asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline">Keep me logged in</asp:Label> </p> </fieldset> <p class="submitButton"> <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup"/> </p> </div> </LayoutTemplate> </asp:Login> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/Login.aspx
ASP.NET
asf20
3,065
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1.Account { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Account/Login.aspx.cs
C#
asf20
466
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Default.aspx.cs
C#
asf20
332
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebRole1._Default" %> <asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> </asp:Content> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> Welcome to ASP.NET! </h2> <p> To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>. </p> <p> You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409" title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>. </p> </asp:Content>
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Default.aspx
ASP.NET
asf20
742
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebRole1 { public partial class About : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/About.aspx.cs
C#
asf20
329
/* DEFAULTS ----------------------------------------------------------*/ body { background: #b6b7bc; font-size: .80em; font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif; margin: 0px; padding: 0px; color: #696969; } a:link, a:visited { color: #034af3; } a:hover { color: #1d60ff; text-decoration: none; } a:active { color: #034af3; } p { margin-bottom: 10px; line-height: 1.6em; } /* HEADINGS ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #666666; font-variant: small-caps; text-transform: none; font-weight: 200; margin-bottom: 0px; } h1 { font-size: 1.6em; padding-bottom: 0px; margin-bottom: 0px; } h2 { font-size: 1.5em; font-weight: 600; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } /* this rule styles <h1> and <h2> tags that are the first child of the left and right table columns */ .rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2 { margin-top: 0px; } /* PRIMARY LAYOUT ELEMENTS ----------------------------------------------------------*/ .page { width: 960px; background-color: #fff; margin: 20px auto 0px auto; border: 1px solid #496077; } .header { position: relative; margin: 0px; padding: 0px; background: #4b6c9e; width: 100%; } .header h1 { font-weight: 700; margin: 0px; padding: 0px 0px 0px 20px; color: #f9f9f9; border: none; line-height: 2em; font-size: 2em; } .main { padding: 0px 12px; margin: 12px 8px 8px 8px; min-height: 420px; } .leftCol { padding: 6px 0px; margin: 12px 8px 8px 8px; width: 200px; min-height: 200px; } .footer { color: #4e5766; padding: 8px 0px 0px 0px; margin: 0px auto; text-align: center; line-height: normal; } /* TAB MENU ----------------------------------------------------------*/ div.hideSkiplink { background-color:#3a4f63; width:100%; } div.menu { padding: 4px 0px 4px 8px; } div.menu ul { list-style: none; margin: 0px; padding: 0px; width: auto; } div.menu ul li a, div.menu ul li a:visited { background-color: #465c71; border: 1px #4e667d solid; color: #dde4ec; display: block; line-height: 1.35em; padding: 4px 20px; text-decoration: none; white-space: nowrap; } div.menu ul li a:hover { background-color: #bfcbd6; color: #465c71; text-decoration: none; } div.menu ul li a:active { background-color: #465c71; color: #cfdbe6; text-decoration: none; } /* FORM ELEMENTS ----------------------------------------------------------*/ fieldset { margin: 1em 0px; padding: 1em; border: 1px solid #ccc; } fieldset p { margin: 2px 12px 10px 10px; } fieldset.login label, fieldset.register label, fieldset.changePassword label { display: block; } fieldset label.inline { display: inline; } legend { font-size: 1.1em; font-weight: 600; padding: 2px 4px 8px 4px; } input.textEntry { width: 320px; border: 1px solid #ccc; } input.passwordEntry { width: 320px; border: 1px solid #ccc; } div.accountInfo { width: 42%; } /* MISC ----------------------------------------------------------*/ .clear { clear: both; } .title { display: block; float: left; text-align: left; width: auto; } .loginDisplay { font-size: 1.1em; display: block; text-align: right; padding: 10px; color: White; } .loginDisplay a:link { color: white; } .loginDisplay a:visited { color: white; } .loginDisplay a:hover { color: white; } .failureNotification { font-size: 1.2em; color: Red; } .bold { font-weight: bold; } .submitButton { text-align: right; padding-right: 10px; }
049011-cloud-2011
trunk/hw3_cloud/WebRole1/Styles/Site.css
CSS
asf20
4,258
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("WorkerRole1")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("WorkerRole1")] [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c44ade5b-b618-498d-8a01-ef6cf67f5b95")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw3_cloud/WorkerRole1/Properties/AssemblyInfo.cs
C#
asf20
1,452
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Threading; using Microsoft.WindowsAzure; using Microsoft.WindowsAzure.Diagnostics; using Microsoft.WindowsAzure.ServiceRuntime; using Microsoft.WindowsAzure.StorageClient; namespace WorkerRole1 { public class WorkerRole : RoleEntryPoint { public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.WriteLine("WorkerRole1 entry point called", "Information"); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); } } public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. return base.OnStart(); } } }
049011-cloud-2011
trunk/hw3_cloud/WorkerRole1/WorkerRole.cs
C#
asf20
1,157
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("SyncLibrary")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("SyncLibrary")] [assembly: AssemblyCopyright("Copyright © Microsoft 2011")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("838bd4bb-51d5-4ca7-813f-fe1de36febe6")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
049011-cloud-2011
trunk/hw2_cloud/SyncLibrary/Properties/AssemblyInfo.cs
C#
asf20
1,452
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SyncLibrary { public class WorkerStat { public string wid { get; set; } public int imgCount { get; set; } public double avgProcTime { get; set; } } }
049011-cloud-2011
trunk/hw2_cloud/SyncLibrary/WorkerStat.cs
C#
asf20
300
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SyncLibrary { public class WorkerEntry : Microsoft.WindowsAzure.StorageClient.TableServiceEntity { public string wid { get; set; } public WorkerEntry() { PartitionKey = "b"; RowKey = string.Format("{0:10}_{1}", DateTime.MaxValue.Ticks - DateTime.Now.Ticks, Guid.NewGuid()); } override public string ToString() { return string.Format("id: {0}", wid); } } }
049011-cloud-2011
trunk/hw2_cloud/SyncLibrary/WorkerEntry.cs
C#
asf20
585
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.WindowsAzure.StorageClient; using Microsoft.WindowsAzure; namespace SyncLibrary { public class WorkerTableService : TableServiceContext { public IQueryable<WorkerEntry> Workers { get { return this.CreateQuery<WorkerEntry>("workers"); } } public WorkerTableService(string baseAddress, StorageCredentials credentials) : base(baseAddress, credentials) { /* foreach (var w in Workers) { DeleteObject(w); } SaveChanges(); */ } public void addWorker(string wid) { string id = Guid.NewGuid().ToString(); this.AddObject("workers", new WorkerEntry { wid = wid }); this.SaveChanges(); } public void removeWorder(string wid) { WorkerEntry w = (from worker in Workers where worker.wid == wid select worker).First<WorkerEntry>(); this.DeleteObject(w); this.SaveChanges(); } public int workersCount() { IEnumerable<WorkerEntry> workers = from w in Workers select w; return workers.Count<WorkerEntry>(); } public IEnumerable<WorkerEntry> workers() { return (from w in Workers select w); } public static WorkerTableService initWorkersTable(CloudStorageAccount account) { CloudTableClient.CreateTablesFromModel(typeof(WorkerTableService), account.TableEndpoint.AbsoluteUri, account.Credentials); return new WorkerTableService(account.TableEndpoint.ToString(), account.Credentials); } } }
049011-cloud-2011
trunk/hw2_cloud/SyncLibrary/WorkerTableService.cs
C#
asf20
1,974