public async Task <ServiceResponse <UserModel> > CreateUserAsync(UserModel model) { try { var createResult = await _userService.CreateUserAsync(ConvertExtension.Convert <ApplicationUser>(model)); if (createResult.IsSuccessful) { var asd = await _userService.GenerateEmailConfirmationTokenAsync(createResult.Data); var callbackUrl = "/Account/ConfirmEmail?userId= " + createResult.Data.Id + "&code=" + asd.Data + ""; //var callbackUrl = Url.Page("/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); await _emailService.SendEmailAsync(model.Email, "Üyelik Aktifleştirme", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); } return(new ServiceResponse <UserModel>()); } catch (Exception ex) { throw; } }
private static int RunCommand(DecodePacketOptions opts) { byte[] data = !String.IsNullOrEmpty(opts.Hex) ? opts.Hex.FromHexString() : !String.IsNullOrEmpty(opts.Base64) ? opts.Base64.FromBase64String() : null; byte[] nwkSKey = null; byte[] appSKey = null; byte[] appKey = null; if (!String.IsNullOrEmpty(opts.NwkSKey)) { nwkSKey = ConvertExtension.FromHexString(opts.NwkSKey); } if (!String.IsNullOrEmpty(opts.AppSKey)) { appSKey = ConvertExtension.FromHexString(opts.AppSKey); } if (!String.IsNullOrEmpty(opts.AppKey)) { appKey = ConvertExtension.FromHexString(opts.AppKey); } PHYPayload packet = new PHYPayload(data, nwkSKey, appSKey, appKey, 0); Console.WriteLine(packet.ToVerboseString()); return(0); }
public int Update <T>(T entity) where T : class { dbcontext.Set <T>().Attach(entity); Hashtable props = ConvertExtension.GetPropertyInfo <T>(entity); foreach (string item in props.Keys) { object value = dbcontext.Entry(entity).Property(item).CurrentValue; if (value != null) { if (value.ToString() == " ") { dbcontext.Entry(entity).Property(item).CurrentValue = null; } dbcontext.Entry(entity).Property(item).IsModified = true; } else { if (item == "AlertDateTime") { dbcontext.Entry(entity).Property(item).CurrentValue = null; dbcontext.Entry(entity).Property(item).IsModified = true;//等于null也置空,比如下次提醒日期清空 } } } return(dbTransaction == null?this.Commit() : 0); }
public DataTable FindTable(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) { using (var dbConnection = dbcontext.Database.Connection) { //此处,分页支持3种库 StringBuilder builder = new StringBuilder(); switch (DbHelper.DbType) { case DatabaseType.SqlServer: builder.Append(new DatabasePage().SqlPageSql(strSql, dbParameter, orderField, isAsc, pageSize, pageIndex)); break; case DatabaseType.MySql: builder.Append(new DatabasePage().MySqlPageSql(strSql, dbParameter, orderField, isAsc, pageSize, pageIndex)); break; case DatabaseType.Oracle: builder.Append(new DatabasePage().OraclePageSql(strSql, dbParameter, orderField, isAsc, pageSize, pageIndex)); break; default: throw new Exception("数据库类型目前不支持!"); } total = Convert.ToInt32(new DbHelper(dbConnection).ExecuteScalar(CommandType.Text, "Select Count(1) From (" + strSql + ") As t", dbParameter)); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, builder.ToString(), dbParameter); DataTable resultTable = ConvertExtension.IDataReaderToDataTable(IDataReader); resultTable.Columns.Remove("rowNum"); return(resultTable); } }
public IEnumerable <T> FindList <T>(Expression <Func <T, bool> > condition, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) where T : class, new() { StringBuilder sb = new StringBuilder(); string strSql = string.Format("SELECT * From {0} Where {1} ", typeof(T).GetMappingAttributeName(), ExpressionToSql.GetWhereByLambda(condition));//test1 sb.AppendFormat(strSql); if (pageIndex == 0) { pageIndex = 1; } int num = (pageIndex - 1) * pageSize; int num1 = (pageIndex) * pageSize; string OrderBy = ""; if (!string.IsNullOrEmpty(orderField)) { if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0) { OrderBy = " Order By " + orderField; } else { OrderBy = " Order By " + orderField + " " + (isAsc ? "ASC" : "DESC"); } } else { OrderBy = " order by (select 0 )"; } sb.Append(OrderBy); sb.Append(" limit " + num + "," + pageSize + ""); total = Convert.ToInt32(this.FindObject("Select Count(1) From (" + strSql + ") As ttt")); return(ConvertExtension.IDataReaderToList <T>(DatabaseCommon.ExecuteDataReader(this.dbConnection, sb.ToString()))); }
public List <T> FindListTop <T>(int top) where T : new() { StringBuilder strSql = DatabaseCommon.SelectTopSql <T>(top); IDataReader dr = DatabaseCommon.ExecuteDataReader(this.dbConnection, strSql.ToString()); return(ConvertExtension.IDataReaderToList <T>(dr)); }
//分页List查询 public IEnumerable <T> FindList <T>(int pageIndex, int pageSize, string orderField, bool isAsc, out int totalCount) where T : class, new() { StringBuilder sb = new StringBuilder(); string strSql = string.Format("SELECT * From {0} ", typeof(T).GetMappingAttributeName()); sb.AppendFormat(strSql); pageIndex = pageIndex == 0 ? 1 : pageIndex; int startNum = (pageIndex - 1) * pageSize; string OrderBy = ""; if (!orderField.IsNullEmpty()) { if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0) { OrderBy = " Order By " + orderField; } else { OrderBy = " Order By " + orderField + " " + (isAsc ? "ASC" : "DESC"); } } else { OrderBy = " order by (select 0 )"; } sb.Append(OrderBy); sb.AppendFormat(" limit {0},{1} ", startNum, pageSize); totalCount = this.FindObject("Select Count(1) From (" + strSql + ") As ttt").ToInt(); return(ConvertExtension.IDataReaderToList <T>(DatabaseCommon.ExecuteDataReader(this.dbConnection, sb.ToString()))); }
public IEnumerable <T> FindList <T>(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) where T : class { using (var dbConnection = Connection) { StringBuilder sb = new StringBuilder(); if (pageIndex == 0) { pageIndex = 1; } int num = (pageIndex - 1) * pageSize; int num1 = (pageIndex) * pageSize; string OrderBy = ""; if (!string.IsNullOrEmpty(orderField)) { if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0) { OrderBy = "Order By " + orderField; } else { OrderBy = "Order By " + orderField + " " + (isAsc ? "ASC" : "DESC"); } } else { OrderBy = "order by (select 0 )"; } sb.Append(strSql + OrderBy); sb.Append(" limit " + num + "," + pageSize + ""); total = Convert.ToInt32(new DbHelper(dbConnection).ExecuteScalar(CommandType.Text, "Select Count(1) From (" + strSql + ") As t", dbParameter)); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, sb.ToString(), dbParameter); return(ConvertExtension.IDataReaderToList <T>(IDataReader)); } }
public DataTable FindTable(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) { StringBuilder sb = new StringBuilder(); if (pageIndex == 0) { pageIndex = 1; } int num = (pageIndex - 1) * pageSize; int num1 = (pageIndex) * pageSize; string OrderBy = ""; if (!string.IsNullOrEmpty(orderField)) { if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0) { OrderBy = " Order By " + orderField; } else { OrderBy = " Order By " + orderField + " " + (isAsc ? "ASC" : "DESC"); } } else { OrderBy = " order by (select 0 )"; } sb.Append(strSql + OrderBy); sb.Append(" limit " + num + "," + pageSize + ""); total = Convert.ToInt32(ExecuteScalar("Select Count(1) From (" + strSql + ") As ttt", dbParameter)); var IDataReader = DatabaseCommon.ExecuteDataReader(this.dbConnection, sb.ToString(), dbParameter); DataTable resultTable = ConvertExtension.IDataReaderToDataTable(IDataReader); return(resultTable); }
public DataTable FindTable(string strSql, params DbParameter[] dbParameters) { using (var conn = DbContext.Database.Connection) { var reader = new DbHelper(conn).ExecuteReader(CommandType.Text, strSql, dbParameters); return(ConvertExtension.IDataReaderToDataTable(reader)); } }
public DataTable FindTable(string strSql, MySqlParameter[] MySqlParameter) { using (var dbConnection = Connection) { var IDataReader = DbHelperMySQL.ExecuteReader(strSql, MySqlParameter); return(ConvertExtension.IDataReaderToDataTable(IDataReader)); } }
public DataTable FindTable(string strSql, DbParameter[] dbParameter) { using (var dbConnection = Connection) { var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToDataTable(IDataReader)); } }
/// <summary> /// 执行sql语句,获取一个DataTable /// </summary> /// <param name="strSql"></param> /// <param name="dbParameter"></param> /// <returns></returns> public DataTable FindTable(string strSql, DbParameter[] dbParameter) { using (var dbConnection = Dbcontext.Database.Connection) { var dataReader = SqlHelper.ExecuteReader(dbConnection, CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToDataTable(dataReader)); } }
public IEnumerable <T> FindList <T>(string strSql, DbParameter[] dbParameter) where T : class, new() { using (var dbConnection = dbcontext.Database.Connection) { var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToList <T>(IDataReader)); } }
public IEnumerable <T> FindList <T>(string strSql, params DbParameter[] dbParameters) where T : class { using (var conn = DbContext.Database.Connection) { var reader = new DbHelper(conn).ExecuteReader(CommandType.Text, strSql, dbParameters); return(ConvertExtension.IDataReaderToList <T>(reader)); } }
public async Task <IEnumerable <T> > FindList <T>(string strSql, DbParameter[] dbParameter) where T : class { using (var dbConnection = dbcontext.Database.GetDbConnection()) { var IDataReader = await new DbHelper(dbConnection).ExecuteReadeAsync(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToList <T>(IDataReader)); } }
public DataTable FindTable(string strSql, DbParameter[] dbParameter) { using (var dbConnection = dbcontext.Database.Connection) { strSql = strSql.Replace("@", "?"); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToDataTable(IDataReader)); } }
public string ConvertToString(string fieldName, IFormatProvider provider) { Field f = this.GetField(fieldName); switch (f.FieldType) { case FieldType.Text: return(this[f].ToString()); case FieldType.Memo: return(this[f].ToString()); case FieldType.Select: List <string> coll = (List <string>)f.Data; int idx = (int)this[f]; return(idx == -1 ? string.Empty : coll[idx]); case FieldType.Number: decimal n = Convert.ToDecimal(this[f]); return(provider == null?n.ToString() : n.ToString(provider)); case FieldType.List: return(ConvertExtension.ToString(((ListData)this[fieldName]).Objects, ";")); case FieldType.Boolean: bool b = Convert.ToBoolean(this[f]); return(provider == null?b.ToString() : b.ToString(provider)); case FieldType.Url: return(this[f].ToString()); case FieldType.Date: DateTime d = Convert.ToDateTime(this[f]); return(provider == null?d.ToString() : d.ToString(provider)); case FieldType.Table: break; case FieldType.Image: break; case FieldType.Rating: decimal r = Convert.ToDecimal(this[f]); return(provider == null?r.ToString() : r.ToString(provider)); case FieldType.Reference: return(this[f].ToString()); default: throw new Exception("Invalid value for FieldType"); } return(string.Empty); }
public async Task <IEnumerable <DataDto> > GetByLine(int line) { var response = await _httpClient.GetAsync( $"https://api.um.warszawa.pl/api/action/busestrams_get/?resource_id=f2e5503e-927d-4ad3-9500-4ab9e55deb59&apikey={_apiOptions.Value.Key}&type={_apiOptions.Value.Type}&line={line}"); var myData = ConvertExtension.JsonConverterExtension(await ConvertExtension.GetDataFromUrlAsString(response)); var returnValues = myData.Select(Mapper.MapDataToDto).ToList(); return(returnValues); }
public List <T> FindListTop <T>(int top, string propertyName, object propertyValue) where T : new() { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat("SELECT * FROM {0} WHERE 1=1", typeof(T).GetMappingAttributeName()); strSql.Append(" AND " + propertyName + " = " + DatabaseCommon.DbParmCharacter + propertyName); strSql.Append(" limit " + top); IDataReader dr = DatabaseCommon.ExecuteDataReader(this.dbConnection, strSql.ToString(), DbParameters.CreateDbParameter(propertyName, propertyValue)); return(ConvertExtension.IDataReaderToList <T>(dr)); }
public IEnumerable <T> FindList <T>(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) where T : class { using (var dbConnection = dbcontext.Database.Connection) { StringBuilder sb = new StringBuilder(); sb.Append(new DatabasePage().SqlPageSql(strSql, dbParameter, orderField, isAsc, pageSize, pageIndex)); total = Convert.ToInt32(new DbHelper(dbConnection).ExecuteScalar(CommandType.Text, "Select Count(1) From (" + strSql + ") t", dbParameter)); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, sb.ToString(), dbParameter); return(ConvertExtension.IDataReaderToList <T>(IDataReader)); } }
public int Update1 <T>(T entity) where T : class { dbcontext.Set <T>().Attach(entity); Hashtable props = ConvertExtension.GetPropertyInfo <T>(entity); foreach (string item in props.Keys) { dbcontext.Entry(entity).Property(item).IsModified = true; } return(dbTransaction == null?this.Commit() : 0); }
public List <T> FindListTop <T>(int top, string WhereOrderSql, params DbParameter[] parameters) where T : new() { StringBuilder strSql = new StringBuilder(); strSql.AppendFormat("SELECT * FROM {0} ", typeof(T).GetMappingAttributeName()); strSql.Append("WHERE True " + WhereOrderSql); strSql.Append(" limit " + top); IDataReader dr = DatabaseCommon.ExecuteDataReader(this.dbConnection, strSql.ToString(), parameters); return(ConvertExtension.IDataReaderToList <T>(dr)); }
public async Task <DataDto> GetAsync(int line, string brigade) { var data = _dataRepository.Get(line, brigade); var response = await _httpClient.GetAsync( $"https://api.um.warszawa.pl/api/action/busestrams_get/?resource_id=f2e5503e-927d-4ad3-9500-4ab9e55deb59&apikey={_apiOptions.Value.Key}&type={_apiOptions.Value.Type}&line={data.Line}&brigade={data.Brigade}"); var myData = ConvertExtension.JsonConverterExtension(await ConvertExtension.GetDataFromUrlAsString(response)); var returnValue = myData.Select(Mapper.MapDataToDto).FirstOrDefault(); return(returnValue); }
public DataTable FindTable(string strSql, DbParameter[] dbParameter) { using (var dbConnection = Connection) { //执行超时时间,刘西 修改于 2017.12.8 var IDataReader = new DbHelper(dbConnection) { CommandTimeout = CommandTimeout }.ExecuteReader(CommandType.Text, strSql, dbParameter); return(ConvertExtension.IDataReaderToDataTable(IDataReader)); } }
public DataTable FindTable(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) { using (var dbConnection = dbcontext.Database.Connection) { strSql = strSql.Replace("@", "?"); StringBuilder sb = new StringBuilder(); sb.Append(new DatabasePage().MySqlPageSql(strSql, dbParameter, orderField, isAsc, pageSize, pageIndex)); total = Convert.ToInt32(new DbHelper(dbConnection).ExecuteScalar(CommandType.Text, "Select Count(1) From (" + strSql + ") t ", dbParameter)); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, sb.ToString(), dbParameter); DataTable resultTable = ConvertExtension.IDataReaderToDataTable(IDataReader); return(resultTable); } }
public DataTable FindTable(string strSql, DbParameter[] dbParameter, string orderField, bool isAsc, int pageSize, int pageIndex, out int total) { using (var dbConnection = dbcontext.Database.Connection) { StringBuilder sb = new StringBuilder(); if (pageIndex == 0) { pageIndex = 1; } int num = (pageIndex - 1) * pageSize; int num1 = (pageIndex) * pageSize; var OrderBy = string.Empty; var rowNumColName = "rowNum"; if (!string.IsNullOrEmpty(orderField)) { if (orderField.ToUpper().IndexOf("ASC") + orderField.ToUpper().IndexOf("DESC") > 0) { OrderBy = "Order By " + orderField; } else { OrderBy = "Order By " + orderField + " " + (isAsc ? "ASC" : "DESC"); } } else { OrderBy = "order by (select 0)"; } if (DbHelper.DbType == DatabaseType.MySql) { sb.AppendFormat("Select * From ({0}) As T {1} LIMIT {2},{3}", strSql, OrderBy, num, num1); } else { sb.AppendFormat("Select * From (Select ROW_NUMBER() Over ({0})", OrderBy); sb.AppendFormat(" As {0}, * From ({1}) As T ) As N Where {0} > {2} And {0} <= {3}", rowNumColName, strSql, num, num1); } total = Convert.ToInt32(new DbHelper(dbConnection).ExecuteScalar(CommandType.Text, string.Format("Select Count(1) From ({0}) As t", strSql), dbParameter)); var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, sb.ToString(), dbParameter); DataTable resultTable = ConvertExtension.IDataReaderToDataTable(IDataReader); if (resultTable.Columns.Contains(rowNumColName)) { resultTable.Columns.Remove(rowNumColName); } return(resultTable); } }
private string GetTextValue(Control c) { Type t = c.GetType(); if (t == typeof(KryptonTextBox)) { return(((KryptonTextBox)c).Text); } else if (t == typeof(KryptonComboBox)) { KryptonComboBox kc = c as KryptonComboBox; if (kc.SelectedItem == null) { return(string.Empty); } else { return(kc.SelectedItem.ToString()); } } else if (t == typeof(TextBoxNumber)) { TextBoxNumber tbn = c as TextBoxNumber; Field field = (Field)c.Tag; if (!field.IsEmptyData(tbn.Value) || !string.IsNullOrEmpty(tbn.Text)) { return(tbn.Value.ToString()); } else { return(string.Empty); } } else if (t == typeof(KryptonDateTimePicker)) { return(((KryptonDateTimePicker)c).Value.ToString()); } else if (t == typeof(KryptonCheckBox)) { return(((KryptonCheckBox)c).Checked.ToString()); } else if (t == typeof(KryptonCheckedListBox)) { return(ConvertExtension.ToString(((KryptonCheckedListBox)c).Items, ";")); } return(string.Empty); }
public string FirstColRowValue(string SQL) { using (var dbConnection = Connection) { var IDataReader = new DbHelper(dbConnection).ExecuteReader(CommandType.Text, SQL); var data = ConvertExtension.IDataReaderToDataTable(IDataReader); if (data.Rows.Count == 0) { return(""); } else { return(Convert.ToString(data.Rows[0][0])); } } }
public static T GetValue <T>(this Match match, int index) where T : struct { try { var value = match.Groups[index].Value; if (string.IsNullOrEmpty(value)) { throw new KeyNotFoundException(); } return(ConvertExtension.GetValue <T>(value)); } catch (Exception) { throw; } }