示例#1
0
 private void MouseListener_OnRightMouseDown(object sender, EventArgs e)
 {
     _rightMouseCount++;
     if (!disableSavingToDisk)
     {
         _saver.Save("M1.txt", _rightMouseCount.ToString());
     }
     _fileMapManager.Write("SC-M1", _rightMouseCount.ToString());
 }
示例#2
0
        private void UpdateValue(string name, string value)
        {
            if (!disableSavingToDisk)
            {
                _saver.Save(name + ".txt", value);
            }

            _highFrequencyDataConsumers.ForEach(h =>
                                                h.Handle(name, value)
                                                );
        }
示例#3
0
        private void UpdateValue(string name, string value)
        {
            if (!disableSavingToDisk)
            {
                _saver.Save(name + ".txt", value);
            }

            _tokenSetter($"{getTokenName(name)}.txt", value, TokenType.Live);

            _highFrequencyDataConsumers.ForEach(h =>
                                                h.Handle(name, value)
                                                );
        }
        public void FetchAndStoreOdds(IEnumerable <string> marketIds)
        {
            int numIds = marketIds.Count();

            if (numIds <= _maxMarketsPerListMarketBookRequest)
            {
                IEnumerable <MarketBook> fetchedOdds = _oddsReader.Read(new MarketFilter()
                {
                    MarketIds = new HashSet <string>(marketIds)
                });
                if (!fetchedOdds.IsNullOrEmpty())
                {
                    foreach (var book in fetchedOdds)
                    {
                        TimeStamp(book);
                        _oddsSaver.Save(book);
                    }
                }
            }
            else
            {
                IEnumerable <IEnumerable <string> > batchesOfIds = marketIds.Split((numIds / _maxMarketsPerListMarketBookRequest) + 1);
                foreach (var batch in batchesOfIds)
                {
                    FetchAndStoreOdds(batch);
                }
            }
        }
示例#5
0
        public void FetchAndStoreMarkets(MarketFilter filter, ISet <string> trackedMarketIds)
        {
            AddMarketTypesToFilter(filter);

            IEnumerable <MarketCatalogue> markets;

            try
            {
                markets = _marketsReader.Read(filter);
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("OddsFetchingTriggerer", "Error fetching markets: " + e.Message);
                markets = new HashSet <MarketCatalogue>();
            }


            List <string> untrackedMarketIds = new List <string>();

            foreach (MarketCatalogue market in markets)
            {
                if (!trackedMarketIds.Contains(market.MarketId))
                {
                    market.EventId = filter.EventIds.FirstOrDefault();

                    untrackedMarketIds.Add(market.MarketId);
                    _marketsSaver.Save(market);
                }
            }
        }
示例#6
0
        public void Save(string filename, IFileable callMeBackforDetails)
        {
            // sorry – you gotta do this

            string txt    = "";
            int    column = callMeBackforDetails.GetColumnCount();
            int    row    = callMeBackforDetails.GetRowCount();

            // whatIsAs.WhatsAt(row, column);
            for (int r = 0; r < row; r++)
            {
                for (int c = 0; c < column; c++)
                {
                    //txt += Convert.ToString(callMeBackforDetails.WhatsAt(r, c));
                    txt += callMeBackforDetails.WhatsAt(r, c).ToString();
                    if (c == (column - 1))
                    {
                        txt += "\n";
                    }
                }
            }
            this.Converter.Compress(txt);
            string compressedLevel = this.Converter.Compressed;

            Saver.Save(filename, compressedLevel);
        }
示例#7
0
        public ISet <string> FetchAndStoreEvents(MarketFilter filter, ISet <string> trackedEventIds)
        {
            IEnumerable <Event> events = new List <Event>();

            try
            {
                events = EventResultsConverter.ConvertEventResults(_eventsReader.Read(filter));
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("OddsFetchingTriggerer", "Error fetching events: " + e.Message);
                trackedEventIds = new HashSet <string>();
            }

            List <string>    untrackedEventIds = new List <string>();
            HashSet <string> eventIds          = new HashSet <string>();

            foreach (Event ev in events)
            {
                ev.CompetitionId = filter.CompetitionIds.FirstOrDefault();
                ev.Markets       = new List <MarketCatalogue>();

                eventIds.Add(ev.IdStr);

                if (!trackedEventIds.Contains(ev.IdStr))
                {
                    untrackedEventIds.Add(ev.IdStr);
                    _eventsSaver.Save(ev);
                }
            }
            return(eventIds);
        }
        public void Process()
        {
            var tickLength = Configuration.TickLength;
            var tasks      = TaskListGenerator.GenerateTaskList(Configuration.SimulationLength / tickLength, tickLength);

            Saver.Save(tasks);
        }
示例#9
0
 public void SaveScore(string name)
 {
     SavedScores.AddScore(new ScoreModel(name, PlayerModel.Happiness));
     saver.Save(SavedScores);
     ScreenManager.Close(ScreenType.YourScoreScreen);
     ScreenManager.Open(ScreenType.ScoreboardScreen);
 }
示例#10
0
        public async Task ProcessAsync <T>(T value)
        {
            await Task.Run(() =>
            {
                Console.WriteLine("Processing...");

                try
                {
                    var order = _parser.Parse <OrderModel>(value as string);
                    _validator.Validate(order);
                    _saver.Save(order);
                }
                catch (ParsingException parsingException)
                {
                    _logger.LogException(parsingException);
                    _errorWorker.OnError(value as string);
                }
                catch (ValidationException validationException)
                {
                    _logger.LogException(validationException);
                    _errorWorker.OnError(value as string);
                }
                catch (Exception exception)
                {
                    _logger.LogException(exception);
                    _errorWorker.OnError(value as string);
                }
            });
        }
示例#11
0
        public async Task <IActionResult> Post([FromBody] UploadRequest request)
        {
            string authHeader = this.HttpContext.Request.Headers["Authorization"];
            string token      = authHeader.Substring("bearer ".Length).Trim();
            var    userresult = _repository.GetUserByToken(token);

            if (!userresult.ResultStatus)
            {
                return(Unauthorized());
            }
            if (userresult.ResultEntity.refUserRole != 1)
            {
                return(Unauthorized());
            }

            var result = _saver.Save(request);

            if (!result.ResultStatus)
            {
                return(Ok(await Task.Run(() => result)));
            }
            return(Ok(await Task.Run(() => _repositoryDocument.Insert(new Document
            {
                CreatedUserId = userresult.ResultEntity.Id,
                CreatedDate = DateTime.UtcNow,
                FilePath = result.ResultEntity.FilePath,
                FileSize = result.ResultEntity.FileSize,
                Name = request.Name
            }))));
        }
        private void SetOutput(IOutputPattern p, string value)
        {
            void WriteToHandlers(string name, string content)
            {
                HighFrequencyDataConsumers.ForEach(h => h.Handle(name, content));
            }

            //Standard output
            WriteToHandlers(p.Name, value.Replace("\r", ""));

            if (SaveLiveTokensOnDisk)
            {
                _saver.Save($"{p.Name}.txt", value);
            }

            //ingameOverlay
            if (p.ShowInOsu)
            {
                var configName = "conf-" + p.Name;
                var valueName  = "value-" + p.Name;
                var config     = $"{p.XPosition} {p.YPosition} {p.Color.R} {p.Color.G} {p.Color.B} {p.Color.A} {p.FontName.Replace(' ', '/')} {p.FontSize} {p.Aligment}";
                WriteToHandlers(configName, config);
                WriteToHandlers(valueName, value);
            }
        }
示例#13
0
 public void Save()
 {
     Saved.Invoke();
     for (int i = 0; i < _datas.Count; i++)
     {
         _saver.Save(_datas[i], _folderPath);
     }
 }
 public void SaveCounters()
 {
     // TODO: choose lightest lock
     lock (InnerCounters)
     {
         _counterSaver.Save("Record.txt", Util.Timestamp(), InnerCounters);
     }
 }
示例#15
0
        public void AddDocument(string text)
        {
            Document doc = new Document()
            {
                Text = text
            };

            saver.Save(doc);
        }
示例#16
0
        public void SaveDecodedText(ISaver saver)
        {
            if (saver == null)
            {
                throw new ArgumentNullException("saver");
            }

            saver.Save(decodedText);
        }
示例#17
0
        public void Process()
        {
            string[] data  = reader.GetInputData();
            var      phone = binder.CreateItem(data);

            if (validator.IsValid(phone))
            {
                saver.Save(phone, "store.txt");
            }
        }
        public void OnReceivingData(List <byte> data)
        {
            if (_needSaveDataToFile)
            {
                _saverData.Save(data);
            }
            var preparedData = new Data(data);

            Info.ProcessNewInfo(preparedData);
        }
示例#19
0
        public async void Load()
        {
            await Load(_startUri, 0);

            _logger.Info("Save mappings...");
            var mappings = _linksMapping.Select((x, i) => $"{i + 1}\t{x.Key}\t-\t{x.Value}");

            _saver.Save(mappings.ToArray(), _downloadPath, "mapping.txt");
            _logger.Info("Ready!");
        }
示例#20
0
 public void Save(string directory, string content)
 {
     try
     {
         _saver.Save(directory, content);
     }
     catch (System.IO.IOException e)
     {
         _logger.Log("EXCEPTION: {0}" + Environment.NewLine + "{1}", LogLevel.Basic, e.Message, e.StackTrace);
     }
 }
示例#21
0
        private void jsonSaveFileMenuItem_Click(object sender, EventArgs e)
        {
            int nPopulation;

            int.TryParse(nucleonAmoutCAPropertiesNumericUpDown.Text, out nPopulation);
            Saver = new JSONSaver(nPopulation,
                                  neighbourhoodCAPropertiesComboBox.Text,
                                  boundaryConditionCAPropertiesComboBox.Text);

            Saver.Save(gridController.GetCurrentGrid());
        }
示例#22
0
    private void SaveLevels()
    {
        SavingParametersContainer spc = new SavingParametersContainer();

        spc.SavingParameters = new SavingParameters[m_AllLevels.Parameters.Length];
        for (int i = 0; i < spc.SavingParameters.Length; ++i)
        {
            spc.SavingParameters[i] = m_AllLevels.Parameters[i].SavedParameters;
        }
        m_Saver.Save(spc);
    }
示例#23
0
        public void Save(MarketBook book)
        {
            var marketId = book.MarketId;
            var runners  = book.Runners;

            foreach (var runner in runners)
            {
                runner.MarketId = marketId;
                _runnerSaver.Save(runner);
            }
        }
示例#24
0
        public SMTPLogger(Game game)
        {
            _container = game.Container;
            if (File.Exists("log.temp"))
            {
                int i = 0;
                while (File.Exists("crashlog_" + i + ".we"))
                {
                    i++;
                }
                File.Copy("log.temp", "crashlog_" + i + ".we");

                Task.Run(() =>
                {
                    MailMessage msg = new MailMessage
                    {
                        From    = new MailAddress("*****@*****.**"),
                        Subject = "Crash report ",
                        Body    =
                            DateTime.Now.ToString(CultureInfo.InvariantCulture) + '\n' +
                            Environment.MachineName,
                        Attachments = { new Attachment("crashlog_" + i + ".we") }
                    };
                    msg.To.Add("*****@*****.**");
                    SmtpClient client = new SmtpClient
                    {
                        UseDefaultCredentials = true,
                        Host           = "smtp.gmail.com",
                        Port           = 587,
                        EnableSsl      = true,
                        DeliveryMethod = SmtpDeliveryMethod.Network,
                        Credentials    = new NetworkCredential("*****@*****.**", "winechek1234"),
                        Timeout        = 20000
                    };
                    try
                    {
                        client.Send(msg);
                        return("Mail has been successfully sent!");
                    }
                    catch (Exception ex)
                    {
                        return("Fail Has error" + ex.Message);
                    }
                    finally
                    {
                        msg.Dispose();
                    }
                });
            }

            game.StateChanged += state => { _saver.Save(_container, "log.temp"); };
        }
        public async Task <IActionResult> CreateEventTypeMarketTypeFetchRoot([FromRoute] int dataProviderId, [FromRoute] string eventTypeId,
                                                                             [FromBody] EventTypeMarketTypeCreationDto eventTypeMarketType)
        {
            DataProvider dataProvider = await _dataProviderReader.Read(dataProviderId);

            if (dataProvider == null)
            {
                return(NotFound($"Unable to find dataProvider with id {dataProviderId}"));
            }

            EventType eventType = await _eventTypeReader.Read(eventTypeId);

            if (eventType == null)
            {
                return(NotFound($"Unable to find eventType with id {eventTypeId}"));
            }

            IExternalMarketTypesRepository marketTypesRepository = _marketTypesRepositoryFactory?.Invoke(dataProviderId);
            IEnumerable <MarketType>       marketTypes           = await marketTypesRepository.GetMarketTypesByEventTypeId(eventTypeId);

            if (!marketTypes.Any(mtr => mtr.Name == eventTypeMarketType.MarketType))
            {
                return(NotFound($"There are no markets with type {eventTypeMarketType.MarketType} in the eventType with id {eventTypeId} in the Betfair system"));
            }

            if (await _eventTypeMarketTypeReader.Read(Tuple.Create(dataProviderId, eventTypeId, eventTypeMarketType.MarketType)) != null)
            {
                return(Conflict($"The fetch root object with eventTypeId {eventTypeId} and marketType {eventTypeMarketType.MarketType} has already been saved."));
            }

            var fetchRoot = new EventTypeMarketType()
            {
                DataProviderId = dataProviderId,
                EventTypeId    = eventTypeId,
                MarketType     = eventTypeMarketType.MarketType
            };
            await _eventTypeMarketTypeSaver.Save(fetchRoot);

            return(CreatedAtRoute(
                       "GetEventTypeMarketTypeFetchRoot",
                       new
            {
                dataProviderId = dataProviderId,
                eventTypeId = eventTypeId,
                marketType = eventTypeMarketType.MarketType
            },
                       fetchRoot));
        }
示例#26
0
        static void Main(string[] args)
        {
            //lista impiegati creata come mock

            var employees = CreateEmployess();

            //per ogni impiegato della lista
            //    se è il suo giorno di paga
            //        calcola la sua paga
            //        crea un record con ID, paga e data di oggi
            //        salva record in una lista di record
            List <PayCheckRecord> payCheckRecords = new List <PayCheckRecord>();

            var date = new DateTime(2019, 8, 31);

            //var endDay = new DateTime(2019, 8, 31);
            //var startDay = new DateTime(2019, 8, 22);

            foreach (var e in employees)
            {
                if (e.IsPayDay(date))
                {
                    var pay = e.CalculatePay(date);
                    if (pay != 0m)
                    {
                        var record = new PayCheckRecord(e.ID, DateTime.Today, pay);
                        payCheckRecords.Add(record);
                    }
                }
            }


            var    persons  = CreatePersons();
            string jsonFile = @"c:\myJson.json";
            string xmlFile  = @"c:\myXML.xml";

            ISaver xmlSaver = Saver.GetSaver <XMLSaver>();

            xmlSaver.Save(persons, xmlFile);

            ISaver jsonSaver = Saver.GetSaver <JSonSaver>();

            jsonSaver.Save(persons, jsonFile);

            Console.ReadKey();
        }
        public void SaveConfigToText(ISaver <TData> gameConfig, string fileName)
        {
            var fileFullPath = GetConfigFileFullPath(fileName);

            if (File.Exists(fileFullPath))
            {
                var data = gameConfig.Save();
                var text = WriteDataToText(data);

                File.WriteAllText(fileFullPath, text);
                UnityEditor.AssetDatabase.ImportAsset(fileFullPath);
            }
            else
            {
                Debug.LogErrorFormat("Failed to save configs since file for path do not exist {0}", fileFullPath);
            }
        }
示例#28
0
文件: Engine.cs 项目: Jebeli/Tiles
        public void SaveTileSet(TileSet tileSet, string fileId = null)
        {
            if (tileSet == null)
            {
                return;
            }
            if (fileId == null)
            {
                fileId = tileSet.Name;
            }
            fileId = AdjustFileName(fileId);
            ISaver saver = GetSaver(fileId);

            if (saver != null)
            {
                saver.Save(tileSet, fileId);
            }
        }
示例#29
0
文件: Engine.cs 项目: Jebeli/Tiles
        public void SaveMap(Map map, string fileId = null)
        {
            if (map == null)
            {
                return;
            }
            if (fileId == null)
            {
                fileId = map.FileName;
            }
            fileId = AdjustFileName(fileId);
            ISaver saver = GetSaver(fileId);

            if (saver != null)
            {
                saver.Save(map, fileId);
            }
        }
示例#30
0
文件: Engine.cs 项目: Jebeli/Tiles
        public void SaveParallax(MapParallax parallax, string fileId = null)
        {
            if (parallax == null)
            {
                return;
            }
            if (fileId == null)
            {
                fileId = parallax.Name;
            }
            fileId = AdjustFileName(fileId);
            ISaver saver = GetSaver(fileId);

            if (saver != null)
            {
                saver.Save(parallax, fileId);
            }
        }