Пример #1
0
        public HttpStatusCode GetListOfBorders(out BorderDefinitionList rec)
        {
            // To allow legacy code to work with the new SVG Configuration now used by MOVE, we'll map
            // the SVG structures into the legacy structures.
            // todo: CONTROL needs to upgrade to using the new SVG calls and data structures.

            AreaDefinitionList ignored;
            LineDefinitionList linesList;

            rec = new BorderDefinitionList();
            var responseCode = GetSVGLayoutInfo(out ignored, out linesList);

            // Map SVG structure "LineDefinitionList" into legacy "BorderDefinitionList"
            foreach (var line in linesList.LineDefinitions)
            {
                var border = new BorderDefinition();
                border.Active     = line.Active;
                border.Id         = line.Id;
                border.Initial.X  = line.Initial.X;
                border.Initial.Y  = line.Initial.Y;
                border.LeftName   = line.LeftName;
                border.RightName  = line.RightName;
                border.Name       = line.Name;
                border.Terminal.X = line.Terminal.X;
                border.Terminal.Y = line.Terminal.Y;
                rec.BorderDefinitions.Add(border);
            }

            return(responseCode);
        }
Пример #2
0
        public static BorderDefinitionList JsonToBorderList(string txt)
        {
            try
            {
                var retval      = new BorderDefinitionList();
                var jBorderList = JArray.Parse(txt);

                // Parse out BORDER Definitions
                foreach (var jRec in jBorderList)
                {
                    var rec = new BorderDefinition();
                    rec.Active   = StringToBool((string)jRec["active"]);
                    rec.Id       = (int)jRec["id"];
                    rec.Initial  = JsonToCordinate(jRec["initial"]);
                    rec.LeftName = (string)jRec["left_name"];
                    rec.Name     = (string)jRec["right_name"];
                    rec.Terminal = JsonToCordinate(jRec["terminal"]);
                    retval.BorderDefinitions.Add(rec);
                }

                return(retval);
            }
            catch (Exception ex)
            {
                var newEx = new Exception("Invalid JSON data format returned for 'State'.", ex);
                throw newEx;
            }
        }
Пример #3
0
        public HttpStatusCode GetListOfBordersDeprecated(out BorderDefinitionList rec)
        {
            ValidateIsBound();

            var    client       = new MoveRestClient(_device, _port, _username, _password);
            string body         = null;
            var    responseCode = client.GetListOfBorders(out body);
            string msg          = (body.Length > _DATA_PREVIEW_SIZE) ? body.Substring(0, _DATA_PREVIEW_SIZE) : body;

            Trace.TraceInformation("\nRaw JSON data:  {0}", msg);

            rec = JsonHelper.JsonToBorderList(body);
            return(responseCode);
        }