Example #1
0
        /// <summary>
        /// 得到某个Node
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public XmlNode ReadNodeFromNodeListByNodeAttr(XmlNodeList nodeList, string attrName, string attrValue)
        {
            try
            {
                foreach (XmlNode xn in  nodeList)
                {
                    if (attrName == "")
                    {
                        return(null);
                    }

                    string factAttr = NodeAtt(xn, attrName);
                    if (factAttr != "")
                    {
                        if (factAttr.Equals(attrValue))
                        {
                            return(xn);
                        }
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取xml出错" + exception.ToString());
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// Writes Logs to log4net library.
        /// </summary>
        /// <param name="logEntry">The log entry.</param>
        private void LogToLog4Net(IAppLog logEntry)
        {
            string msg = logEntry.AppLogTypeID.ToString();

            log4netLogger.Info(msg);

            //switch (logEntry.LogType)
            //{
            //    case LogTypeEnum.Info:
            //        log4netLogger.Info(logEntry.Message);
            //        break;
            //    case LogTypeEnum.Fatal:
            //        log4netLogger.Fatal(logEntry.Message);
            //        break;
            //    case LogTypeEnum.Error:
            //        if (logEntry.ExceptionClass == null)
            //            log4netLogger.Error(logEntry.Message + "\r\n----\r\n" + logEntry.StackTrace);
            //        else
            //            log4netLogger.Error(logEntry.Message, logEntry.ExceptionClass);
            //        break;
            //    case LogTypeEnum.Warn:
            //        log4netLogger.Warn(logEntry.Message);
            //        break;
            //    case LogTypeEnum.Debug:
            //        log4netLogger.Debug(logEntry.Message);
            //        break;
            //    default:
            //        break;
            //}
        }
Example #3
0
        /// <summary>
        /// 得到某个Node
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public XmlNode ReadNodeFromNodeListByNodeName(XmlNodeList nodeList, string nodeName)
        {
            try
            {
                foreach (XmlNode xn in  nodeList)
                {
                    if (nodeName == "")
                    {
                        return(xn);
                    }

                    if (nodeName.Equals(xn.Name))
                    {
                        return(xn);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取xml出错" + exception.ToString());
            }
            return(null);
        }
Example #4
0
        /// <summary>
        /// 读取某个文件某个路径下的某个属性值
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string ReadAttrFromFile(string fileName, string path, string name)
        {
            string XMLFileName = System.AppDomain.CurrentDomain.BaseDirectory + @"config\" + fileName;

            try
            {
                XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(XMLFileName);

                foreach (XmlNode xn in xd.SelectNodes(path))
                {
                    if (name == "")
                    {
                        return("");
                    }
                    string attrName = NodeAtt(xn, name);
                    if (attrName != "")
                    {
                        return(attrName);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + fileName + "出错" + exception.ToString());
            }
            return(null);
        }
Example #5
0
        // AppLog is always first service added so other services can log initialization errors
        public static ServiceManager Instantiate(IAppLog appLog)
        {
            if (GameServices != null)
            {
                throw new System.Exception("Trying to instantiate ServiceManager more than once");
            }

            GameServices = new ServiceManager(appLog);
            return((ServiceManager)GameServices);
        }
Example #6
0
 public DownloadExpression(IAppLog appLog, IPageParser parser, IAppController appController, IFileDownloader downloader, IComicPath comicPath, IFileProxy file, IWebClientProxy webClient, IAppSettings appSettings, IComicStore comicStore)
     : base(appLog, webClient)
 {
     this.parser        = parser;
     this.comicStore    = comicStore;
     this.appSettings   = appSettings;
     this.file          = file;
     this.comicPath     = comicPath;
     this.downloader    = downloader;
     this.appController = appController;
 }
Example #7
0
    void Awake()
    {
        appLog_      = ServiceManager.GameServices.GetAppLog();
        gameManager_ = ServiceManager.GameServices.GetGameManager();

        appLog_.LogInfo("Splash.Awake");
        PanelContent.SetActive(false);

        appLog_.LogInfo("Splash: Initializing FB, first try");
        facebook_.Initialize(OnFacebookInitialized);
    }
Example #8
0
        static AppLogProxy()
        {
            instance_AppLog = new AppLog();

            //启动日志定时保存服务
            alss = new AppLogSaveService();
            ThreadStart threadStartForAppLogSaveService = new ThreadStart(alss.StartService);

            threadForAppLogSaveService = new Thread(threadStartForAppLogSaveService);
            threadForAppLogSaveService.IsBackground = true;
            threadForAppLogSaveService.Start();
        }
Example #9
0
 public MainPresenter(IAppController appController, IUiThread uiThread, IComicStore comicStore, IAppLog appLog, IComicViewModelMapper mapper, IComicPath comicPath, IDirectoryProxy directory, IUserSettings settings, IAppInfo appInfo, IAppSettings appSettings)
 {
     this.appController = appController;
     this.appSettings   = appSettings;
     this.appInfo       = appInfo;
     this.settings      = settings;
     this.directory     = directory;
     this.comicPath     = comicPath;
     this.mapper        = mapper;
     this.appLog        = appLog;
     this.comicStore    = comicStore;
     this.uiThread      = uiThread;
 }
Example #10
0
 public void UpdateBySql(string sqlUpdate)
 {
     try
     {
         System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(sqlUpdate, managerDB.OpenApp());
                command.CommandType             = System.Data.CommandType.Text;
         command.ExecuteNonQuery();
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "更新数据出错!" + exception.ToString());
     }
 }
Example #11
0
        public object ScalarBySql(string sql)
        {
            object dr = null;

            try
            {
                System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(sql, managerDB.OpenApp());
                       dr = command.ExecuteScalar();
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "查询数据出错!" + exception.ToString());
            }
            return(dr);
        }
Example #12
0
        /// <summary>
        /// 根据条件(传入的DataSet)查询数据
        /// </summary>
        /// <param name="ds"></param>
        /// <returns></returns>
        public DataSet SelectByCondition(String table, string where)
        {
            DataSet ds = new DataSet();

            try
            {
                string querySql = table + where;
                System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(querySql, managerDB.OpenApp());

                adapter.Fill(ds, table);
            }
            catch (System.Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "查询数据表" + table + "出错!" + exception.ToString());
            }
            return(ds);
        }
Example #13
0
 public void UpdateByProcedure(string procedureName, System.Data.OleDb.OleDbParameter[] sqlParameter)
 {
     try
     {
         System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(procedureName, managerDB.OpenApp());
               command.CommandType = System.Data.CommandType.StoredProcedure;
         for (int i = 0; i < sqlParameter.Length; i++)
         {
             command.Parameters.Add(sqlParameter[i]);
         }
         command.ExecuteNonQuery();
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "执行存储过程出错!" + exception.ToString());
     }
 }
Example #14
0
        private void SetDefaultLogEntryProperties(IAppLog logEntry)
        {
            logEntry.InsertDate = DateTime.UtcNow;

            if (FWUtils.ConfigUtils.IsInWebContext())
            {
                if (string.IsNullOrEmpty(logEntry.IPAddress))
                {
                    logEntry.IPAddress = FWUtils.WebUIUtils.GetRequestIPAddress();
                }
            }
            if (logEntry.UserID.HasValue == false)
            {
                if (FWUtils.SecurityUtils.IsUserAuthenticated())
                {
                    logEntry.UserID = FWUtils.SecurityUtils.GetCurrentUserIDLong();
                }
            }
        }
Example #15
0
 /// <summary>
 /// 得到某个Node下所有的NodeList
 /// </summary>
 /// <param name="fileName"></param>
 /// <param name="path"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public XmlNodeList ReadNodeListFromNode(XmlNode node)
 {
     try
     {
         if (node.HasChildNodes == false)
         {
             return(null);
         }
         else
         {
             return(node.ChildNodes);
         }
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "根据Node得NodeList出错!" + exception.ToString());
     }
     return(null);
 }
Example #16
0
 public System.Data.OleDb.OleDbDataReader SelectByProcedure(string procedureName, System.Data.SqlClient.SqlParameter[] sqlParameter)
 {
     System.Data.OleDb.OleDbDataReader dr = null;
     try
     {
         System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(procedureName, managerDB.OpenApp());
               command.CommandType = System.Data.CommandType.StoredProcedure;
         for (int i = 0; i < sqlParameter.Length; i++)
         {
             command.Parameters.Add(sqlParameter[i]);
         }
         dr = command.ExecuteReader();
     }
     catch (Exception exception)
     {
         IAppLog log = (IAppLog)AppLogFactory.LogProduct();
         log.writeLog(this.GetType().Name, "执行存储过程" + procedureName + "查询数据出错!" + exception.ToString());
     }
     return(dr);
 }
Example #17
0
        /// <summary>
        /// 得到NodeList
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public XmlNodeList ReadNodeListFromFile(string fileName, string path)
        {
            string XMLFileName = System.AppDomain.CurrentDomain.BaseDirectory + @"config\" + fileName;

            try
            {
                XmlDocument xd = new System.Xml.XmlDocument();
                xd.Load(XMLFileName);

                System.Xml.XmlNode     nodeFirst = xd.SelectSingleNode(path);
                System.Xml.XmlNodeList nodeList  = nodeFirst.ChildNodes;
                return(nodeList);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + fileName + "出错" + exception.ToString());
            }
            return(null);
        }
Example #18
0
        /// <summary>
        /// 取得数据库连接
        /// </summary>
        override public System.Data.OleDb.OleDbConnection OpenApp()
        {
            string connectStr = null;

            try
            {
                if (connect == null)
                {
                    connectStr = "Provider=MSDAORA;User ID=" + this.ServerApplicationUserID + ";Data Source=" + this.ServerApplicationDB + ";Password="******"连接SqlServer数据库失败!连接字符串:" + connectStr + exception.ToString());
            }
            return(connect);
        }
Example #19
0
        public void WriteLogTest()
        {
            Logger  target   = FWUtils.ExpLogUtils.Logger;
            IAppLog logEntry = (IAppLog)EntityFactory.GetEntityObject(AppLog.EntityName, GetSourceTypeEnum.Table);

            logEntry.AppLogTypeID = -1000;
            logEntry.ExtraGuid    = Guid.NewGuid();
            logEntry.ExtraDouble  = TestUtils.RandomUtils.RandomDouble();
            logEntry.ExtraString1 = TestUtils.RandomUtils.RandomStringMaxLength(50, null);
            logEntry.ExtraString2 = TestUtils.RandomUtils.RandomStringMaxLength(50, null);
            bool expected = true;
            bool actual;

            actual = target.WriteLog(logEntry);
            Assert.AreEqual(expected, actual);

            FilterExpression filter     = new FilterExpression(new Filter(AppLog.ColumnNames.ExtraGuid, logEntry.ExtraGuid));
            IServiceBase     logService = EntityFactory.GetEntityServiceByName(AppLog.EntityName, "");

            Assert.AreEqual(1, logService.GetCount(filter));
        }
Example #20
0
        public LocalizationManager(string resource)
        {
            appLog_ = ServiceManager.GameServices.GetAppLog();

            var textAsset = Resources.Load <TextAsset>(resource);

            appLog_.LogErrorIfNull(textAsset, resource);

            var lines = textAsset.text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < lines.Length; ++i)
            {
                if (string.IsNullOrEmpty(lines[i]))
                {
                    continue;
                }

                List <string> header = new List <string>();
                var           items  = lines[i].Split('\t');
                if (i == 0)
                {
                    header.AddRange(items);
                    for (int j = 1; j < items.Length; ++j)
                    {
                        string lang = header[j];
                        languageMap_[lang] = new Dictionary <string, string>();
                    }
                }
                else
                {
                    string key = items[0];
                    for (int j = 1; j < items.Length; ++j)
                    {
                        string lang  = header[j];
                        string value = items[j];
                        languageMap_[lang][key] = value;
                    }
                }
            }
        }
Example #21
0
        /// <summary>
        /// 取得数据库连接
        /// </summary>
        override public System.Data.OleDb.OleDbConnection OpenApp()
        {
            string connectStr = null;

            try
            {
                if (connect == null)
                {
                    connectStr  = "Provider=SQLOLEDB.1;Persist Security Info=True;";
                    connectStr += "Data Source=" + this.DbServer + "; Initial Catalog=" + this.ServerApplicationDB;
                    connectStr += ";User ID=" + this.ServerApplicationUserID + "; Password="******"连接SqlServer数据库失败!连接字符串:" + connectStr + exception.ToString());
            }
            return(connect);
        }
Example #22
0
        /// <summary>
        /// 读取某个节点下的某个属性值
        /// </summary>
        /// <param name="node"></param>
        /// <param name="path"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public string ReadAttrFromPath(XmlNode node, string path, string name)
        {
            if (node.HasChildNodes == false)
            {
                string attrName = NodeAtt(node, name);
                if (attrName != "")
                {
                    return(attrName);
                }
                else
                {
                    return("");
                }
            }


            try
            {
                foreach (XmlNode xn in node.SelectNodes(path))
                {
                    if (name == "")
                    {
                        return("");
                    }
                    string attrName = NodeAtt(xn, name);
                    if (attrName != "")
                    {
                        return(attrName);
                    }
                }
                return(null);
            }
            catch (Exception exception)
            {
                IAppLog log = (IAppLog)AppLogFactory.LogProduct();
                log.writeLog(this.GetType().Name, "读取!" + path + "出错" + exception.ToString());
            }
            return(null);
        }
Example #23
0
 private ServiceManager(IAppLog appLog)
 {
     appLog_ = appLog;
 }
Example #24
0
 public Informes_PedidosManager()
 {
     _appLog = new AppLog();
 }
Example #25
0
 public MatchExpression(IAppLog appLog, IWebClientProxy webClient, IPageParser parser) : base(appLog, webClient)
 {
     this.parser = parser;
 }
Example #26
0
 public LogController(IAppLog appLog)
 {
     _appLog = appLog;
 }
Example #27
0
        //#region Singleton Pattern
        //static readonly object padlock = new object();
        //private static Logger _Instance;

        ///// <summary>
        ///// Gets the instance.
        ///// </summary>
        ///// <value>
        ///// The instance.
        ///// </value>
        //public static Logger Instance
        //{
        //    get
        //    {
        //        lock (padlock)
        //        {
        //            if (_Instance == null)
        //                _Instance = new Logger();
        //            return _Instance;
        //        }
        //    }
        //}

        //#endregion

        //#region Properties

        //private ILogWriter _LogWriter;
        ///// <summary>
        ///// Gets or sets the log writer.
        ///// </summary>
        ///// <value>
        ///// The log writer.
        ///// </value>
        //public ILogWriter LogWriter
        //{
        //    get { return _LogWriter; }
        //    set { _LogWriter = value; }
        //}


        //private ILogWriter _BackupLogWriter;

        ///// <summary>
        ///// Gets or sets the backup log writer. It will be used if the main log writer failed to act.
        ///// </summary>
        ///// <value>
        ///// The backup log writer.
        ///// </value>
        //public ILogWriter BackupLogWriter
        //{
        //    get { return _BackupLogWriter; }
        //    set { _BackupLogWriter = value; }
        //}

        //#endregion

        #region Methods


        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="logEntry">The log entry.</param>
        /// <returns></returns>
        public bool WriteLog(IAppLog logEntry)
        {
            var appSettings = FWUtils.ConfigUtils.GetAppSettings();

            if (appSettings.Log.Enabled == false)
            {
                return(false);
            }


            SetDefaultLogEntryProperties(logEntry);

            // first we use log4Net that is more reliable
            if (appSettings.Log.WriteToLog4NetEnabled)
            {
                LogToLog4Net(logEntry);
            }

            try
            {
                _AppLogService.Insert(logEntry, new InsertParameters());
            }
            catch (Exception ex)
            {
                FWUtils.ExpLogUtils.ExceptionLogger.LogError(ex, null);
            }

            return(true);

            //// then we try to write on the first media, and if it was not successful, we will use the second media.

            //bool logWrited = false; // If the log is written or not

            //Exception WritingException = null; // The exception that happened in the first log writer
            //try
            //{
            //    if (this.LogWriter != null)
            //    {
            //        this.LogWriter.WriteLog(logEntry);
            //        logWrited = true;
            //    }
            //}
            //catch (Exception ex)
            //{
            //    logWrited = false;
            //    FWUtils.ExceptionLogger.LogError(ex, null);
            //}

            //if (logWrited == false) // if we couldn't write on the first media
            //{
            //    if (this.BackupLogWriter != null)
            //    {
            //        try
            //        {
            //            // first we log the main log
            //            BackupLogWriter.WriteLog(logEntry);
            //            logWrited = true;

            //        }
            //        catch (Exception ex)
            //        {
            //            FWUtils.ExceptionLogger.LogError(ex, null);
            //        }

            //    }
            //}

            //return logWrited;
        }
Example #28
0
 public WarnExpression(IAppLog appLog) : base(appLog)
 {
 }
Example #29
0
 public LogExpression(IAppLog appLog) : base(appLog)
 {
 }
Example #30
0
 protected BaseWebExpression(IAppLog appLog, IWebClientProxy webClient) : base(appLog)
 {
     this.webClient = webClient;
 }