/// <summary>
        /// This is the main deal method in this sample.
        /// It invoke methods to read and write journal data and create a wall using these data
        /// </summary>
        public void CreateDocumentation(Document document, DocumentationSetting setting)
        {
            var manager = new DocumentationManager();

            if (CanReadData)
            {
                setting.SetSettings(commandData.JournalData);
                setting = ReadJournalData(setting);
                if (setting.DocumentFormat == DocumentFormat.Json)
                {
                    manager.CreateJsonFamilyDoc(document, setting);
                }
                else if (setting.DocumentFormat == DocumentFormat.Web)
                {
                    manager.CreateWebFamilyDoc(document, setting);
                }

                if (setting.DocumentFormat != DocumentFormat.None)
                {
                    JournalHelper.KillCurrentProcess();
                }
            }
            else
            {
                if (setting.DocumentFormat == DocumentFormat.Json)
                {
                    manager.CreateJsonFamilyDoc(document, setting);
                }
                WriteJournalData(setting);
            }
        }
        static void Main(string[] args)
        {
            var filename = "test.txt";
            var j        = new Journal();

            j.AddEntry("Entry 1");
            j.AddEntry("Entry 2");
            Console.WriteLine(j);
            JournalHelper.SaveToFile(j, filename, true);
            Console.ReadKey();
        }
Example #3
0
 public static void SetJournalEntry(this EnemyDeathEffects ede, JournalHelper jh)
 {
     try
     {
         string s = "CustomJournal" + jh.entrynumber;
         Modding.ReflectionHelper.SetField <EnemyDeathEffects, string>(ede, "playerDataName", s);
     }
     catch (Exception e)
     {
         Log("Journal Extentions", e);
     }
 }
Example #4
0
            public PersistenceIdsLogic(ConnectionMultiplexer redis, int database, ExtendedActorSystem system, Outlet <string> outlet, Shape shape) : base(shape)
            {
                _redis         = redis;
                _database      = database;
                _journalHelper = new JournalHelper(system, system.Settings.Config.GetString("akka.persistence.journal.redis.key-prefix"));
                _outlet        = outlet;

                SetHandler(outlet, onPull: () =>
                {
                    _downstreamWaiting = true;
                    if (_buffer.Count == 0 && (_start || _index > 0))
                    {
                        var callback = GetAsyncCallback <IEnumerable <RedisValue> >(data =>
                        {
                            // save the index for further initialization if needed
                            _index = data.AsInstanceOf <IScanningCursor>().Cursor;

                            // it is not the start anymore
                            _start = false;

                            // enqueue received data
                            try
                            {
                                foreach (var item in data)
                                {
                                    _buffer.Enqueue(item);
                                }
                            }
                            catch (Exception e)
                            {
                                Log.Error(e, "Error while querying persistence identifiers");
                                FailStage(e);
                            }

                            // deliver element
                            Deliver();
                        });

                        callback(_redis.GetDatabase(_database).SetScan(_journalHelper.GetIdentifiersKey(), cursor: _index));
                    }
                    else if (_buffer.Count == 0)
                    {
                        // wait for asynchornous notification and mark dowstream
                        // as waiting for data
                    }
                    else
                    {
                        Deliver();
                    }
                });
            }
        public void A_CanInsertTravelerJournal()
        {
            //  Arrange
            Initiate();
            int  expectedID;
            bool didInsert;
            bool ensuredInsertion;

            //  Act
            expectedID       = currentIDIndex;
            didInsert        = TravelerJournalRepo.Link.InsertData(journal);
            ensuredInsertion = JournalHelper.CheckIDFromStorage(expectedID, TravelerJournalRepo.Link.FilePath);
            CleanUp();

            //  Assert
            Assert.True(didInsert && ensuredInsertion, $"{AssertHelper.ValidatorMessage ("Did Insert:", didInsert, didInsert, true)} <|> {AssertHelper.ValidatorMessage ("Ensured Insertion:", ensuredInsertion, journal.ID, expectedID)}");
        }
        public void CanDeleteTravelerJournal()
        {
            //  Arrange
            Initiate();
            int  expectedID = currentIDIndex;
            bool didDelete;
            bool wasNull;

            JournalHelper.ManualStorageInsertion(journal, JournalType.TravelerJournal, TravelerJournalRepo.Link.StoragePath);

            //  Act
            didDelete = TravelerJournalRepo.Link.DeleteData(journal);
            wasNull   = !JournalHelper.CheckIDFromStorage(expectedID, TravelerJournalRepo.Link.FilePath);
            CleanUp();

            //  Assert
            Assert.True(didDelete && wasNull, $"{AssertHelper.ValidatorMessage ("Did Delete:", didDelete, didDelete, true)} <|> {AssertHelper.ValidatorMessage ("Was Null:", wasNull, wasNull, true)}");
        }
            public CurrentPersistenceIdsLogic(IDatabase redisDatabase, ExtendedActorSystem system, Outlet <string> outlet, Shape shape) : base(shape)
            {
                _outlet        = outlet;
                _journalHelper = new JournalHelper(system, system.Settings.Config.GetString("akka.persistence.journal.redis.key-prefix"));

                SetHandler(outlet, onPull: () =>
                {
                    if (_buffer.Count == 0 && (_start || _index > 0))
                    {
                        var callback = GetAsyncCallback <IEnumerable <RedisValue> >(data =>
                        {
                            // save the index for further initialization if needed
                            _index = data.AsInstanceOf <IScanningCursor>().Cursor;

                            // it is not the start anymore
                            _start = false;

                            // enqueue received data
                            try
                            {
                                foreach (var item in data)
                                {
                                    _buffer.Enqueue(item);
                                }
                            }
                            catch (Exception e)
                            {
                                Log.Error(e, "Error while querying persistence identifiers");
                                FailStage(e);
                            }

                            // deliver element
                            Deliver();
                        });

                        callback(redisDatabase.SetScan(_journalHelper.GetIdentifiersKey(), cursor: _index));
                    }
                    else
                    {
                        Deliver();
                    }
                });
            }
Example #8
0
        public Startup(IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddJsonFile("cognitivemodels.json", optional: true)
                          .AddJsonFile($"cognitivemodels.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            DBHelper.Configuration = Configuration;
            TextAnalyticsHelper.Configure(Configuration);
            JournalHelper.Configure(Configuration);
            TokensController.Configuration = Configuration;
            GraphHelper.Configure(Configuration);
            this.HostingEnvironment = env;
        }
        public ActionResult Edit(JournalUpdateViewModel journal)
        {
            if (ModelState.IsValid)
            {
                var selectedJournal = Mapper.Map <JournalUpdateViewModel, Journal>(journal);
                JournalHelper.PopulateFile(journal.File, selectedJournal);

                var opStatus = _journalRepository.UpdateJournal(selectedJournal);
                if (!opStatus.Status)
                {
                    throw new System.Web.Http.HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(journal));
            }
        }
        public void CanUpdateTravelerJournal()
        {
            //  Arrange
            Initiate();
            bool   updated;
            bool   validated;
            string orignalValue = journal.PatientData.ChildFathersName;

            JournalHelper.ManualStorageInsertion(journal, JournalType.TravelerJournal, TravelerJournalRepo.Link.StoragePath);
            PatientHelper.ManualStorageInsertion(patient, PatientRepo.Link.FullPath);

            //  Act
            journal.PatientData.ChildFathersName = "MyChangedChildFathersName";
            updated   = TravelerJournalRepo.Link.UpdateData(journal);
            validated = PatientHelper.CheckValueFromStorage(journal.PatientData.ChildFathersName, PatientRepo.Link.FullPath);
            journal.PatientData.ChildFathersName = orignalValue;
            CleanUp();

            //  Asserts
            Assert.True(updated && validated, $"{AssertHelper.ValidatorMessage ("Updated:", updated, updated, true)} <|> {AssertHelper.ValidatorMessage ("Validated:", validated, validated, true)}");
        }
        public void CanGetByID()
        {
            //  Arrange
            Initiate();
            int expectedID;
            ITravelerJournal retrievedJournal;
            bool             notNull;
            bool             correctID;

            JournalHelper.ManualStorageInsertion(journal, JournalType.TravelerJournal, TravelerJournalRepo.Link.StoragePath);   //  Ensuring that an entry exists in storage

            //  Act
            expectedID       = journal.ID;
            retrievedJournal = TravelerJournalRepo.Link.GetDataByIdentifier(journal.ID);
            notNull          = (retrievedJournal != null);
            correctID        = (retrievedJournal?.ID == expectedID);
            CleanUp();

            //  Assert
            Assert.True(notNull && correctID, $"{AssertHelper.ValidatorMessage ("Is Null:", !notNull, !notNull, false)} <|> {AssertHelper.ValidatorMessage ("Correct ID:", correctID, ( ( notNull ) ? ( retrievedJournal.ID.ToString () ) : ( "NaN" ) ), expectedID)}");
        }
        public void CreateJournal(CreateJournalSetting createSetting)
        {
            try
            {
                var journalData = JournalHelper.BuildJournalStart(createSetting.DebugModus);
                journalData += JournalHelper.BuildDocumentOpen(createSetting.CurrentFile.FilePath);

                journalData += JournalHelper.BuildAddinLaunch(createSetting.AddinId, createSetting.CmdFullName);
                journalData += JournalHelper.BuildAddinAddinCommandData(createSetting.JournalData);

                var journalFile = FileHelper.ChangeExtension(createSetting.CurrentFile.FilePath, "txt");
                journalFile = Path.GetFileName(journalFile);
                journalFile = $"{createSetting.FileCount}_{journalFile}";
                journalFile = Path.Combine(createSetting.DestinationDir, journalFile);
                FileHelper.WriteFile(journalFile, journalData);
                journalFiles.Add(journalFile);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ActionResult Create(JournalViewModel journal)
        {
            if (ModelState.IsValid)
            {
                var newJournal = Mapper.Map <JournalViewModel, Journal>(journal);
                JournalHelper.PopulateFile(journal.File, newJournal);

                newJournal.UserId = (int)_membershipService.GetUser().ProviderUserKey;

                var opStatus = _journalRepository.AddJournal(newJournal);
                if (!opStatus.Status)
                {
                    throw new System.Web.Http.HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
                }

                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(journal));
            }
        }
        public ActionResult CreateIssue(JournalViewModel journal)
        {
            if (ModelState.IsValid)
            {
                var newJournal = Mapper.Map <JournalViewModel, Journal>(journal);
                //async use here
                JournalHelper.PopulateFile(journal.File, newJournal);

                newJournal.UserId = LoggedInUser.UserId;

                var opStatus = _journalRepository.AddJournalIssue(newJournal);
                if (!opStatus.Status)
                {
                    throw new System.Web.Http.HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError));
                }

                return(RedirectToAction("Issues", new { journalID = journal.JournalId }));
            }
            else
            {
                return(RedirectToAction("CreateIssue", new { journalID = journal.JournalId }));
            }
        }
Example #15
0
            public EventsByTagLogic(
                ConnectionMultiplexer redis,
                int database,
                Config config,
                ActorSystem system,
                string tag,
                long offset,
                bool live,
                Outlet <EventEnvelope> outlet, Shape shape) : base(shape)
            {
                _outlet   = outlet;
                _redis    = redis;
                _database = database;
                _system   = system;
                _offset   = offset;
                _tag      = tag;
                _live     = live;

                _max           = config.GetInt("max-buffer-size");
                _journalHelper = new JournalHelper(system, system.Settings.Config.GetString("akka.persistence.journal.redis.key-prefix"));

                _currentOffset = offset > 0 ? offset + 1 : 0;

                SetHandler(outlet, onPull: () =>
                {
                    switch (_state)
                    {
                    case State.Initializing:
                        _state = State.QueryWhenInitializing;
                        break;

                    default:
                        Query();
                        break;
                    }
                });
            }
        public void CanGetEnumerator()
        {
            //  Arrange
            Initiate();
            int  expectedEntries = 3;
            bool notNull;
            bool notEmpty;
            bool correctAmount;

            JournalHelper.ManualStorageInsertion(JournalFactory.Create(JournalType.TravelerJournal), JournalType.TravelerJournal, TravelerJournalRepo.Link.StoragePath);
            JournalHelper.ManualStorageInsertion(JournalFactory.Create(JournalType.TravelerJournal), JournalType.TravelerJournal, TravelerJournalRepo.Link.StoragePath, true);
            JournalHelper.ManualStorageInsertion(JournalFactory.Create(JournalType.TravelerJournal), JournalType.TravelerJournal, TravelerJournalRepo.Link.StoragePath, true);

            //  Act
            List <ITravelerJournal> pJournal = TravelerJournalRepo.Link.GetEnumerable().ToList();

            notNull       = journal != null;
            notEmpty      = pJournal?.Count != 0;
            correctAmount = pJournal?.Count == 3;
            CleanUp();

            //  Assert
            Assert.True(notNull && notEmpty && correctAmount, $" {AssertHelper.ValidatorMessage ("Is Null:", !notNull, !notNull, false)} <|> {AssertHelper.ValidatorMessage ("Is Empty:", !notEmpty, ( ( journal != null ) ? ( pJournal.Count.ToString () ) : ( "NaN" ) ), "> 0")} <|> {AssertHelper.ValidatorMessage ("Correct Amount:", correctAmount, ( ( pJournal != null ) ? ( pJournal.Count.ToString () ) : ( "NaN" ) ), expectedEntries)}");
        }
Example #17
0
 public RedisJournal()
 {
     _settings      = RedisPersistence.Get(Context.System).JournalSettings;
     _journalHelper = new JournalHelper(Context.System, _settings.KeyPrefix);
 }
Example #18
0
        // Token: 0x06000052 RID: 82 RVA: 0x0000358C File Offset: 0x0000178C
        public override void Initialize(Dictionary <string, Dictionary <string, GameObject> > preloadedObjects)
        {
            Uuwuu.Instance = this;
            Uuwuu.PreloadedGameObjects.Add("saw", preloadedObjects["White_Palace_07"]["wp_saw (30)"]);
            this.Unload();
            this.SetupSettings();
            ModHooks.Instance.BeforeSavegameSaveHook += Instance_BeforeSavegameSaveHook;
            ModHooks.Instance.AfterSavegameLoadHook  += this.SaveGame;
            ModHooks.Instance.NewGameHook            += AddComponent;
            ModHooks.Instance.LanguageGetHook        += this.OnLangGet;
            UnityEngine.SceneManagement.SceneManager.activeSceneChanged += this.SceneChanged;
            ModHooks.Instance.GetPlayerVariableHook += this.GetVariableHook;
            ModHooks.Instance.GetPlayerBoolHook     += this.OnGetPlayerBoolHook;
            ModHooks.Instance.SetPlayerBoolHook     += this.OnSetPlayerBoolHook;
            ModHooks.Instance.GetPlayerIntHook      += this.OnGetPlayerIntHook;
            Assembly asm = Assembly.GetExecutingAssembly();

            Sprites = new Dictionary <string, Sprite>();
            foreach (string res in asm.GetManifestResourceNames())
            {
                if (!res.EndsWith(".png"))
                {
                    continue;
                }

                if (res.Contains("Uuwuu.png"))
                {
                    using (Stream s = asm.GetManifestResourceStream(res))
                    {
                        if (s == null)
                        {
                            continue;
                        }
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();

                        //Create texture from bytes
                        Texture2D tex = new Texture2D(1, 1);
                        tex.LoadImage(buffer);

                        //Create sprite from texture
                        Sprites.Add("Charm", Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)));
                        Log("Created sprite from embedded image: " + res);
                    }
                }
                if (res.Contains("Uumuu_picture.png"))
                {
                    using (Stream s = asm.GetManifestResourceStream(res))
                    {
                        if (s == null)
                        {
                            continue;
                        }
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();

                        //Create texture from bytes
                        Texture2D tex = new Texture2D(1, 1);
                        tex.LoadImage(buffer);

                        //Create sprite from texture
                        Sprites.Add("Picture", Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)));
                        Log("Created sprite from embedded image: " + res);
                    }
                }
                if (res.Contains("Uumuu_portrait.png"))
                {
                    using (Stream s = asm.GetManifestResourceStream(res))
                    {
                        if (s == null)
                        {
                            continue;
                        }
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();

                        //Create texture from bytes
                        Texture2D tex = new Texture2D(1, 1);
                        tex.LoadImage(buffer);

                        //Create sprite from texture
                        Sprites.Add("Portrait", Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)));
                        Log("Created sprite from embedded image: " + res);
                    }
                }
                if (res.Contains("divider.png"))
                {
                    using (Stream s = asm.GetManifestResourceStream(res))
                    {
                        if (s == null)
                        {
                            continue;
                        }
                        byte[] buffer = new byte[s.Length];
                        s.Read(buffer, 0, buffer.Length);
                        s.Dispose();

                        //Create texture from bytes
                        Texture2D tex = new Texture2D(1, 1);
                        tex.LoadImage(buffer);

                        //Create sprite from texture
                        Sprites.Add("Divider", Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)));
                        Log("Created sprite from embedded image: " + res);
                    }
                }
            }
            this.ChHelper             = new CharmHelper();
            ChHelper.customCharms     = 1;
            ChHelper.customSprites[0] = Uuwuu.Instance.Sprites["Charm"];
            jh = JournalHelper.AddJournalEntry(Sprites["Portrait"], Sprites["Picture"], new JournalHelper.JournalPlayerData()
            {
                haskilled = false, Hidden = true, killsremaining = 3, newentry = true
            }, new JournalHelper.JournalNameStrings()
            {
                name = "Uuwuu", desc = "Hidden master of the Fog Canyon", note = "I'm gonna kill you uwu - Uuwuu", shortname = "Uuwuu"
            }, JournalHelper.EntryType.Custom, Sprites["Divider"]);
        }