public void ViewToModel() { if (ValidateData()) { #region 主表 // this.CurMaster.Code = this.txtCode.Text; this.CurMaster.Year = int.Parse(this.dpLstYear.Text); this.CurMaster.Month = int.Parse(this.dpLstMonth.Text); // this.CurMaster.Descript = this.txtDescript.Text; this.CurMaster.EndTime = UtilClass.ToDateTime(this.txtEndTime.Text); CurMaster.CreateDate = UtilClass.ToDateTime(this.txtEndTime.Text); this.CurMaster.FinanceCostSymbol.Money = UtilClass.ToDecimal(txtFinanceCostSymbolMoney.Text); //if (!string.IsNullOrEmpty(this.hdFinanceCostSymbolAccountTtileTreeID.Value) && // ((this.CurMaster.FinanceCostSymbol.AccountTitle == null) || // (!string.Equals(this.CurMaster.FinanceCostSymbol.AccountTitle.Id, this.hdFinanceCostSymbolAccountTtileTreeID.Value)))) //{ // this.CurMaster.FinanceCostSymbol.AccountTitle = GetAccountTitleTree(this.hdFinanceCostSymbolAccountTtileTreeID.Value); // this.CurMaster.FinanceCostSymbol.AccountTitleCode = this.CurMaster.FinanceCostSymbol.AccountTitle == null ? "" : this.CurMaster.FinanceCostSymbol.AccountTitle.Code; // this.CurMaster.FinanceCostSymbol.AccountTitleName = this.CurMaster.FinanceCostSymbol.AccountTitle == null ? "" : this.CurMaster.FinanceCostSymbol.AccountTitle.Name; //this.CurMaster.FinanceCostSymbol.AccountTitleID = this.CurMaster.FinanceCostSymbol.AccountTitle == null ? "" : this.CurMaster.FinanceCostSymbol.AccountTitle.Id; // } this.CurMaster.BorrowSymbol.Money = UtilClass.ToDecimal(this.txtBorrowSymbolMoney.Text); //if (!string.IsNullOrEmpty(this.hdBorrowSymbolAccountTtileTreeID.Value) && // ((this.CurMaster.BorrowSymbol.AccountTitle == null) || // (!string.Equals(this.CurMaster.BorrowSymbol.AccountTitle.Id, this.hdBorrowSymbolAccountTtileTreeID.Value)))) //{ // this.CurMaster.BorrowSymbol.AccountTitle = GetAccountTitleTree(this.hdBorrowSymbolAccountTtileTreeID.Value); // this.CurMaster.BorrowSymbol.AccountTitleCode = this.CurMaster.BorrowSymbol.AccountTitle == null ? "" : this.CurMaster.BorrowSymbol.AccountTitle.Code; // this.CurMaster.BorrowSymbol.AccountTitleName = this.CurMaster.BorrowSymbol.AccountTitle == null ? "" : this.CurMaster.BorrowSymbol.AccountTitle.Name; // this.CurMaster.BorrowSymbol.AccountTitleID = this.CurMaster.BorrowSymbol.AccountTitle == null ? "" : this.CurMaster.BorrowSymbol.AccountTitle.Id; //} this.CurMaster.HandOnSymbol.Money = UtilClass.ToDecimal(txtHandOnSymbolMoney.Text); //if (!string.IsNullOrEmpty(this.hdHandOnSymbolAccountTtileTreeID.Value) && // ((this.CurMaster.HandOnSymbol.AccountTitle == null) || // (!string.Equals(this.CurMaster.HandOnSymbol.AccountTitle.Id, this.hdHandOnSymbolAccountTtileTreeID.Value)))) //{ // this.CurMaster.HandOnSymbol.AccountTitle = GetAccountTitleTree(this.hdHandOnSymbolAccountTtileTreeID.Value); // this.CurMaster.HandOnSymbol.AccountTitleCode = this.CurMaster.HandOnSymbol.AccountTitle == null ? "" : this.CurMaster.HandOnSymbol.AccountTitle.Code; // this.CurMaster.HandOnSymbol.AccountTitleName = this.CurMaster.HandOnSymbol.AccountTitle == null ? "" : this.CurMaster.HandOnSymbol.AccountTitle.Name; // this.CurMaster.HandOnSymbol.AccountTitleID = this.CurMaster.HandOnSymbol.AccountTitle == null ? "" : this.CurMaster.HandOnSymbol.AccountTitle.Id; //} //this.CurMaster.ProfitSymbol.Money = UtilClass.ToDecimal(txtProfitSymbolMoney.Text); //if (!string.IsNullOrEmpty(this.hdProfitSymbolAccountTtileTreeID.Value) && // ((this.CurMaster.ProfitSymbol.AccountTitle == null) || // (!string.Equals(this.CurMaster.ProfitSymbol.AccountTitle.Id, this.hdProfitSymbolAccountTtileTreeID.Value)))) //{ // this.CurMaster.ProfitSymbol.AccountTitle = GetAccountTitleTree(this.hdProfitSymbolAccountTtileTreeID.Value); // this.CurMaster.ProfitSymbol.AccountTitleCode = this.CurMaster.ProfitSymbol.AccountTitle == null ? "" : this.CurMaster.ProfitSymbol.AccountTitle.Code; // this.CurMaster.ProfitSymbol.AccountTitleName = this.CurMaster.ProfitSymbol.AccountTitle == null ? "" : this.CurMaster.ProfitSymbol.AccountTitle.Name; // this.CurMaster.ProfitSymbol.AccountTitleID = this.CurMaster.ProfitSymbol.AccountTitle == null ? "" : this.CurMaster.ProfitSymbol.AccountTitle.Id; //} #endregion #region 明细 //this.gvDetail.DataSource = this.CurMaster.Details; //this.gvDetail.DataBind(); #endregion } }
/// <summary> /// 处理页面删除行 /// </summary> private void DeleteBill() { object oBill = null; object oTempBill = null; IList lstRemove; if (!string.IsNullOrEmpty(hdPageDeleteBillIDs.Value)) { lstRemove = new ArrayList(); string[] arrRemoveID = hdPageDeleteBillIDs.Value.Split(';'); foreach (string sID in arrRemoveID) { oBill = UtilClass.GetBill(this.BillList, sID);//查找 该ID对应的单据对象 if (oBill != null) { this.BillList.Remove(oBill); oTempBill = UtilClass.GetBill(this.NewBillList, sID);//查找该ID是否为新建单据 如果是 不需要添加到删除集合中 如果不是(历史单据) 需要存放在删除集合中 等待后台删除 if (oTempBill != null) { this.NewBillList.Remove(oTempBill); } else { this.RemoveList.Add(oBill); } } } } hdPageDeleteBillIDs.Value = ""; }
public void RowDataBound(object sender, GridViewRowEventArgs e) { //e.Row.Cells[0]. if (oDataTable != null && oDataTable.Rows.Count > 0 && e.Row.RowType == DataControlRowType.DataRow) { string sRowData = string.Empty; int iRowIndex = e.Row.RowIndex; int iColumnIndex = -1; if (oDataTable.Rows.Count > iRowIndex) { iColumnIndex = UtilClass.GetColumnIndex(this.DestControl, "序号"); if (iColumnIndex > -1) { e.Row.Cells[iColumnIndex].Text = (iRowIndex + 1).ToString(); } sRowData = UtilClass.DataRowToJosn(oDataTable.Rows[iRowIndex]); if (!string.IsNullOrEmpty(sRowData)) { //e.Row.Attributes.Add("Data", sRowData ); //当鼠标停留时更改背景色 e.Row.Attributes.Add("onmouseover", "curBak=this.style.backgroundColor;this.style.color='#116a79';this.style.backgroundColor='#cef97b'"); //当鼠标移开时还原背景色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=curBak;this.style.color='#3a6381'"); e.Row.Attributes["style"] = "Cursor:pointer"; // e.Row.Attributes.Add("onmouseover", string.Format("mouseOver({0})", iRowIndex)); e.Row.Attributes.Add("onclick", string.Format("singleClick({0},decodeComponent('{1}'))", iRowIndex, sRowData)); e.Row.Attributes.Add("ondblclick", string.Format("dbClick({0},decodeComponent('{1}'))", iRowIndex, sRowData)); //e.Row.Attributes.Add("onmouseout", string.Format("mouseOut({0})", iRowIndex)); } } } }
void PlayDust(Vector3 dir) { float angle = UtilClass.GetAngleFromVectorFloat(dir); dust.transform.localRotation = Quaternion.Euler(angle, -90, 0); dust.Play(); }
/// <summary> /// SIGN_OUT /// </summary> /// <param name="context"></param> private void SIGN_OUT(HttpContext context) { try { if (LOGOUT_ACCOUNT(context)) { context.Session.Clear(); context.Session.Abandon(); UtilClass.RemoveCookie(context, "accountToken"); result.msg = Constants.NUMBER_CODE.SUCCESS.ToString(); result.status = Constants.NUMBER_CODE.SUCCESS; } else { result.msg = Constants.NUMBER_CODE.SIGN_OUT_FAID.ToString(); result.status = Constants.NUMBER_CODE.SIGN_OUT_FAID; } } catch (Exception ex) { Logs.SaveError("ERROR SIGN_OUT: " + ex); result.status = Constants.NUMBER_CODE.ERROR_EX; result.msg = Constants.NUMBER_CODE.ERROR_EX.ToString(); } context.Response.Write(JsonConvert.SerializeObject(result)); }
//更新所有设备在线信息为false public static string UpdateAllSensorInfoToFalse() { MySQLDB.InitDb(); //string strResult = ""; MySqlParameter[] parmss = null; string strSQL = ""; bool IsDelSuccess = false; strSQL = "Update tdevice SET status = 'False'"; try { IsDelSuccess = MySQLDB.ExecuteNonQry(strSQL, parmss); if (IsDelSuccess != false) { return("ok"); } else { return("fail"); } } catch (Exception ex) { Console.WriteLine(ex); UtilClass.writeLog(ex.ToString()); return("fail"); } }
public HttpResponseMessage UpdateDevice(DeviceInfo p) { string ip = UtilClass.GetIPAddress(); LogClass.SaveCustomerLog("UpdateDevice: " + JsonConvert.SerializeObject(p) + ",IP " + ip); ResultTracking result = new ResultTracking(); result.msg = "success"; result.status = 100; //try //{ // var publisherInfo = publisher.CheckPublickey(p, version); // if (publisherInfo.status == (int)ERROR_CODDE.SUCCESS) // { // ManagerModel managerModel = new ManagerModel(); // var data = JsonConvert.DeserializeObject<AgencyEntity>(publisherInfo.data.ToString()); // string msg = ""; // result.status = managerModel.AgencyModel.CreateAgency_C2(data, ref msg); // result.msg = msg; // } // else // result = publisherInfo; //} //catch (Exception ex) //{ // LogClass.SaveError("ERROR CreateAgency_C2: " + ex.Message, ex, true); // result.status = (int)ERROR_CODDE.ERROR_EX; // result.msg = ex.Message; //} return(Request.CreateResponse(result)); }
/// <summary> /// 开启socket服务 /// </summary> /// <returns></returns> private bool OpenServer() { try { IPEndPoint myclient = new IPEndPoint(IPAddress.Any, 0); EndPoint myRemote = (EndPoint)(myclient); //初始化服务端IP,设置端口号 IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(ServerIP), ServerPort); ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //配置广播发送socket ServerSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1); //服务端绑定网络地址 ServerSocket.Bind(ipEndPoint); //开始异步接收数据 ServerSocket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref myRemote, new AsyncCallback(OnReceive), myRemote); return(true); } catch (Exception e) { Console.WriteLine(e); UtilClass.writeLog(e.ToString()); return(false); } }
private float timeToDie = 2f; // 타겟이 사라진 케이스에 쓸 것 private void Update() { Vector3 moveDir; if (target != null) { moveDir = (target.transform.position - transform.position).normalized; lastMoveDir = moveDir; } else // 만약 적이 사라졌을때 마지막 방향으로 계속 전진 { moveDir = lastMoveDir; } float moveSpeed = 20f; transform.position += moveDir * moveSpeed * Time.deltaTime; transform.eulerAngles = new Vector3(0, 0, UtilClass.GetAngleFromVector(moveDir)); if ((timeToDie -= Time.deltaTime) <= 0) { Destroy(gameObject); } }
private void CastSpellAttacks() { if (!open && Active) { if (Input.GetKeyDown(KeyCode.Alpha1)) { spellBook.CastSpellMain(0); } if (Input.GetKeyDown(KeyCode.Alpha2)) { spellBook.CastSpellMain(1); } if (Input.GetKeyDown(KeyCode.Alpha3)) { spellBook.CastSpellMain(2); } } if (spellBook.castingProgess) { state = State.Casting; StartCoroutine(UtilClass.Wait(0.5f, () => state = State.Normal)); spellBook.castingProgess = false; } else { state = State.Normal; } }
private void PhysicalAttack() { if (Input.GetMouseButtonDown(0) && Active && open == false) { state = State.Attack; Vector3 mousePosition = UtilClass.GetMouseWorldPosition(); Vector3 mouseDir = (mousePosition - transform.position).normalized; int dir = BasicAttackOffset(mousePosition); //Debug.Log(lastMoveDir); animationManager.AttackAnimation(lastMoveDir); animationManager1.AttackAnimation(lastMoveDir); animationManager2.AttackAnimation(lastMoveDir); animationManager3.AttackAnimation(lastMoveDir); animationManager4.AttackAnimation(lastMoveDir); animationManager.MyAnimator.SetTrigger("Attack"); animationManager1.MyAnimator.SetTrigger("Attack"); animationManager2.MyAnimator.SetTrigger("Attack"); animationManager3.MyAnimator.SetTrigger("Attack"); animationManager4.MyAnimator.SetTrigger("Attack"); StartCoroutine(UtilClass.Wait(0.45f, () => BasicAttack(dir, mousePosition, mouseDir))); StartCoroutine(UtilClass.Wait(0.5f, () => state = State.Normal)); } }
public string GetRate(object ActualMoney, object BudgetMoney) { decimal dActualMoney = UtilClass.ToDecimal(ActualMoney); decimal dBudgetMoney = UtilClass.ToDecimal(BudgetMoney); return(dActualMoney == 0 ? "--" : (Math.Round(dBudgetMoney / dActualMoney, 2) * 100).ToString()); }
// void Start(){ // enemy = gameObject.GetComponent<Enemy>(); // playerTransform = gameobject.GetComponent<Transform>(); // } void Update() { if (Input.GetKeyDown(KeyCode.M)) { enemy.Create(playerTransform.position + UtilClass.GetRandomDir() * Random.Range(100f, 200f)); } }
/// <summary> /// 删除主表 /// </summary> public void DeleteMaster() { Model.DeletePaymentMaster(CurMaster); chkIsRefresh.Checked = true; //UtilClass.ExecuteScript(this, "parent.window.showList(true);"); UtilClass.ExecuteScript(this, "alert('删除成功'); parent.window.Operate('back');"); }
public void InitalControl() { Control[] arrControl = new Control[] { this.txtCreateDate, this.txtRemark, this.cmbPaymentType, this.txtBankAcctNo, this.txtBankNo }; UtilClass.SetControl(arrControl, PageState); //this.txtAccountTitle.ReadOnly = true; //this.txtOrgName.ReadOnly = true; }
private void Update() { if (gameObject.activeSelf) { transform.position = UtilClass.GetMouseWorldPos(); } }
private void Awake() { Instance = this; UtilClass.InitializeUtilClass(); grid = new GridXZ <GridObject>(StartTransform, Width, Height, CellSize, StartTransform.position, (GridXZ <GridObject> g, int x, int z) => new GridObject(g, x, z)); }
protected void btnSave_Click(object sender, EventArgs e) { string id = Request.QueryString["Id"].ToString(); PaymentOrderMaster master = model.GetPaymentOrderById(id); PaymentOrderDetial dtl = new PaymentOrderDetial(); if (txtIdHidden.Value != "") { dtl = model.GetPaymentOrderDetailById(txtIdHidden.Value); } dtl.Money = Convert.ToDecimal(txtMoney.Text); dtl.PaymentItemName = txtPaymentItemName.Text; dtl.Describe = this.txtDescribe.Text; dtl.Master = master; master.Money = dtl.Money; foreach (PaymentOrderDetial oDetail in master.Details) { master.Money += oDetail.Money; } model.SaveOrUpdate(dtl); // master.Money += dtl.PaymentMoney; // model.SaveOrUpdate(master); SumMoney(); UtilClass.MessageBox(this, "保存成功!"); this.GridViewSource1.GetData(); }
protected void btnDelete_Click(object sender, EventArgs e) { try { string[] idlst = txtIdListHidden.Value.Split(new char[] { '|' }); ObjectQuery oq = new ObjectQuery(); Disjunction dis = new Disjunction(); foreach (string id in idlst) { dis.Add(Expression.Eq("Id", id)); } oq.AddCriterion(dis); IList <PaymentOrderDetial> list = model.QueryDetial(oq); if (model.Delete(list as IList)) { UtilClass.MessageBox(this, "删除成功!"); GridViewSource1.GetData(); SumMoney(); Clear(); } else { UtilClass.MessageBox(this, "删除失败!"); } } catch (Exception) { UtilClass.MessageBox(this, "操作失误,请重试!"); } }
public void InitalControl() { Control[] arrControl = new Control[] { this.txtCreateDate, this.cmbGatheringType, this.txtRemark }; UtilClass.SetControl(arrControl, PageState); //this.txtAccountTitle.ReadOnly = true; //this.txtOrgName.ReadOnly = true; }
private void EXCEPT_MONEY_AGENCY(HttpContext context) { try { if (context.Session["EXCEPT_MONEY_AGENCY"] == null || (DateTime.Now - (DateTime)context.Session["EXCEPT_MONEY_AGENCY"]).TotalMilliseconds > Constants.TIME_REQUEST) { string json = context.Request.Form["json"]; if (!string.IsNullOrEmpty(json)) { ExceptMoneyAgency jsonData = null; try { jsonData = JsonConvert.DeserializeObject <ExceptMoneyAgency>(json); } catch (Exception) { result.status = Constants.NUMBER_CODE.ERROR_EX; result.msg = "Sai thông tin nhập vào"; context.Response.Write(JsonConvert.SerializeObject(result)); return; } if (jsonData != null) { //jsonData.UwinID = accountInfo.MasterID; jsonData.Key = Constants.KEY_SQL; jsonData.IP = UtilClass.GetIPAddress(); jsonData.Reason = "Tổng đại lý thu hồi: " + jsonData.Amount; //Logs.SaveLog(JsonConvert.SerializeObject(jsonData)); PayloadApi p = new PayloadApi() { clientIP = UtilClass.GetIPAddress(), data = Encryptor.EncryptString(JsonConvert.SerializeObject(jsonData), Constants.API_SECRETKEY) }; var responseData = UtilClass.SendPost(JsonConvert.SerializeObject(p), Constants.API_URL + "api/v1/Agency/ExceptMoneyAgency"); context.Response.Write(responseData); return; } } } else { result.status = Constants.NUMBER_CODE.ERROR_CONNECT_SERVER; result.msg = "Thao tác quá nhanh! vui lòng thử lại"; } } catch (Exception ex) { Logs.SaveError("ERROR EXCEPT_MONEY_AGENCY: " + ex); result.status = Constants.NUMBER_CODE.ERROR_EX; result.msg = Constants.NUMBER_CODE.ERROR_EX.ToString(); } finally { context.Session["EXCEPT_MONEY_AGENCY"] = DateTime.Now; } context.Response.Write(JsonConvert.SerializeObject(result)); }
/// <summary> /// LOGOUT_ACCOUNT Clear all cookie user /// </summary> /// <param name="context"></param> /// <returns></returns> public static bool LOGOUT_ACCOUNT(HttpContext context) { try { var account = GetAccountInfo(context); if (account != null) { Model.ManagerDAO managerDao = new Model.ManagerDAO(); int r = managerDao.AccountModel.LoginOut(account.Token); if (r == (int)Constants.NUMBER_CODE.SUCCESS) { return(true); } else { return(false); } } else { context.Session["account"] = null; UtilClass.RemoveCookie(context, "accountToken"); } return(true); } catch (Exception ex) { Logs.SaveError("ERROR LOGOUT_ACCOUNT: " + ex); return(false); } }
//Lägga till sig på listan - digistudent public Task AddWaitingListItem(string jsonString) { var json = JsonConvert.DeserializeObject <ProtocolMessage>(jsonString); if (json.Command == "Add") { if ((waitingList.SingleOrDefault(p => p.Alias == json.Alias && p.ClassroomName == json.ClassroomName)) == null) { waitingList.Add( new ProblemVM { Alias = json.Alias, Description = UtilClass.ParseHtml(json.Description), Location = UtilClass.ParseHtml(json.Location), ClassroomName = json.ClassroomName, Language = json.PType.ToString(), Time = DateTime.Now } ); repository.SaveProblemToDigiBase(json); string jsonList = JsonConvert.SerializeObject(waitingList.Where(c => c.ClassroomName == json.ClassroomName)); return(Clients.Group(json.ClassroomName).InvokeAsync("onUpdateWaitingListItem", jsonList)); } } return(Task.FromResult <object>(null)); //ingenting händer }
private void RESET_PASSWORD(HttpContext context) { try { if (context.Session["resetpassword"] != null) { var data = (ResetPasswordUser)context.Session["resetpassword"]; string password = context.Request.Form["password"]; if (string.IsNullOrEmpty(password)) { result.status = Constants.NUMBER_CODE.PASS_IS_NULL; result.msg = "Nhập mật khẩu mới!"; context.Response.Write(JsonConvert.SerializeObject(result)); return; } else { if (UtilClass.IsUnicode(password)) { result.status = Constants.NUMBER_CODE.PASS_INVALID; result.msg = "Nhập mật khẩu không được có bỏ dấu!"; context.Response.Write(JsonConvert.SerializeObject(result)); return; } } int code = manage.AccountModel.ResetPassword(data.loginId, data.loginType, password); if (code == 0) { string link = UtilClass.GetWebAppRoot() + "/login.aspx"; bool s = SendMailUser("Thiết lập mật khẩu thành công", "Thiết lập mật khẩu thành công<br/>Email: " + data.loginId + "<br/>Link đăng nhập: <a href='" + link + "'>" + link + "</a>", data.loginId); if (s) { result.status = Constants.NUMBER_CODE.SUCCESS; result.msg = "Cập nhật mật khẩu mới thành công"; context.Session.Clear(); context.Session.Abandon(); UtilClass.RemoveCookie(context, "accountToken"); } else { result.status = Constants.NUMBER_CODE.SEND_MAIL_FAILD; result.msg = "Lỗi hệ thống vui lòng thử lại!"; } } } else { result.status = Constants.NUMBER_CODE.RESET_PASSWORD_TIMEOUT; result.msg = "Lỗi hệ thống vui lòng thử lại!"; } } catch (Exception ex) { Logs.SaveError("ERROR CREATE_ACCOUNT: " + ex); result.status = Constants.NUMBER_CODE.ERROR_EX; result.msg = Constants.NUMBER_CODE.ERROR_EX.ToString(); } context.Response.Write(JsonConvert.SerializeObject(result)); }
private void _DownloadFile() { _currentProgramInDownloading = _downloadablePrograms.Dequeue(); var currentDirectoryPathAndCurrentFile = UtilClass.CreateDirectoryPathWithProgramFile(_currentDirectoryPath, _currentProgramInDownloading.DownloadLink); DownloadFilesOnSpecificDirectory(_currentProgramInDownloading.DownloadLink, currentDirectoryPathAndCurrentFile); }
/// <summary> /// Login account by email , phone /// </summary> /// <param name="context"></param> //private void LOGIN(HttpContext context) //{ // string id = context.Request.Form["id"]; // string pass = context.Request.Form["pass"]; // string captcha = context.Request.Form["captcha"]; // try // { // bool remember = Convert.ToBoolean(context.Request.Form["remember"]); // if (string.IsNullOrEmpty(id)) // { // result.status = Constants.NUMBER_CODE.USERNAME_IS_NULL; // result.msg = "Vui lòng nhập ID!"; // } // else if (string.IsNullOrEmpty(pass)) // { // result.status = Constants.NUMBER_CODE.PASS_IS_NULL; // result.msg = "Vui lòng nhập mật khẩu!"; // } // else if (string.IsNullOrEmpty(captcha)) // { // result.status = Constants.NUMBER_CODE.CAPTCHA_NULL; // result.msg = "Vui lòng nhập captcha!"; // } // else // { // id = id.Trim(); // int? code = 0; // if(captcha != context.Session["captcha"].ToString()) // { // result.status = Constants.NUMBER_CODE.CAPTCHA_ERROR; // result.msg = "Mã captcha không đúng!"; // } // else // { // var userData = manage.AccountModel.LoginID(new Model.LoginInfo() // { // deviceId = "", // deviceName = "", // ip = UtilClass.GetIPAddress(), // loginId = id, // loginType = (byte)Constants.LOGIN_TYPE.SINGLEID, // password = pass // }, ref code); // if (code == 1)//login success // { // context.Session["account"] = userData; // if (remember) // { // UtilClass.AddCookie(context, "accountToken", userData.Token); // } // string menuId = ""; // string menuRule = ""; // int groupID = 0; // int r = manage.AccountModel.GetRuleByAccountId(userData.AccountId, ref menuId, ref menuRule, ref groupID); // if (r == 0) // { // userData.GroupID = groupID; // context.Session["menuId"] = JsonConvert.DeserializeObject<List<int>>(menuId); // context.Session["menuRule"] = JsonConvert.DeserializeObject<List<List<int>>>(menuRule); // context.Session["account"] = userData; // } // result.status = Constants.NUMBER_CODE.SUCCESS; // result.msg = "Đăng nhập thành công"; // if (groupID == 6) // result.data = "Page.aspx?m=9"; // else // result.data = "Dashboard.aspx"; // } // else // { // result.status = (Constants.NUMBER_CODE)code; // result.msg = "Đăng nhập không thành công!"; // } // } // } // } // catch (Exception ex) // { // Logs.SaveError("ERROR LOGIN: "******"\r\n"+ ex); // result.status = Constants.NUMBER_CODE.ERROR_EX; // result.msg = Constants.NUMBER_CODE.ERROR_EX.ToString(); // } // context.Response.Write(JsonConvert.SerializeObject(result)); //} public static UserInfo GetUserByToken(string token) { try { if (!string.IsNullOrEmpty(token)) { ManagerDAO manage = new ManagerDAO(); int? code = 0; var userData = manage.AccountModel.LoginWithToken(token, Lib.UtilClass.GetIPAddress(), ref code); if (code == 1) { var json = new { ///Master id = uwinid uwinID = userData.MasterID }; PayloadApi p = new PayloadApi() { clientIP = UtilClass.GetIPAddress(), data = Encryptor.EncryptString(JsonConvert.SerializeObject(json), Constants.API_SECRETKEY) }; var responseData = UtilClass.SendPost(JsonConvert.SerializeObject(p), Constants.API_URL + "api/v1/Agency/GetAgencyInfo"); Logs.SaveLog("responseData GetAgencyInfo:" + JsonConvert.SerializeObject(responseData)); ResultLoginAgency resGETInfoAgency = JsonConvert.DeserializeObject <ResultLoginAgency>(responseData); if (resGETInfoAgency.status != 0) { HttpContext.Current.Session.Clear(); HttpContext.Current.Session.Abandon(); UtilClass.RemoveCookie(HttpContext.Current, "accountToken"); return(null); } string dataInfoAgency = Encryptor.DecryptString(resGETInfoAgency.data, Constants.API_SECRETKEY); Logs.SaveLog("responseData GetAgencyInfo:" + dataInfoAgency); userData.AgencyInfo = JsonConvert.DeserializeObject <AgencyInfoEntity>(dataInfoAgency); HttpContext.Current.Session["account"] = userData; string menuId = ""; string menuRule = ""; int groupID = 0; int r = manage.AccountModel.GetRuleByAccountId(userData.AccountId, ref menuId, ref menuRule, ref groupID); if (r == 0) { userData.GroupID = groupID; HttpContext.Current.Session["menuId"] = JsonConvert.DeserializeObject <List <int> >(menuId); HttpContext.Current.Session["menuRule"] = JsonConvert.DeserializeObject <List <List <int> > >(menuRule); HttpContext.Current.Session["account"] = userData; } return(userData); } } return(null); } catch (Exception) { return(null); } }
public IActionResult FindClassroom(ClassroomDigiStudentVM viewModel) { if (!ModelState.IsValid) { var model = new HomeIndexVM { LoggedIn = User.Identity.IsAuthenticated, DigiStudent = new HomeIndexFindClassroomVM { Alias = viewModel.Alias }, CreateClassroom = new HomeIndexCreateClassroomVM(), DigiMaster = new HomeIndexLoginVM(), Register = new AccountRegisterVM() }; TempData["alias"] = viewModel.Alias; TempData["findMessage"] = "Fyll i alla fält"; return(RedirectToAction(nameof(Index), model)); } if (viewModel.Alias.Length > 32) { var model = new HomeIndexVM { LoggedIn = User.Identity.IsAuthenticated, DigiStudent = new HomeIndexFindClassroomVM { Alias = viewModel.Alias }, CreateClassroom = new HomeIndexCreateClassroomVM(), DigiMaster = new HomeIndexLoginVM(), Register = new AccountRegisterVM() }; TempData["alias"] = viewModel.Alias; TempData["findMessage"] = "Ditt alias är för långt, vänligen ange ett kortare alias"; return(RedirectToAction(nameof(Index), model)); } var form = int.Parse(Request.Form["DropDownListKlasser"]); if ((DigiHub.loggedInList.Values.SingleOrDefault(p => p.Alias == viewModel.Alias && p.ClassroomName == repository.GetClassroomById(form))) != null) { var model = new HomeIndexVM { LoggedIn = User.Identity.IsAuthenticated, DigiStudent = new HomeIndexFindClassroomVM { Alias = viewModel.Alias }, CreateClassroom = new HomeIndexCreateClassroomVM(), DigiMaster = new HomeIndexLoginVM(), Register = new AccountRegisterVM() }; TempData["alias"] = viewModel.Alias; TempData["findMessage"] = "Alias i detta klassrum är upptaget"; return(RedirectToAction(nameof(Index), model)); } return(RedirectToAction("DigiStudent", "Classroom", new { alias = UtilClass.ParseHtml(viewModel.Alias), classroomId = form })); }
public static bool Existed(GridView oGrid) { if (oGrid != null) { int iColumnIndex = UtilClass.GetColumnIndex(oGrid, headName); return(iColumnIndex > -1); } return(false); }
private void Form1_Load(object sender, EventArgs e) { programDownloadList.DisplayMember = Constants.DisplayMemberProgramName; _AddItemsToCheckedListFromConfigurationFile(UtilClass.FormatDirectoryPathAndAddFileToPath(_appCurrentDirectory, Constants.ConfigurationFile)); _webClientService.RegistryDownloadProgressBar(downloadProgressBar); _webClientService.RegistryDownloadProgressLabel(progressLbl); _webClientService.RegistryDownloadableProgramsCheckedList(programDownloadList); _webClientService.RegistryStopButton(stopDownloadingBtn); }
public static bool Delete(GridView oGrid) { if (Existed(oGrid)) { int iColumnIndex = UtilClass.GetColumnIndex(oGrid, headName); oGrid.Columns.RemoveAt(iColumnIndex); } return(true); }