Ejemplo n.º 1
0
 private void bwScriptTest_DoWork(object sender, DoWorkEventArgs e)
 {
     GlobalConfig.parseStart();
     if ((uint)this.lines.Length > 0U)
     {
         for (int i = 0; i < this.lines.Length; i++)
         {
             string script1Line = this.lines[i].Trim();
             if (!script1Line.StartsWith(";") && script1Line.Length > 0)
             {
                 this.lvScript.Invoke(new Action(delegate
                 {
                     this.lvScript.SelectedIndices.Clear();
                     this.lvScript.SelectedIndices.Add(i);
                     this.lvScript.Items[i].SubItems[1].Text = "Running ...";
                 }));
                 bool result = false;
                 if (script1Line == "capcharAli")
                 {
                     frmMain.FindAli();
                     script1Line = "text(\"" + Capchar.Getcapchar() + "\")";
                 }
                 if (script1Line == "downChMavrochain")
                 {
                     frmMain.FindMavrochain();
                     script1Line = "";
                 }
                 if (script1Line == "capcharMavrochain")
                 {
                     script1Line = "rd(\"" + Capchar.Getcapchar() + "\")";
                 }
                 if (ScriptsCore.executeScript(script1Line, out result))
                 {
                     this.lvScript.Invoke(new Action(delegate
                     {
                         this.lvScript.SelectedIndices.Clear();
                         this.lvScript.SelectedIndices.Add(i);
                         ListViewItem listViewItem     = this.lvScript.Items[i];
                         listViewItem.SubItems[1].Text = "Success [result=" + result.ToString() + "]";
                         listViewItem.EnsureVisible();
                     }));
                 }
                 else
                 {
                     if (result)
                     {
                         this.lvScript.Invoke(new Action(delegate
                         {
                             this.lvScript.SelectedIndices.Clear();
                             this.lvScript.SelectedIndices.Add(i);
                             ListViewItem listViewItem     = this.lvScript.Items[i];
                             listViewItem.SubItems[1].Text = "Success [End]";
                             listViewItem.EnsureVisible();
                         }));
                         break;
                     }
                     this.lvScript.Invoke(new Action(delegate
                     {
                         this.lvScript.SelectedIndices.Clear();
                         this.lvScript.SelectedIndices.Add(i);
                         ListViewItem listViewItem     = this.lvScript.Items[i];
                         listViewItem.SubItems[1].Text = "#Failed";
                         listViewItem.EnsureVisible();
                     }));
                     break;
                 }
             }
         }
     }
     this.lvScript.Invoke(new Action(delegate
     {
         this.btnDone.Enabled = true;
     }));
 }
Ejemplo n.º 2
0
        public void execute(out bool end, int countrun, bool setRRS)
        {
            if (this.type == Operation.OperationType.Script2Operation)
            {
                if (File.Exists(LocalConfig.getCurrentConfig().configDirectory() + "/Scripts/" + this.appScriptOperationAppName.Replace(Operation.CurrentAppName, Operation.__g_var_appName)))
                {
                    string str = File.ReadAllText(LocalConfig.getCurrentConfig().configDirectory() + "/Scripts/" + this.appScriptOperationAppName.Replace(Operation.CurrentAppName, Operation.__g_var_appName));
                    if (str != null)
                    {
                        this.scripts = GlobalConfig.splitToLines(str);
                    }
                }
                else
                {
                    Operation.__g_var_appId   = frmMain.Appid;
                    Operation.__g_var_appName = frmMain.AppnameDefault;
                    if (File.Exists(LocalConfig.getCurrentConfig().configDirectory() + "/Scripts/" + this.appScriptOperationAppName.Replace(Operation.CurrentAppName, Operation.__g_var_appName)))
                    {
                        string str = File.ReadAllText(LocalConfig.getCurrentConfig().configDirectory() + "/Scripts/" + this.appScriptOperationAppName.Replace(Operation.CurrentAppName, Operation.__g_var_appName));
                        if (str != null)
                        {
                            this.scripts = GlobalConfig.splitToLines(str);
                        }
                    }
                }
                bool result1 = false;
                end = false;
                frmMain.BoolstartTimer1 = true;
                for (int index = 0; index < this.scripts.Length; ++index)
                {
                    this.CheckConnectDevice();
                    if (AutoLeadClient.send(Operation.jss.Serialize((object)new Dictionary <string, object>()
                    {
                        ["cmd"] = (object)"topmostappsystem"
                    })) && AutoLeadClient.receive().IndexOf(Operation.idapp_open) < 0)
                    {
                        string script1Line = "open_app(" + Operation.idapp_open + ")";
                        try
                        {
                            bool result2;
                            ScriptsCore.executeScript(script1Line, out result2);
                        }
                        catch
                        {
                        }
                    }
                    string script1Line1 = this.scripts[index].Replace(Operation.CurrentAppName, Operation.__g_var_appName).Replace(Operation.CurrentAppId, Operation.__g_var_appId);
                    if (script1Line1 != null && script1Line1 != "")
                    {
                        frmMain.sttScript2 = script1Line1;
                        if (script1Line1 == "capcharAli")
                        {
                            frmMain.FindAli();
                            script1Line1 = "text(\"" + Capchar.Getcapchar() + "\")";
                        }
                        if (script1Line1 == "downChMavrochain")
                        {
                            frmMain.FindMavrochain();
                            script1Line1 = "";
                        }
                        if (script1Line1 == "capcharMavrochain")
                        {
                            script1Line1 = "rd(\"" + Capchar.Getcapchar() + "\")";
                        }
                        this.CheckConnectDevice();
                        ScriptsCore.executeScript(script1Line1, out result1, this);
                    }
                }
                frmMain.BoolstartTimer1 = false;
            }
            else if (this.type == Operation.OperationType.ScriptOperation && this._description.IndexOf("Script RRS") >= 0)
            {
                bool result1 = false;
                end = false;
                frmMain.BoolstartTimer1 = true;
                for (int index = 0; index < this.scripts.Length; ++index)
                {
                    this.CheckConnectDevice();
                    if (AutoLeadClient.send(Operation.jss.Serialize((object)new Dictionary <string, object>()
                    {
                        ["cmd"] = (object)"topmostappsystem"
                    })) && AutoLeadClient.receive().IndexOf(frmMain.idappRRS) < 0)
                    {
                        string script1Line = "open_app(" + frmMain.idappRRS + ")";
                        try
                        {
                            bool result2;
                            ScriptsCore.executeScript(script1Line, out result2);
                        }
                        catch
                        {
                        }
                    }
                    string script1Line1 = this.scripts[index].Replace(Operation.CurrentAppName, Operation.__g_var_appName).Replace(Operation.CurrentAppId, Operation.__g_var_appId);
                    if (script1Line1 != null && script1Line1 != "")
                    {
                        frmMain.sttScript2 = script1Line1;
                        this.CheckConnectDevice();
                        ScriptsCore.executeScript(script1Line1, out result1, this);
                    }
                }
                frmMain.BoolstartTimer1 = false;
            }
            else if (this.type == Operation.OperationType.WaitForAppStoreOperation)
            {
                try
                {
                    end = false;
                    this.checkASFlag = true;
                    this.checkAS     = new Thread(new ThreadStart(this._check_appstore));
                    this.checkAS.Start();
                    while (this.timeout > 0)
                    {
                        if (!frmMain.sttconnect)
                        {
                            end = true;
                            break;
                        }
                        Thread.Sleep(1000);
                        if (this.checkASResult != null)
                        {
                            break;
                        }
                    }
                    this.checkASFlag = false;
                    while (this.checkAS.IsAlive)
                    {
                        if (!frmMain.sttconnect)
                        {
                            end = true;
                            break;
                        }
                        Thread.Sleep(1000);
                    }
                    if (this.checkASResult == null)
                    {
                        end = true;
                    }
                    this.checkAS = (Thread)null;
                }
                catch (Exception ex)
                {
                    if (this.checkAS != null && this.checkAS.IsAlive)
                    {
                        this.checkAS.Abort();
                    }
                    throw ex;
                }
            }
            else if (this.type == Operation.OperationType.OpenDetectedAppOperation)
            {
                end = false;
                if (frmMain.bool_detectapp)
                {
                    Dictionary <string, object> dictionary = new Dictionary <string, object>();
                    dictionary["cmd"] = (object)"topmostappsystem";
                    string url = (string)null;
                    if (AutoLeadClient.send(Operation.jss.Serialize((object)dictionary)))
                    {
                        string input = AutoLeadClient.receive();
                        this.checkASResult = Operation.jss.Deserialize <Dictionary <string, object> >(input);
                        url = this.checkASResult["url"].ToString();
                        if (url.Length > 0)
                        {
                            Operation.__g_var_detectedAppId = AppURLToAppID.AppIDFromURL(url);
                            if (Operation.__g_var_detectedAppId.Length <= 0)
                            {
                                Operation.__g_var_detectedAppId = AppURLToAppID.AppIDFromSiteLee(url);
                            }
                        }
                    }
                    if (Operation.__g_var_detectedAppId.Length > 0)
                    {
                        List <Listapp> list = frmMain.ListappInstall.Where <Listapp>((Func <Listapp, bool>)(c => c.app_id == Operation.__g_var_detectedAppId)).ToList <Listapp>();
                        if (list.Count <Listapp>() > 0)
                        {
                            Operation.nameapp_open = list[0].app_name;
                            if (!frmMain.bool_sml)
                            {
                                if (frmMain.Appid != Operation.__g_var_detectedAppId)
                                {
                                    end = true;
                                }
                                else
                                {
                                    string script1Line = "open_app(" + Operation.__g_var_detectedAppId + ")";
                                    Operation.idapp_open = Operation.__g_var_detectedAppId;
                                    try
                                    {
                                        bool result;
                                        ScriptsCore.executeScript(script1Line, out result);
                                    }
                                    catch
                                    {
                                    }
                                }
                            }
                            else
                            {
                                string script1Line = "open_app(" + Operation.__g_var_detectedAppId + ")";
                                Operation.idapp_open = Operation.__g_var_detectedAppId;
                                try
                                {
                                    bool result;
                                    ScriptsCore.executeScript(script1Line, out result);
                                }
                                catch
                                {
                                }
                            }
                        }
                        else
                        {
                            end = true;
                        }
                    }
                    else
                    {
                        int num1 = (int)MessageBox.Show(url + " \r\n Nhấn OK để copy link app");
                        if (!frmMain.bool_sml)
                        {
                            int num2 = (int)MessageBox.Show("App này không nhận dạng được, bỏ chọn phần 'Nhận dạng app'");
                        }
                        end = true;
                    }
                }
                else
                {
                    Operation.__g_var_detectedAppId = frmMain.Appid;
                    string script1Line = "open_app(" + Operation.__g_var_detectedAppId + ")";
                    Operation.idapp_open   = Operation.__g_var_detectedAppId;
                    Operation.nameapp_open = frmMain.AppnameDefault;
                    try
                    {
                        bool result;
                        ScriptsCore.executeScript(script1Line, out result);
                    }
                    catch
                    {
                    }
                }
            }
            else if (this.type == Operation.OperationType.GetRunningAppOperation)
            {
                Operation.__g_var_appId   = Operation.idapp_open;
                Operation.__g_var_appName = Operation.nameapp_open;
                end = false;
            }
            else if (this.type == Operation.OperationType.FakeInfoOperation)
            {
                Dictionary <string, object> dictionary;
                while (true)
                {
                    end                      = false;
                    dictionary               = new Dictionary <string, object>();
                    dictionary["cmd"]        = (object)"fake_info";
                    dictionary["listapp_id"] = (object)this.fakeAppId;
                    if (this.fakeSet)
                    {
                        if (Operation.dict.Count <= 0)
                        {
                            Operation.dict = FakeInfoCore.get();
                        }
                        if (Operation.dict.Count > 0)
                        {
                            if (!Operation.CheckinfoFake(Operation.dict))
                            {
                                Operation.dict.Clear();
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            goto label_101;
                        }
                    }
                    else
                    {
                        goto label_101;
                    }
                }
                if (frmMain.bool_fakelangnoIP)
                {
                    Operation.dict["lang"] = (object)Split.tachchuoi(frmMain.langnoIP, "|")[0];
                }
                Operation.dict["setfakegeo"]    = !frmMain.bool_fakegeo ? (object)"0" : (object)"1";
                Operation.dict["setfakeUa"]     = !frmMain.bool_fakeUA ? (object)"0" : (object)"1";
                Operation.dict["setfakescreen"] = !frmMain.bool_fakescreen ? (object)"0" : (object)"1";
                dictionary["info"] = (object)Operation.dict;
label_101:
                if (!AutoLeadClient.send(Operation.jss.Serialize((object)dictionary)))
                {
                    return;
                }
                string input = AutoLeadClient.receive();
                if (Convert.ToInt32(Operation.jss.Deserialize <Dictionary <string, object> >(input)["result"]) != 1)
                {
                    throw new Exception("ERROR. [" + this.description() + "] return [False]");
                }
                Thread.Sleep(1000);
            }
            else if (this.type == Operation.OperationType.SetupProxyOperation)
            {
                end = false;
                try
                {
                    string[] strArray = GlobalConfig.stringSplit(this.ipWithLocation, ",");
                    if (strArray.Length >= 3)
                    {
                        string country = strArray[1].Trim();
                        strArray[2].Trim();
                        if (country.Equals("TAIWAN"))
                        {
                            country = "TAIWAN, PROVINCE OF CHINA";
                        }
                        if (country.Equals("BOLIVIA"))
                        {
                            country = "BOLIVIA, PLURINATIONAL STATE OF";
                        }
                        if (country.Equals("IRAN"))
                        {
                            country = "IRAN, ISLAMIC REPUBLIC OF";
                        }
                        if (country.Equals("IRAN"))
                        {
                            country = "IRAN, ISLAMIC REPUBLIC OF";
                        }
                        if (country.Equals("KOREA"))
                        {
                            country = "KOREA, REPUBLIC OF";
                        }
                        if (country.Equals("KOREA"))
                        {
                            country = "KOREA, REPUBLIC OF";
                        }
                        if (country.Equals("MACEDONIA"))
                        {
                            country = "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF";
                        }
                        if (country.Equals("MOLDOVA"))
                        {
                            country = "MOLDOVA, REPUBLIC OF";
                        }
                        if (country.Equals("PALESTINE"))
                        {
                            country = "PALESTINE, STATE OF";
                        }
                        string str1   = strArray[0].Trim();
                        string str2   = this.ipWithLocation.Replace(str1, "").Replace(", " + country, "").Trim();
                        string region = str2.Length != 0 ? str2.Remove(0, 1).Trim() : (string)null;
                        this.frm.setupProxy(this.tool, str1, country, region, this.previousSshInfo);
                    }
                }
                catch (Exception ex)
                {
                }
                if (GlobalConfig.currentPublicIP == null)
                {
                    throw new Exception("ERROR. Could not execute [" + this.description() + "]");
                }
            }
            else if (this.type == Operation.OperationType.ChangeIPOperation)
            {
                if (!setRRS)
                {
                    Operation.dict.Clear();
                }
                end = false;
                try
                {
                    this.frm.changeIP();
                }
                catch (Exception ex)
                {
                }
                if (GlobalConfig.currentPublicIP == null)
                {
                    throw new Exception("ERROR. Could not execute [" + this.description() + "]");
                }
            }
            else if (this.type == Operation.OperationType.AppScriptOperation)
            {
                end = false;
                new Dictionary <string, object>()["cmd"] = (object)"topmostappsystem";
                if (!this._isAppRunning(this.appScriptOperationAppName))
                {
                    return;
                }
                bool result = false;
                end = false;
                for (int index = 0; index < this.scripts.Length; ++index)
                {
                    this.CheckConnectDevice();
                    string script1Line = this.scripts[index].Replace(Operation.CurrentAppName, Operation.__g_var_appName).Replace(Operation.CurrentAppId, Operation.__g_var_appId);
                    if (this._isAppRunning(this.appScriptOperationAppName))
                    {
                        if (!ScriptsCore.executeScript(script1Line, out result, this))
                        {
                            if (!result)
                            {
                                throw new Exception("ERROR. Could not execute [" + this.description() + "]");
                            }
                            end = true;
                            break;
                        }
                        if (!result)
                        {
                            throw new Exception("ERROR. [" + this.description() + "] return [False]");
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (this.type == Operation.OperationType.ScriptOperation && this._description.IndexOf("Restore") >= 0)
            {
                bool result = false;
                end = false;
                for (int index = 0; index < this.scripts.Length; ++index)
                {
                    string script1Line = this.scripts[index].Replace(Operation.CurrentAppName, Operation.__g_var_appName).Replace(Operation.CurrentAppId, Operation.__g_var_appId).Replace(" ", "");
                    if (script1Line != null && script1Line != "")
                    {
                        ScriptsCore.executeScript(script1Line, out result, this);
                        frmMain.RestoreRRS(Split.tachchuoi(this.scripts[index].Replace("restore(", "").Replace(",<current_appid>)", ""), ",")[0]);
                        Thread.Sleep(3000);
                        result = true;
                        end    = false;
                    }
                }
            }
            else
            {
                bool result = false;
                end = false;
                for (int index1 = 0; index1 < this.scripts.Length; ++index1)
                {
                    string script1Line = this.scripts[index1].Replace(Operation.CurrentAppName, Operation.__g_var_appName).Replace(Operation.CurrentAppId, Operation.__g_var_appId);
                    if (script1Line == "exit()")
                    {
                        script1Line = "";
                        Operation.__g_var_appName = "";
                        Operation.__g_var_appId   = "";
                    }
                    if (script1Line == "downChMavrochain")
                    {
                        frmMain.FindMavrochain();
                        script1Line = "";
                    }
                    if (script1Line == "capcharMavrochain")
                    {
                        script1Line = "rd(\"" + Capchar.Getcapchar() + "\")";
                    }
                    if (script1Line != null && script1Line != "")
                    {
                        if (script1Line.IndexOf("backup") >= 0)
                        {
                            if (script1Line.IndexOf("backuprrs") >= 0)
                            {
                                string str1 = script1Line.Replace("backuprrs", "backup").Replace(" ", "");
                                string str2 = Split.tachchuoi(str1, ",")[0].Replace("backup(", "");
                                frmMain.WipeOlRRSlee(str2);
                                ScriptsCore.executeScript(str1, out result, this);
                                frmMain.BKRRS(str2, true);
                                result = true;
                                end    = false;
                                break;
                            }
                            for (int index2 = 0; index2 < frmMain.ListVitriBk.Count; ++index2)
                            {
                                if (frmMain.ListVitriBk[index2].vitri == countrun)
                                {
                                    string str = script1Line.Replace(" ", "");
                                    ScriptsCore.executeScript(str, out result, this);
                                    frmMain.BKRRS(Split.tachchuoi(str, ",")[0].Replace("backup(", ""), false);
                                    frmMain.UpRRSFtp();
                                    result = true;
                                    end    = false;
                                    break;
                                }
                            }
                            result = true;
                            end    = false;
                        }
                        else if (!ScriptsCore.executeScript(script1Line, out result, this))
                        {
                            if (!result)
                            {
                                throw new Exception("ERROR. Could not execute [" + this.description() + "]");
                            }
                            end = true;
                            break;
                        }
                        if (!result)
                        {
                            throw new Exception("ERROR. [" + this.description() + "] return [False]");
                        }
                    }
                }
            }
        }