コード例 #1
0
        public static void DeleteArticle(int AnnouncementID)
        {
            var statusMessage = String.Empty;

            try
            {
                var account = CloudStorageAccount.FromConfigurationSetting("TableDataConnectionString");

                var context = new MessageDataServiceContext(account.TableEndpoint.ToString(), account.Credentials);
                while (true)
                {
                    var o = (from message in context.Messages
                             where message.IsNotification == false && message.AnnouncementID == AnnouncementID
                             select message).FirstOrDefault();
                    if (o == null)
                    {
                        return;
                    }
                    context.DeleteObject(o);
                    context.SaveChanges();
                }
            }
            catch (DataServiceRequestException ex)
            {
                statusMessage = "Unable to connect to the table storage server. Please check that the service is running.<br>"
                                + ex.Message;
            }
        }
コード例 #2
0
        public static void AddNotice(int StaffID, int StudentID, string Title, int AnnouncementID, bool IsNotification, bool IsViewed)
        {
            var statusMessage = String.Empty;

            try
            {
                var account = CloudStorageAccount.FromConfigurationSetting("TableDataConnectionString");

                var context = new MessageDataServiceContext(account.TableEndpoint.ToString(), account.Credentials);

                context.AddMessage(StaffID, StudentID, Title, AnnouncementID, IsNotification, IsViewed);
            }
            catch (DataServiceRequestException ex)
            {
                statusMessage = "Unable to connect to the table storage server. Please check that the service is running.<br>"
                                + ex.Message;
            }
        }
コード例 #3
0
        public static void ChangeViewedStatus(string key)
        {
            var statusMessage = String.Empty;

            try
            {
                var account = CloudStorageAccount.FromConfigurationSetting("TableDataConnectionString");

                var context = new MessageDataServiceContext(account.TableEndpoint.ToString(), account.Credentials);

                var o = (from message in context.Messages
                         where message.RowKey == key
                         select message).First();
                o.IsViewed = true;
                context.UpdateObject(o);
                context.SaveChanges();
            }
            catch (DataServiceRequestException ex)
            {
                statusMessage = "Unable to connect to the table storage server. Please check that the service is running.<br>"
                                + ex.Message;
            }
        }