Ejemplo n.º 1
0
        public List <VanguardDoc> GetVanguardDocuments(SqlConnection connection, string resultStr)
        {
            var vanguardDocs = new List <VanguardDoc>();

            try
            {
                var tenant = ConfigurationManager.AppSettings["tenant"];
                _log.WriteLog(LogLevel.Info,
                              "Make temporaly table in order to simplify detting data from DM_CONTENT table \n");
                using (var command = new SqlCommand
                {
                    CommandType = CommandType.Text,
                    Connection = connection,
                    CommandTimeout = 0,
                    CommandText =
                        ($@"declare @doc table (DocPath varchar(max)) insert into @doc select tbl.col.value('.[1]', 'varchar(max)')
                        from @XML.nodes('ArrayOfString/string') tbl(col)  select dmc.DM_ID, dmc.DMC_ID, dmc.DMC_PATH, dm.DEPT_ID
                        from VG{tenant}.DOC_MASTER dm
                        join VG{tenant}.DM_CONTENT dmc on dmc.DM_ID = dm.DM_ID
                        join VG{tenant}.DM_OCR_PROCESS ocr on ocr.DMC_ID = dmc.DMC_ID
                        join @doc d on d.DocPath = dmc.DMC_PATH")
                })
                {
                    command.Parameters.Add("@XML", SqlDbType.Xml);
                    command.Parameters["@XML"].Value = resultStr;
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            vanguardDocs.Add(new VanguardDoc
                            {
                                DocId   = Convert.ToInt64(reader["DM_ID"]),
                                DmcId   = Convert.ToInt64(reader["DMC_ID"]),
                                DocPath = Convert.ToString(reader["DMC_PATH"]).Replace("\\", "/"),
                                DeptId  = Convert.ToInt32(reader["DEPT_ID"]),
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.WriteLog(LogLevel.Error,
                              "Error while getting vanguard documents. Error details: \n" + ex.Message + "\n");
            }
            return(vanguardDocs);
        }
Ejemplo n.º 2
0
        public int GetCountOfHistoricData(NpgsqlConnection connection)
        {
            var countOfHistoricData = 0;

            try
            {
                using (var command = GetCommand(connection, "select count(*) from historical_ocr_data"))
                {
                    countOfHistoricData = Convert.ToInt32(command.ExecuteScalar());
                }
            }
            catch (Exception ex)
            {
                _log.WriteLog(LogLevel.Error,
                              "Error while getting historic paths. Error details: \n" + ex.Message + "\n");
            }
            return(countOfHistoricData);
        }