Пример #1
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            var esa = new AvailableEndpoint
            {
                PartitionKey       = AliasBox.Text,
                RowKey             = "",
                alias              = AliasBox.Text,
                description        = DescriptionBox.Text,
                storageaccountname = tableStorageAccountNameBox.Text,
                storageaccountkey  = tableStorageAccountKeyBox.Text
            };

            if (DisclaimerBox.Text.Length > 0)
            {
                esa.disclaimer = DisclaimerBox.Text.Replace('\n', ' ');
            }

            var ta  = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
            var ctx = new OgdiConfigDataServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);

            ctx.AddObject(OgdiConfigDataServiceContext.EndpointsTableName, esa);
            ctx.SaveChanges();

            DisplayLatest();
        }
Пример #2
0
        private void DisplayLatest()
        {
            string statusMessage = String.Empty;

            try
            {
                var ta      = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
                var context = new OgdiConfigDataServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);

                var empty = true;
                foreach (var ep in context.AvailableEndpoints)
                {
                    empty = false;
                    break;
                }
                if (!empty)
                {
                    this.messageList.DataSource = context.AvailableEndpoints.ToList();
                    this.messageList.DataBind();
                }
            }
            catch (DataServiceRequestException ex)
            {
                statusMessage = "Unable to connect to the table storage server. Please check that the service is running.<br />"
                                + ex.Message;
            }
            catch (Exception) { }
            status.Text = statusMessage;
        }
Пример #3
0
        internal static Dictionary <string, AvailableEndpoint> RefreshAvailableEndpoints()
        {
            var ogdiConfigContext  = new OgdiConfigDataServiceContext(Account.TableEndpoint.AbsoluteUri, Account.Credentials);
            var availableEndpoints = ogdiConfigContext.AvailableEndpoints.ToDictionary(item => item.alias);

            HttpContext.Current.Cache[OgdiConfigDataServiceContext.EndpointsTableName] = availableEndpoints;

            return(availableEndpoints);
        }
Пример #4
0
        protected override void Render(XElement feed)
        {
            _HttpContext.Response.ContentType = _xmlContentType;

            OgdiConfigDataServiceContext ogdiConfigContext = new OgdiConfigDataServiceContext(_Account.TableEndpoint.AbsoluteUri, _Account.Credentials);
            string xmlBase = string.Format("http://{0}{1}", _HttpContext.Request.Url.Host, _HttpContext.Request.Url.AbsolutePath);
            List <AvailableEndpoint> list = ogdiConfigContext.AvailableEndpoints.ToList();

            _HttpContext.Response.Write(string.Format(START_SERVICEDOCUMENT_TEMPLATE, xmlBase));

            foreach (AvailableEndpoint item in list)
            {
                _HttpContext.Response.Write(string.Format(COLLECTION_TEMPLATE, item.alias, item.description));
            }

            _HttpContext.Response.Write(END_SERVICEDOCUMENT_TEMPLATE);
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            if (!this.IsHttpGet(context))
            {
                this.RespondForbidden(context);
            }
            else
            {
                context.Response.Headers["DataServiceVersion"] = "1.0;";
                context.Response.CacheControl = "no-cache";
                context.Response.ContentType  = "application/xml;charset=utf-8";

                var xmlBase = "http://" + context.Request.Url.Host + context.Request.Url.AbsolutePath;

                var ta = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
                var ogdiConfigContext = new OgdiConfigDataServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);

                try
                {
                    var list = ogdiConfigContext.AvailableEndpoints.ToList();

                    context.Response.Write(string.Format(START_SERVICEDOCUMENT_TEMPLATE,
                                                         xmlBase));

                    foreach (var item in list)
                    {
                        context.Response.Write(string.Format(COLLECTION_TEMPLATE,
                                                             item.alias, item.description));
                    }

                    context.Response.Write(END_SERVICEDOCUMENT_TEMPLATE);
                }
                catch (WebException ex)
                {
                    var response = ex.Response as HttpWebResponse;
                    context.Response.StatusCode = (int)response.StatusCode;
                    context.Response.End();
                }
            }
        }
Пример #6
0
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            var button = sender as LinkButton;

            string[] p            = button.CommandArgument.Split('|');
            var      partitionKey = p[0];
            var      rowKey       = p[1];

            var availableEndpoint = new AvailableEndpoint
            {
                PartitionKey = partitionKey,
                RowKey       = rowKey
            };

            var ta      = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
            var context = new OgdiConfigDataServiceContext(ta.TableEndpoint.AbsoluteUri, ta.Credentials);

            context.AttachTo(OgdiConfigDataServiceContext.EndpointsTableName, availableEndpoint, "*");
            context.DeleteObject(availableEndpoint);
            context.SaveChanges();

            DisplayLatest();
        }