コード例 #1
0
ファイル: Form1.cs プロジェクト: CarpDeus/Azure-Commands
        private void txtProcessDemo_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

               StringBuilder sbResultsForStorage = new StringBuilder();
               AzureQueueStorage aqs = new AzureQueueStorage(txtAccount.Text, string.Format("http://{0}.queue.core.windows.net", txtAccount.Text), txtSharedKey.Text, "SharedKey");
               azureResults ar = aqs.Messages(cmdType.get, bulkTag, "", "visibilitytimeout=7200", "");
               string MessageID = "";
               string PopReceipt = "";
               string Message = "";
               if (ar.Body != null)
               {
            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            if (ar.Succeeded)
            {
             xdoc.LoadXml(ar.Body);
             System.Xml.XmlNodeList nodes = xdoc.SelectNodes("//QueueMessage");
             StringBuilder sbMultipart = new StringBuilder();
             if (nodes.Count == 0)
              txtMessage.Text = "No message to process";
             else
              foreach (System.Xml.XmlNode node in nodes)
              {
               MessageID = node.SelectSingleNode("MessageId").InnerText;
               PopReceipt = node.SelectSingleNode("PopReceipt").InnerText;
               Message = node.SelectSingleNode("MessageText").InnerText;

               System.Xml.XmlDocument msgDoc = new XmlDocument();
               msgDoc.LoadXml(Message);
               string newAccount = msgDoc.SelectSingleNode("//account[1]").InnerXml;
               string newKey = msgDoc.SelectSingleNode("//key[1]").InnerXml;
               string newSource = msgDoc.SelectSingleNode("//source[1]").InnerXml;
               string updateID = msgDoc.SelectSingleNode("//updateID[1]").InnerXml;
               string newTable = msgDoc.SelectSingleNode("//table[1]").InnerXml;
               AzureTableStorage ats = new AzureTableStorage(txtAccount.Text, "", txtSharedKey.Text, "SharedKey");
               AzureTableStorage ats1 = new AzureTableStorage(txtAccount.Text, "", txtSharedKey.Text, "SharedKey");

               azureHelper ah = new azureHelper(txtAccount.Text, txtEndpoint.Text, txtSharedKey.Text, "SharedKey");

               string mrgMessage = string.Format(queueUpdateCreationEntity, updateID, 0, 0);
               ats.Entities(cmdType.merge, bulkTag, updateID, "000000000000000", mrgMessage, "");
               ats.Entities(cmdType.merge, bulkTag, updateID, "000000000000000", string.Format("<m:properties>\n\t<d:PartitionKey>{0}</d:PartitionKey>\n\t<d:RowKey>000000000000000</d:RowKey><d:StartedProcessing>{1}</d:StartedProcessing></m:properties>", updateID, DateTime.UtcNow.ToLongTimeString()), "");

               AzureBlobStorage abs = new AzureBlobStorage(newAccount, string.Format("http://{0}.blob.core.windows.net", newAccount), newKey, "SharedKey");

               AzureTableStorage atsNew = new AzureTableStorage(newAccount, string.Format("http://{0}.blob.core.windows.net", newAccount), newKey, "SharedKey");
               ar = atsNew.Tables(cmdType.post, newTable);
               if (ar.Succeeded || ar.StatusCode == System.Net.HttpStatusCode.Conflict)
               {
            ar = new azureResults();
            string newContainer = newSource.Replace(string.Format("http://{0}.blob.core.windows.net/", newAccount), "");
            newContainer = newContainer.Substring(0, newContainer.IndexOf("/"));
            string newBlob = newSource.Replace(string.Format("http://{0}.blob.core.windows.net/", newAccount), "").Replace(newContainer, "");
            byte[] blob = abs.GetBlob(newContainer, newBlob, "", ref ar);
            string x = new System.Text.UTF8Encoding().GetString(blob);
            x = x.Substring(x.IndexOf("<"));
            msgDoc.LoadXml(x);

            int errorCt = 0;
            int processedCt = 0;
            //Instantiate an XmlNamespaceManager object.
            System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xdoc.NameTable);

            //Add the namespaces used in books.xml to the XmlNamespaceManager.
            xmlnsManager.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
            xmlnsManager.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
            XmlNodeList pnodes = msgDoc.SelectNodes("//m:properties", xmlnsManager);
            int iCounter = 101;
            int iResponse = 1;
            foreach (XmlNode pnode in pnodes)
            {
             if (iCounter > 100)
             {
              if (sbMultipart.Length > 0)
              {
               sbMultipart.Append("</entry>");
               ProcessMultiPartForStatus(ats.auth, ah.entityGroupTransaction(cmdType.post, newTable, sbMultipart.ToString()), bulkTag, updateID, iResponse.ToString("D15"), ref processedCt, ref errorCt, "201 Created");
               ar = ats1.Entities(cmdType.post, bulkTag, updateID, iResponse.ToString("D15"), sbResultsForStorage.ToString(), "");
               mrgMessage = string.Format(queueUpdateCreationEntity, updateID, processedCt, errorCt);
               ats.Entities(cmdType.merge, bulkTag, updateID, "000000000000000", mrgMessage, "", "*");
               iResponse++;
              }
              sbMultipart = new StringBuilder();
              sbMultipart.AppendFormat(@"<?xml version=""1.0"" encoding=""utf-8"" ?><entry xml:base=""http://finseldemos.table.core.windows.net/"" xmlns:d=""http://schemas.microsoft.com/ado/2007/08/dataservices"" xmlns:m=""http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"" xmlns=""http://www.w3.org/2005/Atom"">");
              iCounter = 0;
             }
             sbMultipart.Append(pnode.OuterXml);
             iCounter++;

            }
            sbMultipart.Append("</entry>");
            ProcessMultiPartForStatus(ats.auth, ah.entityGroupTransaction(cmdType.post, newTable, sbMultipart.ToString()), bulkTag, updateID, iResponse.ToString("D15"), ref processedCt, ref errorCt, "201 Created");
            mrgMessage = string.Format(queueUpdateCreationEntity, updateID, processedCt, errorCt).Replace("Processing", "Completed");
            ats.Entities(cmdType.merge, bulkTag, updateID, "000000000000000", mrgMessage, "", "*");

               }
               else
               {
            mrgMessage = string.Format(queueUpdateCreationEntity, updateID, 0, 0).Replace("Processing", "Failed to create table!");
            ats.Entities(cmdType.merge, bulkTag, updateID, "000000000000000", mrgMessage, "");
               }
               aqs.Messages(cmdType.delete, bulkTag, "", string.Format("popreceipt={0}", PopReceipt), MessageID);
               ats.Entities(cmdType.merge, bulkTag, updateID, "000000000000000", string.Format("<m:properties>\n\t<d:PartitionKey>{0}</d:PartitionKey>\n\t<d:RowKey>000000000000000</d:RowKey><d:CompletedProcessing>{1}</d:CompletedProcessing></m:properties>", updateID, DateTime.UtcNow.ToLongTimeString()), "");
              }

            }
            else txtMessage.Text = "No message to process";
            ProcessResults(ar);
            this.Cursor = Cursors.Default;
               }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: CarpDeus/Azure-Commands
 private void Process(cmdType cmd)
 {
     this.Cursor = Cursors.WaitCursor;
        azureResults ar = new azureResults();
        try
        {
     AzureTableStorage ats = new AzureTableStorage(txtAccount.Text, txtEndpoint.Text, txtSharedKey.Text, "SharedKey");
     string tableName = cbTables.Text;
     if (!cbBulkProcess.Checked)
     {
      if (txtRowKey.Text == string.Empty && txtPartitionKey.Text == string.Empty && txtDocumentData.Text == string.Empty )
       ar = ats.Tables(cmd, tableName);
      else
       ar = ats.Entities(cmd, tableName, txtPartitionKey.Text, txtRowKey.Text, txtDocumentData.Text, txtTParameters.Text ,txtIfMatch.Text );
     }
     else
     {
      azureHelper ah = new azureHelper(txtAccount.Text, txtEndpoint.Text, txtSharedKey.Text, "SharedKey");
      string results = ah.entityGroupTransaction(cmd, cbTables.Text, txtDocumentData.Text);
      ar.Body = results;
      ar.Succeeded = true;
     }
     ProcessResults(ar);
        }
        catch (Exception ex)
        {
     //Literal1.Text = string.Format("<textarea id=\"txtResponse\" name=\"S1\">{0}</textarea>", ex.ToString()); //.Replace("<", "&lt").Replace(">", "&gt;");
     lblError.Text = ex.ToString();
     lblStatus.Text = "Error:";
     lblCalledURL.Text = "";
        }
        this.Cursor = Cursors.Default;
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: CarpDeus/Azure-Commands
        private void ProcessMultiPartForStatus(Authentication auth, string MultipartResults, string containerName, string partitionKey, string rowKey, ref int processedCt, ref int ErrorCt, string successString)
        {
            //string results = string.Empty;
               string[] resultSet = null;
               string location = string.Empty;
               string resultStatus = string.Empty;
               StringBuilder sbResultsForStorage = new StringBuilder();
               resultSet = MultipartResults.Split("\n".ToCharArray());

               location = string.Empty;
               resultStatus = string.Empty;
               foreach (string result in resultSet)
               {

            if (result.StartsWith("HTTP/1.1"))
            {
             resultStatus = result.Substring(8).Replace("\r","");
             if (resultStatus.ToLower().Trim() != successString.ToLower().Trim())
              ErrorCt++;
             location = string.Empty;
             processedCt++;
            }
            if (result.StartsWith("Location:"))
             sbResultsForStorage.AppendFormat("{0}: {1}\r\n", resultStatus.Replace("\r", ""), result.Substring(result.IndexOf(":") + 1).Replace("\r", ""));
               }
               AzureTableStorage ats = new AzureTableStorage(auth);

              azureResults ar= ats.Entities(cmdType.post, containerName, partitionKey, rowKey, string.Format(statusUpdateTEmplate, partitionKey, rowKey, sbResultsForStorage.ToString()), "", "");
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: CarpDeus/Azure-Commands
        private void btnQuery_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
               AzureTableStorage ats = new AzureTableStorage(txtAccount.Text, txtEndpoint.Text, txtSharedKey.Text, "SharedKey");
               string tableName = cbTables.Text;
               string filter = txtDocumentData.Text;
               string parameters = txtTParameters.Text;
               if (filter.StartsWith("?"))
            filter = filter.Substring(1);
               if (!filter.StartsWith("$filter="))
            filter = string.Format("$filter={0}",filter);
               if(parameters != string.Empty){
               if(parameters.StartsWith("?"))
            parameters = parameters.Substring(1);
               if(!parameters.StartsWith("&"))
            parameters = string.Format("&{0}",parameters);
               filter = string.Format("{0}{1}",filter, parameters);
               }

               azureResults ar = ats.Entities(cmdType.get, tableName,"","","",filter  );
               ProcessResults(ar);
               this.Cursor = Cursors.Default;
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: CarpDeus/Azure-Commands
        private void btnLoadDemo_Click(object sender, EventArgs e)
        {
            string newID = Guid.NewGuid().ToString();
               string queueMessage = string.Format("<message><updateID>{0}</updateID><account>{1}</account><key>{2}</key><table>{3}</table><source>http://finseldemos.blob.core.windows.net/public/CalendarDemo.xml</source></message>",
            newID,txtAccount.Text, txtSharedKey.Text, cbTables.Text );
               AzureTableStorage ats = new AzureTableStorage(txtAccount.Text, "", txtSharedKey.Text, "SharedKey");
               azureResults ar = ats.Tables(cmdType.post, bulkTag);
               ar = ats.Entities(cmdType.post, bulkTag, newID, "Summary", string.Format(queueInitialCreationEntity, newID), null);
               AzureQueueStorage aqs = new AzureQueueStorage(txtAccount.Text, "", txtSharedKey.Text, "SharedKey");
               ar = aqs.Queues(cmdType.put, bulkTag, null, new Hashtable());

               ar = aqs.Messages(cmdType.post, bulkTag, queueMessage, string.Empty, string.Empty);
        }
コード例 #6
0
        public void ProcessRequest(HttpContext context)
        {
            string accountName = string.Empty;
              string sharedKey = string.Empty;
              string tableTypeOfCall = string.Empty;

              string tableName = string.Empty;
              string partitionKey = string.Empty;
              string rowKey = string.Empty;
              string docData = string.Empty;
              string tParameters = string.Empty;
              string ifMatch = string.Empty;

              if (context.Request.Params.AllKeys.Contains("accountname"))
              {
            accountName = context.Request.Params["accountname"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("sharedkey"))
              {
            sharedKey = context.Request.Params["sharedkey"].ToString().Replace(" ", "+");
              }
              if (context.Request.Params.AllKeys.Contains("tabletypeofcall"))
              {
            tableTypeOfCall = context.Request.Params["tabletypeofcall"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("tablename"))
              {
            tableName = context.Request.Params["tablename"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("partitionkey"))
              {
            partitionKey = context.Request.Params["partitionkey"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("rowkey"))
              {
            rowKey = context.Request.Params["rowkey"].ToString();
              }

              // This will be an XML Only request so we need to parse it to get what we need
              if (context.Request.ContentType=="text/xml")// .Params.AllKeys.Contains("docdata"))
              {
            StreamReader reader = new StreamReader( context.Request.InputStream);
            Regex regex = new Regex(@">\s*<");
            string cleanXml = regex.Replace(reader.ReadToEnd(), "><");

              XmlDocument xdoc = new XmlDocument();
            xdoc.PreserveWhitespace = false;
            xdoc.LoadXml(cleanXml);
            //Instantiate an XmlNamespaceManager object.

            //Add the namespaces used in books.xml to the XmlNamespaceManager.
            accountName = xdoc.SelectSingleNode("/root/AccountName").InnerText;
            sharedKey = xdoc.SelectSingleNode("/root/SharedKey").InnerText; ;
            tableTypeOfCall = xdoc.SelectSingleNode("/root/TypeOfCall").InnerText;
            tableName = xdoc.SelectSingleNode("/root/TableName").InnerText;
            try { partitionKey = xdoc.SelectSingleNode("/root/PartitionKey").InnerText; }
            catch { }
            try { rowKey = xdoc.SelectSingleNode("/root/RowKey").InnerText; }
            catch { }
            try { tParameters = xdoc.SelectSingleNode("/root/Parameters").InnerText; }
            catch { }
            try { ifMatch = xdoc.SelectSingleNode("/root/IfMatch").InnerText; }
            catch { }
            docData = xdoc.SelectSingleNode("/root/docData").InnerXml.Replace("<![CDATA[", "").Replace("]]>", "");

              }
              rowKey = rowKey.Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("\t", "");
              partitionKey = partitionKey.Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("\t", "");

              string retVal = string.Empty;
              string retValType = string.Empty;
              retValType = "text/xml";

              Hashtable ht = new Hashtable();

              foreach (string key in context.Request.Params.AllKeys)
              {
              if (key != null)
              {
              if (key.StartsWith("x-ms-meta-"))
                  if (ht.ContainsKey(key))
                      ht[key] = string.Format("{0},{1}", ht[key].ToString(), context.Request.Params[key].ToString());
                  else
                      ht.Add(key, context.Request.Params[key].ToString());
              }
              }

              azureResults ar = new azureResults();
              azureHelper ah = new azureHelper(accountName, string.Format("http://{0}.blob.core.windows.net", accountName), sharedKey,
            "SharedKey");
              Finsel.AzureCommands.AzureTableStorage ats = new Finsel.AzureCommands.AzureTableStorage(accountName,
            string.Format("http://{0}.blob.core.windows.net", accountName), sharedKey,
            "SharedKey");

              switch (tableTypeOfCall.ToLower())
              {
              case "bulkinsert":
              ar.Body = ah.entityGroupTransaction(cmdType.post, tableName, docData);
              ar.Succeeded = true;
              break;
              case "bulkupdate":
              ar.Body =  ah.entityGroupTransaction(cmdType.put, tableName, docData);;
              ar.Succeeded = true;
              break;
            case "createtable": ar = ats.Tables(cmdType.post, tableName); retVal = processAzureResults(ar); break;
            case "deleteentity": ar = ats.Entities(cmdType.delete, tableName, partitionKey, rowKey, "", ""); retVal = processAzureResults(ar); break;
            case "deletetable": ar = ats.Tables(cmdType.delete, tableName); retVal = processAzureResults(ar); break;
            case "getentity": ar = ats.Entities(cmdType.get, tableName, partitionKey, rowKey, "", tParameters, ifMatch); retVal = processAzureResults(ar); break;
            case "insertentity": ar = ats.Entities(cmdType.post, tableName, partitionKey, rowKey, docData, ""); retVal = processAzureResults(ar); break;
            case "mergeentity": ar = ats.Entities(cmdType.merge, tableName, partitionKey, rowKey, docData,tParameters, ifMatch ); retVal = processAzureResults(ar); break;
            case "queryentities": ar = ats.Entities(cmdType.get, tableName, partitionKey, rowKey, "", ""); retVal = processAzureResults(ar); break;
            case "querytables": ar = ats.Tables(cmdType.get, ""); retVal = processAzureResults(ar); break;
            case "updateentity": ar = ats.Entities(cmdType.put, tableName, partitionKey, rowKey, docData,tParameters, ifMatch); retVal = processAzureResults(ar); break;
            default:
              retVal = @"<!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>
            <title>Finsel Azure Tables Handler Form</title>
            </head>
            <body>
            <form action='atsHandler.ashx' method='post'>
            <table border='1'>
            <tr>
            <td>Account</td><td><input name='accountname' maxlength='100' /></td>
            </tr><tr>
            <td>Shared Key</td><td><input name='sharedkey' maxlength='100' /></td>
            </tr><tr>
            <td>Table Name</td><td><input name='tablename' maxlength='100' /></td>
            </tr><tr>
            <td>Partition Key</td><td><input name='partitionkey' maxlength='100' /></td>
            </tr><tr>
            <td>Row key</td><td><input name='rowkey' maxlength='100' /></td>
            </tr><tr>
            <td>Document Data</td><td><input name='docdata' Width='398px' Height='92px' TextMode='MultiLine' /></td>
            </tr><tr>
            <td>Parameters</td><td><input name='parameters' maxlength='1240' /></td>
            </tr><tr>
            <td>Type of call</td><td>
            <select name='tabletypeofcall'>
            <option>CreateTable</option>
            <option>DeleteEntity</option>
            <option>DeleteTable</option>
            <option>InsertEntity]</option>
            <option>MergeEntity</option>
            <option>QueryEntities</option>
            <option>QueryTables</option>
            <option>UpdateEntity</option>
            </td>
            </tr><tr>
            <td colspan='2'><input type='submit' /></td>
            </tr>
            </table>
            </form>
            </body>
            </html>";
              retValType = "text/html";

              break;
              }

              context.Response.ContentType = retValType;
              context.Response.Write(retVal);
        }
コード例 #7
0
        private void click_Tables(object sender, RoutedEventArgs e)
        {
            AzureTableStorage ats = new AzureTableStorage(azAccount, azEndPoint, azSharedKey, "SharedKey");
            azureResults ar = new azureResults();
            if (e.Source.ToString().StartsWith("System.Windows.Controls.Button"))
            {
                this.Cursor = Cursors.Wait;
                if (e.Source == btnGet)
                    Process(cmdType.get);
                else if (e.Source == btnPut)
                    Process(cmdType.put);
                else if (e.Source == btnPost)
                    Process(cmdType.post);
                else if (e.Source == btnDelete)
                    Process(cmdType.delete);
                else if (e.Source == btnMerge)
                    Process(cmdType.merge);
                else if (e.Source == btnQuery)
                {
                    string tableName = cbTables.Text;
                    string filter = txtDocumentData.Text;
                    string parameters = txtTParameters.Text;
                    if (filter.StartsWith("?"))
                        filter = filter.Substring(1);
                    if (!filter.StartsWith("$filter="))
                        filter = string.Format("$filter={0}", filter);
                    if (parameters != string.Empty)
                    {
                        if (parameters.StartsWith("?"))
                            parameters = parameters.Substring(1);
                        if (!parameters.StartsWith("&"))
                            parameters = string.Format("&{0}", parameters);
                        filter = string.Format("{0}{1}", filter, parameters);
                    }

                     ar = ats.Entities(cmdType.get, tableName, "", "", "", filter);
                    ProcessResults(ar);
                }
                else if (e.Source == btnGetTables)
                {
                    cbTables.Items.Clear();
                    cbTables.Text = "";
                    ar = ats.GetTableList();
                    if (ar.Succeeded)
                    {
                        XmlDocument xdoc = new XmlDocument();
                        xdoc.LoadXml(ar.Body);
                        //Instantiate an XmlNamespaceManager object.
                        System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xdoc.NameTable);

                        //Add the namespaces used in books.xml to the XmlNamespaceManager.
                        xmlnsManager.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
                        xmlnsManager.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
                        XmlNodeList nodes = xdoc.SelectNodes("//d:TableName", xmlnsManager);

                        foreach (XmlNode node in nodes)
                        {
                            cbTables.Items.Add(node.InnerText);
                        }
                    }
                    ProcessResults(ar);
                }
                this.Cursor = Cursors.Arrow;
            }
        }
コード例 #8
0
        public void ProcessRequest(HttpContext context)
        {
            string accountName = string.Empty;
              string sharedKey = string.Empty;
              string tableTypeOfCall = string.Empty;

              string tableName = string.Empty;
              string partitionKey = string.Empty;
              string rowKey = string.Empty;
              string docData = string.Empty;
              string tParameters = string.Empty;

              if (context.Request.Params.AllKeys.Contains("accountname"))
              {
            accountName = context.Request.Params["accountname"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("sharedkey"))
              {
            sharedKey = context.Request.Params["sharedkey"].ToString().Replace(" ", "+");
              }
              if (context.Request.Params.AllKeys.Contains("tabletypeofcall"))
              {
            tableTypeOfCall = context.Request.Params["tabletypeofcall"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("tablename"))
              {
            tableName = context.Request.Params["tablename"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("partitionkey"))
              {
            partitionKey = context.Request.Params["partitionkey"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("rowkey"))
              {
            rowKey = context.Request.Params["rowkey"].ToString();
              }
              if (context.Request.Params.AllKeys.Contains("docdata"))
              {
            docData = context.Request.Params["docdata"].ToString();
              }

              string retVal = string.Empty;
              string retValType = string.Empty;
              retValType = "text/xml";

              Hashtable ht = new Hashtable();

              foreach (string key in context.Request.Params.AllKeys)
              {
            if (key.StartsWith("x-ms-meta-"))
              if (ht.ContainsKey(key))
            ht[key] = string.Format("{0},{1}", ht[key].ToString(), context.Request.Params[key].ToString());
              else
            ht.Add(key, context.Request.Params[key].ToString());
              }

              azureResults ar = new azureResults();
              Finsel.AzureCommands.AzureTableStorage ats = new Finsel.AzureCommands.AzureTableStorage(accountName,
            string.Format("http://{0}.blob.core.windows.net", accountName), sharedKey,
            "SharedKey");

              switch (tableTypeOfCall.ToLower())
              {
            case "createtable": ar = ats.Tables(cmdType.post, tableName); retVal = processAzureResults(ar); break;
            case "deleteentity": ar = ats.Entities(cmdType.delete, tableName, partitionKey, rowKey, "", ""); retVal = processAzureResults(ar); break;
            case "deletetable": ar = ats.Tables(cmdType.delete, tableName); retVal = processAzureResults(ar); break;
            case "insertentity]": ar = ats.Entities(cmdType.post, tableName, partitionKey, rowKey, docData, ""); retVal = processAzureResults(ar); break;
            case "mergeentity": ar = ats.Entities(cmdType.merge, tableName, partitionKey, rowKey, docData, ""); retVal = processAzureResults(ar); break;
            case "queryentities": ar = ats.Entities(cmdType.get, tableName, partitionKey, rowKey, "", ""); retVal = processAzureResults(ar); break;
            case "querytables": ar = ats.Tables(cmdType.get, ""); retVal = processAzureResults(ar); break;
            case "updateentity": ar = ats.Entities(cmdType.put, tableName, partitionKey, rowKey, docData, ""); retVal = processAzureResults(ar); break;
            default:
              retVal = @"<!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>
            <title>Finsel Azure Tables Handler Form</title>
            </head>
            <body>
            <form action='atsHandler.ashx' method='post'>
            <table border='1'>
            <tr>
            <td>Account</td><td><input name='accountname' maxlength='100' /></td>
            </tr><tr>
            <td>Shared Key</td><td><input name='sharedkey' maxlength='100' /></td>
            </tr><tr>
            <td>Table Name</td><td><input name='tablename' maxlength='100' /></td>
            </tr><tr>
            <td>Partition Key</td><td><input name='partitionkey' maxlength='100' /></td>
            </tr><tr>
            <td>Row key</td><td><input name='rowkey' maxlength='100' /></td>
            </tr><tr>
            <td>Document Data</td><td><input name='docdata' Width='398px' Height='92px' TextMode='MultiLine' /></td>
            </tr><tr>
            <td>Parameters</td><td><input name='parameters' maxlength='1240' /></td>
            </tr><tr>
            <td>Type of call</td><td>
            <select name='tabletypeofcall'>
            <option>CreateTable</option>
            <option>DeleteEntity</option>
            <option>DeleteTable</option>
            <option>InsertEntity]</option>
            <option>MergeEntity</option>
            <option>QueryEntities</option>
            <option>QueryTables</option>
            <option>UpdateEntity</option>
            </td>
            </tr><tr>
            <td colspan='2'><input type='submit' /></td>
            </tr>
            </table>
            </form>
            </body>
            </html>";
              retValType = "text/html";

              break;
              }

              context.Response.ContentType = retValType;
              context.Response.Write(retVal);
        }