Exemple #1
0
        //刷新左侧菜单报警状态
        public JsonResult ReloadState()
        {
            if (!string.IsNullOrEmpty(PrjGUID))
            {
                BLL.tHostInfo   bllhost = new BLL.tHostInfo();
                Model.tHostInfo modhost = new Model.tHostInfo();

                MainViewModel mainVM = new MainViewModel();
                DataTable     dt     = bllhost.GetHostInfo("dbo.tHostInfo.sProjectInfoGUID='" + PrjGUID + "'");

                if (dt != null)
                {
                    dt.Columns.Add("hostByLightCount");
                    dt.Columns.Add("hostByAlarmLightCount");
                    HostInfoVM hvm;


                    foreach (DataRow dr in dt.Rows)
                    {
                        hvm = addInfo(dr);
                        mainVM.HostInfos.Add(hvm);
                    }
                    ;
                }
                return(this.Json(mainVM.HostInfos));
            }
            else
            {
                return(this.Json(""));
            }
        }
Exemple #2
0
        public ActionResult GetDeviceTreeForJson()
        {
            string prjGUID = this.PrjGUID;

            if (string.IsNullOrEmpty(prjGUID))
            {
                return(null);
            }
            BLL.tHostInfo             hiBLL  = new BLL.tHostInfo();
            BLL.tLightInfoes          liBLL  = new BLL.tLightInfoes();
            List <Model.tHostInfo>    hiList = hiBLL.GetModelListByPrjGUID(prjGUID);
            List <Model.tLightInfoes> liList;

            if (hiList.Count == 0)
            {
                return(null);
            }
            StringBuilder result = new StringBuilder();

            result.Append("[");
            for (int i = 0; i < hiList.Count; i++)
            {
                Model.tHostInfo hi = hiList[i];

                result.Append("{\"id\":\"" + hi.sGUID + "\",");
                result.Append("\"text\":\"" + hi.sName + "\",");
                result.Append("\"icon\":\"" + "fa fa-warning icon-state-danger" + "\",");
                result.Append("\"state\":{\"opened\": false},");
                result.Append("\"children\":[");  // 下面是子节点,注意]关闭
                liList = liBLL.GetModelListByHostGUID(hi.sGUID);
                for (int j = 0; j < liList.Count; j++)
                {
                    Model.tLightInfoes li = liList[j];

                    result.Append("{\"id\":\"" + li.sGUID + "\",");
                    result.Append("\"text\":\"" + li.sName + "\",");
                    result.Append("\"icon\":\"" + "fa fa-warning icon-state-danger" + "\"}");
                    if (j < liList.Count - 1)
                    {
                        result.Append(",");
                    }
                }
                result.Append("]}");
                if (i < hiList.Count - 1)
                {
                    result.Append(",");
                }
            }
            result.Append("]");
            return(Content(result.ToString()));
        }
Exemple #3
0
        public JsonResult AllMarker()
        {
            BLL.tHostInfo   bllhost = new BLL.tHostInfo();
            Model.tHostInfo modhost = new Model.tHostInfo();
            MainViewModel   mainVM  = new MainViewModel();

            if (Request.QueryString["sGUID"] != null)
            {
                DataTable dt = bllhost.GetHostInfo("dbo.tHostInfo.sGUID='" + Request.QueryString["sGUID"] + "'");
                //mainVM.maxLat = GetMaxLat(Request.QueryString["sGUID"].ToString());
                //mainVM.maxlng = GetMaxLng(Request.QueryString["sGUID"].ToString());
                if (dt != null)
                {
                    dt.Columns.Add("hostByLightCount");
                    dt.Columns.Add("hostByAlarmLightCount");
                    HostInfoVM hvm;
                    foreach (DataRow dr in dt.Rows)
                    {
                        hvm = addInfo(dr);
                        //hvm = new HostInfoVM();
                        //hvm.GUID = dr["sGUID"].ToString();
                        //hvm.ID = ToString(dr["sID_Addr"]);
                        //hvm.Lat = ToString(dr["fLat"]);
                        //hvm.Lng = ToString(dr["fLng"]);
                        //hvm.Name = ToString(dr["sName"].ToString());
                        //hvm.UpdateTime = Convert.ToDateTime(ToString(dr["dUpdateTime"]) == "" ? "1999-01-01 00:00:00" : ToString(dr["dUpdateTime"]));
                        //hvm.GroupName = dr["GroupName"].ToString();
                        //hvm.Online = Convert.ToInt32(ToString(dr["iState_Online"]) == "" ? "0" : ToString(dr["iState_Online"]));
                        //hvm.Alarm = Convert.ToInt32(ToString(dr["iState_Alarm"]) == "" ? "0" : ToString(dr["iState_Alarm"]));
                        mainVM.HostInfos.Add(hvm);
                    }
                    // ViewBag.hostlist = mainVM.HostInfos;
                }
                return(this.Json(mainVM));
            }
            else
            {
                return(this.Json(""));
            }
        }
Exemple #4
0
        //模糊搜索
        public JsonResult SeachData()
        {
            if (Request.QueryString["sWhere"] != null)
            {
                BLL.tHostInfo   bllhost = new BLL.tHostInfo();
                Model.tHostInfo modhost = new Model.tHostInfo();

                MainViewModel mainVM = new MainViewModel();
                DataTable     dt     = bllhost.GetHostInfo(" dbo.tHostInfo.sProjectInfoGUID='" + PrjGUID + "' and dbo.tHostInfo.sName like'%" + Request.QueryString["sWhere"].ToString() + "%'");

                if (dt != null)
                {
                    dt.Columns.Add("hostByLightCount");
                    dt.Columns.Add("hostByAlarmLightCount");
                    HostInfoVM hvm;
                    foreach (DataRow dr in dt.Rows)
                    {
                        hvm = addInfo(dr);
                        //hvm = new HostInfoVM();
                        //hvm.GUID = dr["sGUID"].ToString();
                        //hvm.ID = ToString(dr["sID_Addr"]);
                        //hvm.Lat = ToString(dr["fLat"]);
                        //hvm.Lng = ToString(dr["fLng"]);
                        //hvm.Name = ToString(dr["sName"].ToString());
                        //hvm.sUpdateTime = ToString(dr["dUpdateTime"]) == "" ? "1999-01-01 00:00:00" : ToString(dr["dUpdateTime"]);
                        //hvm.GroupName = dr["GroupName"].ToString();
                        //hvm.Online = Convert.ToInt32(ToString(dr["iState_Online"]) == "" ? "0" : ToString(dr["iState_Online"]));
                        //hvm.Alarm = Convert.ToInt32(ToString(dr["iState_Alarm"]) == "" ? "0" : ToString(dr["iState_Alarm"]));
                        mainVM.HostInfos.Add(hvm);
                    }
                    ;
                }
                return(this.Json(mainVM.HostInfos));
            }
            else
            {
                return(this.Json(""));
            }
        }
Exemple #5
0
        public ActionResult HostRealStateDefaultView(string guid, int result, string datetime = "")
        {
            ModelState.Clear();
            BLL.tHostInfo               hostbll               = new BLL.tHostInfo();
            Model.tHostInfo             hostmodel             = new Model.tHostInfo();
            BLL.tMeasureConfigs         measureconfigbll      = new BLL.tMeasureConfigs();
            Model.tMeasureConfigs       measureconfigmodel    = new Model.tMeasureConfigs();
            BLL.tBranchConfigs          branchconfigbll       = new BLL.tBranchConfigs();
            List <Model.tBranchConfigs> branchconfigmodellist = new List <Model.tBranchConfigs>();

            BLL.tMeasureInfoes          measurebll       = new BLL.tMeasureInfoes();
            Model.tMeasureInfoes        measuremodel     = new Model.tMeasureInfoes();
            List <Model.tMeasureInfoes> measuremodellist = new List <Model.tMeasureInfoes>();

            Model.tMeasurePowerInfoes   measurepowermodel   = new Model.tMeasurePowerInfoes();
            BLL.tMeasurePowerInfoes     measurepowerbll     = new BLL.tMeasurePowerInfoes();
            Model.tMeasureCurrentInfoes measurecurrentmodel = new Model.tMeasureCurrentInfoes();
            BLL.tMeasureCurrentInfoes   measurecurrentbll   = new BLL.tMeasureCurrentInfoes();

            A = new GetAllStateVM();
            A.OneCircuitList               = new MeasureState();
            A.TwoCircuitList               = new MeasureState();
            A.ThreeCircuitList             = new MeasureState();
            A.ThreeCircuitList.CircuitList = new List <CircuitStateVM>();
            A.OneCircuitList.CircuitList   = new List <CircuitStateVM>();
            A.TwoCircuitList.CircuitList   = new List <CircuitStateVM>();
            //default
            A.Name                    = "获取失败";
            A.MesureCount             = 0;
            A.UpdateTime              = "获取失败";
            A.OneCircuitList.AState   = "获取失败";
            A.OneCircuitList.BState   = "获取失败";
            A.OneCircuitList.CState   = "获取失败";
            A.OneCircuitList.Avoltage = "N/A";
            A.OneCircuitList.Bvoltage = "N/A";
            A.OneCircuitList.Cvoltage = "N/A";
            A.guid                    = guid;

            switch (result)
            {
            case 0:
                A.Name = "参数错误";
                return(View(A));

            case 1:
                A.Name = "主机未设置地址";
                return(View(A));

            case 2:
                A.Name = "写数据库失败";
                return(View(A));

            case 3:
                A.Name = "参数错误";
                return(View(A));

            case 4:
                A.Name = "无此主机";
                return(View(A));

            case 5:
                A.Name = "未配置测量板";
                return(View(A));

            case 6:
                A.Name = "无返回";
                return(View(A));

            case 7:
                try
                {
                    DateTime ResultTime = DateTime.Parse(datetime);
                    hostmodel = hostbll.GetModel(guid);
                    if (hostmodel != null)
                    {
                        if (hostmodel.sName != null)
                        {
                            A.Name = hostmodel.sName;
                        }
                        measureconfigmodel = measureconfigbll.GetModelByHostGuid(guid);
                        if (measureconfigmodel != null)
                        {
                            if (measureconfigmodel.iMeasureNumber != null)
                            {
                                A.MesureCount = (int)measureconfigmodel.iMeasureNumber;
                                if (measuremodel.dCreateDate != null)
                                {
                                    A.UpdateTime = measuremodel.dCreateDate.ToString();
                                }
                                for (int i = 0; i < measureconfigmodel.iMeasureNumber; i++)
                                {
                                    measuremodel = measurebll.GetModelByHostGuidAndIdAndTime(guid, i + 1, ResultTime);
                                    if (measuremodel != null)
                                    {
                                        if (measuremodel.fVlotA != null)
                                        {
                                            A.OneCircuitList.Avoltage = measuremodel.fVlotA.ToString();
                                        }
                                        if (measuremodel.fVlotB != null)
                                        {
                                            A.OneCircuitList.Bvoltage = measuremodel.fVlotB.ToString();
                                        }
                                        if (measuremodel.fVlotC != null)
                                        {
                                            A.OneCircuitList.Cvoltage = measuremodel.fVlotC.ToString();
                                        }
                                        if (measuremodel.iAlarmVlotA != null)
                                        {
                                            switch ((VoltageAlarm)measuremodel.iAlarmVlotA)
                                            {
                                            case VoltageAlarm.Va_Normal: A.OneCircuitList.AState = "正常";
                                                break;

                                            case VoltageAlarm.Va_Zero: A.OneCircuitList.AState = "缺相";
                                                break;

                                            case VoltageAlarm.Va_OvUpper: A.OneCircuitList.AState = "过压";
                                                break;

                                            case VoltageAlarm.Va_OverLower: A.OneCircuitList.AState = "欠压";
                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        if (measuremodel.iAlarmVlotB != null)
                                        {
                                            switch ((VoltageAlarm)measuremodel.iAlarmVlotB)
                                            {
                                            case VoltageAlarm.Va_Normal: A.OneCircuitList.BState = "正常";
                                                break;

                                            case VoltageAlarm.Va_Zero: A.OneCircuitList.BState = "缺相";
                                                break;

                                            case VoltageAlarm.Va_OvUpper: A.OneCircuitList.BState = "过压";
                                                break;

                                            case VoltageAlarm.Va_OverLower: A.OneCircuitList.BState = "欠压";
                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        if (measuremodel.iAlarmVlotC != null)
                                        {
                                            switch ((VoltageAlarm)measuremodel.iAlarmVlotC)
                                            {
                                            case VoltageAlarm.Va_Normal: A.OneCircuitList.CState = "正常";
                                                break;

                                            case VoltageAlarm.Va_Zero: A.OneCircuitList.CState = "缺相";
                                                break;

                                            case VoltageAlarm.Va_OvUpper: A.OneCircuitList.CState = "过压";
                                                break;

                                            case VoltageAlarm.Va_OverLower: A.OneCircuitList.CState = "欠压";
                                                break;

                                            default:
                                                break;
                                            }
                                        }

                                        branchconfigmodellist = branchconfigbll.GetModelList("sMeasureConfigGUID = '" + measureconfigmodel.sGUID + "' and iEnable = " + StateEnable.Enable);
                                        if (branchconfigmodellist != null)
                                        {
                                            foreach (var item in branchconfigmodellist.OrderBy(c => c.iID))
                                            {
                                                if (item.iID != null)
                                                {
                                                    CircuitStateVM C = new CircuitStateVM();
                                                    measurepowermodel   = measurepowerbll.GetModelByHostGuidAndIDAndTime(measuremodel.sGUID, (int)item.iID);
                                                    measurecurrentmodel = measurecurrentbll.GetModelByHostGuidAndIDAndTime(measuremodel.sGUID, (int)item.iID);
                                                    if ((measurepowermodel != null) && (measurecurrentmodel != null))
                                                    {
                                                        if (measurecurrentmodel.fValue != null)
                                                        {
                                                            C.Current = measurecurrentmodel.fValue.ToString();
                                                        }
                                                        C.ID = item.iID.ToString();
                                                        if (measurepowermodel.fValue != null)
                                                        {
                                                            C.Power = measurepowermodel.fValue.ToString();
                                                        }
                                                        if (measurecurrentmodel.iAlarm != null)
                                                        {
                                                            switch ((CurrentAlarm)measurecurrentmodel.iAlarm)
                                                            {
                                                            case CurrentAlarm.I_Normal: C.State = "正常";
                                                                break;

                                                            case CurrentAlarm.IO_Nmatch_CIR: C.State = "接触器断路";
                                                                break;

                                                            case CurrentAlarm.IO_Nmatch_SW: C.State = "接触器吸合";
                                                                break;

                                                            case CurrentAlarm.IO_Nmatch_All: C.State = "回路开路";
                                                                break;

                                                            case CurrentAlarm.INO_Nmatch_CIR: C.State = "接触器未释放";
                                                                break;

                                                            case CurrentAlarm.INO_Nmatch_SW: C.State = "辅助触点故障";
                                                                break;

                                                            case CurrentAlarm.INO_Nmatch_All: C.State = "异常有电流";
                                                                break;

                                                            case CurrentAlarm.INO_OverUpper: C.State = "电流越上限";
                                                                break;

                                                            case CurrentAlarm.INO_OverLower: C.State = "电流越下限";
                                                                break;

                                                            default:
                                                                break;
                                                            }
                                                        }
                                                        if (item.iVoltType != null)
                                                        {
                                                            switch ((VoltageType)item.iVoltType)
                                                            {
                                                            case VoltageType.A: C.Phase = "A"; break;

                                                            case VoltageType.B: C.Phase = "B"; break;

                                                            case VoltageType.C: C.Phase = "C"; break;

                                                            default:
                                                                break;
                                                            }
                                                        }
                                                        if (item.iID <= 12)
                                                        {
                                                            A.OneCircuitList.CircuitList.Add(C);
                                                        }
                                                        else if (item.iID <= 24)
                                                        {
                                                            A.TwoCircuitList.CircuitList.Add(C);
                                                        }
                                                        else
                                                        {
                                                            A.ThreeCircuitList.CircuitList.Add(C);
                                                        }
                                                    }
                                                    //else
                                                    //{
                                                    //    //功率电流为null
                                                    //}
                                                }
                                                //else
                                                //{
                                                //    //item.id为null
                                                //}
                                            }
                                        }
                                        //else
                                        //{
                                        //    //回路表为空
                                        //}
                                    }
                                    //else
                                    //{
                                    //    //查询到的测量板信息为空
                                    //}
                                }
                                return(View(A));
                            }
                            else
                            {
                                //测量板个数为空
                                A.Name = "测量板个数为空";
                                return(View(A));
                            }
                        }
                        else
                        {
                            //测量板配置表为空
                            A.Name = "测量板配置表为空";
                            return(View(A));
                        }
                    }
                    else
                    {
                        //主机未找到
                        A.Name = "未找到该主机";
                        return(View(A));
                    }
                }
                catch
                {
                    //发生异常
                    A.Name = "异常错误";
                    return(View(A));
                }

            default:
                A.Name = "传输错误";
                return(View(A));
            }
        }
Exemple #6
0
        /// <summary>
        /// 发送命令
        /// </summary>
        /// <returns>Int</returns>
        public JsonResult GetHostRealStateCmdPost()
        {
            /*
             * result :
             * 0:参数错误
             * 1:主机未设置地址
             * 2:写数据库失败
             * 3:写成功
             */
            BLL.tHostInfo   bllhost = new BLL.tHostInfo();
            Model.tHostInfo modhost = new Model.tHostInfo();
            BLL.tCMDSends   bllsend = new BLL.tCMDSends();
            Model.tCMDSends modsend = new Model.tCMDSends();
            byte[]          bt1     = null;
            int             result  = 0;

            if (!string.IsNullOrWhiteSpace(Request.QueryString["sGuid"]))
            {
                Model.tHostInfo dt2 = bllhost.GetModel(Request.QueryString["sGuid"]);
                if (dt2 != null)
                {
                    if (!string.IsNullOrWhiteSpace(dt2.sID_Addr))
                    {
                        try
                        {
                            byte[] a = new byte[2];
                            a[0] = (byte)(int.Parse(dt2.sID_Addr) >> 8);
                            a[1] = (byte)(int.Parse(dt2.sID_Addr));
                            bt1  = LightGPRSProtocol.GetStringFor0x68((byte)CMDType.GetHostAllInfoCMD, a);
                            if (bt1 != null)
                            {
                                modsend.dCreateDate  = DateTime.Now;
                                modsend.dUpdateTime  = DateTime.Now;
                                modsend.sGUID        = Guid.NewGuid().ToString();
                                modsend.iContentType = (int)CMDType.GetHostAllInfoCMD;
                                string str = HexHelper.ByteArrayToHexString(bt1);
                                modsend.sContent = str;
                                modsend.iState   = (int)CMDState.NO;
                                if (dt2.iIDType != null)
                                {
                                    modsend.iHostIDType = dt2.iIDType;
                                }
                                if (dt2.iIDType != null)
                                {
                                    modsend.iHostIDType = dt2.iIDType;
                                }
                                if (!string.IsNullOrWhiteSpace(dt2.sID_Addr))
                                {
                                    modsend.sHostIDAddr = dt2.sID_Addr;
                                }
                                if (!string.IsNullOrWhiteSpace(dt2.sID_ID))
                                {
                                    modsend.sHostIDID = dt2.sID_ID;
                                }
                                if (!string.IsNullOrWhiteSpace(dt2.sID_IP))
                                {
                                    modsend.sHostIDIP = dt2.sID_IP;
                                }
                                if (!string.IsNullOrWhiteSpace(dt2.sID_MAC))
                                {
                                    modsend.sHostIDMAC = dt2.sID_MAC;
                                }
                                if (!string.IsNullOrWhiteSpace(dt2.sID_SIM))
                                {
                                    modsend.sHostIDSIM = dt2.sID_SIM;
                                }
                                if (bllsend.Add(modsend) == true)
                                {
                                    result = 3;
                                    return(Json(result));
                                }
                                else
                                {
                                    result = 2;
                                    return(Json(result));
                                }
                            }
                            else
                            {
                                result = 2;
                                return(Json(result));
                            }
                        }
                        catch (Exception)
                        {
                            result = 2;
                            return(Json(result));
                        }
                    }
                    else
                    {
                        result = 1;
                        return(Json(result));
                    }
                }
                else
                {
                    result = 0;
                    return(Json(result));
                }
            }
            else
            {
                result = 0;
                return(Json(result));
            }
        }
Exemple #7
0
        /// <summary>
        /// 获取是否返回成功
        /// </summary>
        /// <returns>StateResultClass</returns>
        public JsonResult HostRealStateReceiveState()
        {
            /*
             * 3:无GUID或sTime
             * 4: 无此主机
             * 5:没配置测量板
             * 6:无返回
             * 7:返回正确
             */

            StateResult result = new StateResult();

            BLL.tHostInfo               hostbll            = new BLL.tHostInfo();
            Model.tHostInfo             hostmodel          = new Model.tHostInfo();
            BLL.tMeasureConfigs         measureconfigbll   = new BLL.tMeasureConfigs();
            Model.tMeasureConfigs       measureconfigmodel = new Model.tMeasureConfigs();
            BLL.tMeasureInfoes          measurebll         = new BLL.tMeasureInfoes();
            Model.tMeasureInfoes        measuremodel       = new Model.tMeasureInfoes();
            List <Model.tMeasureInfoes> measuremodellist   = new List <Model.tMeasureInfoes>();

            BLL.tMeasurePowerInfoes          measurepowerbll       = new BLL.tMeasurePowerInfoes();
            List <Model.tMeasurePowerInfoes> measurepowermodellist = new List <Model.tMeasurePowerInfoes>();

            BLL.tMeasureCurrentInfoes          measurecurrentbll       = new BLL.tMeasureCurrentInfoes();
            List <Model.tMeasureCurrentInfoes> measurecurrentmodellist = new List <Model.tMeasureCurrentInfoes>();

            if (!string.IsNullOrWhiteSpace(Request.QueryString["sGuid"]) && (!string.IsNullOrWhiteSpace(Request.QueryString["sTime"])))
            {
                if ((hostmodel = hostbll.GetModel(Request.QueryString["sGuid"])) != null)
                {
                    if ((measureconfigmodel = measureconfigbll.GetModelByHostGuid(Request.QueryString["sGuid"])) != null)
                    {
                        if ((measuremodellist = measurebll.GetModelList("")).Count > 0)
                        {
                            DateTime dt1 = DateTime.Now;
                            dt1.AddSeconds(-int.Parse(Request.QueryString["sTime"]));
                            result.StateDateTime = dt1;
                            result.Stateresult   = 7;
                            return(Json(result));
                        }
                        else
                        {
                            //未返回数据
                            result.Stateresult = 6;
                            return(Json(result));
                        }
                    }
                    else
                    {
                        //没有配置测量板
                        result.Stateresult = 5;
                        return(Json(result));
                    }
                }
                else
                {
                    //没有该主机
                    result.Stateresult = 4;
                    return(Json(result));
                }
            }
            else
            {
                //没有传guid过来
                result.Stateresult = 3;
                return(Json(result));
            }
        }
Exemple #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LumluxSSYDB.Model.tHostInfo model)
 {
     return(dal.Update(model));
 }
Exemple #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(LumluxSSYDB.Model.tHostInfo model)
 {
     return(dal.Add(model));
 }
Exemple #10
0
 public HostInfo(Model.tHostInfo hi)
 {
     tHostInfo = hi;
 }
Exemple #11
0
 public HostInfo()
 {
     tHostInfo = new Model.tHostInfo();
 }