예제 #1
0
        public ActionResult AddThingsToDo(Int64 key)
        {
            if (Session["userKey"] != null)
            {
                using (ArangoDatabase db = new ArangoDatabase(url: "http://52.32.98.159:8529", database: "Expedia"))
                {
                    var query = from thingsToDo in db.Query <ThingsToDo>()
                                where thingsToDo._key == key
                                select new { thingsToDo.FechaDeFin, thingsToDo.FechaDeInicio };
                    // ViewData["FechaDeFin"] = query.First().FechaDeFin;
                }
                using (WebClient wc = new WebClient())
                {
                    //TTD
                    var jsonttd = wc.DownloadString("http://52.32.98.159:8529/_db/Expedia/_api/document/ThingsToDo/" + key);
                    System.Web.Script.Serialization.JavaScriptSerializer jsSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                    ThingsToDo thingsToDo = jsSerializer.Deserialize <ThingsToDo>(jsonttd);
                    //Usuario
                    var jsonU = wc.DownloadString("http://52.32.98.159:8529/_db/Expedia/_api/document/ThingsToDo/" + key);
                    System.Web.Script.Serialization.JavaScriptSerializer jsSerializerU = new System.Web.Script.Serialization.JavaScriptSerializer();
                    ThingsToDo thingsTo = jsSerializerU.Deserialize <ThingsToDo>(jsonU);
                }

                // usuario.thingsToDo.Add(thingToDo);
                // db.Update<Usuarios>(usuario);
            }
            return(null);
        }
예제 #2
0
        public ActionResult Save(String nombre, String usuario, String contrasenia)
        {
            using (ArangoDB.Client.ArangoDatabase db = new ArangoDatabase(url: "http://52.32.98.159:8529", database: "Expedia"))
            {
                string id = Guid.NewGuid().ToString();

                var usuarios = new Usuarios {
                    _key = id, nombre = nombre, usuario = usuario, contrasenia = contrasenia
                };

                var query = (from User in db.Query <Usuarios>()
                             where User.usuario == usuario
                             select new { User.usuario }).ToList();

                if (query.Count == 0)
                {
                    db.Insert <Usuarios>(usuarios);

                    return(View("Detail", usuarios));
                }
                else
                {
                    return(View("Create", usuarios));
                }
            }
        }
예제 #3
0
        public ActionResult List()
        {
            Session["user"]    = "******";
            Session["userKey"] = 185263600829;

            using (ArangoDatabase db = new ArangoDatabase(url: "http://52.32.98.159:8529", database: "Expedia"))
            {
                IList <ThingsToDo> data = db.Query <ThingsToDo>().ToList();

                return(View("List", data));
            }
        }
예제 #4
0
        private static void PublishTask(string message)
        {
            listPhotosFace.Clear();
            JObject jobj         = new JObject();
            dynamic results      = JsonConvert.DeserializeObject <dynamic>(message);
            string  facebookID   = results.facebook_id;
            string  facebookName = results.facebook_name;
            string  routingKey   = "request.facetrain";

            jobj["facebook_id"]   = facebookID;
            jobj["facebook_name"] = facebookName;

            using (var db = new ArangoDatabase(url: ConnectionConstants.ArangoHost, database: ConnectionConstants.ArangoDatabase))
            {
                //facebook_id example :  "100007369238236"
                var result = db.Query <persons>()
                             .Where(p => p.profilFacebookId == facebookID)
                             .Select(p => new persons
                {
                    _id = p._id,
                    profilFacebookId = p.profilFacebookId,
                    linkPhotosFace   = p.linkPhotosFace
                }).ToList();

                var facephotos = result.First().linkPhotosFace;
                for (int i = 0; i < facephotos.Count; i++)
                {
                    var  photo  = facephotos[i];
                    bool isFace = (bool)facephotos[i]["verified_face"];
                    if (isFace == true)
                    {
                        listPhotosFace.Add(facephotos[i]["url"]);
                    }
                }

                jobj["list_photo_face"] = listPhotosFace;
            }

            //Console.WriteLine(jobj.ToString());
            byte[] messageBody = Encoding.UTF8.GetBytes(jobj.ToString());
            Console.WriteLine("Service {1} : FB ID {0} publish to units processing {2}, {3} face photos", facebookID, DateTime.Now, routingKey, listPhotosFace.Count);
            channel.BasicPublish("amq.topic", routingKey, null, messageBody);
        }
예제 #5
0
 public Task <T> Get(System.Linq.Expressions.Expression <Func <T, bool> > func)
 {
     return(Task.Run(() => db.Query <T>().Where(func).FirstOrDefault()));
 }