Exemplo n.º 1
0
        public static string GetValue(FieldInfo fieldInfo, LogInfo logInfo)
        {
            var value = string.Empty;

            if (logInfo.ContainsKey(fieldInfo.Title))
            {
                if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value)
                {
                    value = string.Join(",", PollUtils.JsonDeserialize <List <string> >(logInfo.Get <string>(fieldInfo.Title)));
                }
                else if (fieldInfo.FieldType == InputType.Date.Value)
                {
                    var date = logInfo.Get <DateTime?>(fieldInfo.Title);
                    if (date.HasValue)
                    {
                        value = date.Value.ToString("yyyy-MM-dd");
                    }
                }
                else if (fieldInfo.FieldType == InputType.DateTime.Value)
                {
                    var datetime = logInfo.Get <DateTime?>(fieldInfo.Title);
                    if (datetime.HasValue)
                    {
                        value = datetime.Value.ToString("yyyy-MM-dd HH:mm");
                    }
                }
                else
                {
                    value = logInfo.Get <string>(fieldInfo.Title);
                }
            }

            return(value);
        }
Exemplo n.º 2
0
        public static string GetValue(FieldInfo fieldInfo, LogInfo logInfo)
        {
            var value = string.Empty;

            if (logInfo.ContainsKey(fieldInfo.Title))
            {
                var fieldValue = logInfo.Get <string>(fieldInfo.Title);

                if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value)
                {
                    var list = FormUtils.JsonDeserialize <List <string> >(fieldValue);
                    if (list != null)
                    {
                        value = string.Join(",", list);
                    }
                }
                else if (fieldInfo.FieldType == InputType.Date.Value)
                {
                    if (!string.IsNullOrEmpty(fieldValue))
                    {
                        var date = FormUtils.ToDateTime(fieldValue, DateTime.MinValue);
                        if (date != DateTime.MinValue)
                        {
                            value = date.ToString("yyyy-MM-dd");
                        }
                    }
                }
                else if (fieldInfo.FieldType == InputType.DateTime.Value)
                {
                    if (!string.IsNullOrEmpty(fieldValue))
                    {
                        var date = FormUtils.ToDateTime(fieldValue, DateTime.MinValue);
                        if (date != DateTime.MinValue)
                        {
                            value = date.ToString("yyyy-MM-dd HH:mm");
                        }
                    }
                }
                else
                {
                    value = fieldValue;
                }
            }

            return(value);
        }