public static void openlog(string fileName, out CLog log, out List<XmlNode> trash) { XmlDocument doc = new XmlDocument(); doc.Load(fileName); open_xml_to_class(doc, out log, out trash); doc = null; }
public CView(IEnumerable<CTrace> collection, CLog log) { Traces = new List<CTrace>(); foreach (CTrace trace in collection) Traces.Add((CTrace)trace.Clone()); Log = log; }
public static void Savelog(string fileName, CLog log, CView View, List<XmlNode> trash) { XmlDocument doc; save_xml_from_class(out doc, log, View, trash); doc.Save(fileName); doc = null; }
/// <summary> /// Конструктор /// </summary> /// <param name="log">Журнал событий, в котором будет это событие</param> public CEvent(CLog log) { _Log = log; log.Add(this); EventID = _Log.LastID++; _Text_Parameters = new Dictionary<string, string>(); _Int_Parameters = new Dictionary<string, int>(); _Double_Parameters = new Dictionary<string, double>(); _Bool_Parameters = new Dictionary<string, bool>(); }
public static CTrace FilledTrace(ref Random rand, CLog log) { CTrace trace = new CTrace(); int count = rand.Next(5, 15); for (int i = 0; i < count; i++) { trace.Add(GenerateEvent(log, ref rand)); } return trace; }
public static CLog GenerateLog(int count = 100) { CLog log = new CLog(); Random rand = new Random(); for (int i = 0; i < count; i++) { Methods.GenerateEvent(log, ref rand); log[i,-1].Date = Methods.GenerateDateTimeOffset(ref rand); } return log; }
public static CEvent GenerateEvent(CLog log, ref Random rand) { CEvent evt = new CEvent(log); evt.Name = GenerateString(ref rand); evt.Date = GenerateDateTimeOffset(ref rand); int paramsCount = rand.Next(0, 15); for (int i = 0; i < paramsCount; i++) try { evt[GenerateString(ref rand, 7)] = evt.Name; } catch (ArgumentException) { File.AppendAllText(@"C:\Users\Fedor\Документы ВШЭ\Программирование\Курсовая\Log ver 2 Test Results\Error Log.txt", "Попытка присвоить значение другого типа\r\n"); } paramsCount = rand.Next(0, 15); for (int i = 0; i < paramsCount;i++ ) try { evt[GenerateString(ref rand, 10)] = rand.Next(); } catch (ArgumentException) { File.AppendAllText(@"C:\Users\Fedor\Документы ВШЭ\Программирование\Курсовая\Log ver 2 Test Results\Error Log.txt", "Попытка присвоить значение другого типа\r\n"); } paramsCount = rand.Next(0, 15); for (int i = 0; i < paramsCount;i++ ) try { evt[GenerateString(ref rand)] = rand.NextDouble() + rand.Next(); } catch (ArgumentException) { File.AppendAllText(@"C:\Users\Fedor\Документы ВШЭ\Программирование\Курсовая\Log ver 2 Test Results\Error Log.txt", "Попытка присвоить значение другого типа\r\n"); } return evt; }
private void Context_BeginRequest(object sender, EventArgs e) { Response = HttpContext.Current.Response; Request = HttpContext.Current.Request; if (Request.Url.AbsolutePath.EndsWith(NotifyPageName)) { //notify url try { handleNotify(); } catch (Exception ex) { using (CLog log = new CLog("alipay handleNotify error ")) { log.Log(ex.ToString()); } } Response.End(); } else if (Request.Url.AbsolutePath.EndsWith(ReturnPageName)) { try { handleReturn(); } catch (Exception ex) { using (CLog log = new CLog("alipay handleReturn error ")) { log.Log(ex.ToString()); } } Response.End(); } }
/// <summary> /// 程序融合切换动作 /// </summary> /// <param name="targetState">目标动作</param> /// <param name="duration">融合时间</param> /// <param name="reset">如果当前动作是目标动作,是否重新播放</param> public void ForcePlayAnim(E_AnimatorState targetState, float duration = 0.0f, bool reset = false) { #if ASVO_DEBUG var attri = Entity.GetComponent <CAttributeCom>(); if (attri != null) { CLog.Log(SysLogType.Battle, "【动作ForcePlayAnim】UID = {0} 转到{1}动作", attri.ID, targetState); } #endif if (m_currentState.IsName(m_stateDict[targetState])) { CLog.Log(SysLogType.Battle, "已经在播放此动作,reset={0}", reset); if (reset) { m_animator.Play(m_stateDict[targetState], 0, 0); } } else { if (m_animator.HasState(0, Animator.StringToHash(m_stateDict[targetState]))) { if (duration == 0)//无融合时间,直切 { m_animator.Play(m_stateDict[targetState], 0, 0); } else { m_animator.CrossFade(m_stateDict[targetState], duration); } } else { CLog.Error(SysLogType.Animation, "{0}没有此动作", m_animator.name); } } }
/// <summary> /// 扫描事件 /// </summary> /// <param name="obj"></param> /// <param name="args"></param> void scanner_OnScannerReaderEvent(object obj, BarcodeReadEventArgs args) { try { if (this.InvokeRequired) { Action <object, BarcodeReadEventArgs> fun = new Action <object, BarcodeReadEventArgs>(scanner_OnScannerReaderEvent); this.Invoke(fun, new object[] { obj, args }); } else { if (Opt.FeatureCodeList == null || Opt.FeatureCodeList.Count < 1) { this.Tip("加载数据失败"); Audio.SoundTip(0);//错误提示音 return; } if (string.IsNullOrEmpty(args.strDataBuffer) || args.strDataBuffer.Length == 0) { this.Tip("扫描的条码错误"); Audio.SoundTip(0);//错误提示音 return; } if (this.IsOK && this.IsHjScan) { watch.Reset(); watch.Start(); } doCommonScan(args.strDataBuffer); } } catch (Exception ex) { this.Tip("扫描失败");//提示 CLog.WriteErrLog("[FrmScan.ScanEvent]" + ex.Message); } }
public TP[] GetGOs <TP, TD>(TD[] data) where TP : Presenter <TD> where TD : PresenterData, new() { for (int i = 0; i < GOs.Count; i++) { if (GOs[i] == null) { CLog.Error("有的GO为null"); } } TP[] ts = GOs.Where(go => go != null).Select(go => go.GetComponent <TP>()).ToArray(); for (int i = 0; i < ts.Length; i++) { if (ts[i] == null) { CLog.Error(string.Format("取出组件为null, type={0},如果想要忽略,请添加IgnoreElement组件", typeof(TP))); break; } else { ts[i].SetIndex(i); ts[i].BaseDupplicate = this; AddChild(ts[i], true); if (data != null) { if (i < data.Length) { ts[i].Init(data[i]); } } else { ts[i].Init(new TD()); } } } return(ts); }
/// <summary> /// 删除结点 /// 使用此方法请确保Entity在EntityList中,否则,使用RemoveBool代替 /// </summary> /// <param name="entity"></param> private void _RemoveNode(EntityNode node) { #if DEBUG if (_ContainsNode(node) == false) { CLog.Warning(SysLogType.Battle, "entity not exit in this entityList.entity.baseid={0}", node.Entity.BaseId); return; } #endif EntityNode pre = node.pre; EntityNode next = node.next; if (head == node) { head = next; } if (tail == node) { tail = pre; } if (pre != null) { pre.next = next; } if (next != null) { next.pre = pre; } _DisposeNode(node); Count--; }
public virtual void prepare( int mapWidth, bool horzWrap, int mapHeight, bool vertWrap, CDLLHints hints, CGameMapParameters mparams, WBQueryI unitData, StringPollerI distributor, MapCallbackI callback, string logpath, string logname, int loglevel) { if (reallogger_ == null) { reallogger_ = new CLog(logpath, logname, loglevel); logger_ = new CSubLog("MapMaker", reallogger_); } distributor_ = distributor; callback_ = callback; unitData_ = unitData; mapUtil_ = new CMapUtil(mapWidth, horzWrap, mapHeight, vertWrap); mparams_ = mparams; //build the map output for (int i = 0; i < mapWidth * mapHeight; i++) { mapLocs_.Add(new TempMapStruct()); } //the default seed - object may get replaced random_ = new CMTRandom(); }
/// <summary> /// Start /// </summary> /// <returns></returns> public async Task Start() { try { httpListener.Start(); while (true) { try { HttpListenerContext httpListenerContext = await httpListener.GetContextAsync(); HttpListenerWebSocketContext webSocketContext = await httpListenerContext.AcceptWebSocketAsync(null); var channel = new WSChannel(webSocketContext); channels[channel.Id] = channel; //this.OnAccept(channel); } catch (Exception e) { CLog.Error(e); } } } catch (HttpListenerException e) { if (e.ErrorCode == 5) { throw new Exception($"CMD管理员中输入: netsh http add urlacl url=http://*:8080/ user=Everyone", e); } CLog.Error(e); } catch (Exception e) { CLog.Error(e); } }
/// <summary> /// 操作调用方法 /// </summary> private void doAction() { try { string action = context.Request.Params["do"].ToString().ToLower(); switch (action) { case "add": this.Insert(); break; case "update": this.Update(null); break; case "get": this.Select(); break; case "check": this.CheckBatchTip(); break; default: break; } } catch (Exception ex) { CLog.WriteErrLog(ex.Message); ReturnData.Data = ex.Message; } finally { context.Response.Write(JsonHelper.JsonSerializer(ReturnData)); } }
/// <summary> /// CallBack /// </summary> /// <param name="myXAQueryClass"></param> private void ReceiveData(XAQueryClass myXAQueryClass) { string result = ""; try { string hname = myXAQueryClass.GetFieldData("t1102OutBlock", "hname", 0); string price = myXAQueryClass.GetFieldData("t1102OutBlock", "price", 0); string sign = myXAQueryClass.GetFieldData("t1102OutBlock", "sign", 0); string change = myXAQueryClass.GetFieldData("t1102OutBlock", "change", 0); string diff = myXAQueryClass.GetFieldData("t1102OutBlock", "diff", 0); if (CStringUtil.IsNullOrEmpty(hname) == false) { StringBuilder param = new StringBuilder(); param.Append(hname); param.Append(CConst.DB_PARAM_DELIMITER).Append(price); param.Append(CConst.DB_PARAM_DELIMITER).Append(sign); param.Append(CConst.DB_PARAM_DELIMITER).Append(change); param.Append(CConst.DB_PARAM_DELIMITER).Append(diff); WebSql.SelectSql(3102, param.ToString()); result = param.ToString(); } } catch (Exception e) { result = "데이터 가져오기 실패"; CLog.debug(logger, "CAgent.ReceiveData: " + e.Message + ", XASession: " + XASession.GetErrorMessage(XASession.GetLastError())); } if (form != null) { form.DisplayReturnMessage(result); } }
public virtual bool Load() { if (_IsLoaded) { return(true); } Debug.Assert(_Textures.Count == 0 && _Videos.Count == 0); // load skins/textures foreach (KeyValuePair <string, string> kvp in _Data.Skins) { CTextureRef texture = CDraw.AddTexture(Path.Combine(_Folder, kvp.Value)); if (texture == null) { CLog.Error("Error on loading texture \"" + kvp.Key + "\": " + kvp.Value, true); return(false); } _Textures.Add(kvp.Key, texture); } // load videos foreach (KeyValuePair <string, string> kvp in _Data.Videos) { CVideoSkinElement sk = new CVideoSkinElement { FileName = kvp.Value }; if (!File.Exists(Path.Combine(_Folder, sk.FileName))) { CLog.Error("Video \"" + kvp.Key + "\": (" + sk.FileName + ") not found!"); continue; } _Videos.Add(kvp.Key, sk); } _IsLoaded = true; return(true); }
/// <summary> /// 更新产品信息 /// </summary> /// <param name="info"></param> public int UpdateProduction(ProductionMDL mdl) { int ret = 0; string strSql = string.Empty; try { //DateTime theDate = DateTime.Now; //theDate.ToString("yyyy-MM-dd HH:mm:ss"); string dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); strSql = "update production set lineid='{0}',brakename='{1}',brakeid='{2}',brakecode='{3}',factory='{4}',remark='{5}' where tid='{6}'"; // strSql = string.Format(strSql, mdl.LineNum, mdl.ProductName, mdl.ProductID, mdl.ProductCode, mdl.Factory, mdl.Remark, mdl.TID); // ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql,null); ret = SQLiteDBHelper.ExecuteNonQuery(strSql); return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(0); } }
/// <summary> /// Fill a <see cref="DataTable"/> with data contained inside a database table /// </summary> /// <param name="sql"></param> /// <returns></returns> public DataTable FillTable(string sql) { if (IsOpen && !string.IsNullOrEmpty(sql)) { try { sql = TryToFixTrueFalseTesting(sql); OdbcDataAdapter da = new OdbcDataAdapter(sql, Database); DataTable dataTable = new DataTable(); da.Fill(dataTable); DataAdapter = da; CommandBuilder = new OdbcCommandBuilder(DataAdapter); DataAdapter.InsertCommand = CommandBuilder.GetInsertCommand(); DataAdapter.UpdateCommand = CommandBuilder.GetUpdateCommand(); DataAdapter.DeleteCommand = CommandBuilder.GetDeleteCommand(); return(dataTable); } catch (Exception ex) { CLog.AddException($"{MethodBase.GetCurrentMethod().Module.Name}.{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}", ex, $"Connection string: {ConnectionString}"); } } return(null); }
/// <summary> /// Selects a set of objects from the database and returns them inside a <see cref="OdbcDataAdapter"/> object to be extracted by the caller /// </summary> /// <param name="command">A complete <see cref="OdbcCommand"/> detailing a select request to launch</param> /// <param name="reader">An <see cref="OdbcDataReader"/> object which can be used to fetch data from the result set</param> /// <returns>True if successfull, false otherwise</returns> public bool SelectRequest(OdbcCommand command, ref OdbcDataReader reader) { reader = null; bool f = false; if (IsOpen && null != command) { try { command.Connection = Database; reader = command.ExecuteReader(); f = true; } catch (Exception ex) { CLog.AddException($"{MethodBase.GetCurrentMethod().Module.Name}.{MethodBase.GetCurrentMethod().DeclaringType.Name}.{MethodBase.GetCurrentMethod().Name}", ex); } finally { command.Dispose(); } } return(f); }
/// <summary> /// 获取产品BOM信息 /// </summary> private void Select() { try { string TableName = context.Request.Params["TableName"].ToString(); string ProductType = context.Request.Params["ProductType"].ToString(); string ProductCode = context.Request.Params["ProductCode"].ToString(); string TraceType = context.Request.Params["TraceType"].ToString(); if (string.IsNullOrEmpty(TraceType) || TraceType == "0") { TraceType = "'扫描追溯','批次追溯'"; } else if (TraceType == "1") { TraceType = "'扫描追溯'"; } else if (TraceType == "2") { TraceType = "'批次追溯'"; } string sql = string.Format("SELECT * FROM (SELECT t.*,n.tid ext1,n.batchno ext2,n.stocknum ext3 FROM (SELECT b.*, m.tablename, m.fieldname FROM productinfo p, productbominfo b, materialfield m WHERE p.productcode = b.productcode AND p.producttype = b.producttype AND b.materialcode = m.materialcode AND m.tablename='{0}') t LEFT JOIN batchno n ON t.materialcode = n.materialcode) t WHERE productcode='{1}' AND producttype='{2}' AND tracetype in({3});", TableName, ProductCode, ProductType, TraceType); DataTable table = CommonDAL.GetDataTable(sql); if (table != null && table.Rows.Count > 0) { //object obj = TableHelper.TableToObj(table); Dictionary <string, MaterialBomMDL> HTMaterialTable = MaterialBomDAL.GetList(table, 3); ReturnData.Code = "1"; ReturnData.Msg = "OK"; ReturnData.Data = HTMaterialTable; } } catch (Exception ex) { CLog.WriteErrLog(ex.Message); } }
public override bool Init() { if (!base.Init()) { return(false); } if (_Version < 0) { CLog.LogError("Can't find Ressource-DB!"); return(false); } if (_Version < CSettings.DatabaseCreditsRessourcesVersion) { #if DEBUG return(_CreateDB() && _UpdateV1()); #else CLog.LogError("Upgrading Ressource-DB not possible"); return(false); #endif } return(true); }
protected bool SetStartupInfo(int execType, int affID, ref ProcessStartInfo startInfo) { try { switch (execType) { case 0: startInfo.FileName = WSCommon.GetAffiliatePath(affID, true) + "\\" + CConfig.stGetConfigValue("FileSecurityBat", false); startInfo.WorkingDirectory = Path.GetDirectoryName(startInfo.FileName); startInfo.Arguments = string.Format("{0} {1}", startInfo.WorkingDirectory, WSCommon.GetAffiliatePath(affID, false)); break; default: return(false); } return(true); } catch (Exception ex) { CLog.stLogException(ex); return(false); } }
public bool Init() { try { var xml = new CXmlDeserializer(); _Data = xml.Deserialize <STheme>(Path.Combine(_Folder, _FileName)); if (_Data.ThemeSystemVersion != _ThemeSystemVersion) { string errorMsg = _Data.ThemeSystemVersion < _ThemeSystemVersion ? "the file ist outdated!" : "the file is for newer program versions!"; errorMsg += " Current Version is " + _ThemeSystemVersion; throw new Exception(errorMsg); } } catch (Exception e) { CLog.LogError("Can't load theme \"" + _FileName + "\". Invalid file!", false, false, e); return(false); } string path = Path.Combine(_Folder, Name); List <string> files = CHelper.ListFiles(path, "*.xml"); // Load skins, succeed if at least 1 skin was loaded bool ok = false; foreach (string file in files) { CSkin skin = _GetNewSkin(path, file); if (skin.Init()) { _Skins.Add(skin.Name, skin); ok = true; } } return(ok); }
/// <summary> /// 下载数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDnData_Click(object sender, EventArgs e) { try { if (!Opt.GlobalNetStatus()) { MessageBox.Show("离线模式下不能下载数据,待在线模式下下载数据!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } else { FrmDataSync form = new FrmDataSync(SyncType.Download); form.ShowDialog(); form.Dispose(); LoadForm(); //加载产品特征码列表 Opt.LoadProductInfo(); } } catch (Exception ex) { CLog.WriteErrLog("[FrmMain.btnDnData]" + ex.Message); } }
/// <summary> /// 更新产品计划信息 /// </summary> /// <param name="info"></param> public int UpdateProductionPlanItem(ProductionPlanMDL mdl) { int ret = 0; string strSql = string.Empty; try { //(plan_id,pline_id,station_id,start_time,end_time,brakeid,plan_num,actual_num,shift,create_time,remark) strSql = "update production_plan set plan_id='{0}',pline_id='{1}',station_id='{2}',start_time='{3}',end_time='{4}',brakeid='{5}',plan_num='{6}'," + "actual_num='{7}',shift='{8}',create_time='{9}',remark='{10}' where tid='{11}'"; strSql = string.Format(strSql, mdl.PlanID, mdl.Pline_ID, mdl.Station_ID, mdl.StartTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.EndTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.BreakeID, mdl.PlanNum, mdl.Actual_num, mdl.Shift, mdl.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), mdl.Remark, mdl.TID); ret = MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null); return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(0); } }
public void ReLoad(string plineID) { try { startCount = 0; curCount = 0; if (lists != null) { lists.Clear(); } // Initial(); InitailPlineUnits(); /// LoadTempPlan(); /// //new system plan LoadSystemDefualtPlan(plineID); } catch (Exception ex) { CLog.WriteErrLog(ex.Message.ToString()); } }
public static bool InitRequiredElements() { string path = Path.Combine(CSettings.ProgramFolder, CSettings.FileNameRequiredSkinElements); var xml = new CXmlDeserializer(); try { _Required = xml.Deserialize <SRequiredElements>(path); } catch (CXmlException e) { CLog.Error("Error reading required elements: " + e); return(false); } for (int i = 1; i <= CSettings.MaxNumPlayer; i++) { string name = "Player" + i; if (!_Required.Colors.Contains(name)) { _Required.Colors.Add(name); } } return(true); }
/// <summary> /// 获取分支节点的下一级节点ID /// </summary> /// <param name="WFID"></param> /// <param name="InstanceID"></param> /// <param name="SwitchNodeID">分支节点ID</param> /// <returns></returns> public static string GoNextNodesFromSwitchNode(string InstanceID, string SwitchNodeID) { try { string[] SwitchNames = CNodeManager.GetSwitchName(InstanceID, SwitchNodeID); for (int i = 0; i < SwitchNames.Length; i++) { string SwitchID = CNodeManager.GetSwitchIDBySwitchName(SwitchNodeID, SwitchNames[i]); //根据switchid获取下一级节点ID string NextNodeID = CNodeManager.GetNextNodeIDBySwitchID(SwitchID); string NodeTransferResult = NodeTransfer(InstanceID, SwitchNodeID, NextNodeID); if (NodeTransferResult != WFGlobal.success) { return(NodeTransferResult); } } return(WFGlobal.success); } catch (Exception ex) { WFGlobal.ErrInfo = CLog.PutDownErrInfo("流程流转操作异常,工作流实例ID:" + InstanceID + ",当前节点ID:" + SwitchNodeID + ",异常信息:" + ex.Message.ToString()); return(WFGlobal.ErrInfo); } }
private void _ParseReadData(byte[] buff) { if ((buff[3] & 0x08) != 0) { CLog.Error("Error reading data from WiiMote: Bytes do not exist"); Connected = false; } if ((buff[3] & 0x07) != 0) { CLog.Error("Error reading data from WiiMote: Attempt to read from write-only registers."); Connected = false; } int size = (buff[3] >> 4) + 1; int offset = buff[4] << 8 | buff[5]; Array.Copy(buff, 6, _ReadBuff, offset - _Address, size); if (_Address + _Size == offset + size) { _ReadDone.Set(); } }
public bool Do_Writes(byte channel, uint dwSetDOValue) { try { byte bytCount = 1; byte bytStartChannel = channel; switch (MXIO_CS.E1K_DO_Writes(this.hConnection[0], bytStartChannel, bytCount, dwSetDOValue)) { case 0: return(true); case 0x7d1: case 0xfa2: MXIO_CS.MXEIO_Exit(); break; } return(false); } catch (Exception exception) { CLog.WriteErrLogInTrace(string.Format("在设置IO端口状态时出错,{0}", exception.Message)); return(false); } }
public static bool CheckRequirements() { #if WIN if (!_IsVC2010Installed()) { CLog.LogError( "VC++ 2010 Redistributables are missing. Please install them first. \r\nDownload(x86): https://www.microsoft.com/de-de/download/details.aspx?id=5555 \r\nDownload(x64): https://www.microsoft.com/de-de/download/details.aspx?id=14632", true, true); return(false); } /*if (!_IsVC2012Installed()) * { * CLog.LogError( * "VC++ 2012 Redistributables are missing. Please install them first.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=30679", * true, true); * return false; * }*/ /* * bool vc2008Installed = _IsVC2008Installed(); * if (!vc2008Installed) * { * CLog.LogError( * "VC++ 2008 Redistributables are missing. Portaudio might not be working.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=29"); * } * if (!vc2008Installed && !_IsVC2010Installed()) * { * CLog.LogError( * "VC++ 2010 and 2008 Redistributables are missing. Please install them first. VC++ 2008 is preferred as Portaudio doesn't work with VC++ 2010.\r\nDownload(2008): http://www.microsoft.com/de-de/download/details.aspx?id=29 \r\nDownload(2010): http://www.microsoft.com/de-de/download/details.aspx?id=5555", * true, true); * return false; * } */ #endif //TODO: check for dependencies on linux? return(true); }
public static BTNode CreateNode(NEData neData) { Type neDataType = neData.data.GetType(); int index = Remote.lstRemoteNodeDataType.IndexOf(neDataType); if (index == -1) { CLog.LogError("can not find remoteNeDataType=" + neDataType + " mapping nodeType"); return(null); } Type neNodeType = Remote.lstRemoteNodeType[index]; BTNode neNode = Activator.CreateInstance(neNodeType) as BTNode; neNode.data = neData.data; if (neData.lstChild != null) { for (int i = 0; i < neData.lstChild.Count; i++) { BTNode childNode = CreateNode(neData.lstChild[i]); neNode.AddChild(childNode); } } return(neNode); }
public static bool ReadThemesFromFolder(string path, int partyModeID) { List <string> files = CHelper.ListFiles(path, "*.xml", false, true); List <CTheme> newThemes = new List <CTheme>(); foreach (string file in files) { CTheme theme; if (partyModeID < 0) { theme = new CBaseTheme(file); } else { theme = new CPartyTheme(file, partyModeID); } if (theme.Init()) { newThemes.Add(theme); } } if (newThemes.Count == 0) { CLog.LogError("No valid themes found in " + path); return(false); } if (partyModeID >= 0 && newThemes.Count(th => th.Name == CSettings.DefaultName) == 0) { CLog.LogError("Partymode misses default theme in " + path); return(false); } _Themes.AddRange(newThemes); return(true); }
/// <summary> /// 记录扫描信息 /// </summary> private void RecordScanInfo() { try { if (IsHjScan) //合件扫描记录 { RequestParam.Clear(); //清除数据 } else//材料扫描记录 { //添加扫描追溯的信息 //子零件编码和条码信息 if (RequestParam.ContainsKey(materialCode)) { RequestParam.Remove(materialCode); } RequestParam.Add(materialCode, this.lblBarCode.Text); } } catch (Exception ex) { CLog.WriteErrLog(ex.Message); } }
protected override void OnLoad() { #if UNITY_EDITOR if (DLCConfig.Ins.IsEditorMode) { asyncOperation = EditorSceneManager.LoadSceneAsyncInPlayMode(AssetFullPath, new LoadSceneParameters(LoadSceneMode.Additive, LocalPhysicsMode.None)); loadState = LoadStateType.Loading; loadCount = 0; return; } #endif { Bundle = DLCManager.LoadBundle(RealBundleName, DlcName, true); if (Bundle == null) { CLog.Error($"无法加载场景Bundle!!{RealBundleName}:{DlcName}"); } else { } loadState = LoadStateType.Loading; loadCount = 0; } }
/// <summary> /// 获得文件路径 /// </summary> /// <param name="path"></param> /// <param name="searchPattern"></param> /// <param name="searchOption"></param> /// <returns></returns> static List <string> GetFilesWithoutDirectories(string path) { if (!Directory.Exists(path)) { CLog.Error("没有这个路径:{0}", path); return(new List <string>()); } var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories); List <string> items = new List <string>(); foreach (var item in files) { if (item.EndsWith(".meta", StringComparison.CurrentCulture)) { continue; } var assetPath = item.Replace('\\', '/'); if (!Directory.Exists(assetPath)) { items.Add(assetPath); } } return(items); }
public void TestMethod1() { const int count = 100; Random rand = new Random(); CLog log = new CLog(); for (int i = 0; i < count; i++) { Methods.GenerateEvent(log, ref rand); log[i,-1].Date = Methods.GenerateDateTimeOffset(ref rand); } Assert.AreEqual(count, log.Count); }
public CView(CLog log) { Traces = new List<CTrace>(); Log = log; }
// Открывает XES в класс Log private static void open_xml_to_class(XmlDocument doc, out CLog log, out List<XmlNode> trash) { int ErrorCount = 0; DateTimeOffset? date = null; XmlNodeList listoftraces = doc.DocumentElement.ChildNodes; XmlNodeList listofevents; XmlNodeList listofnames; CultureInfo a = new CultureInfo(CultureInfo.CurrentCulture.Name); a.NumberFormat.NumberDecimalSeparator = "."; log = new CLog(); trash = new List<XmlNode>(); foreach (XmlNode trace in listoftraces) { if (trace.Name == "trace") { CTrace tr = new CTrace(); listofevents = trace.ChildNodes; foreach (XmlNode node in listofevents) { switch (node.Name) { case "string": if (node.Attributes[0].Value == "concept:name") tr.Name = node.Attributes[1].Value; else tr.Text_Parameters.Add(node.Attributes[0].Value, node.Attributes[1].Value); break; case "int": try { tr.Int_Parameters.Add(node.Attributes[0].Value, int.Parse(node.Attributes[1].Value)); //TODO Это } catch { ErrorCount++; } break; case "float": try { tr.Double_Parameters.Add(node.Attributes[0].Value, double.Parse(node.Attributes[1].Value)); } catch { ErrorCount++; } break; case "boolean": try { tr.Bool_Parameters.Add(node.Attributes[0].Value, bool.Parse(node.Attributes[1].Value)); } catch { ErrorCount++; } break; case "event": CEvent ev = new CEvent(log); listofnames = node.ChildNodes; foreach (XmlNode name in listofnames) switch (name.Name) { case "date": DateTimeOffset dat = new DateTimeOffset(); DateTimeOffset.TryParse(name.Attributes[1].Value, out dat); date = dat; ev.Date = date; break; case "string": if (name.Attributes[0].Value != "concept:name") ev.Text_Parameters.Add(name.Attributes[0].Value, name.Attributes[1].Value); else ev.Name = name.Attributes[1].Value; break; case "int": try { ev.Int_Parameters.Add(name.Attributes[0].Value, int.Parse(name.Attributes[1].Value)); } catch { ErrorCount++; } break; case "float": try { ev.Double_Parameters.Add(name.Attributes[0].Value, double.Parse(name.Attributes[1].Value, a)); } catch { ErrorCount++; } //TODO Создать логгирующую ошибки системы break; case "boolean": try { ev.Bool_Parameters.Add(name.Attributes[0].Value, bool.Parse(name.Attributes[1].Value)); } catch { ErrorCount++; } break; } tr.Add(ev); break; } } log.Add(tr); } else trash.Add(trace); } listofevents = null; listofnames = null; listoftraces = null; if ((ErrorCountEvent != null) && (ErrorCount > 0)) ErrorCountEvent(ErrorCount); }
public void TestMethod3() { CLog log = new CLog(); CEvent evt = new CEvent(log); log[0,-1].Name = "test1"; Assert.AreEqual("test1", evt.Name); }
public void CLogEventNamesTest() { CLog log = new CLog(); string name = ""; for (int i=1;i<15;i++) { name += "a"; for (int j = 0; j < i; j++) { CEvent evt = new CEvent(log); evt.Name = name; } } Assert.AreEqual(14, log.EventNamesCount); name = ""; foreach (string key in log.EventNames) name += key + "\r\n"; File.WriteAllText(String.Format(@"C:\Users\Fedor\Документы ВШЭ\Программирование\Курсовая\Log ver 2 Test Results\CLogEventNamesTest{3}_{4}_{0}_{1}_{2}.txt", DateTime.Now.Day.ToString(),DateTime.Now.Month.ToString(),DateTime.Now.Year.ToString(),DateTime.Now.Hour.ToString(),DateTime.Now.Minute.ToString()), name); }
private static void save_xml_from_class(out XmlDocument doc, CLog log, CView View, List<XmlNode> trash) { CultureInfo a = new CultureInfo(CultureInfo.CurrentCulture.Name); a.NumberFormat.NumberDecimalSeparator = "."; doc = new XmlDocument(); doc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?> <log> </log>"); foreach (XmlNode n in trash) { XmlNode temp = doc.ImportNode(n, true); doc.DocumentElement.AppendChild(temp); } foreach (CTrace trace in View.Traces) { XmlNode TraceNode = doc.CreateElement("trace"); XmlNode NameParam = doc.CreateElement("string"); XmlAttribute Key = doc.CreateAttribute("key"), Value = doc.CreateAttribute("value"); Key.Value = "concept:name"; Value.Value = trace.Name; NameParam.Attributes.Append(Key); NameParam.Attributes.Append(Value); TraceNode.AppendChild(NameParam); // Выведение параметров Trace #region foreach (var i in trace.Text_Parameters) { XmlNode TextParam = doc.CreateElement("string"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(); TextParam.Attributes.Append(Key); TextParam.Attributes.Append(Value); TraceNode.AppendChild(TextParam); } foreach (var i in trace.Bool_Parameters) { XmlNode BoolParam = doc.CreateElement("boolean"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(); BoolParam.Attributes.Append(Key); BoolParam.Attributes.Append(Value); TraceNode.AppendChild(BoolParam); } foreach (var i in trace.Int_Parameters) { XmlNode IntParam = doc.CreateElement("int"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(); IntParam.Attributes.Append(Key); IntParam.Attributes.Append(Value); TraceNode.AppendChild(IntParam); } foreach (var i in trace.Double_Parameters) { XmlNode FloatParam = doc.CreateElement("float"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(a); FloatParam.Attributes.Append(Key); FloatParam.Attributes.Append(Value); TraceNode.AppendChild(FloatParam); } #endregion foreach (CEvent Event in trace.Events) { XmlNode EventNode = doc.CreateElement("event"); XmlNode EventNameParam = doc.CreateElement("string"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = "concept:name"; Value.Value = Event.Name; EventNameParam.Attributes.Append(Key); EventNameParam.Attributes.Append(Value); EventNode.AppendChild(EventNameParam); if (Event.Date.HasValue) { DateTimeOffset Date = Event.Date.Value; string date = Date.Year.ToString("D4") + "-" + Date.Month.ToString("D2") + "-" + Date.Day.ToString("D2") + "T" + Date.Hour.ToString("D2") + ":" + Date.Minute.ToString("D2") + ":" + Date.Second.ToString("D2") + "." + Date.Millisecond.ToString("D3") + (Date.Offset.Hours > 0 ? "+" : "-") + Date.Offset.Hours.ToString("D2") + ":" + Date.Offset.Minutes.ToString("D2"); XmlNode EventDateParam = doc.CreateElement("date"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = "time:timestamp"; Value.Value = date; EventDateParam.Attributes.Append(Key); EventDateParam.Attributes.Append(Value); EventNode.AppendChild(EventDateParam); } foreach (var i in Event.Text_Parameters) { XmlNode TextParam = doc.CreateElement("string"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(); TextParam.Attributes.Append(Key); TextParam.Attributes.Append(Value); EventNode.AppendChild(TextParam); } foreach (var i in Event.Bool_Parameters) { XmlNode BoolParam = doc.CreateElement("boolean"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(); BoolParam.Attributes.Append(Key); BoolParam.Attributes.Append(Value); EventNode.AppendChild(BoolParam); } foreach (var i in Event.Int_Parameters) { XmlNode IntParam = doc.CreateElement("int"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(); IntParam.Attributes.Append(Key); IntParam.Attributes.Append(Value); EventNode.AppendChild(IntParam); } foreach (var i in Event.Double_Parameters) { XmlNode FloatParam = doc.CreateElement("float"); Key = doc.CreateAttribute("key"); Value = doc.CreateAttribute("value"); Key.Value = i.Key; Value.Value = i.Value.ToString(a); FloatParam.Attributes.Append(Key); FloatParam.Attributes.Append(Value); EventNode.AppendChild(FloatParam); } TraceNode.AppendChild(EventNode); } doc.DocumentElement.AppendChild(TraceNode); } }
public void TestMethod4() { CLog log = new CLog(); CEvent evt; for (int i=0;i<100;i++) evt = new CEvent(log); for (int i=0;i<100;i++) Assert.AreEqual(i,log[i,-1].EventID); }
private void ClearMemory_MouseDoubleClick_1(object sender, RoutedEventArgs e) { // Очистка всего и вся ClearLists(); log = new CLog(); NowView = new CView(log); trash = new List<XmlNode>(); //Начальная доступность FilterTabName.IsEnabled = false; ParamsTab.IsEnabled = false; _Filters.IsEnabled = false; CopyButton.IsEnabled = false; DeleteButton.IsEnabled = false; VisualizeFromXButton.IsEnabled = false; _Save.IsEnabled = false; //Установка строки состояния Label LoadStatus = new Label(); LoadStatus.Height = 28; LoadStatus.Content = "Лог не загружен"; StatusBar1.Items.Add(LoadStatus); Label LoadNumbers = new Label(); LoadNumbers.Height = 28; LoadNumbers.Visibility = System.Windows.Visibility.Collapsed; StatusBar1.Items.Add(LoadNumbers); // Очистка памяти GC.Collect(); GC.WaitForPendingFinalizers(); }
public void TestMethod5() { const int count = 10; Random rand = new Random(); CLog log = new CLog(); for (int i = 0; i < count; i++) { Methods.GenerateEvent(log, ref rand); log[i,-1].Date = Methods.GenerateDateTimeOffset(ref rand); } log.Add(new CTrace()); CEvent evt2=log.Events[0]; foreach (CEvent evt in log.Events) log[0].Add(evt); CView view = log.GetView(); view[0].Remove(evt2); Assert.AreEqual(log[0].Count - 1, view[0].Count); }