Esempio n. 1
0
        static int _g_get_Value(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                MongoDB.Bson.BsonObjectId gen_to_be_invoked = (MongoDB.Bson.BsonObjectId)translator.FastGetCSObj(L, 1);
                translator.Push(L, gen_to_be_invoked.Value);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
Esempio n. 2
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 2 && translator.Assignable <MongoDB.Bson.ObjectId>(L, 2))
                {
                    MongoDB.Bson.ObjectId _value; translator.Get(L, 2, out _value);

                    MongoDB.Bson.BsonObjectId gen_ret = new MongoDB.Bson.BsonObjectId(_value);
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.BsonObjectId constructor!"));
        }
Esempio n. 3
0
        static int _m_Create_xlua_st_(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);



                {
                    object _value = translator.GetObject(L, 1, typeof(object));

                    MongoDB.Bson.BsonObjectId gen_ret = MongoDB.Bson.BsonObjectId.Create(_value);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Esempio n. 4
0
        static int __EqMeta(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                if (translator.Assignable <MongoDB.Bson.BsonObjectId>(L, 1) && translator.Assignable <MongoDB.Bson.BsonObjectId>(L, 2))
                {
                    MongoDB.Bson.BsonObjectId leftside  = (MongoDB.Bson.BsonObjectId)translator.GetObject(L, 1, typeof(MongoDB.Bson.BsonObjectId));
                    MongoDB.Bson.BsonObjectId rightside = (MongoDB.Bson.BsonObjectId)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonObjectId));

                    LuaAPI.lua_pushboolean(L, leftside == rightside);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to right hand of == operator, need MongoDB.Bson.BsonObjectId!"));
        }
Esempio n. 5
0
        static int _m_ToString(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.BsonObjectId gen_to_be_invoked = (MongoDB.Bson.BsonObjectId)translator.FastGetCSObj(L, 1);



                {
                    string gen_ret = gen_to_be_invoked.ToString(  );
                    LuaAPI.lua_pushstring(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
Esempio n. 6
0
        static int _m_Equals(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.BsonObjectId gen_to_be_invoked = (MongoDB.Bson.BsonObjectId)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonObjectId>(L, 2))
                {
                    MongoDB.Bson.BsonObjectId _rhs = (MongoDB.Bson.BsonObjectId)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonObjectId));

                    bool gen_ret = gen_to_be_invoked.Equals(_rhs);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && translator.Assignable <object>(L, 2))
                {
                    object _obj = translator.GetObject(L, 2, typeof(object));

                    bool gen_ret = gen_to_be_invoked.Equals(_obj);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.BsonObjectId.Equals!"));
        }
Esempio n. 7
0
        static int _m_CompareTo(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                MongoDB.Bson.BsonObjectId gen_to_be_invoked = (MongoDB.Bson.BsonObjectId)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonObjectId>(L, 2))
                {
                    MongoDB.Bson.BsonObjectId _other = (MongoDB.Bson.BsonObjectId)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonObjectId));

                    int gen_ret = gen_to_be_invoked.CompareTo(_other);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && translator.Assignable <MongoDB.Bson.BsonValue>(L, 2))
                {
                    MongoDB.Bson.BsonValue _other = (MongoDB.Bson.BsonValue)translator.GetObject(L, 2, typeof(MongoDB.Bson.BsonValue));

                    int gen_ret = gen_to_be_invoked.CompareTo(_other);
                    LuaAPI.xlua_pushinteger(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to MongoDB.Bson.BsonObjectId.CompareTo!"));
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            //ConnectionString, name of database & collection to connect
            //All those values will be acquired from App.config's setting section
            string connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            string databaseName     = ConfigurationManager.AppSettings["DatabaseName"];
            string collectionName   = ConfigurationManager.AppSettings["CollectionName"];

            //Mongo client object
            MongoClient client = new MongoClient(connectionString);
            //Switch to specific database
            IMongoDatabase database = client.GetDatabase(databaseName);

            //While selecting the collection, we can specify the read preference
            MongoCollectionSettings collSettings = new MongoCollectionSettings()
            {
                ReadPreference = new ReadPreference(ReadPreferenceMode.Secondary)
            };

            //Adding a record into primary instances
            var messageId = new MongoDB.Bson.BsonObjectId(new MongoDB.Bson.ObjectId());
            var deviceId  = new Random(1).Next();
            IMongoCollection <EventModel> productCollection = database.GetCollection <EventModel>(collectionName, collSettings);

            productCollection.InsertOne(new EventModel {
                _id = messageId, SiteId = 1, DeviceId = deviceId, SensorId = 1, Temperature = 20.05M, TestStatus = "Dormant", TimeStamp = DateTime.Now
            });
            EventModel result = null;

            //Loop through till the record gets replicated to secondary instance
            while (result == null)
            {    //Reading the newly inserted record from secondary instance
                result = productCollection.Find <EventModel>(x => x.DeviceId == deviceId).FirstOrDefault <EventModel>();
            }

            Console.WriteLine("Message Time:" + result.TimeStamp.ToString("dd/mm/yyyy hh:mm:ss"));
            Console.Read();
        }
Esempio n. 9
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (comboBox1.Text == "")
            {
                MessageBox.Show("Morate odabrati kategoriju");
                return;
            }
            if (textBox1.Text == "")
            {
                MessageBox.Show("Morate uneti model !!!");
                return;
            }

            string kat = comboBox1.Text;
            string mod = textBox1.Text;

            MongoDB.Bson.BsonObjectId idd = null;

            var client = new MongoClient("mongodb://localhost/?safe=true");
            var db     = client.GetDatabase("Katalog");

            if (kat == "Prenosni racunari")
            {
                var collection = db.GetCollection <Prenosni_Racunari>("Prenosni_Racunari");

                var rez = collection.AsQueryable <Prenosni_Racunari>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Prenosni_Racunari> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Racunari")
            {
                var collection = db.GetCollection <Racunari>("Racunari");

                var rez = collection.AsQueryable <Racunari>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Racunari> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Mobilni uredjaji")
            {
                var collection = db.GetCollection <Mobilni_Uredjaji>("Mobilni_Uredjaji");

                var rez = collection.AsQueryable <Mobilni_Uredjaji>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Mobilni_Uredjaji> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Misevi")
            {
                var collection = db.GetCollection <Racunarska_Oprema>("Racunarska_Oprema");

                var rez = collection.AsQueryable <Racunarska_Oprema>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Racunarska_Oprema> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Tastature")
            {
                var collection = db.GetCollection <Racunarska_Oprema>("Racunarska_Oprema");

                var rez = collection.AsQueryable <Racunarska_Oprema>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Racunarska_Oprema> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Web kamere")
            {
                var collection = db.GetCollection <Racunarska_Oprema>("Racunarska_Oprema");

                var rez = collection.AsQueryable <Racunarska_Oprema>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Racunarska_Oprema> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Slusalice")
            {
                var collection = db.GetCollection <Audio_Oprema>("Audio_Oprema");

                var rez = collection.AsQueryable <Audio_Oprema>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Audio_Oprema> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Zvucnici")
            {
                var collection = db.GetCollection <Audio_Oprema>("Audio_Oprema");

                var rez = collection.AsQueryable <Audio_Oprema>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Audio_Oprema> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Mikrofoni")
            {
                var collection = db.GetCollection <Audio_Oprema>("Audio_Oprema");

                var rez = collection.AsQueryable <Audio_Oprema>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Audio_Oprema> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }

            if (kat == "Monitori")
            {
                var collection = db.GetCollection <Monitori>("Monitori");

                var rez = collection.AsQueryable <Monitori>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Monitori> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Stampaci")
            {
                var collection = db.GetCollection <Stampaci_i_Skeneri>("Stampaci_I_Skeneri");

                var rez = collection.AsQueryable <Stampaci_i_Skeneri>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Stampaci_i_Skeneri> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
            if (kat == "Skeneri")
            {
                var collection = db.GetCollection <Stampaci_i_Skeneri>("Stampaci_I_Skeneri");

                var rez = collection.AsQueryable <Stampaci_i_Skeneri>().Where(x => x.Model == mod).ToList();
                foreach (var pp in rez)
                {
                    idd = pp.Id;
                }

                var result = collection.DeleteOne(Builders <Stampaci_i_Skeneri> .Filter.Eq("_id", idd));
                MessageBox.Show("Obrisano");
            }
        }