Browse files

Implementing input/output dir and yaml decode

  • Loading branch information...
1 parent ae817b2 commit da59bc22cca07cacc10d2dce060778c62e2d4d7d @rshade rshade committed Jan 11, 2012
View
1 RightGrid_Windows_CS/RightGrid_Windows_CS/App.config
@@ -14,7 +14,6 @@
<add key="S3_Bucket" value="WinRightGrid"/>
<add key="S3_Input_Path" value="input/"/>
<add key="S3_Output_Path" value="output/"/>
- <add key="FS_Output_Path" value=""/>
<add key="QueueTest" value="0"/>
<add key="StorageTest" value="0"/>
<add key="StrorageSampleFile" value="C:\Temp\temp.txt"/>
View
53 RightGrid_Windows_CS/RightGrid_Windows_CS/Program.cs
@@ -34,30 +34,51 @@ public static void Main(string[] args)
public static void Run()
{
Console.WriteLine("Starting");
+ string path = Directory.GetCurrentDirectory();
+ string input_dir = Path.Combine(path,"input");
+ string output_dir = Path.Combine(path,"\\output");
+ Console.WriteLine("Creating Input Directory unless exists");
+ if (!Directory.Exists(input_dir)) { Directory.CreateDirectory(input_dir); }
+ Console.WriteLine("Creating Output Directory unless exists");
+ if (!Directory.Exists(output_dir)) { Directory.CreateDirectory(output_dir); }
while (Queue.Count(ConfigurationManager.AppSettings["input_queue_url"]) >= 1)
{
Console.WriteLine("pass");
Message msg = Queue.Get(ConfigurationManager.AppSettings["input_queue_url"]);
Console.WriteLine("got message");
- Console.WriteLine(msg.Body);
- //Node node = Node.Parse(msg.Body);
- Console.WriteLine("parsed message");
- Stream input = new MemoryStream(Encoding.UTF8.GetBytes(msg.Body));
- TextReader yamltxt = new StreamReader(input);
- YamlStream yaml = new YamlStream();
- yaml.Load(yamltxt);
- YamlMappingNode mapping = (YamlMappingNode)yaml.Documents[0].RootNode;
- foreach (KeyValuePair<YamlNode, YamlNode> entry in mapping.Children)
- {
- Console.WriteLine(((YamlScalarNode)entry.Key).Value);
+ if (msg.Body != null) {
+ Console.WriteLine(msg.Body);
+ //Node node = Node.Parse(msg.Body);
+ Console.WriteLine("parsed message");
+ Stream input = new MemoryStream(Encoding.UTF8.GetBytes(msg.Body));
+ TextReader yamltxt = new StreamReader(input);
+ YamlStream yaml = new YamlStream();
+ yaml.Load(yamltxt);
+ YamlMappingNode mapping = (YamlMappingNode)yaml.Documents[0].RootNode;
+ string input_file = "";
+ string output_file = "";
+ string created_at = "0000-00-00 00:00:00 GMT";
+ int job_id = '0';
+
+ foreach (KeyValuePair<YamlNode, YamlNode> entry in mapping.Children)
+ {
+ if (entry.Key.ToString() == ":input_file") { input_file = entry.Value.ToString(); }
+ if (entry.Key.ToString() == ":output_file") { output_file = entry.Value.ToString(); }
+ if (entry.Key.ToString() == ":created_at") { created_at = entry.Value.ToString(); }
+ if (entry.Key.ToString() == ":id") { job_id = Convert.ToInt32(entry.Value.ToString()); }
+ Console.WriteLine(("Key:" + (YamlScalarNode)entry.Key + " Value:" + (YamlScalarNode)entry.Value));
+ }
+ Console.WriteLine("input_file is set to: " + input_file);
+ Console.WriteLine("output_file is set to: " + output_file);
+ Console.WriteLine("created_at is set to: " + created_at);
+ Console.WriteLine("job_id is set to: " + job_id);
+ //Storage.Get(ConfigurationManager.AppSettings["S3_Bucket"], ConfigurationManager.AppSettings["S3_Input_Path"]+input_file, Path.Combine(input_dir,input_file));
+ //Runner.run(node["input_file"],node["output_file"]));
+ //Storage.Put(ConfigurationManager.AppSettings["S3_Bucket"], ConfigurationManager.AppSettings["S3_Output_Path"], node["output_file"]);
}
-
- //Storage.Get(ConfigurationManager.AppSettings["S3_Bucket"], ConfigurationManager.AppSettings["S3_Input_Path"], node["input_file"]);
- //Runner.run(node["input_file"],node["output_file"]));
- //Storage.Put(ConfigurationManager.AppSettings["S3_Bucket"], ConfigurationManager.AppSettings["S3_Output_Path"], node["output_file"]);
- Console.WriteLine("node");
Queue.Delete(ConfigurationManager.AppSettings["input_queue_url"], msg.ReceiptHandle.ToString());
}
+ Console.WriteLine("Processing Completed");
}
View
1 RightGrid_Windows_CS/RightGrid_Windows_CS/README
@@ -1,6 +1,7 @@
Yaml Parser - http://www.codeproject.com/KB/recipes/yamlparser.aspx
AWS.NetSDK - http://aws.amazon.com/sdkfornet/
Modify App at run-time - http://sufianrashid.wordpress.com/2011/10/17/c-modify-app-config-file-at-run-time/
+This is the best library - http://www.aaubry.net/yamldotnet/documentation/loading-a-yaml-stream.aspx
Job Producer - Windows Version(http://support.rightscale.com/03-Tutorials/02-AWS/03-Grid_Edition/Basic_RightGrid_Example)
View
BIN RightGrid_Windows_CS/RightGrid_Windows_CS/bin/Debug/RightGrid_Windows_CS.exe
Binary file not shown.
View
1 RightGrid_Windows_CS/RightGrid_Windows_CS/bin/Debug/RightGrid_Windows_CS.exe.config
@@ -14,7 +14,6 @@
<add key="S3_Bucket" value="WinRightGrid"/>
<add key="S3_Input_Path" value="input/"/>
<add key="S3_Output_Path" value="output/"/>
- <add key="FS_Output_Path" value=""/>
<add key="QueueTest" value="0"/>
<add key="StorageTest" value="0"/>
<add key="StrorageSampleFile" value="C:\Temp\temp.txt"/>
View
BIN RightGrid_Windows_CS/RightGrid_Windows_CS/bin/Debug/RightGrid_Windows_CS.pdb
Binary file not shown.
View
1 RightGrid_Windows_CS/RightGrid_Windows_CS/bin/Debug/RightGrid_Windows_CS.vshost.exe.config
@@ -14,7 +14,6 @@
<add key="S3_Bucket" value="WinRightGrid"/>
<add key="S3_Input_Path" value="input/"/>
<add key="S3_Output_Path" value="output/"/>
- <add key="FS_Output_Path" value=""/>
<add key="QueueTest" value="0"/>
<add key="StorageTest" value="0"/>
<add key="StrorageSampleFile" value="C:\Temp\temp.txt"/>
View
BIN RightGrid_Windows_CS/RightGrid_Windows_CS/obj/Debug/RightGrid_Windows_CS.exe
Binary file not shown.
View
BIN RightGrid_Windows_CS/RightGrid_Windows_CS/obj/Debug/RightGrid_Windows_CS.pdb
Binary file not shown.

0 comments on commit da59bc2

Please sign in to comment.