Esempio n. 1
0
        public void DrainQueue()
        {
            Google.Apis.Drive.v2.Data.File file           = new Google.Apis.Drive.v2.Data.File();
            DataContractJsonSerializer     jsonSerializer = new DataContractJsonSerializer(file.GetType());
            CloudQueueMessage message = null;

            do
            {
                try
                {
                    message = queue.GetMessage();
                    if (message != null)
                    {
                        try
                        {
                            MemoryStream memoryStream = new MemoryStream(Encoding.Default.GetBytes(message.AsString));
                            file = jsonSerializer.ReadObject(memoryStream) as Google.Apis.Drive.v2.Data.File;
                            ProcessGDriveFile(file, ProcessFile);
                        }
                        finally
                        {
                            queue.DeleteMessage(message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Exception: {0} {1}", ex.Message.ToString(), ex.StackTrace.ToString());
                }
            }while (message != null);
        }
Esempio n. 2
0
        public void PopulateQueue(Google.Apis.Drive.v2.Data.File file)
        {
            MemoryStream memoryStream = new MemoryStream();

            // Create the JSON serializer.
            DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(file.GetType());

            jsonSerializer.WriteObject(memoryStream, file);

            // Get the JSON string from the memory stream.
            string messageString = Encoding.Default.GetString(memoryStream.ToArray());

            CloudQueueMessage message = new CloudQueueMessage(messageString);

            queue.AddMessage(message);
        }