private void SendUpdate(AutoUpdateItem item) { AeInfo[] aes = _AccessAgent.GetRelatedAeTitles(item.SourceAE, UPDATE_RELATION); DicomScp scp = null; if (aes == null || aes.Length == 0) { return; } foreach (AeInfo ae in aes) { using (UpdateProcessor processor = new UpdateProcessor(Module.Options.UseCustomAE ? Module.Options.AutoUpdateAE : item.ClientAE)) { try { DicomCommandStatusType status = DicomCommandStatusType.Reserved4; if (processor.Scu.IsConnected()) { processor.Scu.CloseForced(true); } scp = new DicomScp(IPAddress.Parse(ae.Address), ae.AETitle, ae.Port); status = processor.SendUpdate(scp, item.Dicom, item.Action); if (status != DicomCommandStatusType.Success) { if (status != DicomCommandStatusType.MissingAttribute && status != DicomCommandStatusType.AttributeOutOfRange) { AddRetry(scp, item, ae.Address); } } } catch (ClientAssociationException ce) { string message = string.Format("[Auto Update] Failed to establish association with server: {0}. Adding {1} action to update retry queue.", ce.Reason, AutoRetryProcessor.Actions[item.Action]); UpdateProcessor.LogEvent(LogType.Error, MessageDirection.None, message, DicomCommandType.Undefined, null, processor.Scu, null); AddRetry(scp, item, ae.Address); } catch (DicomException de) { string message = string.Format("[Auto Update] Error: {0}. Adding {1} action to update retry queue.", de.Message, AutoRetryProcessor.Actions[item.Action]); UpdateProcessor.LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, processor.Scu, null); AddRetry(scp, item, ae.Address); } catch (Exception e) { string message = "[Auto Update] " + e.Message; Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now, LogType.Error, MessageDirection.None, message, null, null); } finally { } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (null != Request.QueryString["file"]) { rsp = new RenderStartupParameters(Request.QueryString["file"].Trim()); UpdateProcessor up = new UpdateProcessor(Page.Response, rsp.XBRLInstancePath); up.CallExternalProcessor(rsp.ReportsFolder); } } }
public static async Task Run( [ServiceBusTrigger(Config.ServiceBus.WineEntryUpdate.Topic, Config.ServiceBus.WineEntryUpdate.Subscriber, Connection = Config.ServiceBus.WineEntryUpdate.ListenConnectionStringSetting)] string message, string correlationId, [CosmosDBTrigger(Config.Cosmos.Db, Config.Cosmos.WineEntry.Collection, ConnectionStringSetting = Config.Cosmos.DbConnectionStringSetting)] IDocumentClient client, ILogger log) { if (EventHandler.TryDeserializeAndValidate(message, log, correlationId, out var e)) { await UpdateProcessor.Run(e, log, correlationId, client); } }
/// <summary> /// Processes the update message. /// </summary> /// <param name="message">The message.</param> /// <param name="messageContext">The message context.</param> private void ProcessUpdateMessage(RelayMessage message, MessageContext messageContext) { lock (LockingUtil.Instance.GetLock(message.Id)) { try { CacheIndexUpdate cacheIndexUpdate = message.GetObject <CacheIndexUpdate>(); UpdateProcessor.Process(cacheIndexUpdate, messageContext, storeContext); } catch (Exception ex) { LoggingUtil.Log.ErrorFormat("TypeID {0} -- Error processing update message : {1}", message.TypeId, ex); throw new Exception("Error processing update message"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string filename = string.Empty; try { filename = Request.QueryString["file"]; } catch { } UpdateProcessor up = new UpdateProcessor(Page.Response, Utils.PrepareUserDir(fiName) + filename); //up.TestProcess(); up.CallExternalProcessor(reportsFolder); } }
public void Start() { _started = true; int offset = 0; var updateProcessor = new UpdateProcessor(); while (_started) { var updates = _api.GetUpdates(offset); foreach (var update in updates) { var response = updateProcessor.ProcessIncoming(update); if (response != null) _api.SendMessage(response.ChatId, response.Message); offset = update.UpdateId + 1; } Thread.Sleep(1000); } }
public object Update(int id, UpdateProcessor updateProcessor, IMapper mapper) { var processor = _context.Processors.AsNoTracking() .Where(p => p.Id == id) .FirstOrDefault(); if (processor == null) { var error = new ErrorResponse(); error.ErrorMessages.Add(MessageHelper.RecordToBeUpdatedNotFound); return(error); } else { var mappedProcessor = mapper.Map(updateProcessor, processor); mappedProcessor.DateUpdated = DateTime.Now; _context.Update(mappedProcessor); _context.SaveChanges(); return(new SuccessResponse()); } }
public IActionResult Update(int id, [FromBody] UpdateProcessor processor) { var response = _service.Update(id, processor, _mapper); return(Ok(response)); }
public static IEventProcessor Enable() { return processor ?? (processor = new UpdateProcessor()); }
private void RetryAutoUpdate(object state) { _RetryTimer.Change(Timeout.Infinite, Timeout.Infinite); try { foreach (FileInfo fi in FileSearcher.GetFiles(_RetryDir, "*.xml", SearchOption.AllDirectories)) { string xml = File.ReadAllText(fi.FullName); RetryInfo ri = xml.FromXml <RetryInfo>(_UpdateTypes); if (ri != null) { string dicomPath = Path.Combine(_DicomDir, fi.Name); dicomPath = Path.ChangeExtension(dicomPath, ".ds"); if (DateTime.Now > ri.Expires) { // // Retry period has expired. Delete File // Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now, LogType.Information, MessageDirection.None, "[Auto Update] NAction retry has passed expiration. Item removed from update retry queue.", null, new SerializableDictionary <string, object>() { { "Filename", dicomPath } }); DeleteRetry(fi, dicomPath); continue; } if (!File.Exists(dicomPath)) { Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now, LogType.Information, MessageDirection.None, "[Auto Update] File for retry action doesn't exit. Item removed from update retry queue.", null, new SerializableDictionary <string, object>() { { "Filename", dicomPath } }); DeleteRetry(fi, dicomPath); } using (UpdateProcessor processor = new UpdateProcessor(Module.Options.UseCustomAE ? Module.Options.AutoUpdateAE : ri.Item.ClientAE)) { DicomCommandStatusType status = DicomCommandStatusType.Reserved4; bool failed = false; try { string message = string.Empty; using (DicomDataSet ds = new DicomDataSet(PatientUpdaterAddIn.TemporaryDirectory)) { ds.Load(dicomPath, DicomDataSetLoadFlags.None); ri.Scp.PeerAddress = IPAddress.Parse(ri.Address); status = processor.SendUpdate(ri.Scp, ds, ri.Item.Action); if (status != DicomCommandStatusType.Success) { if (status == DicomCommandStatusType.MissingAttribute || status == DicomCommandStatusType.AttributeOutOfRange) { message = string.Format("[Auto Update] {0} failed. Item not found at destination [{1}]. Item will be removed from update retry queue.", AutoRetryProcessor.Actions[ri.Item.Action], ri.Item.SourceAE); UpdateProcessor.LogEvent(LogType.Warning, MessageDirection.None, message, DicomCommandType.Undefined, null, processor.Scu, null); } else { failed = true; } } } } catch (DicomException de) { string message = string.Format("[Auto Update] Error: {0}. Leaving {1} action to update retry queue.", de.Message, AutoRetryProcessor.Actions[ri.Item.Action]); UpdateProcessor.LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, processor.Scu, null); failed = true; } catch (Exception e) { string message = "[Auto Update] " + e.Message; Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now, LogType.Error, MessageDirection.None, message, null, null); failed = true; } if (!failed) { DeleteRetry(fi, dicomPath); } } } } } finally { _RetryTimer.Change(1000 * _Seconds, Timeout.Infinite); } }