Example #1
0
 public ServiceResult <Article> Delete(int id)
 {
     try
     {
         string role = ApiGlobal.GetRole(HttpContext);
         _articleService.Delete(_articleService.GetById(id));
         return(new ServiceResult <Article>()
         {
             IsSucces = true
         });
     }
     catch (Exception ex)
     {
         return(new ServiceResult <Article>()
         {
             IsSucces = false, Message = ex.Message
         });
     }
 }
Example #2
0
 public ServiceResult <Article> Put([FromBody] Article article)
 {
     try
     {
         string role = ApiGlobal.GetRole(HttpContext);
         _articleService.Update(article);
         return(new ServiceResult <Article>()
         {
             IsSucces = true
         });
     }
     catch (Exception ex)
     {
         return(new ServiceResult <Article>()
         {
             IsSucces = false, Message = ex.Message
         });
     }
 }
Example #3
0
        /// <summary>
        /// Fills the ListView with information on the current session and run.
        /// </summary>
        private void GetRunInformation()
        {
            DateTime st_time = new DateTime(1970, 1, 1, 0, 0, 0);

            st_time = st_time.AddSeconds(_currentRun.StartTime);
            DateTime end_time = new DateTime(1970, 1, 1, 0, 0, 0);

            end_time = end_time.AddSeconds(_currentRun.EndTime);
            TimeSpan duration = end_time - st_time;

            //  Console.WriteLine(st_time +" "+ _currentRun.StartTime);
            //  Console.WriteLine(end_time);
            //   Console.WriteLine(duration);

            infoView.Items.Add("Scenario name").SubItems.Add(_currentRun.Scenario);
            infoView.Items.Add("Result name").SubItems.Add(_currentRun.Name);
            infoView.Items.Add("Duration").SubItems.Add(duration.ToString());
            infoView.Items.Add("Graphs count in session").SubItems.Add(_currentRun.Graphs.Count.ToString());
            infoView.Items.Add("Total graphs count").SubItems.Add(
                ApiGlobal.GetInstance().GraphNames.Count.ToString());
            infoView.Items.Add("Session file name").SubItems.Add(
                _currentSession.Name);
        }
Example #4
0
        /// <summary>
        /// 为单独的 <seealso cref="ApiGlobal"/> 初始化事件列表
        /// </summary>
        /// <param name="global"></param>
        private void InitEvent(ApiGlobal global)
        {
            var methods = global.GetType().GetRuntimeMethods().ToArray();
            var ot      = typeof(ApiGlobal);
            var args    = new[] { typeof(ApiEventArgs) };

            foreach (GlobalEvents e in Enum.GetValues(typeof(GlobalEvents)))
            {
                var m = methods.FirstOrDefault(it => it.Name == e.ToString() && IsOverrided(it));
                if (m == null)
                {
                    continue;
                }
                var ev = _events[(int)e];
                if (ev == null)
                {
                    _events[(int)e] = (Action <ApiEventArgs>)m.CreateDelegate(typeof(Action <ApiEventArgs>), global);
                }
                else
                {
                    _events[(int)e] = ev + (Action <ApiEventArgs>)m.CreateDelegate(typeof(Action <ApiEventArgs>), global);
                }
            }
        }