public ImportScriptPageViewModel() { _gridVisibility = "Hidden"; _messageVisibility = "Hidden"; _scriptDb = new ScriptDb(); _masterScriptDb = new MasterScriptDb(); }
public ScriptsWindowViewModel() { _scriptsDb = new ScriptDb(); _masterScriptDb = new MasterScriptDb(); var savedScripts = _masterScriptDb.GetMasterScript().Result.Scripts; ScriptsCollection = new ObservableCollection <Script>(savedScripts); }
/// <summary> /// Save data into sql /// </summary> /// <returns></returns> internal bool SaveSql() { try { using (ReadFile read = new ReadFile()) { using (Connection connection = new Connection(this.ConnectionString)) { List <string> tables = new List <string>(); if (this.IsTableSeparated == false) { ScriptDb.CreateTable(this.Table, this.DropTable, connection); } string sql = ScriptDb.Sql(this.Table, this.DropTable); foreach (Infors inf in read.Series(this.FileB3)) { System.Windows.Forms.Application.DoEvents(); if (!this.CheckCodneg(inf.Codneg)) { continue; } if (this.IsTableSeparated == true) { sql = ScriptDb.Sql(inf.Codneg, this.DropTable); if (this.DropTable && tables.Contains(inf.Codneg) == false) { ScriptDb.CreateTable(inf.Codneg, this.DropTable, connection); tables.Add(inf.Codneg); } } using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = sql; cmd.Parameters.AddWithValue("@Codneg", inf.Codneg); cmd.Parameters.AddWithValue("@Data", inf.Data); cmd.Parameters.AddWithValue("@Abertura", inf.Abertura); cmd.Parameters.AddWithValue("@Maxima", inf.Maxima); cmd.Parameters.AddWithValue("@Minima", inf.Minima); cmd.Parameters.AddWithValue("@Fechamento", inf.Fechamento); cmd.Parameters.AddWithValue("@Empresa", inf.Empresa); connection.Query(cmd); } } } } return(true); } catch (Exception ex) { throw; } return(false); }
public ScriptsWindowViewModel() { _scriptsDb = new ScriptDb(); _masterScriptDb = new MasterScriptDb(); var savedScripts = _scriptsDb.GetAllScripts().Result; foreach (var script in savedScripts) { ScriptsCollection.Add(script); } }
public AddScriptViewModel() { _scriptName = string.Empty; _scriptDescription = string.Empty; _scriptContent = string.Empty; _message = string.Empty; _messageVisibility = "Hidden"; _messageColor = string.Empty; _scriptDb = new ScriptDb(); _masterScriptDb = new MasterScriptDb(); _isDisabled = false; }
public ScriptsWindowViewModel() { _scriptsDb = new ScriptDb(); _masterScriptDb = new MasterScriptDb(); try { var savedScripts = _masterScriptDb.GetMasterScript().Result.Scripts; ScriptsCollection = new ObservableCollection <Script>(savedScripts); } catch (Exception ex) { Log.Logger.Error($"{Constants.GetMasterScript}: {Constants.Message}: {ex.Message}\n " + $"{Constants.StackTrace}: {ex.StackTrace}\n {Constants.InnerException}: {ex.InnerException}"); } }
private void ClearDatabase_Click(object sender, MouseButtonEventArgs e) { try { if (!this.provider.ValidConnectionString()) { return; } ScriptDb.ClearDatabase(this.provider.ConnectionString); MessageBox.Show("Processo concluído com sucesso!", "Atenção", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void Main() { try { API.Initialize(); //Basic security layer, each request has to contain a valid API Key ScriptDb.LoadScripts(); Quotes.Load(); TrackingListener.Init(); var serverSock = new NetworkServerSocket { ClientBufferSize = 4096, OnConnect = Connecting, OnReceive = Receiving, OnDisconnect = Disconnecting }; serverSock.Prepare(700, 100); serverSock.BeginAccept(); Console.Title = "BitFlash VOTC Service Host"; Service = new ServiceHost(typeof(Logic));//Everything thats used to configure the Server is found in the App.Config Service.Faulted += Service_Faulted; Service.Open(); Console.WriteLine("Service running and active on:"); Console.WriteLine(); foreach (var baseAddress in Service.BaseAddresses) { Console.WriteLine("\t" + baseAddress.AbsoluteUri); } Console.WriteLine(); Console.WriteLine("Create client code class by executing \n\n\tsvcutil.exe " + Service.BaseAddresses[0] + "?wsdl\n\nin the visual studio developer console!\n"); Console.WriteLine("Usually Found at\n\n\t'Microsoft Visual Studio 1X.0\\Common7\\Tools\\VsDevCmd.bat'\n\n"); Console.WriteLine("Press enter to terminate."); } catch (Exception exception) { Console.Write(exception); Console.ReadLine(); } Console.ReadLine(); Service.Close(); Shutdown(); }
public string ScriptSubmit(string[] incommingData, bool harm) { Commands = new List <string>(); Harmful = harm; Name = incommingData[0]; Author = incommingData[1]; App = incommingData[2]; Foreground = incommingData[3]; Description = incommingData[4]; HeaderImage = incommingData[5]; StoreBadge = incommingData[6]; Password = incommingData[7]; Category = harm ? Category.Harmful : Category.New; for (var I = 8; I < 1000; I++) { var s = incommingData[I]; _scriptStartIndex = I; if (s.Contains("using System")) { break; } Commands.Add(s); } var builder = new StringBuilder(); for (var I = _scriptStartIndex; I < incommingData.Length; I++) { builder.AppendLine(incommingData[I]); } Contents = builder.ToString(); if (!File.Exists(Kernel.ScriptLocation + Name + ".cs")) { Kernel.WriteLine("New Script uploaded: " + Name, ConsoleColor.Blue); Added = DateTime.UtcNow; Downloads = 0; Rating = 0; RatingsCount = 0; var json = JsonConvert.SerializeObject(this); File.WriteAllText(Kernel.ScriptLocation + Name + ".cs", json); Kernel.AllScripts.TryAdd(Name + ".cs", this); return("Script successfully uploaded!"); } Kernel.WriteLine("Script " + Name + " existed, waiting for password check...", ConsoleColor.Blue); dynamic obj = JsonConvert.DeserializeObject(File.ReadAllText(Kernel.ScriptLocation + Name + ".cs")); if (obj.Password.ToString() == Password) { Updated = DateTime.UtcNow; Category = Category.Updated; var json = JsonConvert.SerializeObject(this); File.WriteAllText(Kernel.ScriptLocation + Name + ".cs", json); Script s; Kernel.AllScripts.TryRemove(Name + ".cs", out s); Kernel.WriteLine("Script " + Name + " successfully updated!", ConsoleColor.Blue); Kernel.AllScripts.AddOrUpdate(Name + ".cs", this); return("Script successfully updated!"); } ScriptDb.SaveScripts(); return("Script name in use / Wrong password for update"); }
private static void Shutdown() { ScriptDb.SaveScripts(); }