protected override BeeDataAdapter GetRouteData(HttpContext context) { BeeDataAdapter result = new BeeDataAdapter(); RouteValueDictionary routeData = RequestContext.RouteData.Values; foreach (string item in routeData.Keys) { if (string.Compare("controller", item, true) == 0) { result.Add(Constants.BeeControllerName, routeData[item]); } else if (string.Compare("action", item, true) == 0) { result.Add(Constants.BeeActionName, routeData[item]); } else if (string.Compare("area", item, true) == 0) { result.Add(Constants.BeeAreaName, routeData[item]); } else { result.Add(item, routeData[item]); } } return(result); }
protected override BeeDataAdapter GetRouteData(System.Web.HttpContext context) { XmlDocument document = new XmlDocument(); document.Load(context.Request.InputStream); BeeDataAdapter dataAdapter = new BeeDataAdapter(); foreach (XmlNode node in document.DocumentElement.ChildNodes) { dataAdapter.Add(node.Name, node.InnerText); } string msgType = dataAdapter.TryGetValue <string>("msgtype", string.Empty); if (string.Compare("event", msgType, true) == 0) { string eventName = dataAdapter.TryGetValue <string>("event", string.Empty); dataAdapter.Add(Constants.BeeControllerName, MainControllerName); dataAdapter.Add(Constants.BeeActionName, eventName); } else { dataAdapter.Add(Constants.BeeControllerName, MainControllerName); dataAdapter.Add(Constants.BeeActionName, msgType); } Logger.Debug(dataAdapter.ToString()); // 实现一个调用链 /* * menuid-1-2-3 * * */ InvokeTreeManager.Instance.Check(dataAdapter); return(dataAdapter); }
private static BeeDataAdapter GetHeaderItem(PropertySchema propertySchema) { ModelPropertyAttribute modelPropertyAttribute = propertySchema.GetCustomerAttribute <ModelPropertyAttribute>(); BeeDataAdapter dataAdapter = new BeeDataAdapter(); string descriptionInfo; if (modelPropertyAttribute != null) { if (!modelPropertyAttribute.Visible) { return(null); } descriptionInfo = modelPropertyAttribute.Description; if (string.IsNullOrEmpty(descriptionInfo)) { descriptionInfo = propertySchema.Name; } dataAdapter.Add("description", descriptionInfo); dataAdapter.Add("name", propertySchema.Name); if (modelPropertyAttribute.ColumnWidth != 0) { dataAdapter.Add("width", modelPropertyAttribute.ColumnWidth.ToString()); } if (!string.IsNullOrEmpty(modelPropertyAttribute.Align)) { dataAdapter.Add("align", modelPropertyAttribute.Align); } if (modelPropertyAttribute.OrderableFlag) { dataAdapter.Add("orderField", propertySchema.Name); } } else { dataAdapter.Add("description", propertySchema.Name); dataAdapter.Add("Name", propertySchema.Name); } return(dataAdapter); }
private BeeDataAdapter GetSearchItem(PropertySchema propertySchema) { BeeDataAdapter dataAdapter = null; ModelPropertyAttribute modelPropertyAttribute = propertySchema.GetCustomerAttribute <ModelPropertyAttribute>(); if (modelPropertyAttribute != null) { if (!modelPropertyAttribute.Visible) { return(null); } if (!modelPropertyAttribute.Queryable) { return(null); } dataAdapter = new BeeDataAdapter(); string descriptionInfo = modelPropertyAttribute.Description; if (string.IsNullOrEmpty(descriptionInfo)) { descriptionInfo = propertySchema.Name; } dataAdapter.Add("name", propertySchema.Name); dataAdapter.Add("Type", propertySchema.PropertyType); dataAdapter.Add("QueryType", modelPropertyAttribute.QueryType); dataAdapter.Add("Description", descriptionInfo); if (!string.IsNullOrEmpty(modelPropertyAttribute.MappingName)) { dataAdapter.Add("MappingName", modelPropertyAttribute.MappingName); } if (propertySchema.PropertyType.IsEnum && !dataAdapter.ContainsKey("MappingName")) { dataAdapter.Add("MappingName", propertySchema.PropertyType.ToString()); } } return(dataAdapter); }
public void ProcessRequest(HttpContext context) { System.Runtime.Remoting.Messaging.CallContext.HostContext = context; Stopwatch stopwatch = new Stopwatch(); try { stopwatch.Start(); BeeDataAdapter routeData = GetRouteData(context); string controllerName = routeData[Constants.BeeControllerName] as string; string actionName = routeData[Constants.BeeActionName] as string; HttpContext httpContext = context; //this.httpContext = context; BeeDataAdapter dataAdapter = new BeeDataAdapter(routeData); NameValueCollection formParams = httpContext.Request.Form; foreach (string key in formParams.Keys) { if (!string.IsNullOrEmpty(key)) { dataAdapter.Add(key.ToLower(), StringUtil.HtmlEncode(formParams[key])); } } formParams = httpContext.Request.QueryString; foreach (string key in formParams.Keys) { if (!string.IsNullOrEmpty(key)) { dataAdapter.Add(key.ToLower(), StringUtil.HtmlEncode(formParams[key])); } } // 解析inputstream string json = new StreamReader(httpContext.Request.InputStream).ReadToEnd(); if (!string.IsNullOrEmpty(json) && json.StartsWith("{")) { var jObject = Newtonsoft.Json.Linq.JObject.Parse(json); foreach (var item in jObject) { dataAdapter.Add(item.Key, item.Value); } } if (LogRequestFlag) { BeeDataAdapter cookieData = new BeeDataAdapter(); foreach (string key in context.Request.Cookies.AllKeys) { cookieData.Add(key, context.Request.Cookies[key].Value); } Logger.Debug(@" cookie:{0} Request:{1}".FormatWith(cookieData.ToString(), dataAdapter.ToString())); } ActionExecutingArgs args = new ActionExecutingArgs(controllerName, actionName, dataAdapter); ActionExecuting(args); // 提供拦截通道 if (args.Result != ActionExecutingResult.OK) { BeeMvcResult mvcResult = new BeeMvcResult(); mvcResult.code = 400; if (args.Code > 0) { mvcResult.code = args.Code; } mvcResult.msg = args.Message; WriteMvcResult(httpContext, mvcResult); return; } InnerExecuteAction(context, controllerName, actionName, dataAdapter); stopwatch.Stop(); if (stopwatch.ElapsedMilliseconds > 5000) { Logger.Debug(string.Format("{0}耗时较长, 耗时:{1}ms", context.Request.Url.ToString(), stopwatch.ElapsedMilliseconds)); } } catch (Exception e) { string error = ResourceUtil.ReadToEndFromCache(typeof(MvcDispatcher).Assembly, "Bee.Web.Error.htm", false); context.Response.Write(string.Format(error, e.Message, GetFullException(e))); Logger.Error(e.Message, e); Logger.Log(LogLevel.Core, e.Message, e); } }
private static bool CheckMethod(MethodSchema methodSchema, string methodName , BeeDataAdapter dataAdapter, out BeeDataAdapter filteredData) { bool result = false; filteredData = new BeeDataAdapter(); bool flag = true; List <ParameterInfo> customerTypeParaList = new List <ParameterInfo>(); List <ParameterInfo> simpleTypeParaList = new List <ParameterInfo>(); foreach (ParameterInfo parameterInfo in methodSchema.ParameterInfos) { if (Type.GetTypeCode(parameterInfo.ParameterType) == TypeCode.Object && parameterInfo.ParameterType != typeof(Guid)) { customerTypeParaList.Add(parameterInfo); } else { simpleTypeParaList.Add(parameterInfo); } } foreach (ParameterInfo parameterInfo in simpleTypeParaList) { // check the simple parameters name if (!dataAdapter.ContainsKey(parameterInfo.Name)) { flag = false; break; } } if (flag) { foreach (ParameterInfo parameterInfo in simpleTypeParaList) { filteredData.Add(parameterInfo.Name, dataAdapter[parameterInfo.Name]); } if (customerTypeParaList.Count == 0) { result = true; } else { bool allParameterFlag = true; foreach (ParameterInfo parameterInfo in customerTypeParaList) { object dataValue = dataAdapter[parameterInfo.Name]; if (dataValue == null || parameterInfo.ParameterType != dataValue.GetType()) { allParameterFlag = false; } } if (allParameterFlag) { result = true; } else if (customerTypeParaList.Count == 1) { // try to match if possible foreach (ParameterInfo parameterInfo in customerTypeParaList) { if (parameterInfo.ParameterType == typeof(BeeDataAdapter)) { //dataAdapter.RemoveEmptyOrNull(); filteredData.Add(parameterInfo.Name, dataAdapter); } else { filteredData.Add(parameterInfo.Name, ConvertUtil.ConvertDataToObject(parameterInfo.ParameterType, dataAdapter)); //dataAdapter.RemoveEmptyOrNull(); } } result = true; } else { // do nothing here. } } } return(result); }
public static BeeDataAdapter GetExifInfo(Image src) { BeeDataAdapter result = new BeeDataAdapter(); Bee.Util.EXIFMetaData.Metadata metadata = EXIFMetaData.GetEXIFMetaData(src); string model = metadata.CameraModel.DisplayValue; if (model != null && model.EndsWith("\0")) { model = model.Substring(0, model.Length - 1); } result.Add("Camera", model); result.Add("Aperture", metadata.Aperture.DisplayValue); result.Add("ShutterSpeed", metadata.ShutterSpeed.DisplayValue); result.Add("Flash", metadata.Flash.DisplayValue); result.Add("ImageWidth", metadata.ImageWidth.DisplayValue); result.Add("ImageHeight", metadata.ImageHeight.DisplayValue); result.Add("FNum", metadata.FNumber.DisplayValue); result.Add("ISOSpeed", metadata.ISOSpeed.DisplayValue); result.Add("ExposureTime", metadata.ExposureTime.DisplayValue); DateTime pictureTime = DateTime.Now; if (metadata.CreateTime.DisplayValue != null) { if (DateTime.TryParse(metadata.CreateTime.DisplayValue, out pictureTime)) { result.Add("PictureTime", pictureTime); } else { string[] items = metadata.CreateTime.DisplayValue.Split(':', ' '); if (items.Length == 6) { List <int> list = new List <int>(); int intValue = 0; foreach (string item in items) { if (int.TryParse(item, out intValue)) { list.Add(intValue); } } if (list.Count == 6) { pictureTime = new DateTime(list[0], list[1], list[2], list[3], list[4], list[5]); result.Add("PictureTime", pictureTime); } } } } result.Add("Latitude", metadata.Latitude.DisplayValue); result.Add("Longitude", metadata.Longitude.DisplayValue); return(result); }
public override PageResult Index(BeeDataAdapter dataAdapter) { dataAdapter.Add("delflag", false); return(View(List(dataAdapter).Model)); }
private BeeDataAdapter GetDetailItem(PropertySchema propertySchema, string identityColumn) { ModelPropertyAttribute modelPropertyAttribute = propertySchema.GetCustomerAttribute <ModelPropertyAttribute>(); BeeDataAdapter dataAdapter = new BeeDataAdapter(); string descriptionInfo; bool readOnly = false; if (string.Compare(identityColumn, propertySchema.Name, true) == 0) { dataAdapter.Add("showonly", true); readOnly = true; } if (modelPropertyAttribute != null) { descriptionInfo = modelPropertyAttribute.Description; if (string.IsNullOrEmpty(descriptionInfo)) { descriptionInfo = propertySchema.Name; } if (!modelPropertyAttribute.Visible) { dataAdapter.Add("visible", false); } if (!string.IsNullOrEmpty(modelPropertyAttribute.MappingName)) { dataAdapter.Add("mappingname", modelPropertyAttribute.MappingName); } readOnly = readOnly || modelPropertyAttribute.ReadonlyFlag; if (!readOnly) { if (propertySchema.PropertyType.UnderlyingSystemType == typeof(DateTime)) { if (string.Compare("modifytime", propertySchema.Name, true) == 0 || string.Compare("updatetime", propertySchema.Name, true) == 0 || string.Compare("createtime", propertySchema.Name, true) == 0) { readOnly = true; dataAdapter.Add("showonly", true); } } } } else { descriptionInfo = propertySchema.Name; } dataAdapter.Add("description", descriptionInfo); dataAdapter.Add("name", propertySchema.Name); dataAdapter.Add("readonly", readOnly); if (propertySchema.PropertyType == typeof(DateTime)) { dataAdapter.Add("date", true); } if (propertySchema.PropertyType.IsEnum && !dataAdapter.ContainsKey("mappingname")) { dataAdapter.Add("mappingname", propertySchema.PropertyType.ToString()); } return(dataAdapter); }