public DownloadStashViewModel(IDialogCoordinator dialogCoordinator, IPersistentData persistentData, Stash stash) { _stash = stash; _persistenData = persistentData; _dialogCoordinator = dialogCoordinator; DisplayName = L10n.Message("Download & Import Stash"); Build = persistentData.CurrentBuild; if (Build.League != null && _persistenData.LeagueStashes.ContainsKey(Build.League)) _tabs = new List<StashBookmark>(_persistenData.LeagueStashes[Build.League]); TabsView = new ListCollectionView(_tabs); TabsView.CurrentChanged += (sender, args) => UpdateTabLink(); Build.PropertyChanged += BuildOnPropertyChanged; BuildOnPropertyChanged(this, null); RequestsClose += _ => Build.PropertyChanged -= BuildOnPropertyChanged; _viewLoadedCompletionSource = new TaskCompletionSource<object>(); if (CurrentLeagues == null) { CurrentLeagues = new NotifyingTask<IReadOnlyList<string>>(LoadCurrentLeaguesAsync(), async e => { await _viewLoadedCompletionSource.Task; await _dialogCoordinator.ShowWarningAsync(this, L10n.Message("Could not load the currently running leagues."), e.Message); }); } }
internal static void Remove (this StashCollection sc, Stash stash) { int i = 0; foreach (var s in sc) { if (s.FriendlyName == stash.FriendlyName) { sc.Remove (i); break; } ++i; } }
public static int GetNumStashPages(string filename) { if (File.Exists(filename)) { var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename)); var stash = new Stash(); if (stash.Read(pCrypto)) { return(stash.Tabs.Count); } } return(0); }
// this state will stash all messages until it receives StateInitialized, // which was scheduled by previous watchStateActors private bool WaitingForStateInitialized(object message) { switch (message) { case PersistentShardCoordinator.StateInitialized _: Stash.UnstashAll(); this.StateInitialized(); Activate(); return(true); default: Stash.Stash(); return(true); } }
/// <summary>Initializes a new instance of the <see cref="WebCrawlerActor"/> class.</summary> /// <param name="systemConfiguration">The system configuration.</param> /// <param name="client"></param> public WebCrawlerActor(ISystemConfiguration systemConfiguration, IActorRef root) { _systemConfiguration = systemConfiguration; _root = root; _client = new HttpClient(); _httpTimeoutInMiniseconds = systemConfiguration.HttpTimeoutInMiniseconds; SetupHttpClient(); Receive <RootActorMessages.AddressBook>( b => { _actorDictionary = b.ActorDictionary; _gotBook = true; Stash.UnstashAll(); }); Receive <CrawlerMessages.GetData>( m => { if (_gotBook) { ProcessGetMessage(m); _lastActivity = DateTime.Now; } else { Stash.Stash(); } }); Receive <CrawlerMessages.WebApiErrorResponse>(a => { ProcessWebErrorMessage(a); }); Receive <CrawlerMessages.PipedRequest>(o => { ProcessPipedRequest(o); }); Receive <CrawlerMessages.Timer>( t => { if (_gotBook) { ProcessTimer(); } else { Stash.Stash(); } }); }
public void StashingAgainstCleanWorkDirShouldReturnANullStash() { TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath); using (var repo = new Repository(path.RepositoryPath)) { var stasher = DummySignature; Stash stash = repo.Stashes.Add(stasher, "My very first stash", StashOptions.IncludeUntracked); Assert.NotNull(stash); //Stash against clean working directory Assert.Null(repo.Stashes.Add(stasher)); } }
private bool Stashing(object message) { switch (message) { case StopStashing _: Context.Become(NotStashing); Stash.UnstashAll(); return(true); case "scheduled": probe.Tell("saw-scheduled"); Stash.Stash(); return(true); } return(false); }
private void Paused() { // while paused, we need to stash AddSeries & RemoveSeries messages Receive <AddSeries>(addSeries => Stash.Stash()); Receive <RemoveSeries>(removeSeries => Stash.Stash()); Receive <Metric>(metric => HandleMetricsPaused(metric)); Receive <TogglePause>(pause => { SetPauseButtonText(false); UnbecomeStacked(); // ChartingActor is leaving the Paused state, put messages back // into mailbox for processing under new behavior Stash.UnstashAll(); }); }
private void AwaitingConnectionRecovery() { Receive <ConnectionRecoverySucceeded>(connectionRecoverySucceeded => { var resumeProcessingMessage = new ResumeProcessing(); // TODO can use pause transaction id _publishersActorRefs.ForEach(ar => ar.Tell(resumeProcessingMessage)); _consumersActorRefs.ForEach(ar => ar.Tell(resumeProcessingMessage)); Become(Ready); Stash.UnstashAll(); }); Receive <ConnectionShutdown>(connectionShutdown => { // TODO ignore/log }); ReceiveAny(m => Stash.Stash()); }
protected override bool Receive(object message) { if (message is SetStore) { var setStore = message as SetStore; _store = setStore.Store; Stash.UnstashAll(); Context.Become(_initialized); } else { Stash.Stash(); } return(true); }
public void QuietWriter() { Receive <WriteSomethingMessage>(msg => { if (msg.ThingToWrite.ToLowerInvariant() == "be loud") { Console.WriteLine("Letting it all out!"); Stash.UnstashAll(); Become(NormalWriter); } else { Stash.Stash(); } }); }
public void UpdateUnlooted(string filename) { var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename)); var stash = new Stash(); if (stash.Read(pCrypto)) { // Update the internal listing of unlooted items (in stash tabs) var unlootedLocal = new List <Item>(); foreach (var tab in stash.Tabs) { unlootedLocal.AddRange(tab.Items); } Interlocked.Exchange(ref _unlootedItems, new ConcurrentBag <Item>(unlootedLocal)); } }
/// <summary> /// State for when we're currently processing a job /// </summary> private void Busy() { Receive <GithubValidatorActor.RepoIsValid>(valid => BecomeReady("Valid!")); Receive <GithubValidatorActor.InvalidRepo>(invalid => BecomeReady(invalid.Reason, false)); //yes Receive <GithubCommanderActor.UnableToAcceptJob>( job => BecomeReady( string.Format("{0}/{1} is a valid repo, but system can't accept additional jobs", job.Repo.Owner, job.Repo.Repo), false)); //no Receive <GithubCommanderActor.AbleToAcceptJob>( job => BecomeReady(string.Format("{0}/{1} is a valid repo - starting job!", job.Repo.Owner, job.Repo.Repo))); Receive <LaunchRepoResultsWindow>(window => Stash.Stash()); }
public StashingTwiceActor() { Receive("hello", m => { Stash.Stash(); try { Stash.Stash(); } catch (IllegalActorStateException e) { _state.ExpectedException.Open(); } }); ReceiveAny(m => { }); }
public void StashingAgainstCleanWorkDirShouldReturnANullStash() { string path = CloneStandardTestRepo(); using (var repo = new Repository(path)) { var stasher = Constants.Signature; Stash stash = repo.Stashes.Add(stasher, "My very first stash", StashModifiers.IncludeUntracked); Assert.NotNull(stash); //Stash against clean working directory Assert.Null(repo.Stashes.Add(stasher, options: StashModifiers.Default)); } }
private void Awake() { AudioSource audioSource = GetComponent <AudioSource>(); useObject = GetComponent <CommonUsableObject>(); useObject.OnUse.AddListener((character) => { if (Used) { return; } Used = true; audioSource?.Play(); if (LootTable.Length == 0) { return; } for (int i = 0; i < Loot; i++) { int r = Random.Range(0, LootTable.Length); InventoryGUIObject item = LootTable[r].GetComponent <InventoryGUIObject>(); if (item == null) { Debug.LogError("LootBoxes: OnUse: no <InventoryGUIObject> component found in loot index [" + r + "]"); return; } if (item is CraftingMatGUIObject) { Stash.CraftingMaterials += (item as CraftingMatGUIObject).craftingMats; } else { Stash.AddItemToFirstEmpty(item, out int _); } Messaging.GUI.LootMessage.Invoke(item, 0); } useObject.enabled = false; }); }
void Connected(object message) { switch (message) { case Start s: var joinCmd = Console.ReadLine().Split(' '); if (joinCmd.Length != 2 || (!joinCmd[0].ToLowerInvariant().Equals("/join") && !joinCmd[0].ToLowerInvariant().Equals("/create"))) { Console.WriteLine("Invalid input."); Console.WriteLine("Type /join [roomname] to join a room, or /create [roomname] to create a new room."); Self.Tell(s); return; } switch (joinCmd[0].ToLowerInvariant()) { case "/join": receiptionist.Tell(new JoinRoom(joinCmd[1], _name)); break; case "/create": receiptionist.Tell(new CreateRoom(joinCmd[1], _name)); break; } break; case JoinConfirmed confirmed: Console.WriteLine($"Joined {confirmed.RoomName}"); chatActor = Sender; Context.Become(InChat); Context.ActorOf(Props.Create(() => new ConsoleReader(_name, Self, Sender))); Stash.UnstashAll(); break; case Err e: Console.WriteLine($"Error trying to join room. {e.Reason}"); Console.WriteLine("Type /join [roomname] to join a room, or /create [roomname] to create a new room."); Self.Tell(new Start()); break; default: Stash.Stash(); break; } }
private Receive WaitingForBound(IActorRef replyTo, IActorRef handler, Listen listen) { return(message => { if (message is Tcp.Bound) { var bound = message as Tcp.Bound; var promise = new TaskCompletionSource <IAssociationEventListener>(); promise.Task.PipeTo(handler); replyTo.Tell(Tuple.Create(new Address(AkkaIOTransport.Protocal, Context.System.Name, listen.Hostname, ((IPEndPoint)bound.LocalAddress).Port), promise)); UnbecomeStacked(); Stash.Unstash(); return true; } return Queue(message); }); }
/// <summary> /// Gets stash info by id. /// </summary> /// <param name="id">Stash id.</param> /// <param name="stash">Stash model.</param> /// <param name="errorMessage">Error message.</param> /// <returns>Bool value that indicates whether command execution was succeeded.</returns> public bool TryGetStashInfo(int id, out Stash stash, out string errorMessage) { var infoCommand = string.Format(GitCommandConstants.StashInfoFormatted, id); var commandResult = Execute(infoCommand); if (commandResult.IsError) { errorMessage = commandResult.ErrorMessage; stash = null; return(false); } errorMessage = string.Empty; stash = GitResultParser.ParseStashInfoResult(commandResult.OutputMessage); return(true); }
private /*async*/ void CloseFrame(Token token) { if (_encoder == null) { return; } var block = FlushAndEncode(); if (block.Ready) /*await*/ WriteBlock{ (token, block); } Stash.Stash4(0); Stash.TryStash4(ContentChecksum()); /*await*/ Stash.Flush(token); }
/// <summary> /// Write the GD Stash file /// </summary> /// <param name="filename"></param> /// <param name="stash"></param> /// <returns></returns> public bool SafelyWriteStash(string filename, Stash stash) { try { var tempName = $"{filename}-{DateTime.UtcNow.ToTimestamp()}.ia"; // Store the stash file in a temporary location var dataBuffer = new DataBuffer(); stash.Write(dataBuffer); DataBuffer.WriteBytesToDisk(tempName, dataBuffer.Data); // Get the current backup number var backupNumber = _settings.GetLocal().BackupNumber; _settings.GetLocal().BackupNumber = (backupNumber + 1) % 1000; // Back up the existing stash and replace with new stash file var backupLocation = Path.Combine(GlobalPaths.BackupLocation, $"transfer.{backupNumber:00}.gs_"); File.Copy(filename, backupLocation, true); File.Copy(tempName, filename, true); Logger.Info($"The previous stash file has been backed up as {backupLocation}"); // Delete the temporary file if (File.Exists(tempName)) { File.Delete(tempName); } return(true); } catch (FileNotFoundException ex) { Logger.Warn("Could not locate the temporary stash file, this is usually caused by write protections, such as Windows 10 anti ransomware and similar issues denying IA permission to write to files."); Logger.Warn(ex.Message); Logger.Warn(ex.StackTrace); ExceptionReporter.ReportException(ex, "SafelyWriteDatabase"); _helpService.ShowHelp(HelpService.HelpType.WindowsAntiRansomwareIssue); return(false); } catch (UnauthorizedAccessException ex) { Logger.Warn(ex.Message); Logger.Warn(ex.StackTrace); ExceptionReporter.ReportException(ex, "SafelyWriteDatabase"); return(false); } }
private void Uninitialized() { Receive <InitializeAggregate>(ini => { Category = ESCategoryAttribute.GetCategory(this.GetType()); _reader = ini.Reader; _writer = ini.Writer; _options = ini.Options; _validator = _options.DefaultCommandValidator; Become(AwaitingFirstCommand); Stash.UnstashAll(); }); ReceiveAny(o => Stash.Stash()); }
private void Recovering() { Receive <RecoverySuccess <TEntity> >(success => { Entity = success.Entity; Stash.UnstashAll(); UnbecomeStacked(); }); Receive <RecoveryFailure>(failure => { Stash.UnstashAll(); UnbecomeStacked(); OnRecoveryFailure(failure.Exception); }); ReceiveAny(message => Stash.Stash()); }
public static void LoadStash() { List <Lump> data = new List <Lump>(); if (Difficulty.SharedStash && Wad.WadExists("stash.wad")) { Wad.ReadWad("stash.wad", out string wadType, out int version, out data); } else if (!Difficulty.SharedStash && Wad.WadExists("Games/" + CurrentPlayerSlot + "/stash.wad")) { Wad.ReadWad("Games/" + CurrentPlayerSlot + "/stash.wad", out string wadType, out int version, out data); } Stash.Deserialize(data); StashNeedsSave = false; }
private void Removing() { Receive <RemoveSuccess <TEntity> >(success => { Entity = default(TEntity); Stash.UnstashAll(); UnbecomeStacked(); _pendingInvocations.Dequeue()(success.Entity); }); Receive <RemoveFailure>(failure => { _persistenceActor.Tell(new Recover(Id), Sender); OnRemoveFailure(failure.Exception); UnbecomeStacked(); BecomeStacked(Recovering); }); }
private void CompareStashes(Stash newStash) { var oldStash = this.stashIDs[newStash.Id]; // todo: what happens with re-priced items? var newStashIDs = newStash.Items.Select(x => x.Id); var oldStashIDs = oldStash.Keys.ToList(); var unchangedItemIDs = newStashIDs.Intersect(oldStashIDs).ToList(); unchangedItemIDs.ForEach(x => this.CompareUnchangedItems(this.GetItemByID(x, newStash), oldStash[x])); var removedItems = oldStashIDs.Where(x => !newStashIDs.Contains(x)).Select(x => oldStash[x]).ToList(); var newItems = newStashIDs.Where(x => !oldStashIDs.Contains(x)).Select(x => this.GetItemByID(x, newStash)).ToList(); removedItems.ForEach(x => this.EvaluateRemovedItem(x)); newItems.ForEach(x => this.ProcessItem(x)); }
/// <summary> /// TBD /// </summary> /// <param name="message">TBD</param> /// <returns>TBD</returns> protected bool WaitingForInitialization(object message) { return(message.Match() .With <AllPersistenceIds>(all => { _allPersistenceIds = new HashSet <string>(all.Ids); UnbecomeStacked(); Stash.UnstashAll(); }) .With <Failure>(fail => { Log.Error(fail.Exception, "Failure during {0} initialization.", Self); Context.Stop(Self); }) .Default(_ => Stash.Stash()) .WasHandled); }
private Receive WaitingForBound(IActorRef replyTo, IActorRef handler) { return(message => { if (message is Tcp.Bound) { var bound = message as Tcp.Bound; var promise = new TaskCompletionSource <IAssociationEventListener>(); promise.Task.PipeTo(handler); replyTo.Tell(Tuple.Create(bound.LocalAddress.ToAddress(Context.System), promise)); UnbecomeStacked(); Stash.Unstash(); return true; } return Queue(message); }); }
/// <summary> /// Parses the raw data and converts to internal data. /// </summary> private void ParseRawData(Stash sta) { // First create a memory stream so we can decode the binary data as needed. using (BinaryReader reader = new BinaryReader(new MemoryStream(sta.rawData, false))) { int offset = 0; ParseItemBlock(sta, offset, reader); try { string outfile = string.Concat(Path.Combine(GamePathResolver.TQVaultSaveFolder, sta.PlayerName), " Stash Export.txt"); using (StreamWriter outStream = new StreamWriter(outfile, false)) { outStream.WriteLine("Number of Sacks = {0}", sta.numberOfSacks); if (!sta.sack.IsEmpty) { outStream.WriteLine(); outStream.WriteLine("SACK 0"); int itemNumber = 0; foreach (Item item in sta.sack) { object[] params1 = new object[20]; params1[0] = itemNumber; params1[1] = ItemProvider.GetFriendlyNames(item).FullNameBagTooltip; params1[2] = item.PositionX; params1[3] = item.PositionY; params1[4] = item.Seed; outStream.WriteLine(" {0,5:n0} {1}", params1); itemNumber++; } } } } catch (IOException exception) { Log.LogError(exception, "Error Exporting - '{0} Export.txt'" , Path.Combine(GamePathResolver.TQVaultSaveFolder, sta.PlayerName) ); } } }
/// <summary> /// Attempt to get the name of the current mod /// Vanilla leaves this tag empty /// </summary> /// <param name="filename"></param> /// <param name="result"></param> /// <returns></returns> public static bool TryGetModLabel(string filename, out string result) { if (File.Exists(filename)) { var pCrypto = new GDCryptoDataBuffer(DataBuffer.ReadBytesFromDisk(filename)); var stash = new Stash(); if (stash.Read(pCrypto)) { result = stash.ModLabel; return(true); } } result = string.Empty; return(false); }
private void RetrievingEntity() { Receive <Core.Messages.Account.AccountNameChanged>(x => { _log.Info("Retrieve account entity"); Stash.Stash(); _storage.Tell(new GetEntity(x.AggregateId, typeof(Entities.Account))); }); Receive <EntityRetrieved>(x => { _log.Info("Account entity retrieved"); _entity = (Entities.Account)x.Entity; Become(EntityAvailable); Stash.Unstash(); }); }
private void Listen() { ReceiveAsync <GetConnection>(async g => { try { ConnectionOpened connection = null; _randomKey = SignSafeMod(Random.Next(), _maxConnectionsPerHosts); _logicalEndpoint = g.LogicalEndPoint; if (g.LogicalEndPoint != null && g.PhusicalEndPoint == null) { connection = await GetConnection(g.LogicalEndPoint, _randomKey); } else if (g.LogicalEndPoint != null && g.PhusicalEndPoint != null) { connection = await GetConnection(g.LogicalEndPoint, g.PhusicalEndPoint, _randomKey); } else { connection = await GetConnection(g.LogicalEndPoint, _randomKey); } Sender.Tell(new AskResponse(connection)); } catch (Exception e) { Sender.Tell(new AskResponse(PulsarClientException.Unwrap(e))); } }); Receive <CleanupConnection>(c => { CleanupConnection(c.Address, c.ConnectionKey); }); Receive <CloseAllConnections>(_ => { CloseAllConnections(); }); Receive <ReleaseConnection>(c => { ReleaseConnection(c.ClientCnx); }); Receive <GetPoolSize>(c => { Sender.Tell(new GetPoolSizeResponse(PoolSize)); }); Stash?.UnstashAll(); }
public void SetStash(Stash stash) { _stash = stash; }
public Dictionary<string, decimal> CalculateFreeSpace(Stash stash) { return stash.CalculateFreeSpace(); }
private Stash getAllTabs(string league, Stash stash) { for (int i = 1; i < stash.NumberOfTabs; i++) stash.Add(GetStash(i, league, false)); return stash; }
public void GetImages(Stash stash) { foreach (var item in stash.Get<Item>().Distinct(new ImageComparer())) if (item.ItemType == ItemType.Gear && !item.TypeLine.Contains("Flask")) //My modification to only get image of items without flasks getImageWithEvents(item); //foreach (var item in stash.Tabs) // getImageWithEvents("Tab Icon " + item.i, item.srcC); }
void ApplyStashAndRemove(Stash s) { using (IdeApp.Workspace.GetFileStatusTracker ()) { GitService.ApplyStash (s).Completed += delegate(IAsyncOperation op) { if (op.Success) stashes.Remove (s); }; } }
public void GetImages(Stash stash) { foreach (var item in stash.Get<Item>().Distinct(new ImageComparer())) getImageWithEvents(item); foreach (var item in stash.Tabs) getImageWithEvents("Tab Icon " + item.i, item.srcC); }
public bool TryCreateStash (ProgressMonitor monitor, string message, out Stash stash) { Signature sig = GetSignature (); stash = null; if (sig == null) return false; if (monitor != null) monitor.BeginTask ("Stashing changes", 1); stash = RootRepository.Stashes.Add (sig, message, StashModifiers.Default | StashModifiers.IncludeUntracked); if (monitor != null) monitor.EndTask (); return true; }
void NotifyFilesChangedForStash (Stash stash) { // HACK: Notify file changes. foreach (var entry in RootRepository.Diff.Compare<TreeChanges> (stash.WorkTree.Tree, stash.Base.Tree)) { if (entry.Status == ChangeKind.Deleted || entry.Status == ChangeKind.Renamed) { FileService.NotifyFileRemoved (RootRepository.FromGitPath (entry.OldPath)); } else { FileService.NotifyFileChanged (RootRepository.FromGitPath (entry.Path)); } } }
private Stash getAllTabs(string league, Stash stash) { List<Tab> hiddenTabs = new List<Tab>(); for (int i = 1; i < stash.NumberOfTabs; i++) if (!stash.Tabs[i].Hidden) stash.Add(GetStash(i, league, false)); else hiddenTabs.Add(stash.Tabs[i]); if (stash.Tabs[0].Hidden) { stash.Tabs.Remove(stash.Tabs[0]); --stash.NumberOfTabs; } foreach (var tab in hiddenTabs) { stash.Tabs.Remove(tab); --stash.NumberOfTabs; } return stash; }
public static IAsyncOperation ApplyStash (Stash s) { MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor (true, false, false, true); var statusTracker = IdeApp.Workspace.GetFileStatusTracker (); ThreadPool.QueueUserWorkItem (delegate { try { NGit.Api.MergeCommandResult result; using (var gm = new GitMonitor (monitor)) result = s.Apply (gm); ReportStashResult (monitor, result); } catch (Exception ex) { string msg = GettextCatalog.GetString ("Stash operation failed."); monitor.ReportError (msg, ex); } finally { monitor.Dispose (); statusTracker.NotifyChanges (); } }); return monitor.AsyncOperation; }
protected void initializeStash(){ if(playerEnabled){ stash = (Stash) GameObject.FindObjectOfType (typeof (Stash)); stash.setPlayer(this); } }