This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DisableMultipleQueuedItemsFilter : JobFilterAttribute, IClientFilter, IServerFilter | |
{ | |
private static readonly TimeSpan LockTimeout = TimeSpan.FromSeconds(5); | |
private static readonly TimeSpan FingerprintTimeout = TimeSpan.FromHours(1); | |
public void OnCreating(CreatingContext filterContext) | |
{ | |
if (!AddFingerprintIfNotExists(filterContext.Connection, filterContext.Job)) | |
{ | |
filterContext.Canceled = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace V.AdamAnalysis.BusinessLogic.Jobs | |
{ | |
public class AdamAnalysisJob | |
{ | |
//none of the real work is shown here...the interesting parts are the constructors that take in objects to be used | |
//and the journal mechansim to report progress back to the website. | |
private AdamAnalysisManager adamAnalysisManager; | |
private IHubContext hubContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Hangfire; | |
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; | |
using Microsoft.Practices.EnterpriseLibrary.Logging; | |
using V.RemoteDecodeProcessConsole.Properties; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Retry http with a back off on failure | |
await Policy.Handle<HttpRequestException>().WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))) | |
.ExecuteAsync(async () => | |
{ | |
var result = await httpClient.GetAsync("api/CallToServer/" + varibleToSendToServer, cancellationToken); | |
if (result.IsSuccessStatusCode) | |
{ | |
returnValue = await result.Content.ReadAsAsync<List<Results>>(token); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//in setup define client and progress reporter | |
var httpProgressHandler = new ProgressMessageHandler(); | |
httpProgressHandler.InnerHandler = new HttpClientHandler(); | |
var client = new HttpClient(httpProgressHandler) { BaseAddress = new Uri(Settings.Default.ServerUrl) }; | |
//register to use elsewhere in the application, note it is better to resuse for lifetime of application than create for every call | |
Mvx.RegisterSingleton(client); | |
Mvx.RegisterSingleton(httpProgressHandler); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data.Entity; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Net.Http; | |
using System.Net.Http.Handlers; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//build zip file | |
using (var zip = new ZipFile(zipFilePath)) | |
{ | |
zip.AddDirectory("Zip files go here"); | |
zip.Save(zipFilePath); | |
} | |
//create upload package | |
var uploadData = new NewObjectThatGoesAlongWithTheFile(SomeDataToCreateObject); | |
uploadData.ResultFileMd5 = CalculateMd5(zipFilePath); //calculate an md5 to compare on the other side |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('your-module').config(['$provide', function ($provide) { | |
$provide.decorator('$rootScope', ['$delegate', function ($delegate) { | |
wrapMethod($delegate, '$broadcast', function (method, args) { | |
if (isNonSystemEvent(args[0])) | |
logCall('$broadcast', args); | |
return method.apply(this, args); | |
}); | |
wrapMethod($delegate, '$emit', function (method, args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AcceptVerbs(HttpVerbs.Post)] | |
public ActionResult UploadImage(HttpPostedFileBase upload, string CKEditorFuncNum, string CKEditor, string langCode) | |
{ | |
//http://stackoverflow.com/a/4088194/167670 | |
//http://arturito.net/2010/11/03/file-and-image-upload-with-asp-net-mvc2-with-ckeditor-wysiwyg-rich-text-editor/ | |
//http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx | |
if (upload.ContentLength <= 0) | |
return null; |
NewerOlder