public List <LinkageConfigGeneral> GetGeneralLinkageConfigInfo(Model.ControllerModel controller)
        {
            List <LinkageConfigGeneral> lstData = new List <LinkageConfigGeneral>();
            StringBuilder sbQuerySQL            = new StringBuilder("select ID,Code,ActionCoefficient,BuildingNoA,ZoneNoA, LayerNoA1 , LayerNoA2 , DeviceTypeCodeA ,TypeC,MachineNoC ,LoopNoC,DeviceCodeC ,BuildingNoC,ZoneNoC, LayerNoC ,DeviceTypeCodeC ,controllerID from LinkageConfigGeneral where controllerID=" + controller.ID);

            System.Data.DataTable dt = _databaseService.GetDataTableBySQL(sbQuerySQL);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                LinkageConfigGeneral model = new LinkageConfigGeneral();
                model.ID   = Convert.ToInt32(dt.Rows[i]["id"]);
                model.Code = dt.Rows[i]["Code"].ToString();
                model.ActionCoefficient = Convert.ToInt32(dt.Rows[i]["ActionCoefficient"]);
                model.BuildingNoA       = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["BuildingNoA"]));
                model.ZoneNoA           = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["ZoneNoA"]));
                model.LayerNoA1         = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["LayerNoA1"]));
                model.LayerNoA2         = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["LayerNoA2"]));
                model.DeviceTypeCodeA   = Convert.ToInt16(dt.Rows[i]["DeviceTypeCodeA"]);
                model.TypeC             = (LinkageType)Enum.ToObject(typeof(LinkageType), Convert.ToInt16(dt.Rows[i]["TypeC"]));
                model.MachineNoC        = dt.Rows[i]["MachineNoC"].ToString();
                model.LoopNoC           = dt.Rows[i]["LoopNoC"].ToString();
                model.DeviceCodeC       = dt.Rows[i]["DeviceCodeC"].ToString();
                model.BuildingNoC       = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["BuildingNoC"]));
                model.ZoneNoC           = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["ZoneNoC"]));
                model.LayerNoC          = new Nullable <int>(Convert.ToInt32(dt.Rows[i]["LayerNoC"]));
                model.DeviceTypeCodeC   = Convert.ToInt16(dt.Rows[i]["DeviceTypeCodeC"]);
                model.Controller        = controller;
                model.ControllerID      = controller.ID;
                lstData.Add(model);
            }
            return(lstData);
        }
        public LinkageConfigGeneral ToLinkageConfigGeneral()
        {
            LinkageConfigGeneral linkageConfigGeneral = new LinkageConfigGeneral();

            linkageConfigGeneral.Controller        = this.Controller;
            linkageConfigGeneral.ControllerID      = this.ControllerID;
            linkageConfigGeneral.ID                = this.ID;
            linkageConfigGeneral.Code              = this.Code;
            linkageConfigGeneral.ActionCoefficient = this.ActionCoefficient;
            // linkageConfigGeneral.CategoryA = this.CategoryA;
            linkageConfigGeneral.BuildingNoA     = this.BuildingNoA;
            linkageConfigGeneral.ZoneNoA         = this.ZoneNoA;
            linkageConfigGeneral.LayerNoA1       = this.LayerNoA1;
            linkageConfigGeneral.LayerNoA2       = this.LayerNoA2;
            linkageConfigGeneral.DeviceTypeCodeA = this.DeviceTypeCodeA;
            linkageConfigGeneral.TypeC           = this.TypeC;
            linkageConfigGeneral.MachineNoC      = this.MachineNoC;
            linkageConfigGeneral.LoopNoC         = this.LoopNoC;
            linkageConfigGeneral.DeviceCodeC     = this.DeviceCodeC;
            linkageConfigGeneral.BuildingNoC     = this.BuildingNoC;
            linkageConfigGeneral.ZoneNoC         = this.ZoneNoC;
            linkageConfigGeneral.LayerNoC        = this.LayerNoC;
            linkageConfigGeneral.DeviceTypeCodeC = this.DeviceTypeCodeC;
            return(linkageConfigGeneral);
        }
示例#3
0
        public List <LinkageConfigGeneral> GetGeneralLinkageConfig()
        {
            List <LinkageConfigGeneral> lstGeneral = new List <LinkageConfigGeneral>();

            try
            {
                StringBuilder sbQuerySQL  = new StringBuilder("select 编号,动作常数,楼号A,区号A,层号A1,层号A2,类型A,分类C,楼号C,区号C,层号C,类型C from 通用组态;");
                DataTable     dt          = _databaseService.GetDataTableBySQL(sbQuerySQL);
                int           dtRowsCount = dt.Rows.Count;
                for (int i = 0; i < dtRowsCount; i++)
                {
                    LinkageConfigGeneral linkageConfigGeneral = new LinkageConfigGeneral();
                    linkageConfigGeneral.Code = dt.Rows[i]["编号"].ToString();
                    linkageConfigGeneral.ActionCoefficient = Convert.ToInt32(dt.Rows[i]["动作常数"]);
                    linkageConfigGeneral.BuildingNoA       = dt.Rows[i]["楼号A"].ToString().ToNullable <int>();
                    linkageConfigGeneral.ZoneNoA           = dt.Rows[i]["区号A"].ToString().ToNullable <int>();
                    linkageConfigGeneral.LayerNoA1         = dt.Rows[i]["层号A1"].ToString().ToNullable <int>();
                    linkageConfigGeneral.LayerNoA2         = dt.Rows[i]["层号A2"].ToString().ToNullable <int>();

                    linkageConfigGeneral.DeviceTypeCodeA = ConvertDeviceTypeCodeToCurrentVersion(dt.Rows[i]["类型A"].ToString());

                    Int16 intTypeCodeC = ConvertDeviceTypeCodeToCurrentVersion(dt.Rows[i]["类型C"].ToString());

                    linkageConfigGeneral.TypeC = ConvertLinkageType(dt.Rows[i]["分类C"].ToString());
                    if (linkageConfigGeneral.TypeC == LinkageType.ZoneLayer)
                    {
                        linkageConfigGeneral.BuildingNoC     = dt.Rows[i]["楼号C"].ToString().ToNullable <int>();
                        linkageConfigGeneral.ZoneNoC         = dt.Rows[i]["区号C"].ToString().ToNullable <int>();
                        linkageConfigGeneral.LayerNoC        = dt.Rows[i]["层号C"].ToString().ToNullable <int>();
                        linkageConfigGeneral.DeviceTypeCodeC = intTypeCodeC;
                    }
                    else if (linkageConfigGeneral.TypeC == LinkageType.Address)
                    {
                        linkageConfigGeneral.MachineNoC  = dt.Rows[i]["楼号C"].ToString();
                        linkageConfigGeneral.LoopNoC     = dt.Rows[i]["区号C"].ToString();
                        linkageConfigGeneral.DeviceCodeC = dt.Rows[i]["层号C"].ToString();
                    }
                    else if (linkageConfigGeneral.TypeC == LinkageType.SameLayer)
                    {
                        linkageConfigGeneral.DeviceTypeCodeC = intTypeCodeC;
                    }
                    else if (linkageConfigGeneral.TypeC == LinkageType.AdjacentLayer)
                    {
                        linkageConfigGeneral.DeviceTypeCodeC = intTypeCodeC;
                    }

                    lstGeneral.Add(linkageConfigGeneral);
                }
            }
            catch
            {
            }
            return(lstGeneral);
        }
 public bool Update(LinkageConfigGeneral linkageConfigGeneral)
 {
     try
     {
         LinkageConfigGeneral result = _controller.GeneralConfig.Find(
             delegate(LinkageConfigGeneral x)
         {
             return(x.ID == linkageConfigGeneral.ID);
         }
             );
         if (result != null)
         {
             result.Code              = linkageConfigGeneral.Code;
             result.Controller        = linkageConfigGeneral.Controller;
             result.ControllerID      = linkageConfigGeneral.ControllerID;
             result.ID                = linkageConfigGeneral.ID;
             result.Code              = linkageConfigGeneral.Code;
             result.ActionCoefficient = linkageConfigGeneral.ActionCoefficient;
             result.BuildingNoA       = linkageConfigGeneral.BuildingNoA;
             result.CategoryA         = linkageConfigGeneral.CategoryA;
             result.ZoneNoA           = linkageConfigGeneral.ZoneNoA;
             result.LayerNoA1         = linkageConfigGeneral.LayerNoA1;
             result.LayerNoA2         = linkageConfigGeneral.LayerNoA2;
             result.DeviceTypeCodeA   = linkageConfigGeneral.DeviceTypeCodeA;
             result.TypeC             = linkageConfigGeneral.TypeC;
             result.MachineNoC        = linkageConfigGeneral.MachineNoC;
             result.LoopNoC           = linkageConfigGeneral.LoopNoC;
             result.DeviceCodeC       = linkageConfigGeneral.DeviceCodeC;
             result.BuildingNoC       = linkageConfigGeneral.BuildingNoC;
             result.ZoneNoC           = linkageConfigGeneral.ZoneNoC;
             result.LayerNoC          = linkageConfigGeneral.LayerNoC;
             result.DeviceTypeCodeC   = linkageConfigGeneral.DeviceTypeCodeC;
         }
         else
         {
             _controller.GeneralConfig.Add(linkageConfigGeneral);
             DataRecordAlreadySet = true;
             if (linkageConfigGeneral.ID > ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig)
             {
                 ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig = linkageConfigGeneral.ID;
             }
             else
             {
                 ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig++;
             }
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
示例#5
0
        //4>更新通用组态: 器件类型A,器件类型C的“点动”及“字锁”字样去掉,对于在101及129范围内的器件编码-64
        private bool UpdateGeneralLinkageConfigInfo(LinkageConfigGeneral generalConfig)
        {
            bool result = false;

            try
            {
                if (generalConfig.DeviceTypeNameA != null)
                {
                    if (generalConfig.DeviceTypeNameA.Length > 0) //更新器件类型A
                    {
                        Int16 deviceTypeA = Convert.ToInt16(generalConfig.DeviceTypeNameA.Substring(0, 3));
                        if (deviceTypeA >= 101 && deviceTypeA <= 129)
                        {
                            generalConfig.DeviceTypeCodeA = Convert.ToInt16(deviceTypeA - 64);
                        }
                        else
                        {
                            generalConfig.DeviceTypeCodeA = deviceTypeA;
                        }
                    }
                }
                else
                {
                    generalConfig.DeviceTypeCodeA = 0;
                }
                if (generalConfig.DeviceTypeNameC != null)
                {
                    if (generalConfig.DeviceTypeNameC.Length > 0) //更新器件类型C
                    {
                        Int16 deviceTypeC = Convert.ToInt16(generalConfig.DeviceTypeNameC.Substring(0, 3));
                        if (deviceTypeC >= 101 && deviceTypeC <= 129)
                        {
                            generalConfig.DeviceTypeCodeC = Convert.ToInt16(deviceTypeC - 64);
                        }
                        else
                        {
                            generalConfig.DeviceTypeCodeC = deviceTypeC;
                        }
                    }
                }
                else
                {
                    generalConfig.DeviceTypeCodeC = 0;
                }
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
 public bool DeleteBySpecifiedID(int id)
 {
     try
     {
         var result             = from lcg in _controller.GeneralConfig where lcg.ID == id select lcg;
         LinkageConfigGeneral o = result.FirstOrDefault();
         if (o != null)
         {
             _controller.GeneralConfig.Remove(o);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        public List <LinkageConfigGeneral> Create(int amount)
        {
            List <LinkageConfigGeneral> lstLinkageConfigGeneral = new List <LinkageConfigGeneral>();

            if (DataRecordAlreadySet)
            {
                _maxCode = GetMaxCode();
                _maxID   = GetMaxID();
            }
            int tempCode = _maxCode;

            if (tempCode >= MaxGeneralLinkageConfigAmount) //如果已经达到上限,则不添加任何行
            {
                amount = 0;
            }
            else
            {
                if ((tempCode + amount) > MaxGeneralLinkageConfigAmount) //如果需要添加的行数将达上限,则增加剩余的行数
                {
                    amount = MaxGeneralLinkageConfigAmount - tempCode;
                }

                for (int i = 0; i < amount; i++)
                {
                    tempCode++;
                    _maxID++;
                    LinkageConfigGeneral lcg = new LinkageConfigGeneral();
                    lcg.Controller   = _controller;
                    lcg.ControllerID = _controller.ID;
                    lcg.ID           = _maxID;
                    lcg.Code         = tempCode.ToString().PadLeft(MaxGeneralLinkageConfigAmount.ToString().Length, '0');
                    lcg.IsDirty      = true;
                    lstLinkageConfigGeneral.Add(lcg);
                }
                _maxCode             = tempCode;
                DataRecordAlreadySet = false;
                foreach (var singleItem in lstLinkageConfigGeneral)
                {
                    Update(singleItem);
                }
            }
            return(lstLinkageConfigGeneral);
        }
 public EditableLinkageConfigGeneral(LinkageConfigGeneral linkageConfigGeneral)
 {
     this.Controller        = linkageConfigGeneral.Controller;
     this.ControllerID      = linkageConfigGeneral.ControllerID;
     this.ID                = linkageConfigGeneral.ID;
     this.Code              = linkageConfigGeneral.Code;
     this.ActionCoefficient = linkageConfigGeneral.ActionCoefficient;
     this.BuildingNoA       = linkageConfigGeneral.BuildingNoA;
     this.ZoneNoA           = linkageConfigGeneral.ZoneNoA;
     this.LayerNoA1         = linkageConfigGeneral.LayerNoA1;
     this.LayerNoA2         = linkageConfigGeneral.LayerNoA2;
     this.DeviceTypeCodeA   = linkageConfigGeneral.DeviceTypeCodeA;
     this.TypeC             = linkageConfigGeneral.TypeC;
     this.MachineNoC        = linkageConfigGeneral.MachineNoC;
     this.LoopNoC           = linkageConfigGeneral.LoopNoC;
     this.DeviceCodeC       = linkageConfigGeneral.DeviceCodeC;
     this.BuildingNoC       = linkageConfigGeneral.BuildingNoC;
     this.ZoneNoC           = linkageConfigGeneral.ZoneNoC;
     this.LayerNoC          = linkageConfigGeneral.LayerNoC;
     this.DeviceTypeCodeC   = linkageConfigGeneral.DeviceTypeCodeC;
 }
示例#9
0
 public int AddGeneralLinkageConfigInfo(LinkageConfigGeneral linkageConfigGeneral)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// 更新指定通用组态ID的数据
        /// </summary>
        /// <param name="id">待更新数据的ID</param>
        /// <param name="columnNames">列名</param>
        /// <param name="data">新数据</param>
        /// <returns></returns>
        public bool UpdateViaSpecifiedColumnName(int id, string[] columnNames, string[] data)
        {
            try
            {
                LinkageConfigGeneral result = _controller.GeneralConfig.Find(
                    delegate(LinkageConfigGeneral x)
                {
                    return(x.ID == id);
                }
                    );
                for (int i = 0; i < columnNames.Length; i++)
                {
                    switch (columnNames[i])
                    {
                    //case "编号":
                    //    result.Code = data[i];
                    //    break;
                    case "动作常数":
                        result.ActionCoefficient = Convert.ToInt32(data[i]);
                        break;

                    case "A类别":
                    {
                        switch (data[i])
                        {
                        case "本系统":
                            result.CategoryA = 0;
                            break;

                        case "它系统":
                            result.CategoryA = 1;
                            break;

                        case "全系统":
                            result.CategoryA = 2;
                            break;
                        }
                    }
                    break;

                    case "A楼号":
                        result.BuildingNoA = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "A区号":
                        result.ZoneNoA = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "A层号1":
                        result.LayerNoA1 = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "A层号2":
                        result.LayerNoA2 = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "A类型":
                        result.DeviceTypeCodeA = Convert.ToInt16(data[i]);
                        break;

                    case "C分类":
                    {
                        LinkageType linkageType = result.TypeC;
                        Enum.TryParse <LinkageType>(EnumUtility.GetEnumName(linkageType.GetType(), data[i]), out linkageType);
                        result.TypeC = linkageType;
                    }
                    break;

                    case "C楼号":
                        result.BuildingNoC = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "C区号":
                        result.ZoneNoC = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "C层号":
                        result.LayerNoC = new Nullable <int>(Convert.ToInt32(data[i]));
                        break;

                    case "C机号":
                        result.MachineNoC = data[i].ToString();
                        break;

                    case "C回路号":
                        result.LoopNoC = data[i].ToString();
                        break;

                    case "C编号":
                        result.DeviceCodeC = data[i].ToString();
                        break;

                    case "C类型":
                        result.DeviceTypeCodeC = Convert.ToInt16(data[i]);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }