E:\TrabalhoSuely\RoboDescompilado\Redistribuir\ZionRobot\Tasks\Synchronizer.cs E:\TrabalhoSuely\RoboDescompilado\CriarVerificar\ZionRobot\Tasks\Synchronizer.cs
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
.using System.Linq;  
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
using ZionRobot.Handlers; using ZionRobot.Handlers;
using ZionRobot.Models.Source; using ZionRobot.Models.Source;
using ZionRobot.Models.ZFlow; using ZionRobot.Models.ZFlow;
   
namespace ZionRobot.Tasks namespace ZionRobot.Tasks
{ {
    // Token: 0x02000023 RID: 35     // Token: 0x0200001A RID: 26
    internal class Synchronizer     internal class Synchronizer
    {     {
        // Token: 0x17000031 RID: 49         // Token: 0x1700001F RID: 31
        // (get) Token: 0x060000C7 RID: 199 RVA: 0x00006A82 File Offset: 0x00004C82         // (get) Token: 0x0600008E RID: 142 RVA: 0x0000585A File Offset: 0x00003A5A
        public bool Running         public bool Running
        {         {
            get             get
            {             {
                return this.running;                 return this.running;
            }             }
        }         }
   
        // Token: 0x060000C8 RID: 200 RVA: 0x00006A8A File Offset: 0x00004C8A         // Token: 0x0600008F RID: 143 RVA: 0x00005862 File Offset: 0x00003A62
        public Synchronizer()         public Synchronizer()
        {         {
            this.running = false;             this.running = false;
        }         }
   
        // Token: 0x060000C9 RID: 201 RVA: 0x00006AB4 File Offset: 0x00004CB4         // Token: 0x06000090 RID: 144 RVA: 0x0000588C File Offset: 0x00003A8C
        public void Execute(Origin source, Activity activity)         public void Execute(Origin source, Activity activity)
        {         {
            this.running = true;             this.running = true;
            this.stopwatch.Start();             this.stopwatch.Start();
            Application.Current.Dispatcher.Invoke(delegate()             Application.Current.Dispatcher.Invoke(delegate()
            {             {
                this.handler = Browser.Instance;                 this.handler = Browser.Instance;
            });             });
            System.Action <>9__4;             System.Action <>9__4;
            ThreadStart <>9__2;             ThreadStart <>9__2;
            System.Action <>9__5;             System.Action <>9__5;
            ThreadStart <>9__3;             ThreadStart <>9__3;
            new Thread(delegate()             new Thread(delegate()
            {             {
                ThreadStart start;                 ThreadStart start;
                if ((start = <>9__2) == null)                 if ((start = <>9__2) == null)
                {                 {
                    start = (<>9__2 = delegate()                     start = (<>9__2 = delegate()
                    {                     {
                        try                         try
                        {                         {
                            Dispatcher dispatcher = Application.Current.Dispatcher;                             Dispatcher dispatcher = Application.Current.Dispatcher;
                            System.Action callback;                             System.Action callback;
                            if ((callback = <>9__4) == null)                             if ((callback = <>9__4) == null)
                            {                             {
                                callback = (<>9__4 = delegate()                                 callback = (<>9__4 = delegate()
                                {                                 {
                                    this.handler.Source = source;                                     this.handler.Source = source;
                                    bool flag = activity.Action.ToUpper() == "UPDATE" && !string.IsNullOrEmpty(activity.DataJuri);                                     bool flag = activity.Action.ToUpper() == "UPDATE" && !string.IsNullOrEmpty(activity.DataJuri);
                                    if (flag)                                     if (flag)
                                    {                                     {
                                        this.handler.UpdateActivity(activity);                                         this.handler.UpdateActivity(activity);
                                    }                                     }
.                                    else                                      bool flag2 = activity.Action.ToUpper() == "CREATE"; 
                                    {                                      if (flag2) 
                                        bool flag2 = activity.Action.ToUpper() == "CREATE";   
                                        if (flag2)   
                                        {   
                                            this.handler.CreateSubActivity(activity);   
                                        }   
                                        else   
                                        {   
                                            bool flag3 = activity.Action.ToUpper() == "CREATECASE";   
                                            if (flag3)   
                                            {   
                                                this.handler.CreateCase(activity);   
                                            }   
                                            else   
                                            {   
                                                bool flag4 = activity.Action.ToUpper() == "CLOSE";   
                                                if (flag4)   
                                                {   
                                                    this.handler.CloseCase(activity);   
                                                }   
                                                else   
                                                {   
                                                    bool flag5 = activity.Action.ToUpper() == "SHAREPOINT";   
                                                    if (flag5)   
                                                    {   
                                                        Console.WriteLine(activity.Id);   
                                                        this.handler.UploadAttachments(activity);   
                                                    }   
                                                }   
                                            }   
                                        }   
                                    }   
                                });   
                            }   
                            dispatcher.Invoke(callback);   
                        }   
                        catch (Exception ex)   
                        {   
                            throw ex;   
                        }   
                    });   
                }   
                Thread t = new Thread(start);   
                t.Start();   
                ThreadStart start2;   
                if ((start2 = <>9__3) == null)   
                {   
                    start2 = (<>9__3 = delegate()   
                    {   
                        while (this.handler.Main == null || this.handler.Main.IsAlive)   
                        {   
                            bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;   
                            if (flag)   
                            {   
                                activity.UpdateActivitySycn(3);   
                                break;   
                            }   
                            Thread.Sleep(1000);   
                        }   
                        this.stopwatch.Stop();   
                        this.stopwatch.Reset();   
                        Dispatcher dispatcher = Application.Current.Dispatcher;   
                        System.Action callback;   
                        if ((callback = <>9__5) == null)   
                        {   
                            callback = (<>9__5 = delegate()   
                            {   
                                this.handler.Close();   
                            });   
                        }   
                        dispatcher.Invoke(callback);   
                        this.running = false;   
                    });   
                }   
                new Thread(start2).Start();   
            }).Start();   
        }   
   
        // Token: 0x060000CA RID: 202 RVA: 0x00006B24 File Offset: 0x00004D24   
        public void Execute(Origin source, Lawsuit lawsuit)   
        {   
            this.running = true;   
            this.stopwatch.Start();   
            Application.Current.Dispatcher.Invoke(delegate()   
            {   
                this.handler = Browser.Instance;   
            });   
            System.Action <>9__4;   
            ThreadStart <>9__2;   
            System.Action <>9__5;   
            ThreadStart <>9__3;   
            new Thread(delegate()   
            {   
                ThreadStart start;   
                if ((start = <>9__2) == null)   
                {   
                    start = (<>9__2 = delegate()   
                    {   
                        try   
                        {   
                            Dispatcher dispatcher = Application.Current.Dispatcher;   
                            System.Action callback;   
                            if ((callback = <>9__4) == null)   
                            {   
                                callback = (<>9__4 = delegate()   
                                {   
                                    this.handler.Source = source;   
                                    bool flag = lawsuit.SyncAction.ToUpper() == "UPDATE";   
                                    if (flag)   
                                    {                                     {
.                                        this.handler.UpdateLawsuit(lawsuit);                                         this.handler.CreateSubActivity(activity);
                                    }                                     }
.                                    bool flag2 = lawsuit.SyncAction.ToUpper() == "CREATE";                                     bool flag3 = activity.Action.ToUpper() == "CREATECASE";
                                    if (flag2)                                     if (flag3)
                                    {                                     {
.                                        this.handler.CreateLawsuit(lawsuit);                                         this.handler.CreateCase(activity);
                                    }                                     }
.                                });                                     bool flag4 = activity.Action.ToUpper() == "CLOSE";
                            }                                      if (flag4) 
                            dispatcher.Invoke(callback);   
                        }   
                        catch (Exception ex)   
                        {   
                            throw ex;   
                        }   
                    });   
                }   
                Thread t = new Thread(start);   
                t.Start();   
                ThreadStart start2;   
                if ((start2 = <>9__3) == null)   
                {   
                    start2 = (<>9__3 = delegate()   
                    {   
                        while (this.handler.Main == null || this.handler.Main.IsAlive)   
                        {   
                            bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;   
                            if (flag)   
                            {   
                                break;   
                            }   
                            Thread.Sleep(1000);   
                        }   
                        this.stopwatch.Stop();   
                        this.stopwatch.Reset();   
                        Dispatcher dispatcher = Application.Current.Dispatcher;   
                        System.Action callback;   
                        if ((callback = <>9__5) == null)   
                        {   
                            callback = (<>9__5 = delegate()   
                            {   
                                this.handler.Close();   
                            });   
                        }   
                        dispatcher.Invoke(callback);   
                        this.running = false;   
                    });   
                }   
                new Thread(start2).Start();   
            }).Start();   
        }   
   
        // Token: 0x060000CB RID: 203 RVA: 0x00006B94 File Offset: 0x00004D94   
        public void Execute(Origin source, LawsuitPhase lawsuitPhase)   
        {   
            this.running = true;   
            this.stopwatch.Start();   
            Application.Current.Dispatcher.Invoke(delegate()   
            {   
                this.handler = Browser.Instance;   
            });   
            System.Action <>9__4;   
            ThreadStart <>9__2;   
            System.Action <>9__5;   
            ThreadStart <>9__3;   
            new Thread(delegate()   
            {   
                ThreadStart start;   
                if ((start = <>9__2) == null)   
                {   
                    start = (<>9__2 = delegate()   
                    {   
                        try   
                        {   
                            Dispatcher dispatcher = Application.Current.Dispatcher;   
                            System.Action callback;   
                            if ((callback = <>9__4) == null)   
                            {   
                                callback = (<>9__4 = delegate()   
                                {   
                                    this.handler.Source = source;   
                                    bool flag = lawsuitPhase.SyncAction.ToUpper() == "CREATE";   
                                    if (flag)   
                                    {                                     {
.                                        this.handler.CreateLawsuitPhase(lawsuitPhase);                                         this.handler.CloseCase(activity);
                                    }                                     }
.                                });                                     bool flag5 = activity.Action.ToUpper() == "SHAREPOINT";
                            }                                      if (flag5) 
                            dispatcher.Invoke(callback);   
                        }   
                        catch (Exception ex)   
                        {   
                            throw ex;   
                        }   
                    });   
                }   
                Thread t = new Thread(start);   
                t.Start();   
                ThreadStart start2;   
                if ((start2 = <>9__3) == null)   
                {   
                    start2 = (<>9__3 = delegate()   
                    {   
                        while (this.handler.Main == null || this.handler.Main.IsAlive)   
                        {   
                            bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;   
                            if (flag)   
                            {   
                                break;   
                            }   
                            Thread.Sleep(1000);   
                        }   
                        this.stopwatch.Stop();   
                        this.stopwatch.Reset();   
                        Dispatcher dispatcher = Application.Current.Dispatcher;   
                        System.Action callback;   
                        if ((callback = <>9__5) == null)   
                        {   
                            callback = (<>9__5 = delegate()   
                            {   
                                this.handler.Close();   
                            });   
                        }   
                        dispatcher.Invoke(callback);   
                        this.running = false;   
                    });   
                }   
                new Thread(start2).Start();   
            }).Start();   
        }   
   
        // Token: 0x060000CC RID: 204 RVA: 0x00006C04 File Offset: 0x00004E04   
        public void Execute(Origin source, LawsuitPhaseProgress lawsuitPhaseProgress)   
        {   
            this.running = true;   
            this.stopwatch.Start();   
            Application.Current.Dispatcher.Invoke(delegate()   
            {   
                this.handler = Browser.Instance;   
            });   
            System.Action <>9__4;   
            ThreadStart <>9__2;   
            System.Action <>9__5;   
            ThreadStart <>9__3;   
            new Thread(delegate()   
            {   
                ThreadStart start;   
                if ((start = <>9__2) == null)   
                {   
                    start = (<>9__2 = delegate()   
                    {   
                        try   
                        {   
                            Dispatcher dispatcher = Application.Current.Dispatcher;   
                            System.Action callback;   
                            if ((callback = <>9__4) == null)   
                            {   
                                callback = (<>9__4 = delegate()   
                                {   
                                    this.handler.Source = source;   
                                    bool flag = lawsuitPhaseProgress.SyncAction.ToUpper() == "CREATE";   
                                    if (flag)   
                                    {                                     {
.                                        this.handler.CreateLawsuitPhaseProgress(lawsuitPhaseProgress);                                         this.handler.UploadAttachments(activity);
                                    }                                     }
                                });                                 });
                            }                             }
                            dispatcher.Invoke(callback);                             dispatcher.Invoke(callback);
                        }                         }
                        catch (Exception ex)                         catch (Exception ex)
                        {                         {
                            throw ex;                             throw ex;
                        }                         }
                    });                     });
                }                 }
                Thread t = new Thread(start);                 Thread t = new Thread(start);
                t.Start();                 t.Start();
                ThreadStart start2;                 ThreadStart start2;
                if ((start2 = <>9__3) == null)                 if ((start2 = <>9__3) == null)
                {                 {
                    start2 = (<>9__3 = delegate()                     start2 = (<>9__3 = delegate()
                    {                     {
                        while (this.handler.Main == null || this.handler.Main.IsAlive)                         while (this.handler.Main == null || this.handler.Main.IsAlive)
                        {                         {
                            bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;                             bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;
                            if (flag)                             if (flag)
                            {                             {
                                break;                                 break;
                            }                             }
                            Thread.Sleep(1000);                             Thread.Sleep(1000);
                        }                         }
                        this.stopwatch.Stop();                         this.stopwatch.Stop();
                        this.stopwatch.Reset();                         this.stopwatch.Reset();
                        Dispatcher dispatcher = Application.Current.Dispatcher;                         Dispatcher dispatcher = Application.Current.Dispatcher;
                        System.Action callback;                         System.Action callback;
                        if ((callback = <>9__5) == null)                         if ((callback = <>9__5) == null)
                        {                         {
                            callback = (<>9__5 = delegate()                             callback = (<>9__5 = delegate()
                            {                             {
                                this.handler.Close();                                 this.handler.Close();
                            });                             });
                        }                         }
                        dispatcher.Invoke(callback);                         dispatcher.Invoke(callback);
                        this.running = false;                         this.running = false;
                    });                     });
                }                 }
                new Thread(start2).Start();                 new Thread(start2).Start();
            }).Start();             }).Start();
        }         }
   
        // Token: 0x060000CD RID: 205 RVA: 0x00006C74 File Offset: 0x00004E74         // Token: 0x06000091 RID: 145 RVA: 0x000058FC File Offset: 0x00003AFC
.        public void Execute(Origin source, LawsuitDemand lawsuitDemand)         public void Execute(Origin source, Lawsuit lawsuit)
        {         {
            this.running = true;             this.running = true;
            this.stopwatch.Start();             this.stopwatch.Start();
            Application.Current.Dispatcher.Invoke(delegate()             Application.Current.Dispatcher.Invoke(delegate()
            {             {
                this.handler = Browser.Instance;                 this.handler = Browser.Instance;
            });             });
            System.Action <>9__4;             System.Action <>9__4;
            ThreadStart <>9__2;             ThreadStart <>9__2;
            System.Action <>9__5;             System.Action <>9__5;
            ThreadStart <>9__3;             ThreadStart <>9__3;
            new Thread(delegate()             new Thread(delegate()
            {             {
                ThreadStart start;                 ThreadStart start;
                if ((start = <>9__2) == null)                 if ((start = <>9__2) == null)
                {                 {
                    start = (<>9__2 = delegate()                     start = (<>9__2 = delegate()
                    {                     {
                        try                         try
                        {                         {
                            Dispatcher dispatcher = Application.Current.Dispatcher;                             Dispatcher dispatcher = Application.Current.Dispatcher;
                            System.Action callback;                             System.Action callback;
                            if ((callback = <>9__4) == null)                             if ((callback = <>9__4) == null)
                            {                             {
                                callback = (<>9__4 = delegate()                                 callback = (<>9__4 = delegate()
                                {                                 {
                                    this.handler.Source = source;                                     this.handler.Source = source;
.                                    bool flag = lawsuitDemand.SyncAction.ToUpper() == "CREATE";                                     bool flag = lawsuit.Action.ToUpper() == "CREATE";
                                    if (flag)                                     if (flag)
                                    {                                     {
.                                        this.handler.CreateLawsuitDemand(lawsuitDemand);                                         this.handler.CreateLawsuit(lawsuit);
                                    }                                     }
                                });                                 });
                            }                             }
                            dispatcher.Invoke(callback);                             dispatcher.Invoke(callback);
                        }                         }
                        catch (Exception ex)                         catch (Exception ex)
                        {                         {
                            throw ex;                             throw ex;
                        }                         }
                    });                     });
                }                 }
                Thread t = new Thread(start);                 Thread t = new Thread(start);
                t.Start();                 t.Start();
                ThreadStart start2;                 ThreadStart start2;
                if ((start2 = <>9__3) == null)                 if ((start2 = <>9__3) == null)
                {                 {
                    start2 = (<>9__3 = delegate()                     start2 = (<>9__3 = delegate()
                    {                     {
                        while (this.handler.Main == null || this.handler.Main.IsAlive)                         while (this.handler.Main == null || this.handler.Main.IsAlive)
                        {                         {
                            bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;                             bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;
                            if (flag)                             if (flag)
                            {                             {
                                break;                                 break;
                            }                             }
                            Thread.Sleep(1000);                             Thread.Sleep(1000);
                        }                         }
                        this.stopwatch.Stop();                         this.stopwatch.Stop();
                        this.stopwatch.Reset();                         this.stopwatch.Reset();
                        Dispatcher dispatcher = Application.Current.Dispatcher;                         Dispatcher dispatcher = Application.Current.Dispatcher;
                        System.Action callback;                         System.Action callback;
                        if ((callback = <>9__5) == null)                         if ((callback = <>9__5) == null)
                        {                         {
                            callback = (<>9__5 = delegate()                             callback = (<>9__5 = delegate()
                            {                             {
                                this.handler.Close();                                 this.handler.Close();
                            });                             });
                        }                         }
                        dispatcher.Invoke(callback);                         dispatcher.Invoke(callback);
                        this.running = false;                         this.running = false;
                    });                     });
                }                 }
                new Thread(start2).Start();                 new Thread(start2).Start();
            }).Start();             }).Start();
        }         }
   
        // Token: 0x060000CE RID: 206 RVA: 0x00006CE4 File Offset: 0x00004EE4         // Token: 0x06000092 RID: 146 RVA: 0x0000596C File Offset: 0x00003B6C
.        public void SyncFromLocal(Origin source, string json, string type)  
        {  
            this.running = true;  
            this.stopwatch.Start();  
            Application.Current.Dispatcher.Invoke(delegate()  
            {  
                this.handler = Browser.Instance;  
            });  
            System.Action <>9__4;  
            ThreadStart <>9__2;  
            System.Action <>9__9;  
            ThreadStart <>9__3;  
            new Thread(delegate()  
            {  
                ThreadStart start;  
                if ((start = <>9__2) == null)  
                {  
                    start = (<>9__2 = delegate()  
                    {  
                        try  
                        {  
                            Dispatcher dispatcher = Application.Current.Dispatcher;  
                            System.Action callback;  
                            if ((callback = <>9__4) == null)  
                            {  
                                callback = (<>9__4 = delegate()  
                                {  
                                    this.handler.Source = source;  
                                    BlockElement blockElement = null;  
                                    bool flag = type.ToUpper() == "ANDAMENTOS";  
                                    if (flag)  
                                    {  
                                        blockElement = (from be in source.BlockElements  
                                        where be.Name == "CreateLawsuitPhaseProgressLocal"   
                                        select be).FirstOrDefault<BlockElement>();  
                                    }  
                                    bool flag2 = type.ToUpper() == "DEPOSITOS";  
                                    if (flag2)  
                                    {  
                                        blockElement = (from be in source.BlockElements  
                                        where be.Name == "CreateLawsuitDepositLocal"   
                                        select be).FirstOrDefault<BlockElement>();  
                                    }  
                                    bool flag3 = type.ToUpper() == "PEDIDOS";  
                                    if (flag3)  
                                    {  
                                        blockElement = (from be in source.BlockElements  
                                        where be.Name == "CreateLawsuitDemandLocal"   
                                        select be).FirstOrDefault<BlockElement>();  
                                    }  
                                    bool flag4 = type.ToUpper() == "PROCESSOS";  
                                    if (flag4)  
                                    {  
                                        blockElement = (from be in source.BlockElements  
                                        where be.Name == "CreateLawsuitLocal"   
                                        select be).FirstOrDefault<BlockElement>();  
                                    }  
                                    this.handler.CreateWithLocal(json, blockElement);  
                                });  
                            }  
                            dispatcher.Invoke(callback);  
                        }  
                        catch (Exception ex)  
                        {  
                            throw ex;  
                        }  
                    });  
                }  
                Thread t = new Thread(start);  
                t.Start();  
                ThreadStart start2;  
                if ((start2 = <>9__3) == null)  
                {  
                    start2 = (<>9__3 = delegate()  
                    {  
                        while (this.handler.Main == null || this.handler.Main.IsAlive)  
                        {  
                            bool flag = this.stopwatch.Elapsed.TotalSeconds > (double)this.limitTime;  
                            if (flag)  
                            {  
                                break;  
                            }  
                            Thread.Sleep(1000);  
                        }  
                        this.stopwatch.Stop();  
                        this.stopwatch.Reset();  
                        Dispatcher dispatcher = Application.Current.Dispatcher;  
                        System.Action callback;  
                        if ((callback = <>9__9) == null)  
                        {  
                            callback = (<>9__9 = delegate()  
                            {  
                                this.handler.Close();  
                            });  
                        }  
                        dispatcher.Invoke(callback);  
                        this.running = false;  
                    });  
                }  
                new Thread(start2).Start();  
            }).Start();  
        }  
   
        // Token: 0x060000CF RID: 207 RVA: 0x00006D5C File Offset: 0x00004F5C  
        private string convertDate(string value)         private string convertDate(string value)
        {         {
            return DateTime.Parse(value, new CultureInfo("pt-BR")).ToString("dd/MM/yyyy");             return DateTime.Parse(value, new CultureInfo("pt-BR")).ToString("dd/MM/yyyy");
        }         }
   
        // Token: 0x0400004C RID: 76         // Token: 0x04000033 RID: 51
        private bool running;         private bool running;
   
        // Token: 0x0400004D RID: 77         // Token: 0x04000034 RID: 52
        private Browser handler;         private Browser handler;
   
        // Token: 0x0400004E RID: 78         // Token: 0x04000035 RID: 53
.        private int limitTime = 300;         private int limitTime = 600;
   
        // Token: 0x0400004F RID: 79         // Token: 0x04000036 RID: 54
        private Stopwatch stopwatch = new Stopwatch();         private Stopwatch stopwatch = new Stopwatch();
    }     }
} }