public void DataListModel_Create_PayLoadWithComplexObjectsArrayWithParentArray_ShouldHaveComplexObjectItems() { //------------Setup for test-------------------------- const string Shape = @"<DataList> <Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" > <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""None"" /> <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""None"" /> </Car> <Country Description=""name of Country"" IsEditable=""True"" ColumnIODirection=""Both"" /> <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Both"" > <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" > <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" > <a1 Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" ></a1> </a> </a> </a> </DataList>"; const string Data = "<DataList></DataList>"; var dataListModel = new DataListModel(); var converter = new DataListConversionUtils(); //------------Execute Test--------------------------- dataListModel.Create(Data, Shape); var result = converter.CreateListToBindTo(dataListModel); //------------Assert Results------------------------- Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("", dataListModel.ComplexObjects[0].Description); Assert.AreEqual("Country", result[0].DisplayValue); Assert.AreEqual("@a", result[1].DisplayValue); Assert.IsTrue(result[1].IsObject); Assert.IsFalse(result[1].CanHaveMutipleRows); }
public static DataListModel <Production_AlarmModel> GetListNew(string StartTime, string EndTime, int startIndex, int endIndex) { string jsonStr = "[]"; DataListModel <Production_AlarmModel> userList = Production_AlarmTrendDAL.GetListNew(StartTime, EndTime, startIndex, endIndex); return(userList); }
/// <summary> /// Generates the match fragments from data list. /// </summary> /// <returns></returns> private FuzzyMatchVo GenerateMatchFragmentsFromDataList() { FuzzyMatchVo result = null; if (!string.IsNullOrEmpty(DataList)) { var dataListModel = new DataListModel(); dataListModel.Create(DataList, DataList); IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>(); foreach (var rs in dataListModel.RecordSets) { // build map for each column in a recordset ;) foreach (var col in rs.Columns) { foreach (var scalar in col.Value) { if (!tmp.Keys.Any(a => a.Item2 == scalar.Name && a.Item1 == rs.Name)) { tmp[new Tuple <string, string>(rs.Name, scalar.Name)] = rs.Name; } } } } result = new FuzzyMatchVo(tmp); } return(result); }
public void DataListModel_Create_PayLoadWithComplexObjectsArray_ShouldHaveComplexObjectItems() { //------------Setup for test-------------------------- const string Data = @"<DataList> <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" > <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" /> </Food> </DataList>"; const string Shape = @"<DataList> <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" > <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" /> </Food> </DataList>"; var dataListModel = new DataListModel(); var converter = new DataListConversionUtils(); //------------Execute Test--------------------------- dataListModel.Create(Data, Shape); var result = converter.GetOutputs(dataListModel); //------------Assert Results------------------------- Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); Assert.AreEqual("", dataListModel.ComplexObjects[0].Description); Assert.AreEqual("@Food", result[0].DisplayValue); Assert.IsTrue(result[0].IsObject); Assert.IsFalse(result[0].CanHaveMutipleRows); }
public string GetListNew(HttpContext context) { string start_time = context.Request["start_time"]; string end_time = context.Request["end_time"]; int PageSize = Convert.ToInt32(context.Request["rows"]); int PageIndex = Convert.ToInt32(context.Request["page"]); StringBuilder commandText = new StringBuilder(); string where = ""; if (string.IsNullOrEmpty(start_time)) { DateTime t = DateTime.Now.AddMonths(-1); start_time = t.ToString("yyyy-MM-dd"); } string StartTime = start_time.Substring(0, 10); if (string.IsNullOrEmpty(end_time)) { DateTime t = DateTime.Now; end_time = t.ToString("yyyy-MM-dd"); } string EndTime = end_time.Substring(0, 10); int StartIndex = (PageIndex - 1) * PageSize + 1; int EndIndex = PageIndex * PageSize; DataListModel <Production_AlarmModel> userList = Production_AlarmTrendReport_BLL.GetListNew(StartTime, EndTime, StartIndex, EndIndex); string json = JSONTools.ScriptSerialize <DataListModel <Production_AlarmModel> >(userList); return(json); }
public IActionResult GridView(DataListModel args) { EntityGridModel model = new EntityGridModel(); args.CopyTo(model); return(GridView(model)); }
public static string getList(int PageSize, int StartIndex, int EndIndex, string SortFlag, string sortOrder, string wherestr) { if (string.IsNullOrEmpty(SortFlag)) { SortFlag = " st_no,step_startTime"; } if (string.IsNullOrEmpty(sortOrder)) { sortOrder = "asc"; } List <mg_sys_log> list = new List <mg_sys_log>(); int total = 0; string query_sql = " select * from(select row_number() over(order by " + SortFlag + " " + sortOrder + " ) as rowid,report.* from View_mg_sys_log report where 1 = 1 " + wherestr + ") as Results where rowid >=" + StartIndex + " and rowid <=" + EndIndex + " "; string count_sql = "select count(*) as total from View_mg_sys_log where 1 = 1 " + wherestr; DataSet ds = SqlHelper.GetDataSetTableMapping(SqlHelper.SqlConnString, System.Data.CommandType.Text, count_sql + query_sql, new string[] { "count", "data" }, null); if (DataHelper.HasData(ds)) { DataTable dt1 = ds.Tables["count"]; total = NumericParse.StringToInt(DataHelper.GetCellDataToStr(dt1.Rows[0], "total")); DataTable dt2 = ds.Tables["data"]; foreach (DataRow row in dt2.Rows) { mg_sys_log model = new mg_sys_log(); model.sys_id = DataHelper.GetCellDataToStr(row, "sys_id"); model.op_id = DataHelper.GetCellDataToStr(row, "op_id"); model.op_name = DataHelper.GetCellDataToStr(row, "op_name"); model.fl_id = DataHelper.GetCellDataToStr(row, "fl_id"); model.fl_name = DataHelper.GetCellDataToStr(row, "fl_name"); model.st_id = DataHelper.GetCellDataToStr(row, "st_id"); model.st_no = DataHelper.GetCellDataToStr(row, "st_no"); model.PartOrderID = DataHelper.GetCellDataToStr(row, "PartOrderID"); model.or_no = DataHelper.GetCellDataToStr(row, "or_no"); model.part_no = DataHelper.GetCellDataToStr(row, "part_no"); model.step_order = NumericParse.StringToInt(DataHelper.GetCellDataToStr(row, "step_order")); model.step_startTime = DataHelper.GetCellDataToStr(row, "step_startTime"); model.step_endTime = DataHelper.GetCellDataToStr(row, "step_endTime"); model.step_duringtime = DataHelper.GetCellDataToStr(row, "step_duringtime"); model.AngleResult = DataHelper.GetCellDataToStr(row, "AngleResult"); model.TorqueResult = DataHelper.GetCellDataToStr(row, "TorqueResult"); model.scanCode = DataHelper.GetCellDataToStr(row, "scanCode"); model.scanResult = DataHelper.GetCellDataToStr(row, "scanResult"); model.sys_desc = DataHelper.GetCellDataToStr(row, "sys_desc"); model.ScrewCount = DataHelper.GetCellDataToStr(row, "ScrewCount"); model.MenderName = DataHelper.GetCellDataToStr(row, "MenderName"); model.ReviseTime = DataHelper.GetCellDataToStr(row, "ReviseTime"); list.Add(model); } } DataListModel <mg_sys_log> allmodel = new DataListModel <mg_sys_log>(); allmodel.total = total.ToString(); allmodel.rows = list; string jsonStr = JSONTools.ScriptSerialize <DataListModel <mg_sys_log> >(allmodel); return(jsonStr); }
public static DataListModel <Production_Model> GetListNew(string StartTime, string EndTime, int clnameid, string clname, int PageIndex, int PageSize) { string jsonStr = "[]"; DataListModel <Production_Model> userList = Production_ModelDAL.GetListNew(StartTime, EndTime, clnameid, clname, PageIndex, PageSize); return(userList); //List<UserM_Menu> menuList = UserM_MenuDAL.GetUserMenuList(); //jsonStr = JSONTools.ScriptSerialize<DataListModel<Production_Model>>(userList); //return jsonStr; }
public static DataListModel <Production_AlarmModel> GetList(int page, int pagesize, string sidx, string sord, string Where) { string jsonStr = "[]"; DataListModel <Production_AlarmModel> userList = Production_AlarmModelDAL.GetList(page, pagesize, sidx, sord, Where); return(userList); //List<UserM_Menu> menuList = UserM_MenuDAL.GetUserMenuList(); //jsonStr = JSONTools.ScriptSerialize<DataListModel<Production_Model>>(userList); //return jsonStr; }
public string GetDataList(DataListModel param) { if (param == null) { return("Error!! null paramters"); } // get all of data. var _ds = new Select().SelectLists(param.actionName, param.names, param.values); return(LZStringUpdated.compressToUTF16(_ds.GetXml())); }
public void DataListModel_InvalidIODirection_ShouldThrow() { const string Shape = @"<DataList> <Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" > <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" /> <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" /> </Car> </DataList>"; var dataListModel = new DataListModel(); dataListModel.Create(@"<Data><Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" > <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" /> <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" /> </Car><Truck Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" > <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" /> <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" /> </Truck></Data>", Shape); Assert.AreEqual(1, dataListModel.RecordSets.Count); Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Count); Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Values.Count); var values = dataListModel.RecordSets[0].Columns.Values.First(); Assert.AreEqual(2, values.Count); Assert.AreEqual(null, values[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection); Assert.AreEqual(false, values[0].IsEditable); Assert.AreEqual("Make", values[0].Name); Assert.AreEqual("", values[0].Value); Assert.AreEqual(null, values[1].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Output, values[1].IODirection); Assert.AreEqual(false, values[1].IsEditable); Assert.AreEqual("Model", values[1].Name); Assert.AreEqual("", values[1].Value); Assert.AreEqual(1, dataListModel.ShapeRecordSets.Count); Assert.AreEqual(1, dataListModel.ShapeRecordSets[0].Columns.Count); var col = dataListModel.ShapeRecordSets[0].Columns.First(); values = col.Value; Assert.AreEqual(1, col.Key); Assert.AreEqual(2, values.Count); Assert.AreEqual("Make of vehicle", values[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection); Assert.AreEqual(true, values[0].IsEditable); Assert.AreEqual("Make", values[0].Name); Assert.AreEqual(null, values[0].Value); }
public void DataListModel_Create_PayLoadWithComplexObjectsArray_ShouldHaveComplexObjectItems() { //------------Setup for test-------------------------- const string Data = @"<DataList> <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" > <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" /> </Food> </DataList>"; const string Shape = @"<DataList> <Food Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Output"" > <FoodName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" /> </Food> </DataList>"; var dataListModel = new DataListModel(); //------------Execute Test--------------------------- dataListModel.Create(Data, Shape); Assert.AreEqual(0, dataListModel.RecordSets.Count); Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count); Assert.AreEqual(0, dataListModel.Scalars.Count); Assert.AreEqual(0, dataListModel.ShapeScalars.Count); const string expectedValue = "{\r\n \"Description\": \"\",\r\n \"IsEditable\": \"True\",\r\n \"IsJson\": \"True\",\r\n \"IsArray\": \"False\",\r\n \"ColumnIODirection\": \"Output\",\r\n \"FoodName\": {\r\n \"Description\": \"\",\r\n \"IsEditable\": \"True\",\r\n \"IsJson\": \"True\",\r\n \"IsArray\": \"False\",\r\n \"ColumnIODirection\": \"None\"\r\n }\r\n}"; Assert.AreEqual(1, dataListModel.ComplexObjects.Count); Assert.AreEqual("", dataListModel.ComplexObjects[0].Description); Assert.AreEqual("@Food", dataListModel.ComplexObjects[0].Name); Assert.AreEqual(expectedValue, dataListModel.ComplexObjects[0].Value); Assert.AreEqual(enDev2ColumnArgumentDirection.Output, dataListModel.ComplexObjects[0].IODirection); Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray); Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable); Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent); Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count); Assert.AreEqual(1, dataListModel.ShapeComplexObjects.Count); Assert.AreEqual("", dataListModel.ShapeComplexObjects[0].Description); Assert.AreEqual("@Food", dataListModel.ShapeComplexObjects[0].Name); Assert.AreEqual(expectedValue, dataListModel.ShapeComplexObjects[0].Value); Assert.AreEqual(enDev2ColumnArgumentDirection.Output, dataListModel.ShapeComplexObjects[0].IODirection); Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsArray); Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsEditable); Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Parent); Assert.AreEqual(0, dataListModel.ShapeComplexObjects[0].Children.Count); }
public IActionResult List(DataListModel model) { if (!model.EntityId.HasValue || model.EntityId.Equals(Guid.Empty)) { if (!model.QueryViewId.HasValue || model.QueryViewId.Equals(Guid.Empty)) { if (model.EntityName.IsEmpty()) { return(NotFound()); } } } return(View($"~/Views/Entity/{WebContext.ActionName}.cshtml", model)); }
public void DataListModel_DataXmlWithNoShape_Success() { var dataListModel = new DataListModel(); dataListModel.Create(@"" + @"<Country Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />" + @"<Food Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />" , "<datalist></datalist>"); Assert.AreEqual(0, dataListModel.Scalars.Count); Assert.AreEqual(0, dataListModel.ShapeScalars.Count); Assert.AreEqual(0, dataListModel.ComplexObjects.Count); Assert.AreEqual(0, dataListModel.ShapeComplexObjects.Count); Assert.AreEqual(0, dataListModel.RecordSets.Count); Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count); }
public string GetList(HttpContext context) { string start_time = context.Request["start_time"]; string end_time = context.Request["end_time"]; int PageSize = Convert.ToInt32(context.Request["rows"]); int PageIndex = Convert.ToInt32(context.Request["page"]); StringBuilder commandText = new StringBuilder(); string where = ""; if (string.IsNullOrEmpty(start_time)) { DateTime t = DateTime.Now.AddMonths(-1); start_time = t.ToString("yyyy-MM-dd hh:mm:ss"); } string StartTime = start_time.Substring(0, 10) + " 00:00:00"; if (string.IsNullOrEmpty(end_time)) { DateTime t = DateTime.Now; end_time = t.ToString("yyyy-MM-dd hh:mm:ss"); } string EndTime = end_time.Substring(0, 10) + " 23:59:59"; where += " and [AlarmStartTime]>='" + StartTime + "'"; where += " and [AlarmEndTime]<='" + EndTime + "'"; string sidx = RequstString("sidx"); //排序名称 string sort = RequstString("sord"); //排序方式 if ("-1" == sort) { sort = "id"; } if ("-1" == order) { order = "asc"; } DataListModel <Production_AlarmModel> userList = Production_AlarmTrendReport_BLL.GetList(PageIndex, PageSize, sort, order, where); string json = JSONTools.ScriptSerialize <DataListModel <Production_AlarmModel> >(userList); return(json); }
public void DataListModel_Create_PayLoadWithComplexObjectValue_ShouldMatchExpectedValue() { //------------Setup for test-------------------------- const string Data = @"<DataList> <RequestPayload> <EmailAddress>[email protected]</EmailAddress> <FirstName>Sune</FirstName> <DisplayNumber>TU00000</DisplayNumber> <MobilePhone>27832640</MobilePhone> </RequestPayload> </DataList>"; const string Shape = @" <DataList> <RequestPayload Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Input""> <EmailAddress Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></EmailAddress> <FirstName Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></FirstName> <DisplayNumber Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></DisplayNumber> <MobilePhone Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None""></MobilePhone> </RequestPayload> </DataList>"; var dataListModel = new DataListModel(); //------------Execute Test--------------------------- dataListModel.Create(Data, Shape); Assert.AreEqual(0, dataListModel.RecordSets.Count); Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count); Assert.AreEqual(0, dataListModel.Scalars.Count); Assert.AreEqual(0, dataListModel.ShapeScalars.Count); const string expectedValue = "{\r\n \"EmailAddress\": \"[email protected]\",\r\n \"FirstName\": \"Sune\",\r\n \"DisplayNumber\": \"TU00000\",\r\n \"MobilePhone\": \"27832640\"\r\n}"; Assert.AreEqual(1, dataListModel.ComplexObjects.Count); Assert.AreEqual("", dataListModel.ComplexObjects[0].Description); Assert.AreEqual("@RequestPayload", dataListModel.ComplexObjects[0].Name); Assert.AreEqual(expectedValue, dataListModel.ComplexObjects[0].Value); Assert.AreEqual(enDev2ColumnArgumentDirection.Input, dataListModel.ComplexObjects[0].IODirection); Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray); Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable); Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent); Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count); }
public void DataListConversionUtilTest_CreateListToBindTo_WhenScalarHasNoneMapping_ExpectCollectionWithNoItems() { //------------Setup for test-------------------------- var converter = new DataListConversionUtils(); const string Data = "<DataList></DataList>"; const string Shape = @"<DataList><scalar Description="""" IsEditable=""True"" ColumnIODirection=""None"" ></scalar></DataList>"; //------------Execute Test--------------------------- var bdl = new DataListModel(); bdl.Create(Data, Shape); var result = converter.CreateListToBindTo(bdl); //------------Assert Results------------------------- Assert.AreEqual(0, result.Count); }
// ReSharper disable InconsistentNaming public void DataListConversionUtilTest_CreateListToBindTo_WhenScalarHasInputMapping_ExpectCollectionWithOneItem() // ReSharper restore InconsistentNaming { //------------Setup for test-------------------------- var converter = new DataListConversionUtils(); const string Data = "<DataList></DataList>"; const string Shape = @"<DataList><scalar Description="""" IsEditable=""True"" ColumnIODirection=""Input"" ></scalar></DataList>"; //------------Execute Test--------------------------- var bdl = new DataListModel(); bdl.Create(Data, Shape); var result = converter.CreateListToBindTo(bdl); //------------Assert Results------------------------- Assert.AreEqual(1, result.Count); Assert.AreEqual("scalar", result[0].Field); }
FuzzyMatchVo GenerateMatchFragmentsFromDataList() { FuzzyMatchVo result = null; if (!string.IsNullOrEmpty(DataList)) { var dataListModel = new DataListModel(); dataListModel.Create(DataList, DataList); IDictionary <Tuple <string, string>, string> tmp = new Dictionary <Tuple <string, string>, string>(); foreach (var rs in dataListModel.RecordSets) { MapRecordsetColumn(tmp, rs); } result = new FuzzyMatchVo(tmp); } return(result); }
public void DataListModel_Create_PayLoadWithComplexObjects_ShouldHaveComplexObjectItems() { //------------Setup for test-------------------------- const string Data = "<DataList></DataList>"; var dataListModel = new DataListModel(); var converter = new DataListConversionUtils(); //------------Execute Test--------------------------- dataListModel.Create(Data, Shape); var result = converter.CreateListToBindTo(dataListModel); //------------Assert Results------------------------- Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); Assert.AreEqual("", dataListModel.ComplexObjects[0].Description); Assert.AreEqual("Country", result[0].DisplayValue); Assert.AreEqual("@Person", result[1].DisplayValue); Assert.IsTrue(result[1].IsObject); }
public void DataListConversionUtilTest_CreateListToBindTo_WhenColumnHasInputMapping_ExpectCollectionWithOneItem() { //------------Setup for test-------------------------- var converter = new DataListConversionUtils(); const string Data = "<DataList></DataList>"; const string Shape = @"<DataList><rec Description="""" IsEditable=""True"" ColumnIODirection=""None"" ><a Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /><b Description="""" IsEditable=""True"" ColumnIODirection=""None"" /></rec></DataList>"; //------------Execute Test--------------------------- var bdl = new DataListModel(); bdl.Create(Data, Shape); var result = converter.CreateListToBindTo(bdl); //------------Assert Results------------------------- Assert.AreEqual(1, result.Count); Assert.AreEqual("rec", result[0].Recordset); Assert.AreEqual("a", result[0].Field); }
public void DataListModel_DataXmlWithNoRoot_Success() { var dataListModel = new DataListModel(); dataListModel.Create(@"" + @"<Country Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />" + @"<Food Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""None"" />" , "<datalist><Country /><Food /></datalist>"); Assert.AreEqual(2, dataListModel.Scalars.Count); Assert.AreEqual("", dataListModel.Scalars[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[0].IODirection); Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable); Assert.AreEqual("Country", dataListModel.Scalars[0].Name); Assert.AreEqual("", dataListModel.Scalars[0].Value); Assert.AreEqual("", dataListModel.Scalars[1].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[1].IODirection); Assert.AreEqual(true, dataListModel.Scalars[1].IsEditable); Assert.AreEqual("Food", dataListModel.Scalars[1].Name); Assert.AreEqual("", dataListModel.Scalars[1].Value); Assert.AreEqual(2, dataListModel.ShapeScalars.Count); Assert.AreEqual("", dataListModel.Scalars[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[0].IODirection); Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable); Assert.AreEqual("Country", dataListModel.Scalars[0].Name); Assert.AreEqual("", dataListModel.Scalars[0].Value); Assert.AreEqual("", dataListModel.Scalars[1].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[1].IODirection); Assert.AreEqual(true, dataListModel.Scalars[1].IsEditable); Assert.AreEqual("Food", dataListModel.Scalars[1].Name); Assert.AreEqual("", dataListModel.Scalars[1].Value); Assert.AreEqual(0, dataListModel.ComplexObjects.Count); Assert.AreEqual(0, dataListModel.ShapeComplexObjects.Count); Assert.AreEqual(0, dataListModel.RecordSets.Count); Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count); }
public string GetList(HttpContext context) { string StartTime = context.Request["start_time"]; string EndTime = context.Request["end_time"]; string clnameid = context.Request["clnameid"]; int PageSize = Convert.ToInt32(context.Request["rows"]); int PageIndex = Convert.ToInt32(context.Request["page"]); StringBuilder commandText = new StringBuilder(); string where = ""; if (!string.IsNullOrWhiteSpace(clnameid)) { where += " and cl_name like'%" + clnameid + "%' "; if (!string.IsNullOrWhiteSpace(StartTime)) { StartTime = StartTime.Substring(0, 10); where += " and product_date>='" + StartTime + "'"; string endtime = Convert.ToDateTime(StartTime).AddDays(1).ToString(); where += " and product_date<='" + endtime.Substring(0, 10) + "'"; } } else { if (!string.IsNullOrWhiteSpace(StartTime)) { where += " and product_date>='" + StartTime + "'"; } if (!string.IsNullOrWhiteSpace(EndTime)) { where += " and product_date<='" + EndTime + "'"; } } string sort = RequstString("sidx"); //排序名称 string order = RequstString("sord"); //排序方式 DataListModel <Production_Model> userList = Production_Report_BLL.GetList(PageIndex, PageSize, sort, order, where); string json = JSONTools.ScriptSerialize <DataListModel <Production_Model> >(userList); return(json); }
public IServiceTestModel CreateTest(IResourceModel resourceModel, int testNumber, bool isFromDebug) { var testModel = new ServiceTestModel(resourceModel.ID) { TestName = "Test " + (testNumber == 0 ? 1 : testNumber), TestPending = true, Enabled = true, NewTest = true, NoErrorExpected = true, ErrorExpected = false, ErrorContainsText = string.Empty, Inputs = new ObservableCollection <IServiceTestInput>(), Outputs = new ObservableCollection <IServiceTestOutput>(), }; if (!string.IsNullOrEmpty(resourceModel.DataList)) { DataList = new DataListModel(); DataList.Create(resourceModel.DataList, resourceModel.DataList); var inputList = _dataListConversionUtils.GetInputs(DataList); var outputList = _dataListConversionUtils.GetOutputs(DataList); testModel.Inputs = inputList.Select(sca => { var serviceTestInput = new ServiceTestInput(sca.DisplayValue, ""); serviceTestInput.AddNewAction = () => testModel.AddRow(serviceTestInput, DataList); return((IServiceTestInput)serviceTestInput); }).ToObservableCollection(); if (!isFromDebug) { testModel.Outputs = outputList.Select(sca => { var serviceTestOutput = new ServiceTestOutput(sca.DisplayValue, "", "", ""); serviceTestOutput.AddNewAction = () => testModel.AddRow(serviceTestOutput, DataList); return((IServiceTestOutput)serviceTestOutput); }).ToObservableCollection(); } } testModel.Item = (ServiceTestModel)testModel.Clone(); return(testModel); }
public string GetListNew(HttpContext context) { string StartTime = context.Request["start_time"]; string EndTime = context.Request["end_time"]; if (string.IsNullOrEmpty(StartTime)) { DateTime t = DateTime.Now; StartTime = t.AddDays(-1).ToString("yyyy-MM-dd hh:mm:ss"); } if (string.IsNullOrEmpty(EndTime)) { DateTime t = DateTime.Now; EndTime = t.ToString("yyyy-MM-dd hh:mm:ss"); } string clid = context.Request["clnameid"]; int clnameid = 0; if (string.IsNullOrEmpty(clid)) { clnameid = 0; } else { clnameid = Convert.ToInt32(clid); } string clname = context.Request["clname"]; int PageSize = Convert.ToInt32(context.Request["rows"]); int PageIndex = Convert.ToInt32(context.Request["page"]); string sort = RequstString("sidx"); //排序名称 string order = RequstString("sord"); //排序方式 DataListModel <Production_Model> userList = Production_Report_BLL.GetListNew(StartTime, EndTime, clnameid, clname, PageIndex, PageSize); string json = JSONTools.ScriptSerialize <DataListModel <Production_Model> >(userList); return(json); }
public void DataListModel_DataXmlWithSystemTag_GivenOutputIODirection_NotAdded() { var dataListModel = new DataListModel(); dataListModel.Create(@"" + @"<WebServerUrl Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""Output"" />" + @"<Food Description="""" IsEditable=""True"" IsJson=""False"" IsArray=""False"" ColumnIODirection=""Output"" />" , "<datalist><WebServerUrl /><Food /></datalist>"); Assert.AreEqual(1, dataListModel.Scalars.Count); Assert.AreEqual(1, dataListModel.ShapeScalars.Count); Assert.AreEqual(0, dataListModel.ComplexObjects.Count); Assert.AreEqual(0, dataListModel.ShapeComplexObjects.Count); Assert.AreEqual(0, dataListModel.RecordSets.Count); Assert.AreEqual(0, dataListModel.ShapeRecordSets.Count); Assert.AreEqual("", dataListModel.Scalars[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.None, dataListModel.Scalars[0].IODirection); Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable); Assert.AreEqual("Food", dataListModel.Scalars[0].Name); Assert.AreEqual("", dataListModel.Scalars[0].Value); }
public void DataListModel_InvalidXml_ShouldThrow() { var dataListModel = new DataListModel(); dataListModel.Create("<b", Shape); }
public DataListModel GetList(View view, string userId) { RepositoryCompanies repositoryCompanies = new RepositoryCompanies(); List<Field> columns = new List<Field>(); Form form = view.Group.Forms.Single(m => m.FormId == view.Group.DefaultFormId); string select = ""; bool fId = false; bool fUserId = false; bool fUniqueId = false; bool fDato = false; foreach (Field field in form.Fields.Where(a => a.FieldColumn != null && !a.FieldColumn.Equals(String.Empty)).OrderBy(b => b.FieldOrder)) { Permission permission = view.Permissions.FirstOrDefault(a => a.FieldId == field.FieldId); if (permission == null || permission.PermissionTypeId != 0) { columns.Add(field); switch (field.FieldColumn.ToUpper()) { case "ID": select = select + "," + field.FieldColumn; fId = true; break; case "UNIQUEID": select = select + "," + field.FieldColumn; fUniqueId = true; break; case "USERID": select = select + "," + field.FieldColumn; fUserId = true; break; case "DATO": select = select + "," + field.FieldColumn; fDato = true; break; default: if (field.FieldTypeId == 16) { select = select + "," + field.FieldColumn + ".STAsText() AS " + field.FieldColumn; } else { select = select + "," + field.FieldColumn; } break; } } } if (!fUniqueId) select = select + ",UniqueId"; if (!fUserId) select = select + ",UserId"; if (!fDato) select = select + ",Dato"; if (!fId) select = select + ",Id"; select = "SELECT " + select.Substring(1); DataListModel model = new DataListModel { View = view, Form = form, Columns = columns }; DataTable dt = new DataTable(); using (SqlConnection connection = new SqlConnection(form.ResourceName)) { SqlCommand command = connection.CreateCommand(); command.CommandText = select+" FROM " + form.ClassName; if (!String.IsNullOrEmpty(userId)) { command.CommandText = command.CommandText + " WHERE UserId = '" + userId + "'"; } command.CommandText += " order by dato desc"; SqlDataAdapter adapter = new SqlDataAdapter(command); adapter.Fill(dt); } Dictionary<string, UserInfo> users = new Dictionary<string, UserInfo>(); foreach (DataRow row in dt.Rows) { DataListItemModel listItem = new DataListItemModel(); for (int i = 0; i < dt.Columns.Count; i++) { if (!row.IsNull(i)) { string propertyName = dt.Columns[i].ColumnName; string propertyNameUpper = propertyName.ToUpper(); switch (propertyNameUpper) { case "ID": listItem.ItemId = (int)row[i]; if(fId) listItem.Data.Add(propertyName, row[i].ToString()); break; case "UNIQUEID": listItem.UniqueId = (string)row[i]; if (fUniqueId) listItem.Data.Add(propertyName, row[i].ToString()); break; case "USERID": if (row[i] != DBNull.Value && row[i].ToString() != "") { listItem.UserId = (string)row[i]; if (fUserId) listItem.Data.Add(propertyName, row[i].ToString()); UserInfo user = null; if (users.ContainsKey(listItem.UserId)) user = users[listItem.UserId]; else { MembershipUser user1 = Membership.GetUser(new Guid(listItem.UserId)); if (user1 != null) { user = new UserInfo(); user.UserName = user1.UserName; UserProfile profile = UserProfile.GetUserProfile(user1.UserName); if (profile != null) { Company company = repositoryCompanies.Get(profile.CompanyId); if (company != null) { user.CompanyName = company.Name; } } } users.Add(listItem.UserId, user); } if (user != null) { listItem.UserName = user.UserName; listItem.Company = user.CompanyName; } } break; case "DATO": listItem.Date = (DateTime)row[i]; if (fDato) listItem.Data.Add(propertyName, row[i].ToString()); break; default: listItem.Data.Add(propertyName, row[i].ToString()); break; } } } model.ListItemModels.Add(listItem); } return model; }
public DataListModel GetList(Models.View view, List<DataSelectionModel> dataSelections) { Form form = view.Group.Forms.Single(m => m.FormId == view.Group.DefaultFormId); List<Field> columns = new List<Field>(); foreach (Field field in form.Fields.Where(m => m.FieldColumn != null && !m.FieldColumn.Equals(String.Empty)).OrderBy(a => a.FieldOrder)) { Permission permission = view.Permissions.FirstOrDefault(m => m.FieldId == field.FieldId); if (permission == null) { columns.Add(field); } else { if (permission.PermissionTypeId != 0) { columns.Add(field); } } } DataListModel model = new DataListModel { View = view, Form = form, Columns = columns }; RepositoryCompanies repositoryCompanies = new RepositoryCompanies(); DataSelectionModel layer = null; foreach (DataSelectionModel selection in dataSelections) { if (selection.name == form.Name) { layer = selection; break; } } if (layer != null) { foreach (List<string> row in layer.aElements) { DataListItemModel listItem = new DataListItemModel(); for (int i = 0; i < layer.nProperties; i++) { if (!String.IsNullOrEmpty(row[i])) { string upperPropertyName = layer.aPropertiesName[i].ToUpper(); switch (upperPropertyName) { case "ID": int id = 0; int.TryParse(row[i], out id); listItem.ItemId = id; break; case "UNIQUEID": listItem.UniqueId = row[i]; break; case "USERID": listItem.UserId = row[i]; MembershipUser user = Membership.GetUser(new Guid(listItem.UserId)); if (user != null) { listItem.UserName = user.UserName; UserProfile profile = UserProfile.GetUserProfile(user.UserName); Company company = repositoryCompanies.Get(profile.CompanyId); if (company != null) listItem.Company = company.Name; } break; case "DATO": DateTime dt = DateTime.Now; DateTime.TryParse(row[i], culture, DateTimeStyles.AssumeLocal, out dt); listItem.Date = dt; break; default: foreach (Field field in model.Columns) { if (layer.aPropertiesName[i].ToUpper() == field.FieldColumn.ToUpper()) { if (field.FieldTypeId == 10) { DateTime dt1 = DateTime.Now; DateTime.TryParse(row[i], culture, DateTimeStyles.AssumeLocal, out dt1); listItem.Data.Add(field.FieldColumn, dt1.ToString("d", culture)); } else { listItem.Data.Add(field.FieldColumn, row[i]); } break; } } break; } } } model.ListItemModels.Add(listItem); } } return model; }
public ServiceTestCommandHandlerModel() { DataList = new DataListModel(); _dataListConversionUtils = new DataListConversionUtils(); }
public void DataListModel_Create_PayLoadWithComplexObjectsArrayWithParentArray_ShouldHaveComplexObjectItems() { const string Shape = @"<DataList> <Car Description=""A recordset of information about a car"" IsEditable=""True"" ColumnIODirection=""Both"" > <Make Description=""Make of vehicle"" IsEditable=""True"" ColumnIODirection=""Input"" /> <Model Description=""Model of vehicle"" IsEditable=""True"" ColumnIODirection=""Output"" /> </Car> <Country Description=""name of Country"" IsEditable=""True"" ColumnIODirection=""Both"" /> <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""Both"" > <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" > <a Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""True"" ColumnIODirection=""None"" > <a1 Description="""" IsEditable=""True"" IsJson=""True"" IsArray=""False"" ColumnIODirection=""None"" ></a1> </a> </a> </a> </DataList>"; const string Data = "<DataList></DataList>"; var dataListModel = new DataListModel(); // test dataListModel.Create(Data, Shape); // verify Assert.AreEqual(1, dataListModel.RecordSets.Count); Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Count); Assert.AreEqual(1, dataListModel.RecordSets[0].Columns.Values.Count); var values = dataListModel.RecordSets[0].Columns.Values.First(); Assert.AreEqual(2, values.Count); Assert.AreEqual("Make of vehicle", values[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection); Assert.AreEqual(true, values[0].IsEditable); Assert.AreEqual("Make", values[0].Name); Assert.AreEqual(null, values[0].Value); Assert.AreEqual("Model of vehicle", values[1].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Output, values[1].IODirection); Assert.AreEqual(true, values[1].IsEditable); Assert.AreEqual("Model", values[1].Name); Assert.AreEqual(null, values[1].Value); Assert.AreEqual(1, dataListModel.ComplexObjects.Count); Assert.AreEqual("", dataListModel.ComplexObjects[0].Description); Assert.AreEqual("@a", dataListModel.ComplexObjects[0].Name); Assert.AreEqual(null, dataListModel.ComplexObjects[0].Value); Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ComplexObjects[0].IODirection); Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsArray); Assert.AreEqual(false, dataListModel.ComplexObjects[0].IsEditable); Assert.AreEqual(null, dataListModel.ComplexObjects[0].Parent); Assert.AreEqual(0, dataListModel.ComplexObjects[0].Children.Count); Assert.AreEqual(1, dataListModel.Scalars.Count); Assert.AreEqual("name of Country", dataListModel.Scalars[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.Scalars[0].IODirection); Assert.AreEqual(true, dataListModel.Scalars[0].IsEditable); Assert.AreEqual("Country", dataListModel.Scalars[0].Name); Assert.AreEqual(null, dataListModel.Scalars[0].Value); Assert.AreEqual(1, dataListModel.ShapeComplexObjects.Count); Assert.AreEqual(0, dataListModel.ShapeComplexObjects[0].Children.Count); Assert.AreEqual("", dataListModel.ShapeComplexObjects[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ShapeComplexObjects[0].IODirection); Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsArray); Assert.AreEqual(false, dataListModel.ShapeComplexObjects[0].IsEditable); Assert.AreEqual("@a", dataListModel.ShapeComplexObjects[0].Name); Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Parent); Assert.AreEqual(null, dataListModel.ShapeComplexObjects[0].Value); Assert.AreEqual(1, dataListModel.ShapeRecordSets.Count); Assert.AreEqual(1, dataListModel.ShapeRecordSets[0].Columns.Count); var col = dataListModel.ShapeRecordSets[0].Columns.First(); values = col.Value; Assert.AreEqual(1, col.Key); Assert.AreEqual(2, values.Count); Assert.AreEqual("Make of vehicle", values[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Input, values[0].IODirection); Assert.AreEqual(true, values[0].IsEditable); Assert.AreEqual("Make", values[0].Name); Assert.AreEqual(null, values[0].Value); Assert.AreEqual("Model of vehicle", values[1].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Output, values[1].IODirection); Assert.AreEqual(true, values[1].IsEditable); Assert.AreEqual("Model", values[1].Name); Assert.AreEqual(null, values[1].Value); Assert.AreEqual(1, dataListModel.ShapeScalars.Count); Assert.AreEqual("name of Country", dataListModel.ShapeScalars[0].Description); Assert.AreEqual(enDev2ColumnArgumentDirection.Both, dataListModel.ShapeScalars[0].IODirection); Assert.AreEqual(true, dataListModel.ShapeScalars[0].IsEditable); Assert.AreEqual("Country", dataListModel.ShapeScalars[0].Name); Assert.AreEqual(null, dataListModel.ShapeScalars[0].Value); }
public async Task <string> SerializeObjects(DataListModel obj) { var json = JsonConvert.SerializeObject(obj); return(await Task.FromResult(json)); }