コード例 #1
0
 /// <summary>
 /// Stop the code execution if the both conditions are met:
 /// 1)the entry assembly was compiled as a release version;
 /// 2)the test period expired.
 /// </summary>
 /// <param name="year">year when the test period expires; if it is less than 1 then the check is not performed</param>
 /// <param name="month">month when the test period expires</param>
 /// <param name="day">day when the test period expires</param>
 /// <param name="for_release_only"></param>
 static public void CHECK_TEST_PERIOD_VALIDITY(int year, int month, int day, bool silently = false, bool for_release_only = false)
 {
     try
     {
         InternetDateTime.silently = silently;
         //if (year < 1)
         //    return;
         //if (for_release_only && !IsReleaseVersion(Assembly.GetEntryAssembly()))
         //    return;
         //LogMessage.Inform("It is a demo version that is valid until " + year + "-" + month + "-" + day);
         if (!silently)
         {
             Log.Main.Inform("It is a demo version that is valid until " + year + "-" + month + "-" + day);
         }
         ThreadRoutines.StartTry(() =>
         {
             if (new DateTime(year, month, day) < InternetDateTime.GetOverHttp())
             {
                 Action a = (Action)(() => {
                     LogMessage.Exit("The test time expired. \nPlease contact the vendor if you want to use this software.");
                 });
                 if (System.Windows.Forms.Application.OpenForms.Count > 0)
                 {
                     System.Windows.Forms.Application.OpenForms[0].Invoke(a);
                 }
                 else if (System.Windows.Application.Current != null)
                 {
                     System.Windows.Application.Current.Dispatcher.Invoke(a);
                 }
                 else
                 {
                     ThreadRoutines.Start(() =>
                     {
                         Thread.Sleep(5000);
                         Environment.Exit(0);
                     });
                     a();
                 }
             }
         },
                                 (Exception e) =>
         {
             LogMessage.Exit(e);
         }
                                 );
     }
     catch (Exception e)
     {
         LogMessage.Exit(e);
     }
 }
コード例 #2
0
 /// <summary>
 /// Stop the code execution if the both conditions are met:
 /// 1)the entry assembly was compiled as a release version;
 /// 2)the test period expired.
 /// </summary>
 /// <param name="year">year when the test period expires; if it is less than 1 then the check is not performed</param>
 /// <param name="month">month when the test period expires</param>
 /// <param name="day">day when the test period expires</param>
 /// <param name="for_release_only"></param>
 static public void CHECK_TEST_PERIOD_VALIDITY(int year, int month, int day, bool for_release_only = false)
 {
     try
     {
         //if (year < 1)
         //    return;
         //if (for_release_only && !IsReleaseVersion(Assembly.GetEntryAssembly()))
         //    return;
         //LogMessage.Inform("It is a demo version that is valid until " + year + "-" + month + "-" + day);
         Log.Main.Inform("It is a demo version that is valid until " + year + "-" + month + "-" + day);
         if (new DateTime(year, month, day) < InternetDateTime.GetOverHttp())
         {
             LogMessage.Exit("The test time expired. \nPlease contact the vendor if you want to use this software.");
         }
     }
     catch (Exception e)
     {
         LogMessage.Exit(e);
     }
 }