Example #1
0
		/// <summary>
		/// Initialize and start new session here. Session isn't added to session list automatically, 
		/// session must add itself to server session list by calling AddSession().
		/// </summary>
		/// <param name="socket">Connected client socket.</param>
        /// <param name="bindInfo">BindInfo what accepted socket.</param>
		protected override void InitNewSession(Socket socket,BindInfo bindInfo)
		{/*
            // Check maximum conncurent connections from 1 IP.
            if(m_MaxConnectionsPerIP > 0){
                lock(this.Sessions){
                    int nSessions = 0;
                    foreach(SocketServerSession s in this.Sessions){
                        IPEndPoint ipEndpoint = s.RemoteEndPoint;
                        if(ipEndpoint != null){
                            if(ipEndpoint.Address.Equals(((IPEndPoint)socket.RemoteEndPoint).Address)){
                                nSessions++;
                            }
                        }

                        // Maximum allowed exceeded
                        if(nSessions >= m_MaxConnectionsPerIP){
                            socket.Send(System.Text.Encoding.ASCII.GetBytes("-ERR Maximum connections from your IP address is exceeded, try again later !\r\n"));
                            socket.Shutdown(SocketShutdown.Both);
                            socket.Close();
                            return;
                        }
                    }
                }
            }*/

            string   sessionID = Guid.NewGuid().ToString();
            SocketEx socketEx  = new SocketEx(socket);
            if(LogCommands){
                //socketEx.Logger = new SocketLogger(socket,this.SessionLog);
				//socketEx.Logger.SessionID = sessionID;
            }
			HTTP_Session session = new HTTP_Session(sessionID,socketEx,bindInfo,this);
		}
 public GameObjectGroupNameScopeArgBinder(
     BindInfo bindInfo,
     GameObjectBindInfo gameObjectInfo)
     : base(bindInfo)
 {
     GameObjectInfo = gameObjectInfo;
 }
Example #3
0
 public NonLazyBinder(BindInfo bindInfo)
 {
     BindInfo = bindInfo;
 }
 public InheritInSubContainersBinder(BindInfo bindInfo)
     : base(bindInfo)
 {
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="socket">Socket.</param>
 /// <param name="bindInfo">Bind info.</param>
 public QueuedConnection(Socket socket,BindInfo bindInfo)
 {
     m_pSocket   = socket;
     m_pBindInfo = bindInfo;
 }
Example #6
0
        public void ProcessRequest(HttpContext context)
        {
            string unit = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
            //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
            string beginTime = String.IsNullOrEmpty(context.Request["beginTime"].ToString()) ? string.Empty : context.Request["beginTime"].ToString();
            string endTime = String.IsNullOrEmpty(context.Request["endTime"].ToString()) ? string.Empty : context.Request["endTime"].ToString();
            string timeType = String.IsNullOrEmpty(context.Request["timeType"].ToString()) ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = String.IsNullOrEmpty(context.Request["quarterType"].ToString()) ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (quarterType)
            {
                case "0": //指定时间段

                    break;
                case "1"://月度平均值
                    DateTime dt1 = new DateTime();
                    dt1 = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                    beginTime = dh.GetFirstDayOfMonth(dt1).ToString();
                    endTime = dh.GetLastDayOfMonth(dt1).ToString();
                    break;
                case "2"://季度平均值
                    switch (quarterType)
                    {
                        case "0"://一季度
                            string ti = beginTime.Substring(0, 4) + "-01-01";
                            beginTime = ti;
                            endTime = beginTime.Substring(0, 4) + "-03-31";
                            break;
                        case "1"://二季度
                            string ti1 = beginTime.Substring(0, 4) + "-04-01";
                            beginTime = ti1;
                            endTime = beginTime.Substring(0, 4) + "-06-30";
                            break;
                        case "2"://三季度
                            string ti2 = beginTime.Substring(0, 4) + "-07-01";
                            beginTime = ti2;
                            endTime = beginTime.Substring(0, 4) + "-09-30";
                            break;
                        case "3"://四季度
                            string ti3 = beginTime.Substring(0, 4) + "-10-01";
                            beginTime = ti3;
                            endTime = beginTime.Substring(0, 4) + "-12-31";
                            break;
                    }
                    break;
                case "3"://年度平均值
                    string tim = beginTime.Substring(0, 4);
                    beginTime = tim + "01-01";
                    endTime = tim + "-12-31";
                    break;
            }

            List<IndicatorInfo> infoList = new List<IndicatorInfo>();

            //获取所有耗差类型。
            //infoList = bl.GetAllInfo(beginTime, endTime, unit, out errMsg);
            //foreach (var info in infoList)
            //{
            //    ConsumeInfo infos = new ConsumeInfo();
            //    infos.Name = info.Name;
            //    infos.Count = info.Count;
            //    infoList.Add(infos);
            //}

            //ConsumeInfo infos = new ConsumeInfo();
            //infos.Name = "主汽温度";
            //infos.Count = 45;

            //infoList.Add(infos);

            //infos = new ConsumeInfo();
            //infos.Name = "主汽压力(Mpa)";
            //infos.Count = 43;
            //infoList.Add(infos);

            //获取锅炉和汽机的所有耗差类型。
            infoList = bl.GetInfo(beginTime, endTime, unit, -1, -1, out errMsg);
            List<BindInfo> bindList = new List<BindInfo>();
            //总耗差值初始化
            double allValue = 0;
            ArrayList reason = new ArrayList();
            //锅炉可控
            List<IndicatorInfo> tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "0").ToList();
            BindInfo tmp = new BindInfo();
            double value = 0;
            tmp.name="锅炉可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;
            allValue += value;
            tmp.value=value.ToString();
            bindList.Add(tmp);

            //锅炉不可控
            tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "1").ToList();
            tmp = new BindInfo();
            value = 0;
            tmp.name = "锅炉不可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = value.ToString();
            bindList.Add(tmp);

            //汽机可控
            tmpList = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "0").ToList();
            tmp = new BindInfo();
            value = 0;
            tmp.name = "汽机可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = value.ToString();
            bindList.Add(tmp);

            //汽机不可控
            tmpList = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "1").ToList();
            tmp = new BindInfo();
            value = 0;
            tmp.name = "汽机不可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = value.ToString();
            bindList.Add(tmp);

            tmpList = infoList.Where(info => info.ConsumeType != "1" && info.TargetType != "1" && info.ConsumeType != "0" && info.TargetType != "0").ToList();
            tmp = new BindInfo();
            value = 0;
            tmp.name = "不可知因素能耗";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = value.ToString();
            bindList.Add(tmp);

            //总耗差
            tmp = new BindInfo();
            tmp.name = "总耗差";
            //tmp.value = allValue.ToString();
            tmp.value = "133.4";
            bindList.Add(tmp);

            //string content = bindList.ToJsonItem();
            int count = 0;
            object obj = new
            {
                total = count,
                rows = bindList
            };

            string result = JsonConvert.SerializeObject(obj);
            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(result);
        }
Example #7
0
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="sessionID">Session ID.</param>
        /// <param name="socket">Server connected socket.</param>
        /// <param name="bindInfo">BindInfo what accepted socket.</param>
        /// <param name="server">Reference to server.</param>
        internal HTTP_Session(string sessionID,SocketEx socket,BindInfo bindInfo,HTTP_Server server) : base(sessionID,socket,bindInfo,server)
        {
            m_pServer = server;

            StartSession();
        }
 public GameObjectNameGroupNameBinder(
     BindInfo bindInfo, GameObjectBindInfo gameObjectInfo)
     : base(bindInfo, gameObjectInfo)
 {
 }
Example #9
0
 //建立绑定,把绑定到的对象存起来,在表达式解析完成后,外面再监听这些对象的值变化
 private void SetBinding(object o, string path)
 {
     //条件部分不包括
     if (path != null)
     {
         int index = path.IndexOf("[");
         if (index != -1)
         {
             path = path.Substring(0, index);
         }
     }
     //如果建立过绑定,不重复建立
     BindInfo info = new BindInfo() {Object = o, Path = path};
     if (!this.binds.Contains(info))
     {
         //把绑定信息存起来,以便检查
         binds.Add(info);
         //建立绑定关系
         Binding b = new Binding();
         b.Source = o;
         b.Path = new System.Windows.PropertyPath(path);
         BindingSlave bs = new BindingSlave();
         BindingOperations.SetBinding(bs, BindingSlave.ValueProperty, b);
         Bindings.Add(bs);
     }
 }
 public ConcreteIdBinderNonGeneric(
     BindInfo bindInfo,
     BindFinalizerWrapper finalizerWrapper)
     : base(bindInfo, finalizerWrapper)
 {
 }
Example #11
0
 public IdScopeBinder(BindInfo bindInfo)
     : base(bindInfo)
 {
 }
 public FactoryToChoiceIdBinder(
     DiContainer bindContainer, BindInfo bindInfo, FactoryBindInfo factoryBindInfo)
     : base(bindContainer, bindInfo, factoryBindInfo)
 {
 }
 public NameTransformConditionCopyNonLazyBinder(
     BindInfo bindInfo, GameObjectCreationParameters gameObjectInfo)
     : base(bindInfo, gameObjectInfo)
 {
 }
 /// <summary>
 /// 构造函数,绑定信息
 /// </summary>
 /// <param name="bindInfo"></param>
 public BindAsName(BindInfo bindInfo)
 {
     this.bindInfo = bindInfo;
 }
Example #15
0
        public void ProcessRequest(HttpContext context)
        {
            string unit = context.Request["unit"] == null ? string.Empty : context.Request["unit"].ToString();

            //string unit = String.IsNullOrEmpty(context.Request["unit"].ToString()) ? string.Empty : context.Request["unit"].ToString();
            //string time = String.IsNullOrEmpty(context.Request["time"].ToString())?  string.Empty:context.Request["time"].ToString() ;
            string beginTime   = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString();
            string endTime     = context.Request["endTime"] == null ? string.Empty : context.Request["endTime"].ToString();
            string timeType    = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString();
            string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString();

            //根据选择的时间段,设置开始时间和结束时间
            switch (timeType)
            {
            case "0":     //指定时间段

                break;

            case "1":    //月度平均值
                DateTime dt1 = new DateTime();
                dt1       = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01");
                beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-");
                endTime   = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-");
                break;

            case "2":    //季度平均值
                switch (quarterType)
                {
                case "0":        //一季度
                    string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00";
                    beginTime = ti;
                    endTime   = beginTime.Substring(0, 4) + "-03-31 23:59:59";
                    break;

                case "1":        //二季度
                    string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00";
                    beginTime = ti1;
                    endTime   = beginTime.Substring(0, 4) + "-06-30 23:59:59";
                    break;

                case "2":        //三季度
                    string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00";
                    beginTime = ti2;
                    endTime   = beginTime.Substring(0, 4) + "-09-30 23:59:59";
                    break;

                case "3":        //四季度
                    string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00";
                    beginTime = ti3;
                    endTime   = beginTime.Substring(0, 4) + "-12-31 23:59:59";
                    break;
                }
                break;

            case "3":    //年度平均值
                string tim = beginTime.Substring(0, 4);
                beginTime = tim + "-01-01 00:00:00";
                endTime   = tim + "-12-31 23:59:59";
                break;
            }

            List <IndicatorInfo> infoList = new List <IndicatorInfo>();

            //获取所有耗差类型。
            //infoList = bl.GetAllInfo(beginTime, endTime, unit, out errMsg);
            //foreach (var info in infoList)
            //{
            //    ConsumeInfo infos = new ConsumeInfo();
            //    infos.Name = info.Name;
            //    infos.Count = info.Count;
            //    infoList.Add(infos);
            //}

            //ConsumeInfo infos = new ConsumeInfo();
            //infos.Name = "主汽温度";
            //infos.Count = 45;

            //infoList.Add(infos);

            //infos = new ConsumeInfo();
            //infos.Name = "主汽压力(Mpa)";
            //infos.Count = 43;
            //infoList.Add(infos);

            //获取锅炉和汽机的所有耗差类型。
            infoList = bl.GetInfo(beginTime, endTime, unit, -1, -1, out errMsg);
            List <BindInfo> bindList = new List <BindInfo>();
            //总耗差值初始化
            double    allValue = 0;
            ArrayList reason   = new ArrayList();
            //锅炉可控
            List <IndicatorInfo> tmpList = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "0").ToList();
            BindInfo             tmp     = new BindInfo();
            double value = 0;

            tmp.name = "锅炉可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            //value = 32.23;
            allValue += value;
            tmp.value = Math.Round(value, 2).ToString();
            bindList.Add(tmp);


            //锅炉不可控
            tmpList  = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "0").ToList();
            tmp      = new BindInfo();
            value    = 0;
            tmp.name = "锅炉不可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = Math.Round(value, 2).ToString();
            bindList.Add(tmp);

            //汽机可控
            tmpList  = infoList.Where(info => info.ConsumeType == "0" && info.TargetType == "1").ToList();
            tmp      = new BindInfo();
            value    = 0;
            tmp.name = "汽机可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = Math.Round(value, 2).ToString();
            bindList.Add(tmp);


            //汽机不可控
            tmpList  = infoList.Where(info => info.ConsumeType == "1" && info.TargetType == "1").ToList();
            tmp      = new BindInfo();
            value    = 0;
            tmp.name = "汽机不可控";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = Math.Round(value, 2).ToString();
            bindList.Add(tmp);


            tmpList  = infoList.Where(info => info.ConsumeType != "1" && info.TargetType != "1" && info.ConsumeType != "0" && info.TargetType != "0").ToList();
            tmp      = new BindInfo();
            value    = 0;
            tmp.name = "不可知因素能耗";
            foreach (var info in tmpList)
            {
                value += info.ConsumeValue;
            }
            allValue += value;
            tmp.value = Math.Round(value, 2).ToString();
            bindList.Add(tmp);

            //总耗差
            tmp      = new BindInfo();
            tmp.name = "总耗差";
            //tmp.value = allValue.ToString();
            tmp.value = Math.Round(allValue, 2).ToString();
            bindList.Add(tmp);

            //string content = bindList.ToJsonItem();
            int    count = 0;
            object obj   = new
            {
                total = count,
                rows  = bindList
            };

            string result = JsonConvert.SerializeObject(obj);

            context.Response.ContentType = "text/json;charset=gb2312;";
            context.Response.Write(result);
        }
 public NonLazyBinder(BindInfo bindInfo)
 {
     BindInfo = bindInfo;
 }