/// <summary> /// 从目录进行加载数据,必须实例化的时候加载,加载失败会导致系统异常,旧的文件丢失 /// </summary> /// <param name="path"></param> private void GroupFileContainerLoadByPath(string path) { m_filePath = path; if (!Directory.Exists(m_filePath)) { Directory.CreateDirectory(m_filePath); } if (File.Exists(m_filePath + FileListResources)) { try { using (StreamReader sr = new StreamReader(m_filePath + FileListResources, Encoding.UTF8)) { m_files = Newtonsoft.Json.Linq.JArray.Parse(sr.ReadToEnd( )).ToObject <List <GroupFileItem> >( ); } } catch (Exception ex) { LogNet?.WriteException("GroupFileContainer", "Load files txt failed,", ex); } } if (m_files == null) { m_files = new List <GroupFileItem>( ); } coordinatorCacheJsonArray = new HslAsyncCoordinator(CacheJsonArrayContent); CacheJsonArrayContent( ); }
/// <summary> /// 实例化一个流水号生成的对象 /// </summary> /// <param name="textHead">流水号的头文本</param> /// <param name="timeFormate">流水号带的时间信息</param> /// <param name="numberLength">流水号数字的标准长度,不够补0</param> /// <param name="fileSavePath">流水号存储的文本位置</param> public SoftNumericalOrder(string textHead, string timeFormate, int numberLength, string fileSavePath) { TextHead = textHead; TimeFormate = timeFormate; NumberLength = numberLength; FileSavePath = fileSavePath; LoadByFile(); AsyncCoordinator = new HslAsyncCoordinator(() => { if (!string.IsNullOrEmpty(FileSavePath)) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(FileSavePath, false, Encoding.Default)) { sw.Write(CurrentIndex); } } }); }
/// <summary> /// 实例化一个网络服务器类对象 /// </summary> public NetComplexServer( ) { AsyncCoordinator = new HslAsyncCoordinator(new Action(CalculateOnlineClients)); }
/// <summary> /// 实例化一个网络服务器类对象 /// </summary> public NetComplexServer() { LogHeaderText = "NetComplexServer"; AsyncCoordinator = new HslAsyncCoordinator(new Action(CalculateOnlineClients)); }