Exemple #1
0
        private void DrawCompareWave()
        {
            //关闭日期标志
            selectDateFlag = false;

            //标志已经启用对比功能
            compareFlag = true;
            //获取该风机点的风速集合
            compareWindSpeedList = FanPointDAL.GetWindSpeedOrWindDirectionOfSinglePoint(FanPointDAL.Type.风速, windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString(), cmbWindFanNumber.SelectedItem.ToString(), startTime, endTime);
            //获取该风机点的风向集合
            compareWindDirectionList = FanPointDAL.GetWindSpeedOrWindDirectionOfSinglePoint(FanPointDAL.Type.风向, windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString(), cmbWindFanNumber.SelectedItem.ToString(), startTime, endTime);
            //获取风速最大值和最小值
            compareWindSpeedMaxAndMin = new double[2];
            compareWindSpeedMaxAndMin = FanPointDAL.GetMaxMinDataOfSinglePoint(FanPointDAL.Type.风速, windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString(), cmbWindFanNumber.SelectedItem.ToString(), startTime, endTime);
            //获取风向最大值和最小值
            compareWindDirectionMaxAndMin = new double[2];
            compareWindDirectionMaxAndMin = FanPointDAL.GetMaxMinDataOfSinglePoint(FanPointDAL.Type.风向, windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString(), cmbWindFanNumber.SelectedItem.ToString(), startTime, endTime);

            //获取比较之后的风速最大值和最小值
            speedMax = GetMax(windSpeedMaxAndMin[0], compareWindSpeedMaxAndMin[0]);
            speedMin = GetMin(windSpeedMaxAndMin[1], compareWindSpeedMaxAndMin[1]);
            //获取比较之后的风向最大值和最小值
            directionMax = GetMax(windDirectionMaxAndMin[0], compareWindDirectionMaxAndMin[0]);
            directionMin = GetMin(windDirectionMaxAndMin[1], compareWindDirectionMaxAndMin[1]);

            //重新构建时间集合
            //将原始风机的时间加入新集合
            allDate = new List <DateTime?>();
            for (int i = 0; i < dateTimeCollection.Count; i++)
            {
                dateTimeCollection[i] = dateTimeCollection[i].Value.Date;
                allDate.Add(dateTimeCollection[i].Value.Date);
            }
            //将对比风机的时间加入新集合
            for (int i = 0; i < compareDateTimeCollection.Count; i++)
            {
                compareDateTimeCollection[i] = compareDateTimeCollection[i].Value.Date;
                if (allDate.Contains(compareDateTimeCollection[i].Value.Date) == false)
                {
                    allDate.Add(compareDateTimeCollection[i].Value.Date);
                }
            }
            allDate = allDate.OrderBy(d => d.Value.Date).ToList();//对日期排序

            //绘制风速图形
            Draw.DrawGrid(cvsWindSpeed, "#FF95310C");//此方法有清空canvas的操作
            Draw.DrawWord(cvsWindSpeed, this.CompanyName, this.WindFieldName, this.FanNumber, speedMax, speedMin, "#FF95310C", "(米/秒)", allDate, compareDateTimeCollection);
            Draw.DrawCompareCurve(cvsWindSpeed, windSpeedList, speedMax, speedMin, "#FF95310C", allDate, dateTimeCollection);
            Draw.DrawCompareCurve(cvsWindSpeed, compareWindSpeedList, speedMax, speedMin, "#FF104B00", allDate, compareDateTimeCollection);

            //绘制风向图形
            Draw.DrawGrid(cvsWindDirection, "#FF4D056E");//此方法有清空canvas的操作
            Draw.DrawWord(cvsWindDirection, this.CompanyName, this.WindFieldName, this.FanNumber, directionMax, directionMin, "#FF4D056E", "(度)", allDate, compareDateTimeCollection);
            Draw.DrawCompareCurve(cvsWindDirection, windDirectionList, directionMax, directionMin, "#FF4D056E", allDate, dateTimeCollection);
            Draw.DrawCompareCurve(cvsWindDirection, compareWindDirectionList, directionMax, directionMin, "#FF104B00", allDate, compareDateTimeCollection);
        }
Exemple #2
0
        // 创建excel
        private int CreateExcel()
        {
            //获取该风机点的所有数据
            List <FanPoint> fanDate = FanPointDAL.GetDateOfSingleFanByDate(windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime);
            //设置excel的标题名
            string excelTitle = this.CompanyName + "---" + this.WindFieldName + this.FanNumber + "号风机数据(" + fanDate[0].DateTime + "-" + fanDate[fanDate.Count - 1].DateTime + ")";
            //设置地址
            string address = "地址:" + windFieldOfFan.Province + windFieldOfFan.City + windFieldOfFan.DetailAddress;
            //创建EXCEL
            bool excelResult = SaveExcel.CreateExcel(filePath, excelTitle, address, fanDate, epg);

            return(0);
        }
Exemple #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //失能对比按钮
            btnAddCompare.IsEnabled = false;
            this.Title = this.CompanyName + "---" + this.WindFieldName + "---第 " + this.FanNumber + " 号风机";
            //获取当前风机的风场信息
            windFieldOfFan = AllWindFieldDAL.GetWindFieldByName(this.CompanyName, this.WindFieldName);
            //获得当前风机的最新数据
            FanPoint fp = FanPointDAL.GetSinglePoint(windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber);



            txtbkDigital.Text = "业主名称:" + windFieldOfFan.CompanyName + "\n"
                                + "风场名称:" + windFieldOfFan.WindFieldName + "\n"
                                + "地址:" + windFieldOfFan.Province + windFieldOfFan.City + windFieldOfFan.DetailAddress + "\n\n"
                                + "-------------------------------\n"
                                + "风机型号:" + windFieldOfFan.FanModelNumber + "\n"
                                + "风机高度:" + windFieldOfFan.FanHeight + "\n"
                                + "测风仪型号:" + windFieldOfFan.AnemoscopeModelNumber + "\n"
                                + "-------------------------------\n"
                                + "经纬度:" + fp.GPS_lng + "E  " + fp.GPS_lat + "N\n"
                                + "风机号:" + fp.FanNumber + "\n"
                                + "风速:" + fp.WindSpeed + "\n"
                                + "风向:" + fp.WindDirection + "\n"
                                + "临时IP:" + fp.TempIp + "\n"
                                + "海拔:" + fp.Elevation + "\n"
                                + "航向:" + fp.Course + "\n"
                                + "航速:" + fp.NavigationalSpeed + "\n"
                                + "温度:" + fp.Temperature + "\n"
                                + "湿度:" + fp.Humidity + "\n"
                                + "气压:" + fp.AirPressure + "\n";



            //预加载省份
            provinceArray = AllWindFieldDAL.GetAllProvince();
            if (provinceArray != null)
            {
                //如果查到了省份,则加载到复选框
                List <string> provinceList = new List <string>();
                provinceList.Add("全国范围");
                provinceList.AddRange(provinceArray);
                cmbProvince.ItemsSource  = provinceList;//加载省份
                cmbProvince.SelectedItem = "全国范围";
            }

            //预加载所有公司名称
            companyArray = AllWindFieldDAL.GetCompanyName();
            LoadCompany("全国范围", companyArray);
        }
Exemple #4
0
 //选择风场
 private void cmbWindFieldName_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (cmbWindFieldName.SelectedItem == null)
     {
         return;
     }
     if (cmbWindFieldName.SelectedItem.ToString() == "风场名称")
     {
         cmbWindFanNumber.ItemsSource = null;
         return;
     }
     //获得此风机所在的表名 awf.BranchTableName
     windFieldOfCompareFan = AllWindFieldDAL.GetWindFieldByName(cmbCompanyName.SelectedItem.ToString(), cmbWindFieldName.SelectedItem.ToString());
     //获得此风场下的所有风机编号
     int[] fanNumber = FanPointDAL.GetFanNumber(windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString());
     cmbWindFanNumber.ItemsSource = fanNumber;
 }
Exemple #5
0
        //加入对比
        private void btnAddCompare_Click(object sender, RoutedEventArgs e)
        {
            if (cmbWindFanNumber.SelectedItem == null)
            {
                //标志已经关闭对比功能
                compareFlag = false;
                MessageBox.Show("请先选择要加入对比的风机再执行此操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            //获取当前风机的时间集合
            compareDateTimeCollection = FanPointDAL.GetDateTimeCollectionOfSingleFan(windFieldOfCompareFan.BranchTableName, cmbWindFieldName.SelectedItem.ToString(), cmbWindFanNumber.SelectedItem.ToString(), startTime, endTime);
            if (compareDateTimeCollection == null)
            {
                //标志已经关闭对比功能
                compareFlag = false;
                MessageBox.Show("没有检索到该风机的任何风速风向数据!", "啥也没找到", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            //另开线程绘制对比曲线
            Task <int> drawTask = new Task <int>(() => { return(DrawCompareTask()); });

            drawTask.Start();//开始工作
        }
Exemple #6
0
        private void DrawWave()
        {
            //标志已经关闭对比功能
            compareFlag = false;
            //获取起始时间
            startTime = dpStart.SelectedDate;
            //获取终止时间
            endTime = dpEnd.SelectedDate;
            if (startTime == null || endTime == null)
            {
                //重置日期标志为false
                selectDateFlag = false;
                MessageBox.Show("要查询的起止时间不能为空,请选择时间!");
                return;
            }
            if (startTime >= endTime)
            {
                //重置日期标志为false
                selectDateFlag = false;
                MessageBox.Show("您选择的时间不对,请重新输入");
                return;
            }


            //获取当前风机的时间集合
            dateTimeCollection = FanPointDAL.GetDateTimeCollectionOfSingleFan(windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime);
            if (dateTimeCollection == null)
            {
                MessageBox.Show("没有检索到该风机的任何风速风向数据!", "啥也没找到", MessageBoxButton.OK, MessageBoxImage.Warning);
                Draw.DrawGrid(cvsWindSpeed, "#FF95310C");     //此方法有清空canvas的操作
                Draw.DrawGrid(cvsWindDirection, "#FF4D056E"); //此方法有清空canvas的操作
                //重置日期标志为false
                selectDateFlag = false;
                return;
            }

            //重置日期标志为true
            selectDateFlag = true;
            //使能对比按钮
            btnAddCompare.IsEnabled = true;

            //获取当前风机的风速集合
            windSpeedList = FanPointDAL.GetWindSpeedOrWindDirectionOfSinglePoint(FanPointDAL.Type.风速, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime);
            //获取当前风机的风向集合
            windDirectionList = FanPointDAL.GetWindSpeedOrWindDirectionOfSinglePoint(FanPointDAL.Type.风向, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime);
            //获取风速最大值和最小值
            windSpeedMaxAndMin = new double[2];
            windSpeedMaxAndMin = FanPointDAL.GetMaxMinDataOfSinglePoint(FanPointDAL.Type.风速, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime);
            //获取风向最大值和最小值
            windDirectionMaxAndMin = new double[2];
            windDirectionMaxAndMin = FanPointDAL.GetMaxMinDataOfSinglePoint(FanPointDAL.Type.风向, windFieldOfFan.BranchTableName, this.WindFieldName, this.FanNumber, startTime, endTime);



            //绘制风速数据
            Draw.DrawGrid(cvsWindSpeed, "#FF95310C");//此方法有清空canvas的操作
            Draw.DrawWord(cvsWindSpeed, this.CompanyName, this.WindFieldName, this.FanNumber, windSpeedMaxAndMin[0], windSpeedMaxAndMin[1], "#FF95310C", "(米/秒)", dateTimeCollection, null);
            Draw.DrawCurve(cvsWindSpeed, windSpeedList, windSpeedMaxAndMin[0], windSpeedMaxAndMin[1], "#FF95310C");

            //绘制风向数据
            Draw.DrawGrid(cvsWindDirection, "#FF4D056E");//此方法有清空canvas的操作
            Draw.DrawWord(cvsWindDirection, this.CompanyName, this.WindFieldName, this.FanNumber, windDirectionMaxAndMin[0], windDirectionMaxAndMin[1], "#FF4D056E", "(度)", dateTimeCollection, null);
            Draw.DrawCurve(cvsWindDirection, windDirectionList, windDirectionMaxAndMin[0], windDirectionMaxAndMin[1], "#FF4D056E");

            return;
        }
Exemple #7
0
        private void loginWork()
        {
            //首先检查数据库连接
            if (LoginDAL.CheckDBConnection() != 0)
            {
                MessageBox.Show("连接失败,请检查网络连接!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                btnLogin.Content = "登录失败";
                return;
            }
            //获取全国的风机数量
            int pointNum = FanPointDAL.GetAllPoints().Count;

            labPointNum.Content = pointNum + " 台";
            //获取全国风场数量
            int windFieldNum = AllWindFieldDAL.GetWindFieldNumber();

            labWindFieldNumber.Content = windFieldNum + "个";
            //获取全国的公司数量
            int companyNum = AllWindFieldDAL.GetCompanyNumber();

            labCompanyNumber.Content = companyNum + " 家";
            initEvent(); //加载地图


            int ErrorTimeSpanMin = 30;//为保证账户安全,设置多次登录错误后的用户需要等待的时间

            if (cbxUserName.Text == "用户名" || pwx.Password == "*#*#*#")
            {
                MessageBox.Show("用户名或密码有误,请重新输入!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                cbxUserName.Focus();
                return;
            }
            User user = LoginDAL.GetAccountByUserName(cbxUserName.Text);//获取当前的用户信息

            if (user == null)
            {
                MessageBox.Show("不存在此用户!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                cbxUserName.Focus();
                return;
            }
            else
            {
                //如果距离上次登录成功已经超过30分钟,则将登录错误次数清零
                if (user.LoginTime != null)
                {
                    DateTime dt = LoginDAL.GetServerTime();                //获取服务器当前时间
                    TimeSpan ts = dt - (DateTime)user.LoginTime;           //获取当前用户最新的上一次登录的时间
                    if (ts.TotalMinutes >= ErrorTimeSpanMin)               //如果用户长时间没登录过,则将以前的登录错误次数清零
                    {
                        LoginDAL.ResetErrorTimesByUserName(user.UserName); //登录错误次数清零
                        user.ErrorTimes = 0;                               //本地记录的登录错误次数清零
                    }
                    else if (user.ErrorTimes >= 3)                         //如果登录错误次数超过了3次,则禁止用户在 ErrorTimeSpanMin 时间内登录(单位/分钟)
                    {
                        MessageBox.Show("登录失败次数过多,请 "
                                        + Math.Ceiling(ErrorTimeSpanMin - ts.TotalMinutes)
                                        + " 分钟后重试!",
                                        "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                        return;
                    }
                }
            }

            string passWord = LoginDAL.GetMD5(pwx.Password);//获取加密后的密码

            if (passWord != user.Password)
            {
                LoginDAL.UpdateErrorTimesByUserName(user.UserName); //登录错误次数+1
                LoginDAL.UpdateLoginTimeByUserName(user.UserName);  //更新登录时间
                MessageBox.Show("密码不正确,请重新输入!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                pwx.Focus();
                return;
            }
            if ((cbxUserName.Text == user.UserName) && (passWord == user.Password))
            {
                //登录成功
                XMLDAL.UpdateUser(cbxUserName.Text, pwx.Password); //将登录成功的用户信息更新到配置文件里
                LoginDAL.UpdateLoginTimeByUserName(user.UserName); //更新登录时间
                LoginDAL.ResetErrorTimesByUserName(user.UserName); //登录错误次数清零

                LoginGrid.Visibility = Visibility.Hidden;
                MainGrid.Visibility  = Visibility.Visible;
            }
            else
            {
                LoginDAL.UpdateErrorTimesByUserName(user.UserName); //登录错误次数+1
                LoginDAL.UpdateLoginTimeByUserName(user.UserName);  //更新登录时间
                MessageBox.Show("登录失败,请重试!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }