using System;
using System.IO;
using System.Linq;
using ZionFoundation.Components;
using ZionVault.Binder.OCR;
using ZionVault.Binder.Output;
using ZionVault.Binder.Verified;

namespace ZionRobot.Models.Items
{
	// Token: 0x02000033 RID: 51
	public class File : ZionFoundation.Components.File, IDisposable
	{
		// Token: 0x17000092 RID: 146
		// (get) Token: 0x0600017D RID: 381 RVA: 0x00008BD0 File Offset: 0x00006DD0
		public string OCR
		{
			get
			{
				return string.Format("{0}\\{1}.ocr", base.Directory, base.Name);
			}
		}

		// Token: 0x17000093 RID: 147
		// (get) Token: 0x0600017E RID: 382 RVA: 0x00008BE8 File Offset: 0x00006DE8
		public string META
		{
			get
			{
				return string.Format("{0}\\{1}.ztd", base.Directory, base.Name);
			}
		}

		// Token: 0x17000094 RID: 148
		// (get) Token: 0x0600017F RID: 383 RVA: 0x00008C00 File Offset: 0x00006E00
		public string VERIFY
		{
			get
			{
				return string.Format("{0}\\{1}.vrf", base.Directory, base.Name);
			}
		}

		// Token: 0x06000180 RID: 384 RVA: 0x00008C18 File Offset: 0x00006E18
		public File(string path) : base(path)
		{
			bool flag = System.IO.File.Exists(this.META) && (this.METAObject.Status == "INTEGRATED" || this.METAObject.Status == "GROUPED");
			if (flag)
			{
				base.Status = "INTEGRATED";
			}
			else
			{
				bool flag2 = System.IO.File.Exists(this.META);
				if (flag2)
				{
					base.Status = "INTEGRATION";
				}
				else
				{
					base.Status = "EXTRACTION";
				}
			}
			this.Disposed = false;
		}

		// Token: 0x06000181 RID: 385 RVA: 0x00008CAF File Offset: 0x00006EAF
		public new void Move(string folder)
		{
			base.Move(folder);
			System.IO.File.Move(this.META, System.IO.Path.Combine(folder, base.Name + ".ztd"));
		}

		// Token: 0x06000182 RID: 386 RVA: 0x00008CDC File Offset: 0x00006EDC
		public void Dispose()
		{
			bool flag = this.OCRObject != null;
			if (flag)
			{
				this.OCRObject.Dispose();
			}
			bool flag2 = this.METAObject != null;
			if (flag2)
			{
				this.METAObject.Dispose();
			}
			bool flag3 = this.VERIFYObject != null;
			if (flag3)
			{
				this.VERIFYObject.Dispose();
			}
			GC.SuppressFinalize(this);
			GC.Collect();
			GC.WaitForPendingFinalizers();
			this.Disposed = true;
		}

		// Token: 0x17000095 RID: 149
		// (get) Token: 0x06000183 RID: 387 RVA: 0x00008D50 File Offset: 0x00006F50
		public ZionVault.Binder.OCR.Document OCRObject
		{
			get
			{
				bool flag = System.IO.File.Exists(this.OCR);
				ZionVault.Binder.OCR.Document result;
				if (flag)
				{
					bool flag2 = this.ocrObject != null;
					if (flag2)
					{
						result = this.ocrObject;
					}
					else
					{
						this.ocrObject = new ZionVault.Binder.OCR.Document(this.OCR, false);
						result = this.ocrObject;
					}
				}
				else
				{
					result = null;
				}
				return result;
			}
		}

		// Token: 0x17000096 RID: 150
		// (get) Token: 0x06000184 RID: 388 RVA: 0x00008DA4 File Offset: 0x00006FA4
		public ZionVault.Binder.Output.Document METAObject
		{
			get
			{
				bool flag = System.IO.File.Exists(this.META);
				ZionVault.Binder.Output.Document result;
				if (flag)
				{
					bool flag2 = this.metaObject != null;
					if (flag2)
					{
						result = this.metaObject;
					}
					else
					{
						this.metaObject = new ZionVault.Binder.Output.Document(this.META, false);
						result = this.metaObject;
					}
				}
				else
				{
					result = null;
				}
				return result;
			}
		}

		// Token: 0x17000097 RID: 151
		// (get) Token: 0x06000185 RID: 389 RVA: 0x00008DF8 File Offset: 0x00006FF8
		public ZionVault.Binder.Verified.Document VERIFYObject
		{
			get
			{
				bool flag = System.IO.File.Exists(this.VERIFY);
				ZionVault.Binder.Verified.Document result;
				if (flag)
				{
					bool flag2 = this.verifyObject != null;
					if (flag2)
					{
						result = this.verifyObject;
					}
					else
					{
						this.verifyObject = new ZionVault.Binder.Verified.Document(this.VERIFY, false);
						result = this.verifyObject;
					}
				}
				else
				{
					result = null;
				}
				return result;
			}
		}

		// Token: 0x17000098 RID: 152
		// (get) Token: 0x06000186 RID: 390 RVA: 0x00008E4C File Offset: 0x0000704C
		public string LawsuitNumber
		{
			get
			{
				return this.GetField("NrProcesso").Value;
			}
		}

		// Token: 0x17000099 RID: 153
		// (get) Token: 0x06000187 RID: 391 RVA: 0x00008E70 File Offset: 0x00007070
		public string PublicationContent
		{
			get
			{
				return this.GetField("ConteudoCompleto").Value;
			}
		}

		// Token: 0x06000188 RID: 392 RVA: 0x00008E94 File Offset: 0x00007094
		private ZionVault.Binder.Output.Field GetField(string fieldName)
		{
			return (from field in this.METAObject.AllFields
			where field.Name == fieldName
			select field).FirstOrDefault<ZionVault.Binder.Output.Field>();
		}

		// Token: 0x04000093 RID: 147
		private ZionVault.Binder.OCR.Document ocrObject;

		// Token: 0x04000094 RID: 148
		private ZionVault.Binder.Output.Document metaObject;

		// Token: 0x04000095 RID: 149
		private ZionVault.Binder.Verified.Document verifyObject;

		// Token: 0x04000096 RID: 150
		public bool Disposed;
	}
}
