public OperationDetails AddSizeAttribute(string arabicName, string englishName, long SizeCategoryId) { SizeAttribute option = new SizeAttribute(); option.DateAdded = DateTime.Now; option.DateModefied = DateTime.Now; OptionHelper sizeCat = _unitOfWork.OptionHelperRepository.Get(c => c.Id == SizeCategoryId).FirstOrDefault(); option.SizeCatId = SizeCategoryId; option = _unitOfWork.SizeAttributeRepository.Insert(option); SizeAttributeDescription arabicDesciption = new SizeAttributeDescription(); SizeAttributeDescription englishDesciption = new SizeAttributeDescription(); arabicDesciption.Name = arabicName; arabicDesciption.SizeAttributeId = option.Id; arabicDesciption.DateAdded = DateTime.Now; arabicDesciption.DateModefied = DateTime.Now; arabicDesciption.LanguageId = (long)Langs.Arabic; englishDesciption.Name = englishName; englishDesciption.SizeAttributeId = option.Id; englishDesciption.DateAdded = DateTime.Now; englishDesciption.DateModefied = DateTime.Now; englishDesciption.LanguageId = (long)Langs.English; _unitOfWork.SizeAttributeDescriptionRepository.Insert(arabicDesciption); _unitOfWork.SizeAttributeDescriptionRepository.Insert(englishDesciption); _unitOfWork.Save(); return(new OperationDetails(true, "تمت الإضافة بنجاح", option.Id.ToString())); }
///<Summary> /// ConvertHtmlToXps to convert html file to xps ///</Summary> public Response ConvertHtmlToXps(string[] fileNames, string folderName) { return(ProcessTask_(fileNames, (inFiles, outPath, zipOutFolder) => { Aspose.Html.Rendering.Xps.XpsRenderingOptions xps_options = new Aspose.Html.Rendering.Xps.XpsRenderingOptions(); if (Opts.HasCustomParameter("pageSize")) { var sz = OptionHelper.getPageSizeByName(Opts.GetCustomParameter("pageSize")); if (sz != null) { xps_options.PageSetup.AnyPage.Size = sz; } } Dictionary <string, string> customParams = null; if (Opts.HasCustomParameter("mdTheme")) { var csstheme = Opts.GetCustomParameter("mdTheme"); customParams = new Dictionary <string, string> { { "cssTheme", csstheme } }; } SourceFormat srcFormat = ExportHelper.GetSourceFormatByFileName(Opts.FileName); ExportHelper helper = ExportHelper.GetHelper(srcFormat, ExportFormat.XPS, customParams); helper.Export(inFiles, outPath, xps_options); })); }
public OperationDetails DeleteOption(long optionId) { OptionHelper option = unitOfWork.OptionHelperRepository.GetByID(optionId); if (option == null) { return(new OperationDetails(false, "الخيار غير موجودة", "")); } if (!option.SizeAttributes.Any()) { return(new OperationDetails(false, "لا يمكن حذف الخيار لوجود واصفات قياس مرتبطة", "")); } if (unitOfWork.OptionRepository.Get(c => c.OptionId == optionId).Any()) { return(new OperationDetails(false, "لا يمكن حذف الخيار لوجود منتجات مرتبطة", "")); } if (unitOfWork.ColorHelperRepository.Get(c => c.OptionId == optionId).Any()) { return(new OperationDetails(false, "لا يمكن حذف الخيار لوجود ألوان مرتبطة", "")); } if (unitOfWork.SizeHelperRepository.Get(c => c.OptionId == optionId).Any()) { return(new OperationDetails(false, "لا يمكن حذف الخيار لوجود قياسات مرتبطة", "")); } unitOfWork.OptionRepository.Delete(option); unitOfWork.Save(); return(new OperationDetails(true, "تمت عملية الحذف", "")); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); }); // AutoOption Config OptionHelper.Config(typeof(Options), new SqlWrapper(Configuration.GetConnectionString("DefaultConnectionString"))); }
private BoardOption PickBoardOption() { bool isValidOption = false; BoardOption boardOption = BoardOption.Flag; while (!isValidOption) { OptionHelper.PrintOption('r', "Reveal Tile"); OptionHelper.PrintOption('f', "Flag Tile"); string input = Console.ReadLine(); bool isChar = char.TryParse(input.Trim(), out char inputChar); if (isChar) { if (char.ToUpper(inputChar) == 'R') { isValidOption = true; boardOption = BoardOption.Reveal; } else if (char.ToUpper(inputChar) == 'F') { isValidOption = true; boardOption = BoardOption.Flag; } } if (!isValidOption) { Console.WriteLine("You didn't pick one of the listed options. Please try again."); } } return(boardOption); }
public void TestLargeImpliedVol() { var stock = TestDataHelper.GetStock("RIO"); Assert.AreEqual("RIO", stock.Name); var stockObject = TestHelper.CreateStock(stock); ForwardExpiry fwd = new ForwardExpiry(DateTime.Parse("24-09-2009"), 5818); Strike str = new Strike(5800, null, null, Units.Cents); fwd.AddStrike(str, true); stockObject.VolatilitySurface.AddExpiry(fwd); foreach (ForwardExpiry fwdExp in stockObject.VolatilitySurface.Expiries) { foreach (Strike strike in fwdExp.Strikes) { if (strike.StrikePrice == 5800 && (fwdExp.ExpiryDate == DateTime.Parse("24-09-2009"))) { var vol0 = OptionHelper.GetImpliedVol(stockObject, fwdExp.ExpiryDate, strike.StrikePrice, false, "A", 450.0, 120); AmOptionAnalytics call = new AmOptionAnalytics(stockObject.Date, fwdExp.ExpiryDate, Convert.ToDouble(stockObject.Spot), strike.StrikePrice, vol0, "A", "P", stockObject.RateCurve, stockObject.Dividends, 120); Assert.AreEqual(call.Price(), 450, 0.01); } } } }
private static void DisplayMainMenuOptions() { DisplayTitleAndCredits(); OptionHelper.PrintOption('1', "Start new game"); OptionHelper.PrintOption('q', "Quit"); CurrentState = GameState.MainMenu; }
public void TestImpliedVol2() { var stock = TestDataHelper.GetStock("ANZ"); Assert.AreEqual("ANZ", stock.Name); Stock stockObject = TestHelper.CreateStock(stock); ForwardExpiry fwd = new ForwardExpiry(DateTime.Parse("29-10-2009"), 3676); Strike str = new Strike(3650, null, null, Units.Cents); fwd.AddStrike(str, true); stockObject.VolatilitySurface.AddExpiry(fwd); foreach (ForwardExpiry fwdExp in stockObject.VolatilitySurface.Expiries) { foreach (Strike strike in fwdExp.Strikes) { if (strike.StrikePrice == 3650 && (fwdExp.ExpiryDate == DateTime.Parse("29-10-2009"))) { stockObject.Spot = 3676; var vol0 = OptionHelper.GetImpliedVol(stockObject, fwdExp.ExpiryDate, strike.StrikePrice, true, "A", 224.5, 120); AmOptionAnalytics call = new AmOptionAnalytics(stockObject.Date, fwdExp.ExpiryDate, Convert.ToDouble(stockObject.Spot), strike.StrikePrice, vol0, "A", "C", stockObject.RateCurve, stockObject.Dividends, 120); Assert.AreEqual(call.Price(), 224.5, 0.01); } } } }
protected void ResurseOptionsGUI(bool showBuild = false) { if (editorProfile != null) { pathBase = "EditorProfile/"; } else { pathBase = OptionHelper.GetAssetGUID(buildProfile) + "/"; } lastCategory = null; categoryExpanded = true; optionAvailable = true; buildCategory = showBuild; foreach (var option in options) { OptionGUIRecursive(option); } if (Option.changed) { FlushProfile(); Option.changed = false; } }
protected override void Load(System.Xml.XmlElement source) { XmlElement serverElement = (XmlElement)source.SelectSingleNode("server"); System.Net.IPAddress tempIp; if (System.Net.IPAddress.TryParse(serverElement.GetAttribute("serverIp"), out tempIp)) { this.IPAddress = serverElement.GetAttribute("serverIp"); } this.Port = int.Parse(serverElement.GetAttribute("port")); XmlElement baseElement = (XmlElement)source.SelectSingleNode("base"); this.HeartRange = int.Parse(baseElement.GetAttribute("heartRange")); this.IsAsync = bool.Parse(baseElement.GetAttribute("isAsync")); this.ClientType = int.Parse(baseElement.GetAttribute("clientType")); XmlElement verifyElement = (XmlElement)source.SelectSingleNode("verifyConn"); this.VerifyConnCommandString = verifyElement.InnerText.Trim(); XmlElement endCharElement = (XmlElement)source.SelectSingleNode("endChar"); this.EndChar = endCharElement.InnerText.Trim(); this.Spliter = OptionHelper.InterfaceBuilder <IMessageSpliter>(source.SelectSingleNode("spliter")).Value;; this.Combiner = OptionHelper.InterfaceBuilder <IProtocolCombine>(source.SelectSingleNode("combin")).Value; }
override public void PostprocessScene(Scene scene, OptionInclusion inclusion) { base.PostprocessScene(scene, inclusion); var script = OptionHelper.InjectFeature <VersionContainer>(scene, OptionInclusion.Feature); if (script != null) { script.version = Version.ProjectVersion; } }
/// <summary> /// Extracts List of OptionEntity from IFormCollection /// </summary> public static List <OptionEntity> ExtractOption(IFormCollection Inputs) { var Options = OptionHelper.ReadEntities(); foreach (var item in Options) { item.Value = Inputs[item.Key]; } return(Options); }
//----------------------------------------------------------------// public virtual Option DeserializeOption() { Option option = new Option(); string[] constituents = taskInfo.Options.Split(StringConstants.VERTICAL_LINE); foreach (string constituent in constituents) { string[] pair = constituent.Split(StringConstants.EQUAL); OptionHelper.TryMap(pair.FirstOrDefault(), pair.LastOrDefault(), ref option); } return(option); }
private void Save(object sender, RoutedEventArgs e) { if (txtDataSource.Text.Contains("local")) { System.Windows.MessageBox.Show("如需连接本地数据库,请使用\".\"或\"127.0.0.1\",不要使用local之类单词."); return; } UInt16 httpPort = 0; UInt16 tcpPort = 0; UInt16 oldPort = 0; if (!UInt16.TryParse(txtBasicHttpPort.Text, out httpPort) || !UInt16.TryParse(txtNetTcpPort.Text, out tcpPort)) { System.Windows.MessageBox.Show("请输入有效的端口号!", "提示"); return; } if (tcpPort > 4534 || tcpPort < 4502) { System.Windows.MessageBox.Show("NetTcp端口需要配置在4502~4534范围内!", "提示"); return; } OptionHelper.ConnectionString = "Data Source=" + txtDataSource.Text + ";Initial Catalog=" + txtDatabase.Text + ";User ID= " + txtLoginName.Text + ";Password= "******";"; try { bool r = true; r = r && OptionHelper.WriteString("CenterServer", "BasicHttpPort", txtBasicHttpPort.Text); r = r && OptionHelper.WriteString("CenterServer", "NetTcpPort", txtNetTcpPort.Text); r = r && OptionHelper.WriteString("CenterServer", "ServerIP", txtIP.Text); r = r && OptionHelper.WriteString("CenterServer", "OnlineIP", txtOnlineIP.Text); r = r && OptionHelper.WriteString("CenterServer", "ImgPath", txtImgPath.Text); r = r && OptionHelper.WriteString("CenterServer", "ZXAddr", txtzx.Text); if (!r) { System.Windows.MessageBox.Show("保存失败!", "提示"); return; } } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message, "异常"); return; } System.Windows.MessageBox.Show("保存配置后需要重新运行服务程序"); this.DialogResult = true; }
override public void PostprocessScene(Scene scene, OptionInclusion inclusion) { base.PostprocessScene(scene, inclusion); var prompt = OptionHelper.InjectFeature <Prompt>(scene, inclusion); if (prompt != null) { prompt.activationSequence = GetChild <OptionPromptActivation>().Value; prompt.fontSize = GetChild <OptionPromptFontSize>().Value; prompt.position = GetChild <OptionPromptPosition>().Value; } }
override public void PostprocessScene(Scene scene, OptionInclusion inclusion) { base.PostprocessScene(scene, inclusion); var host = OptionHelper.InjectFeature <TrimmerServerHost>(scene, inclusion); if (host != null) { host.enabled = Value; host.serverPort = GetChild <OptionServerPort>().Value; host.isDiscoverable = GetChild <OptionDiscoverable>().Value; } }
public override void Apply() { base.Apply(); var host = OptionHelper.GetSingleton <TrimmerServerHost>(Value); if (host != null) { host.enabled = Value; host.serverPort = GetChild <OptionServerPort>().Value; host.isDiscoverable = GetChild <OptionDiscoverable>().Value; } }
/// <summary> /// Editor coroutine wrapper for OptionHelper.RunScriptAsync. /// </summary> protected IEnumerator Execute(System.Diagnostics.ProcessStartInfo startInfo, string input = null, System.Action <string> onOutput = null, System.Action <string> onError = null, bool logError = true) { var outputBuilder = new StringBuilder(); var errorBuilder = new StringBuilder(); int?exitcode = null; var terminator = OptionHelper.RunScriptAsnyc( startInfo, input, (output) => { outputBuilder.AppendLine(output); if (onOutput != null) { onOutput(output); } }, (error) => { errorBuilder.AppendLine(error); if (onError != null) { onError(error); } }, (code) => { exitcode = code; } ); if (runningScripts == null) { runningScripts = new List <System.Action <bool> >(); } runningScripts.Add(terminator); while (exitcode == null) { yield return(null); } runningScripts.Remove(terminator); // 137 happens for Kill() and 143 for CloseMainWindow(), // which means the script has been canceled if (logError && exitcode != 0 && exitcode != 137 && exitcode != 143) { Debug.LogError(string.Format( "{0}: Failed to execute {1}: {2}\nOutput: {3}", name, Path.GetFileName(startInfo.FileName), errorBuilder.ToString(), outputBuilder.ToString() )); } yield return(exitcode); }
IEnumerator BeginNewGame() { yield return(load.ShowMessage("Loading")); if (LSys.tem == null) { yield return(LSys.Init(load)); } else { LSys.tem.Load = load; } //Loading data yield return(L.Init()); data = new GameData(); data.players = new PlayerMgmt(); data.towns = new TownMgmt(); data.buildings = new List <BuildingUnitData>(); data.units = new List <BuildingUnitData>(); data.features = new Dictionary <string, string>(); data.map = new GameMapData(); data.modi = new Dictionary <string, string>(); //show it ConnectGameObjs(); OptionHelper.RunStartOptions(); data.players.Init(); if (startConfig == null) { startConfig = new Dictionary <string, string>(); startConfig["name"] = "debug"; startConfig["type"] = "scenario"; startConfig["scenario"] = "tutorial3"; //startConfig["scenario"] = "screenshot"; startConfig["scenario"] = "debug"; } yield return(load.ShowMessage("Loading " + startConfig["name"])); if (startConfig["type"] == "endless") { yield return(StartScenario("endless", startConfig["map"])); } else { yield return(StartScenario(startConfig["scenario"], LSys.tem.scenarios[startConfig["scenario"]].map)); } }
public override void Apply() { base.Apply(); var prompt = OptionHelper.GetSingleton <Prompt>(Value); if (prompt != null) { prompt.enabled = Value; prompt.activationSequence = GetChild <OptionPromptActivation>().Value; prompt.fontSize = GetChild <OptionPromptFontSize>().Value; prompt.position = GetChild <OptionPromptPosition>().Value; } }
public CounterCaptureCommand(ILogger logger) : base("counter", "capture the counters in parameter") { AddOption(OptionHelper.CreateOption <string>("--serviceId", isRequired: true)); AddOption(OptionHelper.CreateOption <string>("--clusterId", isRequired: true)); AddOption(OptionHelper.CreateOption("--secretSource", defaultValue: SecretConfiguration.SecretSource.File)); AddOption(OptionHelper.CreateOption <string>("--counterKey", defaultValue: StreamingConstants.DefaultCounterGrain)); AddArgument(new Argument <List <string> >("Counters") { Arity = ArgumentArity.OneOrMore }); Handler = CommandHandler.Create <Parameters>(RunAsync); _logger = logger; }
//----------------------------------------------------------------// public virtual string SerializeOption() { string[] constituents = taskInfo.Options.Split(StringConstants.VERTICAL_LINE); StringBuilder builder = new StringBuilder(); foreach (string constituent in constituents) { string[] pair = constituent.Split(StringConstants.EQUAL); string key = pair.FirstOrDefault(); string value = OptionHelper.GetOptionValueByKey(key, option); builder.Append(String.Join(StringConstants.EQUAL, key, value)); builder.Append(StringConstants.VERTICAL_LINE); } return(builder.ToString()); }
public static bool UpdateVersionWindows(string path, Version version) { var args = string.Format( "- '{0}' {1} {2} {3} {4}", path, version.major, version.minor, version.patch, version.build ); string output, error; var exitcode = OptionHelper.RunScript("python", args, PythonUpdateWindows, out output, out error); if (exitcode != 0) { Debug.LogError("OptionVersion: Failed to run python to update version: " + output); return(false); } return(true); }
public ChaosAgentCommand(ILogger logger) : base("chaosagent", "Shutdown/restart servers gracefully or not") { AddOption(OptionHelper.CreateOption <string>("--serviceId", isRequired: true)); AddOption(OptionHelper.CreateOption <string>("--clusterId", isRequired: true)); AddOption(OptionHelper.CreateOption("--secretSource", defaultValue: SecretConfiguration.SecretSource.File)); AddOption(OptionHelper.CreateOption <int>("--wait", defaultValue: 30)); AddOption(OptionHelper.CreateOption <int>("--serversPerRound", defaultValue: 1)); AddOption(OptionHelper.CreateOption <int>("--rounds", defaultValue: 5)); AddOption(OptionHelper.CreateOption <int>("--roundDelay", defaultValue: 60)); AddOption(OptionHelper.CreateOption <bool>("--graceful", defaultValue: false)); AddOption(OptionHelper.CreateOption <bool>("--restart", defaultValue: false)); Handler = CommandHandler.Create <Parameters>(RunAsync); _logger = logger; }
public IViewComponentResult Invoke(IFormCollection Inputs) { List <OptionEntity> Options; if (Inputs == null) { Options = OptionHelper.ReadEntities(); } else { Options = PageTools.ExtractOption(Inputs); OptionHelper.UpdateEntities(Options); TempData["Message"] = "Success"; } return(View(Options)); }
override public void SetPassword(string service, string name, string password) { // We use the interactive mode of security here that allows us to // pipe the command to stdin and thus avoid having the password // exposed in the process table. var command = string.Format( "add-generic-password -U -a '{0}' -s '{1}' -w '{2}'\n", name, service, password ); string output, error; var code = OptionHelper.RunScript("security", "-i", command, out output, out error); if (code != 0) { Debug.LogError("Failed to store password in Keychain: " + error); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { SystemDefaultConfig.IsCS = true; SystemDefaultConfig.DataUpdateFlag = 3; //显示托盘。 SetNotifyIcon(); JudgeProcessExist(); var _startTime = DateTime.Now; //状态定时器 DispatcherTimer dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromSeconds(1); dt.Tick += (obj, args) => { tbRunTime.Text = GetTimeString((int)(DateTime.Now - _startTime).TotalSeconds); }; dt.Start(); _basicHttpPort = OptionHelper.ReadInt("CenterServer", "BasicHttpPort", 80); _netTcpPort = OptionHelper.ReadInt("CenterServer", "NetTcpPort", 4508); _isBasicHttpOnly = OptionHelper.ReadBool("CenterServer", "IsBasicHttpOnly", false); this.Title = OptionHelper.ReadString("CenterServer", "Title", "智慧云平台服务"); _ServerIP = OptionHelper.ReadString("CenterServer", "ServerIP", ""); SystemInfo.ImgPath = OptionHelper.ReadString("CenterServer", "ImgPath", ""); SystemDefaultConfig.ReadConnectionString = new ConnectionStringSettings("ReadConnectionString", "data source=" + OptionHelper.DataSource + ";database=" + OptionHelper.Database + ";user id=" + OptionHelper.LoginName + ";password="******"", "System.Data.SqlClient").ToString(); SystemDefaultConfig.WriteConnectionString = new ConnectionStringSettings("ConnectionString", "data source=" + OptionHelper.DataSource + ";database=" + OptionHelper.Database + ";user id=" + OptionHelper.LoginName + ";password="******"", "System.Data.SqlClient").ToString(); ThreadPool.QueueUserWorkItem(_ => TestDBConnectionState()); LoadExtendConfig(); foreach (var assembly in ExtendAssemblys.Where(a => a.IsEnabled)) { StartAssembly(assembly); } lvservers.ItemsSource = ExtendAssemblys[0].ServiceHosts; PlatformWcfServers.WXServiceCallback.HeartChanged += WXServiceCallback_HeartChanged; PlatformWcfServers.WXServiceCallback.HeartdelteChanged += WXServiceCallback_HeartdelteChanged; lvconnection.ItemsSource = PlatformClientes; PlatformDownloadData.StartDownload(); }
public ServerCommand(ISiloConfigurator <T> siloConfigurator) : base(siloConfigurator.Name) { _siloRunner = new ServerRunner <T>(siloConfigurator); AddOption(OptionHelper.CreateOption <string>("--serviceId", isRequired: true)); AddOption(OptionHelper.CreateOption <string>("--clusterId", isRequired: true)); AddOption(OptionHelper.CreateOption("--siloPort", defaultValue: 11111)); AddOption(OptionHelper.CreateOption("--gatewayPort", defaultValue: 30000)); AddOption(OptionHelper.CreateOption("--secretSource", defaultValue: SecretConfiguration.SecretSource.File)); foreach (var opt in siloConfigurator.Options) { AddOption(opt); } Handler = CommandHandler.Create <CommonParameters, T>(_siloRunner.Run); }
private void LoadOption() { //LogOption.IsConsoleEnabled = true; //LogOption.IsDebugEnabled = true; //LogOption.IsErrorEnabled = true; //LogOption.IsFatalEnabled = true; //LogOption.IsInfoEnabled = true; //LogOption.IsWarnEnabled = true; //LogOption.FileMaxSize = 5; LogOption.IsConsoleEnabled = OptionHelper.ReadBool("Log", "IsConsoleEnabled", true); LogOption.IsDebugEnabled = OptionHelper.ReadBool("Log", "IsDebugEnabled", true); LogOption.IsErrorEnabled = OptionHelper.ReadBool("Log", "IsErrorEnabled", true); LogOption.IsFatalEnabled = OptionHelper.ReadBool("Log", "IsFatalEnabled", true); LogOption.IsInfoEnabled = OptionHelper.ReadBool("Log", "IsInfoEnabled", true); LogOption.IsWarnEnabled = OptionHelper.ReadBool("Log", "IsWarnEnabled", true); LogOption.FileMaxSize = OptionHelper.ReadInt("Log", "FileMaxSize", 5); }
override public string GetPassword(string service, string name) { var command = string.Format( "find-generic-password -a '{0}' -s '{1}' -w", name, service ); string output, error; var code = OptionHelper.RunScript("security", command, out output, out error); if (code != 0) { return(null); } else { return(output.TrimEnd('\n')); } }