Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Pass the given data-object to the service hosted at Aucxis.
- /// </summary>
- /// <param name="data">The data-object to be passed</param>
- /// <param name="fromDb">Whether the data-object originates from the local database or not.</param>
- /// <returns>A bool to check if the transmission was successfull. False when flooding or when the Aucxis service is offline.
- /// When false is returned, the client is told to delete the </returns>
- private static void Send(Data data, bool fromDb)
- {
- /* If the error is flooding and doesn't originate from the database,
- * we increment the count of the error in the buffer and delete the screenshot. */
- if (IsFlooding(data.AucxisErrorId) && !fromDb)
- {
- var tuple = Buffer[data.AucxisErrorId];
- Buffer[data.AucxisErrorId] = Tuple.Create(tuple.Item1, tuple.Item2 + 1);
- File.Delete(data.BitmapLocation);
- return;
- }
- /* If the error doesn't originate from the database and isn't already in the buffer,
- * we add it to the buffer. */
- if (!fromDb && !Buffer.ContainsKey(data.AucxisErrorId))
- Buffer.Add(data.AucxisErrorId, Tuple.Create(DateTime.Now, 1));
- Console.WriteLine("Data object received!\n > Subject: {0}\n > Bitmap url: {1}", data.Subject, data.BitmapLocation);
- try
- {
- /* An attempt is made to send the data to the Aucxis service. If an EndpointNotFoundException is thrown
- * the service is offline. If a screenshot url is passed, we send the bitmap over FTP to Aucxis
- * and remove it from the shared folder. */
- GetService().SendData(data);
- if (!data.BitmapLocation.Equals(""))
- SendAndDeleteBitmap(data.BitmapLocation);
- }
- catch (EndpointNotFoundException)
- {
- /* The service hosted at Aucxis is offline so we save the errorlog to our local database */
- DbConnection.SaveData(data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment