/// <summary> /// 获取详细列表 /// </summary> /// <param name="planId">计划编号</param> /// <param name="keyword">关键字</param> /// <param name="pageSize">每页显示条数</param> /// <param name="pageNum">当前页码</param> /// <param name="recordCount">总记录条数</param> /// <returns>详细列表</returns> public List <Mod_Online_YearPlan_DetailEntity> GetList(string planId, string keyword, int pageSize, int pageNum, out int recordCount) { StringBuilder strSQL = new StringBuilder(); strSQL.Append(" SELECT * FROM Mod_Online_YearPlan_Detail "); strSQL.Append(" WHERE PlanId=? "); if (!string.IsNullOrEmpty(keyword)) { if (ValidateHelper.IsSafeSqlString(keyword)) { string keyValue = string.Format("'%{0}%'", keyword); strSQL.Append(" AND ( "); strSQL.AppendFormat(" AppTypeName LIKE ({0}) ", keyValue); strSQL.AppendFormat(" OR SchoolName LIKE ({0}) ", keyValue); strSQL.AppendFormat(" OR SchoolMajorName LIKE ({0}) ", keyValue); strSQL.AppendFormat(" OR PlanNumber LIKE ({0}) ", keyValue); strSQL.AppendFormat(" OR CandidateRequire LIKE ({0}) ", keyValue); strSQL.Append(" ) "); } } strSQL.Append(" ORDER BY SchoolId "); SQL sql = SQL.Build(strSQL.ToString(), planId).Limit(pageSize, pageNum); recordCount = sql.RecordCount; return(SqlMap <Mod_Online_YearPlan_DetailEntity> .ParseSql(sql).ToList()); }
private void InitRequest(AbstractRequestContext requestContext) { if (!String.IsNullOrEmpty(requestContext.RealSql)) { requestContext.IsStatementSql = false; } SqlMap sqlMap = null; if (!String.IsNullOrEmpty(requestContext.Scope)) { sqlMap = _smartSqlConfig.GetSqlMap(requestContext.Scope); } if (requestContext.IsStatementSql) { InitByStatement(requestContext, sqlMap); } else { InitByMap(requestContext, sqlMap); } if (requestContext.AutoConverter == null) { requestContext.AutoConverter = NoneAutoConverter.INSTANCE; } }
public Global() { villageList = new VillageList(); request = new DataRequest(); res = new ResourcesUpdate(); build = new BuildingsUpdate(); sqlMap = new SqlMap(); loginThread = new BackgroundWorker(); loginThread.WorkerSupportsCancellation = true; loginThread.DoWork += new DoWorkEventHandler(loginProgress); dorfThread = new BackgroundWorker(); dorfThread.WorkerSupportsCancellation = true; dorfThread.DoWork += new DoWorkEventHandler(dorfProgress); incomingTroopThread = new BackgroundWorker(); incomingTroopThread.WorkerSupportsCancellation = true; incomingTroopThread.DoWork += new DoWorkEventHandler(incomingTroopProgress); outgoingTroopThread = new BackgroundWorker(); outgoingTroopThread.WorkerSupportsCancellation = true; outgoingTroopThread.DoWork += new DoWorkEventHandler(outgoingTroopProgress); sqlmapThread = new BackgroundWorker(); sqlmapThread.WorkerSupportsCancellation = true; sqlmapThread.DoWork += new DoWorkEventHandler(sqlmapProgress); }
/// <summary> /// 获取专业代码列表 /// </summary> /// <param name="keyword">关键字</param> public List <AutocompleteEntity> GetCodeQueryList(string keyword) { bool flag = false; StringBuilder strSQL = new StringBuilder(); strSQL.Append("SELECT (CodeId+CodeName) AS label, CodeId as value "); strSQL.Append(" FROM Mod_Online_MajorCode "); if (!string.IsNullOrEmpty(keyword)) { if (ValidateHelper.IsSafeSqlString(keyword)) { flag = true; strSQL.Append(" WHERE "); strSQL.AppendFormat(" CodeId LIKE ('{0}%') ", keyword); strSQL.AppendFormat(" OR CodeName LIKE ('%{0}%') ", keyword); strSQL.Append(" "); } } if (flag) { strSQL.Append(" ORDER BY CodeId "); SQL sql = SQL.Build(strSQL.ToString()); return(SqlMap <AutocompleteEntity> .ParseSql(sql).ToList()); } else { return(new List <AutocompleteEntity>()); } }
public static SqlMap <string, string> ExtractBody(String json) { JToken root = null; try { root = string.IsNullOrEmpty(json) ? new JObject() : JToken.Parse(json); } catch (Newtonsoft.Json.JsonReaderException e) { Console.WriteLine("Error while reading json string"); return(SqlMap.Create(EMPTYRESULT)); } var o = root as JObject; IEnumerable <JToken> tokens; if (o != null) { tokens = o.PropertyValues(); } else { tokens = root.Children(); } return(SqlMap.Create(TransformTokens(tokens))); }
public SqlSelectQuery(SqlContext context) : base(context) { SqlMap <T> map = Context.GetMap <T>(); AddSelectColumns(map.SelectColumns.Select(x => x.ToSql(context))); }
/// <summary> /// 获取分页后对象列表 /// </summary> /// <param name="pageSize">每页显示的记录条数</param> /// <param name="pageNumber">当前页索引</param> /// <param name="recordCount">总记录条数</param> /// <returns>分页后对象列表</returns> public virtual List <Mod_Online_School_MajorEntity> GetList(int pageSize, int pageNumber, out int recordCount) { SQL sql = SQL.Build("SELECT * FROM Mod_Online_School_Major").Limit(pageSize, pageNumber); recordCount = sql.RecordCount; return(SqlMap <Mod_Online_School_MajorEntity> .ParseSql(sql).ToList()); }
public void should_parse_real_xml() { var xml = File.ReadAllText(@"Input\contract.xml"); var mappings = new SqlMap <string, string>(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("oos:id", "Id"), new KeyValuePair <string, string>("oos:regNum", "RegistrationNumber"), }); var nameSpaces = new SqlMap <string, string>(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("oos", "http://zakupki.gov.ru/oos/types/1"), new KeyValuePair <string, string>("x", "http://zakupki.gov.ru/oos/export/1") }); var result = ExecuteExtract(xml, "/x:export/x:contract", mappings, new USqlSchema(new USqlColumn <string>("Id"), new USqlColumn <string>("RegistrationNumber"), new USqlColumn <string>("Products"), new USqlColumn <string>("Suppliers")), nameSpaces); result[0].Get <string>("Id").Should().Be("13354543"); result[0].Get <string>("RegistrationNumber").Should().Be("0176100000714000001"); }
public void should_parse_xml_with_namespaces() { const string xml = @"<?xml version=""1.0"" encoding=""UTF-8""?> <export xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://zakupki.gov.ru/oos/export/1"" xmlns:oos=""http://zakupki.gov.ru/oos/types/1""> <contract schemeVersion=""1.0""> <oos:id>13354543</oos:id> <oos:regNum>0176100000714000001</oos:regNum> <oos:number>01-5-7349/14</oos:number> <oos:publishDate>2014-01-11T10:59:49Z</oos:publishDate> <oos:signDate>2013-12-31</oos:signDate> <oos:versionNumber>0</oos:versionNumber> </contract> </export>"; var mappings = new SqlMap <string, string>(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("oos:id", "Id"), new KeyValuePair <string, string>("oos:regNum", "RegistrationNumber") }); var nameSpaces = new SqlMap <string, string>(new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("oos", "http://zakupki.gov.ru/oos/types/1"), new KeyValuePair <string, string>("x", "http://zakupki.gov.ru/oos/export/1") }); var result = ExecuteExtract(xml, "/x:export/x:contract", mappings, new USqlSchema(new USqlColumn <string>("Id"), new USqlColumn <string>("RegistrationNumber")), nameSpaces); Assert.IsTrue(result[0].Get <string>("Id") == "13354543"); Assert.IsTrue(result[0].Get <string>("RegistrationNumber") == "0176100000714000001"); }
private void InitByStatement(AbstractRequestContext requestContext, SqlMap sqlMap) { requestContext.Statement = sqlMap.GetStatement(requestContext.FullSqlId); if (requestContext.Statement.SourceChoice.HasValue) { requestContext.DataSourceChoice = requestContext.Statement.SourceChoice.Value; } else { requestContext.DataSourceChoice = (StatementType.Write & requestContext.Statement.StatementType) != StatementType.Unknown ? DataSourceChoice.Write : DataSourceChoice.Read; } if (requestContext.Statement.CommandType.HasValue) { requestContext.CommandType = requestContext.Statement.CommandType.Value; } requestContext.Transaction = requestContext.Transaction ?? requestContext.Statement.Transaction; requestContext.CommandTimeout = requestContext.CommandTimeout ?? requestContext.Statement.CommandTimeout; requestContext.ReadDb = requestContext.Statement.ReadDb; requestContext.CacheId = requestContext.Statement.CacheId; requestContext.Cache = requestContext.Statement.Cache; requestContext.ParameterMapId = requestContext.Statement.ParameterMapId; requestContext.ParameterMap = requestContext.Statement.ParameterMap; requestContext.ResultMapId = requestContext.Statement.ResultMapId; requestContext.ResultMap = requestContext.Statement.ResultMap; requestContext.MultipleResultMapId = requestContext.Statement.MultipleResultMapId; requestContext.MultipleResultMap = requestContext.Statement.MultipleResultMap; }
public void villageListDecode(HtmlDocument doc) { try { var node = doc.GetElementbyId("sidebarBoxVillagelist"); var childNode = node.Descendants("ul"); foreach (HtmlNode parsingParent in childNode) { var villageNode = parsingParent.Descendants("li"); foreach (HtmlNode parsing in villageNode) { string title = parsing.Attributes["title"].Value.Split('&')[0].TrimEnd(); var aNode = parsing.SelectSingleNode("./a"); string reference = aNode.Attributes["href"].Value.Split('&')[0]; int id = Convert.ToInt32(reference.Split('=')[1]); bool active = false; if (aNode.Attributes["class"].Value.Equals("active")) { active = true; } Village village = new Village(title, id, SqlMap.getCoordinatefromVillageID(id)); village.setReference(reference); village.setTileID(SqlMap.getTileIDfromVillageID(village.getID())); village.setActive(active); villageList.Add(village); } } exception = "villagePass"; } catch { exception = "villageError"; } }
public SqlMap Build() { SqlMap = new SqlMap { SmartSqlConfig = SmartSqlConfig, Path = XmlSqlMap.BaseURI, Statements = new Dictionary <String, Statement> { }, Caches = new Dictionary <String, Configuration.Cache> { }, ParameterMaps = new Dictionary <String, ParameterMap> { }, ResultMaps = new Dictionary <String, ResultMap> { }, MultipleResultMaps = new Dictionary <String, MultipleResultMap> { } }; if (!XmlSqlMapRoot.Attributes.TryGetValueAsString(nameof(SqlMap.Scope), out string scope, SmartSqlConfig.Properties)) { throw new SmartSqlException("SqlMap.Code can not be null."); } SqlMap.Scope = scope; BuildCaches(); BuildParameterMaps(); BuildResultMaps(); BuildMultipleResultMaps(); BuildStatements(); SmartSqlConfig.SqlMaps.Add(SqlMap.Scope, SqlMap); return(SqlMap); }
/// <summary> /// 获取分页后Json对象列表 /// </summary> /// <param name="pageSize">每页显示的记录条数</param> /// <param name="pageNumber">当前页索引</param> /// <param name="recordCount">总记录条数</param> /// <returns>页后Json对象列表</returns> public virtual string GetJsonList(int pageSize, int pageNumber, out int recordCount) { SQL sql = SQL.Build("SELECT * FROM Base_User").Limit(pageSize, pageNumber); recordCount = sql.RecordCount; return(SqlMap <Base_UserEntity> .ParseSql(sql).ToJsonList()); }
private void InitByStatement(AbstractRequestContext requestContext, SqlMap sqlMap) { requestContext.Statement = sqlMap.GetStatement(requestContext.FullSqlId); if (requestContext.Statement.SourceChoice.HasValue) { requestContext.DataSourceChoice = requestContext.Statement.SourceChoice.Value; } else { if ((StatementType.Write & requestContext.Statement.StatementType) == StatementType.Unknown) { requestContext.DataSourceChoice = DataSourceChoice.Write; } } if (requestContext.Statement.CommandType.HasValue) { requestContext.CommandType = requestContext.Statement.CommandType.Value; } if (String.IsNullOrEmpty(requestContext.ReadDb)) { requestContext.ReadDb = requestContext.Statement.ReadDb; } requestContext.CacheId = requestContext.Statement.CacheId; requestContext.Cache = requestContext.Statement.Cache; requestContext.ParameterMapId = requestContext.Statement.ParameterMapId; requestContext.ParameterMap = requestContext.Statement.ParameterMap; requestContext.ResultMapId = requestContext.Statement.ResultMapId; requestContext.ResultMap = requestContext.Statement.ResultMap; requestContext.MultipleResultMapId = requestContext.Statement.MultipleResultMapId; requestContext.MultipleResultMap = requestContext.Statement.MultipleResultMap; }
private void InitByMap(AbstractRequestContext requestContext, SqlMap sqlMap) { if (!string.IsNullOrEmpty(requestContext.CacheId)) { SetCache(requestContext, sqlMap); } if (!String.IsNullOrEmpty(requestContext.ParameterMapId)) { var fullParameterMapIdId = $"{requestContext.Scope}.{requestContext.ParameterMapId}"; requestContext.ParameterMap = sqlMap.GetParameterMap(fullParameterMapIdId); } if (!String.IsNullOrEmpty(requestContext.ResultMapId)) { var fullResultMapId = $"{requestContext.Scope}.{requestContext.ResultMapId}"; requestContext.ResultMap = sqlMap.GetResultMap(fullResultMapId); } if (!String.IsNullOrEmpty(requestContext.MultipleResultMapId)) { var fullMultipleResultMapId = $"{requestContext.Scope}.{requestContext.MultipleResultMapId}"; requestContext.MultipleResultMap = sqlMap.GetMultipleResultMap(fullMultipleResultMapId); } }
/// <summary> /// 获取分页后Json对象列表 /// </summary> /// <param name="pageSize">每页显示的记录条数</param> /// <param name="pageNumber">当前页索引</param> /// <param name="recordCount">总记录条数</param> /// <returns>页后Json对象列表</returns> public virtual string GetJsonList(int pageSize, int pageNumber, out int recordCount) { SQL sql = SQL.Build("SELECT * FROM Mod_Online_YearPlan_Detail").Limit(pageSize, pageNumber); recordCount = sql.RecordCount; return(SqlMap <Mod_Online_YearPlan_DetailEntity> .ParseSql(sql).ToJsonList()); }
/// <summary>New instances are constructed at least once per vertex</summary> /// <param name="xmlColumnName">In the input row, the name of the column containing XML. The column must be a string.</param> /// <param name="rowPath">Path of the XML element that contains rows.</param> /// <param name="columnPaths">For each column, map from the XML path to the column name. /// It is specified relative to the row element.</param> /// <remarks>Arguments to appliers must not be column references. /// The arguments must be able to be calculated at compile time.</remarks> /// <param name="namespaceDecls">For each namespace URI in the document that you want to query, map the prefix to the namespace URI. /// If you have a default namespace (without prefix) in your XML document, /// provide a prefix in the map for that namespace URI and use that prefix in the /// XPath expression to select the nodes that are in the default namespace. /// If there is no namespace URI in the document, the map can be left null.</param> /// <remarks>Do not rely on static fields because their values will not cross vertices.</remarks> public XmlApplier(string xmlColumnName, string rowPath, SqlMap <string, string> columnPaths, SqlMap <string, string> namespaceDecls = null) { this.xmlColumnName = xmlColumnName; this.rowPath = rowPath; this.columnPaths = columnPaths; this.namespaceDecls = namespaceDecls; }
public FixedWidthExtractor(SqlMap <string, string> col_widths, string transType = null, string recordID = null, Encoding encoding = null, string row_delim = "\n") { this._encoding = ((encoding == null) ? Encoding.UTF8 : encoding); this._row_delim = this._encoding.GetBytes(row_delim); this._col_widths = col_widths; this._transType = transType; this._recordID = recordID; }
public void Update(ICollection <T> entities) { using (DbConnection conn = _DataBase.CreateConnection()) { conn.ConnectionString = _strConn; SqlMap <T> .Update(entities, conn, _DataBase); } }
public void Update(T entity) { using (DbConnection conn = _DataBase.CreateConnection()) { conn.ConnectionString = _strConn; SqlMap <T> .Update(entity, conn, _DataBase); } }
public int Create(Person person) { int Id = (int)SqlMap.Insert("InsertPerson", person); SqlMap.CommitTransaction(); return(Id); }
private IList <IRow> ExecuteExtract(string xml, string rowPath, SqlMap <string, string> columnMappings, USqlSchema schema, SqlMap <string, string> namespaces = null) { using (var dataStream = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { var reader = new USqlStreamReader(dataStream); var extractor = new XmlExtractor(rowPath, columnMappings, namespaces); return(extractor.Extract(reader, new USqlRow(schema, null).AsUpdatable()).ToList()); } }
public static byte[] GetRawBytes(SqlMap <string, byte[]> inputColumn, string path) { if (inputColumn.ContainsKey(path)) { var value = inputColumn[path]; return(value); } return(null); }
// void OutputValueAtCol_I(string c, int i, IUpdatableRow outputrow) // // Helper function that takes the string value c and puts it into the column at position i in the output row. // The value will be cast to the expected type of the column. private void OutputValueAtCol_I(string c, int i, IUpdatableRow outputrow) { ISchema schema = outputrow.Schema; if (schema[i].Type == typeof(SqlMap <string, string>)) { c = DriverFunctions.RemoveOptionalQuotes(c); SqlMap <string, string> scopeMap = String.IsNullOrEmpty(c) ? null : DriverFunctions.ReadStringMap(c, this._map_item_delim, this._map_kv_delim); outputrow.Set <SqlMap <string, string> >(i, scopeMap); } else if (schema[i].Type == typeof(SqlArray <int>)) { c = DriverFunctions.RemoveOptionalQuotes(c); SqlArray <int> scopeArray = String.IsNullOrEmpty(c) ? null : DriverFunctions.ReadIntArray(c, this._array_item_delim); outputrow.Set <SqlArray <int> >(i, scopeArray); } else if (schema[i].Type == typeof(int)) { int num = Convert.ToInt32(c); outputrow.Set <int>(i, num); } else if (schema[i].Type == typeof(int?)) { int?num2 = (c == "") ? null : new int?(Convert.ToInt32(c)); outputrow.Set <int?>(i, num2); } else if (schema[i].Type == typeof(long)) { long num3 = Convert.ToInt64(c); outputrow.Set <long>(i, num3); } else if (schema[i].Type == typeof(long?)) { long?num4 = (c == "") ? null : new long?(Convert.ToInt64(c)); outputrow.Set <long?>(i, num4); } else if (schema[i].Type == typeof(DateTime)) { DateTime dateTime = Convert.ToDateTime(c); outputrow.Set <DateTime>(i, dateTime); } else if (schema[i].Type == typeof(DateTime?)) { DateTime?dateTime2 = (c == "") ? null : new DateTime?(Convert.ToDateTime(c)); outputrow.Set <DateTime?>(i, dateTime2); } else if (schema[i].Type == typeof(string)) { string text = DriverFunctions.RemoveOptionalQuotes(c); outputrow.Set <string>(i, text); } else { outputrow.Set <string>(i, c); } }
public XmlExtractor(string rowXPath, SqlMap <string, string> columnPaths, SqlMap <string, string> namespaces) { _rowPath = rowXPath; _columnPaths = columnPaths; _namespaceManager = new XmlNamespaceManager(new NameTable()); foreach (var @namespace in (namespaces ?? new SqlMap <string, string>())) { _namespaceManager.AddNamespace(@namespace.Key, @namespace.Value); } }
public static Int64?GetInteger(SqlMap <string, byte[]> inputColumn, string path) { var value = GetValue(inputColumn, path); if (value == null) { return(null); } return(Int64.Parse(value)); }
public static byte[] GetBytes(SqlMap <string, byte[]> inputColumn, string path) { var value = GetValue(inputColumn, path); if (value == null) { return(null); } return(Convert.FromBase64String(value)); }
public void OutputIdentity() { SqlMap <T> map = Context.GetMap <T>(); SqlColumn identity = map.SelectColumns.FirstOrDefault(x => x.Identity); if (identity != null) { AddInsertOutput(identity); } }
/// <summary> /// 更新详细 /// </summary> /// <param name="list">待更新的列表</param> /// <param name="dp">数据库访问对象接口</param> /// <returns>执行结果</returns> public bool UpdateDetail(List <Mod_Online_YearPlan_DetailEntity> list, IDataProvider dp) { List <SQL> sqlList = new List <SQL>(); foreach (Mod_Online_YearPlan_DetailEntity entity in list) { sqlList.Add(SQL.Build("UPDATE Mod_Online_YearPlan_Detail SET AppTypeId=?,AppTypeName=?,SchoolId=?,SchoolName=?,SchoolType=?,SchoolMajorId=?,SchoolMajorName=?,PlanNumber=?,MajorRequire=?,Remarks=?,CastScore=? WHERE DetailId=?", entity.AppTypeId, entity.AppTypeName, entity.SchoolId, entity.SchoolName, entity.SchoolType, entity.SchoolMajorId, entity.SchoolMajorName, entity.PlanNumber, entity.MajorRequire, entity.Remarks, entity.CastScore, entity.DetailId)); } return(SqlMap <Mod_Online_YearPlan_DetailEntity> .ParseSql(sqlList).Execute(dp) > 0); }
/// <summary> /// 删除计划 /// </summary> /// <param name="planId"></param> /// <returns></returns> public bool DeletePlan(string planId) { return(DBHelper.Transaction((dp, ex) => { this.Delete(planId, dp); SQL sql = SQL.Build("DELETE FROM [dbo].[Mod_Online_YearPlan_Detail] WHERE PlanId=?", planId); SqlMap <Mod_Online_YearPlanEntity> .ParseSql(sql).Execute(dp); SQL sql2 = SQL.Build("DELETE FROM [dbo].[Mod_Online_YearPlan_Detail_MajorCode] WHERE PlanId=?", planId); SqlMap <Mod_Online_YearPlanEntity> .ParseSql(sql2).Execute(dp); }) > 0); }
public static string GetString(SqlMap<string, byte[]> inputColumn, string path, int? count) { var valueString = GetValue(inputColumn, path, count); if (valueString == null) { return null; } if (valueString.Length > MaxUSqlStringByteLength) { throw new ArgumentOutOfRangeException($"String too long: {valueString.Length} - {path}"); } return valueString; }
public static string GetPiiString(SqlMap<string, byte[]> inputColumn, string path) { var inputString = GetString(inputColumn, path); return HashEmail(inputString); }
public static string GetString(SqlMap<string, byte[]> inputColumn, string path) { return GetString(inputColumn, path, null); }
private static string GetValue(SqlMap<string, byte[]> inputColumn, string path, int? count = null) { if (inputColumn.ContainsKey(path)) { if (count == null) { return Encoding.UTF8.GetString(inputColumn[path]); }else { return Encoding.UTF8.GetString(inputColumn[path], 0, Math.Min(MaxUSqlStringByteLength, inputColumn[path].Length)); } } return null; }
public static string GetUSqlString(SqlMap<string, byte[]> inputColumn, string path) { return GetUSqlString(GetRawBytes(inputColumn, path)); }
public static byte[] GetBytes(SqlMap<string, byte[]> inputColumn, string path) { var value = GetValue(inputColumn, path); if (value == null) { return null; } return Convert.FromBase64String(value); }
/// <summary>New instances are created at least once per vertex</summary> /// <param name="rowPath">Name of the XML element that will contain columns from a single row.</param> /// <param name="columnElements">For each column, map from the column name to the XML element name</param> /// <remarks>Do not rely on static fields because their values are not shared across vertices.</remarks> public XmlOutputter(string rowPath, SqlMap<string, string> columnPaths) { this.rowPath = rowPath; this.columnPaths = columnPaths; }
public static DateTime? GetDateTime(SqlMap<string, byte[]> inputColumn, string path) { var value = GetValue(inputColumn, path); if (value == null) { return null; } try { DateTime dateTime; DateTime.TryParse(value, out dateTime); return dateTime; } catch (FormatException) { throw new FormatException($"Error trying to parse using GetDateTime - {value}"); } }
public static Int64? GetInteger(SqlMap<string, byte[]> inputColumn, string path) { var value = GetValue(inputColumn, path); if (value == null) { return null; } return Int64.Parse(value); }
/// <summary>New instances are constructed at least once per vertex</summary> /// <param name="rowPath">Path of the XML element that contains rows.</param> /// <param name="columnPaths">For each column, map from the XML path to the column name. /// It is specified relative to the row element.</param> /// <remarks>Do not rely on static fields because their values will not cross vertices.</remarks> public XmlDomExtractor(string rowPath, SqlMap<string, string> columnPaths) { this.rowPath = rowPath; this.columnPaths = columnPaths; }
public static bool? GetBoolean(SqlMap<string, byte[]> inputColumn, string path) { var value = GetValue(inputColumn, path); if (value == null) { return null; } try { Boolean booleanValue; Boolean.TryParse(value, out booleanValue); return booleanValue; } catch (FormatException) { throw new FormatException($"Error trying to parse using GetBoolean - {value}"); } }
// IRow Process(IRow input, IUpdatableRow output) // // Actual implementatoin of the user-defined processor. Overwrites the Process method of IProcessor. public override IRow Process(IRow input, IUpdatableRow output) { List<string> list = new List<string>(); foreach (var current in input.Schema) { if (current.Type.IsGenericType && current.Type.GetGenericTypeDefinition() == typeof(SqlMap) && current.Type.GetGenericArguments()[0] == typeof(string)) { list.Add(current.Name); } } Dictionary<string, ArrayList> maps_to_be_changed = new Dictionary<string, ArrayList>(); foreach (var current2 in output.Schema) { bool flag = list.Contains(current2.Name); if (-1 < input.Schema.IndexOf(current2.Name) && !flag) { output.Set<object>(current2.Name, input.Get<object>(current2.Name)); } else if (!flag) { foreach (string current3 in list) { SqlMap<string, string> sqlMap = input.Get<SqlMap<string, string>>(current3); SqlArray<string> sqlArray = null; List<string> list2 = null; if (sqlMap != null) { sqlArray = sqlMap.Keys; if (sqlMap.Values != null) { list2 = sqlMap.Values.ToList<string>(); } } int num = (sqlArray == null) ? -1 : sqlArray.ToList<string>().IndexOf(current2.Name); if (num != -1) { output.Set<string>(current2.Name, list2[num]); if (maps_to_be_changed.Keys.Contains(current3)) { maps_to_be_changed[current3].Add(current2.Name); } else { maps_to_be_changed.Add(current3, new ArrayList { current2.Name }); } break; } output.Set<object>(current2.Name, current2.Type.IsValueType ? Activator.CreateInstance(current2.Type) : null); } } } using (IEnumerator<IColumn> enumerator = output.Schema.GetEnumerator()) { while (enumerator.MoveNext()) { IColumn out_col = enumerator.Current; bool flag = list.Contains(out_col.Name); if (flag) { SqlMap<string, string> sqlMap = input.Get<SqlMap<string, string>>(out_col.Name); if (maps_to_be_changed != null && maps_to_be_changed.Keys.Contains(out_col.Name)) { sqlMap = new SqlMap<string, string>( from kvp in sqlMap where !maps_to_be_changed[out_col.Name].Contains(kvp.Key) select kvp); } output.Set<SqlMap<string, string>>(out_col.Name, sqlMap); } } } return output.AsReadOnly(); }
public FixedLengthExtractor(Dictionary<int, int> fieldMap) { _fieldMap = new SqlMap<int, int>(fieldMap); }
public FixedLengthExtractor(SqlMap<int, int> fieldMap) { _fieldMap = fieldMap; }
/// <summary>New instances are constructed at least once per vertex</summary> /// <param name="xmlColumnName">In the input row, the name of the column containing XML. The column must be a string.</param> /// <param name="rowPath">Path of the XML element that contains rows.</param> /// <param name="columnPaths">For each column, map from the XML path to the column name. /// It is specified relative to the row element.</param> /// <remarks>Arguments to appliers must not be column references. /// The arguments must be able to be calculated at compile time.</remarks> public XmlApplier(string xmlColumnName, string rowPath, SqlMap<string, string> columnPaths) { this.xmlColumnName = xmlColumnName; this.rowPath = rowPath; this.columnPaths = columnPaths; }
// string WriteQuotedStringMap(SqlMap<string, string> m, string map_item_delim = ",", string map_kv_delim = ":") // // transforms a SQL.MAP<string, string> into a quoted string, using the provided delimiters to delimit keys and values and key-value pairs. public static string WriteQuotedStringMap(SqlMap<string, string> m, string map_item_delim = ",", string map_kv_delim = ":") { return "\"" + string.Join(map_item_delim, from p in m select string.Format("{0}{1}{2}", p.Key, map_kv_delim, p.Value)) + "\""; }
public static byte[] GetRawBytes(SqlMap<string, byte[]> inputColumn, string path) { if (inputColumn.ContainsKey(path)) { var value = inputColumn[path]; return value; } return null; }