コード例 #1
0
ファイル: FrmMain.cs プロジェクト: iswoit/BankClearFileCopy
        private void BankDistDetailLvChange()
        {
            if (bankDistLv.SelectedItems != null && bankDistLv.SelectedItems.Count > 0)
            {
                ListViewItem bankDistLVI = bankDistLv.SelectedItems[0];
                if (bankDistLVI != null)
                {
                    BankDist bankDist = (BankDist)bankDistLVI.Tag;


                    bankDistDetailLv.Items.Clear();
                    bankDistDetailLv.BeginUpdate();
                    int idx = 0;
                    foreach (BankDistFile bankDistFile in bankDist.BankDistFileList)
                    {
                        ListViewItem bankDistFileLVI = new ListViewItem((++idx).ToString());
                        bankDistFileLVI.SubItems.Add(bankDistFile.BankName);
                        bankDistFileLVI.SubItems.Add(bankDistFile.FileName);
                        bankDistFileLVI.SubItems.Add(bankDistFile.FileExist ? "√" : "×");
                        bankDistFileLVI.SubItems.Add(bankDistFile.CheckedPassed ? "√" : "×");
                        bankDistFileLVI.SubItems.Add(bankDistFile.IsCopied ? "√" : "×");
                        bankDistFileLVI.SubItems.Add(bankDistFile.Status);
                        bankDistFileLVI.Tag = bankDistFile;

                        bankDistDetailLv.Items.Add(bankDistFileLVI);

                        //if (tmpHqFile.Required)
                        //{
                        //    if (tmpHqFile.IsOK)
                        //        lvHq.Items[i].BackColor = SystemColors.Window;
                        //    else
                        //        lvHq.Items[i].BackColor = Color.Pink;
                        //}
                        //else
                        //{
                        //    if (tmpHqFile.IsOK)
                        //        lvHq.Items[i].BackColor = SystemColors.Window;
                        //    else
                        //        lvHq.Items[i].BackColor = Color.LightYellow;
                        //}
                    }


                    bankDistDetailLv.Columns[0].Width = -1;
                    bankDistDetailLv.Columns[1].Width = -1;
                    bankDistDetailLv.Columns[2].Width = -1;
                    bankDistDetailLv.Columns[6].Width = -1;
                    //bankDistDetailLv.Columns[1].Width = -1;
                    //bankDistDetailLv.Columns[2].Width = -1;
                    //bankDistLv.Columns[6].Width = -1;

                    bankDistDetailLv.EndUpdate();
                }
            }
            else
            {
                bankDistDetailLv.Items.Clear();
            }
        }
コード例 #2
0
        private string _stauts;           // 错误信息


        /// <summary>
        /// 存管文件-构造函数
        /// </summary>
        /// <param name="bankDist"></param>
        /// <param name="fileName"></param>
        /// <param name="fileSize"></param>
        /// <param name="fileDate"></param>
        /// <param name="fileTime"></param>
        public BankDistFile(BankDist bankDist, string fileName, long fileSize, DateTime fileDate, DateTime fileTime)
        {
            _bankDist    = bankDist;
            _fileName    = fileName;
            _fileSizeIdx = fileSize;
            _fileDateIdx = fileDate;
            _fileTimeIdx = fileTime;

            _fileExist     = false;
            _checkedPassed = false;
            _isCopied      = false;
        }
コード例 #3
0
        private bool _isRunning;                        // 是否运行中

        /// <summary>
        /// 构造函数
        /// </summary>
        private Manager()
        {
            _dtNow = DateTime.Now;                              // 日期
            _bankDistCollection = new BankDistCollection();     // 新建collection对象

            // 判断配置文件是否存在,不存在抛出异常
            if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "cfg.xml")))
            {
                throw new Exception("未能找到配置文件cfg.xml,请重新配置该文件后重启程序!");
            }

            // 读取配置文件
            XmlDocument       doc      = new XmlDocument();
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.IgnoreComments = true;                                     //忽略文档里面的注释
            using (XmlReader reader = XmlReader.Create(@"cfg.xml", settings))
            {
                doc.Load(reader);

                // 检查根节点
                XmlNode rootNode = doc.SelectSingleNode("Config");   // 根节点
                if (rootNode == null)
                {
                    throw new Exception("无法找到根配置节点<Config>,请检查配置文件格式是否正确!");
                }


                // 获取存管列表
                XmlNode bankListXN = rootNode.SelectSingleNode("BankList");
                if (bankListXN == null)
                {
                    throw new Exception("无法找到文件列表节点<BankList>,请检查配置文件格式是否正确!");
                }

                XmlNodeList bankXNL = bankListXN.SelectNodes("Bank");
                foreach (XmlNode bankXN in bankXNL)
                {
                    // 临时变量
                    string        name   = string.Empty;
                    string        source = string.Empty;
                    List <string> dest   = new List <string>();


                    XmlNode valueXN;    // 临时变量
                    valueXN = bankXN.SelectSingleNode("Name");
                    if (valueXN != null)
                    {
                        name = valueXN.InnerText.Trim();
                    }

                    valueXN = bankXN.SelectSingleNode("Source");
                    if (valueXN != null)
                    {
                        source = valueXN.InnerText.Trim();
                        source = Util.ReplaceStringWithDateFormat(source, _dtNow);
                    }

                    valueXN = bankXN.SelectSingleNode("Dest");
                    if (valueXN != null)
                    {
                        string[] strTmp = valueXN.InnerText.Trim().Split(new char[] { ',', ',', ';', ';' });
                        foreach (string s in strTmp)
                        {
                            if (!string.IsNullOrEmpty(s.Trim()))
                            {
                                dest.Add(Util.ReplaceStringWithDateFormat(s.Trim(), _dtNow));
                            }
                        }
                    }


                    // 生成配置对象
                    BankDist tmpBankDist = new BankDist(name, source, dest, _dtNow);
                    _bankDistCollection.Add(tmpBankDist);
                } //eof foreach
            }     //eof using
        }
コード例 #4
0
ファイル: FrmMain.cs プロジェクト: iswoit/BankClearFileCopy
        private void BankDistLvUpdate()
        {
            bankDistLv.BeginUpdate();
            // 进度列表
            try
            {
                for (int i = 0; i < bankDistLv.Items.Count; i++)
                {
                    BankDist bankDist = (BankDist)bankDistLv.Items[i].Tag;   // 配置对象
                    bankDistLv.Items[i].SubItems[4].Text = bankDist.IsFileAllCopied ? "√" : "×";
                    bankDistLv.Items[i].SubItems[5].Text = bankDist.Status;  // 标志到齐

                    if (bankDist.IsRunning)
                    {
                        bankDistLv.Items[i].BackColor = Color.LightBlue;
                        bankDistLv.Items[i].EnsureVisible();
                    }
                    else
                    {
                        if (bankDist.IsFileAllCopied)
                        {
                            bankDistLv.Items[i].BackColor = SystemColors.Window;
                        }
                        else
                        {
                            bankDistLv.Items[i].BackColor = Color.Pink;
                        }
                    }
                }

                bankDistLv.Columns[0].Width = -1;
                bankDistLv.Columns[1].Width = -1;
                bankDistLv.Columns[2].Width = -1;
                bankDistLv.Columns[3].Width = -1;
                bankDistLv.Columns[5].Width = -1;
            }
            catch (Exception)
            {
                // ui异常过滤
            }

            bankDistLv.EndUpdate();


            if ((Manager.GetInstance().IsRunning))
            {
                stautsLb.Text = "运行中...";
            }
            else
            {
                stautsLb.Text = "运行完毕";
            }


            if (Manager.GetInstance().BankDistCollection.IsAllBankCopied)
            {
                isAllOKLb.Text      = "是";
                isAllOKLb.ForeColor = Color.Green;
            }
            else
            {
                isAllOKLb.Text      = "否";
                isAllOKLb.ForeColor = Color.Red;
            }
        }