public static ProtocolLine Parse ( [NotNull] string line ) { Sure.NotNullNorEmpty(line, line); ProtocolLine result = new ProtocolLine { Text = line, Success = true }; string[] parts = line.Split('#'); foreach (string part in parts) { string[] p = part.Split('='); if (p.Length > 0) { string name = p[0].ToUpper(); string value = string.Empty; if (p.Length > 1) { value = p[1]; } switch (name) { case "DBN": result.Database = value; break; case "MFN": result.Mfn = value.SafeToInt32(); break; case "AUTOIN": result.Autoin = value; break; case "UPDATE": result.Update = value; break; case "STATUS": result.Status = value; break; case "UPDUF": result.UpdUf = value; break; case "GBL_ERROR": result.Error = value; result.Success = false; break; } } } return(result); }
/// <summary> /// Parse server response. /// </summary> public void Parse ( [NotNull] ServerResponse response ) { Sure.NotNull(response, nameof(response)); Protocol = ProtocolLine.Parse(response); RecordsProcessed = Protocol.Length; RecordsSucceeded = Protocol.Count(line => line.Success); }
public static ProtocolLine[] Parse ( [NotNull] ServerResponse response ) { Sure.NotNull(response, nameof(response)); List <ProtocolLine> result = new List <ProtocolLine>(); while (true) { string line = response.GetAnsiString(); if (ReferenceEquals(line, null) || line.Length == 0) { break; } ProtocolLine item = Parse(line); result.Add(item); } return(result.ToArray()); }
/// <summary> /// Merge result. /// </summary> public void MergeResult ( [NotNull] GblResult intermediateResult ) { Sure.NotNull(intermediateResult, nameof(intermediateResult)); if (intermediateResult.Canceled) { Canceled = intermediateResult.Canceled; } if (!ReferenceEquals(intermediateResult.Exception, null)) { Exception = intermediateResult.Exception; } RecordsProcessed += intermediateResult.RecordsProcessed; RecordsFailed += intermediateResult.RecordsFailed; RecordsSucceeded += intermediateResult.RecordsSucceeded; if (ReferenceEquals(Protocol, null)) { Protocol = new ProtocolLine[0]; } ProtocolLine[] otherLines = intermediateResult.Protocol; if (ReferenceEquals(otherLines, null)) { otherLines = new ProtocolLine[0]; } Protocol = ArrayUtility.Merge ( Protocol, otherLines ); }