示例#1
0
        /// <summary>
        /// 上传图片文件到数据库
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="className"></param>
        /// <param name="imageContent"></param>
        /// <param name="imageColumnName"></param>
        /// <param name="key"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public static object SaveImageToDatabase(string assemblyName, string className, byte[] imageContent, string extensionName, string key, string loginUser)
        {
            ///构建参数
            object[] param = new object[] { imageContent, extensionName, key, loginUser };
            ///实例化BLL对象
            object classObject = DataCommon.GetClassObject(assemblyName, className);
            ///
            MethodInfo met = classObject.GetType().GetMethod("UpdateImage");

            ///执行函数
            return(met.Invoke(classObject, param));
        }
示例#2
0
        /// <summary>
        /// 从数据库读取图片
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="className"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static object ReadImageFromDatabase(string assemblyName, string className, string key)
        {
            ///构建参数
            object[] param = new object[] { key };
            ///实例化BLL对象
            object classObject = DataCommon.GetClassObject(assemblyName, className);
            ///
            MethodInfo met = classObject.GetType().GetMethod("ReadImage");

            ///执行函数
            return(met.Invoke(classObject, param));
        }
示例#3
0
        /// <summary>
        /// 上传文件完成后执行的后台函数
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="className"></param>
        /// <param name="key"></param>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        public static object UploadFileFinished(string assemblyName, string className, string methodName, string key, string loginUser)
        {
            ///构建参数
            object[] param = new object[] { key, loginUser };
            ///实例化BLL对象
            object classObject = DataCommon.GetClassObject(assemblyName, className);
            ///查找UploadFileFinished函数
            MethodInfo met = classObject.GetType().GetMethod(methodName);

            ///执行函数
            return(met.Invoke(classObject, param));
        }
示例#4
0
        /// <summary>
        /// 获取BLL对象
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static object GetBusinessObject(HttpContext context)
        {
            string entityName = GetEntityName(context);

            if (string.IsNullOrEmpty(entityName))
            {
                entityName = context.Request["ENTITY_NAME"];
            }
            string moduleName = GetModuleName(context);

            return(DataCommon.GetClassObject("BLL." + moduleName, entityName + "BLL"));
        }
示例#5
0
        /// <summary>
        /// 获取数据对象
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static object GetEntityObject(HttpContext context)
        {
            string entityName = GetEntityName(context);

            if (string.IsNullOrEmpty(entityName))
            {
                entityName = context.Request["ENTITY_NAME"];
            }
            string moduleName = GetModuleName(context);
            object obj        = DataCommon.GetClassObject("DM." + moduleName, entityName + "Info");

            return(GetObject(context, obj));
        }
示例#6
0
        /// <summary>
        /// 缺件检查数据集合
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string GetLackOfInspectionPageList(HttpContext context)
        {
            ///page
            int    pageIndex = 1;
            string indexPage = context.Request["page"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(indexPage))
            {
                pageIndex = int.Parse(indexPage);
            }
            ///rows
            int    maxRow = int.MaxValue;
            string rowMax = context.Request["rows"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(rowMax))
            {
                maxRow = int.Parse(rowMax);
            }
            ///sort
            string orderText = string.Empty;

            if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["sort"]))
            {
                orderText += context.Request["sort"];
                if (!orderText.Contains("_"))
                {
                    orderText = DataCommon.GetFieldName(orderText.Trim());
                }
            }
            ///order
            if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["order"]))
            {
                orderText += " " + context.Request["order"];
            }
            ///FILTER
            string strWhere = context.Request["FILTER"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(strWhere))
            {
                strWhere = string.Empty;
            }
            if (strWhere.Trim().ToUpper() == "AND")
            {
                strWhere = string.Empty;
            }

            DataTable dt     = GetLackOfInspectionData(strWhere, orderText, pageIndex, maxRow, out int dataTotal);
            string    result = JsonHelper.DataTableToJson(dt);

            return(@"{""rows"":" + result + @",""total"":" + dataTotal + @"}");
        }
示例#7
0
 private void LoadHandler()
 {
     ///加载路由
     handlers = new HandlerBLL().GetHandlers();
     foreach (var handler in handlers)
     {
         handler.ClassObject = DataCommon.GetClassObject(handler.AssemblyName, handler.ClassName);
         if (handler.ClassObject == null)
         {
             continue;
         }
         handler.Method = handler.ClassObject.GetType().GetMethod(handler.ServerMethodName);
     }
 }
示例#8
0
        /// <summary>
        /// 获取数据集合
        /// </summary>
        /// <param name="context">ENTITY_NAME,AN,page,rows,sort,order,FILTER,SECOND_FILTER,AUTH_FILTER,URL_FILTER,COMBOGRID_FILTER,q</param>
        /// <returns></returns>
        /// SUPPLIER_PART_QUOTA
        public static string GetSupplierPartQuotaTableData(HttpContext context)
        {
            ///ENTITY_NAME
            string entityName = context.Request["ENTITY_NAME"];

            if (entityName.IndexOf("_") != -1)
            {
                entityName = entityName.Substring(0, entityName.IndexOf("_"));
            }
            entityName = entityName.Replace("Init", string.Empty);
            ///AN
            string assemblyName = context.Request["AN"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(assemblyName))
            {
                assemblyName = "BLL.SYS";
            }
            ///page
            int    pageIndex = 1;
            string indexPage = context.Request["page"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(indexPage))
            {
                pageIndex = int.Parse(indexPage);
            }
            ///rows
            int    maxRow = int.MaxValue;
            string rowMax = context.Request["rows"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(rowMax))
            {
                maxRow = int.Parse(rowMax);
            }
            ///sort
            string orderText = string.Empty;

            if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["sort"]))
            {
                orderText += context.Request["sort"];
                if (!orderText.Contains("_"))
                {
                    orderText = DataCommon.GetFieldName(orderText.Trim());
                }
            }
            ///order
            if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["order"]))
            {
                orderText += " " + context.Request["order"];
            }
            ///FILTER
            string strWhere = context.Request["FILTER"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(strWhere))
            {
                strWhere = string.Empty;
            }
            if (strWhere.Trim().ToUpper() == "AND")
            {
                strWhere = string.Empty;
            }
            ///SECOND_FILTER
            string secondFilter = context.Request["SECOND_FILTER"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(secondFilter))
            {
                strWhere += " " + secondFilter;
            }
            ///AUTH_FILTER
            string authFilter = context.Request["AUTH_FILTER"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(authFilter))
            {
                strWhere += " " + authFilter;
            }
            ///ENTITY_AUTH
            string entityAuth = context.Request["ENTITY_AUTH"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(entityAuth))
            {
                strWhere += entityAuth.Replace("^", "'");
            }
            ///URL_FILTER
            string urlFilter = context.Request["URL_FILTER"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(urlFilter))
            {
                string[] urlFilters = urlFilter.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var urlFilterCondition in urlFilters)
                {
                    strWhere += " and " + urlFilterCondition + " ";
                }
            }
            ///COMBOGRID_FILTER
            string combogridFilter = context.Request["COMBOGRID_FILTER"];
            string cbogridFilterQ  = context.Request["q"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(combogridFilter) &&
                !HttpCommon.IsNullOrEmptyOrUndefined(cbogridFilterQ))
            {
                string[] combofilters = combogridFilter.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                string   sqlTempWhere = string.Empty;
                foreach (string combofilter in combofilters)
                {
                    sqlTempWhere += "or charindex('" + cbogridFilterQ + "'," + combofilter + ") > 0 ";
                }
                strWhere += " and (" + sqlTempWhere.Substring(2) + ") ";
            }
            string wmNo = context.Request["FILTERS"].ToString();
            ///
            int dataTotal = 0;

            object list = new object();

            switch (entityName)
            {
            case "SupplierPartQuota":
                list = new SupplierPartQuotaBLL().GetListByPages(strWhere.Replace("^", "'"), pageIndex, maxRow, wmNo, out dataTotal); break;

            default:
                break;
            }
            string result = JsonHelper.ToJson(list);

            return(@"{""rows"":" + result + @",""total"":" + dataTotal + @"}");
        }
示例#9
0
        /// <summary>
        /// 供货计划相关EXCEL导出
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string SupplyPlanExportExcel(HttpContext context)
        {
            ///ENTITY_NAME
            string entityName = context.Request["ENTITY_NAME"];

            if (entityName.IndexOf("_") != -1)
            {
                entityName = entityName.Substring(0, entityName.IndexOf("_"));
            }
            if (HttpCommon.IsNullOrEmptyOrUndefined(entityName))
            {
                throw new Exception("MC:1x00000030");///参数获取错误
            }
            ///fileName
            string fileName = entityName + DateTime.Now.Ticks + ".xlsx";
            ///filePath
            string filePath = HttpContext.Current.Server.MapPath("/TEMP/EXPORTFILES");

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            ///sort
            string orderText = string.Empty;

            if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["sort"]))
            {
                orderText += context.Request["sort"];
                if (!orderText.Contains("_"))
                {
                    orderText = DataCommon.GetFieldName(orderText.Trim());
                }
            }
            ///order
            if (!HttpCommon.IsNullOrEmptyOrUndefined(context.Request["order"]))
            {
                orderText += " " + context.Request["order"];
            }
            ///FILTER
            string textWhere = context.Request["FILTER"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(textWhere))
            {
                textWhere = string.Empty;
            }
            if (textWhere.Trim().ToUpper() == "AND")
            {
                textWhere = string.Empty;
            }
            ///创建标题行
            List <EntityFieldInfo> entityFieldInfos = new List <EntityFieldInfo>();

            switch (entityName)
            {
            ///供货计划
            case "SupplyPlan":
                entityFieldInfos = GetSupplyPlanFields(textWhere, entityName)
                                   .OrderBy(d => d.DisplayOrder.GetValueOrDefault())
                                   .OrderBy(d => d.ExportExcelOrder.GetValueOrDefault()).ToList(); break;

            ///缺件检查
            case "LackOfInspection":
                entityFieldInfos = GetSupplyPlanCheckFields(textWhere, entityName)
                                   .OrderBy(d => d.DisplayOrder.GetValueOrDefault())
                                   .OrderBy(d => d.ExportExcelOrder.GetValueOrDefault()).ToList(); break;
            }

            if (entityFieldInfos.Count == 0)
            {
                throw new Exception("MC:1x00000033");///未设置导出内容
            }
            ///CODE_ITEM下拉菜单集合
            Dictionary <string, Dictionary <string, string> > dicDropdowns = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, string> columnNames = SYSHandler.GetExcelColumnNames(entityFieldInfos, ref dicDropdowns);
            ///page
            int pageIndex = 1;
            ///rows
            int maxRow = int.MaxValue;

            int dataTotal;
            ///获取数据
            DataTable dataTable = new DataTable();

            switch (entityName)
            {
            ///供货计划
            case "SupplyPlan": dataTable = GetSupplyPlanData(textWhere, orderText, pageIndex, maxRow, out dataTotal); break;

            ///缺件检查
            case "LackOfInspection": dataTable = GetLackOfInspectionData(textWhere, orderText, pageIndex, maxRow, out dataTotal); break;
            }

            if (dataTable.Rows.Count > 65535)
            {
                throw new Exception("MC:1x00000036");///导出数据不能多于65535条
            }
            ///NPOI
            NpoiHelper.TableToExcel(dataTable, columnNames, dicDropdowns, entityName, filePath + @"\" + fileName);
            ///
            return("../TEMP/EXPORTFILES/" + fileName);
        }
示例#10
0
        /// <summary>
        /// 获取更新字段集合
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static List <CommonField> GetCommonFields(HttpContext context)
        {
            string entityName      = GetEntityName(context);
            string enityNameFromUI = context.Request["ENTITY_NAME"];

            if (enityNameFromUI.IndexOf("_") != -1)
            {
                enityNameFromUI = enityNameFromUI.Substring(0, enityNameFromUI.IndexOf("_"));
            }
            if (enityNameFromUI.Contains(entityName))
            {
                entityName = enityNameFromUI;
            }
            string             moduleName      = GetModuleName(context);
            object             obj             = DataCommon.GetClassObject("DM." + moduleName, entityName + "Info");
            List <CommonField> commonfieldlist = new List <CommonField>();

            ///此处因为Keys中最后一项是method、key参数,所以需要向前移两位
            for (int i = 0; i < context.Request.Form.AllKeys.Length; i++)
            {
                string propName = context.Request.Form.AllKeys[i];
                if (propName.ToLower() == "method")
                {
                    break;
                }
                string       propValue = context.Request[propName];
                PropertyInfo p         = obj.GetType().GetProperty(propName);
                if (p == null)
                {
                    continue;
                }
                #region FIELD_NAME
                string fieldName = propName.Substring(0, 1).ToUpper();
                for (int j = 1; j < propName.Length; j++)
                {
                    if (propName[j] >= 'a' && propName[j] <= 'z')
                    {
                        fieldName += propName[j].ToString().ToUpper();
                    }
                    else if (propName[j] >= 'A' && propName[j] <= 'Z')
                    {
                        fieldName += "_" + propName[j].ToString().ToUpper();
                    }
                    else
                    {
                        fieldName += propName[j].ToString();
                    }
                }
                #endregion
                CommonField commonfield = new CommonField();
                commonfield.FieldName  = fieldName;
                commonfield.PropName   = propName;
                commonfield.FieldValue = propValue;
                commonfield.DataType   = p.PropertyType.Name;
                if (commonfield.DataType.ToLower() == "nullable`1")
                {
                    if (p.PropertyType.FullName.ToLower().Contains("system.int32"))
                    {
                        commonfield.DataType = "int32?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.int64"))
                    {
                        commonfield.DataType = "int64?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.boolean"))
                    {
                        commonfield.DataType = "boolean?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.decimal"))
                    {
                        commonfield.DataType = "decimal?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.guid"))
                    {
                        commonfield.DataType = "guid?";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.datetime"))
                    {
                        commonfield.DataType = "datetime?";
                    }
                }
                commonfieldlist.Add(commonfield);
            }
            return(commonfieldlist);
        }
示例#11
0
        /// <summary>
        /// 获取UPDATE字段的SQL语句
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public static string GetUpdateFields(HttpContext context)
        {
            string entityName      = GetEntityName(context);
            string enityNameFromUI = context.Request["ENTITY_NAME"];

            if (enityNameFromUI.IndexOf("_") != -1)
            {
                enityNameFromUI = enityNameFromUI.Substring(0, enityNameFromUI.IndexOf("_"));
            }
            if (enityNameFromUI.Contains(entityName))
            {
                entityName = enityNameFromUI;
            }
            string moduleName = GetModuleName(context);
            object obj        = DataCommon.GetClassObject("DM." + moduleName, entityName + "Info");
            string fields     = string.Empty;

            ///此处因为Keys中最后一项是method、key参数,所以需要向前移两位
            for (int i = 0; i < context.Request.Form.AllKeys.Length; i++)
            {
                string propName = context.Request.Form.AllKeys[i];
                if (propName.ToLower() == "method")
                {
                    break;
                }
                string       propValue = context.Request[propName];
                PropertyInfo p         = obj.GetType().GetProperty(propName);
                if (p == null)
                {
                    continue;
                }
                string fieldName = propName.Substring(0, 1).ToUpper();
                for (int j = 1; j < propName.Length; j++)
                {
                    if (propName[j] >= 'a' && propName[j] <= 'z')
                    {
                        fieldName += propName[j].ToString().ToUpper();
                    }
                    else if (propName[j] >= 'A' && propName[j] <= 'Z')
                    {
                        fieldName += "_" + propName[j].ToString().ToUpper();
                    }
                    else
                    {
                        fieldName += propName[j].ToString();
                    }
                }
                switch (p.PropertyType.Name.ToLower())
                {
                case "guid":
                    fields += ",[" + fieldName + "] = N'" + (string.IsNullOrEmpty(propValue) ? Guid.Empty : Guid.Parse(propValue)) + "' "; break;

                case "string":
                    ///需要将单引号转换为双引号
                    fields += ",[" + fieldName + "] = N'" + propValue.Replace("'", "''") + "' "; break;

                case "datetime":
                    fields += ",[" + fieldName + "] = N'" + (string.IsNullOrEmpty(propValue) ? DateTime.Parse("1900-01-01") : DateTime.Parse(propValue)) + "' "; break;

                case "nullable`1":
                    if (string.IsNullOrEmpty(propValue))
                    {
                        fields += ",[" + fieldName + "] = null ";
                        break;
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.int32"))
                    {
                        fields += ",[" + fieldName + "] = " + int.Parse(propValue) + " ";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.int64"))
                    {
                        fields += ",[" + fieldName + "] = " + int.Parse(propValue) + " ";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.boolean"))
                    {
                        fields += ",[" + fieldName + "] = " + (propValue.ToLower() == "30" ? 1 : 0) + " ";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.decimal"))
                    {
                        fields += ",[" + fieldName + "] = " + decimal.Parse(propValue) + " ";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.guid"))
                    {
                        fields += ",[" + fieldName + "] = N'" + Guid.Parse(propValue) + "' ";
                    }
                    if (p.PropertyType.FullName.ToLower().Contains("system.datetime"))
                    {
                        fields += ",[" + fieldName + "] = N'" + DateTime.Parse(propValue) + "' ";
                    }
                    break;

                case "int32":
                case "int64":
                    fields += ",[" + fieldName + "] = " + (string.IsNullOrEmpty(propValue) ? 0 : int.Parse(propValue)) + " "; break;

                case "bool":
                    fields += ",[" + fieldName + "] = " + (propValue.ToLower() == "30" ? 1 : 0) + " "; break;

                case "decimal":
                    fields += ",[" + fieldName + "] = " + (string.IsNullOrEmpty(propValue) ? 0 : decimal.Parse(propValue)) + " "; break;
                }
            }
            ///修改人
            PropertyInfo pModify = obj.GetType().GetProperty("ModifyUser");

            if (pModify != null)
            {
                fields += ",[MODIFY_USER] = N'" + HandlerCommon.LoginUser + "' ";
            }
            pModify = obj.GetType().GetProperty("UpdateUser");
            if (pModify != null)
            {
                fields += ",[UPDATE_USER] = N'" + HandlerCommon.LoginUser + "' ";
            }
            ///修改时间
            pModify = obj.GetType().GetProperty("ModifyDate");
            if (pModify != null)
            {
                fields += ",[MODIFY_DATE] = GETDATE() ";
            }
            pModify = obj.GetType().GetProperty("UpdateDate");
            if (pModify != null)
            {
                fields += ",[UPDATE_DATE] = GETDATE() ";
            }
            ///

            return(fields);
        }