コード例 #1
0
        protected bool HasLink(IIOContainer pinContainer)
        {
            try
            {
                var connected = pinContainer.GetPluginIO().IsConnected;

                foreach (var associated in pinContainer.AssociatedContainers)
                {
                    connected |= associated.GetPluginIO().IsConnected;
                }
                return(connected);
            }
            catch (InvalidComObjectException)
            {
                // [Import]s not yet ready. try another time.
                // its safe to assume that no pins have been created yet.
                FLogger.Log(LogType.Warning, "Not fully initialized [" + this.GetType().Name + "].");
                return(false);
            }
            catch (Exception)
            {
                string nodePath = PluginHost.GetNodePath(false);
                FLogger.Log(LogType.Error, "Failed to protect a " + this.GetType().Name + " node: " + nodePath);
                return(false);
            }
        }
コード例 #2
0
    private void HandleGameEnded()
    {
        if (FLogger.Ready)
        {
            FLogger.LogEvent(
                Firebase.Analytics.FirebaseAnalytics.EventLevelEnd,
                GetLevelName(),
                score.ToString()
                );
        }

        var random = new System.Random();

        if (random.Next(4) == 0)
        {
            PlayAd();
        }

        float timeElapsed = Time.time - startTime;

        this.finished = true;

        if (StateToFlag || StateToFlag || StateToCapital)
        {
            StateText.GetComponent <TextMeshProUGUI>().text = "";
            StateFlag.GetComponent <Image>().enabled        = false;
        }

        GameObject.Find("text").GetComponent <CrazyTextEffect>().SetTimeElapsed((int)timeElapsed);
        GameObject.Find("text").GetComponent <CrazyTextEffect>().SetScore(score);
        GameObject.Find("text").GetComponent <CrazyTextEffect>().play = true;
        BackButton.SetActive(true);
        BackButton.transform.GetChild(0).GetComponent <TextMeshProUGUI>().enabled = true;
        SoundController.PlayFinish();
    }
コード例 #3
0
        private void OnSaveImage(object sender, RoutedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                if (ImagePreview.Source == null)
                {
                    return;
                }
                var saveFileDialog = new SaveFileDialog
                {
                    Title            = "Save Image",
                    FileName         = "Preview.png",
                    InitialDirectory = UserSettings.Default.OutputDirectory,
                    Filter           = "Png Files (*.png)|*.png|All Files (*.*)|*.*"
                };

                if (!(bool)saveFileDialog.ShowDialog())
                {
                    return;
                }
                using var fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create);
                var encoder          = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create((BitmapSource)ImagePreview.Source));
                encoder.Save(fileStream);

                if (!File.Exists(saveFileDialog.FileName))
                {
                    return;
                }
                Log.Information("{FileName} successfully saved", saveFileDialog.FileName.SubstringAfterLast('\\'));
                FLogger.AppendInformation();
                FLogger.AppendText($"Successfully saved '{saveFileDialog.FileName.SubstringAfterLast('\\')}'", Constants.WHITE, true);
            });
コード例 #4
0
        private bool RecompileIfNeeded(CSProject project)
        {
            if (!IsAssemblyUpToDate(project))
            {
                FLogger.Log(LogType.Message, "Assembly of {0} is not up to date. Need to recompile ...", project.Name);

                var isLoaded = project.IsLoaded;
                if (!isLoaded)
                {
                    project.Load();
                }

                project.ProjectCompiledSuccessfully -= project_ProjectCompiled;
                project.Compile();
                project.ProjectCompiledSuccessfully += project_ProjectCompiled;

                if (!isLoaded)
                {
                    project.Unload();
                }

                if (project.CompilerResults.Errors.HasErrors)
                {
                    FLogger.Log(LogType.Error, GetCompileErrorsLog(project, project.CompilerResults));
                    return(false);
                }
            }
            return(true);
        }
コード例 #5
0
ファイル: CrashRepository.cs プロジェクト: wenjie891/UnrealVN
        /// <summary>
        /// Find a user to the database, and add them if they do not exist.
        /// </summary>
        /// <param name="UserName">The user name to find or add.</param>
        /// <param name="UserGroupId">The id of the user group to add the user to.</param>
        /// <returns>The id of the found or added user.</returns>
        /// <remarks>All user interaction is done this way to remove any dependencies on pre-populated tables.</remarks>
        public int FindOrAddUser(string UserName, int UserGroupId = 1)
        {
            int UserNameId = 0;

            try
            {
                IQueryable <int> UserNames = (from UserDetail in Users
                                              where UserDetail.UserName.ToLower() == UserName.ToLower()
                                              select UserDetail.Id);

                // If there is no existing user, add a new one
                if (UserNames.Count() == 0)
                {
                    User NewUser = new User();
                    NewUser.UserName    = UserName;
                    NewUser.UserGroupId = UserGroupId;
                    Users.InsertOnSubmit(NewUser);

                    SubmitChanges();
                    UserNameId = NewUser.Id;
                }
                else
                {
                    UserNameId = UserNames.First();
                }
            }
            catch (Exception Ex)
            {
                FLogger.WriteException("FindOrAddUser: " + Ex.ToString());
            }

            return(UserNameId);
        }
コード例 #6
0
        public async Task ProcessAsync(Sisters.WudiLib.Posts.Message message, HttpApiClient api)
        {
            // TODO 验证用户名是否合法
            var(success, userInfo) = await OsuApi.GetUserInfoAsync(_userName, OsuMixedApi.Mode.Standard);

            if (!success)
            {
                await api.SendMessageAsync(message.Endpoint, "网络错误。");

                return;
            }
            if (userInfo == null)
            {
                await api.SendMessageAsync(message.Endpoint, "没有此用户。");

                return;
            }
            var dbResult = await Database.AddNewBindAsync(message.UserId, userInfo.Id, userInfo.Name, "自己绑定", message.UserId, userInfo.Name);

            if (dbResult.Success)
            {
                await api.SendMessageAsync(message.Endpoint, $"成功绑定为{userInfo.Name}。");
            }
            else if (dbResult.Exception is DbUpdateException && dbResult.Exception.InnerException?.Message.Contains("Duplicate", StringComparison.Ordinal) == true)
            {
                await api.SendMessageAsync(message.Endpoint, "在已绑定的情况下不允许修改,如需修改请联系 bleatingsheep。");
            }
            else
            {
                await api.SendMessageAsync(message.Endpoint, "数据库访问错误。");

                FLogger.LogException(dbResult.Exception);
            }
        }
コード例 #7
0
ファイル: Reflect.cs プロジェクト: kouweizhong/vvvv-Message
        //called when data for any output pin is requested
        public override void Evaluate(int SpreadMax)
        {
            var FieldCount = Getters.Count;

            if (FLearn[0] && FInput.SliceCount > 0 && FInput[0] != null)
            {
                var type = FInput[0].GetType();

                FLogger.Log(LogType.Debug, "Learning Type... " + type.FullName);

                FieldInfo[] fields = type.GetFields();

                FieldCount       = fields.Length;
                FName.SliceCount = FieldCount;

                Getters.Clear();
                var formular = new MessageFormular(type.FullName, "");
                for (var i = 0; i < FieldCount; i++)
                {
                    var name = fields[i].Name;
                    FName[i] = name;

                    var fieldInfo = type.GetField(name);

                    try
                    {
                        formular.Append(new FormularFieldDescriptor(fieldInfo.FieldType, name, 1), true);

                        var getter = fieldInfo.CompileGetter();
                        Getters.Add(name, getter);

                        FLogger.Log(LogType.Debug, "Success: " + fieldInfo.FieldType.Name + " " + name);
                    }
                    catch (Exception)
                    {
                        FLogger.Log(LogType.Debug, "Failed: " + fieldInfo.FieldType.Name + " " + name);
                        //FLogger.Log(ex, LogType.Debug);
                    }
                }
                Formular = formular;
            }

            SpreadMax          = FInput.SliceCount;
            FOutput.SliceCount = SpreadMax;

            for (int i = 0; i < SpreadMax; i++)
            {
                var m = new Message(Formular.Name);
                foreach (var fieldName in Formular.FieldNames)
                {
                    var getter = Getters[fieldName];

                    var bin = BinFactory.New(Formular[fieldName].Type);
                    bin.Add(getter(FInput[i]));
                    m[fieldName] = bin;
                }
                FOutput[i] = m;
            }
        }
コード例 #8
0
ファイル: AdController.cs プロジェクト: uygaruyaniksoy/flags
 private void HandleOnAdLeavingApplication(object sender, EventArgs e)
 {
     Debug.Log("AD_LEAVING_APPLICATION");
     if (FLogger.Ready)
     {
         FLogger.LogEvent("AD_LEAVING_APPLICATION");
     }
 }
コード例 #9
0
ファイル: AdController.cs プロジェクト: uygaruyaniksoy/flags
 private void HandleOnAdOpened(object sender, EventArgs e)
 {
     Debug.Log("AD_OPENED");
     if (FLogger.Ready)
     {
         FLogger.LogEvent("AD_OPENED");
     }
 }
コード例 #10
0
ファイル: AdController.cs プロジェクト: uygaruyaniksoy/flags
 private void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs e)
 {
     Debug.Log("_______________________AD_FAILED_TO_LOAD with message: " + e.Message);
     if (FLogger.Ready)
     {
         FLogger.LogEvent("AD_FAILED_TO_LOAD");
     }
 }
コード例 #11
0
ファイル: AdController.cs プロジェクト: uygaruyaniksoy/flags
 private void HandleOnAdLoaded(object sender, EventArgs e)
 {
     Debug.Log("AD_LOADED");
     if (FLogger.Ready)
     {
         FLogger.LogEvent("AD_LOADED");
     }
 }
コード例 #12
0
 /// <summary> Constructor. </summary>
 /// <param name="InDescription"> Global tag to use for logging.</param>
 public FScopedLogTimer(string InDescription)
 {
     if (Scope.Value == 0)
     {
         FLogger.WriteEvent("".PadLeft(16, '-'));
     }
     Description = InDescription;
     Scope.Value++;
 }
コード例 #13
0
 /// <summary> Destructor, logs delta time from constructor. </summary>
 public void Dispose()
 {
     Scope.Value--;
     // Don't log spam.
     if (Timer.Elapsed.TotalMilliseconds > 1.0)
     {
         FLogger.WritePerf(Description.PadLeft(Description.Length + Scope.Value * 2) + ":" + (Int64)Timer.Elapsed.TotalMilliseconds);
     }
 }
コード例 #14
0
        public async Task RunAsync(HttpApiClient api)
        {
            var result = await Database.GetPlusRecordedUsersAsync();

            if (!result.Success)
            {
                FLogger.LogInBackground("更新 PP+ 数据时访问数据库失败。");
                FLogger.LogException(result.Exception);
                return;
            }

            IEnumerable <int> todo = result.Result;

            Logger.Info($"找到{todo.Count()}个查询过的玩家。");
            int retry = 10;

            do
            {
                const int threads = 10;
                Logger.Debug($"开始查询,线程数为{threads.ToString(CultureInfo.InvariantCulture)}");
                var failed  = new ConcurrentBag <int>();
                var results = new ConcurrentBag <IUserPlus>();

                Parallel.ForEach(todo, new ParallelOptions
                {
                    MaxDegreeOfParallelism = threads,
                }, userId =>
                {
                    try
                    {
                        var user = s_spider.GetUserPlusAsync(userId).ConfigureAwait(false).GetAwaiter().GetResult();
                        if (user != null)
                        {
                            results.Add(user);
                        }
                    }
                    catch (Exception)
                    {
                        failed.Add(userId);
                    }
                });
                Logger.Info($"查询成功{results.Count}条。");
                Logger.Info($"失败{failed.Count}条,首个失败是{failed.FirstOrDefault()}");
                var addResult = await Database.AddPlusHistoryRangeAsync(results);

                if (!addResult.Success)
                {
                    FLogger.LogInBackground("添加新的 PP+ 数据失败。");
                    FLogger.LogException(addResult.Exception);
                }

                todo = failed.ToList();
                await Task.Delay(600_000);

                retry--;
            } while (todo.Any() && retry > 0);
        }
コード例 #15
0
 public override void WriteAll()
 {
     FLogger.Log(LogType.Message, "ChunkWriter: Started writing all files");
     IOMessages.CurrentState = "Started writing all files";
     foreach (Chunk chunk in _chunkManager.ChunkList)
     {
         Write(chunk);
     }
 }
コード例 #16
0
ファイル: AdController.cs プロジェクト: uygaruyaniksoy/flags
 private void HandleOnAdClosed(object sender, EventArgs e)
 {
     Debug.Log("AD_CLOSED");
     if (FLogger.Ready)
     {
         FLogger.LogEvent("AD_CLOSED");
     }
     interstitial.Destroy();
 }
コード例 #17
0
        public override void ReadAll()
        {
            FLogger.Log(LogType.Message, "ChunkReader: Started caching all files");
            IOMessages.CurrentState = "Started caching all files";

            foreach (Chunk chunk in _chunkManager.ChunkList)
            {
                Read(chunk);
            }
        }
コード例 #18
0
 private void OnApplicationQuit()
 {
     if (FLogger.Ready)
     {
         FLogger.LogEvent(
             "APP_CLOSE",
             Firebase.Analytics.FirebaseAnalytics.ParameterLevelName,
             GetLevelName()
             );
     }
 }
コード例 #19
0
 public bool RemoveFromFactory()
 {
     if ((State == SearchPathState.DisablePending) || (IsGarbage))
     {
         FLogger.Log(LogType.Debug, "removing " + Dir + " from " + Factory.Name);
         Factory.RemoveDir(Dir);
         State = SearchPathState.Disabled;
         return(true);
     }
     return(false);
 }
コード例 #20
0
        protected void DeleteArtefacts(string dir)
        {
            // Nothing to do if not existent.
            if (FHDEHost.IsBlackBoxMode || !Directory.Exists(dir))
            {
                return;
            }

            // Dynamic plugins generate a new assembly everytime they are compiled.
            // Cleanup old assemblies.
            var mostRecentFiles = new Dictionary <string, Tuple <string, DateTime> >();

            foreach (var file in Directory.GetFiles(dir, "*.dll"))
            {
                try
                {
                    var match = MsBuildProject.DynamicRegExp.Match(file);
                    if (match.Success)
                    {
                        var fileName = match.Groups[1].Value;

                        var currentFileTupe = new Tuple <string, DateTime>(file, File.GetLastWriteTime(file));
                        if (mostRecentFiles.ContainsKey(fileName))
                        {
                            // We've seen this file before.
                            var mostRecentFileTuple = mostRecentFiles[fileName];

                            if (currentFileTupe.Item2 > mostRecentFileTuple.Item2)
                            {
                                // Current file is newer than most recent -> delete most recent and set current as new most recent.
                                mostRecentFiles[fileName] = currentFileTupe;
                                File.Delete(mostRecentFileTuple.Item1);
                                File.Delete(mostRecentFileTuple.Item1.Replace(".dll", ".pdb"));
                            }
                            else
                            {
                                // Current file is older than most recent -> delete it.
                                File.Delete(currentFileTupe.Item1);
                                File.Delete(currentFileTupe.Item1.Replace(".dll", ".pdb"));
                            }
                        }
                        else
                        {
                            mostRecentFiles.Add(fileName, currentFileTupe);
                        }
                    }
                }
                catch (Exception e)
                {
                    FLogger.Log(e);
                }
            }
        }
コード例 #21
0
        void BuildPattern(Crash CrashInstance)
        {
            List <string> Pattern = new List <string>();

            // Get an array of callstack items
            CallStackContainer CallStack = new CallStackContainer(CrashInstance);

            CallStack.bDisplayFunctionNames = true;

            if (CrashInstance.Pattern == null)
            {
                // Set the module based on the modules in the callstack
                CrashInstance.Module = CallStack.GetModuleName();
                try
                {
                    using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(Id=" + CrashInstance.Id + ")"))
                    {
                        foreach (CallStackEntry Entry in CallStack.CallStackEntries.Take(64))
                        {
                            FunctionCall CurrentFunctionCall = new FunctionCall();

                            if (FunctionCalls.Where(f => f.Call == Entry.FunctionName).Count() > 0)
                            {
                                CurrentFunctionCall = FunctionCalls.Where(f => f.Call == Entry.FunctionName).First();
                            }
                            else
                            {
                                CurrentFunctionCall      = new FunctionCall();
                                CurrentFunctionCall.Call = Entry.FunctionName;
                                FunctionCalls.InsertOnSubmit(CurrentFunctionCall);
                            }

                            //CrashRepository.Context.SubmitChanges();

                            Pattern.Add(CurrentFunctionCall.Id.ToString());
                        }

                        //CrashInstance.Pattern = "+";
                        CrashInstance.Pattern = string.Join("+", Pattern);
                        // We need something like this +1+2+3+5+ for searching for exact pattern like +5+
                        //CrashInstance.Pattern += "+";

                        CrashRepository.Context.SubmitChanges();
                    }
                }
                catch (Exception Ex)
                {
                    FLogger.WriteEvent("Exception in BuildPattern: " + Ex.ToString());
                }
            }
        }
コード例 #22
0
ファイル: CrashRepository.cs プロジェクト: wenjie891/UnrealVN
        /// <summary>
        /// Sets the status for all crashes in a Bugg.
        /// </summary>
        /// <param name="Status">The new status of all crashes.</param>
        /// <param name="BuggId">The id of the Bugg to update the crashes for.</param>
        public void SetBuggStatus(string Status, int BuggId)
        {
            try
            {
                string Query = "UPDATE Crashes SET Status = {0} WHERE Id IN ( SELECT CrashId FROM Buggs_Crashes WHERE BuggId = {1} )";
                Context.ExecuteCommand(Query, Status, BuggId);

                Query = "UPDATE Buggs SET Status = {0} WHERE id = {1}";
                Context.ExecuteCommand(Query, Status, BuggId);
            }
            catch (Exception Ex)
            {
                FLogger.WriteException("SetBuggStatus: " + Ex.ToString());
            }
        }
コード例 #23
0
ファイル: CrashRepository.cs プロジェクト: wenjie891/UnrealVN
        /// <summary>
        /// Sets the fixed in changelist for all crashes in a Bugg.
        /// </summary>
        /// <param name="FixedChangeList">A string representing a revision.</param>
        /// <param name="BuggId">The id of the Bugg to update the crashes for.</param>
        public void SetBuggFixedChangeList(string FixedChangeList, int BuggId)
        {
            try
            {
                string Query = "UPDATE Crashes SET FixedChangeList = {0} WHERE Id IN ( SELECT CrashId FROM Buggs_Crashes WHERE BuggId = {1} )";
                Context.ExecuteCommand(Query, FixedChangeList, BuggId);

                Query = "UPDATE Buggs SET FixedChangeList = {0} WHERE id = {1}";
                Context.ExecuteCommand(Query, FixedChangeList, BuggId);
            }
            catch (Exception Ex)
            {
                FLogger.WriteException("SetBuggFixedChangeList: " + Ex.ToString());
            }
        }
コード例 #24
0
                #pragma warning restore

        protected override SvgDocument ReadDocument(int slice)
        {
            SvgDocument doc = null;

            try
            {
                doc = SvgDocument.Open(FFilenameIn[slice]);
            }
            catch (Exception e)
            {
                FLogger.Log(e);
            }

            return(doc);
        }
コード例 #25
0
        Dictionary <ushort, Tuple <string, QOS> > FUnsubscribeStatus = new Dictionary <ushort, Tuple <string, QOS> >(); //matches unsubscribe commands to packet ids
        #endregion fields

        public override void Dispose()
        {
            try
            {
                foreach (var tup in FSubscriptions)
                {
                    FClient.Unsubscribe(new string[] { tup.Item1 });
                }
            }
            catch (Exception e)
            {
                FLogger.Log(e);
            }
            base.Dispose();
        }
コード例 #26
0
 private static void SaveCheck(string path, string fileName)
 {
     if (File.Exists(path))
     {
         Log.Information("{FileName} successfully saved", fileName);
         FLogger.AppendInformation();
         FLogger.AppendText($"Successfully saved '{fileName}'", Constants.WHITE, true);
     }
     else
     {
         Log.Error("{FileName} could not be saved", fileName);
         FLogger.AppendError();
         FLogger.AppendText($"Could not save '{fileName}'", Constants.WHITE, true);
     }
 }
コード例 #27
0
                #pragma warning restore

        protected override SvgDocument ReadDocument(int slice)
        {
            SvgDocument doc = null;

            try
            {
                var s = new MemoryStream(UTF8Encoding.Default.GetBytes(FXMLIn[slice]));
                doc = SvgDocument.Open(s, null);
            }
            catch (Exception e)
            {
                FLogger.Log(e);
            }

            return(doc);
        }
コード例 #28
0
        private void Reconstruct()
        {
            if (this.scanner.IsScanning())
            {
                string desktop  = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                var    time     = DateTime.Now.ToString("hhmmss", System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat);
                var    fileName = desktop + "\\" + string.Format("model-{0}.{1}", time, PXCM3DScan.FileFormatToString(this.fileFormat));
                FLogger.Log(LogType.Debug, "fileName: " + fileName);

                var sts = this.scanner.Reconstruct(this.fileFormat, fileName);
                if (sts != pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                    FLogger.Log(LogType.Debug, sts.ToString());
                }
            }
        }
コード例 #29
0
ファイル: CrashRepository.cs プロジェクト: wenjie891/UnrealVN
 /// <summary>
 /// Sets the UserName and UserGroupName as derived data for a crash.
 /// </summary>
 /// <param name="CrashInstance">An instance of a crash we wish to augment with additional data.</param>
 public void PopulateUserInfo(Crash CrashInstance)
 {
     using (FAutoScopedLogTimer LogTimer = new FAutoScopedLogTimer(this.GetType().ToString() + "(CrashId=" + CrashInstance.Id + ")"))
     {
         try
         {
             int UserGroupId = CrashInstance.User.UserGroupId;
             var Result      = Context.UserGroups.Where(i => i.Id == UserGroupId).First();
             CrashInstance.UserGroupName = Result.Name;
         }
         catch (Exception Ex)
         {
             FLogger.WriteException("PopulateUserInfo: " + Ex.ToString());
         }
     }
 }
コード例 #30
0
    /// <summary> Constructor. </summary>
    /// <param name="InDescription"> Global tag to use for logging.</param>
    /// <param name="bCreateNewLog">Whether to create a new log file</param>
    public FScopedLogTimer(string InDescription, bool bCreateNewLog = false)
    {
        if (bCreateNewLog)
        {
            Log = new FLogger();
        }

        if (Scope.Value == 0)
        {
            //Callstack = new List<string>();
            Callstack = new ThreadLocal <List <string> >(() => { return(new List <string>()); });
            Callstack.Value.Add("".PadLeft(16, '-'));
        }
        Description = InDescription;
        Scope.Value++;
    }
コード例 #31
0
	/// <summary> Constructor. </summary>
	/// <param name="InDescription"> Global tag to use for logging.</param>
	/// <param name="bCreateNewLog">Whether to create a new log file</param>
	public FScopedLogTimer( string InDescription, bool bCreateNewLog = false )
	{
		if( bCreateNewLog )
		{
			Log = new FLogger();
		}

		if( Scope.Value == 0 )
		{
			//Callstack = new List<string>();
			Callstack = new ThreadLocal<List<string>>( () => { return new List<string>(); } );
			Callstack.Value.Add( "".PadLeft( 16, '-' ) );
		}
		Description = InDescription;
		Scope.Value++;
	}