You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/CommMng/Models/SortsModel.cs

103 lines
2.9 KiB
C#

3 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HcUtility.Core;
using Newtonsoft.Json;
using DSWeb.MvcShipping.Helper;
namespace DSWeb.Areas.CommMng.Models
{
/// <summary>
///
/// </summary>
///
[JsonObject]
public class DatasetSort : ModelObjectBillHead
{
private string _property = String.Empty;
private string _direction = String.Empty;
[ModelDB]
public string property
{
get { return _property; }
set { _property = value; }
}
[ModelDB]
public string direction
{
get { return _direction; }
set { _direction = value; }
}
public static string Getsortstring(string jsonsort)
{
var result = "";
if (!string.IsNullOrEmpty(jsonsort))
{
try
{
var bodyList = DSWeb.MvcShipping.Helper.JsonConvert.Deserialize<List<DatasetSort>>(jsonsort);
if (bodyList != null)
{
foreach (var enumValue in bodyList)
{
if (result == "")
result = result + enumValue.property + " " + enumValue.direction;
else
result = result + "," + enumValue.property + " " + enumValue.direction;
}
}
}
catch
{
result = jsonsort;
}
return result;
//string tempSearch = jsonsort;
//var sorts = new DatasetSort();
//tempSearch = tempSearch.Replace("{", "");
//tempSearch = tempSearch.Replace("}", "");
//tempSearch = tempSearch.Replace("[", "");
//tempSearch = tempSearch.Replace("]", "");
//string[] searchArg = tempSearch.Split(new char[] { ',' });
//for (int i = 0; i < searchArg.Length; i++)
//{
// string[] strArg = searchArg[i].Split(new char[] { ':' });
// if (strArg.Count() > 1)
// {
// if (!strArg[1].Replace("\"", "").Trim().Equals(""))
// {
// if (i == 0)
// {
// sorts.prop = strArg[1].Replace("\"", "");
// }
// else
// {
// sorts.dire = strArg[1].Replace("\"", "");
// }
// }
// }
//}
//return sorts.prop + " " + sorts.dire;
}
else
{
return "";
}
}
}
}