using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Threading;
using HtmlAgilityPack;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.SharePoint.Client;
using mshtml;
using Newtonsoft.Json;
using ZionRobot.Helpers;
using ZionRobot.Models.AASP;
using ZionRobot.Models.Items;
using ZionRobot.Models.Search;
using ZionRobot.Models.Source;
using ZionRobot.Models.ZFlow;
using ZionRobot.Persistence;
using ZionRobot.ZionExchangeManagement;
using ZionVault.Binder.OCR;
using ZionVault.WebService;

namespace ZionRobot.Handlers
{
	// Token: 0x0200004B RID: 75
	public partial class Browser : Window
	{
		// Token: 0x1700016E RID: 366
		// (get) Token: 0x06000362 RID: 866 RVA: 0x0000AB44 File Offset: 0x00008D44
		public static Browser Instance
		{
			get
			{
				bool flag = Browser.instance == null;
				if (flag)
				{
					Browser.instance = new Browser();
				}
				return Browser.instance;
			}
		}

		// Token: 0x1700016F RID: 367
		// (get) Token: 0x06000363 RID: 867 RVA: 0x0000AB71 File Offset: 0x00008D71
		public Thread Main
		{
			get
			{
				return this.main;
			}
		}

		// Token: 0x17000170 RID: 368
		// (get) Token: 0x06000364 RID: 868 RVA: 0x0000AB79 File Offset: 0x00008D79
		public bool Terminate
		{
			get
			{
				return this.terminate;
			}
		}

		// Token: 0x17000171 RID: 369
		// (get) Token: 0x06000365 RID: 869 RVA: 0x0000AB81 File Offset: 0x00008D81
		// (set) Token: 0x06000366 RID: 870 RVA: 0x0000AB89 File Offset: 0x00008D89
		public Origin Source
		{
			get
			{
				return this.source;
			}
			set
			{
				this.source = value;
			}
		}

		// Token: 0x17000172 RID: 370
		// (get) Token: 0x06000367 RID: 871 RVA: 0x0000AB92 File Offset: 0x00008D92
		// (set) Token: 0x06000368 RID: 872 RVA: 0x0000AB9A File Offset: 0x00008D9A
		public Dictionary<string, string> DictionaryValues
		{
			get
			{
				return this.dictionaryValues;
			}
			set
			{
				this.dictionaryValues = value;
			}
		}

		// Token: 0x17000173 RID: 371
		// (get) Token: 0x06000369 RID: 873 RVA: 0x0000ABA3 File Offset: 0x00008DA3
		// (set) Token: 0x0600036A RID: 874 RVA: 0x0000ABAB File Offset: 0x00008DAB
		public List<List<Element>> SearchElements
		{
			get
			{
				return this.searchElements;
			}
			set
			{
				this.searchElements = value;
			}
		}

		// Token: 0x0600036B RID: 875 RVA: 0x0000ABB4 File Offset: 0x00008DB4
		public Browser()
		{
			this.InitializeComponent();
			base.Closing += this.Browser_Closing;
			DockPanel parent = this._holder;
			WebBrowser replacement = new WebBrowser();
			replacement.Name = "browser";
			parent.Children.Clear();
			parent.Children.Add(replacement);
			this.browser = null;
			this.browser = replacement;
			this.browser.VerticalAlignment = VerticalAlignment.Stretch;
			this.browser.HorizontalAlignment = HorizontalAlignment.Stretch;
			this.browser.Navigating += this.Browser_Navigating;
			this.browser.LoadCompleted += this.Browser_LoadComplete;
			this.browser.Unloaded += this.Browser_Unloaded;
			this.HideScriptErrors(this.browser, true);
			this.dictionaryValues = new Dictionary<string, string>();
			this.searchElements = new List<List<Element>>();
		}

		// Token: 0x0600036C RID: 876 RVA: 0x0000ACB8 File Offset: 0x00008EB8
		private void Browser_Unloaded(object sender, RoutedEventArgs e)
		{
			this.browser.ContextMenu = null;
			this.browser.DataContext = null;
			this.browser.Resources = null;
			this.browser.Source = null;
			this.browser.Navigating -= this.Browser_Navigating;
			this.browser.LoadCompleted -= this.Browser_LoadComplete;
			this.browser.Unloaded -= this.Browser_Unloaded;
			this.browser.Dispose();
		}

		// Token: 0x0600036D RID: 877 RVA: 0x0000AD50 File Offset: 0x00008F50
		private void Browser_Closing(object sender, CancelEventArgs e)
		{
			this.terminate = true;
			this.Dispose();
			this.main = null;
			this.source = null;
			this.dictionaryValues.Clear();
			this.dictionaryValues = null;
			this.searchElements.Clear();
			this.searchElements = null;
			Browser.instance = null;
			GC.SuppressFinalize(this);
			GC.Collect();
			GC.WaitForPendingFinalizers();
			GC.Collect();
		}

		// Token: 0x0600036E RID: 878 RVA: 0x0000ADC0 File Offset: 0x00008FC0
		public void Dispose()
		{
			this.main.Abort();
			BindingOperations.ClearAllBindings(this.browser);
			Window w = Browser.getWindowElement(this.browser);
			FieldInfo field = typeof(Window).GetField("_swh", BindingFlags.Instance | BindingFlags.NonPublic);
			object valueSWH = field.GetValue(this);
			object valueSourceWindow = valueSWH.GetType().GetField("_sourceWindow", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(valueSWH);
			object valueKeyboardInput = valueSourceWindow.GetType().GetField("_keyboardInputSinkChildren", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(valueSourceWindow);
			IEnumerable<IKeyboardInputSite> inputSites = valueKeyboardInput as IEnumerable<IKeyboardInputSite>;
			bool flag = inputSites == null;
			if (!flag)
			{
				IKeyboardInputSite currentSite = inputSites.FirstOrDefault((IKeyboardInputSite s) => s.Sink == this.browser);
				bool flag2 = currentSite != null;
				if (flag2)
				{
					currentSite.Unregister();
				}
				this._holder.Children.Remove(this.browser);
			}
		}

		// Token: 0x0600036F RID: 879 RVA: 0x0000AE9C File Offset: 0x0000909C
		private static Window getWindowElement(DependencyObject element)
		{
			while (element != null && !(element is Window))
			{
				element = VisualTreeHelper.GetParent(element);
			}
			return element as Window;
		}

		// Token: 0x06000370 RID: 880 RVA: 0x0000AED6 File Offset: 0x000090D6
		private void Browser_Navigating(object sender, NavigatingCancelEventArgs e)
		{
			this.wait = true;
			Console.WriteLine(e.Uri);
		}

		// Token: 0x06000371 RID: 881 RVA: 0x0000AEEC File Offset: 0x000090EC
		private void Browser_LoadComplete(object sender, NavigationEventArgs e)
		{
			this.wait = false;
		}

		// Token: 0x06000372 RID: 882 RVA: 0x0000AEF8 File Offset: 0x000090F8
		private void Browser_LayoutUpdated(object sender, EventArgs e)
		{
			HTMLDocument doc = (HTMLDocument)this.browser.Document;
			this.browser.LayoutUpdated -= this.Browser_LayoutUpdated;
		}

		// Token: 0x06000373 RID: 883 RVA: 0x0000AF34 File Offset: 0x00009134
		private void HideScriptErrors(WebBrowser wb, bool hide)
		{
			FieldInfo fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
			bool flag = fiComWebBrowser == null;
			if (!flag)
			{
				object objComWebBrowser = fiComWebBrowser.GetValue(wb);
				bool flag2 = objComWebBrowser == null;
				if (flag2)
				{
					wb.Loaded += delegate(object o, RoutedEventArgs s)
					{
						this.HideScriptErrors(wb, hide);
					};
				}
				else
				{
					objComWebBrowser.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, objComWebBrowser, new object[]
					{
						hide
					});
				}
			}
		}

		// Token: 0x06000374 RID: 884 RVA: 0x0000AFE0 File Offset: 0x000091E0
		private void Wait()
		{
			while (this.wait)
			{
				Thread.Sleep(1000);
			}
		}

		// Token: 0x06000375 RID: 885 RVA: 0x0000B008 File Offset: 0x00009208
		public void CreateLawsuit(Lawsuit lawsuit)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			Action<KeyValuePair<string, string>> <>9__3;
			this.main = new Thread(delegate()
			{
				List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
				where be.Name == "CreateLawsuit"
				select be).FirstOrDefault<BlockElement>().Actions;
				List<KeyValuePair<string, string>> list = lawsuit.Fields.ToList<KeyValuePair<string, string>>();
				Action<KeyValuePair<string, string>> action2;
				if ((action2 = <>9__3) == null)
				{
					action2 = (<>9__3 = delegate(KeyValuePair<string, string> f)
					{
						string value = f.Value;
						DateTime date;
						this.dictionaryValues.Add(f.Key, DateTime.TryParse(f.Value, out date) ? Shift.formatDate(f.Value, "dd/MM/yyyy", "pt-BR") : f.Value);
					});
				}
				list.ForEach(action2);
				this.dictionaryValues.Add("Adverse_name", lawsuit.Adverse.Name.ToString());
				this.dictionaryValues.Add("Accountable", lawsuit.Accountable);
				this.dictionaryValues.Add("Physical", lawsuit.Physical.ToString());
				this.dictionaryValues.Add("Folder_number", lawsuit.FolderNumber);
				this.dictionaryValues.Add("Opening_date", Shift.formatDate(lawsuit.OpeningDate.ToString(), "dd/MM/yyyy", "pt-BR"));
				this.dictionaryValues.Add("Distribution_date", Shift.formatDate(lawsuit.DistributionDate.ToString(), "dd/MM/yyyy", "pt-BR"));
				this.dictionaryValues.Add("Client", lawsuit.Client);
				this.dictionaryValues.Add("Field_of_law", lawsuit.FieldOfLaw);
				this.dictionaryValues.Add("Subject", lawsuit.Subject);
				bool juridical_person = lawsuit.Adverse.Juridical_person;
				if (juridical_person)
				{
					this.dictionaryValues.Add("Adverse_juridical_person", lawsuit.Adverse.Juridical_person.ToString());
				}
				foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
				bool flag = this.dictionaryValues.ContainsKey("Lawsuit_link");
				if (flag)
				{
					lawsuit.Link = this.dictionaryValues["Lawsuit_link"];
					lawsuit.UpdateUrl();
					lawsuit.UpdateSycn(2);
				}
				else
				{
					lawsuit.UpdateSycn(5);
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000376 RID: 886 RVA: 0x0000B06C File Offset: 0x0000926C
		public void UpdateLawsuit(Lawsuit lawsuit)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			Action<KeyValuePair<string, string>> <>9__3;
			this.main = new Thread(delegate()
			{
				List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
				where be.Name == "UpdateLawsuit"
				select be).FirstOrDefault<BlockElement>().Actions;
				List<KeyValuePair<string, string>> list = lawsuit.Fields.ToList<KeyValuePair<string, string>>();
				Action<KeyValuePair<string, string>> action2;
				if ((action2 = <>9__3) == null)
				{
					action2 = (<>9__3 = delegate(KeyValuePair<string, string> f)
					{
						string value = f.Value;
						DateTime date;
						this.dictionaryValues.Add(f.Key, DateTime.TryParse(f.Value, out date) ? Shift.formatDate(f.Value, "dd/MM/yyyy", "pt-BR") : f.Value);
					});
				}
				list.ForEach(action2);
				Dictionary<string, string> dictionary = this.dictionaryValues;
				string key = "Adverse_name";
				Adverse adverse = lawsuit.Adverse;
				string text;
				if (adverse == null)
				{
					text = null;
				}
				else
				{
					string name = adverse.Name;
					text = ((name != null) ? name.ToString() : null);
				}
				dictionary.Add(key, text ?? "");
				this.dictionaryValues.Add("Accountable", lawsuit.Accountable);
				this.dictionaryValues.Add("Physical", lawsuit.Physical.ToString());
				this.dictionaryValues.Add("Folder_number", lawsuit.FolderNumber);
				this.dictionaryValues.Add("Opening_date", lawsuit.OpeningDate);
				this.dictionaryValues.Add("Distribution_date", lawsuit.DistributionDate);
				this.dictionaryValues.Add("Client", lawsuit.Client);
				this.dictionaryValues.Add("Field_of_law", lawsuit.FieldOfLaw);
				this.dictionaryValues.Add("Subject", lawsuit.Subject);
				bool juridical_person = lawsuit.Adverse.Juridical_person;
				if (juridical_person)
				{
					this.dictionaryValues.Add("Adverse_juridical_person", lawsuit.Adverse.Juridical_person.ToString());
				}
				foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
				lawsuit.UpdateSycn(2);
			});
			this.Main.Start();
		}

		// Token: 0x06000377 RID: 887 RVA: 0x0000B0D0 File Offset: 0x000092D0
		public void CreateLawsuitPhase(LawsuitPhase lawsuitPhase)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			Action<KeyValuePair<string, string>> <>9__3;
			Func<Orgao, bool> <>9__4;
			this.main = new Thread(delegate()
			{
				List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
				where be.Name == "CreateLawsuitPhase"
				select be).FirstOrDefault<BlockElement>().Actions;
				List<KeyValuePair<string, string>> list = lawsuitPhase.Fields.ToList<KeyValuePair<string, string>>();
				Action<KeyValuePair<string, string>> action2;
				if ((action2 = <>9__3) == null)
				{
					action2 = (<>9__3 = delegate(KeyValuePair<string, string> f)
					{
						string value = f.Value;
						DateTime date;
						this.dictionaryValues.Add(f.Key, DateTime.TryParse(f.Value, out date) ? Shift.formatDate(f.Value, "dd/MM/yyyy", "pt-BR") : f.Value);
					});
				}
				list.ForEach(action2);
				string path = Environment.CurrentDirectory;
				StringReader sr = new StringReader(string.Join("/", new string[]
				{
					path,
					"Persistence/orgao.json"
				}));
				string json = System.IO.File.ReadAllText(path + "\\Persistence\\orgao.json");
				List<Orgao> orgaos = JsonConvert.DeserializeObject<List<Orgao>>(json);
				this.dictionaryValues.Add("ParentLink", lawsuitPhase.ParentLink);
				this.dictionaryValues.Add("Number", lawsuitPhase.Number);
				this.dictionaryValues.Add("Type", lawsuitPhase.Type);
				this.dictionaryValues.Add("Accountable", lawsuitPhase.Accountable);
				this.dictionaryValues.Add("OpeningDate", Shift.formatDate(lawsuitPhase.OpeningDate.ToString(), "dd/MM/yyyy", "pt-BR"));
				Dictionary<string, string> dictionary = this.dictionaryValues;
				string key = "Current";
				bool flag = lawsuitPhase.Current;
				dictionary.Add(key, flag.ToString());
				IEnumerable<Orgao> enumerable = orgaos;
				Func<Orgao, bool> predicate;
				if ((predicate = <>9__4) == null)
				{
					predicate = (<>9__4 = ((Orgao o) => o.Abreviacao + " - " + o.Nome == this.dictionaryValues["Órgão_Judicial"]));
				}
				Orgao orgao = enumerable.Where(predicate).FirstOrDefault<Orgao>();
				bool flag2 = orgao != null;
				if (flag2)
				{
					this.dictionaryValues.Remove("Órgão_Judicial");
					this.dictionaryValues.Add("Órgão_Judicial", orgao.Id.ToString());
				}
				foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
				bool flag3 = this.dictionaryValues.ContainsKey("LawsuitPhaseLink");
				if (flag3)
				{
					lawsuitPhase.Link = this.dictionaryValues["LawsuitPhaseLink"];
					lawsuitPhase.UpdateUrl();
					lawsuitPhase.UpdateSycn(2);
				}
				else
				{
					lawsuitPhase.UpdateSycn(5);
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000378 RID: 888 RVA: 0x0000B134 File Offset: 0x00009334
		public void CreateLawsuitPhaseProgress(LawsuitPhaseProgress lawsuitPhaseProgress)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			Action<KeyValuePair<string, string>> <>9__3;
			this.main = new Thread(delegate()
			{
				bool flag = lawsuitPhaseProgress.Fields.Count<KeyValuePair<string, string>>() < 5;
				if (flag)
				{
					lawsuitPhaseProgress.UpdateSycn(5);
				}
				else
				{
					List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
					where be.Name == "CreateLawsuitPhaseProgress"
					select be).FirstOrDefault<BlockElement>().Actions;
					List<KeyValuePair<string, string>> list = lawsuitPhaseProgress.Fields.ToList<KeyValuePair<string, string>>();
					Action<KeyValuePair<string, string>> action2;
					if ((action2 = <>9__3) == null)
					{
						action2 = (<>9__3 = delegate(KeyValuePair<string, string> f)
						{
							string value = f.Value;
							DateTime date;
							this.dictionaryValues.Add(f.Key, DateTime.TryParse(f.Value, out date) ? Shift.formatDate(f.Value, "dd/MM/yyyy", "pt-BR") : f.Value);
						});
					}
					list.ForEach(action2);
					string path = Environment.CurrentDirectory;
					StringReader sr = new StringReader(string.Join("/", new string[]
					{
						path,
						"Persistence/orgao.json"
					}));
					string json = System.IO.File.ReadAllText(path + "\\Persistence\\orgao.json");
					List<Orgao> orgaos = JsonConvert.DeserializeObject<List<Orgao>>(json);
					this.dictionaryValues.Add("ParentLink", lawsuitPhaseProgress.ParentLink);
					this.dictionaryValues.Add("Number", lawsuitPhaseProgress.Number);
					this.dictionaryValues.Add("Type", lawsuitPhaseProgress.Type);
					this.dictionaryValues.Add("Accountable", lawsuitPhaseProgress.Accountable);
					this.dictionaryValues.Add("OpeningDate", Shift.formatDate(lawsuitPhaseProgress.Date.ToString(), "dd/MM/yyyy", "pt-BR"));
					Dictionary<string, string> dictionary = this.dictionaryValues;
					string key = "Current";
					bool flag2 = lawsuitPhaseProgress.Current;
					dictionary.Add(key, flag2.ToString());
					foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						bool execute = task.Result;
					}
					bool flag3 = this.dictionaryValues.ContainsKey("LawsuitPhaseProgressLink");
					if (flag3)
					{
						lawsuitPhaseProgress.Link = this.dictionaryValues["LawsuitPhaseProgressLink"];
						lawsuitPhaseProgress.UpdateUrl();
						lawsuitPhaseProgress.UpdateSycn(2);
					}
					else
					{
						lawsuitPhaseProgress.UpdateSycn(5);
					}
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000379 RID: 889 RVA: 0x0000B198 File Offset: 0x00009398
		private string translateAnaliseDeRisco(string value)
		{
			string result = string.Empty;
			string text = value.ToUpper();
			string a = text;
			if (!(a == "REMOTA"))
			{
				if (!(a == "POSSÍVEL"))
				{
					if (a == "PROVÁVEL")
					{
						result = "3";
					}
				}
				else
				{
					result = "2";
				}
			}
			else
			{
				result = "1";
			}
			return result;
		}

		// Token: 0x0600037A RID: 890 RVA: 0x0000B1FC File Offset: 0x000093FC
		private string valueHelper(KeyValuePair<string, string> pair)
		{
			string value = Regex.Replace(pair.Value.Trim(), "\r\n", "");
			bool flag = pair.Key.ToLower().Contains("valor");
			if (flag)
			{
				value = this.currencyHelper(value);
			}
			bool flag2 = pair.Key.ToLower() == "análise_de_risco";
			if (flag2)
			{
				value = this.translateAnaliseDeRisco(pair.Value);
			}
			return value;
		}

		// Token: 0x0600037B RID: 891 RVA: 0x0000B27C File Offset: 0x0000947C
		private string currencyHelper(string value)
		{
			decimal result;
			bool flag = string.IsNullOrEmpty(value) || !decimal.TryParse(value, out result);
			string result2;
			if (flag)
			{
				result2 = value;
			}
			else
			{
				CultureInfo culture = CultureInfo.CreateSpecificCulture("pt-BR");
				value = value.Replace(".", "");
				value = decimal.Parse(value).ToString("C", culture);
				value = value.Replace("R$ ", "");
				result2 = value;
			}
			return result2;
		}

		// Token: 0x0600037C RID: 892 RVA: 0x0000B2F4 File Offset: 0x000094F4
		public void CreateWithLocal(string file, BlockElement mainActionBlock)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				string content = System.IO.File.ReadAllText(file);
				JavaScriptSerializer json_serializer = new JavaScriptSerializer();
				Dictionary<string, string> dicProgress = json_serializer.Deserialize<Dictionary<string, string>>(content);
				foreach (KeyValuePair<string, string> prog in dicProgress)
				{
					this.dictionaryValues.Add(prog.Key.Replace(' ', '_'), this.valueHelper(prog));
				}
				this.dictionaryValues.Remove("Data");
				this.dictionaryValues.Add("Data", "22/12/2021");
				foreach (ZionRobot.Models.Source.Action action in mainActionBlock.Actions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
			});
			this.Main.Start();
		}

		// Token: 0x0600037D RID: 893 RVA: 0x0000B35C File Offset: 0x0000955C
		public void CreateLawsuitPhaseProgressLocal(string file)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				List<ZionRobot.Models.Source.Action> CreateLawsuitPhaseProgressActions = (from be in this.Source.BlockElements
				where be.Name == "CreateLawsuitPhaseProgressLocal"
				select be).FirstOrDefault<BlockElement>().Actions;
				string content = System.IO.File.ReadAllText(file);
				JavaScriptSerializer json_serializer = new JavaScriptSerializer();
				Dictionary<string, string> dicProgress = json_serializer.Deserialize<Dictionary<string, string>>(content);
				foreach (KeyValuePair<string, string> prog in dicProgress)
				{
					this.dictionaryValues.Add(prog.Key.Replace(' ', '_'), prog.Value);
				}
				foreach (ZionRobot.Models.Source.Action action in CreateLawsuitPhaseProgressActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
			});
			this.Main.Start();
		}

		// Token: 0x0600037E RID: 894 RVA: 0x0000B3C0 File Offset: 0x000095C0
		public void CreateLawsuitDeposit(string file, BlockElement mainActionBlock)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				string content = System.IO.File.ReadAllText(file);
				JavaScriptSerializer json_serializer = new JavaScriptSerializer();
				Dictionary<string, string> dicProgress = json_serializer.Deserialize<Dictionary<string, string>>(content);
				foreach (KeyValuePair<string, string> prog in dicProgress)
				{
					this.dictionaryValues.Add(prog.Key.Replace(' ', '_'), this.valueHelper(prog));
				}
				foreach (ZionRobot.Models.Source.Action action in mainActionBlock.Actions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
			});
			this.Main.Start();
		}

		// Token: 0x0600037F RID: 895 RVA: 0x0000B428 File Offset: 0x00009628
		public void CreateLawsuitDemand(LawsuitDemand lawsuitDemand)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			Action<KeyValuePair<string, string>> <>9__3;
			this.main = new Thread(delegate()
			{
				List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
				where be.Name == "CreateLawsuitDemand"
				select be).FirstOrDefault<BlockElement>().Actions;
				List<KeyValuePair<string, string>> list = lawsuitDemand.Fields.ToList<KeyValuePair<string, string>>();
				Action<KeyValuePair<string, string>> action2;
				if ((action2 = <>9__3) == null)
				{
					action2 = (<>9__3 = delegate(KeyValuePair<string, string> f)
					{
						string value = f.Value;
						bool flag2 = f.Key == "Análise_de_Risco";
						if (flag2)
						{
							string value2 = f.Value;
							string a = value2;
							if (!(a == "Remota"))
							{
								if (!(a == "Possível"))
								{
									if (a == "Provável")
									{
										value = "3";
									}
								}
								else
								{
									value = "2";
								}
							}
							else
							{
								value = "1";
							}
						}
						bool flag3 = f.Key == "Causa_de_Pedir";
						if (flag3)
						{
							HtmlDocument htmlDoc = new HtmlDocument();
							htmlDoc.LoadHtml(f.Value);
							value = htmlDoc.DocumentNode.InnerText;
						}
						DateTime date;
						this.dictionaryValues.Add(f.Key, DateTime.TryParse(f.Value, out date) ? Shift.formatDate(f.Value, "dd/MM/yyyy", "pt-BR") : value);
					});
				}
				list.ForEach(action2);
				this.dictionaryValues.Add("ParentLink", lawsuitDemand.ParentLink);
				this.dictionaryValues.Add("Accountable", lawsuitDemand.Accountable);
				this.dictionaryValues.Add("OpeningDate", Shift.formatDate(lawsuitDemand.OpeningDate.ToString(), "dd/MM/yyyy", "pt-BR"));
				foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
				bool flag = this.dictionaryValues.ContainsKey("LawsuitDemandLink");
				if (flag)
				{
					lawsuitDemand.Link = this.dictionaryValues["LawsuitDemandLink"];
					lawsuitDemand.UpdateUrl();
					lawsuitDemand.UpdateSycn(2);
				}
				else
				{
					lawsuitDemand.UpdateSycn(5);
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000380 RID: 896 RVA: 0x0000B48C File Offset: 0x0000968C
		public void ExecuteAndSave(string path)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				foreach (ActionsElement actionElement in this.Source.ActionsElements)
				{
					foreach (ZionRobot.Models.Source.Action action in actionElement.Actions)
					{
						this.executeAction(action).Wait();
					}
				}
				this.SaveData(path);
			});
			this.main.Start();
		}

		// Token: 0x06000381 RID: 897 RVA: 0x0000B4F0 File Offset: 0x000096F0
		private void SaveData(string path)
		{
			int i = 1;
			this.searchElements.ForEach(delegate(List<Element> data)
			{
				int i = i;
				i++;
				string allElementsTxt = string.Join(" ", (from d in data
				where d.GoTo == "SearchLog"
				select d into e
				select e.Value).ToArray<string>());
				bool flag = !this.hasLog(allElementsTxt);
				if (flag)
				{
					DateTime datenow = DateTime.Now;
					string fileName = string.Format("Publicação-{0}-{1}", this.source.OutputFolder, datenow.ToString("yyyyMMdd-HHmmssffff"));
					Document doc = new Document();
					doc.Pages.Add(new ZionVault.Binder.OCR.Page(string.Join(Environment.NewLine, (from d in data
					where d.GoTo == "Meta"
					select d into e
					select e.Value).ToArray<string>())));
					Directory.CreateDirectory(path);
					string fileFullPath = Naming.GetFileFullPath(path, fileName, ".ocr");
					doc.Save(fileFullPath, false, false);
					CultureInfo culture = new CultureInfo("pt-BR");
					Logs.SearchLog.SearchResults.Add(string.Concat(new string[]
					{
						datenow.ToString("G", culture),
						"||",
						this.source.Title,
						"||",
						fileFullPath,
						"||",
						allElementsTxt
					}));
					Logs.SearchLog.Save();
				}
			});
		}

		// Token: 0x06000382 RID: 898 RVA: 0x0000B534 File Offset: 0x00009734
		public void ExecuteAndMove(ZionRobot.Models.Items.File file, string outputPath)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				foreach (ActionsElement actionElement in this.Source.ActionsElements)
				{
					foreach (ZionRobot.Models.Source.Action action in actionElement.Actions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						bool execute = task.Result;
					}
				}
				Activity activity = new Activity();
				activity.Date = this.dictionaryValues["ActivityDate"];
				activity.DateFinal = this.dictionaryValues["ActivityDate"];
				activity.TypeId = 152;
				activity.Subject = "Verificar";
				activity.Client = this.dictionaryValues["Cliente"];
				activity.Sponsor = this.dictionaryValues["userName"];
				activity.Fields.Add("1", activity.Sponsor);
				activity.Fields.Add("2", activity.Client);
				activity.Fields.Add("3", this.dictionaryValues["Número da pasta"]);
				activity.Fields.Add("4", this.dictionaryValues["URL da atividade"]);
				activity.Fields.Add("5", (this.dictionaryValues.FirstOrDefault((KeyValuePair<string, string> x) => x.Key == "ProcessUrl").Key != null) ? this.dictionaryValues["ProcessUrl"] : "");
				activity.Fields.Add("6", (this.dictionaryValues.FirstOrDefault((KeyValuePair<string, string> x) => x.Key == "SharpointUrl").Key != null) ? this.dictionaryValues["SharpointUrl"] : "");
				activity.Fields.Add("7", Shift.formatDate(this.dictionaryValues["Data da publicação"], "yyyy-MM-dd HH:mm:ss", "pt-BR"));
				activity.Fields.Add("9", this.dictionaryValues["SearchElements.Fields.Conteudo"]);
				activity.Fields.Add("10", (this.dictionaryValues.FirstOrDefault((KeyValuePair<string, string> x) => x.Key == "Parecer").Key != null) ? this.dictionaryValues["Parecere"] : "");
				try
				{
					activity.createActivity();
				}
				catch (Exception ex)
				{
				}
				finally
				{
					file.METAObject.Status = "INTEGRATED";
					file.METAObject.Save(file.META, false, false);
					file.Status = "INTEGRATED";
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000383 RID: 899 RVA: 0x0000B598 File Offset: 0x00009798
		public void ExecuteDemo()
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				base.Visibility = Visibility.Visible;
				base.ShowInTaskbar = true;
				base.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				foreach (ActionsElement actionElement in this.Source.ActionsElements)
				{
					foreach (ZionRobot.Models.Source.Action action in actionElement.Actions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						bool execute = task.Result;
					}
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000384 RID: 900 RVA: 0x0000B5E8 File Offset: 0x000097E8
		public void SyncActivity(Activity activity)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				bool execute = true;
				this.DictionaryValues.Add("ActivityUrl", activity.DataJuri);
				this.DictionaryValues.Add("Responsável", activity.Sponsor);
				this.DictionaryValues.Add("EmailResponsável", activity.SponsorEmail);
				this.DictionaryValues.Add("Cliente", activity.Client);
				this.DictionaryValues.Add("NumeroPasta", activity.ProcessNumber);
				this.DictionaryValues.Add("Data", Shift.formatDate(activity.Date, "dd/MM/yyyy", "pt-BR"));
				this.DictionaryValues.Add("DataFatal", Shift.formatDate(activity.DateFinal, "dd/MM/yyyy", "pt-BR"));
				foreach (ActionsElement actionElement in this.Source.ActionsElements)
				{
					foreach (ZionRobot.Models.Source.Action action in actionElement.Actions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						execute = task.Result;
					}
				}
				bool flag = activity.Parecer != null && activity.TypeId == 1;
				if (flag)
				{
					this.DictionaryValues.Add("ActivityParecer", activity.Parecer);
					List<ZionRobot.Models.Source.Action> createParecerActions = (from be in this.Source.BlockElements
					where be.Name == "CreateParecer"
					select be).FirstOrDefault<BlockElement>().Actions;
					bool flag2 = createParecerActions != null;
					if (flag2)
					{
						foreach (ZionRobot.Models.Source.Action action2 in createParecerActions)
						{
							Task<bool> task2 = this.executeAction(action2);
							task2.Wait();
							execute = task2.Result;
						}
					}
				}
				List<ZionRobot.Models.Source.Action> createCommentActions = (from be in this.Source.BlockElements
				where be.Name == "CreateComment"
				select be).FirstOrDefault<BlockElement>().Actions;
				bool flag3 = createCommentActions != null;
				if (flag3)
				{
					(from c in activity.Comments
					orderby c.CreatedAt
					select c).ToList<Comment>().ForEach(delegate(Comment comment)
					{
						this.DictionaryValues.Add("CommentResponser", comment.CreatedByName);
						this.DictionaryValues.Add("CommentSubject", comment.Subject);
						this.DictionaryValues.Add("CommentValue", comment.Value);
						foreach (ZionRobot.Models.Source.Action action4 in createCommentActions)
						{
							Task<bool> task4 = this.executeAction(action4);
							task4.Wait();
							execute = task4.Result;
						}
						this.DictionaryValues.Remove("CommentResponser");
						this.DictionaryValues.Remove("CommentSubject");
						this.DictionaryValues.Remove("CommentValue");
					});
				}
				List<ZionRobot.Models.Source.Action> createDeadlineActions = (from be in this.Source.BlockElements
				where be.Name == "CreateDeadline"
				select be).FirstOrDefault<BlockElement>().Actions;
				activity.Deadlines.ForEach(delegate(Deadline deadline)
				{
					bool flag5 = createDeadlineActions != null;
					if (flag5)
					{
						this.DictionaryValues.Add("DeadlineResponser", deadline.SponserName);
						this.DictionaryValues.Add("DeadlineResponserEmail", deadline.SponserEmail);
						this.DictionaryValues.Add("DeadlineSubject", deadline.Subject);
						this.DictionaryValues.Add("DeadlineDate", Shift.formatDate(deadline.Pre, "dd/MM/yyyy", "pt-BR"));
						this.DictionaryValues.Add("DeadlineFinal", Shift.formatDate(deadline.Value, "dd/MM/yyyy", "pt-BR"));
						this.DictionaryValues.Add("SearchElements.Fields.Tipo", "Publicação");
						foreach (ZionRobot.Models.Source.Action action4 in createDeadlineActions)
						{
							Task<bool> task4 = this.executeAction(action4);
							task4.Wait();
							execute = task4.Result;
						}
						Activity subActivity = new Activity();
						subActivity.EntityId = activity.EntityId;
						subActivity.ParentId = new int?(activity.Id);
						subActivity.Date = this.dictionaryValues["DeadlineDate"];
						subActivity.DateFinal = this.dictionaryValues["DeadlineFinal"];
						subActivity.TypeId = 4;
						subActivity.Subject = this.dictionaryValues["DeadlineSubject"];
						subActivity.Client = this.dictionaryValues["Cliente"];
						subActivity.Sponsor = this.dictionaryValues["DeadlineResponser"];
						subActivity.Fields.Add("1", subActivity.Client);
						subActivity.Fields.Add("2", subActivity.Sponsor);
						subActivity.Fields.Add("3", (!string.IsNullOrEmpty(activity.ProcessNumber)) ? activity.ProcessNumber : "");
						subActivity.Fields.Add("4", this.dictionaryValues["URL da atividade"]);
						subActivity.Fields.Add("5", (activity.ProcessURL != null) ? activity.ProcessURL : "");
						subActivity.Fields.Add("6", (activity.Sharepoint != null) ? activity.Sharepoint : "");
						subActivity.createActivity();
						this.DictionaryValues.Remove("DeadlineResponser");
						this.DictionaryValues.Remove("DeadlineResponserEmail");
						this.DictionaryValues.Remove("DeadlineSubject");
						this.DictionaryValues.Remove("DeadlineDate");
						this.DictionaryValues.Remove("DeadlineFinal");
						this.DictionaryValues.Remove("SearchElements.Fields.Tipo");
						this.DictionaryValues.Remove("Número da pasta");
						this.DictionaryValues.Remove("URL da atividade");
						this.DictionaryValues.Remove("1");
						this.DictionaryValues.Remove("2");
						this.DictionaryValues.Remove("3");
						this.DictionaryValues.Remove("4");
						this.DictionaryValues.Remove("5");
						this.DictionaryValues.Remove("6");
					}
				});
				List<ZionRobot.Models.Source.Action> doneActivityActions = (from be in this.Source.BlockElements
				where be.Name == "DoneActivity"
				select be).FirstOrDefault<BlockElement>().Actions;
				bool flag4 = doneActivityActions != null;
				if (flag4)
				{
					foreach (ZionRobot.Models.Source.Action action3 in doneActivityActions)
					{
						Task<bool> task3 = this.executeAction(action3);
						task3.Wait();
						execute = task3.Result;
					}
				}
				activity.DoneActivity();
			});
			this.Main.Start();
		}

		// Token: 0x06000385 RID: 901 RVA: 0x0000B64C File Offset: 0x0000984C
		public void OldUploadAttachments(Activity activity)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				string clientFolder = (activity.ClientCode != null) ? (activity.ClientCode + " " + activity.Client) : activity.Client;
				string numberFolder = "Consultas/" + clientFolder + "/" + activity.ProcessNumber;
				string attachmentsFolder = (activity.Action == "Sharepoint") ? "Anexos Recebidos" : "Anexos Enviados";
				string subDir = (activity.Attachments.Count<ZionRobot.Models.ZFlow.Attachment>() == 0) ? numberFolder : (numberFolder + "/" + attachmentsFolder);
				ZionSharePointManager manager = new ZionSharePointManager(SoaresPiconSharePoint.UserName, SoaresPiconSharePoint.Password);
				manager.ConnectToSharePointOnline(SoaresPiconSharePoint.ConsultaUrl);
				List collection = manager.GetCollection("Documentos");
				Microsoft.SharePoint.Client.Folder folder = manager.GetFolder(collection, subDir.Trim(new char[]
				{
					'/'
				}));
				bool flag = folder.Name != subDir.Split(new char[]
				{
					'/'
				}).Last<string>() || !folder.Name.StartsWith(subDir.Split(new char[]
				{
					'/'
				}).Last<string>());
				if (flag)
				{
					folder = manager.BuildFolder(collection, subDir);
				}
				Microsoft.SharePoint.Client.File file;
				foreach (ZionRobot.Models.ZFlow.Attachment attach in activity.Attachments)
				{
					file = manager.UploadFile(folder, attach.Name, attach.Content);
					bool flag2 = file == null;
					if (flag2)
					{
						activity.UpdateActivitySycn(3);
						return;
					}
					attach.Link = new Uri(SoaresPiconSharePoint.SiteUrl + file.ServerRelativeUrl);
					attach.UpdateLinkOnZion();
				}
				bool flag3 = folder.Name != numberFolder.Split(new char[]
				{
					'/'
				}).Last<string>() || !folder.Name.StartsWith(numberFolder.Split(new char[]
				{
					'/'
				}).Last<string>());
				if (flag3)
				{
					folder = manager.GetFolder(collection, numberFolder);
				}
				HtmlDocument htmlDoc = new HtmlDocument();
				htmlDoc.LoadHtml(activity.EmailContent);
				string result = htmlDoc.DocumentNode.SelectSingleNode("//body").InnerText;
				byte[] emailContent = Encoding.UTF8.GetBytes(result);
				file = manager.UploadFile(folder, activity.EmailSubject + ".txt", Convert.ToBase64String(emailContent));
				activity.Sharepoint = new Uri(SoaresPiconSharePoint.SiteUrl + "/" + folder.ServerRelativeUrl).AbsoluteUri;
				activity.UpdateActivityFieldValue("Link do Sharepoint", activity.Sharepoint);
				activity.UpdateActivitySycn(2);
			});
			this.Main.Start();
		}

		// Token: 0x06000386 RID: 902 RVA: 0x0000B6B0 File Offset: 0x000098B0
		public void UploadAttachments(Activity activity)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				try
				{
					string clientFolder = (activity.ClientCode != null && activity.ClientCode != string.Empty) ? (activity.ClientCode + " " + activity.Client) : activity.Client;
					string numberFolder = "Consultas/" + clientFolder + "/" + activity.ProcessNumber;
					string emailContent = null;
					string emailSubject = null;
					bool flag = string.IsNullOrEmpty(activity.EmailReplyContent);
					string attachmentsFolder;
					if (flag)
					{
						attachmentsFolder = "Anexos Recebidos";
						emailContent = activity.EmailContent;
						emailSubject = activity.EmailSubject;
					}
					else
					{
						attachmentsFolder = "Anexos Enviados";
						emailContent = activity.EmailReplyContent;
						emailSubject = activity.EmailSubject;
					}
					string subDir = (activity.Attachments.Count<ZionRobot.Models.ZFlow.Attachment>() == 0) ? numberFolder : (numberFolder + "/" + attachmentsFolder);
					ZionSharePointManager manager = new ZionSharePointManager(SoaresPiconSharePoint.UserName, SoaresPiconSharePoint.Password);
					manager.ConnectToSharePointOnline(SoaresPiconSharePoint.ConsultaUrl);
					List collection = manager.GetCollection("Documentos");
					Microsoft.SharePoint.Client.Folder folder = manager.GetFolder(collection, subDir.Trim(new char[]
					{
						'/'
					}));
					bool flag2 = folder.Name != subDir.Split(new char[]
					{
						'/'
					}).Last<string>() || !folder.Name.StartsWith(subDir.Split(new char[]
					{
						'/'
					}).Last<string>());
					if (flag2)
					{
						folder = manager.BuildFolder(collection, subDir);
					}
					foreach (ZionRobot.Models.ZFlow.Attachment attach in activity.Attachments)
					{
						Microsoft.SharePoint.Client.File file = manager.UploadFile(folder, attach.Name, attach.Content);
						bool flag3 = file == null;
						if (flag3)
						{
							activity.UpdateActivitySycn(3);
							return;
						}
						attach.Link = new Uri(SoaresPiconSharePoint.SiteUrl + file.ServerRelativeUrl);
					}
					bool flag4 = folder.Name != numberFolder.Split(new char[]
					{
						'/'
					}).Last<string>() || !folder.Name.StartsWith(numberFolder.Split(new char[]
					{
						'/'
					}).Last<string>());
					if (flag4)
					{
						folder = manager.GetFolder(collection, numberFolder);
					}
					activity.Sharepoint = new Uri(SoaresPiconSharePoint.SiteUrl + "/" + folder.ServerRelativeUrl).AbsoluteUri;
					activity.UpdateActivityFieldValue("Link do Sharepoint", activity.Sharepoint);
					bool flag5 = string.IsNullOrEmpty(emailContent);
					if (flag5)
					{
						activity.UpdateActivitySycn(2);
					}
					else
					{
						HtmlDocument htmlDoc = new HtmlDocument();
						htmlDoc.LoadHtml(emailContent);
						string result = htmlDoc.DocumentNode.InnerHtml;
						string to = activity.EmailTo ?? "consultas@soarespicon.adv.br";
						string from = "consultas@soarespicon.adv.br";
						string subject = emailSubject;
						string body = result;
						string tempDir = "C:\\Temp\\Email";
						using (SmtpClient client = new SmtpClient())
						{
							MailMessage msg = new MailMessage(from, to, subject, body);
							msg.IsBodyHtml = true;
							msg.BodyEncoding = Encoding.UTF8;
							client.UseDefaultCredentials = true;
							client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
							client.PickupDirectoryLocation = tempDir;
							try
							{
								client.Send(msg);
							}
							catch (Exception ex)
							{
								Environment.Exit(-1);
							}
						}
						FileInfo msgTemp = (from f in new DirectoryInfo(tempDir).GetFiles()
						orderby f.LastWriteTime descending
						select f).First<FileInfo>();
						Microsoft.SharePoint.Client.File file = manager.UploadFile(folder, subject + ".eml", msgTemp.FullName);
						bool flag6 = file == null;
						if (flag6)
						{
							activity.UpdateActivitySycn(3);
						}
						else
						{
							System.IO.File.Delete(msgTemp.FullName);
							activity.UpdateActivitySycn(2);
						}
					}
				}
				catch (Exception ex2)
				{
					activity.UpdateActivitySycn(12);
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000387 RID: 903 RVA: 0x0000B714 File Offset: 0x00009914
		public void CreateSubActivity(Activity activity)
		{
			this.Activity = activity;
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				bool flag;
				if (string.IsNullOrEmpty(activity.ProcessURL) && string.IsNullOrEmpty(activity.CaseURL))
				{
					if (activity.ParentId != null)
					{
						int? parentId = activity.ParentId;
						int num = 0;
						if (!(parentId.GetValueOrDefault() <= num & parentId != null))
						{
							goto IL_73;
						}
					}
					flag = string.IsNullOrEmpty(activity.ParentDataJuri);
					goto IL_74;
				}
				IL_73:
				flag = false;
				IL_74:
				bool flag2 = flag;
				if (flag2)
				{
					Console.WriteLine();
				}
				else
				{
					List<ZionRobot.Models.Source.Action> createActivityActions = new List<ZionRobot.Models.Source.Action>();
					createActivityActions = (from be in this.Source.BlockElements
					where be.Name == "CreateActivity"
					select be).FirstOrDefault<BlockElement>().Actions;
					Dictionary<string, string> dictionary = this.DictionaryValues;
					string key = "UrlToCreate";
					string value;
					if ((value = activity.ParentDataJuri) == null)
					{
						value = (activity.CaseURL ?? activity.ProcessURL);
					}
					dictionary.Add(key, value);
					bool flag3 = !string.IsNullOrEmpty(activity.Content);
					if (flag3)
					{
						try
						{
							HtmlDocument doc = new HtmlDocument();
							doc.LoadHtml(activity.Content);
							this.DictionaryValues.Add("Content", doc.DocumentNode.InnerText.Replace("&nbsp;", string.Empty));
						}
						catch (Exception)
						{
							this.DictionaryValues.Add("Content", activity.Content);
						}
					}
					this.DictionaryValues.Add("ZionId", activity.Id.ToString());
					this.DictionaryValues.Add("Responser", activity.Sponsor);
					this.DictionaryValues.Add("ResponserEmail", activity.SponsorEmail);
					this.DictionaryValues.Add("Subject", activity.Subject);
					this.DictionaryValues.Add("Date", Shift.formatDate(activity.Date, "dd/MM/yyyy", "pt-BR"));
					this.DictionaryValues.Add("DateFinal", Shift.formatDate(activity.DateFinal, "dd/MM/yyyy", "pt-BR"));
					this.DictionaryValues.Add("Group", activity.Group);
					this.DictionaryValues.Add("SearchElements.Fields.Tipo", "Publicação");
					bool flag4 = !string.IsNullOrEmpty(activity.Hour);
					if (flag4)
					{
						this.DictionaryValues.Add("Hour", activity.Hour);
					}
					foreach (ZionRobot.Models.Source.Action action in createActivityActions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						bool execute = task.Result;
					}
					bool flag5 = this.dictionaryValues.ContainsKey("URL da atividade");
					if (flag5)
					{
						activity.DataJuri = this.dictionaryValues["URL da atividade"];
						activity.UpdateActivityUrl();
						activity.UpdateActivitySycn(2);
					}
					else
					{
						activity.UpdateActivitySycn(5);
					}
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000388 RID: 904 RVA: 0x0000B784 File Offset: 0x00009984
		public void CreateCase(Activity activity)
		{
			this.Activity = activity;
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				bool flag = string.IsNullOrEmpty(activity.Sharepoint);
				if (flag)
				{
					Console.WriteLine();
				}
				else
				{
					List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
					where be.Name == "CreateCase"
					select be).FirstOrDefault<BlockElement>().Actions;
					HtmlDocument htmlDoc = new HtmlDocument();
					htmlDoc.LoadHtml(activity.EmailContent);
					string result = htmlDoc.DocumentNode.InnerText;
					this.DictionaryValues.Add("CaseURL", activity.CaseURL);
					this.DictionaryValues.Add("Responser", activity.Sponsor);
					this.DictionaryValues.Add("ResponserEmail", activity.SponsorEmail);
					this.DictionaryValues.Add("Area", this.translateArea(activity.Subject));
					this.DictionaryValues.Add("CreatedAt", Shift.formatDate(activity.CreatedAt, "dd/MM/yyyy", "pt-BR"));
					this.DictionaryValues.Add("EmailSubject", activity.EmailSubject);
					this.DictionaryValues.Add("EmailContent", result);
					this.DictionaryValues.Add("Priority", activity.Priority);
					this.DictionaryValues.Add("Sharepoint", activity.Sharepoint);
					this.DictionaryValues.Add("Client", activity.Client);
					this.DictionaryValues.Add("FolderNumber", activity.ProcessNumber);
					foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						bool execute = task.Result;
					}
					bool flag2 = this.dictionaryValues.ContainsKey("CaseUrl");
					if (flag2)
					{
						activity.CaseURL = this.dictionaryValues["CaseUrl"];
						activity.UpdateActivityFieldValue("Link do Caso", activity.CaseURL);
						activity.UpdateActivitySycn(2);
					}
					else
					{
						activity.UpdateActivitySycn(5);
					}
				}
			});
			this.Main.Start();
		}

		// Token: 0x06000389 RID: 905 RVA: 0x0000B7F4 File Offset: 0x000099F4
		public void CloseCase(Activity activity)
		{
			this.Activity = activity;
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				bool flag = string.IsNullOrEmpty(activity.CaseURL);
				if (flag)
				{
					Console.WriteLine();
				}
				else
				{
					List<ZionRobot.Models.Source.Action> UpdateActivityActions = (from be in this.Source.BlockElements
					where be.Name == "CloseCase"
					select be).FirstOrDefault<BlockElement>().Actions;
					HtmlDocument htmlDoc = new HtmlDocument();
					htmlDoc.LoadHtml(activity.EmailReplyContent);
					string result = htmlDoc.DocumentNode.InnerText;
					this.DictionaryValues.Add("CaseUrl", activity.CaseURL);
					this.DictionaryValues.Add("Responser", activity.Sponsor);
					this.DictionaryValues.Add("Client", activity.Client);
					this.DictionaryValues.Add("SyncCreateAt", Shift.formatDate(activity.SyncCreateAt, "dd/MM/yyyy", "pt-BR"));
					this.DictionaryValues.Add("EmailReplyContent", result);
					foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
					{
						Task<bool> task = this.executeAction(action);
						task.Wait();
						bool execute = task.Result;
					}
					activity.UpdateActivitySycn(2);
				}
			});
			this.Main.Start();
		}

		// Token: 0x0600038A RID: 906 RVA: 0x0000B864 File Offset: 0x00009A64
		private string translateArea(string area)
		{
			uint num = <PrivateImplementationDetails>.ComputeStringHash(area);
			if (num <= 1241302063U)
			{
				if (num <= 794282553U)
				{
					if (num != 386975329U)
					{
						if (num != 776646911U)
						{
							if (num != 794282553U)
							{
								goto IL_196;
							}
							if (!(area == "Trabalhista - Justa Causa"))
							{
								goto IL_196;
							}
						}
						else
						{
							if (!(area == "Contratos - Plano de saúde (Convênios)"))
							{
								goto IL_196;
							}
							goto IL_18E;
						}
					}
					else
					{
						if (!(area == "Contratos - Locação"))
						{
							goto IL_196;
						}
						goto IL_18E;
					}
				}
				else if (num != 914995025U)
				{
					if (num != 1224632208U)
					{
						if (num != 1241302063U)
						{
							goto IL_196;
						}
						if (!(area == "Contratos - Outros"))
						{
							goto IL_196;
						}
						goto IL_18E;
					}
					else
					{
						if (!(area == "Contratos - Compra e Venda"))
						{
							goto IL_196;
						}
						goto IL_18E;
					}
				}
				else if (!(area == "Trabalhista - Outros"))
				{
					goto IL_196;
				}
			}
			else if (num <= 2200322199U)
			{
				if (num != 1249023226U)
				{
					if (num != 2168012727U)
					{
						if (num != 2200322199U)
						{
							goto IL_196;
						}
						if (!(area == "Trabalhista - Afastamento INSS"))
						{
							goto IL_196;
						}
					}
					else if (!(area == "Trabalhista - Estágio"))
					{
						goto IL_196;
					}
				}
				else
				{
					if (!(area == "Contratos - Internacional"))
					{
						goto IL_196;
					}
					goto IL_18E;
				}
			}
			else if (num != 2676606078U)
			{
				if (num != 3041903933U)
				{
					if (num != 4101459249U)
					{
						goto IL_196;
					}
					if (!(area == "Trabalhista - Outras Sanções"))
					{
						goto IL_196;
					}
				}
				else if (!(area == "Trabalhista - Contrato de Trabalho"))
				{
					goto IL_196;
				}
			}
			else
			{
				if (!(area == "Contratos - Prestação de Serviços"))
				{
					goto IL_196;
				}
				goto IL_18E;
			}
			return "Trabalhista";
			IL_18E:
			return "Contratos";
			IL_196:
			return area;
		}

		// Token: 0x0600038B RID: 907 RVA: 0x0000BA0C File Offset: 0x00009C0C
		public void UpdateActivity(Activity activity)
		{
			this.Activity = activity;
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			Func<BlockElement, bool> <>9__3;
			this.main = new Thread(delegate()
			{
				List<ZionRobot.Models.Source.Action> actions;
				if (!(activity.Status == "2"))
				{
					IEnumerable<BlockElement> blockElements = this.Source.BlockElements;
					Func<BlockElement, bool> predicate;
					if ((predicate = <>9__3) == null)
					{
						predicate = (<>9__3 = ((BlockElement be) => be.Name == ((activity.CaseURL != null) ? "UpdateActivityConsulta" : "UpdateActivity")));
					}
					actions = blockElements.Where(predicate).FirstOrDefault<BlockElement>().Actions;
				}
				else
				{
					actions = (from be in this.Source.BlockElements
					where be.Name == "FinalizeActivity"
					select be).FirstOrDefault<BlockElement>().Actions;
				}
				List<ZionRobot.Models.Source.Action> UpdateActivityActions = actions;
				this.DictionaryValues.Add("ZionId", activity.Id.ToString());
				this.DictionaryValues.Add("ActivityUrl", activity.DataJuri);
				this.DictionaryValues.Add("Responser", activity.Sponsor);
				this.DictionaryValues.Add("ResponserEmail", activity.SponsorEmail);
				this.DictionaryValues.Add("Subject", activity.Subject);
				this.DictionaryValues.Add("Date", Shift.formatDate(activity.Date, "dd/MM/yyyy", "pt-BR"));
				this.DictionaryValues.Add("DateFinal", Shift.formatDate(activity.DateFinal, "dd/MM/yyyy", "pt-BR"));
				this.DictionaryValues.Add("Group", activity.Group);
				this.DictionaryValues.Add("SearchElements.Fields.Tipo", "Publicação");
				this.DictionaryValues.Add("ActivityStatus", this.translateActivityStatus(activity.Status));
				this.DictionaryValues.Add("Client", activity.Client);
				this.DictionaryValues.Add("FolderNumber", activity.ProcessNumber);
				bool flag = !string.IsNullOrEmpty(activity.Hour);
				if (flag)
				{
					this.DictionaryValues.Add("Hour", activity.Hour);
				}
				bool flag2 = !string.IsNullOrEmpty(activity.Content);
				if (flag2)
				{
					try
					{
						HtmlDocument doc = new HtmlDocument();
						doc.LoadHtml(activity.Content);
						this.DictionaryValues.Add("Content", doc.DocumentNode.InnerText.Replace("&nbsp;", string.Empty));
					}
					catch (Exception)
					{
						this.DictionaryValues.Add("Content", activity.Content);
					}
				}
				bool flag3 = activity.Comment != null;
				if (flag3)
				{
					this.DictionaryValues.Add("CommentResponser", activity.CommentCreateBy);
					this.DictionaryValues.Add("CommentSubject", activity.Subject);
					this.DictionaryValues.Add("CommentValue", activity.Comment);
				}
				bool flag4 = !string.IsNullOrEmpty(activity.Parecer);
				if (flag4)
				{
					HtmlDocument htmlDoc = new HtmlDocument();
					htmlDoc.LoadHtml(activity.Parecer);
					string result = htmlDoc.DocumentNode.InnerText;
					this.DictionaryValues.Add("ActivityParecer", result);
				}
				foreach (ZionRobot.Models.Source.Action action in UpdateActivityActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					bool execute = task.Result;
				}
				activity.UpdateActivitySycn(2);
			});
			this.Main.Start();
		}

		// Token: 0x0600038C RID: 908 RVA: 0x0000BA7C File Offset: 0x00009C7C
		private string translateActivityStatus(string status)
		{
			string text = status;
			string text2 = text;
			if ((text2 == null || text2.Length != 0) && !(text2 == "0"))
			{
				if (!(text2 == "2") && !(text2 == "3"))
				{
					if (!(text2 == "4"))
					{
						status = "Não iniciado";
					}
					else
					{
						status = "Aguardando";
					}
				}
				else
				{
					status = "Concluído";
				}
			}
			else
			{
				status = "Cancelado";
			}
			return status;
		}

		// Token: 0x0600038D RID: 909 RVA: 0x0000BAF8 File Offset: 0x00009CF8
		public void SyncActivityCanceling(Activity activity)
		{
			Application.Current.Dispatcher.Invoke(delegate()
			{
				this.Visibility = Visibility.Visible;
				this.ShowInTaskbar = true;
				this.Show();
				this.terminate = false;
			});
			this.main = new Thread(delegate()
			{
				bool execute = true;
				this.DictionaryValues.Add("ActivityUrl", activity.DataJuri);
				List<ZionRobot.Models.Source.Action> authenticateActions = (from be in this.Source.BlockElements
				where be.Name == "Authenticate"
				select be).FirstOrDefault<BlockElement>().Actions;
				foreach (ZionRobot.Models.Source.Action action in authenticateActions)
				{
					Task<bool> task = this.executeAction(action);
					task.Wait();
					execute = task.Result;
				}
				List<ZionRobot.Models.Source.Action> createCommentActions = (from be in this.Source.BlockElements
				where be.Name == "CreateComment"
				select be).FirstOrDefault<BlockElement>().Actions;
				bool flag = createCommentActions != null;
				if (flag)
				{
					(from c in activity.Comments
					orderby c.CreatedAt
					select c).ToList<Comment>().ForEach(delegate(Comment comment)
					{
						this.DictionaryValues.Add("CommentResponser", comment.CreatedByName);
						this.DictionaryValues.Add("CommentSubject", comment.Subject);
						this.DictionaryValues.Add("CommentValue", comment.Value);
						foreach (ZionRobot.Models.Source.Action action3 in createCommentActions)
						{
							Task<bool> task3 = this.executeAction(action3);
							task3.Wait();
							execute = task3.Result;
						}
						this.DictionaryValues.Remove("CommentResponser");
						this.DictionaryValues.Remove("CommentSubject");
						this.DictionaryValues.Remove("CommentValue");
					});
				}
				List<ZionRobot.Models.Source.Action> cancelingActivityActions = (from be in this.Source.BlockElements
				where be.Name == "CancelingActivity"
				select be).FirstOrDefault<BlockElement>().Actions;
				bool flag2 = cancelingActivityActions != null;
				if (flag2)
				{
					foreach (ZionRobot.Models.Source.Action action2 in cancelingActivityActions)
					{
						Task<bool> task2 = this.executeAction(action2);
						task2.Wait();
						execute = task2.Result;
					}
				}
				activity.CanceledActivity();
			});
			this.Main.Start();
		}

		// Token: 0x0600038E RID: 910 RVA: 0x0000BB5C File Offset: 0x00009D5C
		[DebuggerStepThrough]
		private Task<bool> executeAction(ZionRobot.Models.Source.Action action)
		{
			Browser.<executeAction>d__59 <executeAction>d__ = new Browser.<executeAction>d__59();
			<executeAction>d__.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
			<executeAction>d__.<>4__this = this;
			<executeAction>d__.action = action;
			<executeAction>d__.<>1__state = -1;
			<executeAction>d__.<>t__builder.Start<Browser.<executeAction>d__59>(ref <executeAction>d__);
			return <executeAction>d__.<>t__builder.Task;
		}

		// Token: 0x0600038F RID: 911 RVA: 0x0000BBA8 File Offset: 0x00009DA8
		private List<IHTMLElement> getHTMLElements(string where, IHTMLElementCollection elementCollection = null)
		{
			HTMLDocument htmlDoc = this.GetHTMLDocument();
			bool flag = htmlDoc.all == null && elementCollection == null;
			List<IHTMLElement> result;
			if (flag)
			{
				result = new List<IHTMLElement>();
			}
			else
			{
				List<IHTMLElementCollection> list = new List<IHTMLElementCollection>
				{
					(elementCollection != null) ? elementCollection : htmlDoc.all
				};
				result = CQuery.Find(where, list);
			}
			return result;
		}

		// Token: 0x06000390 RID: 912 RVA: 0x0000BBFC File Offset: 0x00009DFC
		private bool checkDictionaryKey(ZionRobot.Models.Source.Action action)
		{
			bool flag = this.dictionaryValues.ContainsKey(action.Value) && action.ResultTrue.Count > 0;
			bool result;
			if (flag)
			{
				action.ResultTrue.ForEach(delegate(ZionRobot.Models.Source.Action a)
				{
					this.executeAction(a).Wait();
				});
				result = true;
			}
			else
			{
				bool flag2 = action.ResultFalse.Count > 0;
				if (flag2)
				{
					action.ResultFalse.ForEach(delegate(ZionRobot.Models.Source.Action a)
					{
						this.executeAction(a).Wait();
					});
					result = true;
				}
				else
				{
					result = false;
				}
			}
			return result;
		}

		// Token: 0x06000391 RID: 913 RVA: 0x0000BC84 File Offset: 0x00009E84
		private bool special2(ZionRobot.Models.Source.Action action)
		{
			bool result;
			try
			{
				string fileName = "C:\\Users\\onset\\Downloads\\Nao_feitos.json";
				string text = System.IO.File.ReadAllText(fileName);
				JavaScriptSerializer jsonSerialiser = new JavaScriptSerializer();
				List<Dictionary<string, string>> json = jsonSerialiser.Deserialize<List<Dictionary<string, string>>>(text);
				using (List<Dictionary<string, string>>.Enumerator enumerator = json.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						Browser.<>c__DisplayClass62_0 CS$<>8__locals1 = new Browser.<>c__DisplayClass62_0();
						CS$<>8__locals1.item = enumerator.Current;
						List<Element> listElements = new List<Element>();
						this.source.SearchElements.ForEach(delegate(Element element)
						{
							element.Value = CS$<>8__locals1.item[element.Where];
							listElements.Add(new Element(element.Name, element.Where, element.Value, element.GoTo, element.IsHtml, element.Attribute));
						});
						this.searchElements.Add(listElements);
					}
				}
				result = true;
			}
			catch (Exception e)
			{
				result = false;
			}
			return result;
		}

		// Token: 0x06000392 RID: 914 RVA: 0x0000BD64 File Offset: 0x00009F64
		private bool special(ZionRobot.Models.Source.Action action)
		{
			bool result;
			try
			{
				using (StreamReader sr = new StreamReader("C:\\Users\\onset\\Downloads\\ADVISE_02.02.txt"))
				{
					string currentLine;
					while ((currentLine = sr.ReadLine()) != null)
					{
						bool flag = currentLine == "DIÁRIO\tPROCESSO\tPUBLICAÇÃO EM\tCOMARCA\tVARA\tDISPONIBILIZAÇÃO EM\tPALAVRA CHAVE\tCADERNO\tCONTRATANTE\tUSUÁRIO\tEDIÇÃO\tPÁGINA INICIAL\tPÁGINA FINAL\tDESPACHO\tCONTEUDO" || currentLine == string.Empty;
						if (!flag)
						{
							string[] array = currentLine.Split(new char[]
							{
								'\t'
							});
							List<Element> listElements = new List<Element>();
							this.source.SearchElements.ForEach(delegate(Element element)
							{
								bool flag2 = element.Where == "-1";
								if (flag2)
								{
									element.Value = "";
								}
								else
								{
									int index = int.Parse(element.Where);
									element.Value = element.Name + ": " + array[index];
								}
								listElements.Add(new Element(element.Name, element.Where, element.Value, element.GoTo, element.IsHtml, element.Attribute));
							});
							this.searchElements.Add(listElements);
						}
					}
				}
				result = true;
			}
			catch (Exception ex)
			{
				result = false;
			}
			return result;
		}

		// Token: 0x06000393 RID: 915 RVA: 0x0000BE48 File Offset: 0x0000A048
		private bool readResultsFromDownloadFile(ZionRobot.Models.Source.Action action)
		{
			return true;
		}

		// Token: 0x06000394 RID: 916 RVA: 0x0000BE5C File Offset: 0x0000A05C
		private bool appendFromApi(ZionRobot.Models.Source.Action action)
		{
			bool result2;
			try
			{
				string value = action.ReplaceWithDictionary(action.Where, this.DictionaryValues);
				string result = new Client(WSProperties.UrlApi)._request("GET", value, WSProperties.Token, null, string.Empty, null);
				JavaScriptSerializer jsonSerialiser = new JavaScriptSerializer();
				Dictionary<string, string> json = jsonSerialiser.Deserialize<Dictionary<string, string>>(result);
				json.ToList<KeyValuePair<string, string>>().ForEach(delegate(KeyValuePair<string, string> j)
				{
					this.dictionaryValues.Add(j.Key, j.Value);
				});
				result2 = true;
			}
			catch (Exception ex)
			{
				result2 = false;
			}
			return result2;
		}

		// Token: 0x06000395 RID: 917 RVA: 0x0000BEE8 File Offset: 0x0000A0E8
		private bool changeAttributeValue(ZionRobot.Models.Source.Action action)
		{
			IHTMLElement element = this.getHTMLElements(action.Where, null).FirstOrDefault<IHTMLElement>();
			bool flag = element == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				string[] parts = action.Value.Split("=".ToCharArray(), 2);
				element.setAttribute(parts[0], (parts.Length == 1) ? string.Empty : parts[1], 1);
				result = true;
			}
			return result;
		}

		// Token: 0x06000396 RID: 918 RVA: 0x0000BF50 File Offset: 0x0000A150
		private bool readJson(ZionRobot.Models.Source.Action action)
		{
			bool result2;
			try
			{
				using (WebClient wc = new WebClient
				{
					Encoding = Encoding.UTF8
				})
				{
					string result = this.ReplaceActionsValue(action);
					string json = wc.DownloadString(result);
					bool flag = string.IsNullOrEmpty(json);
					if (flag)
					{
						return false;
					}
					IntimacoesCollection IC = System.Text.Json.JsonSerializer.Deserialize<IntimacoesCollection>(json, new JsonSerializerOptions
					{
						PropertyNameCaseInsensitive = true
					});
					IC.Intimacoes.ForEach(delegate(Intimacao intimacao)
					{
						List<Element> listElements = new List<Element>();
						this.source.SearchElements.ForEach(delegate(Element element)
						{
							element.Value = ((element.Where.ToUpper() == "ALL") ? intimacao.GetParamAASP() : intimacao.GetParamValue(element.Where));
							listElements.Add(new Element(element.Name, element.Where, element.Value, element.GoTo, element.IsHtml, element.Attribute));
						});
						this.searchElements.Add(listElements);
					});
				}
				result2 = true;
			}
			catch (Exception ex)
			{
				result2 = false;
			}
			return result2;
		}

		// Token: 0x06000397 RID: 919 RVA: 0x0000BFF8 File Offset: 0x0000A1F8
		private bool invokeOnClick(ZionRobot.Models.Source.Action action)
		{
			IHTMLElement element = this.getHTMLElements(action.Where, null).FirstOrDefault<IHTMLElement>();
			return element != null;
		}

		// Token: 0x06000398 RID: 920 RVA: 0x0000C02C File Offset: 0x0000A22C
		private bool executeBLock(ZionRobot.Models.Source.Action action)
		{
			BlockElement block = (from b in this.source.BlockElements
			where b.Name == action.Value
			select b).FirstOrDefault<BlockElement>();
			bool flag = block != null;
			bool result;
			if (flag)
			{
				foreach (ZionRobot.Models.Source.Action a in block.Actions)
				{
					Task<bool> task = this.executeAction(a);
					task.Wait();
				}
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}

		// Token: 0x06000399 RID: 921 RVA: 0x0000C0D4 File Offset: 0x0000A2D4
		[DebuggerStepThrough]
		private Task<bool> navigate(ZionRobot.Models.Source.Action action)
		{
			Browser.<navigate>d__70 <navigate>d__ = new Browser.<navigate>d__70();
			<navigate>d__.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
			<navigate>d__.<>4__this = this;
			<navigate>d__.action = action;
			<navigate>d__.<>1__state = -1;
			<navigate>d__.<>t__builder.Start<Browser.<navigate>d__70>(ref <navigate>d__);
			return <navigate>d__.<>t__builder.Task;
		}

		// Token: 0x0600039A RID: 922 RVA: 0x0000C120 File Offset: 0x0000A320
		private bool readResultsFromPage(ZionRobot.Models.Source.Action action)
		{
			List<IHTMLElement> hElements = this.getHTMLElements(action.Where, null).ToList<IHTMLElement>();
			bool flag = hElements.Count == 0;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				hElements.ForEach(delegate(IHTMLElement hElement)
				{
					List<Element> listElements = new List<Element>();
					this.source.SearchElements.ForEach(delegate(Element element)
					{
						bool flag2 = string.IsNullOrEmpty(element.Attribute);
						if (flag2)
						{
							Browser <>4__this = this;
							string where = element.Where;
							if (Browser.<>o__71.<>p__0 == null)
							{
								Browser.<>o__71.<>p__0 = CallSite<Func<CallSite, object, IHTMLElementCollection>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(IHTMLElementCollection), typeof(Browser)));
							}
							IHTMLElement ihtmlelement = <>4__this.getHTMLElements(where, Browser.<>o__71.<>p__0.Target(Browser.<>o__71.<>p__0, hElement.all)).FirstOrDefault<IHTMLElement>();
							element.Value = (((ihtmlelement != null) ? ihtmlelement.innerText : null) ?? string.Empty);
						}
						else
						{
							if (Browser.<>o__71.<>p__1 == null)
							{
								Browser.<>o__71.<>p__1 = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(Browser)));
							}
							element.Value = Browser.<>o__71.<>p__1.Target(Browser.<>o__71.<>p__1, hElement.getAttribute(element.Attribute, 0));
						}
						element.Value = Regex.Replace(element.Value, "  Exibir comentários  Inserir comentários ", string.Empty);
						bool isHtml = element.IsHtml;
						if (isHtml)
						{
							HtmlDocument doc = new HtmlDocument();
							doc.LoadHtml(element.Value);
							element.Value = doc.DocumentNode.InnerText;
						}
						listElements.Add(new Element(element.Name, element.Where, element.Value, element.GoTo, element.IsHtml, element.Attribute));
					});
					this.searchElements.Add(listElements);
				});
				result = true;
			}
			return result;
		}

		// Token: 0x0600039B RID: 923 RVA: 0x0000C16C File Offset: 0x0000A36C
		private bool invoke(ZionRobot.Models.Source.Action action)
		{
			bool flag = action.Where != null;
			if (flag)
			{
				IHTMLElement element = this.getHTMLElements(action.Where.Replace("@", ""), null).FirstOrDefault<IHTMLElement>();
				bool flag2 = element != null;
				if (flag2)
				{
					if (Browser.<>o__72.<>p__0 == null)
					{
						Browser.<>o__72.<>p__0 = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(string), typeof(Browser)));
					}
					string[] parts = Browser.<>o__72.<>p__0.Target(Browser.<>o__72.<>p__0, element.getAttribute("href", 0)).Split(new char[]
					{
						'('
					});
					string scriptName = parts[0].Replace("javascript:", string.Empty);
					string[] args = parts[1].Trim(new char[]
					{
						')'
					}).Replace("'", string.Empty).Split(new char[]
					{
						','
					});
					IHTMLElement elementTemp = string.IsNullOrEmpty(action.Check) ? null : this.getHTMLElements(action.Check, null).First<IHTMLElement>();
					this.browser.Dispatcher.Invoke(delegate()
					{
						WebBrowser webBrowser = this.browser;
						string scriptName = scriptName;
						object[] args = args;
						webBrowser.InvokeScript(scriptName, args);
					});
					bool flag3 = elementTemp != null;
					if (flag3)
					{
						while (CQuery.CompareInnerHtmlByElements(elementTemp, this.getHTMLElements(action.Check, null).First<IHTMLElement>()))
						{
							Thread.Sleep(200);
						}
						return true;
					}
					return true;
				}
			}
			bool flag4 = action.Value != null;
			if (flag4)
			{
				bool flag5 = Regex.IsMatch(action.Value, "javascript");
				if (flag5)
				{
					string[] parts2 = action.Value.Split(new char[]
					{
						'('
					});
					string scriptName = parts2[0].Trim().Replace("javascript:", string.Empty).Trim();
					string[] args = parts2[1].Trim(new char[]
					{
						')'
					}).Replace("'", string.Empty).Split(new char[]
					{
						','
					});
					IHTMLElement elementTemp2 = string.IsNullOrEmpty(action.Check) ? null : this.getHTMLElements(action.Check, null).First<IHTMLElement>();
					this.browser.Dispatcher.Invoke(delegate()
					{
						WebBrowser webBrowser = this.browser;
						string scriptName = scriptName;
						object[] args = args;
						webBrowser.InvokeScript(scriptName, args);
					});
					bool flag6 = elementTemp2 != null;
					if (flag6)
					{
						while (CQuery.CompareInnerHtmlByElements(elementTemp2, this.getHTMLElements(action.Check, null).First<IHTMLElement>()))
						{
							Thread.Sleep(200);
						}
						return true;
					}
					return true;
				}
			}
			return false;
		}

		// Token: 0x0600039C RID: 924 RVA: 0x0000C444 File Offset: 0x0000A644
		private bool fillInput(ZionRobot.Models.Source.Action action)
		{
			List<IHTMLElement> elements = this.getHTMLElements(action.Where, null);
			bool flag = elements.Count > 0;
			bool result;
			if (flag)
			{
				elements.ForEach(delegate(IHTMLElement element)
				{
					element.setAttribute("value", this.ReplaceActionsValue(action), 1);
				});
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}

		// Token: 0x0600039D RID: 925 RVA: 0x0000C4A4 File Offset: 0x0000A6A4
		private bool checkInput(ZionRobot.Models.Source.Action action)
		{
			IHTMLElement element = this.getHTMLElements(action.Where, null).FirstOrDefault<IHTMLElement>();
			bool flag = element == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				string value = this.ReplaceActionsValue(action);
				string text = value.ToUpper();
				string a = text;
				if (!(a == "0") && !(a == "NÃO"))
				{
					if (!(a == "1") && !(a == "SIM") && !(a == "TRUE"))
					{
						value = "False";
					}
					else
					{
						value = "True";
					}
				}
				else
				{
					value = "False";
				}
				bool x = bool.Parse(value);
				(element as HTMLInputElement).@checked = bool.Parse(value);
				result = true;
			}
			return result;
		}

		// Token: 0x0600039E RID: 926 RVA: 0x0000C56C File Offset: 0x0000A76C
		private bool selectOption(ZionRobot.Models.Source.Action action)
		{
			string value = action.ReplaceWithDictionary(action.Where, this.DictionaryValues);
			IHTMLElement element = this.getHTMLElements(value, null).FirstOrDefault<IHTMLElement>();
			bool flag = element != null;
			bool result;
			if (flag)
			{
				element.setAttribute("selected", "Selected", 1);
				result = true;
			}
			else
			{
				result = false;
			}
			return result;
		}

		// Token: 0x0600039F RID: 927 RVA: 0x0000C5C0 File Offset: 0x0000A7C0
		[DebuggerStepThrough]
		private Task<bool> clickButton(ZionRobot.Models.Source.Action action)
		{
			Browser.<clickButton>d__76 <clickButton>d__ = new Browser.<clickButton>d__76();
			<clickButton>d__.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
			<clickButton>d__.<>4__this = this;
			<clickButton>d__.action = action;
			<clickButton>d__.<>1__state = -1;
			<clickButton>d__.<>t__builder.Start<Browser.<clickButton>d__76>(ref <clickButton>d__);
			return <clickButton>d__.<>t__builder.Task;
		}

		// Token: 0x060003A0 RID: 928 RVA: 0x0000C60C File Offset: 0x0000A80C
		private bool executeIf(ZionRobot.Models.Source.Action action)
		{
			string @operator = (from Match match in Regex.Matches(action.Value, "([!=_<>]{1,2}=?)|\\d+")
			select match.Value).First<string>();
			string[] parts = action.Value.Split(new string[]
			{
				@operator
			}, StringSplitOptions.RemoveEmptyEntries);
			string value = string.Empty;
			bool flag = parts.Count<string>() > 0;
			if (flag)
			{
				value = action.ReplaceWithDictionary(parts[0], this.DictionaryValues);
				value = value.Replace(@operator, string.Empty);
			}
			IHTMLElement element = this.getHTMLElements(action.Where, null).FirstOrDefault<IHTMLElement>();
			bool flag2 = element != null;
			if (flag2)
			{
				string fa = element.innerText;
				bool x = fa == value;
				int y = parts.Count<string>();
				bool flag3 = @operator == "=_=" || (@operator == "==" && element.innerText == value) || (@operator == "==" && parts.Count<string>() > 1 && action.ReplaceWithDictionary(parts[0], this.DictionaryValues) == action.ReplaceWithDictionary(parts[1], this.DictionaryValues)) || (@operator == "===" && Regex.IsMatch(element.innerText, value)) || (@operator == "!=" && element.innerText != value) || (@operator == "!==" && !Regex.IsMatch(element.innerText, value));
				if (flag3)
				{
					action.ResultTrue.ForEach(delegate(ZionRobot.Models.Source.Action a)
					{
						this.executeAction(a).Wait();
					});
					return true;
				}
				bool flag4 = action.ResultFalse.Count > 0;
				if (flag4)
				{
					Console.WriteLine("ELLSEEEEEEE");
					action.ResultFalse.ForEach(delegate(ZionRobot.Models.Source.Action a)
					{
						this.executeAction(a).Wait();
					});
					return true;
				}
			}
			return false;
		}

		// Token: 0x060003A1 RID: 929 RVA: 0x0000C80C File Offset: 0x0000AA0C
		[DebuggerStepThrough]
		private Task<bool> loopWithOperator(ZionRobot.Models.Source.Action action)
		{
			Browser.<loopWithOperator>d__78 <loopWithOperator>d__ = new Browser.<loopWithOperator>d__78();
			<loopWithOperator>d__.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
			<loopWithOperator>d__.<>4__this = this;
			<loopWithOperator>d__.action = action;
			<loopWithOperator>d__.<>1__state = -1;
			<loopWithOperator>d__.<>t__builder.Start<Browser.<loopWithOperator>d__78>(ref <loopWithOperator>d__);
			return <loopWithOperator>d__.<>t__builder.Task;
		}

		// Token: 0x060003A2 RID: 930 RVA: 0x0000C858 File Offset: 0x0000AA58
		[DebuggerStepThrough]
		private Task<bool> loopWithBoolean(ZionRobot.Models.Source.Action action)
		{
			Browser.<loopWithBoolean>d__79 <loopWithBoolean>d__ = new Browser.<loopWithBoolean>d__79();
			<loopWithBoolean>d__.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
			<loopWithBoolean>d__.<>4__this = this;
			<loopWithBoolean>d__.action = action;
			<loopWithBoolean>d__.<>1__state = -1;
			<loopWithBoolean>d__.<>t__builder.Start<Browser.<loopWithBoolean>d__79>(ref <loopWithBoolean>d__);
			return <loopWithBoolean>d__.<>t__builder.Task;
		}

		// Token: 0x060003A3 RID: 931 RVA: 0x0000C8A4 File Offset: 0x0000AAA4
		private bool checkDomain(ZionRobot.Models.Source.Action action)
		{
			HTMLDocument doc = null;
			string domain = null;
			this.browser.Dispatcher.Invoke(delegate()
			{
				doc = (HTMLDocument)this.browser.Document;
				bool flag2 = doc != null;
				if (flag2)
				{
					domain = doc.domain;
				}
			});
			bool flag = domain == null || domain == string.Empty || domain != this.source.Domain;
			bool result;
			if (flag)
			{
				action.ResultTrue.ForEach(delegate(ZionRobot.Models.Source.Action a)
				{
					this.executeAction(a).Wait();
				});
				result = true;
			}
			else
			{
				result = true;
			}
			return result;
		}

		// Token: 0x060003A4 RID: 932 RVA: 0x0000C944 File Offset: 0x0000AB44
		[DebuggerStepThrough]
		private Task<bool> goBack(ZionRobot.Models.Source.Action action)
		{
			Browser.<goBack>d__81 <goBack>d__ = new Browser.<goBack>d__81();
			<goBack>d__.<>t__builder = AsyncTaskMethodBuilder<bool>.Create();
			<goBack>d__.<>4__this = this;
			<goBack>d__.action = action;
			<goBack>d__.<>1__state = -1;
			<goBack>d__.<>t__builder.Start<Browser.<goBack>d__81>(ref <goBack>d__);
			return <goBack>d__.<>t__builder.Task;
		}

		// Token: 0x060003A5 RID: 933 RVA: 0x0000C990 File Offset: 0x0000AB90
		private bool appendData(ZionRobot.Models.Source.Action action)
		{
			string actionWhere = action.ReplaceWithDictionary(action.Where, this.DictionaryValues);
			bool flag = actionWhere == "currentUrl";
			bool result;
			if (flag)
			{
				this.DictionaryValues.Add(action.Value, this.getUrl());
				result = true;
			}
			else
			{
				IHTMLElement ihtmlelement;
				if (action.Regex == null)
				{
					ihtmlelement = this.getHTMLElements(actionWhere, null).FirstOrDefault<IHTMLElement>();
				}
				else
				{
					ihtmlelement = (from e in this.getHTMLElements(actionWhere, null)
					where e.innerText != null && Regex.IsMatch(e.innerText, action.Regex)
					select e).FirstOrDefault<IHTMLElement>();
				}
				IHTMLElement element = ihtmlelement;
				bool flag2 = element != null;
				if (flag2)
				{
					bool flag3 = this.DictionaryValues.FirstOrDefault((KeyValuePair<string, string> x) => x.Key == action.Value).Key != null;
					if (flag3)
					{
						this.DictionaryValues.Remove(action.Value);
					}
					bool flag4 = action.Attribute != null;
					if (flag4)
					{
						if (Browser.<>o__82.<>p__0 == null)
						{
							Browser.<>o__82.<>p__0 = CallSite<Func<CallSite, object, string>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(string), typeof(Browser)));
						}
						string a = Browser.<>o__82.<>p__0.Target(Browser.<>o__82.<>p__0, element.getAttribute(action.Attribute, 0));
						this.DictionaryValues.Add(action.Value, a);
					}
					else
					{
						this.DictionaryValues.Add(action.Value, element.innerText);
					}
					result = true;
				}
				else
				{
					result = false;
				}
			}
			return result;
		}

		// Token: 0x060003A6 RID: 934 RVA: 0x0000CB5C File Offset: 0x0000AD5C
		private bool saveIntegrationLog(ZionRobot.Models.Source.Action action)
		{
			string value = this.ReplaceActionsValue(action);
			System.IO.File.AppendAllText(Basic.LogsFolder + "IntegrationLog.csv", string.Format("{0}{1}\n", DateTime.Now, value));
			return true;
		}

		// Token: 0x060003A7 RID: 935 RVA: 0x0000CBA4 File Offset: 0x0000ADA4
		private string getUrl()
		{
			string url = string.Empty;
			this.browser.Dispatcher.Invoke(delegate()
			{
				url = this.browser.Source.AbsoluteUri;
			});
			return url;
		}

		// Token: 0x060003A8 RID: 936 RVA: 0x0000CBF4 File Offset: 0x0000ADF4
		private HTMLDocument GetHTMLDocument()
		{
			HTMLDocument doc = null;
			this.browser.Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(delegate()
			{
				doc = (HTMLDocument)this.browser.Document;
			}));
			return doc;
		}

		// Token: 0x060003A9 RID: 937 RVA: 0x0000CC40 File Offset: 0x0000AE40
		private bool hasLog(string text)
		{
			foreach (string r in Logs.SearchLog.SearchResults)
			{
				foreach (string v in r.Split(new string[]
				{
					"||"
				}, StringSplitOptions.None).ToList<string>())
				{
					string ab = text.Replace(Environment.NewLine, "");
					bool flag = v == ab;
					if (flag)
					{
						return true;
					}
					bool flag2 = v == text;
					if (flag2)
					{
						return true;
					}
				}
			}
			return false;
		}

		// Token: 0x060003AA RID: 938 RVA: 0x0000CD30 File Offset: 0x0000AF30
		private string ReplaceActionsValue(ZionRobot.Models.Source.Action action)
		{
			string value = string.Empty;
			List<string> parts = (from Match m in Regex.Matches(action.Value, "\\{[^\\}]*\\}|([:=\\[\\(\\{]{0}[a-zA-Z0-9_%@\\-\\.\\/:?=&;]{1,})")
			select m.Value).ToList<string>();
			parts.ForEach(delegate(string part)
			{
				string temp = part.Trim(new char[]
				{
					'{'
				}).Trim(new char[]
				{
					'}'
				});
				string add = string.Empty;
				bool flag2 = Regex.IsMatch(temp, "\\$_Now");
				if (flag2)
				{
					DateTime dateNow = DateTime.Now;
					int day = 0;
					string[] p = temp.Split(new char[]
					{
						'?'
					});
					bool flag3 = p.Count<string>() == 1;
					if (flag3)
					{
						bool flag4 = Regex.IsMatch(p[0], "\\.");
						if (flag4)
						{
							day = int.Parse(temp.Split(new char[]
							{
								'.'
							}).Last<string>());
						}
					}
					else
					{
						string @operator = (from Match match in Regex.Matches(p[0], "([!=<>]{1,2}[<>=]?)")
						select match.Value).First<string>();
						string[] s = p[0].Split(new string[]
						{
							@operator
						}, StringSplitOptions.RemoveEmptyEntries);
						int hours = int.Parse(s[1]);
						string[] days = p[1].Split(new char[]
						{
							':'
						});
						bool flag5 = (@operator == "==" && dateNow.Hour == hours) || (@operator == "!=" && dateNow.Hour != hours) || (@operator == "<=" && dateNow.Hour <= hours) || (@operator == ">=" && dateNow.Hour >= hours) || (@operator == ">" && dateNow.Hour > hours) || (@operator == "<" && dateNow.Hour < hours);
						if (flag5)
						{
							day = int.Parse(days[0]);
						}
						else
						{
							day = int.Parse(days[1]);
						}
					}
					add = ((day == 0) ? dateNow.ToString("dd/MM/yyyy") : this.getBusinessDay(DateTime.Now, day).ToString("dd/MM/yyyy"));
				}
				bool flag6 = this.DictionaryValues.ContainsKey(temp);
				if (flag6)
				{
					bool flag7 = string.IsNullOrEmpty(this.DictionaryValues[temp]);
					if (flag7)
					{
						part = string.Empty;
					}
					else
					{
						add += this.DictionaryValues[temp];
					}
				}
				bool flag8 = add != string.Empty;
				if (flag8)
				{
					value += add;
				}
				else
				{
					value += Regex.Replace(part, "amp;", string.Empty);
				}
			});
			bool flag = !string.IsNullOrEmpty(action.Replace);
			if (flag)
			{
				List<string> replaces = action.Replace.Split(new char[]
				{
					';'
				}).ToList<string>();
				replaces.ForEach(delegate(string replace)
				{
					string[] r = replace.Split(new char[]
					{
						','
					});
					value = Regex.Replace(value, r[0], r[1]);
				});
			}
			string a = value.Substring(0, Math.Min(value.Length, action.MaxLength));
			return (action.MaxLength > 0) ? value.Substring(0, Math.Min(value.Length, action.MaxLength)) : value;
		}

		// Token: 0x060003AB RID: 939 RVA: 0x0000CE4C File Offset: 0x0000B04C
		private DateTime getBusinessDay(DateTime dateTime, int day)
		{
			DateTime currentDay = dateTime;
			bool flag = day >= 0;
			if (flag)
			{
				List<DateTime> dates = Shift.getDaysWithInterval(currentDay, 30, true);
				currentDay = dates[day];
			}
			else
			{
				int count = 0;
				while (count > day)
				{
					currentDay = currentDay.AddDays(-1.0);
					bool flag2 = Shift.isDuringTheWeek(currentDay);
					if (flag2)
					{
						count--;
					}
				}
			}
			return currentDay;
		}

		// Token: 0x04000174 RID: 372
		private static Browser instance;

		// Token: 0x04000175 RID: 373
		private WebBrowser browser;

		// Token: 0x04000176 RID: 374
		private bool wait = false;

		// Token: 0x04000177 RID: 375
		private Thread main;

		// Token: 0x04000178 RID: 376
		private bool terminate = false;

		// Token: 0x04000179 RID: 377
		private Origin source;

		// Token: 0x0400017A RID: 378
		private Dictionary<string, string> dictionaryValues;

		// Token: 0x0400017B RID: 379
		private List<List<Element>> searchElements;

		// Token: 0x0400017C RID: 380
		public Activity Activity;
	}
}
