/// <summary> /// Récupérer une image resource /// </summary> /// <param name="url">Url de l'image</param> /// <returns>Image</returns> public static Image GetImageStageChar(Guid value) { //Pas d'image envoyée if (value == new Guid()) { return(NotFoundPicture); } //Dictionnaire d'image if (_ImagesStageChars == null) { _ImagesStageChars = new Dictionary <Guid, Image>(); } //Création et ajout de l'image si non présente dans le dictionnaire if (!_ImagesStageChars.ContainsKey(value)) { CreateNewImageStageCharacter(value); } //Renvoie de l'image try { return(_ImagesStageChars[value]); } catch (Exception e) { LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_KEY_NOT_FOUND, value)); LogTools.WriteDebug(e.Message); return(NotFoundPicture); } }
/// <summary> /// Récupérer une image background /// </summary> /// <param name="url">Url de l'image</param> /// <returns>Image</returns> public static Image GetImageBackground(VO_BackgroundSerial serial) { //Pas d'image envoyée if (serial == null) { return(NotFoundPicture); } //Dictionnaire d'image if (_ImagesBackgrounds == null) { _ImagesBackgrounds = new Dictionary <string, Image>(); } //Création et ajout de l'image si non présente dans le dictionnaire string serialS = serial.ToString(); if (!_ImagesBackgrounds.ContainsKey(serialS)) { CreateNewImageBackground(serial); } //Renvoie de l'image try { return(_ImagesBackgrounds[serialS]); } catch (Exception e) { LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_KEY_NOT_FOUND, serial.ToString())); LogTools.WriteDebug(e.Message); return(NotFoundPicture); } }
/// <summary> /// Crée une nouvelle image background /// </summary> /// <param name="url">Url de l'image</param> public static void CreateNewImageBackground(VO_BackgroundSerial serial) { //Dictionnaire d'image if (_ImagesBackgrounds == null) { _ImagesBackgrounds = new Dictionary <string, Image>(); } //Ajout de l'image string serialS = serial.ToString(); if (!_ImagesBackgrounds.ContainsKey(serialS)) { try { Image mainBackground = null; if (serial.Padding == 0) { mainBackground = new Bitmap(serial.Size.Width, serial.Size.Height, EditorConstants.PERF_EDITOR_BITSPERPIXEL); Graphics graphic = Graphics.FromImage(mainBackground); graphic.FillRectangle(EditorHelper.Instance.TransparentBrushes[serial.BlockSize], new Rectangle(new Point(0, 0), serial.Size)); graphic.Dispose(); } else { int padding = serial.Padding * 2; mainBackground = new Bitmap(serial.Size.Width + padding, serial.Size.Height + padding, EditorConstants.PERF_EDITOR_BITSPERPIXEL); Graphics graphics = Graphics.FromImage(mainBackground); graphics.FillRectangle(new SolidBrush(Color.Gray), new Rectangle(new Point(0, 0), new Size(serial.Size.Width + padding, serial.Size.Height + padding))); Image temp = new Bitmap(serial.Size.Width, serial.Size.Height, EditorConstants.PERF_EDITOR_BITSPERPIXEL); Graphics graphicBackground = Graphics.FromImage(temp); graphicBackground.FillRectangle(EditorHelper.Instance.TransparentBrushes[serial.BlockSize], new Rectangle(new Point(0, 0), serial.Size)); graphics.DrawImage(temp, new Rectangle(new Point(serial.Padding, serial.Padding), serial.Size)); temp.Dispose(); graphicBackground.Dispose(); graphics.Dispose(); } _ImagesBackgrounds.Add(serialS, mainBackground); LogTools.WriteDebug(string.Format(Logs.MANAGER_IMAGE_CREATED, serial.ToString(), Logs.MANAGER_BACKGROUNDS)); } catch (InsufficientMemoryException ie) { LogTools.WriteInfo(Logs.MANAGER_MEMORY_ERROR); LogTools.WriteDebug(ie.Message); ResetResources(); CreateNewImageBackground(serial); } catch (Exception e) { LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_NOT_FOUND, serial)); LogTools.WriteDebug(e.Message); _ImagesBackgrounds.Add(serialS, NotFoundPicture); } } }
/// <summary> /// Récupérer une image resource /// </summary> /// <param name="url">Url de l'image</param> /// <returns>Image</returns> public static Image GetImageStageDecor(string url) { //Pas d'image envoyée if (string.IsNullOrEmpty(url)) { return(NotFoundPicture); } //Dictionnaire d'image if (_ImagesStageDecors == null) { _ImagesStageDecors = new Dictionary <string, Image>(); } //Création et ajout de l'image si non présente dans le dictionnaire if (!_ImagesStageDecors.ContainsKey(url)) { CreateNewImageStageDecor(url); } //Renvoie de l'image try { return(_ImagesStageDecors[url]); } catch (Exception e) { LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_KEY_NOT_FOUND, url)); LogTools.WriteDebug(e.Message); return(NotFoundPicture); } }
static void PingServer_OnAfterSet() { try { DateTime dt = DateTime.Today; bool result = false; if (dt.Year == Config.AppSetting.lastlogclear.year) { if (dt.Month != Config.AppSetting.lastlogclear.month) { result = true; } } else { result = true; } if (result) { NetTalk.BLL.Log api = new NetTalk.BLL.Log(); api.ClearLastMonthLog(); Config.AppSetting.lastlogclear.month = Convert.ToByte(dt.Month); Config.AppSetting.lastlogclear.year = Convert.ToUInt16(dt.Year); Config.SaveXML(); } } catch (Exception ex) { LogTools.Write(null, ex, "PingServer_OnAfterSet"); } }
/// <summary> /// Si erreur de mémoire, on reset la mémoire du ResourcesManager /// </summary> public static void ResetResources() { LogTools.WriteDebug(Logs.MANAGER_RESETING_MANAGER); //_ImagesResources if (_ImagesResources != null) { foreach (Image image in _ImagesResources.Values) { image.Dispose(); } } _ImagesResources = new Dictionary <string, Image>(); //_ImagesBackgrounds if (_ImagesBackgrounds != null) { foreach (Image image in _ImagesBackgrounds.Values) { image.Dispose(); } } _ImagesBackgrounds = new Dictionary <string, Image>(); ResetStageResources(); }
/// <summary> /// Récupérer une image resource /// </summary> /// <param name="url">Url de l'image</param> /// <returns>Image</returns> public static Texture2D GetPermanentMenu(int width, int height, ViewerEnums.MenuType type) { //Dictionnaire d'image if (_PermanentResources == null) { _PermanentResources = new Dictionary <string, Texture2D>(); } string serial = "MENU|" + VO_GUI.RefResource + ";" + width + ";" + height + ";" + type.ToString(); //Création et ajout de l'image si non présente dans le dictionnaire if (!_PermanentResources.ContainsKey(serial)) { CreateMenu(width, height, type); } //Renvoie de l'image try { return(_PermanentResources[serial]); } catch (Exception e) { LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_KEY_NOT_FOUND, serial)); LogTools.WriteDebug(e.Message); return(null); } }
/// <summary> /// Récupérer une image resource /// </summary> /// <param name="url">Url de l'image</param> /// <returns>Image</returns> public Texture2D GetScreenImage(string url) { //Pas d'image envoyée if (string.IsNullOrEmpty(url)) { return(null); } //Dictionnaire d'image if (_ScreenResources == null) { _ScreenResources = new Dictionary <string, Texture2D>(); } //Création et ajout de l'image si non présente dans le dictionnaire if (!_ScreenResources.ContainsKey(url)) { CreateNewScreenImage(url); } //Renvoie de l'image try { return(_ScreenResources[url]); } catch (Exception e) { LogTools.WriteInfo(string.Format(Logs.MANAGER_IMAGE_KEY_NOT_FOUND, url)); LogTools.WriteDebug(e.Message); return(null); } }
private void Initialize() { ErrorMessage = string.Empty; // Set up the loggers const string logFileNameBase = @"Logs\MyEMSLFileCacher"; LogTools.CreateFileLogger(logFileNameBase, LogLevel); var hostName = System.Net.Dns.GetHostName(); var dbLoggerConnectionString = DbToolsFactory.AddApplicationNameToConnectionString(mLogDBConnectionString, "MyEMSLMTSFileCacher"); LogTools.CreateDbLogger(dbLoggerConnectionString, "MyEMSLFileCacher: " + hostName); // Make initial log entry var msg = "=== Started MyEMSL MTS File Cacher v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version + " === "; LogTools.LogMessage(msg); var connectionStringToUse = DbToolsFactory.AddApplicationNameToConnectionString(MTSConnectionString, "MyEMSLMTSFileCacher"); mDbTools = DbToolsFactory.GetDBTools(connectionStringToUse); RegisterEvents(mDbTools); }
private void SetTaskComplete(int taskID, int completionCode, string completionMessage, IEnumerable <int> cachedFileIDs) { try { //Setup for execution of the stored procedure var cmd = mDbTools.CreateCommand(SP_NAME_SET_TASK_COMPLETE, CommandType.StoredProcedure); mDbTools.AddParameter(cmd, "@Return", SqlType.Int, ParameterDirection.ReturnValue); mDbTools.AddParameter(cmd, "@processorName", SqlType.VarChar, 128, ProcessorName); mDbTools.AddParameter(cmd, "@taskID", SqlType.Int).Value = taskID; mDbTools.AddParameter(cmd, "@CompletionCode", SqlType.Int).Value = completionCode; mDbTools.AddParameter(cmd, "@CompletionMessage", SqlType.VarChar, 255, completionMessage); mDbTools.AddParameter(cmd, "@CachedFileIDs", SqlType.VarChar, -1, string.Join(",", cachedFileIDs)); var messageParam = mDbTools.AddParameter(cmd, "@message", SqlType.VarChar, 512, ParameterDirection.Output); ReportMessage("Calling " + cmd.CommandText + " on " + MTSServer, BaseLogger.LogLevels.DEBUG); //Execute the SP (retry the call up to 4 times) mDbTools.TimeoutSeconds = 20; var resCode = mDbTools.ExecuteSP(cmd, 4); if (resCode != 0) { LogTools.LogError("Error " + resCode + " setting cache task complete: " + (string)messageParam.Value); } } catch (Exception ex) { ReportError("Error in SetTaskComplete for server " + MTSServer + ": " + ex.Message, true, ex); } }
public void Initialize() { LogTools logTools = new LogTools(); foreach (var component in _componets) { switch (component) { case IConsoleSystemEngineSettings engineSettings: RegisterConsoleSystemEngineSettings(engineSettings); break; case IAPIProviderSettings apiProviderSettings: RegisterApiProviderSettings(apiProviderSettings); break; case IAPIProvider apiProvider: RegisterApiProvider(apiProvider); break; default: logTools.WriteLogToFile <Info>(string.Format(Resources.UnknownComponentFatal, component.GetType().Name)); break; } } }
public void Log_JSON() { UT_INIT(); Log.SetDomain("JSON", Scope.Method); String jsonString = "{\"glossary\": " + "{\"title\": \"example glossary\",\"GlossDiv\":" + "{\"title\": \"S\",\"GlossList\": " + "{\"GlossEntry\":" + "{\"ID\": \"SGML\",\"SortAs\": \"SGML\",\"GlossTerm\": \"Standard Generalized Markup Language\"," + "\"Acronym\": \"SGML\",\"Abbrev\": \"ISO 8879:1986\",\"GlossDef\":" + "{\"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\"GlossSeeAlso\": [\"GML\", \"XML\"]" + "}," + "\"GlossSee\": \"markup\"" + "}" + "}" + "}" + "}" + "}"; //Log.Info(jsonString); IDictionary <string, object> dict = DynamicJSONDeserializer.FromString(jsonString); LogTools.Instance(Verbosity.Info, dict, 100, "Logging a JSON based object: "); }
private async Task <bool> updateLastSeenTime(string markId) { bool updateWasSuccessful = false; using (DbContextTransaction transaction = context.Database.BeginTransaction()) { try { UserMarkExperience userMarkExperience = await context.UserMarkExperiences.FindAsync(LoggedUserId, markId); validateOwner(userMarkExperience); userMarkExperience.LastSeen = DateTime.Now; await context.SaveChangesAsync(); transaction.Commit(); updateWasSuccessful = true; } catch (Exception ex) { LogTools.LogException(ex); transaction.Rollback(); throw ex; } } return(updateWasSuccessful); }
Main(string[] args) { XmlTools xtDoc = new XmlTools(); LogTools log = new LogTools(); xtDoc.Load("tdResult.xml"); // login call status // ================= log.Log("result = " + xtDoc.Lookup("//amtd/result")); log.Log("user-id = " + xtDoc.Lookup("//amtd/xml-log-in/user-id")); log.Log("xchange = " + xtDoc.Lookup("//amtd/xml-log-in/authorizations/options360")); log.Log("acct-id = " + xtDoc.Lookup("//amtd/xml-log-in/accounts/account/account-id")); log.Log("acct-id = " + xtDoc.Lookup("//amtd/xml-log-in/accounts/account/account-id")); log.Log("xchstat = " + xtDoc.Lookup("//amtd/xml-log-in/exchange-status")); xtDoc.ListResearch(); Console.ReadKey(); return; } // end of Main()
/// <summary> /// Show a status message at the console and optionally include in the log file /// </summary> /// <param name="statusMessage">Status message</param> /// <param name="isError">True if this is an error</param> /// <param name="writeToLog">True to write to the log file; false to only display at console</param> public static void LogMessage(string statusMessage, bool isError = false, bool writeToLog = true) { if (writeToLog) { if (isError) { LogTools.LogError(statusMessage); } else { LogTools.LogMessage(statusMessage); } } else { if (isError) { ConsoleMsgUtils.ShowErrorCustom(statusMessage, false); } else { Console.WriteLine(statusMessage); } } }
public async Task Invoke(HttpContext context) { var originalBody = context.Response.Body; try { //await FixUserName(context); using (var memStream = new MemoryStream()) { context.Response.Body = memStream; var webApiLogMessage = LogTools.CreateLogMessage <WebApiLogMessage>(context); await _next(context); await FixException(context); await FinalizeResponse(memStream, originalBody, context, _logger, webApiLogMessage); } } catch (Exception exception) { _logger.LogError(exception.ToString()); } finally { context.Response.Body = originalBody; } }
public static void StartBuildBundle() { LogTools.Info("---------------------------------start-------------------------------------"); LogTools.Info("设置打包平台"); //设置打包平台 if (ProjectConfig.Instance.m_AssetBundleBuildTarget != EnumTools.GetException <BuildTarget>()) { buildTarget = ProjectConfig.Instance.m_AssetBundleBuildTarget; } LogTools.Info("清理资源:"); AssetsSetting.ClearResourcesDir(); //清空Resources目录 LogTools.Info("拷贝并导入资源"); srcPath = AssetsSetting.ImportAsset(srcPath); //将srcPath上的文件复制到Resources目录下,并且导入资源 LogTools.Info("设置资源"); AssetsSetting.ImporterSet(configJson, srcPath); //对资源进行各种参数修改和设置再次导入 LogTools.Info("清空AssetBundlesName"); ClearAssetBundlesName(); //清空AssetBundlesName LogTools.Info("设置AssetBundlesName"); PerpareToBuild(srcPath); //设置打包资源的assetBundleName LogTools.Info("开始打包"); StartToBuild(); //开始打包 LogTools.Info("导出资源"); string assetBundlePath = GlobalConstants.TempPath + "/" + FileTools.GetFileName(srcPath).ToLower() + ".ab"; AssetsSetting.MoveOutAsset(assetBundlePath, outPath); //将打包好的文件移动到输出目录 LogTools.Info("清空资源文件"); AssetsSetting.ClearResourcesDir(); //清空Resources目录 LogTools.Info("结束"); LogTools.Info("---------------------------------end-------------------------------------"); }
public void Initialize() { LogTools logTools = new LogTools(); foreach (var component in _componets) { switch (component) { case IWindowsServiceEngineSettings engineSettings: RegisterWindowsServiceEngineSettings(engineSettings); break; case IDataAccessProxySettings dataAccessProxySettings: RegisterDataAccessProxySettings(dataAccessProxySettings); break; case IDataAccessProxy dataAccessProxy: RegisterDataAccessProxy(dataAccessProxy); break; default: logTools.WriteLogToFile <Info>(string.Format(Resources.UnknownComponentFatal, component.GetType().Name)); break; } } }
//private async Task FixUserName(HttpContext context) //{ // if (!context.Items.ContainsKey(FilterConstants.UserName) && // context.User?.Identity != null && // !string.IsNullOrEmpty(context.User.Identity.Name)) // { // context.Items.Add(FilterConstants.UserName, context.User.Identity.Name); // } // //else // //{ // // var authResult = await context.AuthenticateAsync("Bearer"); // // if (!context.Items.ContainsKey(FilterConstants.UserName) && !string.IsNullOrEmpty(authResult?.Principal?.Identity?.Name)) // // context.Items.Add(FilterConstants.UserName, authResult?.Principal?.Identity?.Name); // //} //} /// <summary> /// Финализация обработки запроса /// </summary> private async Task FinalizeResponse(MemoryStream memStream, Stream originalBody, HttpContext context, ILogger logger, WebApiLogMessage webApiLogMessage) { memStream.Position = 0; var responceBodyStream = new StreamReader(memStream); using (responceBodyStream) { string responseBody = responceBodyStream.ReadToEnd(); memStream.Position = 0; await memStream.CopyToAsync(originalBody); if (context.Items.ContainsKey("excpetionReceived")) { var webApiExceptionLogMessage = LogTools.CreateLogMessage <WebApiExceptionLogMessage>(context); webApiExceptionLogMessage.ExceptionReceived = context.Items["excpetionReceived"] as Exception; LogTools.WriteLogMessage(context, webApiExceptionLogMessage, logger, responseBody); } else { LogTools.WriteLogMessage(context, webApiLogMessage, logger, responseBody); } } }
private static void PrintExcepitonLog(Exception e) { if (e.GetType() == typeof(InvalidOperationException)) { LogTools.PrintError("打包失败,文件已损坏"); } else { LogTools.PrintError(e.GetType().Name + e.Message); } LogTools.Error(GetDetailsInfo(), e); //将失败的文件拷贝至指定目录 try { String exceptionFilePath = GlobalConstants.AbsoluteResourcesPath + "/" + FileTools.GetFileName(srcPath); if (FileTools.FileExists(exceptionFilePath)) { LogTools.Info("发生异常的文件存在,文件路径为:" + exceptionFilePath); if (!FileTools.DirectoryExists(GlobalConstants.ExceptionFBXFolder)) { FileTools.CreateDirectory(GlobalConstants.ExceptionFBXFolder); } String destFilePath = GlobalConstants.ExceptionFBXFolder + "/" + FileTools.GetFileName(exceptionFilePath) + "(" + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss") + ")"; FileTools.CopyFile(exceptionFilePath, destFilePath); } else { LogTools.Info("发生异常的文件不存在,文件路径为"); } } catch (Exception ee) { LogTools.Error(GetDetailsInfo(), ee); } }
//取得目前該金鑰權限下的所有Bucket列表 public static List <string> GetBucketList() { var buckets = new List <string>(); var credentials = new StoredProfileAWSCredentials("developer"); //若config檔裡有指定profileName屬性,則此段可省略,下面改寫為 var client = new AmazonS3Client() using (var client = new AmazonS3Client(credentials)) { try { ListBucketsResponse response = client.ListBuckets(); foreach (S3Bucket bucket in response.Buckets) { buckets.Add(bucket.BucketName); } } catch (AmazonS3Exception amazonS3Exception) { if (amazonS3Exception.ErrorCode != null && (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity"))) { LogTools.Error("Please check the provided AWS Credentials. If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3"); } else { LogTools.Error(string.Format("An Error, number {0}, occurred when listing buckets with the message '{1}", amazonS3Exception.ErrorCode, amazonS3Exception.Message)); } } } return(buckets); }
public static void Initialize(int NbChannel) { if (ViewerSettings.ActivateSound) { RESULT result; result = Factory.System_Create(ref system); if (EngineError != null) { EngineError(result); } uint version = 0; result = system.getVersion(ref version); if (EngineError != null) { EngineError(result); } if (version < VERSION.number) { LogTools.WriteError("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + VERSION.number.ToString("X") + "."); throw new ApplicationException("Error! You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + VERSION.number.ToString("X") + "."); } result = system.init(NbChannel, INITFLAGS.NORMAL, (IntPtr)null); if (EngineError != null) { EngineError(result); } channelMusicCallback = new CHANNEL_CALLBACK(OnEndMusic); channelSoundCallback = new CHANNEL_CALLBACK(OnEndSound); channelVoiceCallback = new CHANNEL_CALLBACK(OnEndVoice); } }
public static void MainMethod() { try { commandLineArgs = Environment.GetCommandLineArgs(); if (commandLineArgs.Length < 11) { throw new System.Exception("srcPath不能为空"); } if (commandLineArgs.Length < 12) { throw new System.Exception("outpath不能为空"); } srcPath = commandLineArgs[10]; outPath = commandLineArgs[11]; //获取扩展设置 string configInfoJson = ""; if (commandLineArgs.Length > 12) { configInfoJson = commandLineArgs[12]; } configJson = JsonTools.ResolutionJsonFromString <ConfigJson>(configInfoJson); StartBuildSDF(); LogTools.Info("打包结束,未发现异常.srcPath:" + commandLineArgs [10] + " outPath:" + commandLineArgs[11]); } catch (System.Exception e) { PrintExcepitonLog(e); } }
public static void Stop() { try { Services.CacheService.ContinuePing = false; ThreadIsRun = false; ThreadEvent.Set(); int count = Users.Online.Count; for (int i = 0; i < count; i++) { if (Users.Online[i].IsConnected) { try { Users.Online[i].Stop(); } catch { } } } Users.Online.Clear(); } catch (Exception ex) { LogTools.Write(null, ex, "Main.Stop"); } }
// GET tables/User/48D68C86-6EA6-4C25-AA33-223FC9A27959 public SingleResult <User> GetUser(string id) { LogTools.Log($"Entered UserController.GetUser"); validateOwner(id); return(Lookup(id)); }
/// <summary> /// Prépare le message de log /// </summary> /// <param name="infos"></param> /// <param name="values"></param> private void EnteringMethodLogMessage(MethodInfo infos, params string[] values) { if (LogTools.IsDebugModeActive()) { ParameterInfo[] parameters = infos.GetParameters(); string paramsString = string.Empty; int i = 0; if (values != null) { foreach (ParameterInfo parameter in parameters) { if (values.Length > i) { paramsString += parameter.ParameterType.Name + " " + parameter.Name + " = '" + values[i] + "', "; i++; } } } if (paramsString.Length > 2) { paramsString = paramsString.Substring(0, paramsString.Length - 2); } LogTools.WriteDebug(string.Format(Logs.SERVICE_DEBUG_ENTERING_METHOD, infos.Name, paramsString)); } }
private void SendCallback(IAsyncResult ar) { try { int bytesSent = ConnectionSocket.EndSend(ar); } catch (ObjectDisposedException objex) { XML.Rosters.ChangeStatus(this.Username, this.UserStatusText, this.UserStatus, false); Users.Online.Remove(this); XML.Rosters.SendStatus(this.Username); LogTools.Write(this.SessionId, objex, "Connection.SendCallback"); } catch (SocketException sockex) { if (sockex.ErrorCode == 10054) { XML.Rosters.ChangeStatus(this.Username, this.UserStatusText, this.UserStatus, false); Users.Online.Remove(this); XML.Rosters.SendStatus(this.Username); } else { LogTools.Write(this.SessionId, sockex, "Connection.SendCallback"); } } catch (Exception ex) { LogTools.Write(this.SessionId, ex, "Connection.SendCallback"); } }
public static void Messages(string sid, string username, Message msg) { string TextBody = string.Empty; try { if (!string.IsNullOrEmpty(msg.Body)) { TextBody = msg.Body; } if (msg.To != null) { if (!string.IsNullOrEmpty(msg.To.User)) { if (TextBody == "info") { XML.Messages.SendInfo(username, msg.To.User); } else { XML.Messages.SendMessage(username, msg); } } } } catch (Exception ex) { LogTools.Write(sid, ex, "Proccess.Messages"); } }
public override void Tick(Mat viewportMat, RECT viewportRect) { //viewportCapture.Save("capture.png", System.Drawing.Imaging.ImageFormat.Png); var s = $"Size: {viewportMat.Width},{viewportMat.Height} Rect: {viewportRect.x1},{viewportRect.y1},{viewportRect.x2},{viewportRect.y2}"; LogTools.GetInstance().Info("ShowViewportSizeScriptTick", s); }
private void AddFileInfo(PacketHeader header, Connection connection, SendInfo info) { try { byte[] data = null; ReceivedFile file = null; lock (syncRoot) { long sequenceNumber = info.PacketSequenceNumber; if (incomingDataCache.ContainsKey(connection.ConnectionInfo) && incomingDataCache[connection.ConnectionInfo].ContainsKey(sequenceNumber)) { data = incomingDataCache[connection.ConnectionInfo][sequenceNumber]; incomingDataCache[connection.ConnectionInfo].Remove(sequenceNumber); if (!receivedFilesDict.ContainsKey(connection.ConnectionInfo)) { receivedFilesDict.Add(connection.ConnectionInfo, new Dictionary <string, ReceivedFile>()); } if (!receivedFilesDict[connection.ConnectionInfo].ContainsKey(info.Filename)) { receivedFilesDict[connection.ConnectionInfo].Add(info.Filename, new ReceivedFile(info.Filename, connection.ConnectionInfo, info.TotalBytes)); AddNewReceivedItem(receivedFilesDict[connection.ConnectionInfo][info.Filename]); } file = receivedFilesDict[connection.ConnectionInfo][info.Filename]; Console.WriteLine("Info was received " + info.Filename); } else { if (!incomingDataInfoCache.ContainsKey(connection.ConnectionInfo)) { incomingDataInfoCache.Add(connection.ConnectionInfo, new Dictionary <long, SendInfo>()); } incomingDataInfoCache[connection.ConnectionInfo].Add(sequenceNumber, info); } } if (data != null && file != null && !file.IsCompleted) { file.AddData(info.BytesStart, 0, data.Length, data); file = null; data = null; GC.Collect(); } else if (data == null ^ file == null) { throw new Exception("Either both are null or both are set. Data is " + (data == null ? "null." : "set.") + " File is " + (file == null ? "null." : "set.") + " File is " + (file.IsCompleted ? "completed." : "not completed.")); } } catch (Exception ex) { LogTools.LogException(ex, "IncomingPartialFileDataInfo"); } }