Beispiel #1
0
        /// <summary>
        /// 表单提交执行函数
        /// </summary>
        /// <param name="context">HC</param>
        /// <returns>XR.L 2016.7.7</returns>
        public static object InvokeAction(HttpContext context)
        {
            ///INSERT.UPDATE.DELETE.SELECT
            ///返回大写字符串
            string actionName = HttpCommon.GetActionName(context);
            ///BLL层的对象实例化
            object bllObject = HttpCommon.GetBusinessObject(context);

            ///对于UPDATE.DELETE.SELECT方法需要ID参数支持
            object[][] rowsKeyValues = HttpCommon.GetEntityKeyValues(context);
            string     loginUserName = context.Session["loginUserName"].ToString();

            ///根据不同的ACTION指向执行不同的函数
            switch (actionName.ToLower())
            {
            case "insert": return(InsertInfo(bllObject, HttpCommon.GetEntityObject(context)));

            case "update": return(UpdateInfo(bllObject, HttpCommon.GetUpdateFields(context).Substring(1), rowsKeyValues[0]));

            case "updatefield": return(UpdateInfo(bllObject, HttpCommon.GetCommonFields(context), rowsKeyValues[0]));

            case "delete": return(DeleteInfo(bllObject, rowsKeyValues[0], loginUserName));

            case "select": return(SelectInfo(bllObject, rowsKeyValues[0]));

            case "status":
                string statusName = HttpCommon.GetStatusName(context);
                if (string.IsNullOrEmpty(statusName))
                {
                    throw new Exception("MC:0x00000188");
                }
                return(StatusInfo(bllObject, rowsKeyValues, statusName, loginUserName));
            }
            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 获取供货计划数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string GetSupplyPlanPageList(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;
            }
            ///ENTITY_AUTH
            string entityAuth = context.Request["ENTITY_AUTH"];

            if (!HttpCommon.IsNullOrEmptyOrUndefined(entityAuth))
            {
                strWhere += entityAuth.Replace("^", "'");
            }


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

            return(@"{""rows"":" + result + @",""total"":" + dataTotal + @"}");
        }
Beispiel #3
0
        public string GetExcel(HttpContext context)
        {
            string address = HandlerCommon.ExportExcel(context);
            ///ENTITY_NAME
            string entityName = context.Request["ENTITY_NAME"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(entityName))
            {
                throw new Exception("MC:1x00000030");///参数获取错误
            }
            return(address + "&" + entityName);
        }
Beispiel #4
0
        /// <summary>
        /// 获取缺件检查页面配置信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string GetLackOfInspectionEntityFields(HttpContext context)
        {
            ///实体名,可能是FORM的实体名
            string entityName = context.Request["ENTITY_NAME"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(entityName))
            {
                throw new Exception("MC:1x00000030");///参数获取错误
            }
            ///表名
            string tableName = context.Request["TABLE_NAMES"];

            if (HttpCommon.IsNullOrEmptyOrUndefined(tableName))
            {
                throw new Exception("MC:1x00000030");///参数获取错误
            }
            ///FILTER
            string strWhere = context.Request["FILTER"];

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

            ///EntityFieldInfo  获取实体字段在页面显示的信息
            List <EntityFieldInfo> entityFieldList = GetSupplyPlanCheckFields(strWhere, entityName);

            ///
            string resultEntityFields = JsonHelper.ToJson(entityFieldList);
            ///EntityInfo
            EntityInfo entityinfo       = new EntityBLL().GetInfo(entityName, tableName);
            string     resultEntityInfo = JsonHelper.ToJson(entityinfo);

            return(@"{""entityfieldform"":" + resultEntityFields
                   + @",""entityinfo"":" + resultEntityInfo + @"}");
        }
Beispiel #5
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 + @"}");
        }
Beispiel #6
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);
        }