Exemple #1
0
 private void Closing()
 {
     if (SelectedSession != null)
     {
         SelectedSession.SavePreferences();
     }
 }
Exemple #2
0
 private void PoolingUpdate(object obj)
 {
     App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE
     {
         try
         {
             Session backup = new Session();
             if (FormContext == FormContext.Create)
             {
                 backup.ShallowCopy(SelectedSession);
             }
             UpdateMySessionsList();
             GetAllLecturers();
             //if create mode re-apply props (they were blanking when sub-grid context was different to time
             if (FormContext == FormContext.Create)
             {
                 SelectedSession.ShallowCopy(backup);
             }
             //safe way to get updates to records
             foreach (Session s in MySessions)
             {
                 if (s.Id != SelectedSession.Id)
                 {
                     UnitOfWork.Reload(s);
                 }
             }
         }
         catch (Exception ex)
         {
             ShowFeedback($"Error updating database:\n{ex.Message}", FeedbackType.Error);
         }
     });
 }
        /// <summary>
        /// Add Command used to add items to the blacklist
        /// </summary>
        /// <param name="objToAdd">String word to add to blacklist</param>
        /// <returns></returns>
        public bool Add(object objToAdd)
        {
            if (SelectedSession == null)
            {
                ShowFeedback("No Session selected", FeedbackType.Info);
                return(false);
            }

            try
            {
                string wordToAdd = objToAdd as string;
                string feedback  = "";
                //set new blacklist and update the VM collection
                bool result = SelectedSession.AddToBlacklist(UnitOfWork, wordToAdd, ref feedback);
                BlacklistList = new ObservableCollection <string>(SelectedSession.Blacklist.Split(' '));
                CommonPhrases = SelectedSession.CalcCommonPhraseIdentification();
                //show appropriate feedback
                if (result)
                {
                    ShowFeedback($"{wordToAdd} added to blacklist.", FeedbackType.Success);
                    return(true);
                }
                else
                {
                    ShowFeedback(feedback, FeedbackType.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ShowFeedback(ex.Message, FeedbackType.Error);
                return(false);
            }
        }
 /// <summary>
 /// Remove command used to remove items from blacklist
 /// </summary>
 /// <param name="objToRemove">String word to remove from blacklist</param>
 /// <returns></returns>
 public bool Remove(object objToRemove)
 {
     if (SelectedSession == null)
     {
         ShowFeedback("No Session selected", FeedbackType.Info);
         return(false);
     }
     try
     {
         string wordToRemove = objToRemove as string;
         string feedback     = "";
         bool   result       = SelectedSession.RemoveFromBlacklist(UnitOfWork, wordToRemove, ref feedback);
         BlacklistList = new ObservableCollection <string>(SelectedSession.Blacklist.Split(' '));
         CommonPhrases = SelectedSession.CalcCommonPhraseIdentification();
         if (result)
         {
             ShowFeedback($"{wordToRemove} Removed from blacklist.", FeedbackType.Success);
             return(true);
         }
         else
         {
             ShowFeedback(feedback, FeedbackType.Error);
             return(false);
         }
     }
     catch (Exception ex)
     {
         ShowFeedback(ex.Message, FeedbackType.Error);
         return(false);
     }
 }
 public Dictionary <string, int> KeyWordsAPI()
 {
     try
     {
         return(SelectedSession.CalcKeyWordsAPI());
     }
     catch (Exception ex)
     {
         ShowFeedback(ex.Message, FeedbackType.Error);
         return(null);
     }
 }
Exemple #6
0
 private void btMonitorAction_Click(object sender, EventArgs e)
 {
     // check mac address
     if (SelectedSession == null || SelectedSession.State != ConnectionState.Connected)
     {
         return;
     }
     // check sender
     if (sender == btStartMonitor)
     {
         SelectedSession.SetEventMonitor();
     }
     else if (sender == btStopMonitor)
     {
         SelectedSession.SetEventMonitor(4015, 0);
     }
 }
Exemple #7
0
        public override bool Save()
        {
            ClearFeedback();
            bool result;

            try
            {
                if (FormContext == FormContext.Create)
                {
                    //Create New
                    result = User.AddNewSession(SelectedSession, UnitOfWork);
                    if (result)
                    {
                        UpdateMySessionsList();
                        ChangeSubgridContext(SubgridContext);
                        ShowFeedback($"Successfully created session: {SelectedSession.Id}.", FeedbackType.Success);
                    }
                    else
                    {
                        ShowFeedback($"Failed to create session. please try again or contact support.", FeedbackType.Error);
                    }
                    return(result);
                }
                else
                {
                    //Update
                    result = SelectedSession.ValidateSession(UnitOfWork);
                    if (result)
                    {
                        UnitOfWork.Complete();
                        ShowFeedback($"Successfully updated session: {SelectedSession.Id}.", FeedbackType.Success);
                    }
                    else
                    {
                        ShowFeedback($"Failed to update session: {SelectedSession.Id}.", FeedbackType.Error);
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                ShowFeedback(ex.GetBaseException().Message, FeedbackType.Error);
                return(false);
            }
        }
Exemple #8
0
        private void timer_Tick(object sender, EventArgs e)
        {
            var scanned    = HCommAir.GetScannedTools();
            var registered = HCommAir.GetRegisteredTools();

            // check scanned tools count
            if (scanned.Count != ScanTools.Count)
            {
                // clear scanned tools item
                ScanTools.Clear();
                // add item list
                foreach (var info in scanned)
                {
                    // add
                    ScanTools.Add(info);
                }
                // refresh
                lbScannedTools.Refresh();
            }
            // check registered tools count
            if (registered.Count != RegisterTools.Count)
            {
                // clear register tools item
                RegisterTools.Clear();
                // add item list
                foreach (var info in registered)
                {
                    // add
                    RegisterTools.Add(info);
                }
                // refresh
                lbRegisteredTools.Refresh();
            }
            // check graph state
            if (!GraphState || SelectedSession == null || SelectedSession.State != ConnectionState.Connected ||
                !((DateTime.Now - GraphTime).TotalSeconds > 5))
            {
                return;
            }
            // set
            SelectedSession.SetGraph();
            // reset time
            GraphTime = DateTime.Now;
        }
Exemple #9
0
 private void btGraphAction_Click(object sender, EventArgs e)
 {
     // check selected session
     if (SelectedSession == null || SelectedSession.State != ConnectionState.Connected)
     {
         return;
     }
     // check sender
     if (sender == btGraphSet)
     {
         // check state
         if (GraphState)
         {
             return;
         }
         // get graph setting
         var ch1      = (ushort)cbCh1.SelectedIndex;
         var ch2      = (ushort)cbCh2.SelectedIndex;
         var sampling = (ushort)cbSampling.SelectedIndex;
         var option   = (ushort)cbOption.SelectedIndex;
         // set graph setting
         SelectedSession.SetParam(4101, ch1);
         SelectedSession.SetParam(4102, ch2);
         SelectedSession.SetParam(4103, sampling);
         SelectedSession.SetParam(4104, option);
     }
     else if (sender == btGraphStart)
     {
         GraphState = true;
     }
     else if (sender == btGraphStop)
     {
         // stop
         SelectedSession.SetGraph(4100, 0);
         // reset state
         GraphState = false;
     }
 }
Exemple #10
0
        private void btParamAction_Click(object sender, EventArgs e)
        {
            // check selected session
            if (SelectedSession == null || SelectedSession.State != ConnectionState.Connected)
            {
                return;
            }
            // get info
            var addr  = Convert.ToUInt16(nmAddr.Value);
            var count = Convert.ToUInt16(nmCount.Value);

            // check sender
            if (sender == btGetParam)
            {
                // get param
                SelectedSession.GetParam(addr, count);
            }
            else if (sender == btSetParam)
            {
                // set param
                SelectedSession.SetParam(addr, count);
            }
        }