public List <DateTime> DatabaseDateQuery() { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection List <DateTime> Date = new List <DateTime>(); using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { string queryString = $"select S.[Date] from Stocks as S order by S.Date DESC"; SqlCommand command = new SqlCommand(queryString, connection); // command.Parameters.AddWithValue($"Date", "Date"); connection.Open(); // opens the connection to the database using (SqlDataReader reader = command.ExecuteReader()) // opens the datareader to retrieve data with query { while (reader.Read()) { Date.Add(Convert.ToDateTime(reader[$"Date"])); } } connection.Close(); } return(Date); }
void UploadProfileImage(EditUserInfo info, string path) { if (path != null) { // Crop and Resize image System.Drawing.Image img = ProcessImage(path); if (img != null) { // Generate random file name for processed/temp image (to be saved in temp folder) string newFilename = String_Functions.RandomString(20); // Get file extension of original file string ext = Path.GetExtension(path); // Make sure Temp directory exists FileLocations.CreateTempDirectory(); // Create new full path of temp file string localPath = Path.Combine(FileLocations.TrakHoundTemp, newFilename); //if (ext != null) localPath += "." + ext; if (ext != null) { localPath = Path.ChangeExtension(localPath, ext); } // Save the processed image to the new temp path img.Save(localPath); // Create a temp UserConfiguration object to pass the current SessionToken to the Files.Upload() method var userConfig = new UserConfiguration(); userConfig.SessionToken = info.SessionToken; // Set the HTTP Content Type based on the type of image string contentType = null; if (ext == "jpg") { contentType = "image/jpeg"; } else if (ext == "png") { contentType = "image/png"; } else if (ext == "gif") { contentType = "image/gif"; } var fileData = new HTTP.FileContentData("uploadimage", localPath, contentType); // Upload File var uploadInfos = TrakHound.API.Files.Upload(userConfig, fileData); if (uploadInfos != null && uploadInfos.Length > 0) { string fileId = uploadInfos[0].Id; info.ImageUrl = fileId; } } } }
private async Task <CreateTransferResult> UpdateFileTransferAsync(PictureparkAsset asset) { var transferIdentifier = $"Smint.io Update Import {Guid.NewGuid().ToString()}"; var localFile = await asset.GetDownloadedFileAsync(); var filePaths = new FileLocations[] { new FileLocations(localFile.FullName, asset.RecommendedFileName, asset.RecommendedFileName) }; var request = new CreateTransferRequest { Name = transferIdentifier, TransferType = TransferType.FileUpload, Files = new TransferUploadFile[] { new TransferUploadFile() { FileName = asset.RecommendedFileName } } }; var uploadOptions = new UploadOptions { ChunkSize = 1024 * 1024, ConcurrentUploads = 4, SuccessDelegate = Console.WriteLine, ErrorDelegate = ErrorDelegate, WaitForTransferCompletion = true }; return(await _client.Transfer.UploadFilesAsync(transferIdentifier, filePaths, uploadOptions)); }
/// <summary> /// Downloads the AppInfo using the given Url, parses the file, and returns the AppInfo object /// </summary> /// <param name="url"></param> /// <returns></returns> public static AppInfo Get(string url) { // Create local path to download 'appinfo' file to string path = FileLocations.CreateTempPath(); // Download File Logger.Log("Downloading AppInfo File...", LogLineType.Notification); if (Download(url, path)) { // Parse File as AppInfo class var info = Parse(path); // Delete temp file if (File.Exists(path)) { File.Delete(path); } return(info); } else { return(null); } }
static void LoadResources() { foreach (var file in FileLocations.GetAllSubFiles(FileLocations.GetApplicationDataDir("packages"), "*.pack")) { AssetManager.AddProvider(new PackAssetProvider(file)); } foreach (var file in FileLocations.GetAllSubFiles(FileLocations.GetApplicationDataDir("packages"), "*.zip")) { AssetManager.AddProvider(new ZipPackageAssetProvider(file)); } FileLocations.AddUserAndApplicationSubDirAssets("assets"); FileLocations.AddUserAndApplicationSubDirAssets("music"); foreach (var file in FileLocations.GetAllSubFiles(FileLocations.GetUserDataSubDir("packages"), "*.pack")) { AssetManager.AddProvider(new PackAssetProvider(file)); } foreach (var file in FileLocations.GetAllSubFiles(FileLocations.GetUserDataSubDir("packages"), "*.zip")) { AssetManager.AddProvider(new ZipPackageAssetProvider(file)); } }
/// <summary> /// Returns the 50 most recent closing prices from the selected symbol. /// </summary> /// <param name="database"></param> /// <param name="stock"></param> /// <returns></returns> public List <double> NiftyFiftyQuery(string stock) /// TODO: make this method able to retrieve any price. { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection List <double> Close = new List <double>(); using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { string queryString = $"SELECT TOP (50)(S.[Close] ) FROM Stocks AS S WHERE S.[Symbol] = '{stock}'ORDER BY S.[Date] desc;"; SqlCommand command = new SqlCommand(queryString, connection); // command.Parameters.AddWithValue($"{stock}", stock); connection.Open(); // opens the connection to the database using (SqlDataReader reader = command.ExecuteReader()) // opens the datareader to retrieve data with query { while (reader.Read()) { Close.Add(Convert.ToDouble(reader["Close"])); } } connection.Close(); } return(Close); }
private static void AddControlPanelApplets(SpecialCommandConfigurationElementCollection commands) { string controlPanelImage = FileLocations.ControlPanelImage; if (!File.Exists(controlPanelImage)) { SaveBitmap(Properties.Resources.ControlPanel, controlPanelImage); } foreach (FileInfo file in SystemRoot.GetFiles("*.cpl")) { var command = new SpecialCommandConfigurationElement(file.Name); command.Thumbnail = controlPanelImage; string thumbName = FileLocations.FormatThumbFileName(file.Name); Icon[] fileIcons = IconHandler.IconHandler.IconsFromFile(file.FullName, IconHandler.IconSize.Small); if (fileIcons != null && fileIcons.Length > 0) { SaveIcon(fileIcons[0], thumbName); } if (File.Exists(thumbName)) { command.Thumbnail = thumbName; } command.Name = EnsureAppletName(file); command.Executable = @"%systemroot%\system32\" + file.Name; commands.Add(command); } }
public void SaveToTableWebResult(List <PeregrineResults> results) { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection try { using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; for (int i = 0; i < results.Count; i++) { transaction = connection.BeginTransaction($"Transaction {i}"); command.Connection = connection; command.Transaction = transaction; command.CommandText = $"Insert into [Peregrine Results] ([Date],[CIK],[Symbol],[Last Close],[50 Day Avg], [Name], [Address 1], [Address 2]," + $"[City / State], [Phone], [SIC], [Industry], [MACD], [MACD Signal], [Stochastic Slow], [Stochastic Signal]) " + $"Values (Convert(Date,'{results[i].Date}'),{results[i].CIK}, '{results[i].Symbol.Trim()}',{results[i].LastClose}," + $"{results[i].FiftyDay}, '{results[i].Name.Trim()}', '{results[i].Address1.Trim()}', '{results[i].Address2.Trim()}', '{results[i].CityState.Trim()}'," + $"'{results[i].Phone.Trim()}', {results[i].SIC}, '{results[i].Industry.Trim()}',{results[i].MACD},{results[i].MACDSignal}," + $"{results[i].Stochastic}, {results[i].StochasticSignal});"; command.ExecuteNonQuery(); transaction.Commit(); } } } // If Address 2 is Null the null ref ex is caught and the insert is tried without reference to address 2 allowing it to enter the table as a null ref. catch (NullReferenceException) { using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; for (int i = 0; i < results.Count; i++) { transaction = connection.BeginTransaction($"Transaction {i}"); command.Connection = connection; command.Transaction = transaction; command.CommandText = $"Insert into [Peregrine Results] ([Date],[CIK],[Symbol],[Last Close],[50 Day Avg], [Name], [Address 1], [Address 2]," + $"[City / State], [Phone], [SIC], [Industry], [MACD], [MACD Signal], [Stochastic Slow], [Stochastic Signal]) " + $"Values (Convert(Date,'{results[i].Date}'),{results[i].CIK}, '{results[i].Symbol.Trim()}',{results[i].LastClose}," + $"{results[i].FiftyDay}, '{results[i].Name.Trim()}', '{results[i].Address1.Trim()}', ' ', '{results[i].CityState.Trim()}'," + $"'{results[i].Phone.Trim()}', {results[i].SIC}, '{results[i].Industry.Trim()}',{results[i].MACD},{results[i].MACDSignal}," + $"{results[i].Stochastic}, {results[i].StochasticSignal});"; command.ExecuteNonQuery(); transaction.Commit(); } } } }
public GuildWarsModule() { xmlDatabase.Load(FileLocations.xmlDatabase()); root = xmlDatabase.DocumentElement; // GW specific settings guildWarsNode = CoOpGlobal.XML.findOrCreateChild(xmlDatabase, root, "GuildWars"); guildIDNode = guildWarsNode.SelectSingleNode("descendant::GuildId"); guildAccessTokenNode = guildWarsNode.SelectSingleNode("descendant::GuildAccessToken"); if (guildIDNode != null && guildAccessTokenNode != null) { guildId = guildIDNode.InnerText; guildAccessToken = guildAccessTokenNode.InnerText; } else { guildId = null; guildAccessToken = null; } // GW non tradeable items accountBoundItemsNode = CoOpGlobal.XML.findOrCreateChild(xmlDatabase, guildWarsNode, "AccountBoundItems"); }
public void Test_Language_Scan() { var languageConfig = LanguageConfigBuilder.Create() .WithSpecificDirectories( ScanLocations.GenerateScanDirectories( #if NET471 "net471", #else "netcoreapp3.0", #endif "Application.Demo", "Application.Demo.Addon", "Application.Demo.MetroAddon", "Application.Demo.OverlayAddon").ToArray() ) .BuildLanguageConfig(); var filePattern = new Regex(languageConfig.FileNamePattern, RegexOptions.Compiled); var groupedFiles = FileLocations.Scan(languageConfig.SpecifiedDirectories, filePattern) .GroupBy(x => x.Item2.Groups["IETF"].Value) .ToDictionary(group => group.Key, group => group.Select(x => x.Item1) .ToList()); var foundFiles = FileLocations.Scan(languageConfig.SpecifiedDirectories, filePattern).Select(tuple => tuple.Item1).Select(Path.GetFileName).ToList(); Assert.Contains("language_addon1-de-DE.xml", foundFiles); Assert.Contains("language_addon1-en-US.xml", foundFiles); }
public LoginPage() { _wait = new Waits(); _fileLocations = new FileLocations(); _elementActions = new ElementActions(); PageFactory.InitElements(BeforeHooks.driver, this); }
public string Save(int id, HttpPostedFileBase image, FileLocations location) { var path = string.Empty; try { var extension = Path.GetExtension(image.FileName); var folderPath = this.server.MapPath($"~/Content/DynamicResources/{location.ToString()}"); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } path = $"~/Content/DynamicResources/{location.ToString()}/{id}{extension}"; var serverPath = server.MapPath(path); image.SaveAs(serverPath); } catch { return(string.Empty); } return(path); }
//TODO: Complete the query. Check the Table. public void SaveToTableResult(string database, List <Results> results) { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; for (int i = 0; i < results.Count; i++) { transaction = connection.BeginTransaction($"Transaction {i}"); command.Connection = connection; command.Transaction = transaction; command.CommandText = $"Insert into Results ([Date],[CIK],[Symbol],[Last Close],[50 Day Avg],[MACD],[MACD Signal],[EMA 12],[EMA 26],[Stochastic Fast],[Stochastic Slow],[Stochastic Signal]) " + $"Values (Convert(Date,'{results[i].Date}'),{results[i].CIK}, '{results[i].Symbol.Trim()}',{results[i].LastClose}," + $"{results[i].FiftyDayAvg}, {results[i].mACD},{results[i].MACDSignal}, {results[i].EMA12},{results[i].EMA26}," + $"{results[i].StochasticFast},{results[i].StochasticSlow},{results[i].StochasticSignal});"; command.ExecuteNonQuery(); transaction.Commit(); } } }
public void TruncateStockTable(string tablename) { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { connection.Open(); // opens connection to SQL Database SqlCommand command = connection.CreateCommand(); // translates text to SQL commands for the database SqlTransaction transaction; transaction = connection.BeginTransaction("Truncate Table"); // transaction must have a name command.Connection = connection; command.Transaction = transaction; command.CommandText = $"TRUNCATE TABLE [{tablename}];"; command.ExecuteNonQuery(); transaction.Commit(); } }
/// <summary> /// Helper to create the location of a file /// </summary> /// <param name="checkStartupDirectory"></param> /// <param name="postfix"></param> /// <param name="specifiedDirectory"></param> /// <returns>File location</returns> private string CreateFileLocation(bool checkStartupDirectory, string postfix = "", string specifiedDirectory = null) { string file = null; if (specifiedDirectory != null) { file = Path.Combine(specifiedDirectory, $"{_iniFileConfig.FileName}{postfix}.{_iniFileConfig.IniExtension}"); } else { if (checkStartupDirectory) { var startPath = FileLocations.StartupDirectory; if (startPath != null) { file = Path.Combine(startPath, $"{_iniFileConfig.FileName}{postfix}.{_iniFileConfig.IniExtension}"); } } if (file is null || !File.Exists(file)) { var appDataDirectory = FileLocations.RoamingAppDataDirectory(_iniFileConfig.ApplicationName); file = Path.Combine(appDataDirectory, $"{_iniFileConfig.FileName}{postfix}.{_iniFileConfig.IniExtension}"); } } Log.Verbose().WriteLine("File location: {0}", file); return(file); }
public int DatabaseCIKQuery(string stock) { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection int CIK = 0; using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { string queryString = $"SELECT CIK FROM CentralIndexKey WHERE Symbol = '{stock}'"; // Query sent to SQL database SqlCommand command = new SqlCommand(queryString, connection); // command.Parameters.AddWithValue($"{stock}", stock); connection.Open(); // opens the connection to the database using (SqlDataReader reader = command.ExecuteReader()) // opens the datareader to retrieve data with query { while (reader.Read()) { CIK = Convert.ToInt32(reader["CIK"]); } } connection.Close(); } return(CIK); }
public double CloseQuery(string stock) /// TODO: make this method able to retrieve any price. { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection double Close = 0; using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { string queryString = $"select S.[Close] from Stocks as S where S.Symbol = '{stock}' order by S.Date ASC"; SqlCommand command = new SqlCommand(queryString, connection); // command.Parameters.AddWithValue($"{stock}", stock); connection.Open(); // opens the connection to the database using (SqlDataReader reader = command.ExecuteReader()) // opens the datareader to retrieve data with query { while (reader.Read()) { Close = Convert.ToDouble(reader[$"Close"]); } } connection.Close(); } return(Close); }
public void SaveToTableStockPrices(List <Stock> stock) { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { connection.Open(); SqlCommand command = connection.CreateCommand(); SqlTransaction transaction; for (int i = 0; i < stock.Count; i++) { transaction = connection.BeginTransaction($"Transaction {i}"); command.Connection = connection; command.Transaction = transaction; command.CommandText = $"Insert into Stocks ([StockID],[Symbol],[Date],[Open],[High],[Low],[Close],[Volume]) " + $"Values ({stock[i].CIK}, '{stock[i].Symbol.Trim()}', Convert(Date,'{stock[i].Date}'), {stock[i].OpenPrice}, " + $"{stock[i].HighPrice}, {stock[i].LowPrice},{stock[i].ClosePrice}, {stock[i].Volume});"; command.ExecuteNonQuery(); transaction.Commit(); } } }
/// <summary> /// Returns a list of distinct stock ticker symbols for the specified table. /// </summary> /// <param name="database"></param> /// <param name="table"></param> /// <returns></returns> public List <string> DatabaseSymbolListQuery(string table) { FileLocations locations = new FileLocations(); var connect = locations.DatabaseConnectionString(); // returns Database connectionstring for SQLConnection List <string> Symbol = new List <string>(); using (SqlConnection connection = new SqlConnection(connect.ConnectionString)) { string queryString = $"SELECT DISTINCT S.[Symbol] FROM [{table}] AS S ORDER BY S.Symbol ASC"; SqlCommand command = new SqlCommand(queryString, connection); // command.Parameters.AddWithValue($"Symbol", "Symbol"); connection.Open(); // opens the connection to the database using (SqlDataReader reader = command.ExecuteReader()) // opens the datareader to retrieve data with query { while (reader.Read()) { Symbol.Add(Convert.ToString(reader["Symbol"])); } } connection.Close(); } return(Symbol); }
private async Task convertToNewDbCommand() { XmlDocument xmlDatabase = new XmlDocument(); XmlNode dbRoot; XmlNode usersNode; IEnumerator usersEnumerator; try { xmlDatabase.Load(FileLocations.xmlDatabase()); dbRoot = xmlDatabase.DocumentElement; usersNode = CoOpGlobal.XML.findOrCreateChild(xmlDatabase, dbRoot, "Users"); usersEnumerator = usersNode.GetEnumerator(); while (usersEnumerator.MoveNext()) { XmlElement curNode = usersEnumerator.Current as XmlElement; User user = new User(); user.userID = ulong.Parse(curNode.GetAttribute("id")); user.steamID = CoOpGlobal.XML.findOrCreateChild(xmlDatabase, curNode, "steamID").InnerText; // curNode.SelectSingleNode("descendant::steamID").InnerText; user.gwAPIKey = CoOpGlobal.XML.findOrCreateChild(xmlDatabase, curNode, "gwAPIKey").InnerText; //curNode.SelectSingleNode("descendant::gwAPIKey").InnerText; user.insert(); } await ReplyAsync("Done"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void TestScanRegex() { var startupDirectory = FileLocations.StartupDirectory; var files = FileLocations.Scan(new[] { startupDirectory }, new Regex(@".*\.xml")); Assert.Contains(files, file => file.Item1.EndsWith("Dapplo.Addons.xml")); }
public Job(IGoogleService googleService, IAddressBuilder addressBuilder, IOptions <FileLocations> fileLocationOptions) { _googleService = googleService; _addressBuilder = addressBuilder; _fileLocations = fileLocationOptions.Value; }
public void TestScanFilePatternToRegex() { var startupDirectory = FileLocations.StartupDirectory; var regex = FileTools.FilenameToRegex("*", new[] { ".xml" }); var files = FileLocations.Scan(new[] { startupDirectory }, regex); Assert.Contains(files, file => file.Item1.EndsWith("Dapplo.Addons.xml")); }
public string GetChannelInboundFilepath(Channel channel) { string prefix = (!channel.InGameDll ? "outcmds" : "incmds"); string filename = string.Format("{0}_{1}.txt", prefix, channel.ProcessId); string filepath = System.IO.Path.Combine(FileLocations.GetRunningFolder(), filename); return(filepath); }
static void SavePrefs() { // save off the last good FSAA value PreferencesManager.Set(PrefNames.FSAA, WindowManager.MainWindowAAFactor); // TODO, save window positions and resolutions PreferencesManager.Save(FileLocations.GetOptionsFile()); }
static void LoadMods() { if (!PreferencesManager.GetValueB(PrefNames.ModName)) { return; } FileLocations.AddUserAndApplicationSubDirAssets("mods/" + PreferencesManager.Get(PrefNames.ModName)); }
public RSSSettings(FileLocations location) { Location = location; SaveRSSFeedsOnEveryRefresh = false; NotifyOnRSSErrors = true; EnabledRSSReader = true; IncrementalSearch = false; IntervalMinutes = 5; }
private Task DoDeleteFileLocation(object o) { return(Task.Factory.StartNew(() => { Parent.SyncContext.Post(c => { FileLocations.Remove((FileLocation)o); }, null); })); }
private static IEnumerable <TaskDataset> CreateDatasetChoices(FileLocations fileLocations) { yield return(new TaskDataset { DatasetName = "Small dataset", DatasetPath = fileLocations.SmallTaskList, SavePath = fileLocations.SmallAssignmentList }); yield return(new TaskDataset { DatasetName = "Large dataset", DatasetPath = fileLocations.LargeTaskList, SavePath = fileLocations.LargeAssignmentList }); }
public static bool Initialize() { if (!DirectoryLocations.Initialize() || !FileLocations.Initialize()) { return(false); } LogClassificationTypes.Initialize(); Logger.AddLog(new LogData("", LogTypes.Default.LogConfigIo, LogClassificationTypes.Information)); return(true); }