public void RejectIer(Guid ierId, ClientIer ier, AjaxCallback callback) { ier.IsAccepted = false; _ajaxConn.Put("/ier_reject", JsonHelper.ToJson(new IerIdContainer(ier.Id)), callback); }
public void AcceptIer(ClientIer ier, AjaxCallback callback) { ier.IsAccepted = true; _ajaxConn.Put("/ier_accept", JsonHelper.ToJson(new IerIdContainer(ier.Id)), callback); }
public void LinkIer(ClientIer ier, Guid cardId, AjaxCallback callback) { ier.CardId = cardId; _ajaxConn.Put("/ier_update_active/", JsonHelper.ToJson(ier), callback); }
private void ProcessNotification(object message) { WfsMsg msg; try { msg = JsonHelper.FromJson<WfsMsg>(message.ToString()); } catch (Exception e) { _log.ErrorFormat("Failed to deserialize message {0}: {1}", message, e); return; } if (msg == null || String.IsNullOrEmpty(msg.Name)) return; _log.DebugFormat("Message is {0}", msg); // TODO: refactor that switch out try { switch (msg.Name) { case "Config": TestStaticDataMng.Get(_login).ConfigData = new ClientConfig((msg.Body as Dictionary<string, object>)["Config"] as Dictionary<string, object>); break; case "LastInitMessage": if (InitializationFinished != null) InitializationFinished(); break; case "IerIncoming": if (IncomingIer != null) { ClientUnacceptedIer ier = new ClientUnacceptedIer((msg.Body as Dictionary<string, object>)["Ier"] as Dictionary<string, object>); IncomingIer(ier); } break; case "IerDisconnected": if (CallDisconnected != null) CallDisconnected.Invoke(); break; case "CCSState": if (CcsStateChanged != null) CcsStateChanged(msg.Body, false); break; case "IerChanged": if (CurrentIerChanged != null) { ClientIer ier = new ClientIer((msg.Body as Dictionary<string, object>)["Ier"] as Dictionary<string, object>); CurrentIerChanged(ier); } break; case "IerAcceptFailed": if (AcceptFailed != null) AcceptFailed(); break; } } catch (Exception e) { _log.Error("Message processing failed", e); } }
private void SendCommit() { _log.Info("commit call"); if (_ier != null) { _ajaxHelper.CommitIer(_ier.Id, Failed); _ier = null; } if (Commited != null) Commited(); }
private void OnIncomingIer(ClientUnacceptedIer ier) { _log.InfoFormat("New ier comes with cgpn = {0}", ier.CgPn); if (_ier != null) _log.WarnFormat("New IER {0} comes, but current IER {1} already exists", ier, _ier); _ier = new ClientIer(); _ier.Id = ier.Id; _ier.CallingPartyNumber = ier.CgPn; if (_acceptCalls) { _log.InfoFormat("{0} IER {1}...", "Accepting", _ier); StatisticsGatherer.StartAcceptStopwatch(); _ajaxHelper.AcceptIer(_ier, new AjaxCallback( str => { if (CallOffered != null) CallOffered(); }, Failed)); ++StatisticsGatherer.TotalCallCount; } else if (_rejectCalls) { _log.InfoFormat("{0} IER {1}...", "Rejecting", _ier); _ajaxHelper.RejectIer(ier.Id, _ier, new AjaxCallback( str => { if (CallOffered != null) CallOffered(); }, Failed)); ++StatisticsGatherer.RejectedCallCount; } else { ++StatisticsGatherer.IgnoredCallCount; } }
private void OnCurrentIerChanged(ClientIer ier) { if (_ier == null) { _log.Error("Current IER is absent!"); return; } if (!_ier.IsEstablished && ier.IsEstablished) { _ier = ier; _log.InfoFormat("IER {0} established", ier); if (CallEstablished != null) CallEstablished(); StatisticsGatherer.StopAcceptStopwatch(); ++StatisticsGatherer.SuccessfullyAcceptedCallCount; if (_commitCondition == Condition.TimeInterval) _tmr.Start(); } }
private void OnAcceptFailed() { if (_ier == null) { _log.Error("Current IER is absent!"); return; } StatisticsGatherer.ResetAcceptCallStopwatch(); ++StatisticsGatherer.UnsuccessfullyAcceptedCallCount; _log.DebugFormat("Sending confirm disconnection for IER {0}", _ier); _ajaxHelper.ConfirmDisconnection(_ier.Id, Failed); _ier = null; }