public async Task Wiki(string querry) { try { WikipediaClient wkclient = new WikipediaClient(); string arg = querry; if (arg != null) { string cont = await wkclient.Search(arg); string clncont = Regex.Replace(cont, @"([^a-zA-Z0-9_]|^\s)", string.Empty); string res = String.Format("You asked for :{0 }\n Answer: \n {1}", arg, cont); //await e.Channel.SendMessage(String.Format("You asked for :{0}\n",arg)); //await e.Channel.SendMessage(String.Format("Answer: \n {0}", cont)); string temp = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Temp"); if (Directory.Exists(temp) == true) { Directory.Delete(temp, true); } Directory.CreateDirectory(temp); string path = Path.Combine(temp, arg + ".txt"); File.WriteAllText(path, cont); Stream fil = File.OpenRead(path); // var stat =await e.Channel.SendMessage(res); if (cont.Length > 2000) { await Context.Channel.SendFileAsync(fil, path, String.Format("{0} You asked for :{1} " + "\n The answer exceeds the 2000 characters limit so it is saved on a plain text file" , Context.User.Mention, arg)); File.Delete(path); } else { await ReplyAsync(res); } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } // Console.WriteLine("Message State : {0} \n Message Text {1}", stat.State.ToString(), stat.Text); }
public async Task DeleteServerConfiguration(string ServerId) { try { if (String.IsNullOrWhiteSpace(ServerId) != true && await this.ServersConfigurationExists(ServerId) != false) { var x = await this.GetServersConfigurationById(ServerId); db.ServerConfiguration.Remove(x); db.SaveChanges(); } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public ActionResult GetRelatedWordList(string morphemeId, string excludedWordId) { int totalCount; var words = _searchService.GetWordListByMorpheme(morphemeId, excludedWordId, 11, out totalCount) .Select(word => new { word.Id, word.Stem, Interpretations = word.Interpretations.OrderBy(i => i.Order).Select(i => new { i.Interpretation, PartOfSpeech = CommonTools.GetEnumDescription(i.PartOfSpeech) }) }); return(JsonContent(words)); }
public List <Bugs> BugsByProjectId(int?projectid) { try { List <Bugs> ap = null; if (projectid > 0) { List <Bugs> b = this.db.Bugs.Where(x => x.Project.Id == projectid).ToList(); if (b != null) { ap = b; } } return(ap); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
public void Delete(FileReleases fileReleases) { try { if (fileReleases != null) { List <ProjectFiles> files = this.projfilmngr.DetailsByReleaseId(fileReleases.Id); foreach (var f in files) { projfilmngr.Delete(f); } db.FileReleases.Remove(fileReleases); db.SaveChanges(); } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
private bool ValidateNickName() { if (CommonTools.HasForbiddenWords(name.Text.Trim())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "namewrong", "document.getElementById('ctl00_ContentPlaceHolder1_nameTip').innerHTML = '您的昵称中有违禁字符,请重新输入!';document.getElementById('ctl00_ContentPlaceHolder1_nameTip').style['display']='block';document.getElementById('ctl00_ContentPlaceHolder1_nameTip').className='onError';", true); return(false); } USR_CustomerMod m_user = USR_CustomerBll.GetInstance().CheckNickName(name.Text.Trim()); if (m_user.SysNo != AppConst.IntNull) { Page.ClientScript.RegisterStartupScript(this.GetType(), "namewrong", "document.getElementById('ctl00_ContentPlaceHolder1_nameTip').innerHTML = '该昵称已被占用,请尝试使用其他昵称!';document.getElementById('ctl00_ContentPlaceHolder1_nameTip').style['display']='block';document.getElementById('ctl00_ContentPlaceHolder1_nameTip').className='onError';", true); return(false); } return(true); }
public void CreateBlog(Blog bl, string username) { try { ApplicationUser usr = null; if (bl != null && CommonTools.isEmpty(username) == false) { usr = CommonTools.usrmng.GetUser(username); if (usr != null) { bl.Administrator = usr.Id; //.Clone(); //bl.AdministratorId = bl.Administrator.Id; // bl.Moderators = new List<BlogMods>(); // BlogMods wm = new BlogMods(); // wm.Blog = bl; // wm.Moderator = usr.Id; //bl.Moderators.Add(wm); db.Add(bl); db.SaveChanges(); string blpath; //if (CommonTools.isEmpty(blrotfold )) //{ // blrotfold = "Blogfiles"; //} // blpath = "~/" + AppDataDir + "/" + blrotfold + "/" + bl.Name; blpath = FileSystemManager.GetBlogRootDataFolderAbsolutePath(bl.Name); if (FileSystemManager.DirectoryExists(blpath) == false) { FileSystemManager.CreateDirectory(blpath); } } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); //return null; } }
private void btnConfirm_Click(object sender, EventArgs e) { CoreManager.ConfigManager.Settings.DefaultSaveFolder = txtSavePath.Text; CoreManager.ConfigManager.Settings.HideSysTray = chbSysTray.Checked; CoreManager.ConfigManager.Settings.WatchClipboard = chbWatchClipboard.Checked; CoreManager.ConfigManager.Settings.Logging = chbLogging.Checked; CoreManager.ConfigManager.Settings.SubscribeTime = CommonTools.TryParse(txtSubTime.Text, 10) < 1 ? 10 : CommonTools.TryParse(txtSubTime.Text, 10); CoreManager.ConfigManager.Settings.TextEncoding = rbUnicode.Checked ? rbUnicode.Tag.ToString() : rbUTF8.Checked ? rbUTF8.Tag.ToString():"utf-16"; CoreManager.ConfigManager.Settings.SelectFormatName = ((CSNovelCrawler.Core.CustomSettings.FormatFileName_Class)(cb_Format.SelectedItem)).Name; CoreManager.ConfigManager.Settings.SelectFormat = ((CSNovelCrawler.Core.CustomSettings.FormatFileName_Class)(cb_Format.SelectedItem)).Format; CoreManager.ConfigManager.SaveSettings(); Close(); }
// // GET: /Test/ public ActionResult Index() { string ApiUrl = AliyunCommonParaConfig.ApiUrl; // 注意这里需要使用UTC时间,比北京时间少8小时。 string Timestamp = DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ", DateTimeFormatInfo.InvariantInfo); string Action = "GetVideoPlayAuth"; string SignatureNonce = CommonTools.EncryptToSHA1(CommonTools.GenerateRandomNumber(8)); string VideoId = "61823886c6614369a10025d6fd4fff07"; VideoInfo videoInfo = AliyunVideoServices.GetVideoInfo(ApiUrl, VideoId, Timestamp, Action, SignatureNonce); ViewBag.PlayAuth = videoInfo.PlayAuth; ViewBag.VideoId = VideoId; return(View()); // return RedirectToAction("Details", "Test", new { VideoId = VideoId, PlayAuth = videoInfo.PlayAuth }); }
public ApplicationUser GetUserbyID(string id) { try { ApplicationUser ap = null; if (id != null) { ap = (ApplicationUser)this.db.Users.First(u => u.Id == id); } return(ap); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
private async Task <Boolean> CheckIfMusicthreadExistsexists(ulong guildid) { try { Boolean a = false; a = Musicthreads.ContainsKey(guildid); return(a); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(false); } }
public async Task <BotGearUser> GetUserbyId(string id) { try { BotGearUser user = null; if (id != null) { user = db.Users.FirstOrDefault(x => x.Id == id); } return(user); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
private static string GenerationCardTemplate(string path, NewsPileUp.RssSource sourceName, IReadOnlyList <NewsPileUp> newsPileUps) { const string colTemplate = "<div class='card-item col-lg-3 col-md-3 col-sm-12 col-xs-12'>*|CONTENT|*</div>"; var newsTemplate = System.IO.File.ReadAllText(path + "Card.html"); var segmentSize = (int)Math.Round(newsPileUps.Count / 4.0); var cardHtml = ""; var content = ""; for (var i = 0; i < segmentSize; i++) { var news = newsPileUps[i]; content += string.Format(newsTemplate, news.ImageUrl, news.Title, news.Summary, CommonTools.Encrypt(news.Url), sourceName); } cardHtml += !string.IsNullOrEmpty(content) ? colTemplate.Replace("*|CONTENT|*", content) : ""; content = ""; for (var i = segmentSize; i < segmentSize * 2 && newsPileUps.Count >= segmentSize * 2; i++) { var news = newsPileUps[i]; content += string.Format(newsTemplate, news.ImageUrl, news.Title, news.Summary, CommonTools.Encrypt(news.Url), sourceName); } cardHtml += !string.IsNullOrEmpty(content) ? colTemplate.Replace("*|CONTENT|*", content) : ""; content = ""; for (var i = segmentSize * 2; i < segmentSize * 3 && newsPileUps.Count >= segmentSize * 3; i++) { var news = newsPileUps[i]; content += string.Format(newsTemplate, news.ImageUrl, news.Title, news.Summary, CommonTools.Encrypt(news.Url), sourceName); } cardHtml += !string.IsNullOrEmpty(content) ? colTemplate.Replace("*|CONTENT|*", content) : ""; content = ""; for (var i = segmentSize * 3; i < newsPileUps.Count; i++) { var news = newsPileUps[i]; content += string.Format(newsTemplate, news.ImageUrl, news.Title, news.Summary, CommonTools.Encrypt(news.Url), sourceName); } cardHtml += !string.IsNullOrEmpty(content) ? colTemplate.Replace("*|CONTENT|*", content) : ""; return(cardHtml); }
public async Task <BotGearPreBannedUser> GetPreBannedUserbyIdAndServerId(string id, string serverid) { try { BotGearPreBannedUser user = null; if (id != null && serverid != null) { user = db.PreBannedUsers.FirstOrDefault(x => x.UserId == id && x.ServerId == serverid); } return(user); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
public void LoginCheck(string username, string password) { SYS_AdminMod m_admin = SYS_AdminBll.GetInstance().CheckAdmin(username, password); if (m_admin.CustomerSysNo != AppConst.IntNull)//COOKIES验证成功 { WebForAnalyse.SessionInfo m_session = new SessionInfo(); m_session.AdminEntity = m_admin; m_session.PrivilegeDt = SYS_AdminBll.GetInstance().GetAdminPrivilege(m_admin.CustomerSysNo); Session[AppConfig.AdminSession] = m_session; //记住我 if (CheckBox1.Checked) { HttpCookie Cookie = CookiesHelper.GetCookie("upup1000Admin"); if (Cookie == null || Cookie.Value == null || Cookie.Value == "") { Cookie = new HttpCookie("upup1000Admin"); Cookie.Values.Add("uname", CommonTools.Encode(username)); Cookie.Values.Add("psd", CommonTools.Encode(password)); //设置Cookie过期时间 Cookie.Expires = DateTime.Now.AddYears(50); CookiesHelper.AddCookie(Cookie); } else { CookiesHelper.SetCookie("upup1000Admin", "uname", CommonTools.Encode(username), DateTime.Now.AddYears(50)); CookiesHelper.SetCookie("upup1000Admin", "psd", CommonTools.Encode(password), DateTime.Now.AddYears(50)); } } LogManagement.getInstance().WriteTrace(m_session.AdminEntity, "Login", "IP:" + Request.UserHostAddress + "|AdminID:" + m_session.AdminEntity.Username); //跳转 if (Request.QueryString["url"] != null && Request.QueryString["url"] != "") { Response.Redirect(Request.QueryString["url"]); } else { Response.Redirect("BaZi/PatternList.aspx"); } } else { this.ltrNotice.Text = "用户名或密码错误!"; base.ClientScript.RegisterStartupScript(base.GetType(), "", "document.getElementById('" + divNotice.ClientID + "').style.display='';", true); } }
public async Task Register(string birthday) { try { if (birthday != null) { DateTime date = DateTime.Parse(birthday); UserManager urmngr = new UserManager(); await urmngr.addUser(Context.User, date, Context.Guild); await ReplyAsync(Context.User.Mention + "You succesfully registered with the server"); } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
/* [Timestamp] * public Byte[] RowVersion { get; set; }*/ public void ImportFromModel(ProjectNews md) { try { if (md != null && CommonTools.isEmpty(md.Author) == false ) { base.ImportFromModel(md); ProjectsManager mng = new ProjectsManager(); Project = mng.GetProjectById(md.Project); } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
private async Task <Boolean> CheckIfFFmpegexists(ulong guildid) { try { Boolean a = false; a = FfmpegInstancces.ContainsKey(guildid); return(a); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(false); } }
//public FileRecordManager(SlimeDbContext tdb) //{ // db = tdb; // postManager = new PostManager(db); //} public async Task <string> Create(int?BlogId, int?postid, Files filemodel, IFormFile filedata, string user) { try { string ap = null; if ((filedata != null) && (filemodel != null) && (!CommonTools.isEmpty(user))) { var blog = await blogmngr.GetBlogByIdAsync(BlogId); var post = await postManager.Details(postid); ApplicationUser usr = (ApplicationUser)db.Users.First(m => m.UserName == user); if ((blog != null)) { var blogpath = FileSystemManager.GetBlogRootDataFolderAbsolutePath(blog.Name); string abspath = await FileSystemManager.CreateFile(blogpath, filedata); if (!CommonTools.isEmpty(abspath)) { ap = FileSystemManager.GetBlogRootDataFolderRelativePath(blog.Name) + "/" + Path.GetFileName(abspath); filemodel.FileName = Path.GetFileName(abspath); filemodel.Path = abspath; filemodel.RelativePath = ap; filemodel.Owner = usr.UserName; //filemodel.PostId =(int) postid; db.Files.Add(filemodel); await db.SaveChangesAsync(); FilesPostBlog filesPost = new FilesPostBlog(); filesPost.BlogId = blog.Id; filesPost.FileId = filemodel.Id; filesPost.PostId = (int)postid; db.FilesPostsBlog.Add(filesPost); await db.SaveChangesAsync(); } } } return(ap); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
public async Task <EmbedBuilder> Help(ICommandContext Context) { try { string prefix = "!?"; /* put your chosen prefix here */ var builder = new EmbedBuilder() { Color = new Color(114, 137, 218), Description = "These are the commands you can use" }; if (Context != null) { foreach (var module in _service.Modules) /* we are now going to loop through the modules taken from the service we initiated earlier ! */ { string description = null; foreach (var cmd in module.Commands) /* and now we loop through all the commands per module aswell, oh my! */ { var result = await cmd.CheckPreconditionsAsync(Context); /* gotta check if they pass */ if (result.IsSuccess) { description += $"{prefix}{cmd.Aliases.First()}\n"; /* if they DO pass, we ADD that command's first alias (aka it's actual name) * to the description tag of this embed */ } } if (!string.IsNullOrWhiteSpace(description)) /* if the module wasn't empty, we go and add a field where we drop all the data into! */ { builder.AddField(x => { x.Name = module.Name; x.Value = description; x.IsInline = false; }); } } } return(builder); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
public void ReqTaskDataTake(MsgPack packMsg) { RequestTaskReward data = packMsg._msg.reqTaskReward; NetMsg netMsg = new NetMsg { cmd = (int)MsgCommand.Cmd_RspTaskReward, }; PlayerData playerData = cacheSvc.GetPlayerDataBySession(packMsg._session); TaskRewardCfg taskDataCfg = configSvc.GetTaskRewardData(data.taskId); TaskData taskData = CalcTaskRewardData(playerData, data.taskId); if (taskData.progress == taskDataCfg.count && !taskData.bTaked) { playerData.coin += taskDataCfg.coin; CommonTools.CalcExp(playerData, taskDataCfg.exp); taskData.bTaked = true; //更新任务进度数据 UpdateTaskProgress(playerData, taskData); //更新数据库 if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { netMsg.err = (int)ErroCode.Error_UpdateDB; } else { ResponseTaskReward rspData = new ResponseTaskReward { coin = playerData.coin, lv = playerData.lv, exp = playerData.exp, taskArr = playerData.taskReward }; netMsg.rspTaskReward = rspData; } } else { netMsg.err = (int)ErroCode.Error_ClientData; } packMsg._session.SendMsg(netMsg); }
public async Task UnRegisterBot() { try { UserManager urmngr = new UserManager(); FavoriteCharactersManager favmngr = new FavoriteCharactersManager(); await favmngr.DelFavorites(Convert.ToString(Context.User.Id)); await urmngr.DeleteUser(Context.User); await ReplyAsync("You succesfully unregistered with the server"); } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public void DeleteByProjectId(int id) { try { if (id != null) { List <ProjectNews> news = this.ListByProjectId(id); if (news != null) { foreach (var n in news) { this.Delete(n.Id); } } } } catch (Exception ex) { CommonTools.ErrorReporting(ex); } }
public async Task <BotGearServer> getServerbyId(string id) { try { BotGearServer ap = null; if (id != null) { ap = db.Servers.FirstOrDefault(x => x.Id == id); } return(ap); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
public List <BotGearUser> GetUsers() { try { List <BotGearUser> users = null; users = db.Users.ToList(); return(users); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(null); } }
public void Login() { Debug.Log("XYAnalyser Login "); //兼容jrtt外发的马甲包SDK数据上报 int versionCode = CommonTools.GetVersionCode(); ArrayList list = new ArrayList(needAdaptsJRTT); if (list.Contains(versionCode)) { StartCoroutine(ToutiaoInfo()); } else { StartCoroutine(TrackingInfo()); } SDKMgr.Instance.TrackGameLog("2100", "西游SDK登录"); XYSDK.Instance.login(); }
public virtual Task UserUpdated(SocketUser arg1, SocketUser arg2) { try { if (arg1 != null && arg1.IsBot == false && arg2.IsBot == false) { UserManager usermngr = new UserManager(); usermngr.EditUser(arg1, arg2); } return Task.CompletedTask; } catch (Exception ex) { CommonTools.ErrorReporting(ex); return Task.CompletedTask; } }
private void UpdateDeviceList() { CommonTools.ExecuteOnUiThreadInvoke(() => { foreach (BMDatabase db in BMDatabaseMap.INSTANCE.Databases) { UpdateOrAddBMDeviceRecordVM(db); } if (_devices.Count > 0) { if (_listDevices.SelectedItem == null) { _listDevices.SelectedIndex = 0; //select first by default } } }); }
public override Task UserJoined(SocketGuildUser user) { try { base.UserJoined(user); //var channel = user.Guild.DefaultChannel; //if (channel != null && user.IsBot ==false) //{ // //channel.SendMessageAsync(String.Format("{0} Type !help for help ", user.Mention)); //} return(Task.CompletedTask); } catch (Exception ex) { CommonTools.ErrorReporting(ex); return(Task.CompletedTask); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); try { if (Request.Cookies["upup1000Admin"]["uname"] != null && Request.Cookies["upup1000Admin"]["uname"] != string.Empty && Request.Cookies["upup1000Admin"]["psd"] != null && Request.Cookies["upup1000Admin"]["psd"] != string.Empty) { string username = CommonTools.Decode(Request.Cookies["upup1000Admin"]["uname"]); string password = CommonTools.Decode(Request.Cookies["upup1000Admin"]["psd"]); Default my_default = new Default(); my_default.LoginCheck(username, password); Response.Cache.SetCacheability(HttpCacheability.NoCache); } } catch { } }
// TreeListView recursion private void NodeFind(string text, CommonTools.NodeCollection cNodes, bool searchFields, out CommonTools.Node outNode) { bool found = false; outNode = null; foreach (Node n in NodeCollection.ForwardNodeIterator(this.Nodes[0], false)) { for (int f = 0; f <= this.Columns.Count - 1; f++) { if (n[f] == null) { continue; } if (text == n[f].ToString()) { found = true; break; } } if (found) { outNode = n; break; } } }
private void LoadVariablesNode(Variable theVar, CommonTools.Node parent, object[] parentNodeData) { parentNodeData[2] = theVar.ToString(); parent.SetData(parentNodeData); int i = 0; foreach (Variable aFieldVar in theVar.Fields) { CommonTools.Node newNode = new CommonTools.Node(); object[] nodeData = new object[3]; nodeData[0] = i++; nodeData[1] = aFieldVar.dbType.Signature; nodeData[2] = Utils.GetValueStr(aFieldVar.value, aFieldVar.dbType.Signature); newNode.SetData(nodeData); parent.Nodes.Add(newNode); LoadVariablesNode(aFieldVar, newNode, nodeData); } RefreshTreeViews(); }
public void setMissionType(CommonTools.MissionType missionType, String missionKey) { m_mission.setType(missionType); m_mission.setKey(missionKey); guiTypeCbo.SelectedItem = missionType; guiKeyTxt.Text = missionKey; }
protected virtual CommonTools.TreeList.TextFormatting GetFormatting(CommonTools.Node node, CommonTools.TreeListColumn column) { return column.CellFormat; }
private void BuildTreeViewMenu(CT.Node treeListNode) { behaviorTreeCMS.Items.Clear(); var root = _controller.Data.Root.RootNode; var node = treeListNode != null ? treeListNode.Tag as Node : root; if (node is Composite || (node is Decorator && node.Nodes.Count == 0)) { foreach (var type in _nodeTypes) { var nodeName = Node.GetName(type); var nodeType = Node.GetType(type); var items = GetMenuItem(behaviorTreeCMS.Items, nodeType); if (items == null) items = AddMenuItem(nodeType, null, null); AddMenuItem(items, nodeName, type, t => AddNewNode(t, node)); } } if (node != root) { AddMenuItem("Remove Node", null, t => node.Remove()); } }
public TreeViewEventArgs(CommonTools.Node oNode) { this.Node = oNode; }