/// <summary> /// Open the adequate stream to the server. /// </summary> /// <param name="client">TCP client to use to open the stream</param> /// <param name="settings">Settings to use when manipulating the stream</param> public CStreamClientIO(TcpClient client, CStreamClientSettings settings) : base(client, settings.LengthBufferSize) { if (settings.IsValid) { Settings = settings; // determine the kind of link to use if (Settings.UseSsl) { sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null); int tmo = client.ReceiveTimeout * 1000; client.ReceiveTimeout = 5000; try { // authenticate aginst the server #if NET35 // check if TLS is supported bool useTLS = false; try { RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5"); object value = (null != key ? key.GetValue("SP") : null); useTLS = (null != value && 1 <= (int)value); } catch (Exception ex) { } CLog.Add($".NET 3.5 {(useTLS ? "using TLS 1.2" : "not using TLS")}", TLog.INFOR); if (useTLS) { sslStream.AuthenticateAsClient(Settings.ServerName, null, (System.Security.Authentication.SslProtocols) 3072, false); } else { sslStream.AuthenticateAsClient(Settings.ServerName); } #else sslStream.AuthenticateAsClient(Settings.ServerName); #endif } catch (Exception ex) { CLog.AddException($"{MethodBase.GetCurrentMethod().Module.Name}.{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}", ex); sslStream = null; throw; } finally { client.ReceiveTimeout = tmo; } } else { networkStream = client.GetStream(); } } else { throw new Exception("Invalid client stream settings."); } }
/// <summary> /// Конструктор /// </summary> /// <param name="log">Журнал событий, в котором будет это событие</param> public CEvent(CLog log) { _Log = log; log.Add(this); EventID = _Log.LastID++; _Text_Parameters = new Dictionary<string, string>(); _Int_Parameters = new Dictionary<string, int>(); _Double_Parameters = new Dictionary<string, double>(); _Bool_Parameters = new Dictionary<string, bool>(); }
public static string Add(string text, TLog tlog = TLog.INFOR, bool display = true) { if (display) { Console.WriteLine(CLog.Add(text, tlog)); } else { CLog.Add(text, tlog); } return(text); }
/// <summary> /// The following method is invoked by the RemoteCertificateValidationDelegate /// Refer to .NET specs for a full description /// </summary> /// <param name="sender"></param> /// <param name="certificate"></param> /// <param name="chain"></param> /// <param name="sslPolicyErrors"></param> /// <returns></returns> private bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { //return true; if (Settings.AllowedSslErrors == (sslPolicyErrors | Settings.AllowedSslErrors)) { return(true); } // arrived here a certificate error occured // Do not allow this client to communicate with unauthenticated servers. CLog.Add($"Certificate error [{sslPolicyErrors}]", TLog.ERROR); return(false); }
/// <summary> /// Calls the <see cref="Win32UIActivityDelegate"/> method which is in charge of taking care of the activity, passing it the arguments /// </summary> /// <param name="method">The <see cref="Win32UIActivityDelegate"/> method to call</param> /// <param name="activity">The <see cref="UIActivity"/> object to pass to the method</param> public static void AddActivity(Win32UIActivityDelegate method, UIActivity activity) { try { if (null != method && null != activity && null != activity.Ctrl) { activity.Ctrl.Invoke(method, activity); } else { CLog.Add($"{activity} could not be added", TLog.ERROR); } } catch (Exception ex) { CLog.AddException($"{MethodBase.GetCurrentMethod().Module.Name}.{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}", ex, $"Exception while processing {activity}"); } }
public static string UnavailableDeviceUnavailablePINVerificationMethod(NexoResponseType r, string method) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableDevice; r.AdditionalResponse = "Unavaible PIN verification method: " + method; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string DeviceOutDeviceTemporaryOut(NexoResponseType r, string device, string reason) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.DeviceOut; r.AdditionalResponse = device + " is temporarily out of service: " + reason; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundTransactionNotFound(NexoResponseType r, string txnid, string component) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Transaction " + txnid + " not Found in " + component + " link"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string WrongPIN(NexoResponseType r, string nbretries, string remainingretries) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.WrongPIN; r.AdditionalResponse = "Wrong PIN: " + nbretries + " retries – Remaining retries: " + remainingretries; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string CancelSystemCancellation(NexoResponseType r, string reason) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.Cancel; r.AdditionalResponse = "System cancellation during " + reason; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableServiceUnavailableServiceForTheCard(NexoResponseType r, string service, string cardbrand) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableService; r.AdditionalResponse = "Service " + service + " unavailable for card: " + cardbrand; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string CancelUserCancellation(NexoResponseType r, string status) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.Cancel; r.AdditionalResponse = "User cancellation during " + status; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundCardRemoved(NexoResponseType r, string lastmessage) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Card removed by the customer: " + lastmessage; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string PaymentRestriction(NexoResponseType r, string number, string brand) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.PaymentRestriction; r.AdditionalResponse = number + " products not payable by " + brand + " card"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundPredefinedMessageReferenceNotFound(NexoResponseType r, string messageid) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Message reference " + messageid + " not found"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundLanguageNotSupported(NexoResponseType r, string language) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Language " + language + " not supported"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundKeyReferenceNotFound(NexoResponseType r, string keyref) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Key reference " + keyref + " not found"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundReconciliationNotFound(NexoResponseType r, string reconciliationid, string reason) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Reconciliation " + reconciliationid + " not found: " + reason; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string NotFoundMessageNotFound(NexoResponseType r, string messagecategory, string id) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.NotFound; r.AdditionalResponse = "Message not found, last " + messagecategory + " has ID " + id; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableDeviceUnavailableSoundFormat(NexoResponseType r, string format) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableDevice; r.AdditionalResponse = "Unavailable sound format: " + format; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string RefusalLocalDecline(NexoResponseType r, string transaction, string acquirer, string reason, string code) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.Refusal; r.AdditionalResponse = transaction + " refused locally : " + acquirer + " - Reason: " + reason + " - Code: " + code; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableServiceTooOldProtocolVersion(NexoResponseType r, string saleversion, string serverversion) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableService; r.AdditionalResponse = "Sale protocol version " + saleversion + " too old for server implemented version: " + serverversion; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string BusyDeviceBusy(NexoResponseType r, string system, string device) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.Busy; r.AdditionalResponse = system + " terminal " + device + " busy processing the device request"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableServiceUnavailableAdministrativeService(NexoResponseType r) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableService; r.AdditionalResponse = "Unavailable administrative service"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public void TestMethod5() { const int count = 10; Random rand = new Random(); CLog log = new CLog(); for (int i = 0; i < count; i++) { Methods.GenerateEvent(log, ref rand); log[i,-1].Date = Methods.GenerateDateTimeOffset(ref rand); } log.Add(new CTrace()); CEvent evt2=log.Events[0]; foreach (CEvent evt in log.Events) log[0].Add(evt); CView view = log.GetView(); view[0].Remove(evt2); Assert.AreEqual(log[0].Count - 1, view[0].Count); }
public static string UnreachableHostNoHostAnswer(NexoResponseType r, string reason) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnreachableHost; r.AdditionalResponse = "No answer from host: " + reason; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableDeviceUnavailableDisplayFormat(NexoResponseType r, string format, string feature) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableDevice; r.AdditionalResponse = "Unavailable display format: " + format + " for feature: " + feature; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string GenericEror(NexoResponseType r, ResultEnumeration result, ErrorConditionEnumeration errorCondition, string addtionalInformation) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = result; r.ErrorCondition = errorCondition; r.AdditionalResponse = addtionalInformation; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableDeviceUnavailableInputCommand(NexoResponseType r, string command) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableDevice; r.AdditionalResponse = "Unavaible input command: " + command; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string DeviceOutPOIPermanentlyUnavailable(NexoResponseType r, string device, string reason) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.DeviceOut; r.AdditionalResponse = "POI " + device + " is permanently unavailable: " + reason; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableDeviceUnavailablePrintingMode(NexoResponseType r, string parameter, string value) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableDevice; r.AdditionalResponse = "Unavaible printing mode: " + parameter + " (" + value + ")"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
public static string UnavailableDevice(NexoResponseType r, string devicetype, string infoqualify) { if (ResultEnumeration.Success != r.Result) { return(r.AdditionalResponse); } r.Result = ResultEnumeration.Failure; r.ErrorCondition = ErrorConditionEnumeration.UnavailableDevice; r.AdditionalResponse = devicetype + " (" + infoqualify + ") Device unavailable absent or not configured"; CLog.Add(r.AdditionalResponse, TLog.ERROR); return(r.AdditionalResponse); }
// Открывает XES в класс Log private static void open_xml_to_class(XmlDocument doc, out CLog log, out List<XmlNode> trash) { int ErrorCount = 0; DateTimeOffset? date = null; XmlNodeList listoftraces = doc.DocumentElement.ChildNodes; XmlNodeList listofevents; XmlNodeList listofnames; CultureInfo a = new CultureInfo(CultureInfo.CurrentCulture.Name); a.NumberFormat.NumberDecimalSeparator = "."; log = new CLog(); trash = new List<XmlNode>(); foreach (XmlNode trace in listoftraces) { if (trace.Name == "trace") { CTrace tr = new CTrace(); listofevents = trace.ChildNodes; foreach (XmlNode node in listofevents) { switch (node.Name) { case "string": if (node.Attributes[0].Value == "concept:name") tr.Name = node.Attributes[1].Value; else tr.Text_Parameters.Add(node.Attributes[0].Value, node.Attributes[1].Value); break; case "int": try { tr.Int_Parameters.Add(node.Attributes[0].Value, int.Parse(node.Attributes[1].Value)); //TODO Это } catch { ErrorCount++; } break; case "float": try { tr.Double_Parameters.Add(node.Attributes[0].Value, double.Parse(node.Attributes[1].Value)); } catch { ErrorCount++; } break; case "boolean": try { tr.Bool_Parameters.Add(node.Attributes[0].Value, bool.Parse(node.Attributes[1].Value)); } catch { ErrorCount++; } break; case "event": CEvent ev = new CEvent(log); listofnames = node.ChildNodes; foreach (XmlNode name in listofnames) switch (name.Name) { case "date": DateTimeOffset dat = new DateTimeOffset(); DateTimeOffset.TryParse(name.Attributes[1].Value, out dat); date = dat; ev.Date = date; break; case "string": if (name.Attributes[0].Value != "concept:name") ev.Text_Parameters.Add(name.Attributes[0].Value, name.Attributes[1].Value); else ev.Name = name.Attributes[1].Value; break; case "int": try { ev.Int_Parameters.Add(name.Attributes[0].Value, int.Parse(name.Attributes[1].Value)); } catch { ErrorCount++; } break; case "float": try { ev.Double_Parameters.Add(name.Attributes[0].Value, double.Parse(name.Attributes[1].Value, a)); } catch { ErrorCount++; } //TODO Создать логгирующую ошибки системы break; case "boolean": try { ev.Bool_Parameters.Add(name.Attributes[0].Value, bool.Parse(name.Attributes[1].Value)); } catch { ErrorCount++; } break; } tr.Add(ev); break; } } log.Add(tr); } else trash.Add(trace); } listofevents = null; listofnames = null; listoftraces = null; if ((ErrorCountEvent != null) && (ErrorCount > 0)) ErrorCountEvent(ErrorCount); }