private IConnector getHubSpotConnector(CRMSoftware software)
        {
            IConnector returnValue = null;

            if (software == CRMSoftware.SAGECRM)
            {
                returnValue = new SageCRMConnector();
            }
            else if (software == CRMSoftware.SALESLOGIX)
            {
                returnValue = new SalesLogixConnector();
            }
            // MHM Added
            else if (software == CRMSoftware.GOLDMINE)
            {
                returnValue = new GMConnector();
            }
            //***********
            else
            {
                //We have a problem
            }

            return returnValue;
        }
示例#2
0
        public static void Main(string[] args)
        {
            //Call to log4net.Config.BasicConfigurator.Configure() is required otherwise you will get no logging data
            log4net.Config.BasicConfigurator.Configure();

            //Write the default log header
            ULogging.writeToInfoLog(AppGlobal.getAppLogger(), "PROCESS STARTED AT " + DateTime.Now + " (Log Level = " + ULogging.getLogLevel() + ")");
            ULogging.writeToInfoLog(AppGlobal.getAppLogger(), "");

            string validConfig = UConfig.validateConfig();

            if (args.Length > 0)  // If we have args then see if they are valid and run appropriate processes.
            {
                if (args[0].Trim().Equals("configure", StringComparison.OrdinalIgnoreCase) == true)
                {
                    Application.EnableVisualStyles();  // Standard Windows Housekeeping
                    Application.SetCompatibleTextRenderingDefault(false);  // Standard Windows Housekeeping
                    Application.Run(new ConfigurationForm());  // Run instance of Configuration Form

                    Application.Exit();

                    writeClosingLogEntry();
                }

                if (args[0].Trim().Equals("configure", StringComparison.OrdinalIgnoreCase) == false)
                {
                    // Command line argument DOES NOT EQUAL "configure"

                    string crmSoftware = UConfig.getAppConfigValue("CRMSoftware", false);
                    IConnector crmConnector = null;

                    if (crmSoftware.Trim().ToUpper().Equals("SALESLOGIX") == true)
                    {
                        crmConnector = new SalesLogixConnector();
                    }
                    else if (crmSoftware.Trim().ToUpper().Equals("SAGECRM") == true)
                    {
                        crmConnector = new SageCRMConnector();
                    }
                    else if (crmSoftware.Trim().ToUpper().Equals("MSCRMONLINE2011") == true)
                    {
                        crmConnector = new MSCRMOnline2011Connector();
                    }
                    // MHM Added
                    else if (crmSoftware.Trim().ToUpper().Equals("GOLDMINE") == true)
                    {
                        crmConnector = new GMConnector();
                    }
                    // *********
                    else
                    {
                        //Exit out
                        ULogging.writeToDebugLog(AppGlobal.getAppLogger(), "Invalid CRM Software Application - " + crmSoftware);
                        writeClosingLogEntry();

                        return;
                    }

                    if (args[0].Trim().Equals("ui", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new HubSpotIntegrationForm());

                        Application.Exit();

                        writeClosingLogEntry();
                    }

                    if (args[0].Trim().Equals("run", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        //***** MHM Contacts – Replaced *****//
                        //crmConnector.getHubSpotLeads();
                        crmConnector.getHubSpot();
                        //***** MHM Contacts ****************//

                        //crmConnector.setLastHubSpotPullDateTime();

                        crmConnector.pushHubSpotLeadsToCRM();
                        if (bool.Parse(UConfig.getAppConfigValue("PushChangesToHubSpot", false)))
                        {
                            //crmConnector.pushLeadChangesToHubSpot();
                            crmConnector.pushContactChangesToHubSpot();
                        }
                        //crmConnector.pushLeadChangesToHubSpot();

                        writeClosingLogEntry();
                        //Add code to exit
                    }

                    if (args[0].Trim().Equals("stage", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        //***** MHM Contacts – Replaced *****//
                        //int ret = crmConnector.getHubSpotLeads();
                        int ret = crmConnector.getHubSpot();
                        //***** MHM Contacts ****************//

                        //crmConnector.setLastHubSpotPullDateTime();

                        writeClosingLogEntry();
                        //Add code to exit
                    }

                    if (args[0].Trim().Equals("crm", StringComparison.OrdinalIgnoreCase) == true)
                    {
                        int ret = crmConnector.pushHubSpotLeadsToCRM();
                        if (bool.Parse(UConfig.getAppConfigValue("PushChangesToHubSpot", false)))
                        {
                            //crmConnector.pushLeadChangesToHubSpot();
                            crmConnector.pushContactChangesToHubSpot();
                        }
                        //crmConnector.pushLeadChangesToHubSpot();

                        writeClosingLogEntry();
                        //Add code to exit
                    }
                }
            }
            else
            {
                StringBuilder sb = new StringBuilder();

                sb.Append("HubSpot Integration Switches\n\r");
                sb.Append("Switches can only be used one at a time and not together\n\r");
                sb.Append("\tconfigure - Shows the HubSpot configuration form\n\r");
                sb.Append("\tui - Shows the HubSpot Integration form\n\r");
                sb.Append("\tstage - Runs only the staging portion of the integration\n\r");
                sb.Append("\tcrm - Runs only the CRM portion of the integration\n\r");
                sb.Append("\trun - Runs the staging and CRM portions of the integration in that order\n\r");

                Console.Write(sb.ToString());
            }
        }