private void Save() { SaveXaml(); new VersionManager().KeepVersion(VersionObjectTypes.Rule, _idpeRule.Id); new Manager().Save(_idpeRule); ServiceCommunicator.ClearRule(_idpeRule.Id, _idpeRule.Name); }
/// <summary> /// Sends image to ocr service /// </summary> /// <param name="model">Model that contains values if the request properties</param> /// <param name="callback">Action to be executed after response is received</param> public void SendImage(PostImageModel model, Action <string> callback) { Task task = taskFactory.StartNew(() => { string result = string.Empty; try { // Trys to save current model state ToXML(model); // Creating parts of the request to be sent IList <IFormPart> parts = new List <IFormPart>(); parts.Add(new FileFormPartModel("image", model.PicturePath, new Dictionary <string, string>() { { "Content-Type", GetContentType(model.PicturePath) } })); parts.Add(new StringFormPartModel("language", model.LanguageCode)); parts.Add(new StringFormPartModel("apikey", model.ApiKey)); // Creats communicator and sending request ServiceCommunicator communicator = new ServiceCommunicator(); ServiceResponse response = communicator.PostRequest(_ocrApiServiceUrl, parts, 10000); result = response.ToString(); } catch { } return(result); } ).ContinueWith(cTask => { if (callback != null) { callback(cTask.Result); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
public bool SaveSreRule(IdpeRule idpeRule) { new Manager().Save(idpeRule); ServiceCommunicator.ClearRule(idpeRule.Id, idpeRule.Name); return(true); }