//gets/reads all task/work orders, used for tables
        //GET: /TSTaskWorkOrder/GetTaskWO
        public ActionResult GetTaskWO()
        {
            //stores the first table
            TaskWO = itsApp.GetTaskWO().Tables[0].DefaultView;

            List <Dictionary <string, object> > parentRow = new List <Dictionary <string, object> >();
            Dictionary <string, object>         childRow;

            foreach (DataRow row in TaskWO.Table.Rows)
            {
                childRow = new Dictionary <string, object>();
                foreach (DataColumn col in TaskWO.Table.Columns)
                {
                    childRow.Add(col.ColumnName, row[col]);
                }
                parentRow.Add(childRow);
            }


            //takes the List, and filters through to data using LINQ to SQL format,
            //gets only the rows of data that have Activity labeled as "true"
            var taskTableFilteredByActiveTrue = from x in parentRow
                                                where x.Keys.Contains("Active") &&
                                                x.Values.Contains(true)
                                                select x;


            //serializes/converts the DataView to JSON
            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            //serialized the data into javascript
            string JsSerializer = JsonConvert.SerializeObject(taskTableFilteredByActiveTrue);

            //this sets the Json data allowance to it's max value. Otherwise, Json will limit the Equipment data from displaying
            JsonResult json = Json(JsSerializer, JsonRequestBehavior.AllowGet);

            json.MaxJsonLength = int.MaxValue;
            return(json);
        }
コード例 #2
0
        //gets/reads all task WO id numbers, used for dropdown list
        public ActionResult GetTaskWONumbers()
        {
            //stores the first table
            TaskOrIdNumbers = itsApp.GetTaskWO().Tables[0].DefaultView;
            //serializes/converts the DataView to JSON
            JavaScriptSerializer jsSerializer             = new JavaScriptSerializer();
            List <Dictionary <string, object> > parentRow = new List <Dictionary <string, object> >();
            Dictionary <string, object>         childRow;

            foreach (DataRow row in TaskOrIdNumbers.Table.Rows)
            {
                childRow = new Dictionary <string, object>();
                foreach (DataColumn col in TaskOrIdNumbers.Table.Columns)
                {
                    childRow.Add(col.ColumnName, row[col]);
                }
                parentRow.Add(childRow);
            }
            //serialized the data into javascript
            string JsSerializer = JsonConvert.SerializeObject(parentRow);

            //returns the data as JSON, which can now be used with AngularJS
            return(Json(JsSerializer, JsonRequestBehavior.AllowGet));
        }