예제 #1
0
        void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                comS.expander.IsExpanded = false;

                TomDisPatcherLb tomdisPatcher = new TomDisPatcherLb(new System.Action(() =>
                {
                    DataInit();
                }));

                TomDisPatcherLb tomdisPatcher2 = new TomDisPatcherLb(new System.Action(() =>
                {
                    this.borTip.Visibility = System.Windows.Visibility.Visible;

                    CommonMethod.ReFresh();

                    tomdisPatcher.Start();
                }));

                tomdisPatcher2.Start();
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "btnSearch_Click", ex.ToString());
            }
        }
예제 #2
0
        void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TomDisPatcherLb tomdisPatcher = new TomDisPatcherLb(new System.Action(() =>
                {
                    ThreadPool.QueueUserWorkItem((o) =>
                    {
                        this.Dispatcher.BeginInvoke(new System.Action(() =>
                        {
                            if (this.dataGrid.Items.Count > 0)
                            {
                                PrintDocument print    = new PrintDocument();
                                print.ContentRendered += new EventHandler(print_ContentRendered);
                                var tittle             = this.txtTittle2PropertyName.Text + " : " + this.txtTittle2Year + this.txtTittle2Month + this.txtTittle2Day.Text + "故障列表";
                                CommonMethod.FHDataGrid_btn_打印(print, tittle, DataPager1, this.dataGrid, this._fhFormListSave);
                            }
                        }));
                    });
                }));

                TomDisPatcherLb tomdisPatcher2 = new TomDisPatcherLb(new System.Action(() =>
                {
                    this.borTip2.Visibility = System.Windows.Visibility.Visible;

                    tomdisPatcher.Start();
                }));

                tomdisPatcher2.Start();
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "btf3_Click", ex.ToString(), sender, e);
            }
            finally
            {
            }
        }
예제 #3
0
        void btf3_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                TomDisPatcherLb tomdisPatcher = new TomDisPatcherLb(new System.Action(() =>
                {
                    ThreadPool.QueueUserWorkItem((o) =>
                    {
                        this.Dispatcher.BeginInvoke(new System.Action(() =>
                        {
                            if (this._dataGrid.Items.Count > 0)
                            {
                                PrintDocument print    = new PrintDocument();
                                print.ContentRendered += new EventHandler(print_ContentRendered);
                                CommonMethod.FHDataGrid_btn_打印(print, "历史故障---" + DateTime.Now.ToShortDateString(), DataPager1, this._dataGrid, this.fhFormListSave);
                            }
                        }));
                    });
                }));

                TomDisPatcherLb tomdisPatcher2 = new TomDisPatcherLb(new System.Action(() =>
                {
                    this.borTip.Visibility = System.Windows.Visibility.Visible;

                    tomdisPatcher.Start();
                }));

                tomdisPatcher2.Start();
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "btf3_Click", ex.ToString(), sender, e);
            }
            finally
            {
            }
        }
예제 #4
0
        void Chart2Init()
        {
            try
            {
                TomDisPatcherLb tomdisPatcher = new TomDisPatcherLb(new System.Action(() =>
                {
                    #region 图表2生成

                    this.chart2.Series.Clear();

                    DataSeries ds2 = new DataSeries();

                    ds2.RenderAs = RenderAs.Pie;

                    // 显示Lable
                    ds2.LabelStyle   = LabelStyles.OutSide;
                    ds2.LabelEnabled = true;

                    foreach (var item in _dicChartData2)
                    {
                        var count = Convert.ToDouble(item.Value);
                        if (count > 0)
                        {
                            DataPoint dp1  = new DataPoint();
                            dp1.YValue     = count;
                            dp1.AxisXLabel = item.Key;
                            ds2.DataPoints.Add(dp1);
                        }
                    }
                    this.chart2.Series.Add(ds2);

                    #endregion

                    #region 图表3生成

                    this.chart3.Series.Clear();

                    DataSeries ds3 = new DataSeries();

                    ds3.RenderAs = RenderAs.Pie;

                    // 显示Lable
                    ds3.LabelStyle   = LabelStyles.OutSide;
                    ds3.LabelEnabled = true;

                    foreach (var item in _dicChartData3)
                    {
                        var count = Convert.ToDouble(item.Value);
                        if (count > 0)
                        {
                            DataPoint dp1  = new DataPoint();
                            dp1.AxisXLabel = item.Key;
                            dp1.YValue     = count;
                            ds3.DataPoints.Add(dp1);
                        }
                    }
                    this.chart3.Series.Add(ds3);

                    #endregion

                    this.borTip3.Visibility = System.Windows.Visibility.Collapsed;
                }));

                TomDisPatcherLb tomdisPatcher2 = new TomDisPatcherLb(new System.Action(() =>
                {
                    this.borTip3.Visibility = System.Windows.Visibility.Visible;

                    tomdisPatcher.Start();
                }));

                tomdisPatcher2.Start();
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "Chart2Init", ex.ToString());
            }
            finally
            {
            }
        }
예제 #5
0
        /// <summary>
        /// 二次列表生成
        /// </summary>
        /// <param name="listResult"></param>
        void ListInit(List <FHFormLb> listResult)
        {
            try
            {
                TomDisPatcherLb tomdisPatcher = new TomDisPatcherLb(new System.Action(() =>
                {
                    //清除原来的数据
                    _fhFormList.Clear();
                    _fhFormListSave.Clear();

                    #region 生成进行中

                    foreach (var form in listResult)
                    {
                        _fhFormList.Add(form);
                    }

                    #region 附件前台设置

                    foreach (var form in _fhFormList)
                    {
                        bool isHave = Convert.ToBoolean(form.是否有附件);
                        if (this._SettingFuJiJianImageUriEvent != null)
                        {
                            this._SettingFuJiJianImageUriEvent(ref _hasFuJianImageUri, ref _noFuJIanImageUri);
                            if (!string.IsNullOrEmpty(_hasFuJianImageUri) && !string.IsNullOrEmpty(_noFuJIanImageUri))
                            {
                                if (isHave)
                                {
                                    form.附件 = _hasFuJianImageUri;
                                }
                                else
                                {
                                    form.附件 = _noFuJIanImageUri;
                                }
                            }
                        }

                        if (form.责任单位.Contains(";"))
                        {
                            if (!string.IsNullOrEmpty(form.责任单位.Split(new char[] { ';' })[1]))
                            {
                                form.责任单位背景 = Style1.Instacnce.Resources["lin1"] as Brush;
                            }
                        }

                        _fhFormListSave.Add(form);
                    }
                    #endregion

                    #region 件数、总延时、平均延时设置

                    count故障件数.Text = _fhFormListSave.Count.ToString();

                    double sumYanShi = 0.0;

                    double singleYanShi = 0.0;

                    foreach (var item in _fhFormListSave)
                    {
                        if (!string.IsNullOrEmpty(item.延时) && Double.TryParse(item.延时, out singleYanShi))
                        {
                            sumYanShi += singleYanShi;
                        }
                    }
                    sum故障延时.Text = sumYanShi.ToString();

                    if (Double.IsNaN(sumYanShi / _fhFormListSave.Count))
                    {
                        平均延时.Text = "0";
                    }
                    else
                    {
                        平均延时.Text = (sumYanShi / _fhFormListSave.Count).ToString("0.00");
                    }

                    #endregion

                    #region 数据填充

                    ListCollectionView collection = new ListCollectionView(_fhFormList);

                    DataPager1.listInit(this.dataGrid, _fhFormList, 5);

                    #endregion

                    #endregion

                    this.borTip2.Visibility = System.Windows.Visibility.Collapsed;
                }));

                TomDisPatcherLb tomdisPatcher2 = new TomDisPatcherLb(new System.Action(() =>
                {
                    this.borTip2.Visibility = System.Windows.Visibility.Visible;

                    tomdisPatcher.Start();
                }));

                tomdisPatcher2.Start();
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "ListInit", ex.ToString(), listResult);
            }
            finally
            {
            }
        }
예제 #6
0
        /// <summary>
        /// 生成图表1
        /// </summary>
        /// <param name="dtMain"></param>
        void Chart1Init()
        {
            try
            {
                TomDisPatcherLb tomdisPatcher = new TomDisPatcherLb(new System.Action(() =>
                {
                    #region 生成中

                    this.chart1.Series.Clear();

                    if (this._AppointPropertyEvent != null)
                    {
                        this._AppointPropertyEvent(ref _PropertyName, ref _strList);
                    }

                    if (dtMain.Rows.Count > 0)
                    {
                        #region 图表2,图表3数据

                        this._dicChartData2.Clear();
                        this._dicChartData3.Clear();

                        if (this._AppointPropertyEvent2 != null)
                        {
                            this._AppointPropertyEvent2(ref _PropertyName2, ref _strList2);
                        }

                        foreach (var item in _strList2)
                        {
                            object count = 0;
                            //条件表达式
                            string Expression = _PropertyName2 + "='" + item + "'";
                            count             = dtMain.Compute("Count(ID)", Expression);
                            this._dicChartData2.Add(item, count);
                        }

                        if (this._AppointPropertyEvent3 != null)
                        {
                            this._AppointPropertyEvent3(ref _PropertyName3, ref _strList3);
                        }

                        foreach (var item in _strList3)
                        {
                            object count = 0;
                            //条件表达式
                            string Expression = _PropertyName3 + "='" + item + "'";
                            count             = dtMain.Compute("Count(ID)", Expression);
                            this._dicChartData3.Add(item, count);
                        }

                        #endregion
                    }

                    #region 生成图表1

                    for (int i = 0; i <= _strList.Count; i++)
                    {
                        DataSeries ds = new DataSeries();

                        ds.RenderAs = RenderAs.Line;

                        // 显示Lable
                        ds.LabelStyle   = LabelStyles.OutSide;
                        ds.LabelEnabled = true;

                        if (i == _strList.Count)
                        {
                            ds.Name = "全部";
                        }
                        else
                        {
                            ds.Name = _strList[i];
                        }

                        foreach (var day in this._dayList)
                        {
                            object count = 0;
                            if (dtMain.Rows.Count > 0)
                            {
                                //起始时间和终止时间
                                var start = Convert.ToDateTime(_nowYearAndMonth + day);
                                var end   = start.AddDays(1).AddSeconds(-1);
                                //条件表达式
                                string Expression = string.Empty;

                                if (i == _strList.Count)
                                {
                                    Expression = "startData" + ">=" + "'" + start + "'" + " And " + "startData" + "<" + "'" + end + "'";
                                }
                                else
                                {
                                    Expression = "startData" + ">=" + "'" + start + "'" + " And " + "startData" + "<" + "'" + end + "'" + " And " + _PropertyName + "='" + _strList[i] + "'";
                                }

                                count = dtMain.Compute("Count(ID)", Expression);
                            }

                            DataPoint dp1            = new DataPoint();
                            dp1.AxisXLabel           = day;
                            dp1.YValue               = Convert.ToDouble(count);
                            dp1.Tag                  = ds.Name;
                            dp1.MouseLeftButtonDown += new MouseButtonEventHandler(dp1_MouseLeftButtonDown);

                            ds.DataPoints.Add(dp1);
                        }
                        this.chart1.Series.Add(ds);
                    }

                    #endregion

                    #endregion

                    #region 生成列表

                    List <FHFormLb> listResult = new List <FHFormLb>();
                    this._dicData.ForEach(item => listResult.Add(new FHFormLb(item)));
                    ListInit(listResult);

                    #endregion

                    Chart2Init();

                    this.borTip1.Visibility = System.Windows.Visibility.Collapsed;
                }));

                TomDisPatcherLb tomdisPatcher2 = new TomDisPatcherLb(new System.Action(() =>
                {
                    this.borTip1.Visibility = System.Windows.Visibility.Visible;

                    tomdisPatcher.Start();
                }));

                tomdisPatcher2.Start();
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "Chart1Init", ex.ToString(), dtMain);
            }
            finally
            {
            }
        }
예제 #7
0
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="filePath">文件路径</param>
        /// <param name="UserName">用户名</param>
        /// <param name="PassWord">密码</param>
        /// <param name="Doamin">站点</param>
        public void Download(string filePath, string UserName, string PassWord, string Doamin)
        {
            try
            {
                WebClient client = new WebClient();
                //通过验证
                client.Credentials = new NetworkCredential(UserName, PassWord, Doamin);

                //保存对话框
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                //扩展名
                string extension = System.IO.Path.GetExtension(filePath);

                ////默认文件名称
                string fileName = filePath.Substring(filePath.LastIndexOf("/") + 1);
                saveFileDialog.FileName += fileName;

                //保存对话框对应的类型
                saveFileDialog.Filter = string.Format("*{0}| *{0}", extension);

                //对话框选择确定,则标记需要下载
                if (saveFileDialog.ShowDialog() == true)
                {
                    needDownload = true;
                }

                if (needDownload)
                {
                    //对话框的进度为0
                    this.progressBar1.Value = 0;

                    #region 初始化化对话框
                    //进度条最大值设置
                    this.progressBar1.Maximum = 100;

                    this.hbFileName.Content = fileName;
                    this.hbFileName.Tag     = filePath;

                    this.btnOK.IsEnabled     = false;
                    this.btnCancel.IsEnabled = true;

                    #endregion

                    TomDisPatcherLb timer2 = new TomDisPatcherLb(new Action(() =>
                    {
                        //下载文件
                        client.DownloadFile(filePath, saveFileDialog.FileName);
                        //下载完成之后
                        client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
                        client.DownloadFileAsync(new Uri(filePath), Dns.GetHostName());
                        //下载中
                        client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
                    }));
                    timer2.Start();
                }
            }
            catch (Exception ex)
            {
                MethodLb.CreateLog(this.GetType().FullName, "Download", ex.ToString(), filePath, UserName, PassWord, Doamin);
            }
            finally
            {
            }
        }