E:\TrabalhoSuely\RoboDescompilado\Redistribuir_Suely_2023_02_16\ZionRobot\Tasks\JobManager.cs E:\TrabalhoSuely\RoboDescompilado\Sincronizar_Mauro_2022_06_01\ZionRobot\Tasks\JobManager.cs
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using ZionFoundation.Threading; using ZionFoundation.Threading;
using ZionRobot.Models.Items; using ZionRobot.Models.Items;
using ZionRobot.Models.Process; using ZionRobot.Models.Process;
using ZionRobot.Models.Source; using ZionRobot.Models.Source;
using ZionRobot.Models.ZFlow; using ZionRobot.Models.ZFlow;
using ZionRobot.Persistence; using ZionRobot.Persistence;
using ZionRobot.WebService; using ZionRobot.WebService;
using ZionVault.Binder.Output; using ZionVault.Binder.Output;
   
namespace ZionRobot.Tasks namespace ZionRobot.Tasks
{ {
    // Token: 0x02000020 RID: 32     // Token: 0x0200001F RID: 31
    internal class JobManager : ZionFoundation.Threading.Thread     internal class JobManager : ZionFoundation.Threading.Thread
    {     {
        // Token: 0x1700002F RID: 47         // Token: 0x1700002F RID: 47
        // (get) Token: 0x060000B2 RID: 178 RVA: 0x00006293 File Offset: 0x00004493         // (get) Token: 0x060000AD RID: 173 RVA: 0x00005EC7 File Offset: 0x000040C7
        // (set) Token: 0x060000B3 RID: 179 RVA: 0x0000629B File Offset: 0x0000449B         // (set) Token: 0x060000AE RID: 174 RVA: 0x00005ECF File Offset: 0x000040CF
        internal Workflow Workflow         internal Workflow Workflow
        {         {
            get             get
            {             {
                return this.workflow;                 return this.workflow;
            }             }
            set             set
            {             {
                this.workflow = value;                 this.workflow = value;
            }             }
        }         }
   
        // Token: 0x060000B4 RID: 180 RVA: 0x000062A4 File Offset: 0x000044A4         // Token: 0x060000AF RID: 175 RVA: 0x00005ED8 File Offset: 0x000040D8
        public JobManager(Workflow workflow, bool execute = true)         public JobManager(Workflow workflow, bool execute = true)
        {         {
            this.workflow = workflow;             this.workflow = workflow;
            this.interval = 60000;             this.interval = 60000;
            this.TInput = new Input();             this.TInput = new Input();
            this.TExtractor = new Extractor();             this.TExtractor = new Extractor();
            this.TOutput = new Output();             this.TOutput = new Output();
            this.TSynchronizer = new Synchronizer();             this.TSynchronizer = new Synchronizer();
            this.workflow.Folders.Add(new Folder(Basic.SearchResultFolder, true));             this.workflow.Folders.Add(new Folder(Basic.SearchResultFolder, true));
            base.Initilize(execute);             base.Initilize(execute);
            this.workflow.Queue.Start();             this.workflow.Queue.Start();
        }         }
   
        // Token: 0x060000B5 RID: 181 RVA: 0x00006338 File Offset: 0x00004538         // Token: 0x060000B0 RID: 176 RVA: 0x00005F6C File Offset: 0x0000416C
        public override void Execute()         public override void Execute()
        {         {
            bool flag = !this.tasksIsAlive();             bool flag = !this.tasksIsAlive();
            if (flag)             if (flag)
            {             {
                bool flag2 = this.sync == "Local";                 bool flag2 = this.sync == "Local";
                if (flag2)                 if (flag2)
                {                 {
                    string rootPath = "C:\\Temp\\html\\";                     string rootPath = "C:\\Temp\\html\\";
                    Origin source = this.workflow.SyncConfigurations[0];                     Origin source = this.workflow.SyncConfigurations[0];
                    Directory.GetFiles(rootPath + "andamentos", "*.json").ToList<string>().ForEach(delegate(string file)                     Directory.GetFiles(rootPath + "andamentos", "*.json").ToList<string>().ForEach(delegate(string file)
                    {                     {
                        string fileName = Path.GetFileName(file);                         string fileName = Path.GetFileName(file);
                        this.TSynchronizer.SyncFromLocal(source, file, "Andamentos");                         this.TSynchronizer.SyncFromLocal(source, file, "Andamentos");
                        while (this.TSynchronizer.Running)                         while (this.TSynchronizer.Running)
                        {                         {
                            System.Threading.Thread.Sleep(2000);                             System.Threading.Thread.Sleep(2000);
                        }                         }
                        System.IO.File.Move(file, rootPath + "sincronizados\\andamentos\\" + fileName);                         System.IO.File.Move(file, rootPath + "sincronizados\\andamentos\\" + fileName);
                    });                     });
                }                 }
                bool flag3 = this.sync == "Demo";                 bool flag3 = this.sync == "Demo";
                if (flag3)                 if (flag3)
                {                 {
                    this.workflow.OutputConfigurations.ForEach(delegate(Origin source)                     this.workflow.OutputConfigurations.ForEach(delegate(Origin source)
                    {                     {
                        this.TOutput.Execute(source);                         this.TOutput.Execute(source);
                        while (this.TOutput.Running)                         while (this.TOutput.Running)
                        {                         {
                            System.Threading.Thread.Sleep(2000);                             System.Threading.Thread.Sleep(2000);
                        }                         }
                    });                     });
                }                 }
                bool flag4 = this.sync == "Publications";                 bool flag4 = this.sync == "Publications";
                if (flag4)                 if (flag4)
                {                 {
                    this.workflow.InputConfigurations.ForEach(delegate(Origin source)                     this.workflow.InputConfigurations.ForEach(delegate(Origin source)
                    {                     {
                        this.TInput.Execute(source);                         this.TInput.Execute(source);
                        while (this.TInput.Running)                         while (this.TInput.Running)
                        {                         {
                            System.Threading.Thread.Sleep(2000);                             System.Threading.Thread.Sleep(2000);
                        }                         }
                    });                     });
                    List<ZionRobot.Models.Items.File> filesExtraction = this.workflow.Queues.Extraction;                     List<ZionRobot.Models.Items.File> filesExtraction = this.workflow.Queues.Extraction;
                    bool flag5 = filesExtraction.Count > 0;                     bool flag5 = filesExtraction.Count > 0;
                    if (flag5)                     if (flag5)
                    {                     {
                        filesExtraction.ForEach(delegate(ZionRobot.Models.Items.File file)                         filesExtraction.ForEach(delegate(ZionRobot.Models.Items.File file)
                        {                         {
                            this.TExtractor.Execute(file, this.workflow.Blueprints);                             this.TExtractor.Execute(file, this.workflow.Blueprints);
                        });                         });
                        filesExtraction.Clear();                         filesExtraction.Clear();
                    }                     }
                    List<ZionRobot.Models.Items.File> filesIntegration = new List<ZionRobot.Models.Items.File>();                     List<ZionRobot.Models.Items.File> filesIntegration = new List<ZionRobot.Models.Items.File>();
                    using (List<ZionRobot.Models.Items.File>.Enumerator enumerator = this.workflow.Queues.Integration.GetEnumerator())                     using (List<ZionRobot.Models.Items.File>.Enumerator enumerator = this.workflow.Queues.Integration.GetEnumerator())
                    {                     {
                        while (enumerator.MoveNext())                         while (enumerator.MoveNext())
                        {                         {
                            ZionRobot.Models.Items.File file = enumerator.Current;                             ZionRobot.Models.Items.File file = enumerator.Current;
                            bool flag6 = string.IsNullOrEmpty(file.LawsuitNumber);                             bool flag6 = string.IsNullOrEmpty(file.LawsuitNumber);
                            if (flag6)                             if (flag6)
                            {                             {
                                filesIntegration.Add(file);                                 filesIntegration.Add(file);
                            }                             }
                            else                             else
                            {                             {
                                ZionRobot.Models.Items.File fi = (from f in filesIntegration                                 ZionRobot.Models.Items.File fi = (from f in filesIntegration
                                where f.LawsuitNumber == file.LawsuitNumber                                 where f.LawsuitNumber == file.LawsuitNumber
                                select f).FirstOrDefault<ZionRobot.Models.Items.File>();                                 select f).FirstOrDefault<ZionRobot.Models.Items.File>();
                                bool flag7 = fi != null;                                 bool flag7 = fi != null;
                                if (flag7)                                 if (flag7)
                                {                                 {
                                    Action<ZionVault.Binder.Output.Field> <>9__7;                                     Action<ZionVault.Binder.Output.Field> <>9__7;
                                    fi.METAObject.Pages.ForEach(delegate(Page page)                                     fi.METAObject.Pages.ForEach(delegate(Page page)
                                    {                                     {
                                        List<ZionVault.Binder.Output.Field> list = page.SearchElements.ToList<ZionVault.Binder.Output.Field>();                                         List<ZionVault.Binder.Output.Field> list = page.SearchElements.ToList<ZionVault.Binder.Output.Field>();
                                        Action<ZionVault.Binder.Output.Field> action;                                         Action<ZionVault.Binder.Output.Field> action;
                                        if ((action = <>9__7) == null)                                         if ((action = <>9__7) == null)
                                        {                                         {
                                            action = (<>9__7 = delegate(ZionVault.Binder.Output.Field element)                                             action = (<>9__7 = delegate(ZionVault.Binder.Output.Field element)
                                            {                                             {
.                                                bool flag13 = element.Name == "ConteudoCompleto";                                                 bool flag16 = element.Name == "ConteudoCompleto";
                                                if (flag13)                                                 if (flag16)
                                                {                                                 {
                                                    element.Value = string.Format("{0}<hr>{1}", element.Value, file.PublicationContent);                                                     element.Value = string.Format("{0}<hr>{1}", element.Value, file.PublicationContent);
                                                }                                                 }
                                            });                                             });
                                        }                                         }
                                        list.ForEach(action);                                         list.ForEach(action);
                                    });                                     });
                                    fi.METAObject.Save(fi.META, false, false);                                     fi.METAObject.Save(fi.META, false, false);
                                    file.METAObject.Status = "GROUPED";                                     file.METAObject.Status = "GROUPED";
                                    file.METAObject.Save(file.META, false, false);                                     file.METAObject.Save(file.META, false, false);
                                    file.Status = "INTEGRATED";                                     file.Status = "INTEGRATED";
                                }                                 }
                                else                                 else
                                {                                 {
                                    filesIntegration.Add(file);                                     filesIntegration.Add(file);
                                }                                 }
                            }                             }
                        }                         }
                    }                     }
                    bool flag8 = filesIntegration.Count > 0;                     bool flag8 = filesIntegration.Count > 0;
                    if (flag8)                     if (flag8)
                    {                     {
                        this.workflow.OutputConfigurations.ForEach(delegate(Origin source)                         this.workflow.OutputConfigurations.ForEach(delegate(Origin source)
                        {                         {
                            filesIntegration.ForEach(delegate(ZionRobot.Models.Items.File file)                             filesIntegration.ForEach(delegate(ZionRobot.Models.Items.File file)
                            {                             {
                                this.TOutput.Execute(source, file);                                 this.TOutput.Execute(source, file);
                                while (this.TOutput.Running)                                 while (this.TOutput.Running)
                                {                                 {
                                    System.Threading.Thread.Sleep(2000);                                     System.Threading.Thread.Sleep(2000);
                                }                                 }
                            });                             });
                        });                         });
                    }                     }
                }                 }
                bool flag9 = this.sync == "Lawsuits";                 bool flag9 = this.sync == "Lawsuits";
                if (flag9)                 if (flag9)
                {                 {
                    List<ZionRobot.Models.ZFlow.Lawsuit> lawsuitsToSync = new ZionRobot.WebService.Lawsuit().LawsuitsToSync();                     List<ZionRobot.Models.ZFlow.Lawsuit> lawsuitsToSync = new ZionRobot.WebService.Lawsuit().LawsuitsToSync();
                    bool flag10 = lawsuitsToSync.Count > 0;                     bool flag10 = lawsuitsToSync.Count > 0;
                    if (flag10)                     if (flag10)
                    {                     {
                        this.workflow.SyncConfigurations.ForEach(delegate(Origin source)                         this.workflow.SyncConfigurations.ForEach(delegate(Origin source)
                        {                         {
.                            int i = 1;  
                            lawsuitsToSync.ForEach(delegate(ZionRobot.Models.ZFlow.Lawsuit lawsuit)                             lawsuitsToSync.ForEach(delegate(ZionRobot.Models.ZFlow.Lawsuit lawsuit)
                            {                             {
                                this.TSynchronizer.Execute(source, lawsuit);                                 this.TSynchronizer.Execute(source, lawsuit);
                                while (this.TSynchronizer.Running)                                 while (this.TSynchronizer.Running)
                                {                                 {
                                    System.Threading.Thread.Sleep(2000);                                     System.Threading.Thread.Sleep(2000);
                                }                                 }
.                                int i = i;                             });
                                i++;                         });
                      } 
                      List<ZionRobot.Models.ZFlow.LawsuitPhase> lawsuitPhasesToSync = new ZionRobot.WebService.LawsuitPhase().LawsuitPhasesToSync(); 
                      bool flag11 = lawsuitPhasesToSync.Count > 0; 
                      if (flag11) 
                      { 
                          this.workflow.SyncConfigurations.ForEach(delegate(Origin source) 
                          { 
                              List<ZionRobot.Models.ZFlow.LawsuitPhase> x = (from l in lawsuitPhasesToSync 
                              where l.SyncAction == "Create" 
                              select l).ToList<ZionRobot.Models.ZFlow.LawsuitPhase>(); 
                              x.ForEach(delegate(ZionRobot.Models.ZFlow.LawsuitPhase lawsuitPhase) 
                              { 
                                  bool flag16 = lawsuitPhase.SyncAction == "Create"; 
                                  if (flag16) 
                                  { 
                                      this.TSynchronizer.Execute(source, lawsuitPhase); 
                                      while (this.TSynchronizer.Running) 
                                      { 
                                          System.Threading.Thread.Sleep(2000); 
                                      } 
                                  } 
                              }); 
                          }); 
                      } 
                      List<ZionRobot.Models.ZFlow.LawsuitPhaseProgress> lawsuitPhaseProgressToSync = new ZionRobot.WebService.LawsuitPhaseProgress().LawsuitPhaseProgressToSync(); 
                      bool flag12 = lawsuitPhaseProgressToSync.Count > 0; 
                      if (flag12) 
                      { 
                          this.workflow.SyncConfigurations.ForEach(delegate(Origin source) 
                          { 
                              List<ZionRobot.Models.ZFlow.LawsuitPhaseProgress> x = (from l in lawsuitPhaseProgressToSync 
                              where l.SyncAction == "Create" 
                              select l).ToList<ZionRobot.Models.ZFlow.LawsuitPhaseProgress>(); 
                              x.ForEach(delegate(ZionRobot.Models.ZFlow.LawsuitPhaseProgress lawsuitPhaseProgress) 
                              { 
                                  bool flag16 = lawsuitPhaseProgress.SyncAction == "Create"; 
                                  if (flag16) 
                                  { 
                                      this.TSynchronizer.Execute(source, lawsuitPhaseProgress); 
                                      while (this.TSynchronizer.Running) 
                                      { 
                                          System.Threading.Thread.Sleep(2000); 
                                      } 
                                  } 
                              }); 
                          }); 
                      } 
                      List<ZionRobot.Models.ZFlow.LawsuitDemand> lawsuitDemandsToSync = new ZionRobot.WebService.LawsuitDemand().LawsuitDemandsToSync(); 
                      bool flag13 = lawsuitDemandsToSync.Count > 0; 
                      if (flag13) 
                      { 
                          this.workflow.SyncConfigurations.ForEach(delegate(Origin source) 
                          { 
                              List<ZionRobot.Models.ZFlow.LawsuitDemand> x = (from l in lawsuitDemandsToSync 
                              where l.SyncAction == "Create" 
                              select l).ToList<ZionRobot.Models.ZFlow.LawsuitDemand>(); 
                              x.ForEach(delegate(ZionRobot.Models.ZFlow.LawsuitDemand lawsuitDemand) 
                              { 
                                  bool flag16 = lawsuitDemand.SyncAction == "Create"; 
                                  if (flag16) 
                                  { 
                                      this.TSynchronizer.Execute(source, lawsuitDemand); 
                                      while (this.TSynchronizer.Running) 
                                      { 
                                          System.Threading.Thread.Sleep(2000); 
                                      } 
                                  } 
                            });                             });
                        });                         });
                    }                     }
                }                 }
.                bool flag11 = this.sync == "Activities";                 bool flag14 = this.sync == "Activities";
                if (flag11)                 if (flag14)
                {                 {
                    List<ZionRobot.Models.ZFlow.Activity> activitiesToSync = new ZionRobot.WebService.Activity().ActivityToSync();                     List<ZionRobot.Models.ZFlow.Activity> activitiesToSync = new ZionRobot.WebService.Activity().ActivityToSync();
.                    bool flag12 = activitiesToSync.Count > 0;                     bool flag15 = activitiesToSync.Count > 0;
                    if (flag12)                     if (flag15)
                    {                     {
                        this.workflow.SyncConfigurations.ForEach(delegate(Origin source)                         this.workflow.SyncConfigurations.ForEach(delegate(Origin source)
                        {                         {
                            activitiesToSync.ForEach(delegate(ZionRobot.Models.ZFlow.Activity activity)                             activitiesToSync.ForEach(delegate(ZionRobot.Models.ZFlow.Activity activity)
                            {                             {
.                                  this.TSynchronizer.Execute(source, activity);
                                  while (this.TSynchronizer.Running)
                                  {
                                      System.Threading.Thread.Sleep(2000);
                                  }
                            });                             });
.                            this.TSynchronizer.Execute(source, activitiesToSync[0]);  
                            while (this.TSynchronizer.Running)  
                            {  
                                System.Threading.Thread.Sleep(2000);  
                            }  
                        });                         });
                    }                     }
                }                 }
            }             }
        }         }
   
        // Token: 0x060000B6 RID: 182 RVA: 0x0000670C File Offset: 0x0000490C         // Token: 0x060000B1 RID: 177 RVA: 0x00006414 File Offset: 0x00004614
        private bool tasksIsAlive()         private bool tasksIsAlive()
        {         {
            return this.TInput.Running || this.TExtractor.Running || this.TOutput.Running || this.TSynchronizer.Running;             return this.TInput.Running || this.TExtractor.Running || this.TOutput.Running || this.TSynchronizer.Running;
        }         }
   
        // Token: 0x04000040 RID: 64         // Token: 0x0400003A RID: 58
        private Workflow workflow;         private Workflow workflow;
   
        // Token: 0x04000041 RID: 65         // Token: 0x0400003B RID: 59
        private Input TInput;         private Input TInput;
   
        // Token: 0x04000042 RID: 66         // Token: 0x0400003C RID: 60
        private Extractor TExtractor;         private Extractor TExtractor;
   
        // Token: 0x04000043 RID: 67         // Token: 0x0400003D RID: 61
        private Output TOutput;         private Output TOutput;
   
        // Token: 0x04000044 RID: 68         // Token: 0x0400003E RID: 62
        private Synchronizer TSynchronizer;         private Synchronizer TSynchronizer;
   
        // Token: 0x04000045 RID: 69         // Token: 0x0400003F RID: 63
.        private string sync = "Lawsuits";         private string sync = "Activities";
    }     }
} }