Пример #1
0
        /// <summary>
        /// 添加设备的监听事件
        /// </summary>
        /// <param name="appkey"></param>
        /// <param name="infokey"></param>
        public void ListenEquipAll(string appkey, string infokey)
        {
            DataResult dr = new DataResult();

            if (string.IsNullOrEmpty(appkey) || string.IsNullOrEmpty(infokey))
            {
                dr = ApiCode.Code1003(dr);
            }
            else
            {
                dr = ServerLib.VerifyService(appkey, infokey, 1);
            }
            if (dr.code != 200)
            {
                string drs = new JavaScriptSerializer().Serialize(dr);
                ServerLib.ErrorLog(drs, "");
                return;
            }

            Dictionary <int, myEquipItem> equipItem = Proxy_DataCenter.EqpItemDict;

            foreach (myEquipItem my in equipItem.Values)
            {
                my.EquipItem.PropertyChanged += EquipItem_PropertyChanged;
            }
        }
Пример #2
0
        public object get_equip_3(JObject obj)
        {
            DataResult dr = new DataResult();
            //注意:post请求参数为JObject类型
            dynamic json        = obj; //动态解析参数
            string  allHTML     = json.allHTML;
            string  fileName    = json.fileName;
            string  number      = json.number;
            string  objoriginal = json.objoriginal;


            string sql = "insert into WelcomingSpeech(JSONContent,BGImage,Type,siginalVal) values('" + allHTML + "','" + fileName + "','" + number + "','" + objoriginal + "')";

            dr = ServerLib.ExecuteSQL(sql);//内置接口,执行查询SQL
            return(dr);



            // if (string.IsNullOrEmpty(name) && string.IsNullOrEmpty(age))
            // {
            //     return ApiCode.Code1003(dr);
            // }

            // string str = "POST your input name:" + name + ",age:" + age;
            // dr.data = str;
            // return dr;
        }
Пример #3
0
		static int Main()
		{
			ServerLib server = new ServerLib(8888, "Test");
			server.Run();
			Console.ReadLine ();
			return 0;
		}
Пример #4
0
        public object get_equip_2(string equip_no)
        {
            DataResult dr  = new DataResult();
            string     sql = "select * from Equip where equip_no=" + equip_no;

            dr = ServerLib.GetDataTableSQL(sql);//内置接口,执行查询SQL
            return(dr);
        }
Пример #5
0
        public object GetDataTableFromSQL()
        {
            DataResult dr  = new DataResult();
            string     sql = "select top 1 *  from WelcomingSpeech where Type=0 order by ID desc";

            dr = ServerLib.GetDataTableSQL(sql);//内置接口,执行查询SQL
            return(dr);
        }
Пример #6
0
        public object GetSetParmItem(string equip_no, string set_no)
        {
            DataResult dr = new DataResult();

            //判断是否为空
            if (string.IsNullOrEmpty(equip_no) && string.IsNullOrEmpty(set_no))
            {
                return(ApiCode.Code1003(dr));
            }
            string sql = "select * from setParm where equip_no =" + equip_no + " and set_no=" + set_no;

            dr = ServerLib.GetDataTableSQL(sql);//内置接口,执行查询SQL
            return(dr);
        }
Пример #7
0
 /// <summary>
 /// yxp测点的监听事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DictEquipItem_PropertyChanged_yxp(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "m_YXState" || e.PropertyName == "m_IsAlarm" || e.PropertyName == "m_AdviceMsg")
     {
         try
         {
             myProxy_YXItem dictEquipItem = (myProxy_YXItem)sender;
             var            str           = dictEquipItem.m_iYXNo + "," + dictEquipItem.m_YXNm + "," + dictEquipItem.m_YXState + "," + dictEquipItem.m_AdviceMsg + "," + dictEquipItem.m_IsAlarm;
             Clients.Caller.sendYxpSingle(str);
         }
         catch (Exception ex)
         {
             ServerLib.ErrorLog(ex.ToString(), "");
             Clients.Caller.sendConnect(ex.ToString());
         }
     }
 }
Пример #8
0
 /// <summary>
 /// 设备的监听事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EquipItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "m_State")
     {
         try
         {
             myProxy_EquipItem dictEquipItem = (myProxy_EquipItem)sender;
             var str = dictEquipItem.m_iEquipNo + "," + dictEquipItem.m_EquipNm + "," + dictEquipItem.m_State + ";";
             str = str.Substring(0, str.Length - 1);
             Clients.Caller.sendEquipSingle(str);
         }
         catch (Exception ex)
         {
             ServerLib.ErrorLog(ex.ToString(), "");
             Clients.Caller.sendConnect(ex.ToString());
         }
     }
 }
Пример #9
0
 public LibDisplay(ServerLib lib)
 {
     this.Id = lib.Id;
     this.Name = lib.DisplayName;
     //this.ImagePath = @"V:\MyProjects\Cameyo\Debug\LibCache.Icons\" + serverApp.PkgId + ".icon";
 }
Пример #10
0
        /// <summary>
        /// 获取设备ycp,yxp测点的实时状态并添加监听事件
        /// </summary>
        /// <param name="select">设备号</param>
        /// <param name="appkey"></param>
        /// <param name="infokey"></param>
        public void StartListen(int select, string appkey, string infokey)
        {
            DataResult dr = new DataResult();

            dr = null;

            if (string.IsNullOrEmpty(appkey) || string.IsNullOrEmpty(infokey))
            {
                dr = ApiCode.Code1003(dr);
            }
            else
            {
                Clients.Caller.sendAll("开始验证身份", "message");
                try
                {
                    dr = ServerLib.VerifyService(appkey, infokey, 1);
                }
                catch (Exception ex)
                {
                    Clients.Caller.sendAll("身份验证失败:" + ex, "message");
                }
            }
            if (dr.code != 200)
            {
                string drs = new JavaScriptSerializer().Serialize(dr);
                ServerLib.ErrorLog(drs, "");
                return;
            }

            myEquipItem equipItem = Proxy_DataCenter.EqpItemDict[select];

            var ycp = "[";
            Dictionary <int, myProxy_YCItem> dictEquipItem_ycp = equipItem.YCItemDict;

            foreach (myProxy_YCItem my in dictEquipItem_ycp.Values)
            {
                ycp += "{\"m_iYCNo\":\"" + my.m_iYCNo + "\",\"m_YCNm\":\"" + my.m_YCNm + "\",\"m_YCValue\":\"" + my.m_YCValue.ToString() + "\",\"m_AdviceMsg\":\"" + my.m_AdviceMsg + "\",\"m_IsAlarm\":\"" + my.m_IsAlarm + "\",\"m_Unit\":\"" + my.m_Unit + "\"},";
                my.PropertyChanged += DictEquipItem_PropertyChanged_ycp;
            }
            ycp = ycp.Substring(0, ycp.Length - 1);
            if (ycp != "")
            {
                ycp += "]";
            }
            else
            {
                ycp = "[]";
            }
            Clients.Caller.sendAll(ycp, "ycp");

            var yxp = "[";
            Dictionary <int, myProxy_YXItem> dictEquipItem_yxp = equipItem.YXItemDict;

            foreach (myProxy_YXItem my in dictEquipItem_yxp.Values)
            {
                yxp += "{\"m_iYXNo\":\"" + my.m_iYXNo + "\",\"m_YXNm\":\"" + my.m_YXNm + "\",\"m_YXState\":\"" + my.m_YXState + "\",\"m_AdviceMsg\":\"" + my.m_AdviceMsg + "\",\"m_IsAlarm\":\"" + my.m_IsAlarm + "\"},";
                my.PropertyChanged += DictEquipItem_PropertyChanged_yxp;
            }
            yxp = yxp.Substring(0, yxp.Length - 1);
            if (yxp != "")
            {
                yxp += "]";
            }
            else
            {
                yxp = "[]";
            }

            Clients.Caller.sendAll(yxp, "yxp");
        }