示例#1
0
        private async void btnProcessImports_Click(object sender, EventArgs e)
        {
            ImportManager importManager = new ImportManager(txtDataFolderPath.Text);
            importManager.IsSandboxedAPIMode = false;

            ExportType exportType = ExportType.JSON;
            
            if (lstOutputType.SelectedItem.ToString().StartsWith("XML")) exportType = ExportType.XML;
            if (lstOutputType.SelectedItem.ToString().StartsWith("API")) exportType = ExportType.API;
            if (lstOutputType.SelectedItem.ToString().StartsWith("CSV")) exportType = ExportType.CSV;
            if (lstOutputType.SelectedItem.ToString().StartsWith("JSON")) exportType = ExportType.JSON;
            
            importManager.GeonamesAPIUserName = txtGeonamesAPIUserID.Text;
            importManager.ImportUpdatesOnly = chkUpdatesOnly.Checked;

            this.btnProcessImports.Enabled = false;
            this.Cursor = Cursors.WaitCursor;
            
            await importManager.PerformImportProcessing(exportType, txtDataFolderPath.Text, txtAPIIdentifier.Text, txtAPISessionToken.Text, chkFetchLiveData.Checked);
            this.Cursor = Cursors.Default;
            this.btnProcessImports.Enabled = true;
            MessageBox.Show("Processing Completed");

        }
示例#2
0
        static void Main(string[] args)
        {
            bool isAutomaticMode = true;
            bool isAPIImportMode = false;

            string importFolder = "";
            string OCM_API_Identifier = null;
            string OCM_API_SessionToken = null;

            LogEvent("Starting Import:", true);
            if (args.Length > 0)
            {
                LogEvent("Arguments supplied: ");

                for (int i = 0; i < args.Length; i++)
                {
                    string arg = args[i];
                    LogEvent("arg: " + arg);
                    if (arg == "-auto") isAutomaticMode = true;
                    if (arg == "-api") isAPIImportMode = true;
                    //if (arg == "-log") EnableLogging = true;

                    try
                    {
                        if (arg == "-api_identifier")
                        {
                            OCM_API_Identifier = args[i + 1];
                        }

                        if (arg == "-api_sessiontoken")
                        {
                            OCM_API_SessionToken = args[i + 1];
                        }
                    }
                    catch (Exception) { LogEvent("Invalid parameter supplied."); }
                }
            }
            else
            {
                LogEvent("No Arguments supplied.");
            }

            if (isAutomaticMode)
            {
                bool actionPerformed = false;

                ActionType mode = ActionType.ClientTest;

                if (mode == ActionType.DataImport && isAPIImportMode == true && OCM_API_Identifier != null && OCM_API_SessionToken != null)
                {
                    ExportType exportType = ExportType.API;

                    ImportManager importManager = new ImportManager(importFolder);
                    LogEvent("Performing Import, Publishing via API (" + OCM_API_Identifier + ":" + OCM_API_SessionToken + "): " + DateTime.UtcNow.ToShortTimeString());
                    Task<bool> processing = importManager.PerformImportProcessing(exportType, importFolder, OCM_API_Identifier, OCM_API_SessionToken, true);
                    processing.Wait();
                    LogEvent("Import Processed. Exiting. " + DateTime.UtcNow.ToShortTimeString());

                    actionPerformed = true;
                }

                if (mode == ActionType.NetworkServices)
                {
                    //network service polling
                    //OCM.API.NetworkServices.ServiceManager serviceManager = new OCM.API.NetworkServices.ServiceManager();
                    //serviceManager.Test(OCM.API.NetworkServices.ServiceProvider.CoulombChargePoint);
                }

            #if DEBUG
                if (mode ==ActionType.ClientTest)
                {
                    OCMClient client = new OCMClient();
                    client.APITestTiming();
                    actionPerformed = true;
                }
            #endif

                if (!actionPerformed)
                {
                    LogEvent("Nothing to do. Exiting. " + DateTime.UtcNow.ToShortTimeString());
                }
            }
        }