/// <summary> /// message IDに対応したメッセージ記述。<br/> /// Get message description from message ID /// </summary> /// <param name="messageID"> /// messageID /// </param> /// <returns> /// メッセージ記述<br/> /// Get message description /// </returns> public static string GetMessageDescription(string messageID) { // FxBusinessMessageCulture string fxBusinessMessageCulture = GetConfigParameter.GetConfigValue(FxLiteral.BUSINESSMESSAGECULTUER); // Check FxBusinessMessageCulture CultureInfo uiCulture = null; if (string.IsNullOrEmpty(fxBusinessMessageCulture)) { // Use CurrentUICulture uiCulture = Thread.CurrentThread.CurrentUICulture; } else { try { // Use FxBusinessMessageCulture uiCulture = new CultureInfo(fxBusinessMessageCulture); } catch { // Use CurrentUICulture uiCulture = Thread.CurrentThread.CurrentUICulture; } } // call overload. return(GetMessage.GetMessageDescription(messageID, uiCulture)); }
/// <summary> /// Sets all intial values to member variables from the .config file /// </summary> public void SetFromConfig() { try { // Get maximum thread count from .config file string maxThreadCount = GetConfigParameter.GetConfigValue("FxMaxThreadCount"); if (string.IsNullOrEmpty(maxThreadCount)) { // Set default _maxThreadCount = 10; } else { _maxThreadCount = int.Parse(maxThreadCount); } // Get number of seconds from .config file string numberOfSeconds = GetConfigParameter.GetConfigValue("FxMaxThreadCount"); if (string.IsNullOrEmpty(numberOfSeconds)) { // Set default _numberOfSeconds = 1; } else { _numberOfSeconds = int.Parse(numberOfSeconds); } // Get maximum number of retries from .config file string maxNumberOfRetries = GetConfigParameter.GetConfigValue("FxMaxNumberOfRetries"); if (string.IsNullOrEmpty(maxNumberOfRetries)) { // Set default _maxNumberOfRetries = 10; } else { _maxNumberOfRetries = int.Parse(maxNumberOfRetries); } // Get maximum number of hours from .config file string maxNumberOfHours = GetConfigParameter.GetConfigValue("FxMaxNumberOfHours"); if (string.IsNullOrEmpty(maxNumberOfHours)) { // Set default _maxNumberOfHours = 24; } else { // Get maximum number of hours from .config file _maxNumberOfHours = int.Parse(maxNumberOfHours); } } catch { // Error while setting from config LogIF.ErrorLog("ASYNC-SERVICE", GetMessage.GetMessageDescription("E0007")); throw new Exception(); } }
/// <summary></summary> /// <param name="args"></param> public static void Main(string[] args) { // configの初期化(無くても動くようにせねば。) #if NETCORE GetConfigParameter.InitConfiguration("appsettings.json"); #endif try { MyDebug.OutputDebugAndConsole("----------------------------------------------------------------------------------------------------"); TestEnumToStringExtensions.Root(); MyDebug.OutputDebugAndConsole("----------------------------------------------------------------------------------------------------"); TestXmlLib.Root(); MyDebug.OutputDebugAndConsole("----------------------------------------------------------------------------------------------------"); TestDeflateCompression.Root(); MyDebug.OutputDebugAndConsole("----------------------------------------------------------------------------------------------------"); // echoすると例外 try { Console.ReadKey(); } catch { } } catch (Exception ex) { MyDebug.OutputDebugAndConsole(ex.ToString()); } }
/// <summary>OnStartupイベント</summary> protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // configの初期化 GetConfigParameter.InitConfiguration("appsettings.json"); }
/// <summary>コンストラクタ</summary> public _3TierEngine() { // Daoクラス名のヘッダ・フッタ this.DaoClassNameHeader = GetConfigParameter.GetConfigValue("DaoClassNameHeader"); this.DaoClassNameFooter = GetConfigParameter.GetConfigValue("DaoClassNameFooter"); // メソッド名のヘッダ・フッタ(静的) this.MethodNameHeaderS = GetConfigParameter.GetConfigValue("MethodNameHeaderS"); this.MethodNameFooterS = GetConfigParameter.GetConfigValue("MethodNameFooterS"); // メソッド名のCRUD名 this.MethodLabel_Ins = GetConfigParameter.GetConfigValue("MethodLabel_Ins"); this.MethodLabel_Sel = GetConfigParameter.GetConfigValue("MethodLabel_Sel"); this.MethodLabel_Upd = GetConfigParameter.GetConfigValue("MethodLabel_Upd"); this.MethodLabel_Del = GetConfigParameter.GetConfigValue("MethodLabel_Del"); this.MethodLabel_SelCnt = GetConfigParameter.GetConfigValue("MethodLabel_SelCnt"); // メソッド名のヘッダ・フッタ(動的) this.MethodNameHeaderD = GetConfigParameter.GetConfigValue("MethodNameHeaderD"); this.MethodNameFooterD = GetConfigParameter.GetConfigValue("MethodNameFooterD"); // Updateのパラメタ名のヘッダ・フッタ this.UpdateParamHeader = GetConfigParameter.GetConfigValue("UpdateParamHeader"); this.UpdateParamFooter = GetConfigParameter.GetConfigValue("UpdateParamFooter"); // Likeのパラメタ名のヘッダ・フッタ this.LikeParamHeader = GetConfigParameter.GetConfigValue("LikeParamHeader"); this.LikeParamFooter = GetConfigParameter.GetConfigValue("LikeParamFooter"); }
/// <summary>[埋め込まれたリソース ファイル]を含むアセンブリを取得する</summary> /// <param name="assemblyString"> /// アセンブリ名 /// http://msdn.microsoft.com/ja-jp/library/k8xx4k69.aspx /// </param> /// <returns>Assembly</returns> private static Assembly GetEntryAssembly(string assemblyString) { // Azureスイッチ string azure = GetConfigParameter.GetConfigValue("Azure"); if (string.IsNullOrEmpty(azure)) { // 通常時 if (string.IsNullOrEmpty(assemblyString)) { // assemblyString 指定なし return(Assembly.GetEntryAssembly()); } else { // assemblyString 指定あり return(Assembly.Load(assemblyString)); } } else { // Azureスイッチ・オンの場合 if (string.IsNullOrEmpty(assemblyString)) { // assemblyString 指定なし return(Assembly.Load(azure)); } else { // assemblyString 指定あり return(Assembly.Load(assemblyString)); } } }
/// <summary>SQL実行終了処理を実装する共通UOCメソッド(異常時)</summary> /// <param name="sql">実行したSQLの情報</param> /// <param name="ex">エラー情報</param> /// <remarks>データ アクセス親クラス1から利用される派生の末端</remarks> protected override void UOC_AfterQuery(string sql, Exception ex) { // 性能測定終了 this.perfRec.EndsPerformanceRecord(); // SQLトレースログ出力 // ------------ // メッセージ部 // ------------ // 処理時間(実行時間), 処理時間(CPU時間), ユーザ名, 実行したSQLの情報 // ------------ string strLogMessage = this.perfRec.ExecTime + "," + this.perfRec.CpuTime + "," + ((MyUserInfo)(this.GetDam().Obj)).UserName + "," + sql; // Log4Netへログ出力 if (string.IsNullOrEmpty(GetConfigParameter.GetConfigValue(PubLiteral.SQL_TRACELOG))) { // SQLトレースログ(OFF) } else if (GetConfigParameter.GetConfigValue(PubLiteral.SQL_TRACELOG).ToUpper() == PubLiteral.ON) { LogIF.ErrorLog("SQLTRACE", strLogMessage); } else if (GetConfigParameter.GetConfigValue(PubLiteral.SQL_TRACELOG).ToUpper() == PubLiteral.OFF) { // SQLトレースログ(OFF) } else { // パラメータ・エラー(書式不正) throw new ArgumentException( String.Format(PublicExceptionMessage.SWITCH_ERROR, PubLiteral.SQL_TRACELOG)); } // --- // 以下も、ログ出力で使用可能 object obj = null; // UOC_Connection等で情報を設定しておく。 // UserInfoなどの情報を想定している。 obj = this.GetDam().Obj; // SQL実行時に情報が自動設定される。 // ・ExecSelectFill_DT // DataTable // ・ExecSelectFill_DS // DataSet // ・ExecSelect_DR // IDataReader // ・ExecSelectScalar // object // ・ExecInsUpDel_NonQuery // int obj = this.LogInfo; }
/// <summary>SetSqlByFileの強化版メソッド</summary> /// <param name="sQLFileName">ファイル名</param> /// <param name="cmdType">CommandType</param> public void SetSqlByFile2(string sQLFileName, CommandType?cmdType) { // SQLを設定する。 if (MyBaseDao.UseEmbeddedResource) { // 埋め込まれたリソースファイル if (cmdType.HasValue) { this.SetSqlByFile( GetConfigParameter.GetConfigValue("sqlTextFilePath") + "." + sQLFileName, cmdType.Value); } else { this.SetSqlByFile( GetConfigParameter.GetConfigValue("sqlTextFilePath") + "." + sQLFileName); } } else { // 通常のファイル if (cmdType.HasValue) { this.SetSqlByFile( Path.Combine( GetConfigParameter.GetConfigValue("sqlTextFilePath"), sQLFileName), cmdType.Value); } else { this.SetSqlByFile( Path.Combine( GetConfigParameter.GetConfigValue("sqlTextFilePath"), sQLFileName)); } } }
// P層フレームワークのイベント処理機能へ // コントロール イベントを追加するコード #region コントロールの検索、取得、イベントハンドラの設定処理 /// <summary>イベント追加処理</summary> private void addControlEvent() { // 2009/07/21-start #region コントロール取得処理 #region 旧処理 //// CHECK BOX //MyCmnFunction.GetCtrlAndSetClickEventHandler( // this, GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX), // new System.EventHandler(this.Check_CheckedChanged), this.ControlHt); #endregion // プレフィックス string prefix = ""; // プレフィックスとイベント ハンドラのディクショナリを生成 Dictionary <string, object> prefixAndEvtHndHt = new Dictionary <string, object>(); // CHECK BOX prefix = GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Check_CheckedChanged)); } // コントロール検索&イベントハンドラ設定 MyCmnFunction.GetCtrlAndSetClickEventHandler2(this, prefixAndEvtHndHt, this.ControlHt); #endregion // 2009/07/21-end }
/// <summary>Connectionオブジェクト生成メソッド</summary> /// <returns>IDbConnection</returns> public static IDbConnection CreateConnection() { switch (ASPNETIdentityConfig.UserStoreType) { case EnumUserStoreType.SqlServer: //return new SqlConnection(GetConfigParameter.GetConnectionString("ConnectionString_SQL")); return(new ProfiledDbConnection( new SqlConnection(GetConfigParameter.GetConnectionString("ConnectionString_SQL")), new TraceDbProfiler())); case EnumUserStoreType.ODPManagedDriver: //return new OracleConnection(GetConfigParameter.GetConnectionString("ConnectionString_ODP")); return(new ProfiledDbConnection( new OracleConnection(GetConfigParameter.GetConnectionString("ConnectionString_ODP")), new TraceDbProfiler())); case EnumUserStoreType.PostgreSQL: //return new NpgsqlConnection(GetConfigParameter.GetConnectionString("ConnectionString_NPS")); return(new ProfiledDbConnection( new NpgsqlConnection(GetConfigParameter.GetConnectionString("ConnectionString_NPS")), new TraceDbProfiler())); default: return(null); } }
/// <summary>Returns the specified string resource for the specified culture or current UI culture. </summary> /// <param name="key">resource key</param> /// <returns>resource string</returns> private static string CmnFunc(string key) { // We acquire ResourceManager. ResourceManager rm = MyBusinessSystemExceptionMessageResource.ResourceManager; // We acquire a value from App.Config. string FxUICulture = GetConfigParameter.GetConfigValue(PubLiteral.EXCEPTIONMESSAGECULTUER); if (string.IsNullOrEmpty(FxUICulture)) { // When the key is not set to App.Config, we use a default culture. return(rm.GetString(key)); } else { // When the key is set to App.Config, we use the specified culture. try { CultureInfo culture = new CultureInfo(FxUICulture); return(rm.GetString(key, culture)); } #pragma warning disable catch (Exception ex) // There is not CultureNotFoundException in .NET3.5. { #pragma warning restore // When the specified culture is not an effective name, we use a default culture. return(rm.GetString(key)); } } }
/// <summary>数定義(コンフィグ)の取得処理</summary> /// <param name="configKey">コンフィグのキー</param> /// <param name="defaultNum">デフォルト値</param> /// <returns>数</returns> public static int GetNumFromConfig(string configKey, int defaultNum) { int temp; // null チェック if (GetConfigParameter.GetConfigValue(configKey) == null) { // デフォルト値 return(defaultNum); } else { // int チェック if (int.TryParse(GetConfigParameter.GetConfigValue(configKey), out temp)) { // 変換完了 return(temp); } else { // 変換ミス throw new FrameworkException( FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_NUMVAL[0], String.Format(FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_NUMVAL[1], configKey)); } } }
static void Main() { #if NETCOREAPP // configの初期化 GetConfigParameter.InitConfiguration("appsettings.json"); #else #endif try { // Add DefaultCulture key in app.Config file and take the culture value from app.Config file. string culture = GetConfigParameter.GetConfigValue("DefaultCulture"); if (!string.IsNullOrEmpty(culture)) { Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture); Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culture); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } catch (Exception ex) { MessageBox.Show(string.Format(RM_GetString("EntryPoint"), ex.Message)); } }
/// <summary>初期化処理</summary> protected void Page_Load(object sender, EventArgs e) { // 親画面の画面GUIDを設定(QueryString)から取得 string parentScreenGuid = (string)Request.QueryString[FxHttpQueryStringIndex.PARENT_SCREEN_GUID]; // メッセージIDとメッセージをセッションより取得し、設定 this.lblmessage.Text = (string)Session[parentScreenGuid + FxHttpSessionIndex.MODAL_DIALOG_MESSAGE]; this.lblmessageID.Text = (string)Session[parentScreenGuid + FxHttpSessionIndex.MODAL_DIALOG_MESSAGEID]; // タイトル設定 this.Title = (string)Session[parentScreenGuid + FxHttpSessionIndex.MODAL_DIALOG_NAME]; // アイコンへのパスを取得 string iconPath; // 選択入力を促すアイコン(?)を設定 iconPath = GetConfigParameter.GetConfigValue(FxLiteral.QUESTION_ICON_PATH); // エラー処理 if (iconPath == "") { throw new FrameworkException( FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH1[0], String.Format(FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_PATH1[1], FxLiteral.QUESTION_ICON_PATH)); } this.imgIcon.ImageUrl = iconPath; // 表示の完了後、セッションを消去する。 Session.Remove(parentScreenGuid + FxHttpSessionIndex.MODAL_DIALOG_MESSAGE); Session.Remove(parentScreenGuid + FxHttpSessionIndex.MODAL_DIALOG_MESSAGEID); Session.Remove(parentScreenGuid + FxHttpSessionIndex.MODAL_DIALOG_NAME); // ACCESSログ出力 ---------------------------------------------- // ------------ // メッセージ部 // ------------ // ユーザ名, IPアドレス, // レイヤ, 画面名, コントロール名, 処理名 // 処理時間(実行時間), 処理時間(CPU時間) // エラーメッセージID, エラーメッセージ等 // ------------ string strLogMessage = "," + this.GetUserInfo().UserName + "," + Request.UserHostAddress + ",init" + ",YesNoMessageDialog" + ","; // Log4Netへログ出力 LogIF.InfoLog("ACCESS", strLogMessage); }
static void Main() { // configの初期化 GetConfigParameter.InitConfiguration("appsettings.json"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
/// <summary> /// コンストラクタ /// </summary> public WebCustomImageMap() { // コンストラクタでのスタイル系のプロパティ設定は、 // CSSとの相性が悪と考え、廃止しました。 // これはサンプル用に残した。 this.Height = 200; this.Width = 200; this.ImageUrl = GetConfigParameter.GetConfigValue("ImagePath"); }
/// <summary>Damの初期化</summary> private void InitDam() { // Initializes dam this._dam = new DamSqlSvr(); this._dam.Obj = new MyUserInfo("WorkflowTest", "127.0.0.1"); // Gets the connection string from config and open the db connection this._dam.ConnectionOpen(GetConfigParameter.GetConnectionString("ConnectionString_SQL")); this._dam.BeginTransaction(DbEnum.IsolationLevelEnum.ReadCommitted); }
/// <summary>Main</summary> static void Main(string[] args) { //////////////////////////////////////////////////////////////////////// // 簡素なサンプルなので、 // ・多重化(タスク毎、結果セットを分割) // ・フェッチ・サイズ(メモリ消費量を抑える) // ・コミット・インターバル、リラン // 等の考慮が別途必要になることがあります。 //////////////////////////////////////////////////////////////////////// // configの初期化 GetConfigParameter.InitConfiguration("appsettings.json"); // コマンドラインをバラす関数がある。 List <string> valsLst = null; Dictionary <string, string> argsDic = null; PubCmnFunction.GetCommandArgs('/', out argsDic, out valsLst); // 引数クラスを生成 // 下位(B・D層)は、テスト クラスを流用する TestParameterValue testParameterValue = new TestParameterValue( System.Reflection.Assembly.GetExecutingAssembly().Location, "-", "SelectCount", argsDic["/DAP"] + "%" + argsDic["/MODE1"] + "%" + argsDic["/MODE2"] + "%" + argsDic["/EXROLLBACK"], new MyUserInfo("", "")); // 戻り値 TestReturnValue testReturnValue; // B層呼出し LayerB layerB = new LayerB(); testReturnValue = (TestReturnValue)layerB.DoBusinessLogic(testParameterValue, DbEnum.IsolationLevelEnum.ReadCommitted); if (testReturnValue.ErrorFlag == true) { // 結果(業務続行可能なエラー) string error = "ErrorMessageID:" + testReturnValue.ErrorMessageID + "\r\n"; error += "ErrorMessage:" + testReturnValue.ErrorMessage + "\r\n"; error += "ErrorInfo:" + testReturnValue.ErrorInfo + "\r\n"; Console.WriteLine(error); Console.ReadKey(); } else { // 結果(正常系) Console.WriteLine(testReturnValue.Obj.ToString() + "件のデータがあります"); Console.ReadKey(); } }
/// <summary>constructor</summary> /// <param name="configuration">IConfiguration</param> public Startup(IConfiguration configuration) { Configuration = configuration; // ライブラリにも設定 GetConfigParameter.InitConfiguration(configuration); // Dockerで埋め込まれたリソースを使用する場合、 // 以下のコメントアウトを解除し、appsettings.jsonのappSettings sectionに、 // "Azure": "既定の名前空間" を指定し、設定ファイルを埋め込まれたリソースに変更する。 //Touryo.Infrastructure.Business.Dao.MyBaseDao.UseEmbeddedResource = true; }
static void Main() { // configの初期化 GetConfigParameter.InitConfiguration("appsettings.json"); // 既定の処理 Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // UnhandledExceptionイベント・ハンドラを登録する Thread.GetDomain().UnhandledException += new UnhandledExceptionEventHandler(Application_UnhandledException); // ThreadExceptionイベント・ハンドラを登録する Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); // スプラッシュ画面の表示 Splash.ShowSplash(new Login()); // <スピンロック> // SleepすればCPUオーバヘッドはほとんど無いが // Sleep時間を長く、ループ回数を短くする // ことでよりCPUオーバヘッドを軽減できる。 for (int i = 0; i < 30; i++) { if (Splash.SpinLock) { break; // 直ちに抜ける } Thread.Sleep(100); } // ThreadExceptionイベント・ハンドラを登録する Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); // 次の画面(ログイン画面)の表示 Application.Run(Splash.NextForm); if (Program.FlagEnd) { return; // ログインしないで終わった場合 } // ThreadExceptionイベント・ハンドラを登録する Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); // 業務画面の表示(業務の開始) Application.Run(new Form1()); }
/// <summary>開始処理</summary> private void Form1_Load(object sender, EventArgs e) { // イベントハンドラ this.dataGridView1.DataError += new DataGridViewDataErrorEventHandler(DataGridView_DataError); // ステータス this.cmbTSColType.SelectedIndex = 0; this.cmbTableType.SelectedIndex = 0; dam = new DamSqlSvr(); dam.Obj = new MyUserInfo("userName", Environment.MachineName); this.dam.ConnectionOpen(GetConfigParameter.GetConnectionString("ConnectionString_SQL")); }
/// <summary>Constructor</summary> public LayerB() { // Number of seconds to sleep the thread. string numberOfSeconds = GetConfigParameter.GetConfigValue("FxSleepUserProcess"); if (!string.IsNullOrEmpty(numberOfSeconds)) { this.NumberOfSeconds = int.Parse(numberOfSeconds); } else { this.NumberOfSeconds = 5; } }
//(不要であれば削除すること) // P層フレームワークのイベント処理機能へ // コントロール イベントを追加するコード #region コントロールの検索、取得、イベントハンドラの設定処理 /// <summary>イベント追加処理</summary> private void addControlEvent() { #region Formイベント // Formイベント this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_CMNEventHandler); // FormのKeyイベント this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form_KeyDownEventHandler); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form_CMNEventHandler); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form_KeyPressEventHandler); this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form_CMNEventHandler); this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form_KeyUpEventHandler); this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form_CMNEventHandler); #endregion #region コントロール取得処理 #region 旧処理 //// CHECK BOX //RcMyCmnFunction.GetCtrlAndSetClickEventHandler( // this, GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX), // new System.EventHandler(this.Check_CheckedChanged), this.ControlHt); ////// TOOL STRIP MENU ITEM(再起でファインドできないので各画面で設定) ////RcMyCmnFunction.GetCtrlAndSetClickEventHandler( //// this, GetConfigParameter.GetConfigValue("FxPrefixOfToolStripMenuItem"), //// new System.EventHandler(this.Button_Click), this.ControlHt); #endregion // プレフィックス string prefix = ""; // プレフィックスとイベント ハンドラのディクショナリを生成 Dictionary <string, object> prefixAndEvtHndHt = new Dictionary <string, object>(); // CHECK BOX prefix = GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Check_CheckedChanged)); } // コントロール検索&イベントハンドラ設定 RcMyCmnFunction.GetCtrlAndSetClickEventHandler2(this, prefixAndEvtHndHt, this.ControlHt); #endregion }
/// <summary>Constructor</summary> public LayerB() { #region SampleのSimulation // Number of seconds to sleep the thread. string numberOfSeconds = GetConfigParameter.GetConfigValue("FxSleepUserProcess"); if (!string.IsNullOrEmpty(numberOfSeconds)) { this.NumberOfSeconds = int.Parse(numberOfSeconds); } else { this.NumberOfSeconds = 5; } // Max progress rate string maxProgressRate = GetConfigParameter.GetConfigValue("FxMaxProgressRate"); if (!string.IsNullOrEmpty(maxProgressRate)) { this.MaxProgressRate = uint.Parse(maxProgressRate); } else { this.MaxProgressRate = 30; } // Stop probability. string stopPercentage = GetConfigParameter.GetConfigValue("FxStopPercentage"); if (!string.IsNullOrEmpty(stopPercentage)) { this.StopPercentage = uint.Parse(stopPercentage); } else { this.StopPercentage = 3; } // Abort probability. string abortPercentage = GetConfigParameter.GetConfigValue("FxAbortPercentage"); if (!string.IsNullOrEmpty(abortPercentage)) { this.AbortPercentage = uint.Parse(abortPercentage); } else { this.AbortPercentage = 1; } #endregion }
/// <summary>終了処理(3秒待って終了)</summary> private void FinalBeginInvoke() { // 非同期呼び出し Program.Af = new MyBaseAsyncFunc(this.panel1); // 非同期処理本体デレゲード Program.Af.AsyncFunc = delegate(object o) { // 指定時間スリープ string temp = GetConfigParameter.GetConfigValue("PDWSleepSec"); if (!string.IsNullOrEmpty(temp)) { int sleepSec = 0; if (int.TryParse(temp, out sleepSec)) { // 指定の時間スリープ Thread.Sleep(sleepSec * 1000); } } return(null); }; // 進捗報告・無名関数デレゲード Program.Af.ChangeProgress = null; // 結果設定・無名関数デレゲード Program.Af.SetResult = delegate(object retVal) { // スリープの後、自身を閉じる。 this.Close(); }; // 非同期処理を開始させる。 Program.Af.Parameter = null; if (Program.Af.Start()) { //this.xxx(string.Format( // "キューイングされました、現在のスレッド数:{0}", // BaseAsyncFunc.ThreadCount.ToString())); } else { //this.xxx(string.Format( // "非同期スレッドが最大数に達しています。:{0}", // BaseAsyncFunc.ThreadCount.ToString())); } }
/// <summary>キャッシュ制御処理(スイッチ付き)</summary> private void CacheControlWithSwitch() { // システムで固定に出来る場合は、ここでキャッシュ無効化する。 // また、ユーザープログラムのファイル・ダウンロード処理などで // フレームワークの設定したキャッシュ制御を変更したい場合は、Response.Clearを実行して再設定する。 // 画面遷移方法の定義を取得 string noCache = GetConfigParameter.GetConfigValue(MyLiteral.CACHE_CONTROL); // デフォルト値対策:設定なし(null)の場合の扱いを決定 if (noCache == null) { // OFF扱い noCache = FxLiteral.OFF; } if (noCache.ToUpper() == FxLiteral.ON) { // ON // http - How to control web page caching, across all browsers? - Stack Overflow // http://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers // IPA ISEC セキュア・プログラミング講座:Webアプリケーション編 第5章 暴露対策:プロキシキャッシュ対策 // https://www.ipa.go.jp/security/awareness/vendor/programmingv2/contents/405.html // Using ASP.NET-MVC: //this.Response.Cache.SetCacheability(HttpCacheability.NoCache); // HTTP 1.1. //this.Response.Cache.AppendCacheExtension("no-store, must-revalidate"); MyHttpContext.Current.Response.Headers.Add("Cache-Control", new StringValues(new string[] { "no-cache", "no-store", "must-revalidate" })); //this.Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. MyHttpContext.Current.Response.Headers.Add("Pragma", new StringValues("no-cache")); //this.Response.AppendHeader("Expires", "0"); // Proxies. MyHttpContext.Current.Response.Headers.Add("Expires", new StringValues("0")); } else if (noCache.ToUpper() == FxLiteral.OFF) { // OFF } else { // パラメータ・エラー(書式不正) throw new FrameworkException( FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_SWITCH1[0], String.Format(FrameworkExceptionMessage.ERROR_IN_WRITING_OF_FX_SWITCH1[1], MyLiteral.CACHE_CONTROL)); } }
/// <summary>Get</summary> /// <param name="fileName"> /// CurrentUICulture等の拡張子を除くテキスト・ファイル名 /// </param> /// <param name="codePage"></param> /// <param name="resourcesString"> /// テキスト・ファイルが見つからない場合に使用するリソース文字列 /// </param> /// <returns>文字列</returns> public static string Get(string fileName, int codePage, string resourcesString) { CultureInfo currentUICulture = null; string uICultureName = ""; string contentOfLetter = ""; // テキスト・ファイル文字列の利用 do { if (currentUICulture == null) { // 初回 currentUICulture = Thread.CurrentThread.CurrentUICulture; } else { // フォールバック currentUICulture = currentUICulture.Parent; } uICultureName = currentUICulture.Name; string path = GetConfigParameter.GetConfigValue("ContentOfLetterFilePath") + "\\" + fileName + string.Format(".{0}.txt", uICultureName); if (ResourceLoader.Exists(path, false)) { contentOfLetter = ResourceLoader.LoadAsString(path, Encoding.GetEncoding(codePage)); } }while ( !string.IsNullOrEmpty(uICultureName) && // フォールバックが終わった。 string.IsNullOrEmpty(contentOfLetter) // ファイルを読み取れなかった。 ); if (string.IsNullOrEmpty(contentOfLetter)) // 既定(英語) { string path = GetConfigParameter.GetConfigValue("ContentOfLetterFilePath") + "\\" + fileName + ".txt"; if (ResourceLoader.Exists(path, false)) { contentOfLetter = ResourceLoader.LoadAsString(path, Encoding.GetEncoding(codePage)); } } // リソース文字列の利用 if (string.IsNullOrEmpty(contentOfLetter) && !string.IsNullOrEmpty(resourcesString)) { contentOfLetter = resourcesString; } return(contentOfLetter); }
/// <summary> /// コントロールのプレフィックスと /// イベント ハンドラのディクショナリを生成 /// </summary> /// <returns> /// プレフィックスと /// イベント ハンドラのディクショナリ /// </returns> protected Dictionary <string, object> MyCreatePrefixAndEvtHndHt() { // プレフィックス string prefix = ""; // プレフィックスとイベント ハンドラのディクショナリを生成 Dictionary <string, object> prefixAndEvtHndHt = new Dictionary <string, object>(); // CHECK BOX prefix = GetConfigParameter.GetConfigValue(MyLiteral.PREFIX_OF_CHECK_BOX); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Check_CheckedChanged)); } return(prefixAndEvtHndHt); }
public string[] ValidateAuthTicket(string authTicket) { try { // 認証チケットの復号化 return((string[])BinarySerialize.BytesToObject( CustomEncode.FromBase64String( SymmetricCryptography.DecryptString( authTicket, GetConfigParameter.GetConfigValue("private-key"), EnumSymmetricAlgorithm.TripleDESCryptoServiceProvider)))); } catch { // 認証失敗 return(null); } }
/// <summary> /// コントロールのプレフィックスと /// イベント ハンドラのディクショナリを生成 /// </summary> /// <returns> /// プレフィックスと /// イベント ハンドラのディクショナリ /// </returns> protected Dictionary <string, object> CreatePrefixAndEvtHndHt() { // プレフィックスとイベント ハンドラのディクショナリを生成 Dictionary <string, object> prefixAndEvtHndHt = new Dictionary <string, object>(); // プレフィックス string prefix = ""; // BUTTON prefix = GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_BUTTON); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Button_Click)); } // PICTURE BOX prefix = GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_PICTURE_BOX); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Button_Click)); } // COMBO BOX prefix = GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_COMBO_BOX); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.List_SelectedIndexChanged)); } // LIST BOX prefix = GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_LIST_BOX); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.List_SelectedIndexChanged)); } // RADIO BUTTON prefix = GetConfigParameter.GetConfigValue(FxLiteral.PREFIX_OF_RADIO_BUTTON); if (!string.IsNullOrEmpty(prefix)) { prefixAndEvtHndHt.Add(prefix, new System.EventHandler(this.Check_CheckedChanged)); } return(prefixAndEvtHndHt); }