示例#1
0
        public void init()
        {
            try
            {
                if (this.startAutoSync)
                {
                    using (AutoSynchronizeForm form = new AutoSynchronizeForm())
                    {
                        DialogResult result = form.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            if (KbBimstoreApp.autosynchTimer.Enabled)
                            {
                                KbBimstoreApp.autosynchTimer.Stop();
                            }

                            AutoSyncData data = new AutoSyncData();
                            data.AutoSync         = form.AutoSyncOn();
                            data.AutoSave         = form.AutoSaveOn();
                            data.AutoSyncInterval = form.getAutoSyncInerval();
                            data.AutoSaveInterval = form.getAutoSaveInerval();

                            Update(data);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TaskDialog.Show("Exception", ex.Message);
            }

            KbBimstoreApp.hasUserOpenedAutoSyncDialog = true;
        }
示例#2
0
        public static AutoSyncData Deserialize(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(AutoSyncData));
            AutoSyncData  data       = null;

            if (File.Exists(path))
            {
                using (FileStream fs = File.OpenRead(path))
                {
                    data = (AutoSyncData)serializer.Deserialize(fs);
                }
            }

            return(data);
        }
示例#3
0
        public static void Update(AutoSyncData data)
        {
            if (KbBimstoreApp.autosynchTimer.Enabled)
            {
                KbBimstoreApp.autosynchTimer.Stop();
            }

            if (data.AutoSync)
            {
                KbBimstoreApp.autosynchInterval = data.AutoSyncInterval;
                KbBimstoreApp.AutoSync();
                KbBimstoreApp.autosynchTimer.Start();
                KbBimstoreApp.autosynchIsActive = true;
            }
            else if (KbBimstoreApp.autosynchIsActive)
            {
                KbBimstoreApp.autosynchIsActive = false;
            }

            if (data.AutoSave)
            {
                KbBimstoreApp.autoSaveInterval = data.AutoSaveInterval;
                KbBimstoreApp.autoSaveIsActive = true;

                if (!KbBimstoreApp.autosynchIsActive) //don't try to start a running timer
                {
                    KbBimstoreApp.autosynchTimer.Start();
                }
            }
            else if (KbBimstoreApp.autoSaveIsActive)
            {
                KbBimstoreApp.autoSaveIsActive = false;
            }

            KbBimstoreApp.hasUserOpenedAutoSyncDialog = true;

            data.Serialize(KbBimstoreApp.AutoSyncSettingsFilePath);
        }