예제 #1
0
        private void SaveInputData(string id)
        {
            CurrentProfile.id = IdTextBox.Text;

            if (ProfileDictionary.ContainsKey(id))
            {
                ProfileDictionary[id] = CurrentProfile;
            }
            else
            {
                ProfileDictionary.Add(id, CurrentProfile);
            }

            var writer = new XmlSerializer(typeof(Profiles));
            var xmlDoc = new XmlDocument();

            using (var memStr = new MemoryStream())
            {
                writer.Serialize(memStr, new Profiles {
                    profile = ProfileDictionary.Values.ToArray()
                });
                memStr.Position = 0;
                xmlDoc.Load(memStr);
            }

            xmlDoc.Save(ProfilesLocation);
        }
        public ProfileSelectionPage(ProfileDictionary ProEngine)
        {
            InitializeComponent();

            profilesList.Items.Clear();

            profilesList.ItemsSource = ProEngine.PlainCollection;

            profilesList.Items.Refresh();

            if (profilesList.Items.Count > 0)
            {
                profilesList.SelectedIndex = 0;
            }

            //для возможности развязать по времени поиск профилей по части его имени от визуализации результата этого поиска
            m_ActionQueue = new ConcurrentQueue <Action>();
            TimerForFound = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 2000)
            };
            TimerForFound.Tick     += OnTimerForFoundTick;
            TimerForFound.IsEnabled = false;

            //настраиваем таймер, который будет использоваться при синхронизации выбранного профиля
            TimerSyncSelectedProfile = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 2500)
            };
            TimerSyncSelectedProfile.Tick     += OnTimerSyncSelectedProfileTick;
            TimerSyncSelectedProfile.IsEnabled = false;
        }
예제 #3
0
        public static void LoadProfile(List <MyProfile> profiles)
        {
            var dictionary = new ProfileDictionary(profiles.Select(m => m.ToProfile()));

            Cache.Main.IsProfilesParsed = true;

//            Cache.ProfileEdit = new ProfilePage(dictionary);
//            Cache.ProfileSelection = new ProfileSelectionPage(dictionary);
//            Cache.ProfileSelection.SetNextButtonVisibility(Cache.Main.Param);
        }
예제 #4
0
        public static void ImportProfilesFromDb()
        {
            var seviceConnected = false;
            List<ProfileItem> profileItems;
            try
            {
                profileItems = Cache.Net.GetProfilesFromServerDb(Cache.Main.MmeCode);
                Cache.Main.State = "online";
                seviceConnected = true;
            }
            catch (CommunicationObjectFaultedException)
            {
                profileItems = Cache.Net.GetProfilesFromLocalDb(Cache.Main.MmeCode, ref seviceConnected);
                Cache.Main.State = "offline";
            }

            if (profileItems == null || profileItems.Count <= 0 && !seviceConnected)
                return;
            if (profileItems.Count <= 0)
            {
                var dialog = new DialogWindow("Сообщение", "Нет активных профилей");
                dialog.ButtonConfig(DialogWindow.EbConfig.OK);
                dialog.ShowDialog();
            }

            var profiles = new List<Profile>();
            foreach (var profileItem in profileItems)
            {

                var profile = new Profile(profileItem.ProfileName, profileItem.ProfileKey, profileItem.ProfileTS)
                {
                    IsHeightMeasureEnabled = profileItem.IsHeightMeasureEnabled,
                    ParametersClamp = profileItem.ParametersClamp,
                    Height = profileItem.Height,
                    Temperature = profileItem.Temperature
                };

                foreach (var g in profileItem.GateTestParameters) profile.TestParametersAndNormatives.Add(g);
                foreach (var b in profileItem.BVTTestParameters) profile.TestParametersAndNormatives.Add(b);
                foreach (var v in profileItem.VTMTestParameters) profile.TestParametersAndNormatives.Add(v);
                foreach (var d in profileItem.DvDTestParameterses) profile.TestParametersAndNormatives.Add(d);


                profiles.Add(profile);
            }
            var dictionary = new ProfileDictionary(profiles);
            Cache.Main.IsProfilesParsed = true;

            Cache.ProfileEdit = new ProfilePage(dictionary);
            Cache.ProfileSelection = new ProfileSelectionPage(dictionary);
            Cache.ProfileSelection.SetNextButtonVisibility(Cache.Main.Param);
        }
        public ProfileSelectionPage(ProfileDictionary ProEngine)
        {
            InitializeComponent();

            profilesList.Items.Clear();

            profilesList.ItemsSource = ProEngine.PlainCollection;

            profilesList.Items.Refresh();

            if (profilesList.Items.Count > 0)
            {
                profilesList.SelectedIndex = 0;
            }
        }
예제 #6
0
        //private bool Renamed = false;

        public ProfilePage(ProfileDictionary Engine)
        {
            InitializeComponent();

            m_ProfileEngine = Engine;

            profilesList.SetBinding(ItemsControl.ItemsSourceProperty,
                                    new Binding {
                ElementName = "profilePage", Path = new PropertyPath("ProfileItems")
            });

            if (profilesList.Items.Count > 0)
            {
                profilesList.SelectedIndex = 0;
            }

            InitFilter();
        }
예제 #7
0
        public void ImportProfiles(string filePath)
        {
            var dictionary   = new ProfileDictionary(filePath);
            var profileList  = dictionary.PlainCollection.ToList();
            var profileItems = new List <ProfileItem>(profileList.Count);

            foreach (var profile in profileList)
            {
                var profileItem = new ProfileItem
                {
                    ProfileName            = profile.Name,
                    ProfileKey             = profile.Key,
                    ProfileTS              = profile.Timestamp,
                    GateTestParameters     = new List <Types.Gate.TestParameters>(),
                    VTMTestParameters      = new List <Types.VTM.TestParameters>(),
                    BVTTestParameters      = new List <Types.BVT.TestParameters>(),
                    DvDTestParameterses    = new List <Types.dVdt.TestParameters>(),
                    ATUTestParameters      = new List <Types.ATU.TestParameters>(),
                    QrrTqTestParameters    = new List <Types.QrrTq.TestParameters>(),
                    TOUTestParameters      = new List <Types.TOU.TestParameters>(),
                    CommTestParameters     = profile.ParametersComm,
                    IsHeightMeasureEnabled = profile.IsHeightMeasureEnabled,
                    ParametersClamp        = profile.ParametersClamp,
                    Height      = profile.Height,
                    Temperature = profile.Temperature
                };
                foreach (var baseTestParametersAndNormativese in profile.TestParametersAndNormatives)
                {
                    var gate = baseTestParametersAndNormativese as Types.Gate.TestParameters;
                    if (gate != null)
                    {
                        profileItem.GateTestParameters.Add(gate);
                        continue;
                    }
                    var sl = baseTestParametersAndNormativese as Types.VTM.TestParameters;
                    if (sl != null)
                    {
                        profileItem.VTMTestParameters.Add(sl);
                        continue;
                    }
                    var bvt = baseTestParametersAndNormativese as Types.BVT.TestParameters;
                    if (bvt != null)
                    {
                        profileItem.BVTTestParameters.Add(bvt);
                    }

                    var dvdt = baseTestParametersAndNormativese as Types.dVdt.TestParameters;
                    if (dvdt != null)
                    {
                        profileItem.DvDTestParameterses.Add(dvdt);
                    }

                    var atu = baseTestParametersAndNormativese as Types.ATU.TestParameters;
                    if (atu != null)
                    {
                        profileItem.ATUTestParameters.Add(atu);
                    }

                    var qrrTq = baseTestParametersAndNormativese as Types.QrrTq.TestParameters;
                    if (qrrTq != null)
                    {
                        profileItem.QrrTqTestParameters.Add(qrrTq);
                    }

                    var tou = baseTestParametersAndNormativese as Types.TOU.TestParameters;
                    if (tou != null)
                    {
                        profileItem.TOUTestParameters.Add(tou);
                    }
                }
                profileItems.Add(profileItem);
            }
            if (State == ConnectionState.Open)
            {
                _profilesService.SaveProfiles(profileItems);
            }
        }
예제 #8
0
        public static void ImportProfilesFromDb()
        {
            bool seviceConnected;

            List <ProfileItem> profileItems;

            profileItems = Cache.Net.GetProfilesFromLocalDb(Cache.Main.VM.MmeCode, out seviceConnected);

            if (profileItems == null || profileItems.Count <= 0 && !seviceConnected)
            {
                return;
            }

            if (profileItems.Count <= 0)
            {
                var dialog = new DialogWindow("Сообщение", "Нет активных профилей");
                dialog.ButtonConfig(DialogWindow.EbConfig.OK);
                dialog.ShowDialog();
            }

            var profiles = new List <Profile>();

            foreach (var profileItem in profileItems)
            {
                var profile = new Profile(profileItem.ProfileName, profileItem.ProfileKey, profileItem.Version, profileItem.ProfileTS)
                {
                    Key = profileItem.ProfileKey,
                    NextGenerationKey      = Guid.NewGuid(),
                    IsHeightMeasureEnabled = profileItem.IsHeightMeasureEnabled,
                    ParametersClamp        = profileItem.ParametersClamp,
                    Height      = profileItem.Height,
                    Temperature = profileItem.Temperature
                };

                foreach (var g in profileItem.GateTestParameters)
                {
                    profile.TestParametersAndNormatives.Add(g);
                }
                foreach (var b in profileItem.BVTTestParameters)
                {
                    profile.TestParametersAndNormatives.Add(b);
                }
                foreach (var v in profileItem.VTMTestParameters)
                {
                    profile.TestParametersAndNormatives.Add(v);
                }
                foreach (var d in profileItem.DvDTestParameterses)
                {
                    profile.TestParametersAndNormatives.Add(d);
                }
                foreach (var a in profileItem.ATUTestParameters)
                {
                    profile.TestParametersAndNormatives.Add(a);
                }
                foreach (var q in profileItem.QrrTqTestParameters)
                {
                    profile.TestParametersAndNormatives.Add(q);
                }
                foreach (var t in profileItem.TOUTestParameters)
                {
                    profile.TestParametersAndNormatives.Add(t);
                }

                profiles.Add(profile);
            }

            var dictionary = new ProfileDictionary(profiles);

            Debug.Assert(Cache.Main.Dispatcher != null, "Cache.Main.Dispatcher != null");
//            Cache.Main.Dispatcher.BeginInvoke(new Action(() =>
//            {
//                Cache.Main.IsProfilesParsed = true;
//
//                Cache.ProfileEdit = new ProfilePage(dictionary);
//                Cache.ProfileSelection = new ProfileSelectionPage(dictionary);
//                Cache.ProfileSelection.SetNextButtonVisibility(Cache.Main.Param);
//            }));
        }