private static object DynamicServiceCall(IService service, string methodName, string parameterString) { object[] parameters = ParameterParse.GetParameters(parameterString); return(DynamicServiceCall(service, methodName, parameters)); }
private bool InitRequestParameters(ServiceRequest request, out string errorMessage) { List <IocProvider> providers = null; try { foreach (var item in request.MethodParameters) { if (item.ParameterType == null) { if (providers == null) { providers = Unity.Instance.GetProviders("ServiceModel"); if (providers == null) { //throw new InvalidOperationException("IOC配置文件中IOC节点没有指定的名称ServiceModel"); errorMessage = "IOC配置文件中IOC节点没有指定的名称ServiceModel"; ProcessServiceError(new ArgumentException(errorMessage)); return(false); } } IocProvider provider = providers.FirstOrDefault(i => i.FullClassName == item.ParameterTypeName); if (provider != null) { item.ParameterType = Unity.Instance.GetProviderType(provider); item.ParameterValue = ParameterParse.GetObject(item); } else { //处理泛型列表 if (item.ParameterTypeName.StartsWith("System.Collections.Generic.List`1[[")) { string tempTypeName = item.ParameterTypeName.Replace("System.Collections.Generic.List`1[[", ""); tempTypeName = tempTypeName.Substring(0, tempTypeName.IndexOf(',')); provider = providers.FirstOrDefault(i => i.FullClassName == tempTypeName); if (provider == null) { //throw new InvalidOperationException("IOC配置文件的名称ServiceModel下面没有定义当前类型:" + tempTypeName); errorMessage = "IOC配置文件的名称ServiceModel下面没有定义当前类型:" + tempTypeName; ProcessServiceError(new ArgumentException(errorMessage)); return(false); } //生成基本类型 Type tempType = Unity.Instance.GetProviderType(provider); Type generic = typeof(List <>); Type[] typeArgs = { tempType }; Type constructed = generic.MakeGenericType(typeArgs); item.ParameterType = constructed; item.ParameterValue = ParameterParse.GetObject(item); } else { //throw new InvalidOperationException("系统不能处理当前类型的参数:" + item.ParameterTypeName); errorMessage = "系统不能处理当前类型的参数:" + item.ParameterTypeName; ProcessServiceError(new ArgumentException(errorMessage)); return(false); } } } }//end for request.Parameters = request.MethodParameters.Select(o => o.ParameterValue).ToArray(); errorMessage = ""; return(true); } catch (Exception ex) { errorMessage = "参数处理异常:" + ex.Message; ProcessServiceError(ex, errorMessage); return(false); } }
public void Start(string[] args) { m_Parameters = ParameterParse.ParseArguments(args, false /* firstOpFlag */, true /* multipleFiles */); foreach (KeyValuePair <string, string> kvp in m_Parameters) { switch (kvp.Key) { case "-o": case "--output": m_outFile = kvp.Value; break; case "--verbose": m_ParamVerbose++; break; case ParameterParse.LAST_PARAM: m_inFiles = kvp.Value; break; case ParameterParse.ERROR_PARAM: // if we get here, the parser found an error Logger.Log("Parameter error: " + kvp.Value); Logger.Log(Invocation()); return; default: Logger.Log("ERROR: UNKNOWN PARAMETER: " + kvp.Key); Logger.Log(Invocation()); return; } } GlobalRecordCollection globalCollection = new GlobalRecordCollection(); // Read in all log records into approriate structure type for each log line if (!String.IsNullOrEmpty(m_inFiles)) { string[] files = m_inFiles.Split(','); foreach (string fileName in files) { if (fileName.Substring(0, connName.Length) == connName) { List <Records> syncConn = StatSyncConnector.Read(fileName); globalCollection.Add(syncConn); } else if (fileName.Substring(0, sceneName.Length) == sceneName) { List <Records> syncConn = StatScene.Read(fileName); globalCollection.Add(syncConn); } else if (fileName.Substring(0, serverName.Length) == serverName) { List <Records> syncConn = StatServer.Read(fileName); globalCollection.Add(syncConn); } else { Logger.Log("No handler for file {0}", fileName); } } } // Compute the number of buckets based on the log records. Compute min and max. double[] bucketTimes = ComputeBuckets(globalCollection, 10 /* bucket size in seconds */); long numBuckets = bucketTimes.Length; if (numBuckets > 0) { List <Records>[] buckets = DistributeToBucketArray(globalCollection, numBuckets); GenerateOutput(globalCollection, buckets, bucketTimes); } }
public void Start(string[] args) { m_Parameters = ParameterParse.ParseArguments(args, false /* firstOpFlag */, true /* multipleFiles */); foreach (KeyValuePair <string, string> kvp in m_Parameters) { switch (kvp.Key) { case "-p": case "--period": m_bucketSeconds = int.Parse(kvp.Value); break; case "-o": case "--output": m_outFile = kvp.Value; break; case "-h": case "--cmHosts": m_cmHosts = kvp.Value; break; case "--verbose": m_ParamVerbose++; break; case ParameterParse.LAST_PARAM: m_inFiles = kvp.Value; break; case ParameterParse.ERROR_PARAM: // if we get here, the parser found an error Logger.Log("Parameter error: " + kvp.Value); Logger.Log(Invocation()); return; default: Logger.Log("ERROR: UNKNOWN PARAMETER: " + kvp.Key); Logger.Log(Invocation()); return; } } List <HTTPRecord> records = new List <HTTPRecord>(); // Read in the records if (!String.IsNullOrEmpty(m_inFiles)) { string[] files = m_inFiles.Split(','); foreach (string fileName in files) { records.AddRange(HTTPRecord.Read(fileName)); } } // Find high and low dates and compute the number of buckets double minDate = double.MaxValue; double maxDate = double.MinValue; foreach (HTTPRecord rec in records) { minDate = Math.Min(minDate, rec.time); maxDate = Math.Max(maxDate, rec.time); } double bucketBaseTime = minDate; int numBuckets = ((int)((maxDate - minDate) * LongDate.secondsPerDay)) / m_bucketSeconds; numBuckets += 1; // add a last bucket for rounding error at the end. Logger.Log("Number of buckets = {0}", numBuckets); // Loop through all the records and assign each to a bucket foreach (HTTPRecord rec in records) { rec.bucket = ((int)((rec.time - bucketBaseTime) * LongDate.secondsPerDay)) / m_bucketSeconds; } // Specify individual hosts to count accesses with CSV list "host,host,host" List <string> cmHosts = m_cmHosts.Split(',').ToList <string>(); int numHosts = cmHosts.Count; if (numHosts == 0) { Logger.Log("NUMBER OF Client Manager HOSTS MUST NOT BE ZERO!!"); return; } // Initialize each bucket line with the variable sized structures BucketLine[] bucketLines = new BucketLine[numBuckets]; for (int ii = 0; ii < numBuckets; ii++) { bucketLines[ii].bucket = ii; bucketLines[ii].time = bucketBaseTime + ((double)(ii * m_bucketSeconds) / LongDate.secondsPerDay); bucketLines[ii].hostCount = new int[numHosts]; bucketLines[ii].logins = 0; } // Loop through all the records and fill the bucket info foreach (HTTPRecord rec in records) { int nHost = cmHosts.IndexOf(rec.source); if (nHost >= 0) { bucketLines[rec.bucket].hostCount[nHost]++; } if (rec.remain.Contains("/Grid/login/ ")) { bucketLines[rec.bucket].logins++; } } // Print out all the buckets bool firstLine = true; TextWriter outWriter = new StreamWriter(File.Open(m_outFile, FileMode.Create)); if (outWriter != null) { using (outWriter) { if (firstLine) { StringBuilder buff = new StringBuilder(); buff.Append("bucket"); buff.Append(","); buff.Append("time"); buff.Append(","); buff.Append("logins"); buff.Append(","); for (int ii = 0; ii < cmHosts.Count; ii++) { buff.Append(cmHosts[ii]); buff.Append(","); } outWriter.WriteLine(buff.ToString()); firstLine = false; } foreach (BucketLine buck in bucketLines) { StringBuilder buff = new StringBuilder(); buff.Append(buck.bucket.ToString()); buff.Append(","); buff.Append(buck.time.ToString()); buff.Append(","); buff.Append(buck.logins.ToString()); buff.Append(","); for (int ii = 0; ii < buck.hostCount.Length; ii++) { buff.Append(buck.hostCount[ii].ToString()); buff.Append(","); } outWriter.WriteLine(buff.ToString()); } } } }
public DeviceDictionaryRWItem(byte bits, bool use, string name, ParameterShow show, ParameterParse parse) : base(bits, use, name, show) { parseFunction = parse; }
static public string GetParseFuncName(ParameterParse func) { var res = ParameterParseList.Find((Tuple <string, ParameterParse> t) => { return(t.Item2 == func); }); return(res.Item1); }