public Application(XLua.LuaEnv env) { _luaenv = env; _tiSync = new TimeSync(); _tiSync.LocalTime(); _lastTi = _tiSync.LocalTime(); #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN //_cotype = CoType.THREAD; _cotype = CoType.CO; #elif UNITY_IOS || UNITY_ANDROID _cotype = CoType.CO; #endif if (_cotype == CoType.THREAD) { _semaphore = new Semaphore(1, 1); _worker = new Thread(new ThreadStart(Worker)); _worker.IsBackground = true; _worker.Start(); UnityEngine.Debug.Log("create thread success."); } else { UnityEngine.Debug.Log("create co success."); } }
private void gridCoType_CellValueChanged(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e) { if (dataBindingCompleted && e.RowIndex >= 0) { //Helper.ShowInformation("gridCoType_CellValueChanged at: " + (e.RowIndex + 1).ToString()); CoType currentCoType = new CoType(); currentCoType = (CoType)e.Row.DataBoundItem; if (currentCoType != null) { switch (gridCoType.CurrentColumn.Name) { case "CoCode": currentCoType.CoCode = Helper.ConvertToString(e.Row.Cells["CoCode"].Value); break; case "CoName": currentCoType.CoName = Helper.ConvertToString(e.Row.Cells["CoName"].Value); break; case "CoNotes": currentCoType.CoNotes = Helper.ConvertToString(e.Row.Cells["CoNotes"].Value); break; case "Active": currentCoType.Active = (bool)e.Row.Cells["Active"].Value; break; default: break; } currentCoType.UpdatedDate = DateTime.Now; EQ_MainForm.dbContext.SaveChanges(); } } }
private void gridCoType_UserDeletedRow(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e) { //Helper.ShowInformation("gridCoType_UserDeletedRow"); CoType currentCoType = new CoType(); currentCoType = (CoType)e.Row.DataBoundItem; //EQ_MainForm.dbContext.CoTypes.FirstOrDefault(ct => ct.CoType_ID == cotypeID); if (currentCoType != null) { EQ_MainForm.dbContext.CoTypes.Remove(currentCoType); EQ_MainForm.dbContext.SaveChanges(); } }
private void gridCoType_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e) { if (e.RowIndex < 0) // Don't check if it's the new adding row { return; } switch (gridCoType.CurrentColumn.Name) { case "CoCode": string sCode = Helper.ConvertToString(e.Value); // Code cannot be empty if (sCode == string.Empty) { Helper.ShowError("Input the code for Company type."); e.Cancel = true; } else { string oldCode = Helper.ConvertToString(e.OldValue); // If a new code is input if (sCode != oldCode) { CoType currentCoType = EQ_MainForm.dbContext.CoTypes.FirstOrDefault(ct => ct.CoCode == sCode); if (currentCoType != null) // Code is already existed { Helper.ShowError("The code is already existed. Input another code."); e.Cancel = true; } } } break; case "CoName": // Name cannot be empty if (Helper.ConvertToString(e.Value) == string.Empty) { Helper.ShowError("Input the name of Company type."); e.Cancel = true; } break; default: break; } }
private void gridCoType_UserAddedRow(object sender, Telerik.WinControls.UI.GridViewRowEventArgs e) { CoType newCoType = new CoType(); newCoType.CoCode = Helper.ConvertToString(e.Row.Cells["CoCode"].Value); newCoType.CoName = Helper.ConvertToString(e.Row.Cells["CoName"].Value); newCoType.CoNotes = Helper.ConvertToString(e.Row.Cells["CoNotes"].Value); if (Helper.ConvertToString(e.Row.Cells["Active"].Value) != string.Empty) { newCoType.Active = (bool)e.Row.Cells["Active"].Value; } else { newCoType.Active = false; } newCoType.UpdatedDate = DateTime.Now; EQ_MainForm.dbContext.CoTypes.Add(newCoType); EQ_MainForm.dbContext.SaveChanges(); InitData(); // rebound datasource Helper.ShowInformation("A new COMPANY-TYPE has been created under line " + (e.Row.Index + 1).ToString()); }
/// <summary> /// 站点类型列表 /// </summary> /// <returns></returns> public DataTable GetSelectRoomType() { DataTable dtSource = new DataTable(); dtSource.Columns.Add("Id", typeof(System.String)); dtSource.Columns.Add("Text", typeof(System.String)); System.Reflection.FieldInfo[] fields = typeof(CoType).GetFields(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); foreach (System.Reflection.FieldInfo field in fields) { if (!field.Name.Contains("Rm")) { continue; } CoType aa = (CoType)Enum.Parse(typeof(CoType), field.Name); var obj = field.GetCustomAttributes(typeof(DisplayAttribute), false); if (obj != null && obj.Count() != 0) { DisplayAttribute md = obj[0] as DisplayAttribute; dtSource.Rows.Add(new object[] { aa.ToString(), md.Name }); } } return(dtSource); }
public Application(Maria.Util.App app) { _app = app; _tiSync = new TimeSync(); _tiSync.LocalTime(); _lastTi = _tiSync.LocalTime(); #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN //_cotype = CoType.THREAD; _cotype = CoType.CO; #elif UNITY_IOS || UNITY_ANDROID _cotype = CoType.CO; #endif if (_cotype == CoType.THREAD) { _semaphore = new Semaphore(1, 1); _worker = new Thread(new ThreadStart(Worker)); _worker.IsBackground = true; _worker.Start(); UnityEngine.Debug.LogWarning("create thread success."); } else { UnityEngine.Debug.LogWarning("create co success."); } _luaenv = new XLua.LuaEnv(); _luaenv.AddBuildin("cjson", XLua.LuaDLL.Lua.LoadCJson); _luaenv.AddBuildin("lpeg", XLua.LuaDLL.Lua.LoadLpeg); _luaenv.AddBuildin("sproto.core", XLua.LuaDLL.Lua.LoadSprotoCore); _luaenv.AddLoader((ref string filepath) => { UnityEngine.Debug.LogFormat("LUA custom loader {0}", filepath); string[] xpaths = filepath.Split(new char[] { '.' }); string path = "xlua/src"; int idx = 0; while (idx + 1 < xpaths.Length) { path += "/"; path += xpaths[idx]; idx++; } TextAsset file = ABLoader.current.LoadAsset <TextAsset>(path, xpaths[idx] + ".lua"); if (file != null) { return(file.bytes); } else { file = ABLoader.current.LoadAsset <TextAsset>(path + "/lualib", xpaths[idx] + ".lua"); if (file != null) { return(file.bytes); } return(null); } }); _luaenv.DoString(@" require 'main' "); }