Exemple #1
0
        /// <summary> 매수 주문 </summary>
        private void ProcessBuyByRealData(AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveRealDataEvent e, string code, int firstPrice, int price)
        {
            if (_processErrorFlag)
            {
                return;
            }

            if (IsDelay() == false)
            {
                //매수정보 저장
                BoughtEventData temp = new BoughtEventData();
                string          log  = temp.SettingBoughtPrice(firstPrice, price, code);
                _logManager.AddLog(code, log);

                if (_boughtDataDict.ContainsKey(code) == false)
                {
                    _boughtDataDict.Add(code, temp);
                }
                else
                {
                    Console.WriteLine("Error On Add Buy Dict");
                }
                TODAY_LIST_BUY_PRICE[code] = float.MaxValue;
                //매수 주문
                //axKHOpenAPI2.SendOrder(ORDER_NAME, ORDER_NO, MY_ACCOUNT, 1, code, temp.boughtCount, 0, "03", string.Empty);
                ++_tickProcessCount;
            }
        }
Exemple #2
0
        private void StartService()
        {
            StartEnable = false;

            _servicesHosts = new Dictionary <Type, ServiceHost>();
            try
            {
                foreach (var serviceType in _services)
                {
                    var serviceHost = this.InitializeService(serviceType);
                    _servicesHosts.Add(serviceType, serviceHost);

                    _logManager.AddLog($"Service: {serviceType.Name} started successfully");
                }

                StopEnable = true;
            }
            catch (Exception e)
            {
                _logManager.AddLog($"ERROR: Failed: {e.Message}");
                StartEnable = true;
            }

            this.OnPropertyChanged($"Info");
        }
    public void Guard()
    {
        if (_localPet.state == 1)
        {
            RemoveMount();
        }
        _localPet.state = (_localPet.state == 2) ? 0 : 2;

        if (_localPet.state == 2)
        {
            _logManager.AddLog(_localPet.name + " started to patrol.");
        }
        else
        {
            _logManager.AddLog(_localPet.name + " stopped patrolling");
        }

        foreach (int key in GameData._playerData.Pets.Keys)
        {
            Debug.Log("Key = " + key + ", State = " + GameData._playerData.Pets[key].state);
        }
        GameData._playerData.Pets [_localIndex] = _localPet;
        StorePetState();
        UpdateDetail();
        SetPetCells();
    }
Exemple #4
0
 public Postman(LogManager logger) : this()
 {
     this.Logger = logger;
     logger.AddLog(
         LOGS_PATH
         );
 }
Exemple #5
0
        static private string CompileInclude(string fileToIncludePath)
        {
            // We got the include file name
            char[] splitChar = new char[1];
            splitChar[0] = '\\';
            string fileToIncludeName             = fileToIncludePath.Split(splitChar)[fileToIncludePath.Split(splitChar).Length - 1];
            string sourceCopiedFiletoIncludePath = "";

            LogManager.AddLog("Compilation du fichier inclue : " + fileToIncludeName);


            try
            {
                // We make a copie of theincluded file to make recurcive includes
                sourceCopiedFiletoIncludePath = fileToIncludePath + ".comp";
                try
                {
                    File.Copy(fileToIncludePath, sourceCopiedFiletoIncludePath);
                }
                catch (Exception e)
                {
                    LogManager.AddLog("Try to copy files in CompileInclude function :");
                    LogManager.AddLog(e.Message);
                }

                // We recurcivly add include on the included file
                PreProcessor.AddIncludes(sourceCopiedFiletoIncludePath);


                string SourceFiletoIncludeContent = ReadFileWithPath(fileToIncludePath);

                // We check if the included file is valide
                using (Stream toIncludeStream = new FileStream(fileToIncludePath, FileMode.Open))
                {
                    Scanner scn    = new Scanner(toIncludeStream);
                    Parser  parser = new Parser(scn);
                    parser.montage.SetDeclarationSymboleAffectationFromOther(Program.mainMontage);
                    parser.montage.AddSymboleFromPreCompile(SourceFiletoIncludeContent);

                    parser.Parse();
                    if (parser.montage == null || parser.montage.errorList.Any() || scn.hasErrors)
                    {
                        includesHasErros = true;
                        LogManager.AddLog(parser.montage.WriteErrors());
                    }
                    else
                    {
                        LogManager.AddLog("L'inclusion " + fileToIncludeName + " a été compilée avec succès.");
                    }
                }
            }
            catch (Exception e)
            {
                LogManager.AddLog("In CompileInclude function :");
                LogManager.AddLog(e.Message);
            }

            // We return the path of the file to include, which now do not containt any includes
            return(sourceCopiedFiletoIncludePath);
        }
        public async Task <T> LoadConfig(string path)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    if (File.Exists(path))
                    {
                        string configStr;
                        lock (Obj)
                        {
                            configStr = File.ReadAllText(path);
                        }
                        var config = JsonConvert.DeserializeObject <T>(configStr);
                        return config;
                    }

                    return default(T);
                }
                catch (Exception e)
                {
                    if (IsLog)
                    {
                        LogManager.AddLog(e);
                    }
                    return default(T);
                }
            }));
        }
        public async Task <T> LoadConfig(string path)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    if (File.Exists(path))
                    {
                        XDocument docu;
                        lock (Obj)
                        {
                            docu = XDocument.Load(path);
                        }

                        XElement root = docu.Root;
                        var entity = CreateEntity(root, typeof(T));
                        return (T)entity;
                    }
                    return default(T);
                }
                catch (Exception e)
                {
                    if (IsLog)
                    {
                        LogManager.AddLog(e);
                    }
                    return default(T);
                }
            }));
        }
        public void Write(string category, string source, LogType logType, string logMsg, string detail)
        {
            Guid id = Guid.NewGuid();

            LogEntity log = new LogEntity();

            log.Id       = id;
            log.Category = category;
            log.Source   = source;
            log.Type     = (short)logType;
            log.Message  = logMsg;

            LogDetailEntity logDetail = new LogDetailEntity();

            logDetail.Id        = id;
            logDetail.LogDetail = detail;

            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    LogManager manager = new LogManager(tran);
                    manager.AddLog(log);
                    manager.AddLogDetail(logDetail);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                FileLogWriter writer = new FileLogWriter();
                writer.Write(LogCategory.LogWrite, "Write log to database", ex);
                writer.Write(category, source, logType, logMsg, detail);
            }
        }
Exemple #9
0
        private void GetParametersForService()
        {
            Program.exePath  = Application.ExecutablePath;
            Program.basePath = Application.StartupPath;
            LogManager logManager = LogManager.CreateLogManager();

            logManager.AddLog("系统服务运行池", LogLevel.Info, $"程序启动路径:{Program.exePath}\r\n启动基础路径:{Program.basePath}");
        }
        public async Task <IActionResult> PriceChange(PriceChangeDto priceChange)
        {
            pm.ChangePrices(priceChange.PercPriceChange);
            lm.AddLog(priceChange.User, $"Prices changed by {priceChange.PercPriceChange * 100}");
            await context.SaveChangesAsync();

            return(Ok());
        }
Exemple #11
0
        static GenePool()
        {
            LogManager.AddLog("GeneticScheduling", LogType.FolderFilesByDate);

            GeneParameterIndices = new SortedDictionary <string, byte>();
            ParamsPossibleValues = new List <byte[]>();
            GeneParameters       = new List <GeneParameter>();
            Frozen = false;
        }
Exemple #12
0
        static Postman()
        {
            LogManager.AddLog(
                LOG_NAME,
                LogType.FolderFilesByDate
                );

            tokenClient = new RestClient("https://is.workwave.com/oauth2/token?scope=openid");
            tokenClient.AddDefaultHeader("Authorization", "Bearer N2JWMU9wRjFmT1FDSVRNam1fWmpsNjJkcFFZYTpjdXJueTNXb3g0ZUdpREdKTWhWdUI3OVhSSVlh");
            tokenClient.AddDefaultHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");

            client = new RestClient("https://api.workwave.com/pestpac/v1/");
            client.AddDefaultHeader("apikey", "");
            client.AddDefaultHeader("tenant-id", "323480");
            client.AddDefaultHeader("Authorization", "");

            HTTPUtils.WaitForInternet();
            DateTime now = DateTime.Now;

            if (String.IsNullOrWhiteSpace(Settings.Default.access_token) || DateTime.Compare(Settings.Default.expires_in, now) <= 0)
            {
                GetToken(now);
            }
            else
            {
                client.RemoveDefaultParameter("Authorization");
                client.AddDefaultHeader("Authorization", "Bearer " + Settings.Default.access_token);
            }

            if (!File.Exists("BranchIDs.txt"))
            {
                if (TryGetBranches(out IDictionary <string, int> branchIDs))
                {
                    BranchIDs = new SortedDictionary <string, int>(branchIDs);
                    BranchIDs.SaveDictAs("BranchIDs.txt");
                }
                else
                {
                    LogManager.Enqueue(
                        LOG_NAME,
                        EntryType.ERROR,
                        "Initialization",
                        "Branches update failed"
                        );
                }
            }
            else
            {
                BranchIDs = new SortedDictionary <string, int>(Utils.LoadIntDictionary("BranchIDs.txt"));
            }

            IsInitialized = true;
            client.Proxy  = null;
        }
Exemple #13
0
    void CatchThief(Thief t)
    {
        string s = "You get ";
        Dictionary <int, int> drop = Algorithms.GetReward(LoadTxt.GetMonster(t.monsterId).drop);

        foreach (int key in drop.Keys)
        {
            _gameData.AddItem(key * 10000, drop [key]);
            s += LoadTxt.MatDic [key].name + " ×" + drop [key];
            break;
        }
        if (drop.Count <= 0)
        {
            s = "";
        }
        _logManager.AddLog(t.name + " tried to steal, but was caught by your guard." + s);

        //Achievement
        this.gameObject.GetComponentInParent <AchieveActions>().CatchThief(t.id);
    }
Exemple #14
0
 private static void deleteFile(string FilePath)
 {
     try
     {
         File.Delete(FilePath);
     }
     catch (Exception e)
     {
         LogManager.AddLog(" In deleteFile function:");
         LogManager.AddLog(e.Message);
     }
 }
Exemple #15
0
 private static void WriteTheTmpSrcFile(string fileName, string copiedSourceFile)
 {
     try
     {
         File.WriteAllText(fileName, copiedSourceFile, Encoding.UTF8);
     }
     catch (Exception e)
     {
         LogManager.AddLog("In WriteTheTmpSrcFile function :");
         LogManager.AddLog(e.Message);
     }
 }
Exemple #16
0
        static void Main(string[] args)
        {
            LogManager.AddLog("Test", LogType.FolderFilesByDate);
            LogManager.Start();
            Random gen = new Random();

            for (int i = 0; i < 16; ++i)
            {
                LogManager.Enqueue("Test", EntryType.DEBUG, new object[] { gen.NextDouble() });
            }
            LogManager.Stop();
            SpinWait.SpinUntil(() => !LogManager.hasWork);
        }
    void GoToMap()
    {
        int min = TravelTime(LoadTxt.MapDic [GameData._playerData.placeNowId].distances [mapGoing.id]);

        _gameData.ChangeTime(min);
        GameData._playerData.placeNowId = mapGoing.id;
        _gameData.StoreData("PlaceNowId", mapGoing.id);

        _panelManager.MapGoing = mapGoing;
        if (mapGoing.id == 0)
        {
            _logManager.AddLog("Get home.");
        }
        else
        {
            _logManager.AddLog("You get to " + mapGoing.name + ".");
        }
        _panelManager.GoToPanel("Place");

        //检测是否有新信息
        GetComponentInParent <SerendipityActions>().CheckSerendipity();
    }
Exemple #18
0
    public void OnClick()
    {
        if (inputField.text != "")
        {
            gameManager.SetPlayerName(inputField.text);
            logManager.AddLog();
            scoreTextGenerater1.UpdateText();
            scoreTextGenerater2.UpdateText();

            resultController.HideMenus();
            resultController.DisplayResultMenu();
            resultController.SetInteractive(buttonObj, false);
        }
    }
        public StatusCodeResult PostLogRecord([FromBody] Log l)
        {
            if (l == null)
            {
                return(new Microsoft.AspNetCore.Mvc.BadRequestResult());
            }

            else
            {
                LogManager lm = new LogManager(l.UserName);
                lm.AddLog(l);
                return(new StatusCodeResult(200)); //created
            }
        }
Exemple #20
0
 // to log a molecule created, it has to be a molecule that exists, not an incomplete one
 // returns true if it can be logged, and false if it can't
 public void CheckAvailableBonds(GameObject molecule)
 {
     for (int i = 0; i < molecule.transform.childCount; i++)
     {
         Transform child = molecule.transform.GetChild(i);
         if (child.gameObject.CompareTag("Interactable"))
         {
             if (child.gameObject.GetComponent <Atom>().GetAvailableBonds() > 0)
             {
                 return;
             }
         }
     }
     LM.AddLog("Built " + GetMoleculeName(molecule) + " molecule");
 }
Exemple #21
0
        //应该通过发现Xelement来给泛型类型赋值
        public object CreateEntity(XElement element, Type type)
        {
            var entity  = Activator.CreateInstance(type);
            var type1   = entity.GetType();
            var elemens = element.Elements();

            foreach (var xElement in elemens)
            {
                PropertyInfo propertyInfo = null;
                try
                {
                    propertyInfo = type1.GetProperty(xElement.Name.ToString());
                }
                catch (Exception e)
                {
                    if (IsLog)
                    {
                        LogManager.AddLog(e);
                    }
                }

                if (xElement.HasElements && propertyInfo != null)
                {
                    var child = CreateEntity(xElement, propertyInfo.PropertyType);
                    propertyInfo.SetValue(entity, child, null);
                }
                else
                {
                    if (!string.IsNullOrEmpty(xElement.Value) && propertyInfo != null)   //没有值,不必要转换
                    {
                        try
                        {
                            object v = Convert.ChangeType(xElement.Value, propertyInfo.PropertyType);
                            propertyInfo?.SetValue(entity, v, null);
                        }
                        catch (Exception e)
                        {
                            if (IsLog)
                            {
                                LogManager.AddLog(e);
                            }
                        }
                    }
                }
            }

            return(entity);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public async Task <bool> SendPasswordResetEmail(string email)
        {
            var user = await Context.Users.FirstOrDefaultAsync(u => u.Email == email && !u.IsVerified);

            if (user == null)
            {
                return(false);
            }

            var token = await InsertOneTimeTokenAsync(email, OneTimeTokenType.ForgotPassword);

            emailManager.Send(email, "Reset your password", "Here is your token: " + token);

            LogManager.AddLog(LogCategory.Email, "Password reset email sent: {email}", LogEventLevel.Information, email);

            return(true);
        }
Exemple #23
0
        private static string ReadFileWithPath(string filePath)
        {
            string fileText = "";

            try
            {   // Open the text file using a stream reader.
                using (StreamReader sr = new StreamReader(filePath))
                {
                    // Read the stream to a string, and write the string to the console.
                    fileText = sr.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                LogManager.AddLog("In ReadFileWithPath function :");
                LogManager.AddLog(e.Message);
            }
            return(fileText);
        }
Exemple #24
0
        static public Montage GetIncludeSIDB()
        {
            FileStream file   = null;
            Scanner    scn    = null;
            Parser     parser = null;
            Montage    montageBaseWithSIDB = null;

            try
            {
                file   = new FileStream(PreProcessor.BDSIPath, FileMode.Open);
                scn    = new Scanner(file);
                parser = new Parser(scn);

                parser.Parse();
                //ici on va rajouter que toute les déclaration du montage vienne de la db
                foreach (Declaration dec in parser.montage.listOfDeclarations)
                {
                    // Indicate that the declaration come from the dataBase
                    dec.fromDataBase = true;
                }
                //
                //ici on va rajouter que toute les déclaration du montage vienne de la db
                foreach (Affectation aff in parser.montage.mapOfCalculExpressions.Values)
                {
                    // Indicate that the declaration come from the dataBase
                    aff.fromDataBase = true;
                }
                //
                //
                montageBaseWithSIDB = parser.montage;
            }
            catch (Exception e)
            {
                LogManager.AddLog("Lors de GetIncludeSIDB");
                LogManager.AddLog(e.Message);
            }
            finally
            {
                file.Close();
            }
            return(montageBaseWithSIDB);
        }
        public void AddLogMessageWithArgs()
        {
            const LogCategory   category = LogCategory.Email;
            const string        message  = "log message {myArg}";
            const LogEventLevel level    = LogEventLevel.Debug;
            var myArg = 43;

            object[] args = { myArg };

            var       actualMessage   = "";
            var       actualLevel     = LogEventLevel.Fatal;
            Exception actualException = null;

            object[] actualArgs     = null;
            var      actualCategory = LogCategory.GeneralError;

            var adapter = new Mock <ILogAdapter>();

            adapter
            .Setup(c => c.Write(It.IsAny <LogEventLevel>(), It.IsAny <Exception>(), It.IsAny <string>(),
                                It.IsAny <object[]>()))
            .Callback((LogEventLevel l, Exception e, string m, object[] args) =>
            {
                actualLevel     = l;
                actualMessage   = m;
                actualException = e;
                actualArgs      = args;
                actualCategory  = (LogCategory)(args[args.Length - 1] as LogParameters).CategoryId;
            });

            var sut = new LogManager(adapter.Object);

            sut.AddLog(category, message, level, args);

            Assert.AreEqual(message + " {@LogParameters}", actualMessage);
            Assert.AreEqual(level, actualLevel);
            Assert.AreEqual(category, actualCategory);
            Assert.IsNull(actualException);
            Assert.AreEqual(2, actualArgs.Length);
            Assert.AreEqual(myArg, actualArgs[0]);
        }
 public async Task SaveConfig(string path, T config)
 {
     await Task.Run(() =>
     {
         try
         {
             var conJs = JsonConvert.SerializeObject(config);
             lock (Obj)
             {
                 File.WriteAllText(path, conJs);
             }
         }
         catch (Exception e)
         {
             if (IsLog)
             {
                 LogManager.AddLog(e);
             }
         }
     });
 }
Exemple #27
0
        private List <Brick> MakeListBrick(string fileName)
        {
            List <Brick> localBrickList = new List <Brick>();
            // We got the include file path
            string filePath = directoryPath + '\\' + fileName;

            try
            {
                string copiedSourceFiletoInclude = ReadFileWithPath(filePath);
                // we have already done all the declaration and the affectationsS
                string includeContentOnlyWithBricks = "$Titre{include} %% %% " + Regex.Split(copiedSourceFiletoInclude, "%%")[2];
                // We check if the included file is valide
                using (Stream toIncludeStream = new MemoryStream(Encoding.UTF8.GetBytes(includeContentOnlyWithBricks)))
                {
                    Scanner scn    = new Scanner(toIncludeStream, "GUESS");
                    Parser  parser = new Parser(scn);
                    parser.montage.SetDeclarationSymboleAffectationFromOther(Program.mainMontage);
                    parser.Parse();
                    if (parser.montage == null || parser.montage.errorList.Any() || scn.hasErrors)
                    {
                        //parser.montage.PrintErrors();
                        LogManager.AddLog("L'inclussion " + fileName + " n'a pas été effectuée car le montage contenait des erreures.");
                    }
                    else
                    {
                        localBrickList.AddRange(parser.montage.listOfBricks);
                    }
                }
            }
            catch (Exception e)
            {
                LogManager.AddLog("In Compile Include function from parse:");
                LogManager.AddLog(e.Message);
            }

            // We return the path of the file to include, which now do not containt any includes
            return(localBrickList);
        }
        public void Write(string category, string source, Exception exception)
        {
            if (exception == null)
            {
                return;
            }
            Guid id = Guid.NewGuid();

            LogEntity log = new LogEntity();

            log.Id       = id;
            log.Category = category;
            log.Source   = source;
            log.Type     = (short)LogType.Error;
            log.Message  = exception.Message;

            LogDetailEntity logDetail = new LogDetailEntity();

            logDetail.Id        = id;
            logDetail.LogDetail = LogHelper.GetExceptionMessage(exception);

            try
            {
                using (ILHDBTran tran = BeginTran())
                {
                    LogManager manager = new LogManager(tran);
                    manager.AddLog(log);
                    manager.AddLogDetail(logDetail);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                FileLogWriter writer = new FileLogWriter();
                writer.Write(LogCategory.LogWrite, "Write log to database", ex);
                writer.Write(category, source, exception);
            }
        }
Exemple #29
0
 /// <summary>
 /// 使用创建一个xml文档保存,还是加载本地文档进行修改? 先使用直接创建一个覆盖保存
 /// </summary>
 /// <param name="path"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 public async Task SaveConfig(string path, T config)
 {
     await Task.Run(() =>
     {
         try
         {
             var type = config.GetType();
             var xml  = CreateXelement(type, type.Name);
             //xml文档节点赋值
             AssignElement(xml, config);
             //保存到本地
             XDocument docu = new XDocument(new XComment($"{type.Name}"), xml);
             docu.Save(path);
         }
         catch (Exception e)
         {
             if (IsLog)
             {
                 LogManager.AddLog(e);
             }
         }
     });
 }
        /// <summary>
        /// 生成配置文件
        /// </summary>
        /// <param name="path"></param>
        public async Task <bool> GenrateConfig(string path)
        {
            return(await Task.Run(() =>
            {
                try
                {
                    Type type = typeof(T);
                    var ob = Activator.CreateInstance(type);

                    var ss = JsonConvert.SerializeObject(ob);
                    File.WriteAllText(path, ss);
                    return true;
                }
                catch (Exception e)
                {
                    if (IsLog)
                    {
                        LogManager.AddLog(e);
                    }
                    return false;
                }
            }));
        }