private static void Generate(DataTable dt, object entity, string gridName)
        {
            Dictionary<string, object> dict;
            using (GridDataConvert dp = new GridDataConvert())
            {
                dict = dp.Process(entity, gridName);
            }
            if (dict == null || dict.Count == 0)
                return;

            DataRow newRow = dt.NewRow();

            foreach (DataColumn col in dt.Columns)
            {
                if (dict.ContainsKey(col.ColumnName))
                {
                    newRow[col.ColumnName] = (dict[col.ColumnName] != null ? dict[col.ColumnName] : System.DBNull.Value);
                }
                else
                {
                    object o = null;
                    try
                    {
                        o = EntityScript.GetPropertyValue(entity, col.ColumnName);
                    }
                    catch(Exception)    // 不一定有这个属性,例如大写金额
                    {
                    }
                    newRow[col.ColumnName] = o != null ? o : System.DBNull.Value;
                }
            }

            dt.Rows.Add(newRow);
        }
Exemplo n.º 2
0
        private static void Generate(DataTable dt, object entity, string gridName)
        {
            Dictionary <string, object> dict;

            using (GridDataConvert dp = new GridDataConvert())
            {
                dict = dp.Process(entity, gridName);
            }
            if (dict == null || dict.Count == 0)
            {
                return;
            }

            DataRow newRow = dt.NewRow();

            foreach (DataColumn col in dt.Columns)
            {
                if (dict.ContainsKey(col.ColumnName))
                {
                    newRow[col.ColumnName] = (dict[col.ColumnName] != null ? dict[col.ColumnName] : System.DBNull.Value);
                }
                else
                {
                    object o = null;
                    try
                    {
                        o = EntityScript.GetPropertyValue(entity, col.ColumnName);
                    }
                    catch (Exception)    // 不一定有这个属性,例如大写金额
                    {
                    }
                    newRow[col.ColumnName] = o != null ? o : System.DBNull.Value;
                }
            }

            dt.Rows.Add(newRow);
        }
        internal static IList<Dictionary<string, object>> InternalGetItems(string winTabName, NameValueCollection nvc)
        {
            if (!Utils.AuthHelper.CheckAuthentication())
                return null;

            ISearchManager sm = Feng.Server.Utils.ServiceHelper.GetSearchManagerFromWindowTab(winTabName);
            var smParams = Utils.WebHelper.GetSearchManagerParameters(sm, nvc);
            var se = smParams.Item1;
            var so = smParams.Item2;
            sm.FillSearchAdditionals(ref se, ref so);
            IEnumerable list = sm.GetData(se, so);

            WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(winTabName);
            bool includeDetail = false;
            if (!string.IsNullOrEmpty(nvc["detail"]))
            {
                includeDetail = Feng.Utils.ConvertHelper.ToBoolean(nvc["detail"]).Value;
            }
            using (GridDataConvert dp = new GridDataConvert(!includeDetail))
            {
                IList<Dictionary<string, object>> r = dp.Process(list, tabInfo.GridName);

                return r;
            }
        }
        private List<object> GenerateData(object entity, string gridName, List<SoaDataGridColumn> columns)
        {
            Dictionary<string, object> dict;
            using (GridDataConvert dp = new GridDataConvert())
            {
                dict = dp.Process(entity, gridName);
            }

            List<object> ret = new List<object>();

            foreach (SoaDataGridColumn col in columns)
            {
                if (dict.ContainsKey(col.Name))
                {
                    ret.Add(dict[col.Name]);
                }
                else
                {
                    object o = null;
                    try
                    {
                        o = EntityScript.GetPropertyValue(entity, col.Name);
                    }
                    catch (Exception)    // 不一定有这个属性,例如大写金额
                    {
                    }
                    ret.Add(o);
                }
            }

            return ret;
        }