// Start is called before the first frame update void Awake() { if (instance == null) { instance = this; } }
public static void PostServiceOrders(string path) { Console.Write("Enter the number of the batch you want to post to: "); int batchNum = Convert.ToInt32(Console.ReadLine().Trim()); var loop = new LoopManager <PostedOrder>( path, "FinishedPostedOrders.txt", "ErroredPostedOrders.txt", o => o.OrderID ); loop.EndLoop( Parallel.ForEach( loop.Updates, LoopManager.PARALLEL_OPTS, postedOrder => { try { var responseCode = Postman.PostServiceOrder(postedOrder.OrderID, postedOrder.Tech, batchNum); if (responseCode.IsOK()) { loop.LogUpdate(postedOrder.OrderID, "OK", UpdateType.Finished); } else { loop.LogUpdate(postedOrder.OrderID, responseCode.ToString(), UpdateType.Error); } } catch (Exception e) { loop.LogUpdate(postedOrder.OrderID, e.Message, UpdateType.Error); } } ) ); }
public static void SkipMonths(string path, bool clearErrors = false) { var loop = new LoopManager <Location_CodeOnly>( path, PATH_LOGGING + "SetupSkipMonthsFinished.txt", PATH_LOGGING + "SetupSkipMonthsErrored.txt", l => l.Location.ToString(), clearErrors ); var skipFields = Enumerable.Range(1, 12).Select(m => "Skip" + m.ToString()).ToArray(); loop.EndLoop( Parallel.ForEach( loop.Updates, PARALLEL_OPTS, location => { try { int locID = Postman.GetLocationIDFromCode(location.Location); var setupID = Postman.GetLocationServiceSetup(locID, s => s.ServiceCode == "MONTHLY MOSQ").SetupID.Value.ToString(); PPWebLib.PestPac.EditServiceSetup(setupID, null, skipFields); loop.LogUpdate(location.Location.ToString(), setupID); } catch (Exception e) { loop.LogUpdate(location.Location, e.Message, UpdateType.Error); } } ), false ); }
private static void Main(string[] args) { Initialize(); InitialzieLoops(); LoopManager.StartAll(); LoopManager.WaitAll(5000); }
// Start is called before the first frame update void Awake() { if (instance == null) { instance = this; } else { Debug.LogError($"This is not okie dokie, two {GetType().ToString()} exist"); } }
// Start is called before the first frame update void Start() { if (type == ButtonType.forButton) { manager = GameObject.Find("For Loops").GetComponent <LoopManager>(); } else { whileManager = GameObject.Find("While Loops").GetComponent <WhileLoopManager>(); } controllable = transform.GetChild(1).GetComponent <VRTK_BaseControllable>(); controllable.MaxLimitReached += Controllable_MaxLimitReached; }
void Start() { LoopManager loopManager = LoopManager.main; string loopCounterString = "You escaped the wicked timeloop in {0} loops."; if (loopManager == null) { loopCounterString = loopCounterString.Format("∞"); loopCounterText.text = loopCounterString; } else { loopCounterString = loopCounterString.Format(loopManager.LoopCount.ToString()); loopCounterText.text = loopCounterString; } }
public IContext StartLoop(IContext context) { if (!context.Flags.Loop || context.CancellationTokenSource.IsCancellationRequested) { return(context); } context.ResolvedCollectionMethods = context.ResolvedCollectionMethods.GetLoopCollectionMethods(); context.Logger.LogInformation("Creating loop manager with methods {Methods}", context.ResolvedCollectionMethods); var manager = new LoopManager(context); context.Logger.LogInformation("Starting looping"); context.CollectionTask = manager.StartLooping(); return(context); }
public ProfileEditorViewModel(ProfileEditorModel profileEditorModel, DeviceManager deviceManager, LoopManager loopManager, ModuleModel moduleModel, MetroDialogService dialogService) { _deviceManager = deviceManager; _loopManager = loopManager; _moduleModel = moduleModel; _dialogService = dialogService; ProfileNames = new ObservableCollection <string>(); Layers = new ObservableCollection <LayerModel>(); ProfileEditorModel = profileEditorModel; ShowAll = true; PropertyChanged += EditorStateHandler; _deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged; _moduleModel.ProfileChanged += ModuleModelOnProfileChanged; LoadProfiles(); }
void Awake() { this.transform.parent = null; GameObject[] objs = GameObject.FindGameObjectsWithTag("LoopManager"); if (objs.Length > 1) { Destroy(this.gameObject); return; } main = this; DontDestroyOnLoad(this.gameObject); if (Configs.main.PlayerInventory != null) { Configs.main.PlayerInventory.Init(); } }
public ProfileEditorViewModel(ProfileEditorModel profileEditorModel, DeviceManager deviceManager, LoopManager loopManager, LuaManager luaManager, ModuleModel moduleModel, MetroDialogService dialogService) { _deviceManager = deviceManager; _loopManager = loopManager; _moduleModel = moduleModel; _dialogService = dialogService; _copyKeybind = new KeybindModel("copy", new HotKey(Key.C, ModifierKeys.Control), PressType.Down, LayerToClipboard); _pasteKeybind = new KeybindModel("paste", new HotKey(Key.V, ModifierKeys.Control), PressType.Up, ClipboardToLayer); _placeholderKeyboard = KeyboardPreview = ImageUtilities.BitmapToBitmapImage(Resources.none); ProfileNames = new ObservableCollection <string>(); Layers = new ObservableCollection <LayerModel>(); ProfileEditorModel = profileEditorModel; LuaManager = luaManager; ShowAll = true; PropertyChanged += EditorStateHandler; _deviceManager.OnKeyboardChanged += DeviceManagerOnOnKeyboardChanged; _moduleModel.ProfileChanged += ModuleModelOnProfileChanged; LoadProfiles(); }
// Use this for initialization void Start() { holds = GameObject.FindGameObjectsWithTag("Hold"); loopManager = gameObject.GetComponent <LoopManager>(); loopManager.Setup(soundItems); // If starting directly into music scene, holds will be empty if (DEBUG) { holds = ClimbARHandhold.InstantiateHandholds(prefabHold, GetComponent <Camera>(), new float[] { 1f, 1f, 0.2f, 0.2f, 2f, 2f, 0.2f, 0.2f, 1f, 1f, 0.1f, 0.1f, 0.4f, 0.4f, 0.3f, 0.2f }); holds[0].transform.localPosition = new Vector2(-1, -1); holds[1].transform.localPosition = new Vector2(1, 1); holds[2].transform.localPosition = new Vector2(-1, 1); holds[3].transform.localPosition = new Vector2(1, -1); } // If not debugging and no holds, just return else if (holds.Length <= 0) { return; } // Otherwise we actually have holds, assign it to hold HashSet <int> usedHoldIndexes = new HashSet <int>(); HashSet <int> usedSoundIndexes = new HashSet <int>(); if (holds.Length < soundItems.Length) { Debug.Log("Not enough handholds for the number of sound items"); } for (int i = 0; i < Mathf.Min(holds.Length, soundItems.Length); i++) { GameObject soundHold = holds[i]; if (soundHold == null) { Debug.Log("no valid hold found"); } else { ClimbARHandhold.HoldLineRendererActive(soundHold, true); ClimbingHold holdScript = soundHold.GetComponent <ClimbingHold>(); Destroy(holdScript); SoundHold soundHoldScript = soundHold.AddComponent <SoundHold>(); soundHoldScript.Setup(soundItems[i], i, loopManager); loopManager.RegisterHold(soundHoldScript.holdIndex, i); soundHoldScript.GetComponent <LineRenderer>() .startColor = UnityEngine.Color.cyan; soundHoldScript.GetComponent <LineRenderer>() .endColor = UnityEngine.Color.cyan; GameObject holdText = new GameObject(); HoldText holdTextScript = holdText.AddComponent <HoldText>(); holdTextScript.addText(" " + soundItems[i], holdText, soundHold); } } }
static void Main(string[] args) { Console.Write("Enter the number of the batch you want to post to: "); int batchNum = Convert.ToInt32(Console.ReadLine().Trim()); OpenFileDialog dialog = new OpenFileDialog() { CheckFileExists = true, CheckPathExists = true, DefaultExt = "csv", AddExtension = true, Filter = "CSV UTF-8 (Comma delimited) (*.csv)|*.csv|Text files (*.prn;*.txt;*.csv)|*.prn;*.txt;*.csv|All files (*.*)|*.*", InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads", SupportMultiDottedExtensions = true, Title = "PostServiceOrders - Open File" }; Console.Write("Pick a file: "); if (dialog.ShowDialog() != DialogResult.OK) { return; } Console.WriteLine(dialog.FileName); PostedOrder[] postedOrders = null; try { postedOrders = LoopManager.StartLoop <PostedOrder>( dialog.FileName, "FinishedPostedOrders.txt", "ErroredPostedOrders.txt", o => o.OrderID ); } catch (Exception err) { if (err.Message.StartsWith("The process cannot access the file")) { Console.WriteLine("Please close the Excel file and try again."); } else if (err.Message.StartsWith("No members are mapped")) { Console.WriteLine("Please make sure that the Excel file has 'OrderID' and 'Tech' fields."); } else { Console.WriteLine(err.Message); } Console.Write("Press Enter to exit..."); Console.ReadLine(); return; } LoopManager.EndLoop( Parallel.ForEach( postedOrders, LoopManager.PARALLEL_OPTS, postedOrder => { try { if (Postman.PostServiceOrder(postedOrder.OrderID, postedOrder.Tech, batchNum)) { LoopManager.LogUpdate(postedOrder.OrderID + " - true", UpdateType.Finished); } else { LoopManager.LogUpdate(postedOrder.OrderID + " - false", UpdateType.Error); } } catch { LoopManager.LogUpdate(postedOrder.OrderID + " - ERROR"); } } ) ); }
static void Main(string[] args) { var proc = Process.GetCurrentProcess(); proc.PriorityBoostEnabled = true; proc.PriorityClass = ProcessPriorityClass.AboveNormal; Thread.CurrentThread.Priority = ThreadPriority.Highest; LogManager.AddLog(new Log(LogType.FolderFilesByDate, "BatchPayments") { LogFileEntries = true }); LogManager.Start(ThreadPriority.AboveNormal, false); OpenFileDialog dialog = new OpenFileDialog() { CheckFileExists = true, CheckPathExists = true, DefaultExt = "csv", AddExtension = true, Filter = "CSV UTF-8 (Comma delimited) (*.csv)|*.csv|Text files (*.prn;*.txt;*.csv)|*.prn;*.txt;*.csv|All files (*.*)|*.*", InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads", SupportMultiDottedExtensions = true, Title = "PostServiceOrders - Open File" }; Console.Write("Pick a file: "); if (dialog.ShowDialog() != DialogResult.OK) { return; } Console.WriteLine(dialog.FileName); var loop = new LoopManager <BillToPaymentModel>( dialog.FileName, "FinishedBatchPayments.txt", "ErroredBatchPayments.txt", b => b.LocationCode ); loop.EndLoop( Parallel.ForEach( loop.Updates, new ParallelOptions() { MaxDegreeOfParallelism = 32 }, billto => { CardOnFileListModel[] accounts = null; CardOnFileListModel account = null; PaymentProcessorTransactionModel transaction = null; try { accounts = Postman.GetPaymentAccounts(billto.BillToID); if (accounts.Length == 0) { loop.LogUpdate(billto, billto.LocationCode + ", " + billto.BillToID + " - No payment accounts found", UpdateType.Nonexistant); } else { if (accounts.Count() > 1) { accounts = accounts.Where(a => a.ExpirationDate.Value > Utils.Now).ToArray(); if (accounts.Count() > 1) { accounts = accounts.Where(a => a.AutoBilledServices.Any()).ToArray(); } } account = accounts.Count() == 1 ? accounts[0] : accounts.First(a => a.IsPrimary.Value); transaction = Postman.Charge( account.CardID.Value, billto.Balance.StartsWith("$") ? billto.Balance.Substring(1) : billto.Balance, false ); string loopLogEntry = (transaction.Payment != null ? transaction.Payment.BatchNumber + " - " : "") + (transaction.TransactionResponse.TransactionResult.HasValue ? transaction.TransactionResponse.TransactionResult.Value.ToString() + ": " : "") + transaction.TransactionResponse.Message; string loopLogKey = billto.BillToID; switch (transaction.TransactionResponse.TransactionResult.Value) { case TransactionResponseModel.TransactionResultEnum.Error: loop.LogUpdate(loopLogKey, loopLogEntry, UpdateType.Error); LogManager.Enqueue( "BatchPayments", loopLogKey, new object[] { loopLogKey, transaction.TransactionResponse.Message }, new object[] { billto, account, transaction.TransactionResponse }, true ); break; case TransactionResponseModel.TransactionResultEnum.Approved: loop.LogUpdate(loopLogKey, loopLogEntry, UpdateType.Finished); LogManager.Enqueue( "BatchPayments", EntryType.DEBUG, loopLogKey + " has been charged " + billto.Balance.ToString(), "Batch " + transaction.Payment.BatchNumber.Value.ToString() ); break; } } } catch (Exception e) { loop.LogUpdate(billto, e.Message, UpdateType.Error); LogManager.Enqueue( "BatchPayments", billto.BillToID, true, "Code - " + billto.BillToID, e, true ); } } ) ); }
public static void BatchPayments(string path) { var loop = new LoopManager <BillToPaymentModel>( path, PATH_LOGGING + "FinishedBatchPayments.txt", PATH_LOGGING + "ErroredBatchPayments.txt", b => b.LocationCode ); loop.EndLoop( Parallel.ForEach( loop.Updates, new ParallelOptions() { MaxDegreeOfParallelism = 32 }, billto => { CardOnFileListModel[] accounts = null; CardOnFileListModel account = null; PaymentProcessorTransactionModel transaction = null; try { accounts = Postman.GetPaymentAccounts(billto.BillToID); if (accounts.Length == 0) { loop.LogUpdate(billto, billto.LocationCode + ", " + billto.BillToID + " - No payment accounts found", UpdateType.Nonexistant); } else { if (accounts.Count() > 1) { accounts = accounts.Where(a => a.ExpirationDate.Value > Utils.Now).ToArray(); if (accounts.Count() > 1) { accounts = accounts.Where(a => a.AutoBilledServices.Any()).ToArray(); } } account = accounts.Count() == 1 ? accounts[0] : accounts.First(a => a.IsPrimary.Value); transaction = Postman.Charge( account.CardID.Value, billto.Balance.StartsWith("$") ? billto.Balance.Substring(1) : billto.Balance, false ); string loopLogEntry = (transaction.Payment != null ? transaction.Payment.BatchNumber + " - " : "") + (transaction.TransactionResponse.TransactionResult.HasValue ? transaction.TransactionResponse.TransactionResult.Value.ToString() + ": " : "") + transaction.TransactionResponse.Message; int loopLogKey = billto.BillToID; switch (transaction.TransactionResponse.TransactionResult.Value) { case TransactionResponseModel.TransactionResultEnum.Error: loop.LogUpdate(loopLogKey, loopLogEntry, UpdateType.Error); LogManager.Enqueue( "BatchPayments", loopLogKey.ToString(), new object[] { loopLogKey, transaction.TransactionResponse.Message }, new object[] { billto, account, transaction.TransactionResponse }, true ); break; case TransactionResponseModel.TransactionResultEnum.Approved: loop.LogUpdate(loopLogKey, loopLogEntry, UpdateType.Finished); LogManager.Enqueue( "BatchPayments", EntryType.DEBUG, loopLogKey + " has been charged " + billto.Balance, "Batch " + transaction.Payment.BatchNumber.Value.ToString() ); break; } } } catch (Exception e) { loop.LogUpdate(billto, e.Message, UpdateType.Error); LogManager.Enqueue( "BatchPayments", billto.BillToID.ToString(), true, "Code - " + billto.BillToID, e, true ); } } ), false ); }
public static void TimeRanges(string path) { var loop = new LoopManager <Location_CodeAndOrder>( @"C:\Users\ZACH-GAMING\Downloads\Time Range Updates Oct.18.2018.csv", @"E:\Work Programming\Insight Program Files\PPInternal\Logging\TimerangeChangesFinished.txt", @"E:\Work Programming\Insight Program Files\PPInternal\Logging\TimerangeChangesErrored.txt", t => t.Location ); loop.EndLoop( Parallel.ForEach( loop.Updates, LoopManager.PARALLEL_OPTS, l => { string location = l.Location.ToString(); try { int id = Postman.GetLocationIDFromCode(l.Location); var serviceSetups = Postman.GetLocationServiceSetups(id).Where(s => !String.IsNullOrWhiteSpace(s.TimeRange)); var serviceOrder = Postman.GetServiceOrderByNumber(id, l.Order); foreach (var serviceSetup in serviceSetups) { PPWebLib.PestPac.EditServiceSetup(serviceSetup.SetupID.Value.ToString(), new Dictionary <string, string>() { { "TimeRange", "" } }); } if (serviceOrder == null || !serviceOrder.OrderID.HasValue) { loop.LogUpdate(l.Location, l.Location + " has no matching orders.", UpdateType.Nonexistant); } else { Postman.Patch( EntityType.ServiceOrders, serviceOrder.OrderID.Value.ToString(), new PatchOperation( "replace", "/constraints/latesttime", "07:00 PM" ) ); } loop.LogUpdate(l.Location, null); } catch (Exception e) { loop.LogUpdate( l.Location, l.Location + " met with error: " + e.Message, UpdateType.Error ); } } ), false ); }
public void Setup(string audioPath, int holdIndex, LoopManager loopManager) { this.loopManager = loopManager; this.holdIndex = holdIndex; }
public static void UpdateEmployeeAccess(string path) { List <int> branchIDs = new List <int>(); do { Console.Write("Enter branch name(s): "); var branchesStr = Console.ReadLine().Trim(); string[] branches = branchesStr.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var branch in branches) { if (Postman.TryGetBranch(branch, out int branchID)) { branchIDs.Add(branchID); } else { Console.WriteLine("\"" + branch + "\" is an invalid branch"); } } if (branchIDs.Count > 0) { if (branchIDs.Count < branches.Length) { Console.Write("Would you like to add more branches? (y/n)"); var key = Console.ReadKey(); if (key.KeyChar == 'N' || key.KeyChar == 'n') { break; } } else { break; } } else { Console.WriteLine("Try again, fat-fingers."); } } while (true); string access = null; Console.Write("Enter new access template: "); access = Console.ReadLine().Trim(); var loop = new LoopManager( path, PATH_LOGGING + "FinishedEmployeeAccessUpdates.txt", PATH_LOGGING + "ErroredEmployeeAccessUpdates.txt", s => !s.Contains('.') #if DEBUG , true #endif ); loop.EndLoop( Parallel.ForEach( loop.Updates, PARALLEL_OPTS, username => { try { var employee = Postman.GetEmployee(username); var id = employee.EmployeeID.Value.ToString(); List <int> erroredBranchIDs = new List <int>(); foreach (var branchID in branchIDs) { if (!Postman.UpdateEmployeeAccess(id, branchID, access)) { erroredBranchIDs.Add(branchID); } } if (erroredBranchIDs.Any()) { loop.LogUpdate(username, "Failed branches: " + erroredBranchIDs.ToArrayString(), UpdateType.Error); } else { loop.LogUpdate(username, id); } } catch (Exception e) { loop.LogUpdate(username, e.Message, UpdateType.Error); } } ) ); }