예제 #1
0
        public HttpResponseMessage UpdateStructureAggConfig([FromUri] int configId, [FromBody] AggConfigData model)
        {
            using (var db = new SecureCloud_Entities())
            {
                try
                {
                    var config =
                        (from aggconfig in db.T_DIM_AGG_CONFIG where aggconfig.Id == configId select aggconfig).First();
                    if (config == null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.BadRequest, StringHelper.GetMessageString("聚集配置不存在")));
                    }
                    if (!IsConfigChanged(config, model))
                    {
                        config.IsEnable = false;
                        config.IsDelete = true;
                        var newConfig = new T_DIM_AGG_CONFIG();
                        ToT_DIM_AGG_CONFIG(model, ref newConfig);
                        db.Entry(config).State    = System.Data.EntityState.Modified;
                        db.Entry(newConfig).State = System.Data.EntityState.Added;
                        db.SaveChanges();
                        SendAggConfigChangedMsg();
                    }

                    return(Request.CreateResponse(HttpStatusCode.Accepted, StringHelper.GetMessageString("聚集配置修改成功")));
                }
                catch (Exception)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, StringHelper.GetMessageString("聚集配置修改失败")));
                }
            }
        }
예제 #2
0
 private bool IsConfigChanged(T_DIM_AGG_CONFIG oldConfig, AggConfigData newData)
 {
     return(oldConfig.AggTypeId == newData.AggTypeId && oldConfig.AggWayId == newData.AggWayId &&
            oldConfig.DataBeginHour == newData.BeginHour && oldConfig.DataEndHour == newData.EndHour &&
            oldConfig.DateBegin == newData.BeginDate && oldConfig.DateEnd == newData.EndDate &&
            oldConfig.FacotrId == newData.FacotrId && oldConfig.StructureId == newData.StructureId &&
            oldConfig.IsEnable == newData.IsEnable && oldConfig.TimeMode == newData.TimingMode);
 }
예제 #3
0
 private static void ToT_DIM_AGG_CONFIG(AggConfigData model, ref T_DIM_AGG_CONFIG config)
 {
     config.AggTypeId     = model.AggTypeId;
     config.AggWayId      = model.AggWayId;
     config.DataBeginHour = model.BeginHour;
     config.DataEndHour   = model.EndHour;
     config.DateBegin     = model.BeginDate;
     config.DateEnd       = model.EndDate;
     config.FacotrId      = model.FacotrId;
     config.StructureId   = model.StructureId;
     config.IsEnable      = model.IsEnable;
     config.TimeMode      = model.TimingMode;
 }
예제 #4
0
        public HttpResponseMessage AddStructureAggConfig([FromBody] AggConfigData model)
        {
            using (var db = new SecureCloud_Entities())
            {
                try
                {
                    var newConfig = new T_DIM_AGG_CONFIG();
                    ToT_DIM_AGG_CONFIG(model, ref newConfig);

                    db.Entry(newConfig).State = System.Data.EntityState.Added;
                    db.SaveChanges();
                    SendAggConfigChangedMsg();
                    return(Request.CreateResponse(HttpStatusCode.Accepted, StringHelper.GetMessageString("聚集配置修改成功")));
                }
                catch (Exception e)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, StringHelper.GetMessageString("聚集配置修改失败")));
                }
            }
        }