Пример #1
0
 /// <summary>
 /// 增加测点
 /// </summary>
 /// <param name="amp"></param>
 /// <returns></returns>
 public bool AddAMP(AnalogMeasurePoint amp)
 {
     try
     {
         //if (!amp.AMP_ParentNo.HasValue || amp.AMP_ParentNo.Value <= 0)
         //{
         //    int parentNo = 0;
         //    AnalogMeasurePoint tempAMP = null;
         //    if (amp.AMP_RoomID > 0)
         //    {
         //        tempAMP = _dataContext.AnalogMeasurePoints.FirstOrDefault(x => x.AMP_CptFlag == 0 && x.AMP_Statistic == 1 && x.AMP_PowerType == amp.AMP_PowerType && x.AMP_BuildingID == amp.AMP_BuildingID && x.AMP_RoomID == 0);
         //    }
         //    else if (amp.AMP_BuildingID > 0)
         //    {
         //        tempAMP = _dataContext.AnalogMeasurePoints.FirstOrDefault(x => x.AMP_CptFlag == 0 && x.AMP_Statistic == 1 && x.AMP_PowerType == amp.AMP_PowerType && x.AMP_SAreaID == amp.AMP_SAreaID && x.AMP_BuildingID == 0);
         //    }
         //    else if (amp.AMP_SAreaID > 0)
         //    {
         //        tempAMP = _dataContext.AnalogMeasurePoints.FirstOrDefault(x => x.AMP_CptFlag == 0 && x.AMP_Statistic == 1 && x.AMP_PowerType == amp.AMP_PowerType && x.AMP_SchooldID == amp.AMP_SchooldID && x.AMP_SAreaID == 0);
         //    }
         //    if (tempAMP != null)
         //    {
         //        parentNo = tempAMP.AMP_AnalogNo;
         //    }
         //    amp.AMP_ParentNo = parentNo;
         //}
         _dataContext.AnalogMeasurePoints.InsertOnSubmit(amp);
         _dataContext.SubmitChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #2
0
        AnalogMeasurePoint CloneAmp(AnalogMeasurePoint amp)
        {
            AnalogMeasurePoint newAmp = new AnalogMeasurePoint();

            newAmp.AMP_AnalogNo           = amp.AMP_AnalogNo;
            newAmp.AMP_BuildingID         = amp.AMP_BuildingID;
            newAmp.AMP_CptFlag            = amp.AMP_CptFlag;
            newAmp.AMP_Date               = amp.AMP_Date;
            newAmp.AMP_DepartID           = amp.AMP_DepartID;
            newAmp.AMP_Encoding           = amp.AMP_Encoding;
            newAmp.AMP_Name               = amp.AMP_Name;
            newAmp.AMP_OperationParameter = amp.AMP_OperationParameter;
            newAmp.AMP_OperationRule      = amp.AMP_OperationRule;
            newAmp.AMP_ParentNo           = amp.AMP_ParentNo;
            newAmp.AMP_PowerName          = amp.AMP_PowerName;
            newAmp.AMP_PowerType          = amp.AMP_PowerType;
            newAmp.AMP_RoomID             = amp.AMP_RoomID;
            newAmp.AMP_SAreaID            = amp.AMP_SAreaID;
            newAmp.AMP_SchooldID          = amp.AMP_SchooldID;
            newAmp.AMP_State              = amp.AMP_State;
            newAmp.AMP_Statistic          = amp.AMP_Statistic;
            newAmp.AMP_Timespan           = amp.AMP_Timespan;
            newAmp.AMP_Unit               = amp.AMP_Unit;
            newAmp.AMP_Val    = amp.AMP_Val;
            newAmp.AMP_ValRem = amp.AMP_ValRem;
            return(newAmp);
        }
Пример #3
0
 /// <summary>
 /// 清除某个房间对应测点的所属对象信息
 /// </summary>
 /// <param name="roomID"></param>
 public void ClearObjIDByRoom(int roomID)
 {
     try
     {
         AnalogMeasurePoint item = _dataContext.AnalogMeasurePoints.Single(x => x.AMP_RoomID == roomID);
         item.AMP_SchooldID  = 0;
         item.AMP_SAreaID    = 0;
         item.AMP_BuildingID = 0;
         item.AMP_RoomID     = 0;
         _dataContext.SubmitChanges();
     }
     catch (Exception e)
     {
     }
 }
Пример #4
0
        public AnalogMeasurePoint GetMeasurePointByAnalogNo(int AnalogNo)
        {
            AnalogMeasurePoint amp = _dataContext.AnalogMeasurePoints.Where(x => x.AMP_AnalogNo == AnalogNo).SingleOrDefault();

            return(amp);
        }
Пример #5
0
 /// <summary>
 /// 修改AMP
 /// </summary>
 /// <param name="amp"></param>
 /// <returns></returns>
 public bool ModifyAMP(AnalogMeasurePoint amp)
 {
     try
     {
         AnalogMeasurePoint oldAMP = _dataContext.AnalogMeasurePoints.Single(x => x.AMP_AnalogNo == amp.AMP_AnalogNo);
         AnalogMeasurePoint tombstoneAmp = CloneAmp(oldAMP), baseAmp = CloneAmp(oldAMP);
         oldAMP.AMP_Name       = amp.AMP_Name;
         oldAMP.AMP_CptFlag    = amp.AMP_CptFlag;
         oldAMP.AMP_Statistic  = amp.AMP_Statistic;
         oldAMP.AMP_SchooldID  = amp.AMP_SchooldID;
         oldAMP.AMP_SAreaID    = amp.AMP_SAreaID;
         oldAMP.AMP_BuildingID = amp.AMP_BuildingID;
         oldAMP.AMP_RoomID     = amp.AMP_RoomID;
         oldAMP.AMP_PowerType  = amp.AMP_PowerType;
         oldAMP.AMP_PowerName  = amp.AMP_PowerName;
         ////如果父测点改变,则新增两个虚拟点,以下if语句内容为开发维护工具时新增(曾彬)
         if (oldAMP.AMP_ParentNo != amp.AMP_ParentNo)
         {
             int newID = this.GetAMPMaxNo() + 1;
             tombstoneAmp.AMP_CptFlag  = 0;
             tombstoneAmp.AMP_AnalogNo = newID++;
             tombstoneAmp.AMP_Name     = amp.AMP_AnalogNo.ToString() + "墓碑节点";
             _dataContext.AnalogMeasurePoints.InsertOnSubmit(tombstoneAmp);
             if (amp.AMP_ParentNo != 0)
             {
                 baseAmp.AMP_CptFlag  = 0;
                 baseAmp.AMP_AnalogNo = newID;
                 baseAmp.AMP_ParentNo = amp.AMP_ParentNo;
                 baseAmp.AMP_Val      = -1 * oldAMP.AMP_Val;
                 baseAmp.AMP_Name     = amp.AMP_AnalogNo.ToString() + "基数节点";
                 _dataContext.AnalogMeasurePoints.InsertOnSubmit(baseAmp);
             }
         }
         ////////////////////////////////////
         oldAMP.AMP_ParentNo = amp.AMP_ParentNo;
         oldAMP.AMP_Encoding = amp.AMP_Encoding;
         //if (amp.AMP_ParentNo.HasValue && amp.AMP_ParentNo.Value > 0)
         //{
         //    oldAMP.AMP_ParentNo = amp.AMP_ParentNo;
         //}
         //else
         //{
         //    int parentNo = 0;
         //    AnalogMeasurePoint tempAMP = null;
         //    // 找他的父节点,并修改父节点
         //    if (amp.AMP_RoomID > 0)
         //    {
         //        tempAMP = _dataContext.AnalogMeasurePoints.FirstOrDefault(x => x.AMP_CptFlag == 0 && x.AMP_Statistic == 1 && x.AMP_PowerType == amp.AMP_PowerType && x.AMP_BuildingID == amp.AMP_BuildingID && x.AMP_RoomID == 0);
         //    }
         //    else if (amp.AMP_BuildingID > 0)
         //    {
         //        tempAMP = _dataContext.AnalogMeasurePoints.FirstOrDefault(x => x.AMP_CptFlag == 0 && x.AMP_Statistic == 1 && x.AMP_PowerType == amp.AMP_PowerType && x.AMP_SAreaID == amp.AMP_SAreaID && x.AMP_BuildingID == 0);
         //    }
         //    else if (amp.AMP_SAreaID > 0)
         //    {
         //        tempAMP = _dataContext.AnalogMeasurePoints.FirstOrDefault(x => x.AMP_CptFlag == 0 && x.AMP_Statistic == 1 && x.AMP_PowerType == amp.AMP_PowerType && x.AMP_SchooldID == amp.AMP_SchooldID && x.AMP_SAreaID == 0);
         //    }
         //    if (tempAMP != null)
         //    {
         //        parentNo = tempAMP.AMP_AnalogNo;
         //    }
         //    oldAMP.AMP_ParentNo = parentNo;
         //}
         _dataContext.SubmitChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }