예제 #1
0
 /// <summary>
 /// Read excavation information
 /// </summary>
 private void ReadExcavationInfo()
 {
     try
     {
         _batInfos = new List <BatInfo>();
         StreamReader _reader = new StreamReader(_infoFile, Encoding.GetEncoding("Shift-JIS"));
         while (!_reader.EndOfStream)
         {
             String   line    = _reader.ReadLine();
             String[] infos   = line.Split(',');
             BatInfo  batinfo = new BatInfo();
             batinfo.Grid          = Int32.Parse(infos[0]);
             batinfo.ChousaJisuu   = Int32.Parse(infos[1]);
             batinfo.OoChiku       = infos[2];
             batinfo.ChuushouChiku = infos[3];
             batinfo.Ikoumei       = infos[4];
             batinfo.Dosoumei      = infos[5];
             batinfo.Date          = DateTime.Parse(infos[6]);
             _batInfos.Add(batinfo);
         }
     }
     catch
     {
         _batInfos.Clear();
     }
 }
예제 #2
0
        /// <summary>
        /// Executing work
        /// </summary>
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            int iCount = _batPaths.Count;
            int _start = _startRId;

            for (int i = 0; i < iCount; i++)
            {
                // The Work to be performed...
                String _batPath = _batPaths[i];
                String _batName = Path.GetFileName(_batPaths[i]);

                String _batFilePath = _batPath + "\\" + _batName + MkaDefine.BmkFileExt;
                FileOpenBat(_batFilePath);
                if (_batManager == null)
                {
                    continue;
                }


                // Update the description and progress on the modal form
                // using Control.Invoke.  Invoke will run the anonymous
                // function to set the label's text on the UI thread.
                // Since it's illegal to touch the UI control on the worker
                // thread that we're on right now.
                // Moron Anonymous functions: http://www.codeproject.com/books/cs2_anonymous_method.asp
                _fmProgress.LabelDescription.Invoke(
                    (MethodInvoker) delegate()
                {
                    _fmProgress.LabelDescription.Text = String.Format("実行 {0}_{1} ({2}/{3})...", _batManager.BatInfo.Grid, _batName, i + 1, iCount);
                    _fmProgress.ProgressBar.Value     = Convert.ToInt32((i + 1) * (100.0 / iCount));
                }
                    );

                // change bat information
                if (ckbFileUpdate.Checked)
                {
                    _batInfo = _batInfos.Find(delegate(BatInfo b) { return(b.Grid == _batManager.BatInfo.Grid); });
                    if (_batInfo != null)
                    {
                        _batManager.BatInfo.BatDirectory  = _batPath;
                        _batManager.BatInfo.BatBangou     = _batName;
                        _batManager.BatInfo.Grid          = _batInfo.Grid;
                        _batManager.BatInfo.ChousaJisuu   = _batInfo.ChousaJisuu;
                        _batManager.BatInfo.OoChiku       = _batInfo.OoChiku;
                        _batManager.BatInfo.ChuushouChiku = _batInfo.ChuushouChiku;
                        _batManager.BatInfo.Ikoumei       = _batInfo.Ikoumei;
                        _batManager.BatInfo.Dosoumei      = _batInfo.Dosoumei;
                        _batManager.BatInfo.Date          = _batInfo.Date;
                        _batManager.Save();
                    }
                }

                List <string> _glassPaths = Directory.GetFiles(_batPath, "*" + MkaDefine.MkaFileExt).ToList();
                _glassPaths.Sort(CompareGlass);

                int _sum = 0;
                foreach (String _glassPath in _glassPaths)
                {
                    _activeDoc = FileLoadGlass(_glassPath);
                    if (_activeDoc == null)
                    {
                        continue;
                    }

                    // change bat information
                    if (ckbFileUpdate.Checked && _batInfo != null)
                    {
                        _activeDoc.BatInfo.BatDirectory  = _batPath;
                        _activeDoc.BatInfo.BatBangou     = _batName;
                        _activeDoc.BatInfo.Grid          = _batInfo.Grid;
                        _activeDoc.BatInfo.ChousaJisuu   = _batInfo.ChousaJisuu;
                        _activeDoc.BatInfo.OoChiku       = _batInfo.OoChiku;
                        _activeDoc.BatInfo.ChuushouChiku = _batInfo.ChuushouChiku;
                        _activeDoc.BatInfo.Ikoumei       = _batInfo.Ikoumei;
                        _activeDoc.BatInfo.Dosoumei      = _batInfo.Dosoumei;
                        _activeDoc.BatInfo.Date          = _batInfo.Date;
                    }

                    // change glass and mokkans' start id
                    if (ckbFileUpdate.Checked && _startRIdSet)
                    {
                        _activeDoc.GlassInfo.KaishiRBangou = _start;
                        _activeDoc.MokkanList.ReArrangeId(_start);
                    }

                    _activeDoc.Save(false);
                    _start += _activeDoc.MokkanList.Count;
                    _sum   += _activeDoc.MokkanList.Count;

                    _statWriter.WriteLine(String.Format("{0},{1},{2},{3},{4},{5}", _batManager.BatInfo.Grid, _batName, Path.GetFileNameWithoutExtension(_glassPath),
                                                        _activeDoc.GlassInfo.KaishiRBangou, _activeDoc.GlassInfo.KaishiRBangou + _activeDoc.MokkanList.Count - 1, _activeDoc.MokkanList.Count));
                }
                _statWriter.Flush();

                if (_startRIdSet)
                {
                    _statGlassWriter.WriteLine(String.Format("{0},{1},{2},{3},{4},{5}", _batManager.BatInfo.Grid, _batName, _batManager.GlassFileNames.Count, _startRId, _start - 1, _sum));
                }
                else
                {
                    _statGlassWriter.WriteLine(String.Format("{0},{1},{2},{3}", _batManager.BatInfo.Grid, _batName, _batManager.GlassFileNames.Count, _sum));
                }
                _statGlassWriter.Flush();

                // Periodically check for a Cancellation
                // If the user clicks the cancel button, or tries to close
                // the progress form the m_fmProgress.Cancel flag will be set to true.
                if (_fmProgress.Cancel)
                {
                    // Set the e.Cancel flag so that the WorkerCompleted event
                    // knows that the process was canceled.
                    e.Cancel = true;
                    return;
                }
            }
        }