コード例 #1
0
ファイル: ScriptServices.cs プロジェクト: zoath/clonedeploy
        public ActionResultDTO UpdateScript(ScriptEntity script)
        {
            var s = GetScript(script.Id);

            if (s == null)
            {
                return new ActionResultDTO {
                           ErrorMessage = "Script Not Found", Id = 0
                }
            }
            ;
            var validationResult = ValidateScript(script, false);
            var actionResult     = new ActionResultDTO();

            if (validationResult.Success)
            {
                _uow.ScriptRepository.Update(script, script.Id);

                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = script.Id;
            }
            else
            {
                actionResult.ErrorMessage = validationResult.ErrorMessage;
            }

            return(actionResult);
        }
コード例 #2
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void listViewScriptAL_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listViewScriptAL.SelectedItems.Count > 0)
     {
         this.textBoxScriptAL.Enabled = true;
         string       text         = this.listViewScriptAL.SelectedItems[0].Text;
         ScriptEntity scriptEntity = this.listScriptAL[this.listViewSlotAL.SelectedItems[0].Index];
         this.textBoxScriptAL.Text = scriptEntity.scriptDictionary[text];
     }
 }
コード例 #3
0
ファイル: ScriptWriter.cs プロジェクト: wetor/LucaSystemTools
 private void WriteParamData()
 {
     for (int line = 0; line < script.lines.Count; line++)
     {
         for (int index = 0; index < script.lines[line].paramDatas.Count; index++)
         {
             var paramData = script.lines[line].paramDatas[index];
             script.lines[line].paramDatas[index] = ScriptEntity.ToParamData(paramData.valueString, paramData.type);
         }
     }
 }
コード例 #4
0
        public void CreateTest()
        {
            ScriptEntity script = new ScriptEntity()
            {
                CaseID = "TEST_CASE_ID_001"
            };

            long result = ScriptDA.Create(script);

            Assert.IsTrue(ScriptDA.RetrieveAll().Select(x => x.CaseID).Contains(script.CaseID));
        }
コード例 #5
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void comScriptToRunAL_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listViewSlotAL.SelectedItems.Count > 0)
     {
         int          index        = this.listViewSlotAL.SelectedItems[0].Index;
         ScriptEntity scriptEntity = this.listScriptAL[index];
         scriptEntity.scriptIndex = this.comScriptToRunAL.SelectedIndex;
         scriptEntity.scriptKey   = this.comScriptToRunAL.Text;
         this.savescriptsAL();
     }
 }
コード例 #6
0
        public ActionResultDTO Put(int id, ScriptEntity script)
        {
            script.Id = id;
            var result = _scriptServices.UpdateScript(script);

            if (result == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            return(result);
        }
コード例 #7
0
ファイル: ScriptAPI.cs プロジェクト: nknwn-ncgnt/clonedeploy
        public ActionResultDTO Put(int id, ScriptEntity tObject)
        {
            Request.Method = Method.PUT;
            Request.AddJsonBody(tObject);
            Request.Resource = string.Format("api/{0}/Put/{1}", Resource, id);
            var response = _apiRequest.Execute <ActionResultDTO>(Request);

            if (response.Id == 0)
            {
                response.Success = false;
            }
            return(response);
        }
コード例 #8
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void setDataListScriptRRS(List <appDetail> appList)
 {
     this.listViewSlot.Items.Clear();
     this.listViewScript.Items.Clear();
     this.listScriptRRS.Clear();
     foreach (appDetail appDetail in appList)
     {
         ListViewItem value = new ListViewItem(appDetail.appID);
         this.listViewSlot.Items.Add(value);
         ScriptEntity item = new ScriptEntity(appDetail.appID, appDetail.appName);
         this.listScriptRRS.Add(item);
     }
     this.loadScriptsRRSApp();
 }
コード例 #9
0
ファイル: ScriptWriter.cs プロジェクト: wetor/LucaSystemTools
        public void LoadJson(string path)
        {
            JsonSerializerSettings jsetting = new JsonSerializerSettings();

            jsetting.DefaultValueHandling = DefaultValueHandling.Ignore;
            StreamReader sr = new StreamReader(path, Encoding.UTF8);

            script = JsonConvert.DeserializeObject <ScriptEntity>(sr.ReadToEnd(), jsetting);
            sr.Close();
            if (script.toolVersion > Program.toolVersion)
            {
                throw new Exception(String.Format("Tool version is {0}, but this file version is {1}!", Program.toolVersion, script.toolVersion));
            }
        }
コード例 #10
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
        private void btnAddScriptAL_Click(object sender, EventArgs e)
        {
            if (this.listViewSlotAL.SelectedItems.Count <= 0)
            {
                this.listViewSlotAL.Items[0].Selected = true;
            }
            string       text         = "Script " + (this.listViewScriptAL.Items.Count + 1).ToString();
            int          index        = this.listViewSlotAL.SelectedItems[0].Index;
            ScriptEntity scriptEntity = this.listScriptAL[index];

            scriptEntity.scriptDictionary.Add(text, "");
            this.listViewScriptAL.Items.Add(new ListViewItem(text));
            this.comScriptToRunAL.Items.Add(text);
            this.savescriptsAL();
        }
コード例 #11
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void listViewSlotAL_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listViewSlotAL.SelectedItems.Count > 0)
     {
         this.listViewScriptAL.Items.Clear();
         this.comScriptToRunAL.Items.Clear();
         this.comScriptToRunAL.Items.Add("Random");
         ScriptEntity scriptEntity = this.listScriptAL[this.listViewSlotAL.SelectedItems[0].Index];
         foreach (string text in scriptEntity.scriptDictionary.Keys)
         {
             this.listViewScriptAL.Items.Add(new ListViewItem(text));
             this.comScriptToRunAL.Items.Add(text);
         }
         this.comScriptToRunAL.SelectedIndex = scriptEntity.scriptIndex;
     }
 }
コード例 #12
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void textBoxScriptAL_TextChanged(object sender, EventArgs e)
 {
     if (this.listViewScriptAL.SelectedItems.Count > 0)
     {
         this.textBoxScriptAL.Invoke(new MethodInvoker(delegate
         {
             string text = this.listViewScriptAL.SelectedItems[0].Text;
             ScriptEntity scriptEntity = this.listScriptAL[this.listViewSlotAL.SelectedItems[0].Index];
             if (scriptEntity.scriptDictionary.ContainsKey(text))
             {
                 scriptEntity.scriptDictionary.Remove(text);
             }
             scriptEntity.scriptDictionary.Add(text, this.textBoxScriptAL.Text);
         }));
         this.savescriptsAL();
     }
 }
コード例 #13
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void deleteScriptAL_KeyDown()
 {
     if (this.listViewScriptAL.SelectedItems.Count > 0)
     {
         string       text         = this.listViewScriptAL.SelectedItems[0].Text;
         ScriptEntity scriptEntity = this.listScriptAL[this.listViewSlotAL.SelectedItems[0].Index];
         if (scriptEntity.scriptDictionary.ContainsKey(text))
         {
             scriptEntity.scriptDictionary.Remove(text);
         }
         this.listViewScriptAL.Items.Remove(this.listViewScriptAL.SelectedItems[0]);
         this.comScriptToRunAL.Items.Remove(text);
         this.comScriptToRunAL.SelectedIndex = 0;
         this.textBoxScriptAL.Enabled        = false;
         this.textBoxScriptAL.Text           = "";
     }
 }
コード例 #14
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void deleteToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (this.listViewScript.SelectedItems.Count > 0)
     {
         string       text         = this.listViewScript.SelectedItems[0].Text;
         ScriptEntity scriptEntity = this.listScriptRRS[this.listViewSlot.SelectedItems[0].Index];
         if (scriptEntity.scriptDictionary.ContainsKey(text))
         {
             scriptEntity.scriptDictionary.Remove(text);
         }
         this.listViewScript.Items.Remove(this.listViewScript.SelectedItems[0]);
         this.comScriptToRun.Items.Remove(text);
         this.comScriptToRun.SelectedIndex = 0;
         this.textBoxScript.Enabled        = false;
         this.textBoxScript.Text           = "";
     }
 }
コード例 #15
0
        /// <summary>
        /// Valida que existan 2 archivos.
        /// </summary>
        /// <param name="directorio">Nombre del directorio donde se encuentran los scripts</param>
        /// <param name="secuencia">numero de secuencia</param>
        /// <param name="files">nombre de los archivos</param>
        private void ProcesarScripts(string directorio, string secuencia, FileInfo[] files)
        {
            if (files.Length != 2)
            {
                string mensaje = string.Format("Se requieren 2 scripts con numero de secuencia {0} en el direcotrio {1}.", secuencia, directorio);
                throw new ApplicationException(mensaje);
            }

            ScriptFactory scriptFactory = new ScriptFactory();
            FileInfo      implementacion = null, desimplementacion = null;

            if (files[0].Name.Contains("_up.sql"))
            {
                implementacion = files[0];
            }

            if (files[1].Name.Contains("_up.sql"))
            {
                implementacion = files[1];
            }

            if (files[0].Name.Contains("_down.sql"))
            {
                desimplementacion = files[0];
            }

            if (files[1].Name.Contains("_down.sql"))
            {
                desimplementacion = files[0];
            }

            if (implementacion == null || desimplementacion == null)
            {
                string mensaje = string.Format("Dentro del directorio {0} la secuencia {1} " +
                                               "tiene mal formado el postfijo '_down.sql' o '_up.sql', " +
                                               "revíse el nombre de los archivos de dicha secuancia.",
                                               directorio, secuencia, files[0].Name, files[1].Name);
                throw new ApplicationException(mensaje);
            }

            ScriptEntity script = scriptFactory.Crear(implementacion, desimplementacion);

            _ScriptList.Add(script);
        }
コード例 #16
0
ファイル: ScriptServices.cs プロジェクト: zoath/clonedeploy
        public ActionResultDTO AddScript(ScriptEntity script)
        {
            var actionResult     = new ActionResultDTO();
            var validationResult = ValidateScript(script, true);

            if (validationResult.Success)
            {
                _uow.ScriptRepository.Insert(script);
                _uow.Save();
                actionResult.Success = true;
                actionResult.Id      = script.Id;
            }
            else
            {
                actionResult.ErrorMessage = validationResult.ErrorMessage;
            }

            return(actionResult);
        }
コード例 #17
0
ファイル: ScriptDA.cs プロジェクト: YangEricLiu/Mento
        public long Create(ScriptEntity entity)
        {
            string sql = @"INSERT INTO [Script]([CaseID],[ManualCaseID],[Name],[SuiteName],[Type],[Priority],[Feature],[Module],[Owner],[CreateTime],[SyncTime],[FullName],[Assembly])
                           VALUES (@CaseID,@ManualCaseID,@Name,@SuiteName,@Type,@Priority,@Feature,@Module,@Owner,@CreateTime,@SyncTime,@FullName,@Assembly);
                           SELECT SCOPE_IDENTITY()";

            DbCommand command = Database.GetSqlStringCommand(sql);

            Database.AddInParameter(command, "CaseID", DbType.String, entity.CaseID);
            Database.AddInParameter(command, "ManualCaseID", DbType.String, entity.ManualCaseID);
            Database.AddInParameter(command, "Name", DbType.String, entity.Name);
            Database.AddInParameter(command, "SuiteName", DbType.String, entity.SuiteName);
            Database.AddInParameter(command, "Type", DbType.Int32, entity.Type);
            Database.AddInParameter(command, "Priority", DbType.Int32, entity.Priority);
            Database.AddInParameter(command, "Feature", DbType.String, entity.Feature);
            Database.AddInParameter(command, "Module", DbType.String, entity.Module);
            Database.AddInParameter(command, "Owner", DbType.String, entity.Owner);

            if (entity.CreateTime.HasValue)
            {
                Database.AddInParameter(command, "CREATETIME", DbType.DateTime, entity.CreateTime.Value);
            }
            else
            {
                Database.AddInParameter(command, "CREATETIME", DbType.DateTime, DBNull.Value);
            }

            if (entity.SyncTime.HasValue)
            {
                Database.AddInParameter(command, "SYNCTIME", DbType.DateTime, entity.SyncTime.Value);
            }
            else
            {
                Database.AddInParameter(command, "SYNCTIME", DbType.DateTime, DBNull.Value);
            }

            Database.AddInParameter(command, "FullName", DbType.String, entity.FullName);
            Database.AddInParameter(command, "Assembly", DbType.String, entity.Assembly);


            return(Convert.ToInt64(Database.ExecuteScalar(command)));
        }
コード例 #18
0
        private void mWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            ScriptEntitys.Clear();

            string            scriptTypes = "script|warp|shop|cashshop|monster|boss_monster|mapflag";
            Regex             regexEntity = new Regex("^(.+)\t(" + scriptTypes + ")\t(.+)\t([^{\n]*){?", RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.Compiled);
            MatchCollection   matches     = regexEntity.Matches(mText);
            int               matchCount  = matches.Count;
            List <FoldMarker> newFoldings = new List <FoldMarker>();

            foreach (Match match in matches)
            {
                string matchString = match.Groups[0].Captures[0].Value.TrimEnd();                 // trim possible \r
                string w1          = match.Groups[1].Captures[0].Value;
                string w2          = match.Groups[2].Captures[0].Value;
                string w3          = match.Groups[3].Captures[0].Value;
                string w4          = match.Groups[4].Captures[0].Value;
                int    offsetStart = match.Index;
                int    offsetEnd   = 0;
                string safeW2      = w2.ToLower().Trim();
                if (safeW2 == "monster" || safeW2 == "boss_monster" || safeW2 == "shop" || safeW2 == "cashshop")
                {
                    offsetEnd = match.Index + matchString.Length;
                }
                else
                {
                    // Search closing bracket
                    offsetEnd = GetBodyEnd(match.Index + matchString.Length);
                    // Add folding
                    newFoldings.Add(new FoldMarker(Editor.Document, offsetStart + match.Length - 1, (offsetEnd - offsetStart - match.Length + 1), "...", false));
                }

                ScriptEntity en = ScriptEntityFactory.CreateEntity(w1, w2, w3, w4, offsetStart, offsetEnd);
                ScriptEntitys.Add(en);
            }

            matches = null;
            mText   = null;

            Editor.Document.FoldingManager.UpdateFoldings(newFoldings);
        }
コード例 #19
0
ファイル: ScriptServices.cs プロジェクト: zoath/clonedeploy
        private ValidationResultDTO ValidateScript(ScriptEntity script, bool isNewScript)
        {
            var validationResult = new ValidationResultDTO {
                Success = true
            };

            if (string.IsNullOrEmpty(script.Name) || !script.Name.All(c => char.IsLetterOrDigit(c) || c == '_'))
            {
                validationResult.Success      = false;
                validationResult.ErrorMessage = "Script Name Is Not Valid";
                return(validationResult);
            }

            if (isNewScript)
            {
                if (_uow.ScriptRepository.Exists(h => h.Name == script.Name))
                {
                    validationResult.Success      = false;
                    validationResult.ErrorMessage = "This Script Already Exists";
                    return(validationResult);
                }
            }
            else
            {
                var originalScript = _uow.ScriptRepository.GetById(script.Id);
                if (originalScript.Name != script.Name)
                {
                    if (_uow.ScriptRepository.Exists(h => h.Name == script.Name))
                    {
                        validationResult.Success      = false;
                        validationResult.ErrorMessage = "This Script Already Exists";
                        return(validationResult);
                    }
                }
            }

            return(validationResult);
        }
コード例 #20
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.CreateGlobal);
            var script = new ScriptEntity
            {
                Name        = txtScriptName.Text,
                Description = txtScriptDesc.Text
            };
            var fixedLineEnding = scriptEditor.Value.Replace("\r\n", "\n");

            script.Contents = fixedLineEnding;
            var result = Call.ScriptApi.Post(script);

            if (result.Success)
            {
                EndUserMessage = "Successfully Created Script";
                Response.Redirect("~/views/global/scripts/edit.aspx?cat=sub1&scriptid=" + result.Id);
            }
            else
            {
                EndUserMessage = result.ErrorMessage;
            }
        }
コード例 #21
0
        public void GetScriptsDataTest()
        {
            ScriptEntity script1 = new ScriptEntity()
            {
                CaseID = "TA-Example-001", ManualCaseID = "Manual_ID_082"
            };
            ScriptEntity script2 = new ScriptEntity()
            {
                CaseID = "TA-Example-007", ManualCaseID = "Manual_ID_073"
            };
            ScriptEntity script3 = new ScriptEntity()
            {
                CaseID = "TA-Trial-001", ManualCaseID = "Manual_ID_064"
            };

            long result  = ScriptDA.Create(script1);
            long result2 = ScriptDA.Create(script2);
            long result3 = ScriptDA.Create(script3);

            string exportFileName = String.Empty;

            ll.Export(out exportFileName);
        }
コード例 #22
0
ファイル: edit.aspx.cs プロジェクト: zoath/clonedeploy
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            RequiresAuthorization(AuthorizationStrings.UpdateGlobal);
            var script = new ScriptEntity
            {
                Id          = Script.Id,
                Name        = txtScriptName.Text,
                Description = txtScriptDesc.Text
            };
            var fixedLineEnding = scriptEditor.Value.Replace("\r\n", "\n");

            script.Contents = fixedLineEnding;
            var result = Call.ScriptApi.Put(script.Id, script);

            if (result.Success)
            {
                EndUserMessage = "Successfully Updated Script";
            }
            else
            {
                EndUserMessage = result.ErrorMessage;
            }
        }
コード例 #23
0
ファイル: TabScript.cs プロジェクト: thankhuong/autolead_pc
 private void loadScriptsRRSApp()
 {
     if (this.listScriptRRS.Count == 0)
     {
         return;
     }
     if (this.DeviceInfo.SerialNumber != null && File.Exists(AppDomain.CurrentDomain.BaseDirectory + this.DeviceInfo.SerialNumber + "\\scriptsRRS.txt"))
     {
         string value             = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + this.DeviceInfo.SerialNumber + "\\scriptsRRS.txt");
         List <ScriptEntity> list = (List <ScriptEntity>)JsonConvert.DeserializeObject(value, typeof(List <ScriptEntity>));
         try
         {
             using (List <ScriptEntity> .Enumerator enumerator = list.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     ScriptEntity entity       = enumerator.Current;
                     ScriptEntity scriptEntity = this.listScriptRRS.FirstOrDefault((ScriptEntity x) => x.scriptAppID == entity.scriptAppID);
                     if (scriptEntity == null)
                     {
                         this.listScriptRRS.Add(entity);
                     }
                     else
                     {
                         scriptEntity.scriptIndex      = entity.scriptIndex;
                         scriptEntity.scriptKey        = entity.scriptKey;
                         scriptEntity.scriptAppName    = entity.scriptAppName;
                         scriptEntity.scriptDictionary = entity.scriptDictionary;
                     }
                 }
             }
         }
         catch (Exception)
         {
         }
     }
 }
コード例 #24
0
        private void tvwSource_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                var selectedNode = ((TreeView)sender).SelectedNode;

                if (selectedNode is IncidenciaTreeNode)
                {
                    try
                    {
                        string  path = ((IssueEntity)((IncidenciaTreeNode)selectedNode).Tag).PathFisico;
                        Process p    = new Process();
                        p.StartInfo = new ProcessStartInfo("explorer.exe", path);
                        p.Start();
                    }
                    catch (Exception ex)
                    {
                        string mensaje = ex.Message;
                    }
                }
                else if (selectedNode is FileTreeNode)
                {
                    try
                    {
                        ScriptEntity script       = (ScriptEntity)((ScriptTreeNode)selectedNode.Parent).Tag;
                        string       path         = script.IssueEntity.PathFisico;
                        string       filename     = selectedNode.Text;
                        string       fullFileName = path + @"\\" + filename;
                        new frmFileEdit(fullFileName).ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        string mensaje = ex.Message;
                    }
                }
            }
        }
コード例 #25
0
        private void singleAutoLead(offerItem item)
        {
            int index = this.offerListItem.IndexOf(item);

            this.lblStatusMsg.Invoke(new MethodInvoker(delegate
            {
                this.lblStatusMsg.Text = "Running :" + this.listViewOffer.Items[index].Text;

                this.listViewOffer.Items[index].UseItemStyleForSubItems = false;

                this.listViewOffer.Items[index].SubItems[0].BackColor = Color.Lime;

                this.listViewOffer.Items[index].SubItems[1].BackColor = Color.Yellow;

                this.listViewOffer.Refresh();
            }));

            openOfferLink(item);

            bool fullWipe = false;

            this.listViewOffer.Invoke(new MethodInvoker(delegate
            {
                this.listViewOffer.Items[index].SubItems[2].BackColor = Color.Lime;
                this.listViewOffer.Items[index].SubItems[3].BackColor = Color.Yellow;
                this.listViewOffer.Refresh();
                fullWipe = this.cbWipeFull.Checked;
            }));


            if (fullWipe)
            {
                installAppAndWait(item.appID);
                refreshAppListAndWait();
                while (!isAppInstalled(item.appID))
                {
                    updateProcessLog("App not installed");
                    Thread.Sleep(3000);
                }
            }


            int timesleep = item.timeSleepBefore;

            if (item.timeSleepBeforeRandom)
            {
                Random random5 = new Random();
                timesleep = random5.Next(item.timeSleepBeforeMin, item.timeSleepBeforeMax);
                this.listViewOffer.Invoke(new MethodInvoker(delegate
                {
                    this.listViewOffer.Items[index].SubItems[3].Text = timesleep.ToString();
                }));
            }

            for (int i = 0; i < timesleep; i++)
            {
                this.lblStatusMsg.Invoke(new MethodInvoker(delegate
                {
                    this.lblStatusMsg.Text = "Sleeping for " + (timesleep - i - 1).ToString() + " seconds";
                }));
                Thread.Sleep(1000);
            }


            if (!NetworkHelper.isHostUp(this.ipProxyHost.Text, (int)this.numProxyPort.Value))
            {
                throw new Exception("Error proxy die");
            }

            this.cmdResult.openApp = 0;
            this.lblStatusMsg.Invoke(new MethodInvoker(delegate
            {
                this.lblStatusMsg.Text = "Opening Aplication...";
            }));
            this.cmd.openApp(item.appID);

            DateTime now4           = DateTime.Now;
            int      maxTimeOpenApp = 0;

            this.btnConnectDevice.Invoke(new MethodInvoker(delegate
            {
                maxTimeOpenApp = (int)this.numMaxWait.Value;
            }));
            while (this.cmdResult.openApp != 1)
            {
                Thread.Sleep(100);
                if ((DateTime.Now - now4).TotalSeconds > (double)maxTimeOpenApp)
                {
                    throw new TimeoutException("Open app timeouted");
                }
            }

            Thread.Sleep(2000);

            if (this.cmdResult.openApp == 1)
            {
                for (int j = 0; j < Convert.ToInt32(item.timeSleep); j++)
                {
                    Thread.Sleep(1000);

                    int secondRemain = Convert.ToInt32(item.timeSleep) - j;
                    this.listViewOffer.Invoke(new MethodInvoker(delegate
                    {
                        this.listViewOffer.Items[index].SubItems[3].Text = secondRemain.ToString();
                        this.lblStatusMsg.Text = "Application will be closed in " + secondRemain.ToString() + " sec";
                    }));
                }


                this.listViewOffer.Invoke(new MethodInvoker(delegate
                {
                    this.listViewOffer.Items[index].SubItems[3].Text      = item.timeSleep.ToString();
                    this.listViewOffer.Items[index].SubItems[3].BackColor = Color.Lime;
                    this.listViewOffer.Refresh();
                }));

                if (this.cbServerOffer.Checked)
                {
                    this.excuteScript(item.script);
                }
                else
                {
                    IEnumerable <ScriptEntity> source = this.listScriptAL;

                    ScriptEntity scriptEntity = source.FirstOrDefault(((ScriptEntity x) => x.scriptAppID == item.appID));
                    if (scriptEntity != null & scriptEntity.scriptDictionary.Keys.Count > 0)
                    {
                        Random random6 = new Random();
                        string script  = (scriptEntity.scriptKey == "Random") ? scriptEntity.scriptDictionary.ElementAt(random6.Next(0, scriptEntity.scriptDictionary.Keys.Count)).Value : scriptEntity.scriptDictionary[scriptEntity.scriptKey];
                        this.excuteScript(script);
                    }
                }

                this.listViewOffer.Invoke(new MethodInvoker(delegate
                {
                    this.listViewOffer.Refresh();
                }));

                this.cmd.closeApp(item.appID);
                Thread.Sleep(3000);
            }
            else
            {
                throw new Exception("Open app unknown error");
            }
        }
コード例 #26
0
ファイル: ScriptDomainService.cs プロジェクト: yescent/emud
        public async Task Update(ScriptEntity entity)
        {
            await _scriptRepository.Update(entity);

            await _bus.RaiseEvent(new EntityUpdatedEvent <ScriptEntity>(entity)).ConfigureAwait(false);
        }
コード例 #27
0
ファイル: ScriptDomainService.cs プロジェクト: yescent/emud
 public async Task Add(ScriptEntity entity)
 {
     await _scriptRepository.Add(entity);
 }
コード例 #28
0
        private void openAppAndrunRRSS(BackupObj item)
        {
            ListViewItem currentlistview = getRRSListViewItemFromBackupObj(item);

            this.lblStatusMsg.Invoke(new MethodInvoker(delegate
            {
                this.lblStatusMsg.Text = "Opening application....";
            }));

            foreach (string appID in item.appList)
            {
                this.cmdResult.openApp = 0;
                this.cmd.openApp(appID);
                while (this.cmdResult.openApp != 0)
                {
                    Thread.Sleep(1000);
                    if ((DateTime.Now - DateTime.Now).TotalSeconds > (double)this.maxTimeOpenApp)
                    {
                        throw new Exception("open application timeout");
                    }
                }

                int waittime = 20;
                this.rsswaitnum.Invoke(new MethodInvoker(delegate
                {
                    waittime = (int)this.rsswaitnum.Value;
                }));

                for (int i = 0; i < waittime; i++)
                {
                    Thread.Sleep(1000);
                    this.lblStatusMsg.Invoke(new MethodInvoker(delegate
                    {
                        this.lblStatusMsg.Text = "Application will be closed in " + (waittime - i - 1).ToString() + " seconds";
                    }));
                }

                string scriptText = "";
                string key        = "";
                this.lblStatusMsg.Invoke(new MethodInvoker(delegate
                {
                    if (this.useScriptWhenRRS.Checked)
                    {
                        ScriptEntity scriptEntity = this.listScriptRRS.FirstOrDefault((ScriptEntity x) => x.scriptAppID == appID);
                        if (scriptEntity != null & scriptEntity.scriptDictionary.Keys.Count > 0)
                        {
                            Random random3 = new Random();
                            int index      = random3.Next(0, scriptEntity.scriptDictionary.Keys.Count);
                            if (scriptEntity.scriptKey == "Random")
                            {
                                scriptText = scriptEntity.scriptDictionary.ElementAt(index).Value;
                                key        = scriptEntity.scriptDictionary.ElementAt(index).Key;
                            }
                            else
                            {
                                scriptText = scriptEntity.scriptDictionary[scriptEntity.scriptKey];
                                key        = scriptEntity.scriptKey;
                            }
                        }

                        this.lblStatusMsg.Text = "Running script " + key;
                    }
                }));

                if (scriptText != "")
                {
                    this.excuteScript(scriptText);
                }
            }

            base.Invoke(new MethodInvoker(delegate
            {
                this.listViewRRS.SelectedIndices.Clear();
                currentlistview.Selected = true;
            }));

            this.cmd.closeApp("all");
            Thread.Sleep(3000);

            this.saverrsthread(currentlistview);
            base.Invoke(new MethodInvoker(delegate
            {
                currentlistview.BackColor = Color.Lime;
                currentlistview.Checked   = false;
                this.listViewRRS.Refresh();
                this.savecheckedssh();
            }));
        }
コード例 #29
0
        /// <summary>
        ///   Recursively scripts all objects in the collection while walking the dependency tree to ensure
        ///   child or parent objects are dropped/created appropriately
        /// </summary>
        protected virtual void RecurseScript(Server server, 
                                             StringCollection output,
                                             ScriptNameObjectBase dbobject, 
                                             ScriptingOptions scriptOptions,
                                             ScriptEntity entity,
                                             bool parents)
        {
            if (dbobject == null || entity == null)
                return;

            LogMessage("Checking {0} '{1}'", dbobject.GetType().Name, dbobject.Name);

            if (CheckIsSystemObject(dbobject) || entity.HasBeenScripted || !Filter.IsMatch(dbobject.Name))
                return;

            entity.HasBeenScripted = true;

            var dependencies = parents ? entity.EntitiesWhichIDependOn : entity.EntitiesWhichDependOnMe;

            foreach (var dependencyEntity in dependencies)
            {
                if (dependencyEntity != entity &&
                    dependencyEntity.HasBeenScripted == false)
                {
                    RecurseScript(server,
                                  output,
                                  GetObjectByName(dependencyEntity.Schema, dependencyEntity.Name),
                                  scriptOptions,
                                  dependencyEntity,
                                  parents);
                }
            }

            LogMessage("Scripting {0} '{1}'", dbobject.GetType().Name, dbobject.Name);

            var scriptOutput = ((IScriptable)dbobject).Script(scriptOptions);
            var entries = new string[scriptOutput.Count + 1];
            scriptOutput.CopyTo(entries, 0);
            entries[entries.Length - 1] = "GO";
            output.AddRange(entries);
        }
コード例 #30
0
 public static IObservable <StateChange <ScriptEntity, EntityState <ScriptAttributes> > > StateAllChangesWithCurrent(this ScriptEntity entity)
 {
     return(entity.StateAllChangesWithCurrent <ScriptEntity, EntityState <ScriptAttributes>, ScriptAttributes>());
 }
コード例 #31
0
 public ActionResultDTO Post(ScriptEntity script)
 {
     return(_scriptServices.AddScript(script));
 }