Exemplo n.º 1
0
        void DeleteMessage(List <MessageRecord> records,
                           string strGroupName)
        {
            List <MessageRecord> delete_records = new List <MessageRecord>();

            foreach (MessageRecord source in records)
            {
                MessageRecord record = new MessageRecord();
                record.groups = strGroupName.Split(new char[] { ',' });
                record.id     = source.id;
                delete_records.Add(record);
            }

            string strError = "";

            // CancellationToken cancel_token = new CancellationToken();

            try
            {
                MessageConnection connection = this.Channels.GetConnectionAsync(
                    this.Url,
                    "").Result;
                SetMessageRequest param = new SetMessageRequest("expire",
                                                                "dontNotifyMe",
                                                                records);

                SetMessageResult result = connection.SetMessageAsync(param).Result;
                if (result.Value == -1)
                {
                    goto ERROR1;
                }
            }
            catch (AggregateException ex)
            {
                strError = MessageConnection.GetExceptionText(ex);
                goto ERROR1;
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                goto ERROR1;
            }
            return;

ERROR1:
            this.WriteLog("DeleteMessage() error : " + strError);
        }