public static void Dapper_Execute_Sample() { Console.WriteLine(String.Format("{0} Dapper_Execute_Sample", databaseProductType.ToString())); Console.WriteLine("Start"); CdbcConnection con = UtilCommon.getConnection(databaseProductType); string sqlInsert = @"INSERT INTO student(studentid, studentname, birthdate, photo) VALUES (:studentid, :studentname, :birthdate, :photo)"; string sqlUpdate = @"UPDATE student SET studentname=:studentname, birthdate=:birthdate, photo=:photo WHERE studentid=:studentid"; string sqlDelete = @"DELETE FROM student WHERE studentid=:studentid"; string sqlSelect = @"SELECT studentid, studentname, birthdate, photo FROM student WHERE studentid=:studentid"; int studentid1 = new System.Random(DateTime.Now.Millisecond).Next(1000); byte[] photo1 = null; //You can use the following code to insert the photo. //byte[] photo1=System.IO.File.ReadAllBytes(@"photo file path"); var student1 = new Student() { studentid = studentid1, studentname = "Tom", birthdate = new DateTime(2004, 11, 24), photo = photo1 }; try { //Insert int i = con.Execute(sqlInsert, student1); Console.WriteLine("--------------------------"); Console.WriteLine("Sql : " + sqlInsert); Console.WriteLine("student parameter: " + student1.ToString()); Console.WriteLine(String.Format("{0} Line(s) inserted.", i)); //Insert result var studentDb = con.QuerySingle <Student>(sqlSelect, student1); Console.WriteLine("student inserted: " + studentDb.ToString()); //update //We will change the student's name and birthday then update database. student1.studentname = "Tom2"; student1.birthdate = new DateTime(2004, 6, 11); i = con.Execute(sqlUpdate, student1); Console.WriteLine(String.Format("{0} Line(s) updated.", i)); //update result studentDb = con.QuerySingle <Student>(sqlSelect, student1); Console.WriteLine("student updated: " + studentDb.ToString()); //delete i = con.Execute(sqlDelete, student1); Console.WriteLine(String.Format("{0} Line(s) deleted.", i)); } catch (Exception ex) { Console.WriteLine("Exception:"); Console.WriteLine(ex.Message); } Console.WriteLine("--------------------------"); Console.WriteLine("End"); }
/// <summary> /// 下载成功处理 /// </summary> public override void OnDownloadFinish() { string newV = UtilCommon.ReadVersionFile(Application.persistentDataPath + "/VersionTemp.json"); UtilCommon.SetTempVersion(newV); base.OnDownloadFinish(); }
static int GenBezierPath(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 3) { List <Vector3> arg0 = (List <Vector3>)LuaScriptMgr.GetNetObject(L, 1, typeof(List <Vector3>)); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); LineRenderer arg2 = (LineRenderer)LuaScriptMgr.GetUnityObject(L, 3, typeof(LineRenderer)); List <Vector3> o = UtilCommon.GenBezierPath(arg0, arg1, arg2); LuaScriptMgr.PushObject(L, o); return(1); } else if (count == 4) { Vector3 arg0 = LuaScriptMgr.GetVector3(L, 1); Vector3 arg1 = LuaScriptMgr.GetVector3(L, 2); int arg2 = (int)LuaScriptMgr.GetNumber(L, 3); LineRenderer arg3 = (LineRenderer)LuaScriptMgr.GetUnityObject(L, 4, typeof(LineRenderer)); List <Vector3> o = UtilCommon.GenBezierPath(arg0, arg1, arg2, arg3); LuaScriptMgr.PushObject(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UtilCommon.GenBezierPath"); } return(0); }
private void BtnLogin_Click(object sender, EventArgs e) { UtilCommon.userId = txtUserId.Text; UtilCommon.userPassword = txtPassword.Text; CdbcConnection con = UtilCommon.getConnection(); try { con.ConnectToServiceWhileOpen = true; con.Open(); this.Hide(); FrmProductList frmProductList = new FrmProductList(); frmProductList.ShowDialog(); frmProductList.Dispose(); this.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) ; } }
static int Peer(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(Transform), typeof(string))) { Transform arg0 = LuaScriptMgr.GetUnityObject <Transform>(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); GameObject o = UtilCommon.Peer(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(string))) { GameObject arg0 = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); GameObject o = UtilCommon.Peer(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UtilCommon.Peer"); } return(0); }
static int GetComponent(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(Type))) { GameObject arg0 = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); Type arg1 = LuaScriptMgr.GetTypeObject(L, 2); Component o = UtilCommon.GetComponent(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(GameObject), typeof(string))) { GameObject arg0 = LuaScriptMgr.GetUnityObject <GameObject>(L, 1); string arg1 = LuaScriptMgr.GetString(L, 2); Component o = UtilCommon.GetComponent(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UtilCommon.GetComponent"); } return(0); }
// Use this for initialization void Start() { // example of loading csv file csv = CSVLoader.Instance; //TextAsset txt = csv.loadFile(1, 1, "Alocer_Dania"); unit = new Unit(); unit.readCharCSV(1, "Lancelot_Tartare"); //Debug.Log("step Name: " + BLance.getName()); // including fade and transition fm = FadeManager.Instance; // example of sound playing snd = SoundManager.Instance; //snd.PlayBGM(0); // example of random value util = UtilCommon.Instance; // example of using ClassBase cb = ClassBase.Instance; ps = ParameterScreen.Instance; ps.inactivateGuages(); mb = MessageBase.Instance; ms = MapScreen.Instance; //ms.showMap(); DontDestroyOnLoad(this.gameObject); }
public static UserModel ToUserModel(this User user, UserRole role) { var model = new UserModel(); if (user != null) { model.UserId = user.Id; model.Avatar = UtilCommon.GetDisplayImageUrl(user.Avatar); model.FullName = user.FullName; model.Email = user.Email; model.Phone = user.Phone; model.Role = user.Role; model.Gender = user.Gender; model.LinkedSite = user.LinkedSite; model.Address = user.Address; model.Bio = user.Bio; model.Location = user.Location; model.Strength = user.Strength; model.Languages = user.Languages; model.UserName = user.UserName; model.UserId = user.Id; if (string.IsNullOrWhiteSpace(user.DateOfBirth.ToString())) { model.DateOfBirth = Constants.DEFAULT_DATEOFBIRTH; } else { model.DateOfBirth = user.DateOfBirth.ToString(); } } return(model); }
public async Task <CourseApiModel> EditCourse(CourseModel model, int userId, IFormFile uploadedFile) { try { var result = new CourseApiModel(); var entity = await _courseRepo.GetByIdAsync(model.Id); if (entity == null) { return(result); } entity = model.ToEntity(entity); entity.CourseImage = UtilCommon.ImageUpload(Constants.UserDataFolderName, uploadedFile, "", false); await _courseRepo.UpdateAsync(entity); var owner = await _userRepo.GetByIdAsync(userId); result = entity.ToModel(); return(result); } catch (Exception ex) { return(null); } }
private void getCurrencyList() { CdbcConnection con = UtilCommon.getConnection(); string cmdQuery = "SELECT C.CURRENCY_CODE " + " , C.CURRENCY_SYMBOL " + " FROM CURRENCIES C " + " ORDER BY C.CURRENCY_CODE"; CdbcCommand cmd = new CdbcCommand(cmdQuery); cmd.Connection = con; cmd.CommandType = CommandType.Text; CdbcDataAdapter dataAdapter = new CdbcDataAdapter(cmd); try { dataAdapter.Fill(dsCurrencies, dsCurrencies.CURRENCIES.TableName); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) ; } }
public static void Command_ExecuteDbDataReader_Sample() { Console.WriteLine(String.Format("{0} Command_ExecuteDbDataReader_Sample", databaseProductType.ToString())); Console.WriteLine("Start"); CdbcConnection con = UtilCommon.getConnection(databaseProductType); string queryStr = @"SELECT TABLE_NAME FROM ALL_TABLES"; CdbcCommand cmd = new CdbcCommand(queryStr, con); Console.WriteLine("--------------------------"); Console.WriteLine("Sql : " + queryStr); Console.WriteLine("--------------------------"); try { DbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader.GetValue(0).ToString()); } } catch (Exception ex) { Console.WriteLine("Exception:"); Console.WriteLine(ex.Message); } Console.WriteLine("--------------------------"); Console.WriteLine("End"); }
public async Task <CourseApiModel> CreateCourse(CourseModel model, int ownerId, IFormFile uploadedFile) { var entity = new Course(); try { var result = new CourseApiModel(); entity.OwnerId = ownerId; entity.CourseImage = UtilCommon.ImageUpload(Constants.UserDataFolderName, uploadedFile, "", false); entity = model.ToEntity(entity); await _courseRepo.InsertAsync(entity); result = entity.ToModel(); return(result); } catch (Exception ex) { if (entity.Id != 0) { await _courseRepo.DeleteAsync(entity); } return(null); } }
public static CourseApiModel ToModel(this Course entity) { var model = new CourseApiModel(); model.Id = entity.Id; model.Name = entity.Name; model.Description = entity.Description; model.OwnerId = entity.OwnerId; model.Owner = entity.Owner; model.CourseCategory = entity.CourseCategory; model.CourseFee = entity.CourseFee; if (string.IsNullOrWhiteSpace(entity.AvailableFrom.ToString())) { model.AvailableFrom = Constants.DEFAULT_DATEOFBIRTH; } else { model.AvailableFrom = entity.AvailableFrom.ToString(); } if (string.IsNullOrWhiteSpace(entity.AvailableTo.ToString())) { model.AvailableTo = Constants.DEFAULT_DATEOFBIRTH; } else { model.AvailableTo = entity.AvailableTo.ToString(); } model.CourseImage = UtilCommon.GetDisplayImageUrl(entity.CourseImage); return(model); }
/// <summary> /// 保存gamemanager,开始init /// </summary> /// <param name="ins"></param> public void StartInitResources(GameManager ins) { mGameManager = ins; _pkgConfig = UtilCommon.AddComponent <PkgConfig>(mGameManager.gameObject) as PkgConfig; _pkgConfig.SetCallback(InitVersionContrl); _pkgConfig.OnStartDownload(); }
protected virtual void Init() { mGUID = UtilCommon.GenGUID(); MASK_DEFAULT = 1 << LayerMask.NameToLayer(SceneLayerMask.Terrain); mNMA = mGameObject.GetComponent <NavMeshAgent>(); GameObject root = GameObject.Find("SimplePool/" + mGameObject.name + "/Root"); if (root != null) { mAnim = mGameObject.transform.Find("Root").GetComponent <Animator>(); AnimSpeed(1); } GameObject ap = GameObject.Find("SimplePool/" + mGameObject.name + "/Root/AttackPoint"); if (ap != null) { mAttackPoint = ap.transform; } mRenderers = mGameObject.transform.GetComponentsInChildren <SkinnedMeshRenderer>(); mRigidbody = mGameObject.GetComponent <Rigidbody>(); SetBodyActive(); mDisappearTimer = attr.baseAttr.disappearTime; InitCollider(); BindEffect(); CoroutineController.Instance.StartCoroutine(DisProtected(mProtectedTime)); }
/// <summary> /// ²¥·Å±³¾°ÒôÀÖ /// </summary> /// <param name="canPlay"></param> public void PlayBacksound(string name, bool canPlay) { if (audio.clip != null) { if (name.IndexOf(audio.clip.name) > -1) { if (!canPlay) { audio.Stop(); audio.clip = null; UtilCommon.ClearMemory(); } return; } } if (canPlay) { audio.loop = true; audio.clip = LoadAudioClip(name); audio.Play(); } else { audio.Stop(); audio.clip = null; UtilCommon.ClearMemory(); } }
static int Random(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(float), typeof(float))) { float arg0 = (float)LuaScriptMgr.GetNumber(L, 1); float arg1 = (float)LuaScriptMgr.GetNumber(L, 2); float o = UtilCommon.Random(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2 && LuaScriptMgr.CheckTypes(L, 1, typeof(int), typeof(int))) { int arg0 = (int)LuaScriptMgr.GetNumber(L, 1); int arg1 = (int)LuaScriptMgr.GetNumber(L, 2); int o = UtilCommon.Random(arg0, arg1); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UtilCommon.Random"); } return(0); }
public async Task <ResponseModel> LoginUser(LoginModel loginModel) { ResponseModel result = new ResponseModel(); User user = null; if (!string.IsNullOrWhiteSpace(loginModel.Email)) { user = _userRepo.GetUserByEmailAsync(loginModel.Email, true); } if (user == null) { result.Error = ErrorMessageCode.USER_NOT_FOUND; result.Status = HttpStatusCode.NotFound; return(result); } if (user.IsDeactivate) { result.Error = ErrorMessageCode.USER_IS_DEACTIVATE; result.Status = HttpStatusCode.Forbidden; return(result); } try { var passcode = UtilCommon.GeneratePasscode(loginModel.PassCode, user.Salt); var expireToken = 1; if (passcode.Equals(user.PassCode)) { result.Status = System.Net.HttpStatusCode.OK; LoginApiModel data = new LoginApiModel(); data.IsFirstLogin = user.IsFirstLogin; data.Token = _jwtHandler.Create(user.Id.ToString(), expireToken, user.Role); data.Avatar = UtilCommon.GetDisplayImageUrl(user.Avatar); data.FullName = user.FullName; data.Role = user.Role; data.UserId = user.Id; result.Data = data; await _userRepo.UpdateAsync(user); return(result); } else { result.Error = ErrorMessageCode.PASSWORD_INCORRECT; result.Status = System.Net.HttpStatusCode.NotFound; var date = DateTime.UtcNow; return(result); } } catch (Exception ex) { result.Error = ex.ToString(); result.Status = System.Net.HttpStatusCode.NotImplemented; return(result); } }
private void GetData() { var sw = new System.Diagnostics.Stopwatch(); sw.Start(); if (!isNew) { CdbcConnection con = UtilCommon.getConnection(); string cmdQuery = "SELECT P.PRODUCT_CODE " + " , P.PRODUCT_NAME " + " , P.PRODUCT_PRICE " + " , P.CURRENCY_CODE " + " , P.PRODUCT_SUMMARY " + " , P.CATEGORY_CODE " + " , P.PRODUCT_IMAGE " + " , P.RELEASE_DATE " + " FROM PRODUCTS P " + " WHERE P.PRODUCT_CODE = :PRODUCT_CODE "; CdbcCommand cmd = new CdbcCommand(cmdQuery); cmd.Connection = con; cmd.CommandType = CommandType.Text; CdbcParameter para = new CdbcParameter(":PRODUCT_CODE", Cdbc.Common.Data.Type.CdbcOracleDbType.Varchar2); para.Value = ProductCode; cmd.Parameters.Add(para); DataSetProducts dsProduct = new DataSetProducts(); CdbcDataAdapter myDa = new CdbcDataAdapter(cmd); try { myDa.Fill(dsProduct, dsProduct.PRODUCTS.TableName); if (dsProduct.Tables.Count > 0 && dsProduct.Tables[0].Rows.Count > 0) { DataSetProducts.PRODUCTSRow dr = (DataSetProducts.PRODUCTSRow)dsProduct.PRODUCTS.Rows[0]; txtProductName.Text = UtilCommon.NvlStr(dr.PRODUCT_NAME); txtPrice.Text = UtilCommon.NvlStr(dr.PRODUCT_PRICE); cbCurrency.SelectedValue = UtilCommon.NvlStr(dr.CURRENCY_CODE); txtSummary.Text = UtilCommon.NvlStr(dr.PRODUCT_SUMMARY); cbCategory.SelectedValue = UtilCommon.NvlStr(dr.CATEGORY_CODE); dtReleaseDate.Value = dr.RELEASE_DATE; pictureBox1.Image = UtilCommon.ByteArrayToImage(dr.PRODUCT_IMAGE); } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) ; } } sw.Stop(); this.Text = $"{sw.ElapsedMilliseconds} ms"; }
public async Task <ResponseModel> ChangePasscode(int idUser, ChangePasscodeModel changePasscode) { ResponseModel result = new ResponseModel(); if (!UtilCommon.IsValidPassword(changePasscode.NewPasscode)) { result.Error = ErrorMessageCode.PASSWORD_INVALID; result.Status = System.Net.HttpStatusCode.BadRequest; return(result); } var user = await _userRepo.GetByIdAsync(idUser); if (user == null) { result.Error = ErrorMessageCode.USER_NOT_FOUND; result.Status = System.Net.HttpStatusCode.BadRequest; return(result); } if (!user.PassCode.Equals(UtilCommon.GeneratePasscode(changePasscode.OldPasscode, user.Salt))) { result.Error = ErrorMessageCode.PASSWORD_INVALID; result.Status = System.Net.HttpStatusCode.BadRequest; return(result); } try { string newPasscode = UtilCommon.GeneratePasscode(changePasscode.NewPasscode, user.Salt); user.PassCode = newPasscode; var res = await _userRepo.UpdateAsync(user); if (res != Constants.REPOSITORY_FAILED) { result.Status = System.Net.HttpStatusCode.OK; result.IsSuccess = true; if (user.IsFirstLogin) { user.IsFirstLogin = false; await _userRepo.UpdateAsync(user); } return(result); } else { result.Error = ErrorMessageCode.UPDATE_PASSWORD_FAILED; result.Status = System.Net.HttpStatusCode.InternalServerError; return(result); } } catch (Exception ex) { result.Error = ex.ToString(); result.Status = System.Net.HttpStatusCode.NotImplemented; return(result); } }
static int SetTempVersion(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); UtilCommon.SetTempVersion(arg0); return(0); }
static int GenGUID(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); int o = UtilCommon.GenGUID(); LuaScriptMgr.Push(L, o); return(1); }
static int IsFirstOpen(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); bool o = UtilCommon.IsFirstOpen(); LuaScriptMgr.Push(L, o); return(1); }
static int GetTempVersion(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); string o = UtilCommon.GetTempVersion(); LuaScriptMgr.Push(L, o); return(1); }
static int RemoveData(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); UtilCommon.RemoveData(arg0); return(0); }
static int AppContentPath(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); string o = UtilCommon.AppContentPath(); LuaScriptMgr.Push(L, o); return(1); }
static int ClearChild(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); Transform arg0 = LuaScriptMgr.GetUnityObject <Transform>(L, 1); UtilCommon.ClearChild(arg0); return(0); }
public async Task <int> EditProfile(UserApiModel model, IFormFile uploadedFile, User userEntity) { userEntity = model.ToEntity(userEntity); userEntity.Avatar = UtilCommon.ImageUpload(Constants.UserDataFolderName, uploadedFile, userEntity.Avatar, false); return(await _userRepo.UpdateAsync(userEntity)); }
static int AddLuaPath(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); string arg0 = LuaScriptMgr.GetLuaString(L, 1); UtilCommon.AddLuaPath(arg0); return(0); }
static int GetTime(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); long o = UtilCommon.GetTime(); LuaScriptMgr.Push(L, o); return(1); }
static int GetLocalIPAddress(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 0); string o = UtilCommon.GetLocalIPAddress(); LuaScriptMgr.Push(L, o); return(1); }