Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        SqliteInit.InitSqlite();


        FieldLister lister = new FieldLister();

        UserData[] data = new UserData[2];

        data[0]                  = new UserData();
        data[0].ID               = 1;
        data[0].Name             = "Tarou";
        data[0].Hoge             = "fuga";
        data[0].Age              = 32;
        data[0].LastUpdated      = new DateTime(2013, 4, 1);
        data[0].NestedClass.Fuga = "bbbb";
        data[0].NestedClass.Hoge = 23;

        data[1]             = new UserData();
        data[1].ID          = 2;
        data[1].Name        = "Jirou";
        data[1].Hoge        = "wahoo";
        data[1].Age         = 11;
        data[1].AddressData = "aaaaa";
        data[1].LastUpdated = new DateTime(2013, 5, 1);

        Write(data[0].ToString());


        var info = lister.ListUp <UserData>();

        Write(info.ToString());

        var    sqlMaker = new SQLMaker();
        string insert   = sqlMaker.GenerateInsertSQL(info, data[0]);
        string update   = sqlMaker.GenerateUpdateSQL(info, data[0]);

        Write("Insert = {0}", insert);
        Write("Update = {0}", update);

        DBMapper mapper = new DBMapper(SqliteInit.Evolution.Database);

        mapper.UpdateOrInsertAll(data);

        UserData[] fromDb = mapper.Read <UserData>("SELECT * FROM UserData;");
        Write(fromDb[0].ToString());
        Write(fromDb[1].ToString());


        JSONMapper jsonMapper = new JSONMapper();

        string json = jsonMapper.Write <UserData>(fromDb);

        UserData[] fromJson = jsonMapper.Read <UserData>(json);

        Write("Json = {0}", json);

        Write(fromJson[0].ToString());
        Write(fromJson[1].ToString());
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        SqliteInit.InitSqlite();

        FieldLister lister = new FieldLister();

        UserData[] data = new UserData[2];

        data[0] = new UserData();
        data[0].ID = 1;
        data[0].Name = "Tarou";
        data[0].Hoge = "fuga";
        data[0].Age = 32;
        data[0].LastUpdated = new DateTime(2013,4,1);
        data[0].NestedClass.Fuga = "bbbb";
        data[0].NestedClass.Hoge = 23;

        data[1] = new UserData();
        data[1].ID = 2;
        data[1].Name = "Jirou";
        data[1].Hoge = "wahoo";
        data[1].Age = 11;
        data[1].AddressData = "aaaaa";
        data[1].LastUpdated = new DateTime(2013,5,1);

        Debug.Log(data[0]);

        var info = lister.ListUp<UserData>();

        Debug.Log(info);

        var sqlMaker = new SQLMaker();
        string insert = sqlMaker.GenerateInsertSQL(info,data[0]);
        string update = sqlMaker.GenerateUpdateSQL(info,data[0]);

        Debug.Log("Insert = " + insert);
        Debug.Log("Update = " + update);

        DBMapper mapper = new DBMapper(SqliteInit.Evolution.Database);

        mapper.UpdateOrInsertAll(data);

        UserData[] fromDb = mapper.Read<UserData>("SELECT * FROM UserData;");
        Debug.Log(fromDb[0]);
        Debug.Log(fromDb[1]);

        JSONMapper jsonMapper = new JSONMapper();

        string json = jsonMapper.Write<UserData>(fromDb);
        UserData[] fromJson = jsonMapper.Read<UserData>(json);

        Debug.Log("Json = " + json);

        Debug.Log(fromJson[0]);
        Debug.Log(fromJson[1]);
    }
Esempio n. 3
0
        public string ExecuteDataProcessing()
        {
            // parse the data payload to get info for schemas

            // determine the type of event call
            var jsonCollection = _eventObject.GetJsonCollection();

            JObject joEventMap = JObject.Parse(jsonCollection, "eventmap");
            string  calltype   = (joEventMap, ".event.type");

            switch (calltype)
            {
            case "insert":
            {
                /// execute the services first routine
                /// collect the services collection

                var services = joEventMap.SelectToken("event.services");

                foreach (var ea in services.Childres())
                {
                    serviceinfo = new serviceinfo
                    {
                        servicename = (ea, ".servicename"),
                        serviceroute,
                        parentobject,
                        serviceargs,
                        servicetype
                    };

                    string callername = _eventObject.callername;
                    _eventObject.parentObject = serviceinfo.parentobject;
                    returnobject = JSONMapper.Map2Requested_(_eventObject);
                }

                break;
            }

            case "get":
            {
                break;
            }

            case "update":
            {
                break;
            }

            case "delete":
            {
                break;
            }
            }

            return(returnobject);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            // Get the JSON file.

            /*
            ** Let the location of the JSON file if not provided as an argument be the pwd of the program
            ** [REQUIRED] filename has to be -> Quick.json
            */
            string x;

            if (args.Length == 0)
            {
                x = (Directory.GetCurrentDirectory() + "/Quick.json");
            }
            else
            {
                x = args[0];
            }

            /*
            ** Read Quick.json and Parse it.
            */
            JSONParser jParser = new JSONParser();
            var        json    = jParser.JSONFileReader(x);

            /*
            ** Map each JToken to its corresponding RabbitMQ object, for example the ConnectionModel object
            */
            JSONMapper jMapper         = new JSONMapper();
            var        connectionModel = jMapper.BuildConnectionObject(json["ConnectionModel"]);
            var        connection      = GetRabbitConnection(connectionModel);
            var        channel         = GetRabbitChannel(connection);

            var exchangeModel = jMapper.BuildExchangeModel(json["ExchangeModel"]);

            channel = DeclareRabbitExchange(channel, exchangeModel);

            var queueModel = jMapper.BuildQueueModel(json["QueueModel"]);

            channel = DeclareRabbitQueue(channel, queueModel);

            var queueExchangeBindingModel = jMapper.BuildQueueExchangeBindingModel(json["QueueExchangeBindingModel"]);

            channel = CreateQueueExchangeBinding(channel, queueExchangeBindingModel);

            CloseRabbitChannel(channel);
            CloseRabbitConnection(connection);
            Console.Read();
        }
Esempio n. 5
0
 public string ExecuteDataMapping()
 {
     try
     {
         var     jsonCollection = _eventObject.GetJsonCollection();
         JObject joEventMap     = JObject.Parse(jsonCollection.Find(x => x.Key == "eventmap").Value.toString());
         string  orimaryobject  = ((JValue)joEventMap.Selecttoken("definitions.parentobject.jsonobject"));
         string  returnobject   = string.Empty;
         _eventObject.ParentObject = primaryobject;
         returnobject = JSONMapper.Map2Requested_(_eventObject);
         return($"Success-MappingManager.ExecuteDataMapping: {returnobject}");
     }
     catch ()
     {
     }
 }
    // Use this for initialization
    void Start()
    {
                #if UNITY_ANDROID
        MyLibs.InitializeSQLCipher();
                #endif

        if (dataObjects.Length < 1)
        {
            Write("No data to write database!");
            return;
        }

        ORMSQLiteInit.InitSqlite(dbFile, dbDirectory, password);
        Write("Open Database at " + ORMSQLiteInit.pathDB);

        FieldLister lister = new FieldLister();

        Write(dataObjects[0].ToString());
        var info = lister.ListUp <UserData>();

        Write(info.ToString());
        string insert = SQLMaker.GenerateInsertSQL(info, dataObjects[0]);
        string update = SQLMaker.GenerateUpdateSQL(info, dataObjects[0]);

        Write("Insert = {0}", insert);
        Write("Update = {0}", update);

        DBMapper mapper = new DBMapper(ORMSQLiteInit.Evolution.Database);
        mapper.UpdateOrInsertAll(dataObjects);

        UserData[] fromDb = mapper.Read <UserData>("SELECT * FROM UserData;");
        Write(fromDb[0].ToString());
        Write(fromDb[1].ToString());

        JSONMapper jsonMapper = new JSONMapper();
        string     json       = jsonMapper.Write <UserData>(fromDb);
        UserData[] fromJson   = jsonMapper.Read <UserData>(json);

        Write("Json = {0}", json);
        Write(fromJson[0].ToString());
        Write(fromJson[1].ToString());

                #if UNITY_ANDROID
        MyLibs.ToastMessage("SQLCipher Done");
                #endif
    }
Esempio n. 7
0
        /// <summary>
        /// This method is called for every Lambda invocation. This method takes in an S3 event object and can be used
        /// to respond to S3 notifications.
        /// </summary>
        /// <param name="evnt"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <string> FunctionHandler(S3Event evnt, ILambdaContext context)
        {
            var s3Event = evnt.Records?[0].S3;

            if (s3Event == null)
            {
                return(null);
            }

            try
            {
                var response = await this.S3Client.GetObjectAsync(s3Event.Bucket.Name, s3Event.Object.Key);

                JSONMapper.Initialize();
                Console.WriteLine("Starting!");
                Stopwatch stopWatch = Stopwatch.StartNew();
                stopWatch.Start();
                List <KeyValuePair <string, string> > jsonCollection = new List <KeyValuePair <string, string> >();
                string eventPayload = string.Empty;

                using (var stream = response.ResponseStream)
                {
                    TextReader tr = new StreamReader(stream);
                    eventPayload = tr.ReadToEnd();
                    Console.WriteLine("Handler: Got Data from Key");
                }

                EventManager em        = new EventManager(eventPayload);
                var          returnobj = em.ProcessLambdaEvent();
                Console.WriteLine("Enroll Member Time taken: {0}ms", stopWatch.Elapsed.TotalMilliseconds);
                Console.ReadLine();

                return(response.Headers.ContentType);
            }
            catch (Exception e)
            {
                context.Logger.LogLine($"Error getting object {s3Event.Object.Key} from bucket {s3Event.Bucket.Name}. Make sure they exist and your bucket is in the same region as this function.");
                context.Logger.LogLine(e.Message);
                context.Logger.LogLine(e.StackTrace);
                throw;
            }
        }
Esempio n. 8
0
        public async Task <string> GetEventMap(string BucketName, string FileKey)
        {
            IAmazonS3 S3Client = new AmazonS3Client("AKIAIAYIN7WKAGAFBTDA", "zxa+XMi4ORN8sk5cXsqEozq2Q1Wcwac1xOPrkwyB", "EUWest1");
            var       response = await S3Client.GetObjectAsync(BucketName, FileKey);

            JSONMapper.Initialize();
            Console.WriteLine("Starting!");
            Stopwatch stopWatch = Stopwatch.StartNew();

            stopWatch.Start();
            List <KeyValuePair <string, string> > jsonCollection = new List <KeyValuePair <string, string> >();
            string eventPayload = string.Empty;

            using (var stream = response.ResponseStream)
            {
                TextReader tr = new StreamReader(stream);
                eventPayload = tr.ReadToEnd();
                Console.WriteLine("Handler: Got Data from Key");
            }

            return(eventPayload);
        }