// GET: Word public ActionResult Index() { _learnedWords = new LearnedWordXmlSource(ServerPath.MapUserVocabularyPath(UserName)); var words = _learnedWords.GetAll().ToList(); return(View(words)); }
/// <summary> /// 创建数据库连接和SqlCommand实例 /// </summary> public DataLogic() { ServerPath sp = new ServerPath(); string iniName = "DataBase"; //获取登录的服务器 string strServer = sp.sqlPath(iniName, "Server"); //获取登录的数据库名 string strDatabase = sp.sqlPath(iniName, "Data"); //获取登录用户 string strUserID = sp.sqlPath(iniName, "UserID"); //获取登录密码 string strPwd = sp.sqlPath(iniName, "Pwd"); //数据库连接字符串 string strConn = "Server = " + strServer + ";Database=" + strDatabase + ";User id=" + strUserID + ";PWD=" + strPwd; try { m_Conn = new SqlConnection(strConn); m_Cmd = new SqlCommand(); m_Cmd.Connection = m_Conn; } catch (Exception e) { throw e; } }
private List <WordInfo> ConvertToWordInfo(IEnumerable <KeyValuePair <string, int> > wordsCount) { LearnWord kostyl; LearnedWordXmlSource source = new LearnedWordXmlSource(ServerPath.MapUserVocabularyPath(User.Identity.Name)); List <WordInfo> wordsInfo = new List <WordInfo>(wordsCount.Count()); foreach (var pair in wordsCount) { WordInfo word = new WordInfo { WordString = pair.Key, Count = pair.Value }; if (source.IsLearned(pair.Key, out kostyl)) { word.Status = WordStatus.Learned; } else { word.Status = WordStatus.NotLearned; } wordsInfo.Add(word); } return(wordsInfo); }
public DownloadFileFromServer(DropBoxEvent @event, ICloudStorage cloudStorage, LocalFolderRoot root) { this.serverPath = @event.ServerPath; this.Title = "Download : " + this.serverPath.Value; this.cloudStorage = cloudStorage; this.root = root; }
public ServiceModule(IServiceMethodLocator serviceMethodLocator) { foreach (ServiceMethod serviceMethod in serviceMethodLocator.GetServiceMethods()) { ParameterInfo[] parameterInfos = serviceMethod.MethodInfo.GetParameters(); ServerPath serverPath = ServerPaths.GetServerPath(serviceMethod.AsyncServiceMethodInfo); Post[serverPath.SubPath, serverPath.FullPath, true] = async(x, ct) => { Task responseTask = (Task)serviceMethod.MethodInfo.Invoke( serviceMethod.Instance, parameterInfos.Select(CreateParameter).ToArray()); object result = await GetTaskResult(responseTask); Response response = JsonConvert.SerializeObject(result); response.ContentType = "application/json"; response.StatusCode = HttpStatusCode.OK; return(response); }; } }
public void DownloadFolderContent(IServerPath serverPath, ILocalPath localPath, ILogger logger) { var items = this.VersionControlServer.GetItems(serverPath.AsString(), VersionSpec.Latest, RecursionType.OneLevel); foreach (var item in items.Items) { if (0 == string.Compare(item.ServerItem, serverPath.AsString(), true)) { continue; } var itemServerPath = new ServerPath(item.ServerItem); var itemLocalPath = localPath.Subpath(itemServerPath.GetName()); if (item.ItemType == ItemType.File) { logger.Info($"Download file {item.ServerItem} to {itemLocalPath.AsString()}"); item.DownloadFile(itemLocalPath.AsString()); } else { DownloadFolderContent(itemServerPath, itemLocalPath, logger); } } }
public string GetLocalBuild(string serverId, string appId) { string manifestFile = $"appmanifest_{appId}.acf"; string manifestPath = Path.Combine(ServerPath.GetServersServerFiles(serverId), "steamapps", manifestFile); if (!File.Exists(manifestPath)) { Error = $"{manifestFile} is missing."; return(string.Empty); } string text; try { text = File.ReadAllText(manifestPath); } catch (Exception e) { Error = $"Fail to get local build {e.Message}"; return(string.Empty); } Regex regex = new Regex("\"buildid\".{1,}\"(.*?)\""); var matches = regex.Matches(text); if (matches.Count != 1 || matches[0].Groups.Count != 2) { Error = $"Fail to get local build"; return(string.Empty); } return(matches[0].Groups[1].Value); }
public void Test() { var serverPath = new ServerPath("$/GamingX/GGP/"); //var slnExplorer = new GGPSolutionStructureBuilder(); //slnExplorer.Build(); }
public async Task <Process> Install() { string version = await GetRemoteBuild(); if (version == null) { return(null); } string tarName = $"vs_server_{version}.tar.gz"; string address = $"https://cdn.vintagestory.at/gamefiles/stable/{tarName}"; string tarPath = ServerPath.GetServersServerFiles(_serverData.ServerID, tarName); // Download vs_server_{version}.tar.gz from https://cdn.vintagestory.at/gamefiles/stable/ using (WebClient webClient = new WebClient()) { try { await webClient.DownloadFileTaskAsync(address, tarPath); } catch { Error = $"Fail to download {tarName}"; return(null); } } // Extract vs_server_{version}.tar.gz if (!await FileManagement.ExtractTarGZ(tarPath, Directory.GetParent(tarPath).FullName)) { Error = $"Fail to extract {tarName}"; return(null); } // Delete vs_server_{version}.tar.gz, leave it if fail to delete await FileManagement.DeleteAsync(tarPath); return(null); }
public ServerFile(FileMetadata entry) { this.Path = ServerPath.FromServerPath(entry.PathLower); this.Bytes = (long)entry.Size; this.ServerModified = entry.ServerModified; this.ClientModified = entry.ClientModified; }
public void Test() { var serverPath = ServerPath.FromLocalPath(new LocalPath("hello", new LocalFolderRoot("World"))); var serverPath2 = ServerPath.FromLocalPath(new LocalPath("hello", new LocalFolderRoot("World"))); serverPath2.Should().Be(serverPath); }
/// <summary> /// Executes login. /// </summary> private void LoginExecute() { this.BusyCount++; this.LoginCommand.RaiseCanExecuteChanged(); #region prepare url string serverUrl = ServerPath; if (!ServerPath.StartsWith("http://") && !ServerPath.StartsWith("https://")) { serverUrl = string.Concat("http://", ServerPath); } if (!serverUrl.EndsWith("/")) { serverUrl = string.Concat(serverUrl, "/"); } #endregion try { Membership.CheckUserData(Login, Password, serverUrl, LoginCallback); } catch { this.BusyCount--; #if !UNIT_TEST MessageBox.Show((Application.Current.Resources["LanguageStrings"] as LanguageStrings).WRONG_SERVER_ADDRESS); #else RaiseTestCompleted("cannot locate server"); #endif } }
public bool DeleteDirectory(string directoryPath) { try { if (string.IsNullOrEmpty(ServerPath)) { throw RaiseException("DeleteDirectory", "未设置服务器文件目录!"); } if (string.IsNullOrEmpty(directoryPath) || ServerPath.EndsWith(directoryPath, StringComparison.CurrentCultureIgnoreCase)) { throw RaiseException("DeleteDirectory", "不能删除服务器根目录!"); } FileUtil.DeleteDirectory(ServerPath + @"\\" + directoryPath); //Directory.Delete(ServerPath + @"\\" + directoryPath, true); return(true); } catch (IOException e) { Log.Warn(e); throw RaiseException("DeleteDirectory", e.Message); } catch (Exception e) { Log.Warn(e); throw RaiseException("DeleteDirectory", e.Message); } }
public ActionResult AddToLearned(int fileId, string[] words) { _documentWords = new WordInfoXmlSource(ServerPath.MapDocumentPath(fileId.ToString())); _learnedWords = new LearnedWordXmlSource(ServerPath.MapUserVocabularyPath(UserName)); foreach (string word in words) { var wordInfo = _documentWords.Get(w => w.WordString == word); wordInfo.Status = Models.WordStatus.Learned; LearnWord outValue; bool learned = _learnedWords.IsLearned(word, out outValue); if (learned) { outValue.Documents.Add(fileId); } else { outValue = new LearnWord { WordString = word, Documents = new List <int> { fileId } }; _learnedWords.Add(outValue); } } _documentWords.Save(); _learnedWords.Save(); return(RedirectToAction("Load", "Home", new { fileId = fileId })); }
public async Task <Process> Install(string serverId, string modName, string appId, bool validate = true, bool loginAnonymous = true) { SetParameter(ServerPath.GetServersServerFiles(serverId), modName, appId, validate, loginAnonymous); Process p = await Run(); SendEnterPreventFreeze(p); return(p); }
public JsonConfig() { string path_fishlord = Path.Combine(ServerPath.getPathMediaRoot(), "Fishing\\FishLord\\"); string path_route = Path.Combine(ServerPath.getPathMediaRoot(), "Fishing\\Route\\"); json_packet_list = _readJsonPacketListFormFile(path_fishlord); route_json_packet_list = _readRouteJsonPacketListFormFile(path_route); }
private void TryConnectServer() { mWebSocket.Close(4999, "新連線"); Uri uri = new Uri(ServerPath); Debug.LogFormat("準備連線至 {0}:{1}", uri.Host, uri.Port); mWebSocket.Connect(uri.Host, uri.Port, ServerPath.Contains("https"), "null"); }
//------------------------------------------------------------------------- public override void init() { Init = false; CacheDesktopKey = "CacheDesktopData_" + Entity.Guid; DesktopConfigData = new Ps.DesktopConfigData(); DesktopConfigData.desktop_etguid = Entity.Guid; DesktopConfigData.seat_num = 6; DesktopConfigData.is_vip = false; DesktopConfigData.desktop_waitwhile_tm = 60; MapAllPlayer1 = new Dictionary <uint, Entity>(); MapAllPlayer = new Dictionary <string, Entity>(); byte index = 0; AllSeat = new SeatInfo[DesktopConfigData.seat_num]; foreach (var i in AllSeat) { SeatInfo seat_info = new SeatInfo(); seat_info.index = index; seat_info.et_player_rpcid = 0; seat_info.et_playermirror = null; AllSeat[index] = seat_info; index++; } DesktopInfo = new DesktopInfo(); DesktopInfo.desktop_etguid = Entity.Guid; DesktopInfo.seat_num = 6; DesktopInfo.desktop_tableid = 1; DesktopInfo.is_vip = false; DesktopInfo.list_seat_player = new List <DesktopPlayerInfo>(); DesktopInfo.all_player_num = 0; DesktopInfo.seat_player_num = 0; QueAoIEvent = new Queue <_tAoIEvent>(); QuePlayerId = new Queue <byte>(); MaxPlayerId = 0; for (int i = 0; i < 50; i++) { QuePlayerId.Enqueue(++MaxPlayerId); } TbDataRoom._eRoomType room_type = TbDataRoom._eRoomType.RT_Tenfold; bool fish_mustdie = true; bool is_single = false; float pumping_rate = 1f; string path_fishlord = Path.Combine(ServerPath.getPathMediaRoot(), "Fishing\\FishLord\\"); string path_route = Path.Combine(ServerPath.getPathMediaRoot(), "Fishing\\Route\\"); ILogicListener listener = new LogicListener(this); LogicScene = new CLogicScene(); LogicScene.create(1, 1.0f, is_single, fish_mustdie, listener, pumping_rate, _getRateList(room_type), CellApp.Instance.jsonCfg.json_packet_list, CellApp.Instance.jsonCfg.route_json_packet_list); }
public bool IsSubItemOf(string folderPath) { if (ServerPath.Equals(folderPath)) { return(true); } else { return(Path.Equals(Path.GetDirectoryName(ServerPath), folderPath)); } }
//TODO: change remove logic in XmlSource public ActionResult Remove(int fileId, string[] words) { _documentWords = new WordInfoXmlSource(ServerPath.MapDocumentPath(fileId.ToString())); foreach (var word in words) { var wordToRemove = _documentWords.Get(w => w.WordString == word); _documentWords.Remove(wordToRemove); } _documentWords.Save(); return(RedirectToAction("Load", "Home", new { fileId = fileId })); }
public async void CreateServerCFG() { //Download serverconfig.json var replaceValues = new List <(string, string)>() { ("{{ServerName}}", _serverData.ServerName), ("{{Port}}", _serverData.ServerPort), ("{{MaxClients}}", _serverData.ServerMaxPlayer) }; await Github.DownloadGameServerConfig(ServerPath.GetServersServerFiles(_serverData.ServerID, "data", "serverconfig.json"), FullName, replaceValues); }
private string GetFileDirectory(string directoryPath) { if (string.IsNullOrEmpty(ServerPath)) { throw RaiseException("GetFileDirectory", "未获取到服务器文件目录!"); } if (string.IsNullOrEmpty(directoryPath) || ServerPath.EndsWith(directoryPath, StringComparison.CurrentCultureIgnoreCase)) { return(ServerPath); } return(ServerPath + directoryPath + @"\\"); }
public ActionResult Load(int fileId) { string filePath = ServerPath.MapDocumentPath(fileId.ToString()); WordInfoXmlSource source = new WordInfoXmlSource(filePath); var model = new ContentViewModel { FileId = fileId, Words = source.GetNotLearned() }; return(View("Content", model)); }
public string GetLocalBuild() { // Get local version in VintageStoryServer.exe string exePath = ServerPath.GetServersServerFiles(_serverData.ServerID, StartPath); if (!File.Exists(exePath)) { Error = $"{StartPath} is missing."; return(string.Empty); } return(FileVersionInfo.GetVersionInfo(exePath).ProductVersion); // return "1.12.14" }
// New public static async Task <(Process, string)> UpdateEx(string serverId, string appId, bool validate = true, bool loginAnonymous = true, string modName = null, string custom = null, bool embedConsole = true) { string param = GetParameter(ServerPath.GetServersServerFiles(serverId), appId, validate, loginAnonymous, modName, custom); if (param == null) { return(null, "Steam account not set up"); } string exePath = Path.Combine(_installPath, _exeFile); if (!File.Exists(exePath) && !await Download()) { return(null, "Unable to download steamcmd"); } var p = new Process { StartInfo = { WorkingDirectory = _installPath, FileName = exePath, Arguments = param, WindowStyle = ProcessWindowStyle.Minimized, UseShellExecute = false }, EnableRaisingEvents = true }; if (embedConsole) { p.StartInfo.CreateNoWindow = true; p.StartInfo.StandardOutputEncoding = Encoding.UTF8; p.StartInfo.StandardErrorEncoding = Encoding.UTF8; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; var serverConsole = new ServerConsole(serverId); p.OutputDataReceived += serverConsole.AddOutput; p.ErrorDataReceived += serverConsole.AddOutput; p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); return(p, null); } p.Start(); return(p, null); }
public ActionResult Delete(int fileId) { string userName = User.Identity.Name; using (_context = new AppDbContext()) { var file = _context.Files.Find(fileId); //var user = _context.Users.First(u => u.UserName == userName); //user.Files.Remove(file); _context.Files.Remove(file); _context.SaveChanges(); } System.IO.File.Delete(ServerPath.MapDocumentPath(fileId.ToString())); return(RedirectToAction("DisplayFiles")); }
public async Task <FileMetadata> GetFileMetadata(ServerPath serverPath, CancellationToken token) { try { token.ThrowIfCancellationRequested(); var storedPath = serverPath.Value; var data = await this.client.Files.GetMetadataAsync(storedPath); return(data.IsFile ? data.AsFile : null); } catch (Exception e) { //Console.WriteLine (e.ToString()); return(null); } }
public static void AddCustomDbContext(this IServiceCollection services, IConfiguration configuration, Assembly startupAssembly) { string projectDir = ServerPath.GetProjectPath(startupAssembly); var connectionString = configuration.GetConnectionString("DefaultConnection") .Replace("|DataDirectory|", Path.Combine(projectDir, "wwwroot", "app_data")); services.AddDbContext <ApplicationDbContext>(options => { options.UseSqlServer(connectionString, serverDbContextOptionsBuilder => { var minutes = (int)TimeSpan.FromMinutes(3).TotalSeconds; serverDbContextOptionsBuilder.CommandTimeout(minutes); serverDbContextOptionsBuilder.EnableRetryOnFailure(); }); }); }
public async Task HandleDelta(Delta delta) { var batch = new ServerEventsBatch(); var entries = delta.Entries; var toAdd = entries.Where(it => it.IsFile).Select(it => it.AsFile).ToList(); var toDelete = entries.Where(it => it.IsDeleted).Select(it => it.AsDeleted).ToList(); foreach (var entry in toDelete) { var fileItem = this.Files.FirstOrDefault(it => it.Path.Value == entry.PathLower); if (fileItem != null) { this.Files.Remove(fileItem); } batch.Add(new DropBoxFileDeletedEvent(ServerPath.FromServerPath(entry.PathLower), delta.Cursor)); Console.WriteLine($"Deleted {fileItem}"); } foreach (var entry in toAdd) { var fileItem = this.Files.FirstOrDefault(it => it.Path.Value == entry.PathLower); if (fileItem == null) { var item = new ServerFile(entry); this.Files.Add(item); Console.WriteLine($"Added {item}"); batch.Add(new DropBoxFileAddedEvent(item.Path, delta.Cursor)); } else { fileItem.Bytes = (long)entry.Size; Console.WriteLine($"Changed {fileItem}"); this.Files.Remove(fileItem); this.Files.Add(fileItem); batch.Add(new DropBoxFileChangedEvent(fileItem.Path, delta.Cursor)); } } await this.listener.Handle(batch); }
private string MakeConnectionString() { if (ConnectionType == ConnectionType.Embedded) { return(String.Format("type=embedded;storesDirectory={0}", DirectoryPath)); } if (ConnectionType == ConnectionType.Http || ConnectionType == ConnectionType.Tcp) { var connString = new StringBuilder(); connString.Append(ConnectionType == ConnectionType.Http ? "type=http;endpoint=http://" : "type=tcp;endpoint=net.tcp://"); connString.Append(ServerName); if (!String.IsNullOrEmpty(ServerPort)) { connString.Append(":"); connString.Append(ServerPort); } if (!String.IsNullOrEmpty(ServerPath)) { if (!ServerPath.StartsWith("/")) { connString.Append("/"); } connString.Append(ServerPath); } return(connString.ToString()); } if (ConnectionType == ConnectionType.NamedPipe) { var connString = new StringBuilder(); connString.Append("type=namedpipe;endpoint=net.pipe://"); connString.Append(ServerName); if (!PipeName.StartsWith("/")) { connString.Append("/"); } connString.Append(PipeName); return(connString.ToString()); } throw new NotSupportedException(String.Format("Cannot generate connection string for connection type {0}", ConnectionType)); }