public override NodeResult Run() { if (profile.Value == null) { Log.Error("You must specify a profile to sync"); return(NodeResult.Fail); } if (!profile.Value.Exists) { Log.Error("The specified profile could not be found"); return(NodeResult.Fail); } try { Profile p = null; try { Environment.CurrentDirectory = Path.GetDirectoryName(profile.Value.FullName); switch (profile.Value.Extension) { case ".xsync": p = XProfile.Load(XDocument.Load(profile.Value.FullName)); break; } } catch (Exception e) { Log.Error("Error while loading the specified profile: " + e.Message); } // Compute differences and actions Diff[] differences = p.GetDifferences().ToArray(); global::SmartSync.Common.Action[] actions = differences.Select(d => d.GetAction(p.SyncType)).ToArray(); if (actions.Length > 0) { // Process actions for (int i = 0; i < actions.Length; i++) { Log.Info("{1} % - {0} ...", actions[i], i * 100 / actions.Length); actions[i].Process(); } Log.Info("Flushing data to storage..."); } p.Dispose(); Log.Info("Everything is in sync. {0} actions processed.", actions.Length); return(NodeResult.Success); } catch (Exception e) { Log.Error("Error while trying to sync specified profile: " + e.Message); return(NodeResult.Fail); } }
public static void Fill(RecommendationsRes profiles) { var db = new TinderContext(); foreach (var profile in profiles.results) { if (!(db.XProfiles.Any(key => key.id == profile._id))) { XProfile profile_tmp = new XProfile { id = profile._id, name = profile.name, bio = profile.bio, distance = profile.distance_mi, photo_url = profile.photos[0].url }; db.XProfiles.Add(profile_tmp); } } db.SaveChanges(); }
private async void BottomTabBarContainer_Tapped(object sender, BottomTabBar.TabItem e) { if (e.Id == 1) { stack.IsVisible = true; GloboList.IsVisible = false; GloboProfile.IsVisible = false; GloboSearch.IsVisible = false; } else if (e.Id == 2) { stack.IsVisible = false; GloboList.IsVisible = true; GloboProfile.IsVisible = false; GloboSearch.IsVisible = false; // await Navigation.PushPopupAsync(new MyPreferencePopupPage()); } else if (e.Id == 3) { stack.IsVisible = false; GloboList.IsVisible = false; GloboProfile.IsVisible = false; GloboSearch.IsVisible = true; } else if (e.Id == 4) { stack.IsVisible = false; GloboList.IsVisible = false; GloboProfile.IsVisible = true; GloboSearch.IsVisible = false; XProfile.TranslationY = 600; await Task.Delay(2000); XProfile.IsVisible = true; await XProfile.TranslateTo(0, 0, 500, Easing.SinOut); } }
public static void Main(string[] args) { Options = args.Where(a => a.StartsWith("/")) .Select(a => a.TrimStart('/')) .Select(a => new { Parameter = a.Trim(), Separator = a.Trim().IndexOf(':') }) .ToDictionary(a => a.Separator == -1 ? a.Parameter : a.Parameter.Substring(0, a.Separator).ToLower(), a => a.Separator == -1 ? null : a.Parameter.Substring(a.Separator + 1)); Parameters = args.Where(a => !a.StartsWith("/")) .ToList(); // Break if asked if (Options.ContainsKey("debug")) { if (Debugger.IsAttached) { Debugger.Break(); } else { Debugger.Launch(); } } string profilePath = Parameters.FirstOrDefault(); if (profilePath == null) { Log.Error("You must specify a profile to run"); Exit(); } FileInfo profileInfo = new FileInfo(profilePath); if (!profileInfo.Exists) { Log.Error("Could not find the specified profile"); Exit(); } Environment.CurrentDirectory = profileInfo.DirectoryName; Profile profile = null; // Load the profile try { Log.Debug("Loading profile {0} ...", profileInfo.FullName); switch (profileInfo.Extension) { case ".xsync": profile = XProfile.Load(XDocument.Load(profileInfo.FullName)); break; } } catch (Exception e) { Log.Error("Error while loading the specified profile: {0}", e.Message); } if (profile == null) { Log.Error("Could not load the specified profile"); Exit(); } else { Log.Debug("Profile loaded successfully"); Log.Debug(""); } if (Options.ContainsKey("reverse")) { profile = profile.Reverse(); } // Display some profile informations Log.Info("Left : {0}", profile.Left); Log.Info("Right : {0}", profile.Right); Log.Info("Sync : {0}", profile.SyncType); Log.Info("Diff : {0}", profile.DiffType); Log.Info(""); // Compute differences and actions Diff[] differences; Action[] actions; try { Log.Info("Computing storage differences ..."); differences = profile.GetDifferences().ToArray(); Log.Info("Computing actions to perform ..."); actions = differences.Select(d => d.GetAction(profile.SyncType)).Where(a => a != null).Sort().ToArray(); Log.Info(""); } catch (Exception e) { Log.Error("Error while computing differences: {0}", e.Message); Exit(); return; } if (actions.Length > 0) { // Show actions to validate sync if (!Options.ContainsKey("novalidate") && Log.Verbosity <= LogVerbosity.Info) { Log.Info("{0} actions to process ...", actions.Length); for (int i = 0; i < actions.Length; i++) { Log.Info(actions[i].ToString()); } string input = ""; string[] answers = { "o", "y", "oui", "ok", "yes", "yep", "yeah", "n", "no", "non", "nope", "nop", "nah" }; while (!answers.Contains(input.ToLower())) { Log.Info("Do you want to process these actions ? "); input = Console.ReadLine(); } if (input[0] == 'n') { Log.Info("Sync cancelled by user"); Exit(); } } profile.Right.BeginSync(); Log.Info("Processing {0} actions ...", actions.Length); // Process actions for (int i = 0; i < actions.Length; i++) { Log.Info("{1} % - {0} ...", actions[i], i * 100 / actions.Length); try { actions[i].Process(); } catch (Exception e) { Log.Error("Error while processing action {0}. {1}", actions[i], e.Message); Exit(); } } profile.Right.EndSync(); Log.Info("Flushing data to storage ..."); Log.Info(""); } profile.Dispose(); Log.Info("Everything is in sync. {0} actions processed.", actions.Length); Exit(); }
/// <summary> /// Saves the the specified NodeCanvas as a new asset at path, optionally as a working copy and overwriting any existing save at path /// </summary> public static void SaveNodeCanvas(string path, ref NodeCanvas nodeCanvas, bool createWorkingCopy = false, bool safeOverwrite = true) { #if !UNITY_EDITOR throw new System.NotImplementedException(); #else if (string.IsNullOrEmpty(path)) { throw new System.ArgumentNullException("Cannot save NodeCanvas: No path specified!"); } if (nodeCanvas == null) { throw new System.ArgumentNullException("Cannot save NodeCanvas: The specified NodeCanvas that should be saved to path '" + path + "' is null!"); } if (nodeCanvas.GetType() == typeof(NodeCanvas)) { throw new System.ArgumentException("Cannot save NodeCanvas: The NodeCanvas has no explicit type! Please convert it to a valid sub-type of NodeCanvas!"); } if (nodeCanvas.allowSceneSaveOnly) { throw new System.InvalidOperationException("Cannot save NodeCanvas: NodeCanvas is marked to contain scene data and cannot be saved as an asset!"); } nodeCanvas.Validate(); if (nodeCanvas.livesInScene) { Debug.LogWarning("Attempting to save scene canvas '" + nodeCanvas.name + "' to an asset, references to scene object may be broken!" + (!createWorkingCopy? " Forcing creation of working copy!" : "")); createWorkingCopy = true; } if (UnityEditor.AssetDatabase.Contains(nodeCanvas) && UnityEditor.AssetDatabase.GetAssetPath(nodeCanvas) != path) { Debug.LogWarning("Trying to create a duplicate save file for '" + nodeCanvas.name + "'! Forcing creation of working copy!"); nodeCanvas = CreateWorkingCopy(nodeCanvas); } // Prepare and update source path of the canvas path = ResourceManager.PreparePath(path); nodeCanvas.UpdateSource(path); // Preprocess the canvas NodeCanvas processedCanvas = nodeCanvas; processedCanvas.OnBeforeSavingCanvas(); if (createWorkingCopy) { processedCanvas = CreateWorkingCopy(processedCanvas); } // Differenciate canvasSave as the canvas asset and nodeCanvas as the source incase an existing save has been overwritten NodeCanvas canvasSave = processedCanvas; NodeCanvas prevSave; if (safeOverwrite && (prevSave = ResourceManager.LoadResource <NodeCanvas> (path)) != null && prevSave.GetType() == canvasSave.GetType()) { // OVERWRITE: Delete contents of old save Object[] subAssets = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path); for (int i = 0; i < subAssets.Length; i++) { // Delete all subassets except the main canvas to preserve references if (subAssets[i] != prevSave) { Object.DestroyImmediate(subAssets[i], true); } } // Overwrite main canvas OverwriteCanvas(ref prevSave, processedCanvas); canvasSave = prevSave; } else { // Write main canvas UnityEditor.AssetDatabase.DeleteAsset(path); UnityEditor.AssetDatabase.CreateAsset(processedCanvas, path); } // Write editorStates AddSubAssets(processedCanvas.editorStates, canvasSave); // Write nodes + contents foreach (Node node in processedCanvas.nodes) { // Write node and additional scriptable objects AddSubAsset(node, canvasSave); AddSubAssets(node.GetScriptableObjects(), node); // Make sure all node ports are included in the representative connectionPorts list ConnectionPortManager.UpdatePortLists(node); foreach (ConnectionPort port in node.connectionPorts) { AddSubAsset(port, node); } } XProfile.Begin("-"); UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.Refresh(); XProfile.End(true); NodeEditorCallbacks.IssueOnSaveCanvas(canvasSave); #endif }