Ejemplo n.º 1
0
        public object FormatColumn(object val)
        {
            if (!string.IsNullOrEmpty(this.format))
            {
                if (this.type == "ref")
                {
                    if (val != null && !string.IsNullOrEmpty(val.ToString()))
                    {
                        var selectedValue = val.ToString();
                        var dict          = StructureHelper.GetRelation(format, selectedValue);
                        return(string.Join(",", dict.Values));
                    }
                }
                else if (this.type == "timestamp")
                {
                    var dt = new DateTime(1970, 1, 1).AddSeconds(Convert.ToInt32(val));
                    return(dt.ToString(this.format));
                }
                else if (this.type == "datetime" || this.type == "date")
                {
                    if (val != null && !string.IsNullOrEmpty(val.ToString()))
                    {
                        return(Convert.ToDateTime(val).ToString(this.format));
                    }
                    return(val);
                }
                else if (this.type == "enum")
                {
                    var arr = this.format.Split('^');
                    if (arr.First().IndexOf('@') > -1)
                    {
                        foreach (var item in arr)
                        {
                            var xxxx = item.Split('@');
                            if (xxxx[0] == val.ToString())
                            {
                                return(xxxx[1]);
                            }
                        }
                    }
                }
            }

            return(val);
        }