123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.IO;
- namespace SysBaseLibs
- {
- public class AppEnv
- {
- // private static rsDBConn _DbConn = null;
- private static Random _random;
- private static bool _IsMachineValidated = false;
- public static int GetIntRandom()
- {
- if (_random == null)
- {
- _random = new Random(0x989680);
- }
- return _random.Next(0x989680, 0x5f5e0ff);
- }
- public static string GetRandom()
- {
- int liInt = GetIntRandom();
- return ("R" + liInt.ToString());
- }
- public static string GetNextDataTableName()
- {
- return ("T" + GetRandom());
- }
- public static DateTime CurrentTime
- {
- get
- {
- return DateTime.Now;
- }
- }
- public static string GetGUID()
- {
- return System.Guid.NewGuid().ToString("N");
- }
- public static string GetGUIDDate()
- {
- return System.Guid.NewGuid().ToString("N")+DateTime.Now.ToString("yyMMddHHmmssfff");
- }
- public static string DBConnectString
- {
- get {
- return SysSecLibs.AppEnv.ReadConnectionString();
- }
- }
- public static bool IsMachineValidated()
- {
- bool lbRetVal = _IsMachineValidated;
- if (!lbRetVal)
- {
- lbRetVal = SysSecLibs.MySecurity.IsMachineValidated();
- }
- _IsMachineValidated = lbRetVal;
- return lbRetVal;
- }
- public static bool SaveStrToFile(string pcMessage, string pcFileName)
- {
- try
- {
- StreamWriter writer1 = new StreamWriter(pcFileName, false);
- writer1.Write(pcMessage);
- writer1.Flush();
- writer1.Close();
- }
- catch (Exception exception1)
- {
- return false;
- }
- return true;
- }
- public static bool isExist(string TableName, string ColumName, string pcNo,DBConnSql poDBConn)
- {
- string lqSql = "select * from " + TableName + " where " + ColumName + " ='" + pcNo + "'";
- rsQuery loQuery = poDBConn.OpenQuery(lqSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
|