示例#1
0
        // << autocomplete-remote-on-post-execute-xamarin
        // << autocomplete-remote-full-xamarin

        private List <TokenModel> GetTokenModelObjects(JSONArray data)
        {
            List <TokenModel> feedData = new List <TokenModel>();
            JSONObject        current  = new JSONObject();

            for (int i = 0; i < data.Length(); i++)
            {
                string airport = "";

                try
                {
                    current = data.GetJSONObject(i);
                    string fullname = (string)current.Get("FIELD2");
                    string abr      = (string)current.Get("FIELD5");
                    airport = fullname + "," + abr;
                }
                catch (JSONException ex)
                {
                    ex.PrintStackTrace();
                }

                TokenModel token = new TokenModel(airport, null);
                feedData.Add(token);
            }

            return(feedData);
        }
示例#2
0
        public virtual void TestSingleApp()
        {
            ApplicationId  appId    = ApplicationId.NewInstance(0, 1);
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("applicationhistory").Path
                                          ("apps").Path(appId.ToString()).QueryParam("user.name", Users[round]).Accept(MediaType
                                                                                                                       .ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject app = json.GetJSONObject("app");

            NUnit.Framework.Assert.AreEqual(appId.ToString(), app.GetString("appId"));
            NUnit.Framework.Assert.AreEqual("test app", app.Get("name"));
            NUnit.Framework.Assert.AreEqual(round == 0 ? "test diagnostics info" : string.Empty
                                            , app.Get("diagnosticsInfo"));
            NUnit.Framework.Assert.AreEqual("test queue", app.Get("queue"));
            NUnit.Framework.Assert.AreEqual("user1", app.Get("user"));
            NUnit.Framework.Assert.AreEqual("test app type", app.Get("type"));
            NUnit.Framework.Assert.AreEqual(FinalApplicationStatus.Undefined.ToString(), app.
                                            Get("finalAppStatus"));
            NUnit.Framework.Assert.AreEqual(YarnApplicationState.Finished.ToString(), app.Get
                                                ("appState"));
        }
            private void HandleNotificationOpened(JSONObject data)
            {
                string methodName = string.Empty;
                string uidSeekios = string.Empty;

                if (!data.IsNull("uidSeekios"))
                {
                    uidSeekios = data.Get("uidSeekios").ToString();
                }

                if (!data.IsNull("methodName"))
                {
                    methodName = data.Get("methodName").ToString();
                }

                if (methodName == "RefreshCredits")
                {
                    //go to credits
                }
                else
                {
                    var seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios);
                    if (seekios != null)
                    {
                        App.Locator.DetailSeekios.SeekiosSelected = seekios;
                        App.Locator.DetailSeekios.GoToMap(seekios);
                    }
                }
            }
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler = new Handler();
            LinearLayout layout = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            maps         = new SfMaps(context);
            currentToast = new Toast(context);
            ShapeFileLayer layer = new ShapeFileLayer();

            layer.Uri            = "usa_state.shp";
            layer.ShapeSelected += (object sender, ShapeFileLayer.ShapeSelectedEventArgs e) => {
                JSONObject data = (JSONObject)e.P0;
                if (data != null)
                {
                    if (currentToast != null)
                    {
                        currentToast.Cancel();
                    }
                    currentToast = Toast.MakeText(context, data.Get("Name") + "\n" + data.Get("Type"), ToastLength.Short);
                    currentToast.Show();
                }
            };
            layer.EnableSelection   = true;
            layer.ShapeIdTableField = "STATE_NAME";
            layer.ShapeIdPath       = "Name";
            layer.DataSource        = GetDataSource();
            layer.LegendSetting     = new LegendSetting()
            {
                ShowLegend = true
            };
            layer.ShapeSettings.ShapeStrokeThickess = 2;
            SetColorMapping(layer.ShapeSettings);
            layer.ShapeSettings.ShapeColorValuePath = "Type";
            maps.Layers.Add(layer);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");
            //sfBusyIndicator.SetBackgroundColor(Color.ParseColor("#779772"));

            layout.AddView(sfBusyIndicator);
            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(maps);
            });
            handler.PostDelayed(run, 100);

            return(layout);
        }
 /**
  * create property and parse json
  * @param jsonObject : json to parse
  */
 public DynamicProperty(JSONObject jsonObject) : base()
 {
     try
     {
         //name = NAME.ValueOf(jsonObject.GetString("name").ToUpper().Trim());//toUpperCase().trim());
         System.Enum.TryParse <NAME>(jsonObject.GetString("name").ToUpper().Trim(), out name); // NAME.ValueOf(jsonObject.GetString("name").ToUpper().Trim());
     }
     catch (Java.Lang.Exception e)
     {
         name = NAME.NO_VALID;
     }
     try
     {
         //type = TYPE.valueOf(jsonObject.GetString("type").ToUpper().Trim());//.ToUpperCase().trim());
         System.Enum.TryParse <TYPE>(jsonObject.GetString("type").ToUpper().Trim(), out type);
     }
     catch (Java.Lang.Exception e)
     {
         type = TYPE.NO_VALID;
     }
     try
     {
         value = convertValue(jsonObject.Get("value"));
     }
     catch (Java.Lang.Exception e) { }
 }
示例#6
0
        public virtual void TestSingleAttempt()
        {
            ApplicationId        appId        = ApplicationId.NewInstance(0, 1);
            ApplicationAttemptId appAttemptId = ApplicationAttemptId.NewInstance(appId, 1);
            WebResource          r            = Resource();
            ClientResponse       response     = r.Path("ws").Path("v1").Path("applicationhistory").Path
                                                    ("apps").Path(appId.ToString()).Path("appattempts").Path(appAttemptId.ToString()
                                                                                                             ).QueryParam("user.name", Users[round]).Accept(MediaType.ApplicationJson).Get <ClientResponse
                                                                                                                                                                                            >();

            if (round == 1)
            {
                NUnit.Framework.Assert.AreEqual(ClientResponse.Status.Forbidden, response.GetClientResponseStatus
                                                    ());
                return;
            }
            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject appAttempt = json.GetJSONObject("appAttempt");

            NUnit.Framework.Assert.AreEqual(appAttemptId.ToString(), appAttempt.GetString("appAttemptId"
                                                                                          ));
            NUnit.Framework.Assert.AreEqual("test host", appAttempt.GetString("host"));
            NUnit.Framework.Assert.AreEqual("test diagnostics info", appAttempt.GetString("diagnosticsInfo"
                                                                                          ));
            NUnit.Framework.Assert.AreEqual("test tracking url", appAttempt.GetString("trackingUrl"
                                                                                      ));
            NUnit.Framework.Assert.AreEqual(YarnApplicationAttemptState.Finished.ToString(),
                                            appAttempt.Get("appAttemptState"));
        }
        public virtual void TestSingleNodeQueryStateLost()
        {
            WebResource r   = Resource();
            MockNM      nm1 = rm.RegisterNode("h1:1234", 5120);
            MockNM      nm2 = rm.RegisterNode("h2:1234", 5120);

            rm.SendNodeStarted(nm1);
            rm.SendNodeStarted(nm2);
            rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running);
            rm.NMwaitForState(nm2.GetNodeId(), NodeState.Running);
            rm.SendNodeLost(nm1);
            rm.SendNodeLost(nm2);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").Path
                                          ("h2:1234").Accept(MediaType.ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();
            JSONObject info = json.GetJSONObject("node");
            string     id   = info.Get("id").ToString();

            NUnit.Framework.Assert.AreEqual("Incorrect Node Information.", "h2:1234", id);
            RMNode rmNode = rm.GetRMContext().GetInactiveRMNodes()["h2"];

            WebServicesTestUtils.CheckStringMatch("nodeHTTPAddress", string.Empty, info.GetString
                                                      ("nodeHTTPAddress"));
            WebServicesTestUtils.CheckStringMatch("state", rmNode.GetState().ToString(), info
                                                  .GetString("state"));
        }
示例#8
0
        public virtual void TestJobsQueryStateNone()
        {
            WebResource      r         = Resource();
            AList <JobState> JobStates = new AList <JobState>(Arrays.AsList(JobState.Values()));
            // find a state that isn't in use
            IDictionary <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> jobsMap = appContext
                                                                                      .GetAllJobs();

            foreach (KeyValuePair <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> entry in
                     jobsMap)
            {
                JobStates.Remove(entry.Value.GetState());
            }
            NUnit.Framework.Assert.IsTrue("No unused job states", JobStates.Count > 0);
            JobState       notInUse = JobStates[0];
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("state", notInUse.ToString()).Accept(MediaType.ApplicationJson
                                                                                                                                                  ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            NUnit.Framework.Assert.AreEqual("jobs is not null", JSONObject.Null, json.Get("jobs"
                                                                                          ));
        }
示例#9
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            Toast        currentToast = new Toast(context);
            LinearLayout layout       = new LinearLayout(context);

            layout.Orientation = Orientation.Vertical;
            TextView textView = new TextView(context);

            textView.TextSize = 20;
            textView.SetPadding(10, 20, 0, 0);
            textView.SetHeight(70);

            textView.Text = "Primary Agricultural Data of USA";
            layout.AddView(textView);
            textView.Gravity = Android.Views.GravityFlags.Top;
            maps             = new SfMaps(context);

            ShapeFileLayer layer = new ShapeFileLayer();

            layer.ShapeSelected += (object sender, ShapeFileLayer.ShapeSelectedEventArgs e) => {
                JSONObject data = (JSONObject)e.P0;
                if (data != null)
                {
                    if (currentToast != null)
                    {
                        currentToast.Cancel();
                    }
                    currentToast = Toast.MakeText(context, data.Get("Name") + "\n" + data.Get("Type"), ToastLength.Short);
                    currentToast.Show();
                }
            };
            layer.EnableSelection   = true;
            layer.Uri               = "usa_state.shp";
            layer.ShapeIdTableField = "STATE_NAME";
            layer.ShapeIdPath       = "Name";
            layer.DataSource        = GetDataSource();
            layer.ShapeSettings.ShapeStrokeThickess = 2;
            SetColorMapping(layer.ShapeSettings);
            layer.ShapeSettings.ShapeColorValuePath = "Type";
            maps.Layers.Add(layer);
            maps.SetY(-20);
            layout.AddView(maps);
            return(layout);
        }
示例#10
0
        void UpdateSelection()
        {
            string selected = "";

            string selectedSeat = "";


            if ((maps.Layers[0] as ShapeFileLayer).SelectedItems.Count == 0)
            {
                SelectedLabel.Text      = "" + selected;
                SelectedLabelCount.Text = "" + (maps.Layers[0] as ShapeFileLayer).SelectedItems.Count;
                //ClearSelection.Visibility = ViewStates.Invisible;
                ClearSelection.Alpha   = 0.5f;
                ClearSelection.Enabled = false;
            }
            else
            {
                for (int i = 0; i < (maps.Layers[0] as ShapeFileLayer).SelectedItems.Count; i++)
                {
                    JSONObject item = (JSONObject)(maps.Layers[0] as ShapeFileLayer).SelectedItems[i];


                    object SeatNo = item.Get("SeatNumber");
                    selectedSeat = SeatNo.ToString();

                    if (selectedSeat == "1" || selectedSeat == "2" || selectedSeat == "8" || selectedSeat == "9")
                    {
                        (maps.Layers[0] as ShapeFileLayer).SelectedItems.Remove(item);
                    }

                    else
                    {
                        if ((maps.Layers[0] as ShapeFileLayer).SelectedItems.Count <= 1)
                        {
                            selected += ("S" + selectedSeat);
                        }
                        else if (i == (maps.Layers[0] as ShapeFileLayer).SelectedItems.Count - 1)
                        {
                            selected += ("S" + selectedSeat);
                        }
                        else
                        {
                            selected += ("S" + selectedSeat + ", ");
                        }
                    }
                }
                //	ClearSelection.Visibility = ViewStates.Visible;

                ClearSelection.Alpha   = 1f;
                ClearSelection.Enabled = true;

                SelectedLabel.Text      = selected;
                SelectedLabelCount.Text = "" + (maps.Layers[0] as ShapeFileLayer).SelectedItems.Count;
            }
        }
示例#11
0
        public static IMap ToJavaMap(this JSONObject @object)
        {
            IMap      map  = new HashMap();
            IIterator keys = @object.Keys();

            while (keys.HasNext)
            {
                var key = ((Java.Lang.String)keys.Next()).ToString();
                map.Put(key, FromJson(@object.Get(key)));
            }
            return(map);
        }
            protected override bool OnNotificationProcessing(OSNotificationReceivedResult p0)
            {
                OverrideSettings overrideSettings = new OverrideSettings();

                overrideSettings.Extender = new NotificationCompat.CarExtender();

                Com.OneSignal.Android.OSNotificationPayload payload = p0.Payload;
                JSONObject additionalData = payload.AdditionalData;

                if (additionalData.Has("room_name"))
                {
                    string roomName = additionalData.Get("room_name").ToString();
                    string callType = additionalData.Get("call_type").ToString();
                    string callId   = additionalData.Get("call_id").ToString();
                    string fromId   = additionalData.Get("from_id").ToString();
                    string toId     = additionalData.Get("to_id").ToString();

                    return(false);
                }

                return(true);
            }
        public virtual void TestNodeContainersNone()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("node").Path("containers")
                                      .Accept(MediaType.ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("apps isn't NULL", JSONObject.Null, json.Get("containers"
                                                                                         ));
        }
 public void onMessage(string data)
 {
     try
     {
         JSONObject json = new JSONObject(data);
         string     type = (string)json.Get("type");
         if (type.Equals("candidate"))
         {
             IceCandidate candidate = new IceCandidate((string)json.Get("id"), json.GetInt("label"), (string)json.Get("candidate"));
             if (outerInstance.queuedRemoteCandidates != null)
             {
                 outerInstance.queuedRemoteCandidates.AddLast(candidate);
             }
             else
             {
                 outerInstance.pc.AddIceCandidate(candidate);
             }
         }
         else if (type.Equals("answer") || type.Equals("offer"))
         {
             SessionDescription sdp = new SessionDescription(SessionDescription.SessionDescriptionType.FromCanonicalForm(type), outerInstance.preferISAC((string)json.Get("sdp")));
             outerInstance.pc.SetRemoteDescription(outerInstance.sdpObserver, sdp);
         }
         else if (type.Equals("bye"))
         {
             outerInstance.logAndToast("Remote end hung up; dropping PeerConnection");
             outerInstance.disconnectAndExit();
         }
         else
         {
             throw new Exception("Unexpected message: " + data);
         }
     }
     catch (JSONException e)
     {
         throw new Exception("Error", e);
     }
 }
示例#15
0
        public virtual void TestJobsQueryQueueNonExist()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("queue", "bogus").Accept(MediaType.ApplicationJson).Get
                                      <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            NUnit.Framework.Assert.AreEqual("jobs is not null", JSONObject.Null, json.Get("jobs"
                                                                                          ));
        }
示例#16
0
        public virtual void TestJobsQueryFinishTimeEnd()
        {
            WebResource r = Resource();
            // the mockJobs finish time is the current time + some random amount
            long           now      = Runtime.CurrentTimeMillis();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("finishedTimeEnd", now.ToString()).Accept(MediaType.ApplicationJson
                                                                                                                                                       ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            NUnit.Framework.Assert.AreEqual("jobs is not null", JSONObject.Null, json.Get("jobs"
                                                                                          ));
        }
        public virtual void TestNodesQueryStateNone()
        {
            WebResource r = Resource();

            rm.RegisterNode("h1:1234", 5120);
            rm.RegisterNode("h2:1235", 5121);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").QueryParam
                                          ("states", NodeState.Decommissioned.ToString()).Accept(MediaType.ApplicationJson
                                                                                                 ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            NUnit.Framework.Assert.AreEqual("nodes is not null", JSONObject.Null, json.Get("nodes"
                                                                                           ));
        }
        public virtual void TestNodesQueryHealthyFalse()
        {
            WebResource r   = Resource();
            MockNM      nm1 = rm.RegisterNode("h1:1234", 5120);
            MockNM      nm2 = rm.RegisterNode("h2:1235", 5121);

            rm.SendNodeStarted(nm1);
            rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running);
            rm.NMwaitForState(nm2.GetNodeId(), NodeState.New);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").QueryParam
                                          ("states", "UNHEALTHY").Accept(MediaType.ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            NUnit.Framework.Assert.AreEqual("nodes is not null", JSONObject.Null, json.Get("nodes"
                                                                                           ));
        }
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void TestNodesHelper(string path, string media)
        {
            WebResource r   = Resource();
            MockNM      nm1 = rm.RegisterNode("h1:1234", 5120);
            MockNM      nm2 = rm.RegisterNode("h2:1235", 5121);

            rm.SendNodeStarted(nm1);
            rm.SendNodeStarted(nm2);
            rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running);
            rm.NMwaitForState(nm2.GetNodeId(), NodeState.Running);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path(path).Accept
                                          (media).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject nodes = json.GetJSONObject("nodes");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.Length()
                                            );
            JSONArray nodeArray = nodes.GetJSONArray("node");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 2, nodeArray.Length
                                                ());
            JSONObject info = nodeArray.GetJSONObject(0);
            string     id   = info.Get("id").ToString();

            if (id.Matches("h1:1234"))
            {
                VerifyNodeInfo(info, nm1);
                VerifyNodeInfo(nodeArray.GetJSONObject(1), nm2);
            }
            else
            {
                VerifyNodeInfo(info, nm2);
                VerifyNodeInfo(nodeArray.GetJSONObject(1), nm1);
            }
        }
        public virtual void TestNodeAppsUserNone()
        {
            WebResource r = Resource();

            Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                app = new MockApp(1);
            nmContext.GetApplications()[app.GetAppId()] = app;
            AddAppContainers(app);
            Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                app2 = new MockApp("foo", 1234, 2);
            nmContext.GetApplications()[app2.GetAppId()] = app2;
            AddAppContainers(app2);
            ClientResponse response = r.Path("ws").Path("v1").Path("node").Path("apps").QueryParam
                                          ("user", "george").Accept(MediaType.ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("apps is not null", JSONObject.Null, json.Get("apps"
                                                                                          ));
        }
        public virtual void TestNodesQueryStateLost()
        {
            WebResource r   = Resource();
            MockNM      nm1 = rm.RegisterNode("h1:1234", 5120);
            MockNM      nm2 = rm.RegisterNode("h2:1234", 5120);

            rm.SendNodeStarted(nm1);
            rm.SendNodeStarted(nm2);
            rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running);
            rm.NMwaitForState(nm2.GetNodeId(), NodeState.Running);
            rm.SendNodeLost(nm1);
            rm.SendNodeLost(nm2);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").QueryParam
                                          ("states", NodeState.Lost.ToString()).Accept(MediaType.ApplicationJson).Get <ClientResponse
                                                                                                                       >();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json  = response.GetEntity <JSONObject>();
            JSONObject nodes = json.GetJSONObject("nodes");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.Length()
                                            );
            JSONArray nodeArray = nodes.GetJSONArray("node");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 2, nodeArray.Length
                                                ());
            for (int i = 0; i < nodeArray.Length(); ++i)
            {
                JSONObject info   = nodeArray.GetJSONObject(i);
                string     host   = info.Get("id").ToString().Split(":")[0];
                RMNode     rmNode = rm.GetRMContext().GetInactiveRMNodes()[host];
                WebServicesTestUtils.CheckStringMatch("nodeHTTPAddress", string.Empty, info.GetString
                                                          ("nodeHTTPAddress"));
                WebServicesTestUtils.CheckStringMatch("state", rmNode.GetState().ToString(), info
                                                      .GetString("state"));
            }
        }
示例#22
0
        public override Android.Views.View GetSampleContent(Android.Content.Context context)
        {
            handler       = new Handler();
            layout        = new LinearLayout(context);
            linearLayout1 = new LinearLayout(context);
            linearLayout  = new LinearLayout(context);

            linearLayout.Visibility = Android.Views.ViewStates.Invisible;
            text          = new TextView(context);
            text.TextSize = 16;
            text.SetPadding(10, 20, 0, 0);
            text.SetHeight(90);
            text.Text = "WorldMap";
            text.SetTextColor(Color.Blue);

            text.Click += Text_Click;

            linearLayout.AddView(text);

            text3          = new TextView(context);
            text3.TextSize = 16;
            text3.SetPadding(10, 20, 0, 0);
            text3.Text          = "Click on a shape to drill";
            text3.TextAlignment = Android.Views.TextAlignment.Center;

            linearLayout1.AddView(text3);

            text1      = new TextView(context);
            text1.Text = ">>";
            text1.SetPadding(10, 20, 0, 0);
            linearLayout.AddView(text1);

            text2 = new TextView(context);
            linearLayout.AddView(text2);

            layout.Orientation = Orientation.Vertical;
            maps = new SfMaps(context);
            maps.EnableZooming = false;
            layer                   = new ShapeFileLayer();
            layer.Uri               = "world-map.shp";
            layer.EnableSelection   = true;
            layer.ShapeIdTableField = "admin";
            layer.ShapeIdPath       = "country";
            layer.DataSource        = GetDataSource();
            layer.ShapeSettings.ShapeColorValuePath = "continent";
            layer.ShapeSelected += (object sender, ShapeFileLayer.ShapeSelectedEventArgs e) =>
            {
                JSONObject data = (JSONObject)e.P0;
                if (data != null)
                {
                    var dat = data.Get("continent").ToString();
                    text2.Text = dat;
                    linearLayout.Visibility  = Android.Views.ViewStates.Visible;
                    linearLayout1.Visibility = Android.Views.ViewStates.Invisible;

                    if (dat == "South America")
                    {
                        maps.BaseMapIndex = 1;
                        layer.ShapeSettings.SelectedShapeColor = Color.ParseColor("#9C3367");
                    }
                    else if (dat == "North America")
                    {
                        maps.BaseMapIndex = 2;
                        layer.ShapeSettings.SelectedShapeColor = Color.ParseColor("#C13664");
                    }
                    else if (dat == "Europe")
                    {
                        maps.BaseMapIndex = 3;
                        layer.ShapeSettings.SelectedShapeColor = Color.ParseColor("#622D6C");
                    }
                    else if (dat == "Africa")
                    {
                        maps.BaseMapIndex = 4;
                        layer.ShapeSettings.SelectedShapeColor = Color.ParseColor("#80306A");
                    }
                    else if (dat == "Australia")
                    {
                        maps.BaseMapIndex = 5;
                        layer.ShapeSettings.SelectedShapeColor = Color.ParseColor("#2A2870");
                    }
                    else if (dat == "Asia")
                    {
                        maps.BaseMapIndex = 6;
                        layer.ShapeSettings.SelectedShapeColor = Color.ParseColor("#462A6D");
                    }
                }
            };

            SetColorMapping(layer.ShapeSettings);

            CustomMarker mapMarker = new CustomMarker(context);

            mapMarker.Label     = "Asia";
            mapMarker.Latitude  = 63.34303378997662;
            mapMarker.Longitude = 102.07617561287645;
            layer.Markers.Add(mapMarker);

            CustomMarker mapMarker1 = new CustomMarker(context);

            mapMarker1.Label     = "Australia";
            mapMarker1.Latitude  = -25.74775493367931;
            mapMarker1.Longitude = 136.80451417932431;
            layer.Markers.Add(mapMarker1);

            CustomMarker mapMarker2 = new CustomMarker(context);

            mapMarker2.Label     = "Africa";
            mapMarker2.Latitude  = 19.025302093442327;
            mapMarker2.Longitude = 15.157534554671087;
            layer.Markers.Add(mapMarker2);

            CustomMarker mapMarker3 = new CustomMarker(context);

            mapMarker3.Label     = "North America";
            mapMarker3.Latitude  = 59.88893689676585;
            mapMarker3.Longitude = -109.3359375;
            layer.Markers.Add(mapMarker3);

            CustomMarker mapMarker4 = new CustomMarker(context);

            mapMarker4.Label     = "Europe";
            mapMarker4.Latitude  = 47.95121990866204;
            mapMarker4.Longitude = 18.468749999999998;
            layer.Markers.Add(mapMarker4);

            CustomMarker mapMarker5 = new CustomMarker(context);

            mapMarker5.Label     = "South America";
            mapMarker5.Latitude  = -6.64607562172573;
            mapMarker5.Longitude = -55.54687499999999;
            layer.Markers.Add(mapMarker5);

            maps.Layers.Add(layer);

            ShapeFileLayer layer1 = new ShapeFileLayer();

            layer1.ShapeIdPath       = "country";
            layer1.ShapeIdTableField = "admin";
            layer1.Uri = "south-america.shp";
            layer1.ShapeSettings.ShapeFill = Color.ParseColor("#9C3367");
            maps.Layers.Add(layer1);

            ShapeFileLayer layer2 = new ShapeFileLayer();

            layer2.ShapeIdPath       = "country";
            layer2.ShapeIdTableField = "admin";
            layer2.Uri = "north-america.shp";
            layer2.ShapeSettings.ShapeFill = Color.ParseColor("#C13664");
            maps.Layers.Add(layer2);

            ShapeFileLayer layer3 = new ShapeFileLayer();

            layer3.ShapeIdPath       = "country";
            layer3.ShapeIdTableField = "admin";
            layer3.Uri = "europe.shp";
            layer3.ShapeSettings.ShapeFill = Color.ParseColor("#622D6C");
            maps.Layers.Add(layer3);

            ShapeFileLayer layer4 = new ShapeFileLayer();

            layer4.ShapeIdPath       = "country";
            layer4.ShapeIdTableField = "admin";
            layer4.Uri = "africa.shp";
            layer4.ShapeSettings.ShapeFill = Color.ParseColor("#80306A");
            maps.Layers.Add(layer4);

            ShapeFileLayer layer5 = new ShapeFileLayer();

            layer5.ShapeIdPath       = "country";
            layer5.ShapeIdTableField = "admin";
            layer5.Uri = "australia.shp";
            layer5.ShapeSettings.ShapeFill = Color.ParseColor("#2A2870");
            maps.Layers.Add(layer5);

            ShapeFileLayer layer6 = new ShapeFileLayer();

            layer6.ShapeIdPath       = "country";
            layer6.ShapeIdTableField = "admin";
            layer6.Uri = "asia.shp";
            layer6.ShapeSettings.ShapeFill = Color.ParseColor("#462A6D");
            maps.Layers.Add(layer6);

            SfBusyIndicator sfBusyIndicator = new SfBusyIndicator(context);

            sfBusyIndicator.IsBusy        = true;
            sfBusyIndicator.AnimationType = AnimationTypes.SlicedCircle;
            sfBusyIndicator.ViewBoxWidth  = 50;
            sfBusyIndicator.ViewBoxHeight = 50;
            sfBusyIndicator.TextColor     = Color.ParseColor("#779772");

            layout.AddView(sfBusyIndicator);

            Java.Lang.Runnable run = new Java.Lang.Runnable(() =>
            {
                layout.RemoveView(sfBusyIndicator);
                layout.AddView(linearLayout);
                layout.AddView(linearLayout1);
                layout.AddView(maps);
            });

            handler.PostDelayed(run, 100);

            return(layout);
        }
            /// <summary>
            /// Handle the notifications from OneSignal that have data passed in order to update the UI
            /// </summary>
            private void HandleNotificationData(JSONObject data)
            {
                string           uidSeekios       = string.Empty;
                string           methodName       = string.Empty;
                Tuple <int, int> batteryAndSignal = null;
                Tuple <double, double, double, double> location = null;
                DateTime date = DateTime.Now;
                int      userCreditDebitAmount    = 0;
                int      seekiosCreditDebitAmount = 0;
                int      idAlert = 0;
                int      idMode  = 0;

                if (!data.IsNull("uidSeekios"))
                {
                    uidSeekios = data.Get("uidSeekios").ToString();
                }

                string seekiosName = string.Empty;

                if (null != uidSeekios && !string.Empty.Equals(uidSeekios))
                {
                    var seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios);
                    if (seekios != null)
                    {
                        seekiosName = seekios.SeekiosName;
                    }
                }

                if (!data.IsNull("batterySignal"))
                {
                    batteryAndSignal = JsonConvert.DeserializeObject <Tuple <int, int> >(data.Get("batterySignal").ToString());
                }

                if (!data.IsNull("location"))
                {
                    location = JsonConvert.DeserializeObject <Tuple <double, double, double, double> >(data.Get("location").ToString());
                }

                if (!data.IsNull("date"))
                {
                    date = DateExtension.FormatJsonDateToDateTime(data.Get("date").ToString());
                }

                if (!data.IsNull("userCreditDebitAmount"))
                {
                    userCreditDebitAmount = JsonConvert.DeserializeObject <int>(data.Get("userCreditDebitAmount").ToString());
                }

                if (!data.IsNull("seekiosCreditDebitAmount"))
                {
                    seekiosCreditDebitAmount = JsonConvert.DeserializeObject <int>(data.Get("seekiosCreditDebitAmount").ToString());
                }

                if (!data.IsNull("methodName"))
                {
                    methodName = data.Get("methodName").ToString();
                }

                if (!data.IsNull("idAlert"))
                {
                    idAlert = JsonConvert.DeserializeObject <int>(data.Get("idAlert").ToString());
                }

                if (!data.IsNull("idMode"))
                {
                    idMode = JsonConvert.DeserializeObject <int>(data.Get("idMode").ToString());
                }


                if (!string.IsNullOrEmpty(methodName))
                {
                    SeekiosDTO seekios = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(el => el.UIdSeekios == uidSeekios);

                    switch (methodName)
                    {
                    case "RefreshCredits":
                        App.Locator.ListSeekios.OnHasToRefreshCredits(uidSeekios, userCreditDebitAmount, seekiosCreditDebitAmount, date);
                        break;

                    case "RefreshPosition":
                        if (batteryAndSignal != null && location != null)
                        {
                            App.Locator.BaseMap.OnDemandPositionReceived(uidSeekios, batteryAndSignal, location, date);
                        }
                        break;

                    case "InstructionTaken":
                        if (batteryAndSignal != null)
                        {
                            App.Locator.ListSeekios.SeekiosInstructionTaken(uidSeekios, batteryAndSignal, date);
                        }
                        break;

                    case "NotifySeekiosOutOfZone":
                        if (batteryAndSignal != null && location != null)
                        {
                            App.Locator.ModeZone.OnNotifySeekiosOutOfZone(uidSeekios, batteryAndSignal, location, date);
                        }
                        break;

                    case "AddTrackingLocation":
                        if (batteryAndSignal != null && location != null)
                        {
                            App.Locator.ModeTracking.OnAddTrackingLocation(uidSeekios, batteryAndSignal, location, date);
                        }
                        break;

                    case "AddNewZoneTrackingLocation":
                        if (batteryAndSignal != null && location != null)
                        {
                            App.Locator.ModeZone.OnNewZoneTrackingLocationAdded(uidSeekios, batteryAndSignal, location, date);
                        }
                        break;

                    case "AddNewDontMoveTrackingLocation":
                        if (batteryAndSignal != null && location != null)
                        {
                            App.Locator.ModeDontMove.OnNewDontMoveTrackingLocationAdded(uidSeekios, batteryAndSignal, location, date);
                        }
                        break;

                    case "NotifySeekiosMoved":
                        if (batteryAndSignal != null)
                        {
                            App.Locator.ModeDontMove.OnNotifySeekiosMoved(uidSeekios, batteryAndSignal, date);
                        }
                        break;

                    case "SOSSent":
                        if (seekios != null)
                        {
                            App.Locator.ListSeekios.OnSOSSentReceived(uidSeekios, batteryAndSignal, date);
                        }
                        break;

                    case "SOSLocationSent":
                        if (batteryAndSignal != null && location != null)
                        {
                            App.Locator.BaseMap.NotifySOSLocationReceived(uidSeekios, batteryAndSignal, location, date);
                        }
                        break;

                    case "CriticalBattery":
                        if (seekios != null)
                        {
                            App.Locator.ListSeekios.OnCriticalBatteryReceived(uidSeekios, batteryAndSignal, date);
                        }
                        break;

                    case "PowerSavingDisabled":
                        if (seekios != null)
                        {
                            App.Locator.ListSeekios.OnPowerSavingDisabledReceived(uidSeekios, batteryAndSignal, date);
                        }
                        break;
                    }
                }
            }
示例#24
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_mainview);

            //Получение Bitmap из пути к файлу
            string path;

            path = Intent.GetStringExtra("image");
            if (path != null && path != "")
            {
                sourceBitmap = GetBitmap(path);
            }

            //Инициализация сервисов
            latexService         = new LatexApiService(this);
            firebaseImageService = new FirebaseImageService(this);
            loadingAnimation     = FindViewById <AVLoadingIndicatorView>(Resource.Id.loadingAnimation);

            PhotoCropFragment photoCropFragment = new PhotoCropFragment(sourceBitmap, ProcessBitmaps);

            Android.Support.V4.App.FragmentManager     fragmentManager     = SupportFragmentManager;
            Android.Support.V4.App.FragmentTransaction fragmentTransaction = fragmentManager.BeginTransaction();
            fragmentTransaction.Replace(Resource.Id.content_main, photoCropFragment, "crop_view_tag").Commit();

            firebaseImageService.AddImageResultListener(delegate(string[] text, string[] ex)
            {
                if (ex == null || ex.Length == 0)
                {
                    List <string> tmpRes = new List <string>();
                    foreach (var detectionResult in text)
                    {
                        tmpRes.Add(detectionResult);
                    }
                    textParsigResults.Add(string.Join('\n', tmpRes.ToArray()));
                    textParsigResults.AddRange(tmpRes);
                }
                else if (ex.Length > 0)
                {
                    Toast.MakeText(Application.Context, $"Ошибка: {ex[0]}", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(Application.Context, "null", ToastLength.Short).Show();
                }
                processedReady++;
                ProcessedReady();
            });


            latexService.AddOnLatexResultListener(delegate(string[] res, string[] ex)
            {
                if (res != null)
                {
                    List <string> tmpRes = new List <string>();
                    foreach (var detectionResult in res)
                    {
                        var jsonRes = new JSONObject(detectionResult);
                        if (jsonRes.Has("latex_styled"))
                        {
                            tmpRes.Add(jsonRes.Get("latex_styled").ToString());
                        }
                        else if (jsonRes.Has("text"))
                        {
                            tmpRes.Add(jsonRes.Get("text").ToString());
                        }
                    }
                    latexParsigResults.Add(string.Join('\n', tmpRes.ToArray()));
                    latexParsigResults.AddRange(tmpRes);
                }
                else if (ex[0] != null)
                {
                    Toast.MakeText(Application.Context, $"Ошибка: {ex[0]}", ToastLength.Short).Show();
                }
                processedReady++;
                ProcessedReady();
            });
        }