本文整理汇总了C#中System.Text.UTF8Encoding.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# UTF8Encoding.IndexOf方法的具体用法?C# UTF8Encoding.IndexOf怎么用?C# UTF8Encoding.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Text.UTF8Encoding
的用法示例。
在下文中一共展示了UTF8Encoding.IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: txtProcessDemo_Click
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, "");
//.........这里部分代码省略.........