Пример #1
0
        protected void SaveSystemDate()
        {
            string oldSystemDateString = DataContext.SystemValues.Where(sv => sv.Name == "SystemDate").FirstOrDefault().Value;

            DateTime newDate = dtpkSystemDate.SelectedDate == null ? DateTime.Now : dtpkSystemDate.SelectedDate.Value;

            DateTime oldConfigDate = newDate;

            DateTime.TryParse(oldSystemDateString, out oldConfigDate);

            string newSystemDateString = dtpkSystemDate.SelectedDate == null ? string.Empty : dtpkSystemDate.SelectedDate.Value.ToString("dd-MMM-yyyy HH:mm:ss");

            SystemValue sysValue = DataContext.SystemValues.Where(sv => sv.Name == "SystemDate").FirstOrDefault();

            sysValue.Value = newSystemDateString;

            DataContext.SaveChanges();

            ClearSystemCache();

            ShowNotification("saveNotice");

            if (newDate < oldConfigDate)
            {
                //If the date has moved into past, reset the agent last run date as well.
                ResetAgentLastRunDates();
            }
        }
 private static SystemDrawDown CreateNewDD(SystemValue lastValue, SystemValue currValue) =>
 new SystemDrawDown()
 {
     TopValue    = lastValue,
     BottomValue = currValue,
     Ticks       = 0
 };
Пример #3
0
        public async Task <Result <SystemValueDto> > AddAsync(SystemValueDto entity)
        {
            var response = new Result <SystemValueDto>();

            try
            {
                var ctx          = GetOpenConnection();
                var systemValues = new GenericRepositoryEF <KntDbContext, SystemValue>(ctx);

                var newEntity = new SystemValue();
                newEntity.SetSimpleDto(entity);

                var resGenRep = await systemValues.AddAsync(newEntity);

                response.Entity    = resGenRep.Entity?.GetSimpleDto <SystemValueDto>();
                response.ErrorList = resGenRep.ErrorList;

                await CloseIsTempConnection(ctx);
            }
            catch (Exception ex)
            {
                AddExecptionsMessagesToErrorsList(ex, response.ErrorList);
            }
            return(ResultDomainAction(response));
        }
Пример #4
0
        private void LoadAgentExecutionStatus()
        {
            SystemValue systemValue = DataContext.SystemValues.Where(sv => sv.Name == "IsAgentRunning").FirstOrDefault();

            if (systemValue != null)
            {
                litStatus.Visible = string.Equals(systemValue.Value, "true");
            }
        }
        private static SystemDrawDown ProcessSystemValue(SystemValue currValue, ref SystemValue lastValue, ref SystemDrawDown lastDD)
        {
            SystemDrawDown currDD = UpdateDD(CreateNewDDIfRequired(CloseDDIfRequired(lastDD, currValue), currValue, lastValue), currValue);

            lastValue = currValue;
            if ((currDD == null) || (currDD == lastDD))
            {
                return(null);
            }
            lastDD = currDD;
            return(currDD);
        }
Пример #6
0
        /// <summary>
        /// Umwandlung in String
        /// </summary>
        /// <returns>Die Stringrepräsentation</returns>
        public override string ToString()
        {
            if (SystemValue != TypeOnChange.None)
            {
                return(SystemValue.ToValue());
            }
            else if (!string.IsNullOrWhiteSpace(UserValue))
            {
                return(UserValue);
            }

            return(null);
        }
 private static SystemDrawDown UpdateDD(SystemDrawDown currDD, SystemValue currValue)
 {
     if (currDD == null)
     {
         return(null);
     }
     if (currDD.BottomValue.Value > currValue.Value)
     {
         currDD.BottomValue = currValue;
     }
     currDD.LastTS = currValue.TS;
     currDD.Ticks++;
     return(currDD);
 }
Пример #8
0
        public async Task <IActionResult> OnGetAsync()
        {
            if (string.IsNullOrEmpty(SystemValueKey))
            {
                return(new RedirectToPageResult("/Admin/SystemValues/List"));
            }

            SystemValue = await _context.SystemValue.FirstOrDefaultAsync(f => f.Key == SystemValueKey);

            if (SystemValue == null)
            {
                return(new RedirectToPageResult("/Admin/SystemValues/List"));
            }

            return(Page());
        }
        public static List <SystemDrawDown> Calculate(List <SystemValue> equity)
        {
            if (equity.Count <= 1)
            {
                return(new List <SystemDrawDown>());
            }

            SystemValue    lastValue = equity[0];
            SystemDrawDown lastDD    = null;

            return(equity
                   .Skip(1)
                   .Select(currValue => ProcessSystemValue(currValue, ref lastValue, ref lastDD))
                   .Where(o => o != null)
                   .ToList());
        }
Пример #10
0
 /// <summary>
 /// Update agent execution flag.
 /// </summary>
 /// <param name="isExecuted">The is executed.</param>
 private static void UpDateAgentExecutionFlag(string isExecuted)
 {
     try
     {
         using (StageBitzDB dataContext = new StageBitzDB())
         {
             SystemValue sysValue = dataContext.SystemValues.Where(sv => sv.Name == "IsAgentRunning").FirstOrDefault();
             sysValue.Value = isExecuted;
             dataContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         AgentErrorLog.HandleException(ex);
     }
 }
Пример #11
0
        /// <summary>
        /// Set một giá trị theo key và mô tả
        /// </summary>
        /// <param name="key">Khóa</param>
        /// <param name="value">Giá trị</param>
        /// <returns>Nếu đã tồn tại thì sẽ update</returns>
        private bool SetStringByKey(string key, string value)
        {
            using SystemDbContext dbContext = new SystemDbContext(new DbContextOptionsBuilder <SystemDbContext>().UseSqlServer(_connectionString).Options);
            SystemValue systemKeyValue = dbContext.SystemValues.FirstOrDefault(q => q.Key == key);

            if (systemKeyValue != null)
            {
                systemKeyValue.Value = value;
            }
            else
            {
                dbContext.SystemValues.Add(new SystemValue()
                {
                    Key = key, Value = value
                });
            }
            return(dbContext.SaveChanges() > 0);
        }
Пример #12
0
        /// <summary>
        /// Lấy nội dung file thiết lập nếu chưa có thì tạo theo string mặc định chuyền vào
        /// </summary>
        /// <param name="settingJsonStringDefault">string mặc định</param>
        /// <param name="key">Đường dẫn đến file setting</param>
        /// <param name="description">Mô tả cho khóa dữ liệu</param>
        /// <returns>nội dung file setting</returns>
        private string GetSettingsOfCreateIfNotExist(string settingJsonStringDefault, string key, string description = "")
        {
            using SystemDbContext dbContext = new SystemDbContext(new DbContextOptionsBuilder <SystemDbContext>().UseSqlServer(_connectionString).Options);
            SystemValue systemKeyValue = dbContext.SystemValues.FirstOrDefault(q => q.Key == key);

            if (systemKeyValue != null)
            {
                return(systemKeyValue.Value);
            }

            systemKeyValue = new SystemValue()
            {
                Key = key, Value = settingJsonStringDefault, Description = description
            };
            dbContext.SystemValues.Add(systemKeyValue);
            dbContext.SaveChanges();
            return(settingJsonStringDefault);
        }
Пример #13
0
 public SystemValueMapper(SystemValue value)
 {
     _value = value;
 }
 private static SystemDrawDown CreateNewDDIfRequired(SystemDrawDown currDD, SystemValue currValue, SystemValue lastValue) =>
 (currDD == null) && (currValue.Value < lastValue.Value) ? CreateNewDD(lastValue, currValue) : currDD;
 private static SystemDrawDown CloseDDIfRequired(SystemDrawDown currDD, SystemValue currValue) =>
 (currDD?.TopValue.Value < currValue.Value) ? null : currDD;