/// <summary> /// 构造函数 /// </summary> /// <param name="name"></param> /// <param name="valueType"></param> /// <param name="value"></param> /// <param name="description">对此项结果的描述,比如“整个矩形框架中的每一层的最大位移”</param> public ResultFileItem(string name, ResultValueType valueType, object value, string description) { Name = name; ValueType = valueType; Value = value; Description = description; }
private static Dictionary <string, ResultFileItem> ReadDictionary(StreamReader sr) { var dict = new Dictionary <string, ResultFileItem>(); string strLine = sr.ReadLine(); string pattern = @"T \* (.*) \* (.*) \* (.*)"; // 以 “liner-组名-”开头 // Match match = Regex.Match(strLine, pattern, RegexOptions.IgnoreCase); while (match.Success) { string keyName = match.Groups[1].Value; ResultValueType valueType = GetResultValueType(match.Groups[2].Value); string description = match.Groups[3].Value; // switch (valueType) { case ResultValueType.Vector: double[] vec = null; strLine = GetVector(sr, out vec); dict.Add(keyName, new ResultFileItem(keyName, ResultValueType.Vector, value: vec, description: description)); break; case ResultValueType.Number: double num = 0; strLine = GetNumber(sr, out num); dict.Add(keyName, new ResultFileItem(keyName, ResultValueType.Number, value: num, description: description)); break; case ResultValueType.Array2D: double[,] arr2D; strLine = GetArray2D(sr, out arr2D); dict.Add(keyName, new ResultFileItem(keyName, ResultValueType.Array2D, value: arr2D, description: description)); break; case ResultValueType.String: string str; strLine = GetString(sr, out str); dict.Add(keyName, new ResultFileItem(keyName, ResultValueType.String, value: str, description: description)); break; } if (sr.EndOfStream) { break; } match = Regex.Match(strLine, pattern, RegexOptions.IgnoreCase); } return(dict); }
public static double GetDLRSinrCalcResult(ResultValueType vt) { switch (vt) { case ResultValueType.INVALID: return double.MinValue; case ResultValueType.NOTCOUNT: return double.MinValue; case ResultValueType.DEFAULT: return 0.0; } return 0.0; }
public static short GetBestServerRSRPResult(ResultValueType vt) { switch (vt) { case ResultValueType.INVALID: return -32768; case ResultValueType.NOTCOUNT: return -32768; case ResultValueType.DEFAULT: return -32768; } return -32768; }
public static short GetBestServerCarrierIDResult(ResultValueType vt) { switch (vt) { case ResultValueType.INVALID: return 0x7fff; case ResultValueType.NOTCOUNT: return 0x7fff; case ResultValueType.DEFAULT: return 0x7fff; } return 0x7fff; }
public static short GetDLRSSICalcResult(ResultValueType vt) { switch (vt) { case ResultValueType.INVALID: return -32768; case ResultValueType.NOTCOUNT: return -32768; case ResultValueType.DEFAULT: return -32768; } return 0; }
public static short GetHandoverResult(ResultValueType vt) { switch (vt) { case ResultValueType.INVALID: return 0; case ResultValueType.NOTCOUNT: return 0x7fff; case ResultValueType.DEFAULT: return -32768; } return 0; }
private static ResultValue GetResultValue(ResultValueType type, JToken rawValue) { switch (type) { case ResultValueType.String: return(new StringValue((string)rawValue)); case ResultValueType.Integer: return(new IntegerValue((int?)rawValue)); case ResultValueType.Decimal: return(new DecimalValue((decimal?)rawValue)); case ResultValueType.Date: return(new DateValue((DateTime?)rawValue)); case ResultValueType.TimeSpan: var data = new TimeSpanData { Quantity = (int)rawValue["Quantity"], Increment = ParseEnum <TimeSpanIncrement>(rawValue["Increment"]), Recurrence = ParseEnum <TimeSpanRecurrenceType>(rawValue["Recurrence"]), EndByDate = (DateTime?)rawValue["EndByDate"], EndAfterOccurrences = (int?)rawValue["EndAfterOccurrences"], }; return(new TimeSpanValue(data)); case ResultValueType.Guid: return(new GuidValue((Guid?)rawValue)); case ResultValueType.StringList: var stringTokens = (JArray)rawValue; var stringList = new List <string>(stringTokens.Select(t => (string)t)); return(new StringListValue(stringList)); case ResultValueType.IntegerList: var intTokens = (JArray)rawValue; var intList = new List <int>(intTokens.Select(t => (int)t)); return(new IntegerListValue(intList)); case ResultValueType.GuidList: var guidTokens = (JArray)rawValue; var guidList = new List <Guid>(guidTokens.Select(t => (Guid)t)); return(new GuidListValue(guidList)); case ResultValueType.AttachmentList: var attachmentTokens = (JArray)rawValue; var attachmentList = attachmentTokens.Select(attachmentToken => new AttachmentFile { FileId = (int)attachmentToken["FileId"], FileName = (string)attachmentToken["FileName"], Notes = (string)attachmentToken["Notes"], }).ToArray(); return(new AttachmentListValue(attachmentList)); case ResultValueType.ScoringGroupList: var scoringGroupTokens = (JArray)rawValue; var scoringGroupList = scoringGroupTokens.Select(scoringGroupToken => new ScoringGroup { ListValueId = (Guid)scoringGroupToken["ListValueId"], Name = (string)scoringGroupToken["Name"], Score = (decimal)scoringGroupToken["Score"], MaximumScore = (decimal)scoringGroupToken["MaximumScore"], }).ToArray(); return(new ScoringGroupListValue(scoringGroupList)); } // e.g., future types not supported in this version return(null); }