示例#1
0
        public InitResults Init(string ip, string Catalog, string username, string password, int pcid, string empName, string empPass)
        {
            ActivityLogService.Logger.LogFunctionCall();
            string connBackup = "";

            try
            {
                UserData user;
                ConnectionService.StoresConn = connBackup = ConnectionService.CreateConnectionString(ip, username, password, Catalog);
                if ((user = DBService.GetService()
                            .GetUserData(empName, empPass)) != null)
                {
                    User = user;
                    PCID = pcid;
                    ActivityLogService.Logger.LogMessage("initiated succssfully, Module version: " + Version);
                    return(InitResults.Success);
                }
                ActivityLogService.Logger.LogMessage("Login failed!");
                return(InitResults.F_Credentials);
            }
            catch (Exception ex)
            {
                ActivityLogService.Logger.LogError(ex);
                if (connBackup != "")
                {
                    ConnectionService.StoresConn = connBackup;
                }
                return(InitResults.F_Unhandled);
            }
        }
        public void ParsePartOfFolder(int numberOfParallelizations, int filesCount, int part, int numberOfFilesPerPart,
                                      string[] filesInDirectory, Action <string, MySqlConnection> parser, Stopwatch stopwatch)
        {
            var abortCondition = (part == numberOfParallelizations) ? filesCount : part * numberOfFilesPerPart; // to ensure we get the last files, that otherwise would remain due to rounding

            for (int fileIndex = (part - 1) * numberOfFilesPerPart; fileIndex < abortCondition; fileIndex++)
            {
                var filePath = filesInDirectory[fileIndex];
                Console.WriteLine($"Start parsing file: {filePath}");
                var jsonRaw = ReadFile(filePath);
                jsonRaw = jsonRaw.Replace("'", "''");

                var connectionString = ConnectionService.CreateConnectionString("127.0.0.1", "root", "pass", "meetup");

                // each threads needs his own mysql connection
                using (ConnectionService connectionService = new ConnectionService(connectionString))
                {
                    parser(jsonRaw, connectionService.Connection);
                }
                ParsedFilesCount++;
                Console.WriteLine($"Finished parsing file: {ParsedFilesCount}/{filesCount} after {stopwatch.Elapsed.Minutes} minutes");
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            var connectionString = ConnectionService.CreateConnectionString("127.0.0.1", "root", "pass");

            using (ConnectionService connectionService = new ConnectionService(connectionString))
            {
                var dbCreationService = new CreationService(connectionService.Connection, "meetup");
                var dbSeedService     = new SeedService(connectionService.Connection);
            }

            // ########## scenario 1: website ##########

            // list all groups:         SELECT g.id, g.name FROM `group` AS g
            // list a certain group:    SELECT * FROM `group` AS g WHERE g.id = 973292;

            // list all events:         SELECT g.id, g.name FROM `group` AS g LIMIT 1000;
            // list a certain event:    SELECT * FROM event AS e WHERE e.id = 8627496;


            // ########## scenario 2: visualization  ##########

            // rsvps of a single group  (0.047s)

            /*
             *  SELECT g.name, YEAR(e.created), MONTH(e.created), SUM(e.yes_rsvp_count)
             *  FROM event AS e
             *  JOIN `group` AS g ON g.id = e.group_id
             *  WHERE e.group_id = 6510
             *  GROUP BY YEAR(e.created), MONTH(e.created);
             */

            // rsvps of all groups  (347s)

            /*
             *  SELECT g.name, YEAR(e.created), MONTH(e.created), SUM(e.yes_rsvp_count)
             *  FROM event AS e
             *  JOIN `group` AS g ON g.id = e.group_id
             *  GROUP BY g.id, YEAR(e.created), MONTH(e.created);
             */


            // rsvps of a single category (20s)  // moving around the join order does not improve query time ... obviously the database is optimizing the query for us

            /*
             *  SELECT c.shortname, YEAR(e.created), MONTH(e.created), SUM(e.yes_rsvp_count)
             *  FROM event AS e
             *  JOIN `group` AS g ON g.id = e.group_id
             *  JOIN `category` AS c ON c.id = g.category_id
             *  WHERE c.id = 9
             *  GROUP BY c.id, YEAR(e.created), MONTH(e.created);
             */

            // rsvps of a all categories (260s)

            /*
             *  SELECT c.shortname, YEAR(e.created), MONTH(e.created), SUM(e.yes_rsvp_count)
             *  FROM event AS e
             *  JOIN `group` AS g ON g.id = e.group_id
             *  JOIN `category` AS c ON c.id = g.category_id
             *  GROUP BY c.Id, YEAR(e.created), MONTH(e.created)
             *
             */

            Console.ReadLine();  // prevents application from closing
        }