コード例 #1
0
ファイル: services.cs プロジェクト: porduna/labmanager
        //ROUTE: ../plugin/widgets
        public static string getWidgets(string laboratory_id)
        {
            // This can be retrieved from a database, or by contacting the laboratory
            // in case it manages more than one laboratory. It will get all widgets of an specific lab given by the laboratory_id parameter
            if (laboratory_id != "Sample_lab_1") //Dummy example, in real life it should query a database
            {
                return "Lab Not found";
            }

            widget widget1 = new widget
            {
                name = "Camera1",
                description = "Left camera"
            };
            widget widget2 = new widget
            {
                name = "Camera2",
                description = "Right camera"
            };

            widgetList wList = new widgetList { widgets = new widget[] { widget1, widget2 } };

            var javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string jsonString = javaScriptSerializer.Serialize(wList);
            return jsonString;
        }
コード例 #2
0
ファイル: services.cs プロジェクト: rahulyhg/labmanager
        //ROUTE: ../plugin/widgets
        public static string getWidgets(string laboratory_id)
        {
            // This can be retrieved from a database, or by contacting the laboratory
            // in case it manages more than one laboratory. It will get all widgets of an specific lab given by the laboratory_id parameter
            if (laboratory_id != "Sample_lab_1") //Dummy example, in real life it should query a database
            {
                return("Lab Not found");
            }

            widget widget1 = new widget
            {
                name        = "Camera1",
                description = "Left camera"
            };
            widget widget2 = new widget
            {
                name        = "Camera2",
                description = "Right camera"
            };

            widgetList wList = new widgetList {
                widgets = new widget[] { widget1, widget2 }
            };

            var    javaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string jsonString           = javaScriptSerializer.Serialize(wList);

            return(jsonString);
        }