Exemplo n.º 1
0
        private void readRegistry()
        {
            CMSettings  cmSettings  = ConnectionSettingsManager.GetCMSettings();
            CRMSettings crmSettings = ConnectionSettingsManager.GetCRMSettings();
            int         refreshRate = ServiceSettingsManager.GetRefreshRate();

            if (cmSettings != null)
            {
                CMUserName.Text     = cmSettings.UserName;
                CMPassword.Password = cmSettings.Password;
                CMApiKey.Text       = cmSettings.ApiKey;
            }
            if (crmSettings != null)
            {
                CRMUserName.Text     = crmSettings.UserName;
                CRMPassword.Password = crmSettings.Password;
                CRMDomain.Text       = crmSettings.Domain;
                CRMUrl.Text          = crmSettings.Url;
                if (crmSettings.ProtocolSSH)
                {
                    CRMProtocol.SelectedIndex = 1;
                }
                else
                {
                    CRMProtocol.SelectedIndex = 0;
                }
            }

            RefreshRate.Text = refreshRate.ToString();
        }
Exemplo n.º 2
0
        void SyncList()
        {
            //delete this sleep time
            Thread.Sleep(30000);

            while (true)
            {
                //Read refresh rate from registry
                try
                {
                    refreshRate = Convert.ToInt64(ServiceSettingsManager.GetRefreshRate()); //In minut
                    if (refreshRate == 0)
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    refreshRate = 2;
                }
                refreshRate = refreshRate * 60000;
                Stopwatch watch = Stopwatch.StartNew();

                try
                {
                    syncCrmCm = new SyncCrmCm();
                    syncCrmCm.Sync();
                }
                catch (Exception e)
                {
                    EventLogManager.WriteMessage(new Message()
                    {
                        Description = e.Message.ToString(), System = "Sync", Time = DateTime.Now
                    }, EventType.Error);
                }
                watch.Stop();
                long elapsedMs   = watch.ElapsedMilliseconds;
                long timeToSleep = refreshRate - elapsedMs;
                if (timeToSleep > 0)
                {
                    Thread.Sleep(Convert.ToInt32(timeToSleep));
                }
            }
        }