Ejemplo n.º 1
0
        public async Task <IActionResult> OnGetAsync(int productId, int categoryId)
        {
            ConfigDetails = await _configDetailService.GetAllConfigDetailsByProductId(productId);

            ConfigCharts = await _configChartService.GetAllConfigChartByCategoryId(categoryId);

            ConfigGroups = await _configGroupService.GetAllConfigGroupByCategoryId(categoryId);

            Product = await _productService.GetProductById(productId);

            ViewData["CategoryId"] = categoryId;
            ViewData["ProductId"]  = productId;

            foreach (var chart in ConfigCharts)
            {
                if (!_configDetailService.AnyConfigDetailsByProductIdAndConfigChartId(productId, chart.Id))
                {
                    var configDetail = new ConfigDetail()
                    {
                        ProductId     = productId,
                        ConfigGroupId = chart.ConfigGroupId,
                        ConfigChart   = chart,
                        ConfigChartId = chart.Id,
                        Value         = null
                    };
                    await _configDetailService.AddConfigDetail(configDetail);
                }
            }

            return(Page());
        }
Ejemplo n.º 2
0
        public ConfigDetail LoadConfigurationDetail()
        {
            try
            {
                ConfigDetail ObjConfigDetail = new ConfigDetail();
                string       Key             = null;
                string       CSName          = "";
                //int CSCounter = ConfigurationManager.ConnectionStrings.Count;
                //if (CSCounter > 0)
                //{
                //    ObjConfigDetail.ConnectionStringCollection = new ConcurrentDictionary<string, string>();
                //    while (CSCounter != 0)
                //    {
                //        CSName = ConfigurationManager.ConnectionStrings[CSCounter - 1].ConnectionString;
                //        Key = ConfigurationManager.ConnectionStrings[CSCounter - 1].Name;
                //        if (!string.IsNullOrEmpty(CSName) && Key != "LocalSqlServer")
                //            ObjConfigDetail.ConnectionStringCollection.Add(Key, CSName);
                //        CSCounter--;
                //    }
                //}

                //string[] KeyArrays = ConfigurationManager.AppSettings.AllKeys;
                //if (KeyArrays.Count() > 0)
                //{
                //    ObjConfigDetail.AppSettingCollection = new ConcurrentDictionary<string, string>();
                //    foreach (string key in KeyArrays)
                //        ObjConfigDetail.AppSettingCollection.Add(key, ConfigurationManager.AppSettings[key]);
                //}
                return(ObjConfigDetail);
            }
            catch (BeanException _beanEx)
            {
                _beanEx.LocationTrack(this.GetType().FullName + "LoadConfigurationDetail()");
                throw _beanEx;
            }
            catch (Exception ex)
            {
                BeanException ObjBeanException = new BeanException();
                ObjBeanException.LocationTrack(this.GetType().FullName + "LoadConfigurationDetail()");
                ObjBeanException.SetMessage(ex.Message);
                throw ObjBeanException;
            }
        }
Ejemplo n.º 3
0
        public static ConfigDetailData ToAllViewData(this ConfigDetail node, CategoryDictionary suffix = CategoryDictionary.None)
        {
            if (node == null)
                return null;
            var result = new ConfigDetailData()
            {
                Id = node.Id,
                TemplateId = node.TemplateId,
                MeterId = node.MeterId,
                BuildingId = node.BuildingId,
                OrganizationId = node.OrganizationId,
                Enabled = node.Enabled,
                OperatorId = node.OperatorId,
                OperatorName = node.OperatorName,
                CreateTime = node.CreateTime,
                BuildingCategoryId = node.BuildingCategoryId,
                EnergyCategoryId = node.EnergyCategoryId,
                IsOpenOverLoadAlert = node.IsOpenOverLoadAlert,
                IsOpenMalignantLoadAlert = node.IsOpenMalignantLoadAlert,
                IsControlPower = node.IsControlPower,
                IsControlWater = node.IsControlWater,
                IsControlWaterByPower = node.IsControlWaterByPower,
                VacationTimeControlTemplateId = node.VacationTimeControlTemplateId,
                HolidayTimeControlTemplateId = node.HolidayTimeControlTemplateId,
                WeekEndTimeControlTemplateId = node.WeekEndTimeControlTemplateId,
                PeacetimeTimeControlTemplateId = node.PeacetimeTimeControlTemplateId,
                IsControlByAccount = node.IsControlByAccount,
                IsControlByTime = node.IsControlByTime,
                MinThresholdForMalignantLoad = node.MinThresholdForMalignantLoad,
                MinThresholdForOverLoad = node.MinThresholdForOverLoad

            };
            using (MonitoringConfigBLL configBLL = new MonitoringConfigBLL())
            {
                if (node.Template.ConfigTypeId != (DictionaryCache.MonitoringConfigTypePrice.Id + 5))
                    if (node.MonitoringConfigTemplate != null)
                        result.Template = node.MonitoringConfigTemplate.ToViewData();
                    else
                    {

                        result.Template = configBLL.Find(node.TemplateId).ToViewData();
                    }
                if (node.MonitoringConfigTemplate == null)
                    result.VacationTimeControlTemplate = configBLL.Find(node.VacationTimeControlTemplateId).ToViewData();
                else
                    result.VacationTimeControlTemplate = node.VacationTimeControlTemplate.ToViewData();

                if (node.HolidayTimeControlTemplate == null)
                    result.HolidayTimeControlTemplate = configBLL.Find(node.HolidayTimeControlTemplateId).ToViewData();
                else
                    result.HolidayTimeControlTemplate = node.HolidayTimeControlTemplate.ToViewData();

                if (node.WeekEndTimeControlTemplate == null)
                    result.WeekEndTimeControlTemplate = configBLL.Find(node.WeekEndTimeControlTemplateId).ToViewData();
                else
                    result.WeekEndTimeControlTemplate = node.WeekEndTimeControlTemplate.ToViewData();

                if (node.PeacetimeTimeControlTemplate == null)
                    result.PeacetimeTimeControlTemplate = configBLL.Find(node.PeacetimeTimeControlTemplateId).ToViewData();
                else
                    result.PeacetimeTimeControlTemplate = node.PeacetimeTimeControlTemplate.ToViewData();

            }
            return result;
        }
Ejemplo n.º 4
0
 public void UpdateConfigDetail(ConfigDetail configDetail)
 {
     _context.ConfigDetails.Update(configDetail);
 }
Ejemplo n.º 5
0
 public async Task AddConfigDetail(ConfigDetail configDetail)
 {
     _context.ConfigDetails.Add(configDetail);
     await SaveChangeAsync();
 }