예제 #1
0
        internal static int SyncPortalKeysToBulkDataFile(string connectionString, string bulkLoadFilePath)
        {
            try
            {
                List <KeyDataObject> featureKeyList = new List <KeyDataObject>();
                if (DataBaseOperations.GetFeaturesForPortalRev(connectionString, out featureKeyList) != 0)
                {
                    return(8);
                }

                if (!TextOperations.WriteBuklLoadFeatureFile(bulkLoadFilePath, featureKeyList, null))
                {
                    return(4);
                }
            }
            catch (Exception e)
            {
                Console.Write("Error, key list could not be deserialized: ", e.Message);
                {
                    return(8);
                }
            }

            return(0);
        }
예제 #2
0
        ////////////////////////////////////////////////////////////
        // Return codes:
        // 0 - success
        // 1 - bad command line - error parsing
        // 2 - disply help
        // 3 - static csv file not found or could not be read
        // 4 - error writing build data key file
        // 5 - key list deserialization error
        // 6 - DB error
        // 7 - Error getting current database version
        // 8 - Error syncing builk data file from DB
        ////////////////////////////////////////////////////////////
        static int Main(string[] args)
        {
#if DEBUG
            Debugger.Launch();
#endif
            var serializer = new JavaScriptSerializer();

            // command line options
            CommandLineOptions cmdLineOpts = new CommandLineOptions();

            List <string> extra;
            var           commandLineWasProcessed = ProcessCommandLineOpts(args, cmdLineOpts);

            // Show help if the option was passed or there was a problem processing command line args
            if (cmdLineOpts.show_help || !commandLineWasProcessed)
            {
                Help.ShowHelp(cmdLineOpts.optionSet, serializer);
                return(2);
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // Return true/false based on if the specified portal has had keys written to it already
            ////////////////////////////////////////////////////////////////////////////////////////////////////
            if (!string.IsNullOrEmpty(cmdLineOpts.portalConnectionString) && cmdLineOpts.hasKeys)
            {
                if (cmdLineOpts.useBase64Encoding)
                {
                    cmdLineOpts.portalConnectionString = TextOperations.GetConnectionStringFromB64(cmdLineOpts.portalConnectionString);
                }

                var ret = DataBaseOperations.DatabaseKeysExist(cmdLineOpts.portalConnectionString);
                var serializedResult = serializer.Serialize(ret);
                Console.WriteLine(serializedResult);
                return(0);
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // Retrieve the illuminated feature keys from the database  - return json keys list
            ////////////////////////////////////////////////////////////////////////////////////////////////////
            if (!string.IsNullOrEmpty(cmdLineOpts.portalConnectionString) && cmdLineOpts.getfeaturekeys)
            {
                if (cmdLineOpts.useBase64Encoding)
                {
                    cmdLineOpts.portalConnectionString = TextOperations.GetConnectionStringFromB64(cmdLineOpts.portalConnectionString);
                }

                List <string> featuresList;
                var           ret = DataBaseOperations.GetIlluminatedFeatures(cmdLineOpts.portalConnectionString, out featuresList);
                var           serializedResult = serializer.Serialize(featuresList);
                Console.WriteLine(serializedResult);
                return(ret);
            }


            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // Retrieve the keys from the static csv file and return them as a string in the a kvp Json form.
            ////////////////////////////////////////////////////////////////////////////////////////////////////
            if ((!string.IsNullOrEmpty(cmdLineOpts.pathToSqlFile)) || (cmdLineOpts.useDefaultKeyFile))
            {
                string serializedResult;
                int    ret = Operations.HandleStaticSqlFile(cmdLineOpts, serializer, out serializedResult);
                Console.WriteLine(serializedResult);
                return(ret);
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // Generate bulk load data file for insertion into database based on selected feature keys
            ////////////////////////////////////////////////////////////////////////////////////////////////////
            if ((!string.IsNullOrEmpty(cmdLineOpts.pathToBulkDataKeyFile)) && (!string.IsNullOrEmpty(cmdLineOpts.featureLaunchKeys) || !string.IsNullOrEmpty(cmdLineOpts.featureLaunchKeysPath)))
            {
                return(Operations.WriteBuklLoadFeatureFile(args, cmdLineOpts, serializer));
            }
            else if ((!string.IsNullOrEmpty(cmdLineOpts.pathToBulkDataKeyFile)) && (!string.IsNullOrEmpty(cmdLineOpts.portalConnectionString)))
            {
                //////////////////////////////////////////////////////////////////////////////////////////////////////
                /// This case is responsible for getting the extended dark launch keys out of the portal
                /// and writing them to the bulk data file for the case - essentially sync up the keys for the case.
                /////////////////////////////////////////////////////////////////////////////////////////////////////
                return(Operations.SyncPortalKeysToBulkDataFile(cmdLineOpts.portalConnectionString, cmdLineOpts.pathToBulkDataKeyFile));
            }
            else if (cmdLineOpts.testMode && (string.IsNullOrEmpty(cmdLineOpts.featureLaunchKeys)))
            {
                // Simple mode used for testing
                var darkLaunchKeysList = MockData.GenerateMockFeatureLaunchKeysList();
                var serializedResult   = serializer.Serialize(darkLaunchKeysList);
                Console.WriteLine(serializedResult);

                return(0);
            }
            else
            {
                Help.ShowHelp(cmdLineOpts.optionSet, serializer);
                return(0);
            }
        }