Exemplo n.º 1
0
    void VerifyWs()
    {
        data_notification = new List <DataNotification> ();

        String api_url = DataPaths.WS_NOTIFICATION_URL + "?user_id=" + PlayerPrefs.GetInt("user_id");

        Debug.Log("====== URL");
        Debug.Log(api_url);
        NetClient.OnWebRequestDoneDelegate onWebRequestDone = delegate(string webResponse) {
            Debug.Log(webResponse);
            try
            {
                JsonData rawData = JsonMapper.ToObject(webResponse);
                if ((string)rawData["status"] == "ok")
                {
                    foreach (JsonData elem in rawData["data"]["notification"])
                    {
                        if ((bool)elem["status"] == false)
                        {
                            DataNotification data = new DataNotification();
                            data.id      = (int)elem["id"];
                            data.title   = (string)elem["titulo"];
                            data.content = (string)elem["contenido"];
                            data.path    = (string)elem["path"];
                            data_notification.Add(data);
                        }
                    }
                    onNotificationLoaded();
                }
                else
                {
                    Debug.Log("Sin notificaciones");
                }
            }catch (JsonException e) {
                Debug.LogError("JSON Exception: " + e.Message + "\n" + e.StackTrace);
                throw e;
            }
        };


        NetClient.OnWebRequestFailDelegate onWebRequestFail = delegate
        {
            // NotificationSystem.Instance.PromptAction(DataMessages.SERVER_RESPONSE_FAIL, delegate {  }, delegate { NotificationSystem.Instance.Terminate(); });
            Debug.Log("Error al llamar el WS");
        };

        //REVISA WEBSERVICE;

        StartCoroutine(NetClient.Instance.MakeWebRequest(api_url, null, onWebRequestDone, onWebRequestFail));
    }
        public static Notification SearchNotification(Notification NotiObj)
        {
            Notification no = new Notification();

            try
            {
                no = DataNotification.SearchNotification(NotiObj);
            }
            catch (System.Exception ex)
            {
                GasLogB.CrearLogError(ex);
            }

            return(no);
        }
        public static List <Message> SearchMessages(UserAutentication userobj)
        {
            List <Message> MessageList = new List <Message>();
            DataTable      dt          = new DataTable();

            dt = DataNotification.SearchMessages(userobj);
            foreach (DataRow drFuente in dt.Rows)
            {
                Message MessageItem = new Message();
                MessageItem.Fecha        = drFuente["Fecha"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(drFuente["Fecha"]);
                MessageItem.Mensaje      = drFuente["Mensaje"] == DBNull.Value ? "" : Convert.ToString(drFuente["Mensaje"]);
                MessageItem.Remitente    = drFuente["Remitente"] == DBNull.Value ? "" : Convert.ToString(drFuente["Remitente"]);
                MessageItem.Destinatario = drFuente["Destinatario"] == DBNull.Value ? "" : Convert.ToString(drFuente["Destinatario"]);
                MessageList.Add(MessageItem);
            }
            return(MessageList);
        }