public override void OnToolWindowCreated() { var tsvnPackage = Package as TSVNPackage; var dte = (DTE)tsvnPackage.GetServiceHelper(typeof(DTE)); _tsvnToolWindowControl.SetDTE(dte); _fileHelper = new FileHelper(dte); _commandHelper = new CommandHelper(dte); _documentEvents = dte.Events.DocumentEvents; _documentEvents.DocumentSaved += DocumentEvents_DocumentSaved; _solutionEvents = dte.Events.SolutionEvents; _solutionEvents.Opened += SolutionEvents_Opened; _tsvnToolWindowControl.GotFocus += _tsvnToolWindowControl_GotFocus; _tsvnToolWindowControl.HideUnversionedButton.IsChecked = Settings.Default.HideUnversioned; _tsvnToolWindowControl.Update(_commandHelper.GetPendingChanges(), _fileHelper.GetSolutionDir()); }
public static void CompletePendingReadWithFailure(this SqlCommand command, int errorCode, bool resetForcePendingReadsToWait) { CommandHelper.CompletePendingReadWithFailure(command, errorCode, resetForcePendingReadsToWait); }
public async Task <APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) { LambdaLogger.Log(request.Body); var response = new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK }; WebhookMessage webhookMessage = null; try { webhookMessage = JsonConvert.DeserializeObject <WebhookMessage>(request.Body); } catch (Exception ex) { LambdaLogger.Log("Error: " + ex.Message); } if (webhookMessage == null) { return(response); } var serviceCollection = new ServiceCollection(); ConfigureServices(serviceCollection); var serviceProvider = serviceCollection.BuildServiceProvider(); var botService = serviceProvider.GetService <IBotService>(); if (webhookMessage.Message?.Text != null && CommandHelper.TryParseCommand(webhookMessage.Message.Text, out Command command)) { try { switch (command) { case Command.Start: await botService.StartSubscriptionAsync(webhookMessage.Message.Chat.Id); break; case Command.Stop: await botService.RemoveSubscriptionAsync(webhookMessage.Message.Chat.Id); break; case Command.Magnitude: await botService.AskMagnitudeAsync(webhookMessage.Message.Chat.Id); break; case Command.Location: await botService.AskLocationAsync(webhookMessage.Message.Chat.Id); break; case Command.RemoveLocation: await botService.RemoveLocationAsync(webhookMessage.Message.Chat.Id); break; } } catch (TelegramApiException exception) when(exception.Response.ErrorCode == 403) //bot blocked, delete subscription { await botService.RemoveSubscriptionAsync(webhookMessage.Message.Chat.Id); } } if (webhookMessage.Message?.Location != null) { await botService.SetLocationAsync(webhookMessage.Message.Chat.Id, webhookMessage.Message.Location); } if (webhookMessage.CallbackQuery != null) { switch (webhookMessage.CallbackQuery.Message.Text) { case BotDialog.ASK_MAGNITUDE: if (double.TryParse(webhookMessage.CallbackQuery.Data, out double magnitude)) { await botService.SetMagnitudeAsync(webhookMessage.CallbackQuery.Message.MessageId, webhookMessage.CallbackQuery.Id, webhookMessage.CallbackQuery.Message.Chat.Id, magnitude); } break; } } return(response); }
/// <summary> /// Called when the mouse leaves a <see cref="T:System.Windows.Controls.ListBoxItem"/>. /// </summary> /// <param name="e">The event data.</param> protected override void OnMouseLeave(MouseEventArgs e) { base.OnMouseLeave(e); CommandHelper.Execute(this.CancelPreviewCommand, this, null); }
/// <summary> /// Determines whether the Command can be executed /// </summary> /// <returns>Returns Command CanExecute</returns> protected bool CanExecuteCommand() { return(CommandHelper.CanExecute(this.Command, this.CommandParameter, this.CommandTarget)); }
public SpecialNotePointer() { InitializeComponent(); CommandHelper.InitializeCommandBindings(this); }
public async Task ExecuteCommandAsync(SocketSlashCommand command, IServiceScopeFactory scopeFactory) { await command.RespondAsync(embed : CommandHelper.WaitResponceBuilder.Build()); var option = command.Data.Options.FirstOrDefault(); using var scope = scopeFactory.CreateScope(); var clanActivities = scope.ServiceProvider.GetRequiredService <IClanActivities>(); var userContainer = option is null ? await clanActivities.GetUserActivitiesAsync(command.User.Id) : await clanActivities.GetUserActivitiesAsync(command.User.Id, CommandHelper.GetPeriod((string)option.Value)); if (userContainer is null) { await command.ModifyOriginalResponseAsync(x => x.Embed = CommandHelper.UserIsNotRegisteredBuilder.Build()); return; } var sb = new StringBuilder($"{CommandHelper.GetActivityCountImpression(userContainer.TotalCount, command.User.Mention)}"); sb.Append("\n\n***За класами:***"); foreach (var character in userContainer.ClassCounters) { var emoji = CommonData.DiscordEmoji.Emoji.GetClassEmoji(character.Class); var className = Translation.ClassNames[character.Class]; sb.Append($"\n{emoji} **{className}** – **{character.Count}**"); } sb.Append("\n\n***За типом активности:***"); foreach (var mode in userContainer.ModeCounters.Counters) { var emoji = CommonData.DiscordEmoji.Emoji.GetActivityEmoji(mode.ActivityMode); var modes = Translation.ActivityNames[mode.ActivityMode]; sb.Append($"\n{emoji} **{modes[0]}** | {modes[1]} – **{mode.Count}**"); } var builder = new EmbedBuilder() .WithColor(0xFACC3F) .WithThumbnailUrl(command.User.GetAvatarUrl()) .WithTitle($"Активності {userContainer.UserName}{(option is null ? string.Empty : $" за {option.Value}")}")
public MultipleRegisterCommandModel(ushort address, ushort count, ConfigurationSettingsModel settings) : base(address, settings) { Count = count; Items = CommandHelper.GenerateSignalModelList <ushort>(Address, Count); }
private void RevertButton_Click(object sender, RoutedEventArgs e) => CommandHelper.Revert().FireAndForget();
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { await CommandHelper.SaveFiles(); await ProcessHelper.RunTortoiseGitCommand("svnfetch"); }
/// <summary> /// 窗体初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmStatus_Load(object sender, EventArgs e) { if (!GuiConfig.IsMono) { Icon = GetSystemIcon.ConvertImgToIcon(Resources.KeyInfo); } var strType = RuntimeMongoDbContext.SelectTagType; var docStatus = new BsonDocument(); cmbChartField.Visible = false; chartResult.Visible = false; btnOpCnt.Visible = false; tempIsDisplayNumberWithKSystem = CtlTreeViewColumns.IsDisplayNumberWithKSystem; CtlTreeViewColumns.IsDisplayNumberWithKSystem = true; switch (strType) { case ConstMgr.ServerTag: case ConstMgr.SingleDbServerTag: if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin) { docStatus = CommandHelper.ExecuteMongoSvrCommand(CommandHelper.ServerStatusCommand, RuntimeMongoDbContext.GetCurrentServer()).Response; trvStatus.Height = trvStatus.Height * 2; } if (strType == ConstMgr.ServerTag) { btnOpCnt.Visible = true; } break; case ConstMgr.DatabaseTag: case ConstMgr.SingleDatabaseTag: docStatus = RuntimeMongoDbContext.GetCurrentDataBase().GetStats().Response.ToBsonDocument(); cmbChartField.Visible = true; chartResult.Visible = true; //{{ "db" : "aaaa", // "collections" : 8, // "objects" : 0, // "avgObjSize" : 0.0, // "dataSize" : 0.0, // "storageSize" : 32768.0, // "numExtents" : 0, // "indexes" : 8, // "indexSize" : 32768.0, // "ok" : 1.0 }} var statuspoint = docStatus.AsBsonDocument; //这里其实应该看Collection的Status,不同的引擎所拥有的状态不一样 if (statuspoint.Contains("avgObjSize")) { cmbChartField.Items.Add("AverageObjectSize"); } if (statuspoint.Contains("dataSize")) { cmbChartField.Items.Add("DataSize"); } if (statuspoint.Contains("extentCount")) { cmbChartField.Items.Add("ExtentCount"); } if (statuspoint.Contains("indexes")) { cmbChartField.Items.Add("IndexCount"); } if (statuspoint.Contains("lastExtentSize")) { cmbChartField.Items.Add("LastExtentSize"); } //MaxDocuments仅在CapedCollection时候有效 if (statuspoint.Contains("MaxDocuments")) { cmbChartField.Items.Add("MaxDocuments"); } if (statuspoint.Contains("ObjectCount")) { cmbChartField.Items.Add("ObjectCount"); } if (statuspoint.Contains("PaddingFactor")) { cmbChartField.Items.Add("PaddingFactor"); } if (statuspoint.Contains("storageSize")) { cmbChartField.Items.Add("StorageSize"); } cmbChartField.SelectedIndex = 0; try { RefreshDbStatusChart("StorageSize"); } catch (Exception ex) { Utility.ExceptionDeal(ex); } break; case ConstMgr.CollectionTag: //TODO:这里无法看到Collection的Document Validation信息。 docStatus = RuntimeMongoDbContext.GetCurrentCollection().GetStats().Response.ToBsonDocument(); //图形化初始化 chartResult.Visible = true; chartResult.Series.Clear(); chartResult.Titles.Clear(); var seriesResult = new Series("Usage"); var dpDataSize = new DataPoint(0, RuntimeMongoDbContext.GetCurrentCollection().GetStats().DataSize) { LegendText = "DataSize", LegendToolTip = "DataSize", ToolTip = "DataSize" }; seriesResult.Points.Add(dpDataSize); var dpTotalIndexSize = new DataPoint(0, RuntimeMongoDbContext.GetCurrentCollection().GetStats().TotalIndexSize) { LegendText = "TotalIndexSize", LegendToolTip = "TotalIndexSize", ToolTip = "TotalIndexSize" }; seriesResult.Points.Add(dpTotalIndexSize); var dpFreeSize = new DataPoint(0, RuntimeMongoDbContext.GetCurrentCollection().GetStats().StorageSize - RuntimeMongoDbContext.GetCurrentCollection().GetStats().TotalIndexSize - RuntimeMongoDbContext.GetCurrentCollection().GetStats().DataSize) { LegendText = "FreeSize", LegendToolTip = "FreeSize", ToolTip = "FreeSize" }; seriesResult.Points.Add(dpFreeSize); seriesResult.ChartType = SeriesChartType.Pie; chartResult.Series.Add(seriesResult); chartResult.Titles.Add(new Title("Usage")); break; default: if (RuntimeMongoDbContext.GetCurrentServerConfig().LoginAsAdmin) { docStatus = CommandHelper.ExecuteMongoSvrCommand(CommandHelper.ServerStatusCommand, RuntimeMongoDbContext.GetCurrentServer()).Response; trvStatus.Height = trvStatus.Height * 2; } break; } GuiConfig.Translateform(this); UiHelper.FillDataToTreeView(strType, trvStatus, docStatus); trvStatus.DatatreeView.Nodes[0].Expand(); }
/// <summary> /// 团体比赛结束一次对决 /// </summary> /// <param name="currentUser">忽略</param> /// <param name="request">Request.GameLoop.Entities</param> /// <returns>Response.EmptyEntity</returns> public Response Execute(string request) { var req = JsonConvert.DeserializeObject <Request <GameLoop> >(request); var temp = req.FirstEntity(); //非轮空,非双方弃权,需要胜方签名 if (!temp.IsBye && temp.WaiverOption != WaiverOption.AB && Ext.IsNullOrEmpty(temp.WinSign)) { return(ResultHelper.Fail("非轮空,非双方弃权,需要胜方签名。")); } var loop = GameHelper.GetLoop(temp.Id); //从数据库取出,重新赋值 loop.IsBye = req.Entities.First().IsBye; loop.State = GameLoopState.FINISH.Id; loop.WaiverOption = temp.WaiverOption.GetId(); loop.WinSign = temp.WinSign; loop.JudgeSign = temp.JudgeSign; //更新结束时间 loop.EndTime = DateTime.Now; if (loop.StartTime == null) { loop.StartTime = loop.EndTime; } loop.SetRowModified(); loop.Team1Id = loop.Team1Id.GetId(); loop.Team2Id = loop.Team2Id.GetId(); IWaiver waiver = new TeamWaiver(); if (loop.WaiverOption.IsNotNullOrEmpty()) { waiver.SetWaiver(loop); } else { waiver.SetScore(loop); var order = GameHelper.GetGameOrder(loop.OrderId.GetId()); //验证爱猕模式需要打完所有对阵 if (order.TeamScoreMode == TeamScoreMode.SINGLE_RACE.Id) { if (loop.Team1 + loop.Team2 != order.WinTeam * 2 - 1) { return(ResultHelper.Fail(string.Format("需要打满{0}场。", order.WinTeam * 2 - 1))); } } else { int max = loop.Team1 > loop.Team2 ? loop.Team1 : loop.Team2; if (max < order.WinTeam) { //团队比赛胜场检查 return(ResultHelper.Fail(string.Format("胜方需要赢{0}场。", order.WinTeam))); } } } List <EntityBase> entities = new List <EntityBase>(); entities.Add(loop); SetNextLoop(loop, entities); var cmdSave = CommandHelper.CreateSave(entities); //更新个人积分 var cmdUpdateScore = CommandHelper.CreateProcedure(FetchType.Execute, "sp_UpdateGameSportScoreForTeam"); cmdUpdateScore.Params.Add("@GameId", loop.GameId); cmdUpdateScore.Params.Add("@LoopId", loop.Id.GetId()); cmdSave.AfterCommands = new List <Command> { cmdUpdateScore }; return(DbContext.GetInstance().Execute(cmdSave)); }
internal ArgsParser(List <Command> commands) { CommandHelper = new CommandHelper(commands); }
private static uint FindType(string expression, Variable[] vars, bool quiet, bool force) { if (vars.Length == 0) { throw new RunTimeError("Usage: findtype ('name of item'/'graphicID) [inrangecheck (true/false)/backpack] [hue]"); } string gfxStr = vars[0].AsString(); Serial gfx = Utility.ToUInt16(gfxStr, 0); List <Item> items; List <Mobile> mobiles; bool inRangeCheck = false; bool backpack = false; int hue = -1; if (vars.Length > 1) { if (vars.Length == 3) { hue = vars[2].AsInt(); } if (vars[1].AsString().IndexOf("pack", StringComparison.OrdinalIgnoreCase) > 0) { backpack = true; } else { inRangeCheck = vars[1].AsBool(); } } // No graphic id, maybe searching by name? if (gfx == 0) { items = CommandHelper.GetItemsByName(gfxStr, backpack, inRangeCheck, hue); if (items.Count == 0) // no item found, search mobile by name { mobiles = CommandHelper.GetMobilesByName(gfxStr, inRangeCheck); if (mobiles.Count > 0) { return(mobiles[Utility.Random(mobiles.Count)].Serial); } } else { return(items[Utility.Random(items.Count)].Serial); } } else // Provided graphic id for type, check backpack first (same behavior as DoubleClickAction in macros { ushort id = Utility.ToUInt16(gfxStr, 0); items = CommandHelper.GetItemsById(id, backpack, inRangeCheck, hue); // Still no item? Mobile check! if (items.Count == 0) { mobiles = CommandHelper.GetMobilesById(id, inRangeCheck); if (mobiles.Count > 0) { return(mobiles[Utility.Random(mobiles.Count)].Serial); } } else { return(items[Utility.Random(items.Count)].Serial); } } return(Serial.Zero); }
/// <summary> /// Initializes a new instance of the <see cref="UsingStatementCleanupLogic" /> class. /// </summary> /// <param name="package">The hosting package.</param> private UsingStatementCleanupLogic(CodeMaidPackage package) { _package = package; _commandHelper = CommandHelper.GetInstance(_package); }
private async Task ToggleUnversioned(bool hide) { Settings.Default.HideUnversioned = hide; Settings.Default.Save(); Update(await CommandHelper.GetPendingChanges(), await CommandHelper.GetRepositoryRoot()); }
// • RegisterUser <username> <password> <repeat-password> <firstName> <lastName> <age> <gender> public string Execute(string[] args) { Validator.CheckLength(7, args); //if (AuthenticationManager.IsAuthenticated()) //{ // throw new InvalidOperationException(Constants.ErrorMessages.LogoutFirst); //} string username = args[0]; if (username.Length > Constants.MaxUsernameLength || username.Length < Constants.MinUsernameLength) { throw new ArgumentException(string.Format(Constants.ErrorMessages.UsernameNotValid, username)); } string password = args[1]; if (!password.Any(char.IsDigit) || !password.Any(char.IsUpper)) { throw new ArgumentException(string.Format(Constants.ErrorMessages.PasswordNotValid, password)); } string repeatPassword = args[2]; if (password != repeatPassword) { throw new ArgumentException(string.Format(Constants.ErrorMessages.PasswordDoesNotMatch)); } string firstName = args[3]; string lastName = args[4]; int age; bool isNumber = int.TryParse(args[5], out age); if (!isNumber || age <= 0) { throw new ArgumentException(Constants.ErrorMessages.AgeNotValid); } Gender gender; bool isGenderValid = Enum.TryParse(args[6], out gender); if (!isGenderValid) { throw new ArgumentException(Constants.ErrorMessages.GenderNotValid); } if (CommandHelper.IsUserExisting(username)) { throw new InvalidOperationException(string.Format(Constants.ErrorMessages.UsernameIsTaken, username)); } User u = new User { Username = username, Password = password, FirstName = firstName, LastName = lastName, Age = age, Gender = gender }; this.RegisterUser(u); // AuthenticationManager.LoginUser(u); return($"User {username} successfully registered!"); }
private void ShowDifferences_Click(object sender, RoutedEventArgs e) { var filePath = ((e.OriginalSource as MenuItem).DataContext as TSVNTreeViewItem).Path; CommandHelper.ShowDifferences(filePath).FireAndForget(); }
static void Main(string[] args) { try { string path = string.Empty; string xpath = string.Empty; Console.OutputEncoding = utf8; //removed input encoding utf8 because character like "é" are treated like "\0" when entered in cmd and in windows terminal. //Console.InputEncoding = utf8; NamespaceHelper.Instance.LoadNamespaces(); if (args.Length > 0) { path = args[0]; _startWithParameter = true; } DisplayHelp(); #region "file mode" while (true) { CConsole.Write("File path > ", MODE_COLOR); if (_startWithParameter) { CConsole.WriteLine(path); _startWithParameter = false; } else { path = Console.ReadLine(); } path = path.Trim(CommandHelper.TRIMMABLE.ToCharArray()); if (string.IsNullOrWhiteSpace(path)) { continue; } if (CommandHelper.IsExitKeyword(path) || CommandHelper.IsExitAllKeyword(path)) { break; } if (CommandHelper.IsHelpKeyword(path)) { DisplayHelp(); continue; } if (CommandHelper.IsNamespacesCommand(path)) { EExitMode nsExitMode = new NamespaceMgtMode().Start(); //if (nsExitMode == EExitMode.ExitMode) continue; if (nsExitMode == EExitMode.ExitApplication) { break; } //use continue for EExitMode.None (is usefull ?) and EExitMode.ExitMode continue; } if (!File.Exists(path)) { CConsole.WriteLine($"Path '{path}' doesn't exists!", ConsoleColor.Red); CConsole.WriteLine(); continue; } try { XmlDocument doc = new XmlDocument(); doc.Load(path); Console.WriteLine(); XPathMode mode = new XPathMode(doc); EExitMode exitMode = mode.Start(); if (exitMode == EExitMode.ExitApplication) { break; } } catch (XmlException ex) { CConsole.WriteLine("Error when loading file!", ConsoleColor.Red); CConsole.WriteLine($"Message: {ex.Message}", ConsoleColor.Red); Console.WriteLine(); } } #endregion "file mode" } catch (Exception ex) { CConsole.WriteLine(ex.ToString(), ConsoleColor.Red); CConsole.WriteLine(); CConsole.WriteLine("Press a key to exit ..."); Console.ReadKey(); } }
private async Task Update() => Update(await CommandHelper.GetPendingChanges(), await CommandHelper.GetRepositoryRoot());
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { await CommandHelper.RunTortoiseSvnFileCommand("update", "/rev"); }
void ucGridView1_RowCommand(object sender, Util_ucGridView.RowCommandEventArgs e) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); string strDataKeys = (e.DataKeys != null) ? Util.getStringJoin(e.DataKeys) : ""; Dictionary <string, string> dicContext = new Dictionary <string, string>(); switch (e.CommandName) { case "cmdAdd": dicContext.Clear(); dicContext.Add("Mode", "Add"); dicContext.Add("DataKeys", strDataKeys); LaunchPopup(dicContext); break; case "cmdEdit": dicContext.Clear(); dicContext.Add("Mode", "Edit"); dicContext.Add("DataKeys", strDataKeys); LaunchPopup(dicContext); break; case "cmdCopy": dicContext.Clear(); dicContext.Add("Mode", "Copy"); dicContext.Add("DataKeys", strDataKeys); LaunchPopup(dicContext); break; case "cmdDelete": if (string.IsNullOrEmpty(strDataKeys)) { Util.MsgBox(Util.getHtmlMessage(Util.HtmlMessageKind.ParaDataError)); return; } else { try { sb.Reset(); sb.AppendStatement(string.Format("Delete {0} ", _TableName)); sb.Append(" Where KindID = ").AppendParameter("KindID", strDataKeys.Split(',')[0]); sb.Append(" And TypeID = ").AppendParameter("TypeID", strDataKeys.Split(',')[1]); sb.Append(" And ItemID = ").AppendParameter("ItemID", strDataKeys.Split(',')[2]); db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg(SinoPac.WebExpress.Common.Properties.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); } catch (Exception ex) { Util.MsgBox(Util.getHtmlMessage(Util.HtmlMessageKind.Error, ex.ToString())); } } break; case "cmdMultilingual": string strURL = string.Format("{0}?DBName={1}&TableName={2}&PKFieldList={3}&PKValueList={4}", Util._MuiAdminUrl, _DBName, _TableName, _PKFieldList, Util.getStringJoin(e.DataKeys)); ucModalPopup1.Reset(); ucModalPopup1.ucFrameURL = strURL; ucModalPopup1.ucPopupWidth = 650; ucModalPopup1.ucPopupHeight = 350; ucModalPopup1.ucBtnCloselEnabled = true; ucModalPopup1.Show(); break; default: Util.MsgBox(string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_Undefined1, e.CommandName)); break; } }
/// <summary> /// Execute command /// </summary> protected void ExecuteCommand() { CommandHelper.Execute(this.Command, this.CommandParameter, this.CommandTarget); }
protected void LaunchPopup(Dictionary <string, string> oContext) { KindID.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_KindID; TypeID.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_TypeID; ItemID.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemID; IsEnabled.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_IsEnabled; ItemName.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemName; ItemProp1.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemProp1; ItemProp2.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemProp2; ItemProp3.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemProp3; ItemJSON.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemJSON; ItemRemark.ucCaption = SinoPac.WebExpress.Common.Properties.Resources.KindTypeMap_ItemRemark; KindID.ucIsRequire = true; TypeID.ucIsRequire = true; ItemID.ucIsRequire = true; IsEnabled.ucIsRequire = true; ItemName.ucIsRequire = true; KindID.ucIsReadOnly = false; TypeID.ucIsReadOnly = false; ItemID.ucIsReadOnly = false; KindID.ucTextData = ""; TypeID.ucTextData = ""; ItemID.ucTextData = ""; IsEnabled.ucSelectedID = "Y"; ItemName.ucTextData = ""; ItemProp1.ucTextData = ""; ItemProp2.ucTextData = ""; ItemProp3.ucTextData = ""; ItemJSON.ucTextData = ""; ItemRemark.ucTextData = ""; Dictionary <string, string> oDicIsEnabled = new Dictionary <string, string>(); oDicIsEnabled.Add("Y", "Y"); oDicIsEnabled.Add("N", "N"); IsEnabled.ucSourceDictionary = oDicIsEnabled; IsEnabled.ucIsSearchEnabled = false; IsEnabled.ucDropDownSourceListWidth = 40; IsEnabled.Refresh(); if (!string.IsNullOrEmpty(oContext["DataKeys"])) { DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); sb.AppendStatement(string.Format("Select * From {0} Where 0=0 ", _TableName)); sb.Append(" And KindID = ").AppendParameter("KindID", oContext["DataKeys"].Split(',')[0]); sb.Append(" And TypeID = ").AppendParameter("TypeID", oContext["DataKeys"].Split(',')[1]); sb.Append(" And ItemID = ").AppendParameter("ItemID", oContext["DataKeys"].Split(',')[2]); DataRow dr = db.ExecuteDataSet(sb.BuildCommand()).Tables[0].Rows[0]; KindID.ucIsReadOnly = true; TypeID.ucIsReadOnly = true; if (oContext["Mode"] != "Copy") { ItemID.ucIsReadOnly = true; } KindID.ucTextData = dr["KindID"].ToString(); TypeID.ucTextData = dr["TypeID"].ToString(); ItemID.ucTextData = dr["ItemID"].ToString(); IsEnabled.ucSelectedID = dr["IsEnabled"].ToString(); IsEnabled.Refresh(); ItemName.ucTextData = dr["ItemName"].ToString(); ItemProp1.ucTextData = dr["ItemProp1"].ToString(); ItemProp2.ucTextData = dr["ItemProp2"].ToString(); ItemProp3.ucTextData = dr["ItemProp3"].ToString(); ItemJSON.ucTextData = dr["ItemJSON"].ToString(); ItemRemark.ucTextData = dr["ItemRemark"].ToString(); } ucModalPopup1.Reset(); ucModalPopup1.ucPopupWidth = 600; ucModalPopup1.ucPopupHeight = 500; ucModalPopup1.ucContextData = Util.getJSON(oContext); ucModalPopup1.ucPanelID = pnlEdit.ID; ucModalPopup1.Show(); }
/// <summary> /// Called when the mouse enters a <see cref="T:System.Windows.Controls.ListBoxItem"/>. /// </summary> /// <param name="e">The event data.</param> protected override void OnMouseEnter(MouseEventArgs e) { base.OnMouseEnter(e); CommandHelper.Execute(this.PreviewCommand, this, null); }
protected void btnSave_Click(object sender, EventArgs e) { UserInfo oUser = UserInfo.getUserInfo(); DbHelper db = new DbHelper(_DBName); CommandHelper sb = db.CreateCommandHelper(); sb.Reset(); Dictionary <string, string> oContext = Util.getDictionary(ucModalPopup1.ucContextData); Dictionary <string, string> oData = Util.getControlEditResult(pnlEdit); switch (oContext["Mode"].ToUpper()) { case "ADD": case "COPY": sb.Reset(); sb.AppendStatement(string.Format("Insert {0} ", _TableName)); sb.Append("(KindID,TypeID,ItemID,IsEnabled,ItemName,ItemProp1,ItemProp2,ItemProp3,ItemJSON,ItemRemark,UpdUser,UpdDateTime)"); sb.Append(" Values (").AppendParameter("KindID", oData["KindID"]); sb.Append(" ,").AppendParameter("TypeID", oData["TypeID"]); sb.Append(" ,").AppendParameter("ItemID", oData["ItemID"]); sb.Append(" ,").AppendParameter("IsEnabled", oData["IsEnabled"]); sb.Append(" ,").AppendParameter("ItemName", oData["ItemName"]); sb.Append(" ,").AppendParameter("ItemProp1", oData["ItemProp1"]); sb.Append(" ,").AppendParameter("ItemProp2", oData["ItemProp2"]); sb.Append(" ,").AppendParameter("ItemProp3", oData["ItemProp3"]); sb.Append(" ,").AppendParameter("ItemJSON", oData["ItemJSON"]); sb.Append(" ,").AppendParameter("ItemRemark", oData["ItemRemark"]); sb.Append(" ,").AppendParameter("UpdUser", oUser.UserID); sb.Append(" ,").AppendDbDateTime(); sb.Append(")"); try { db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg(SinoPac.WebExpress.Common.Properties.Resources.Msg_AddSucceed, Util.NotifyKind.Success); } catch { Util.NotifyMsg(SinoPac.WebExpress.Common.Properties.Resources.Msg_AddFail, Util.NotifyKind.Error); } break; case "EDIT": sb.Reset(); sb.AppendStatement(string.Format(" Update {0} ", _TableName)); sb.Append(" Set IsEnabled = ").AppendParameter("IsEnabled", oData["IsEnabled"]); sb.Append(" ,ItemName = ").AppendParameter("ItemName", oData["ItemName"]); sb.Append(" ,ItemProp1 = ").AppendParameter("ItemProp1", oData["ItemProp1"]); sb.Append(" ,ItemProp2 = ").AppendParameter("ItemProp2", oData["ItemProp2"]); sb.Append(" ,ItemProp3 = ").AppendParameter("ItemProp3", oData["ItemProp3"]); sb.Append(" ,ItemJSON = ").AppendParameter("ItemJSON", oData["ItemJSON"]); sb.Append(" ,ItemRemark = ").AppendParameter("ItemRemark", oData["ItemRemark"]); sb.Append(" ,UpdUser = "******"UpdUser", oUser.UserID); sb.Append(" ,UpdDateTime = ").AppendDbDateTime(); sb.Append(" Where KindID = ").AppendParameter("KindID", oData["KindID"]); sb.Append(" and TypeID = ").AppendParameter("TypeID", oData["TypeID"]); sb.Append(" and ItemID = ").AppendParameter("ItemID", oData["ItemID"]); try { db.ExecuteNonQuery(sb.BuildCommand()); Util.NotifyMsg(SinoPac.WebExpress.Common.Properties.Resources.Msg_EditSucceed, Util.NotifyKind.Success); } catch (Exception ex) { LogHelper.WriteSysLog(ex); Util.NotifyMsg(SinoPac.WebExpress.Common.Properties.Resources.Msg_EditFail, Util.NotifyKind.Error); } break; default: Util.MsgBox(string.Format(SinoPac.WebExpress.Common.Properties.Resources.Msg_Undefined1, oContext["Mode"])); break; } ucGridView1.Refresh(true); }
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { await CommandHelper.RunTortoiseSvnCommand("shelve"); }
void gvFlowStepBtn_RowCommand(object sender, Util_ucGridView.RowCommandEventArgs e) { DbHelper db = new DbHelper(FlowExpress._FlowSysDB); CommandHelper sb = db.CreateCommandHelper(); switch (e.CommandName) { case "cmdSelect": Response.Redirect(string.Format("FlowStepBtn.aspx?FlowID={0}&FlowStepID={1}&FlowStepBtnID={2}", HttpUtility.HtmlEncode(e.DataKeys[0]), HttpUtility.HtmlEncode(e.DataKeys[1]), HttpUtility.HtmlEncode(e.DataKeys[2]))); break; case "cmdCopy": hidFlowID.Value = e.DataKeys[0]; hidFlowStepID.Value = e.DataKeys[1]; hidFlowStepBtnID.Value = e.DataKeys[2]; DataRow dr = db.ExecuteDataSet(string.Format("Select * From FlowStepBtn Where FlowID='{0}' and FlowStepID = '{1}' and FlowStepBtnID = '{2}'", e.DataKeys[0], e.DataKeys[1], e.DataKeys[2])).Tables[0].Rows[0]; txtNewFlowStepBtnID.ucTextData = "Cpy-" + dr["FlowStepBtnID"].ToString().Left(15); txtNewFlowStepBtnCaption.ucTextData = "Cpy-" + dr["FlowStepBtnCaption"].ToString().Left(25); txtNewFlowStepBtnSeqNo.ucTextData = dr["FlowStepBtnSeqNo"].ToString(); ucModalPopup1.ucPopupHeader = "複製流程按鈕"; ucModalPopup1.ucPanelID = pnlNewFlowStepBtn.ID; ucModalPopup1.Show(); break; case "cmdAdd": hidFlowID.Value = _FlowID; hidFlowStepID.Value = _FlowStepID; hidFlowStepBtnID.Value = ""; txtNewFlowStepBtnID.ucTextData = "New-BtnID"; txtNewFlowStepBtnCaption.ucTextData = "New-BtnCaprion"; txtNewFlowStepBtnSeqNo.ucTextData = "99"; ucModalPopup1.ucPopupHeader = "新增流程按鈕"; ucModalPopup1.ucPanelID = pnlNewFlowStepBtn.ID; ucModalPopup1.Show(); break; case "cmdDelete": sb.Reset(); sb.AppendStatement("Delete FlowStepBtn Where FlowID =").AppendParameter("FlowID", e.DataKeys[0]); sb.Append(" And FlowStepID =").AppendParameter("FlowStepID", e.DataKeys[1]); sb.Append(" And FlowStepBtnID =").AppendParameter("FlowStepBtnID", e.DataKeys[2]); sb.AppendStatement("Delete FlowStepBtn_MUI Where FlowID =").AppendParameter("FlowID", e.DataKeys[0]); sb.Append(" And FlowStepID =").AppendParameter("FlowStepID", e.DataKeys[1]); sb.Append(" And FlowStepBtnID =").AppendParameter("FlowStepBtnID", e.DataKeys[2]); sb.AppendStatement("Delete FlowStepBtnHideExp Where FlowID =").AppendParameter("FlowID", e.DataKeys[0]); sb.Append(" And FlowStepID =").AppendParameter("FlowStepID", e.DataKeys[1]); sb.Append(" And FlowStepBtnID =").AppendParameter("FlowStepBtnID", e.DataKeys[2]); try { db.ExecuteNonQuery(sb.BuildCommand()); //[刪除]資料異動Log LogHelper.WriteAppDataLog(FlowExpress._FlowSysDB, "FlowStepBtn", Util.getStringJoin(e.DataKeys), LogHelper.AppDataLogType.Delete); Util.NotifyMsg(RS.Resources.Msg_DeleteSucceed, Util.NotifyKind.Success); } catch (Exception ex) { Util.MsgBox(ex.Message); } break; } (this.Master as FlowExpress_Admin_FlowExpess).RefreshTreeView(); }
public static void CompletePendingReadWithSuccess(this SqlCommand command, bool resetForcePendingReadsToWait) { CommandHelper.CompletePendingReadWithSuccess(command, resetForcePendingReadsToWait); }
public async Task ExecuteCommandAsync(SocketSlashCommand command, IServiceScopeFactory scopeFactory) { await command.RespondAsync(embed : CommandHelper.WaitResponceBuilder.Build()); var option = command.Data.Options.FirstOrDefault(); using var scope = scopeFactory.CreateScope(); var clanActivities = scope.ServiceProvider.GetRequiredService <IClanActivities>(); var userContainer = option is null ? await clanActivities.GetUserPartnersAsync(command.User.Id) : await clanActivities.GetUserPartnersAsync(command.User.Id, CommandHelper.GetPeriod((string)option.Value)); if (userContainer is null) { await command.ModifyOriginalResponseAsync(x => x.Embed = CommandHelper.UserIsNotRegisteredBuilder.Build()); return; } var sb = new StringBuilder($"Всього кооперативних активностей: "); sb.Append($"**{userContainer.CoopCount}/{userContainer.TotalCount} ({Math.Round(userContainer.CoopCount * 100.0 / userContainer.TotalCount, 2)}%)**\n"); foreach (var partner in userContainer.Partners) { sb.Append($"\n**{partner.UserName}** – **{partner.Count}**"); } var builder = new EmbedBuilder() .WithColor(0xB4A647) .WithThumbnailUrl(command.User.GetAvatarUrl()) .WithTitle($"Побратими {userContainer.UserName}{(option is null ? string.Empty : $" за {option.Value}")}")
/// <summary> /// 创建比赛 /// </summary> /// <param name="currentUser">忽略</param> /// <param name="request">Request.Game</param> /// <returns>Response.EmptyEntity</returns> public Response Execute(User currentUser, string request) { var req = JsonConvert.DeserializeObject <Request <Game> >(request); var game = req.FirstEntity(); SetLinkIdField(game); //俱乐部赛事,验证管理员权限 if (game.ClubId.IsNotNullOrEmpty() && !ClubHelper.IsUserClubAdmin(game.ClubId, currentUser.Id)) { return(ResultHelper.Fail("俱乐部管理员才能创建俱乐部比赛。")); } //非小组循环后模式,则设置IsKnockOutAB为false,否则保持用户输入。 if (game.KnockoutOption != KnockoutOption.ROUND_KNOCKOUT.Id) { game.IsKnockOutAB = false; } if (game.RowState == RowState.Added) { game.SetNewId(); game.SetCreateDate(); game.CreatorId = currentUser.Id; } game.ModifyHeadIcon(); List <EntityBase> entities = new List <EntityBase> { game }; //获取将要保存的图片列表 game.GetWillSaveFileList(entities); ////更改相应对阵模板的使用次数,更新多数代码迁移至比赛结束代码接口处,这样统计更准确 //string oldTempletId = string.Empty; //if (game.RowState == RowState.Modified) //{ // var cmd2 = CommandHelper.CreateText<Game>(FetchType.Fetch, "SELECT TeamMode FROM Game WHERE Id=@gameId"); // cmd2.Params.Add("@gameId", game.Id); // var res2 = DbContext.GetInstance().Execute(cmd2); // oldTempletId = (res2.Entities[0] as Game).TeamMode;//旧模板ID //} //GameLoopTempletHelper.UpdateTempletUseCount(game.TeamMode, oldTempletId); ///////////////////////// var result = DbContext.GetInstance().Execute(CommandHelper.CreateSave(entities)); if (game.ClubId.IsNotNullOrEmpty() && game.RowState == RowState.Added) { try { NotifyClubUser(game); } catch (Exception) { } } return(result); }
public void SetDTE(DTE dte) { _dte = dte; _commandHelper = new CommandHelper(dte); _fileHelper = new FileHelper(dte); }