コード例 #1
0
 private void InsertQueue(AJEntity aj)
 {
     lock (locker)
     {
         ajEntities_Queue.Enqueue(aj);
     }
 }
コード例 #2
0
        /// <summary>
        /// 根据案卷信息生成卷内实体
        /// </summary>
        /// <param name="aj">案卷实体</param>
        /// <returns></returns>
        private List <JNEntity> FindJNEntity(AJEntity aj)
        {
            List <JNEntity> jNEntities = new List <JNEntity>();
            string          Findable   = string.Join("-", aj.Key);
            string          filter     = string.Empty;
            List <string>   columnName = AJ_JN.Values.ToList();

            for (int i = 0; i < AJ_JN.Count; i++)
            {
                filter += columnName[i] + "=" + "'" + aj.Key[i].Trim() + "'";
                if (i != AJ_JN.Count - 1)
                {
                    filter += " and ";
                }
            }
            JNTotalView.RowFilter = filter;
            DataTable jnsTable = JNTotalView.ToTable();
            int       JNCount  = jnsTable.Rows.Count;

            if (JNCount != 0)
            {
                for (int i = 0; i < JNCount; i++)
                {
                    try
                    {
                        DataTable jnTable = new DataTable();
                        object[]  obj     = new object[jnsTable.Columns.Count];
                        jnsTable.Rows[i].ItemArray.CopyTo(obj, 0);
                        for (int j = 0; j < jnsTable.Columns.Count; j++)
                        {
                            jnTable.Columns.Add(jnsTable.Columns[j].ColumnName);
                        }
                        jnTable.Rows.Add(obj);
                        JNEntity jn = new JNEntity
                        {
                            Value = jnTable,
                        };
                        string result = jn.LoadProperty(JNPageColumn, Findable);
                        if (!string.IsNullOrWhiteSpace(result))
                        {
                            WriteErrorInfo(aj.Location.ToString(), "[JN/LoadProperty]" + i, result);
                        }
                        jNEntities.Add(jn);
                    }
                    catch (Exception ex)
                    {
                        WriteErrorInfo(aj.Location.ToString(), "[BuildJNEntity]" + i, ex.Message);
                        continue;
                    }
                }
                return(jNEntities);
            }
            else
            {
                WriteErrorInfo(aj.Location.ToString(), Findable, "未能找到对应的卷内:" + filter);
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 组装案卷信息,不保留[页数为空],[路径无法拼接],[某单元格无列名]情况的案卷
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bgwPrepareAJ_DoWork(object sender, DoWorkEventArgs e)
        {
            int location = 0;

            prepareAJComplete = false;
            for (int i = ColumnNameRow + 1; i < AJCells.MaxDataRow + 1; i++)
            {
                try
                {
                    location = i + 1;
                    float a       = (i - ColumnNameRow) / (float)(AJCells.MaxDataRow - ColumnNameRow) * 100;
                    int   percent = (int)a;
                    bgwPrepareAJ.ReportProgress(percent);

                    AJEntity aj = new AJEntity();

                    aj.Location = location;

                    DataTable AJ = DataTableBuilder(i);
                    if (AJ != null)
                    {
                        aj.Value = AJ;
                    }
                    else
                    {
                        continue;
                    }

                    string result;
                    if (isOneToMany)
                    {
                        aj.IsOneToMany = isOneToMany;
                        result         = aj.LoadProperty(AJPageColumn, dirConstitute, JNCountColumn, AJ_JN);
                    }
                    else
                    {
                        result = aj.LoadProperty(AJPageColumn, dirConstitute);
                    }
                    if (!string.IsNullOrWhiteSpace(result))
                    {
                        WriteErrorInfo(location.ToString(), "[LoadProperty]", result);
                        continue;
                    }

                    InsertQueue(aj);
                    UsefulAJ++;
                }
                catch (Exception ex)
                {
                    WriteErrorInfo(location.ToString(), "[PrepareAJ]", ex.Message);
                    continue;
                }
            }
        }
コード例 #4
0
 private void bgwMatch_DoWork(object sender, DoWorkEventArgs e)
 {
     while (true)
     {
         lock (locker)
         {
             if (ajEntities_Queue.Count > 0)
             {
                 AJEntity aj     = ajEntities_Queue.Dequeue();
                 string   result = aj.LoadFiles(rootDir, fileFormat);
                 if (!string.IsNullOrWhiteSpace(result))
                 {
                     WriteErrorInfo(aj.Location.ToString(), "LoadFiles", result);
                 }
                 else if (aj.ScanFiles.Count != aj.Pages)
                 {
                     WriteErrorInfo(aj.Location.ToString(), "", "[扫描件][" + aj.ScanFiles.Count + "]与[案卷][" + aj.Pages + "]页数不相等");
                 }
                 ajEntities_List.Add(aj);
                 if (isOneToMany)
                 {
                     DataTable JNTotalTable = DataTableBuilder(JNCells);
                     JNTotalView = JNTotalTable.AsDataView();
                     List <JNEntity> jns = FindJNEntity(aj);
                     if (jns != null)
                     {
                         int totalPage = 0;
                         foreach (JNEntity jn in jns)
                         {
                             totalPage += jn.Pages;
                         }
                         if (aj.Pages != totalPage)
                         {
                             WriteErrorInfo(aj.Location.ToString(), "", "[卷内][" + totalPage + "]与[案卷][" + aj.Pages + "]页数不相等");
                         }
                         if (JNCountColumn != null)
                         {
                             if (aj.JNCount != jns.Count)
                             {
                                 WriteErrorInfo(aj.Location.ToString(), "", "[件数][" + aj.JNCount + "]与[卷内条目数][" + jns.Count + "]不相等");
                             }
                         }
                     }
                     Entities_Dic.Add(aj, jns);
                 }
             }
             if (prepareAJComplete == true && ajEntities_List.Count == UsefulAJ)
             {
                 break;
             }
         }
     }
 }
コード例 #5
0
        private DataTable DataTableRecombine(AJEntity AJEntity)
        {
            DataTable AJ = AJEntity.Value;
            DataTable JN = new DataTable();

            foreach (string column in saveColumn)
            {
                JN.Columns.Add(column);
            }
            JN.Columns.Add("序号");
            JN.Columns.Add("题名");
            JN.Columns.Add("页数");
            try
            {
                int orderNum = 1;
                for (int i = 0; i < turnRow.Count; i++)
                {
                    if (AJ.Columns.Contains(turnRow[i]))
                    {
                        DataRow row = JN.NewRow();
                        for (int j = 0; j < saveColumn.Count; j++)
                        {
                            row[saveColumn[j]] = AJ.Rows[0][saveColumn[j]];
                        }
                        row["序号"] = orderNum;
                        row["题名"] = turnRow[i].Trim();
                        //纯数字,则页数为1
                        if (int.TryParse(AJ.Rows[0][turnRow[i]].ToString(), out int num1))
                        {
                            row["页数"] = 1;
                        }
                        else
                        {
                            //用分隔符进行拆分
                            string[] pageNum = AJ.Rows[0][turnRow[i]].ToString().Split('-');
                            //正常情况,拆分为两段
                            if (pageNum.Length == 2)
                            {
                                //首位不为数字
                                if (!int.TryParse(pageNum[0], out int num2))
                                {
                                    //第二位不为数字
                                    if (!int.TryParse(pageNum[1], out int num3))
                                    {
                                        //放弃
                                        continue;
                                    }
                                }
                                //第二位不为数字
                                if (!int.TryParse(pageNum[1], out int num4))
                                {
                                    WriteErrorInfo(AJEntity.Location.ToString(), turnRow[i], "该位置页号存在问题");
                                    row["页数"] = "-";
                                }
                                else
                                {
                                    row["页数"] = int.Parse(pageNum[1].Trim()) - int.Parse(pageNum[0].Trim()) + 1;
                                }
                            }
                            //不正常情况
                            else
                            {
                                //首位不为数字,直接放弃
                                if (!int.TryParse(pageNum[0], out int num2))
                                {
                                    continue;
                                }
                                //首位为数字,但整体为不标准情况,需要检查
                                else
                                {
                                    WriteErrorInfo(AJEntity.Location.ToString(), turnRow[i], "该位置页号存在问题");
                                    row["页数"] = "-";
                                }
                            }
                        }

                        JN.Rows.Add(row);
                        orderNum++;
                    }
                }
            }
            catch (Exception ex)
            {
                WriteErrorInfo(AJEntity.Location.ToString(), "DataTableRecombine", ex.Message);
            }
            return(JN);
        }