/// <summary> /// 获取Excel客户端 /// </summary> /// <returns>Excel客户端</returns> public unsafe client GetClient() { provider provider = Enum <providerType, provider> .Array((byte)Provider); pointer buffer = fastCSharp.sql.client.SqlBuffers.Get(); try { using (charStream connectionStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize)) { connectionStream.SimpleWriteNotNull("Provider="); connectionStream.Write(provider.Name); connectionStream.SimpleWriteNotNull(";Data Source="); connectionStream.Write(DataSource); if (Password != null) { connectionStream.WriteNotNull(";Database Password="******";Extended Properties='"); connectionStream.Write(provider.Excel); connectionStream.WriteNotNull(IsTitleColumn ? ";HDR=YES;IMEX=" : ";HDR=NO;IMEX="); number.ToString((byte)Intermixed, connectionStream); connectionStream.Write('\''); return((client) new sql.connection { Type = type.Excel, Connection = connectionStream.ToString() }.Client); } } finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); } }
/// <summary> /// AJAX响应输出处理 /// </summary> /// <param name="js">JS输出流</param> protected unsafe override void ajax(charStream js) { js.WriteNotNull(@"{At:"); { string _value1_ = At; if (_value1_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value1_, js); } } js.WriteNotNull(@",Environment:"); { fastCSharp.document.environment _value1_ = Environment; if (_value1_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.WriteNotNull(@"{FastCSharpPath:"); { string _value2_ = _value1_.FastCSharpPath; if (_value2_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value2_, js); } } js.WriteNotNull(@",VS2010:"); { bool _value2_ = _value1_.VS2010; fastCSharp.web.ajax.ToString((bool)_value2_, js); } js.Write('}'); } } js.WriteNotNull(@",WorkPath:"); { string _value1_ = WorkPath; if (_value1_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value1_, js); } } js.Write('}'); }
/// <summary> /// 查询对象集合 /// </summary> /// <typeparam name="valueType">对象类型</typeparam> /// <typeparam name="modelType">成员位图类型</typeparam> /// <param name="sqlTool">SQL操作工具</param> /// <param name="query">查询信息</param> /// <param name="keyName">关键之名称</param> /// <param name="memberMap">成员位图</param> /// <param name="sqlStream"></param> /// <returns></returns> private unsafe string selectKeys <valueType, modelType> (fastCSharp.emit.sqlTable.sqlTool <valueType, modelType> sqlTool, selectQuery <modelType> query, string keyName, fastCSharp.code.memberMap <modelType> memberMap, charStream sqlStream) where valueType : class, modelType where modelType : class { pointer buffer = fastCSharp.sql.client.SqlBuffers.Get(); try { using (sqlStream) { sqlStream.UnsafeReset(buffer.Byte, SqlBufferSize << 1); sqlStream.SimpleWriteNotNull("select "); sqlModel <modelType> .GetNames(sqlStream, memberMap); sqlStream.SimpleWriteNotNull(" from["); sqlStream.SimpleWriteNotNull(sqlTool.TableName); sqlStream.WriteNotNull("]with(nolock)where "); sqlStream.SimpleWriteNotNull(keyName); sqlStream.SimpleWriteNotNull(" in(select "); sqlStream.SimpleWriteNotNull(keyName); sqlStream.SimpleWriteNotNull(" from(select "); sqlStream.SimpleWriteNotNull(keyName); sqlStream.WriteNotNull(",row_number()over("); int startIndex = sqlStream.Length; query.WriteOrder(sqlTool, sqlStream); int count = sqlStream.Length - startIndex; sqlStream.SimpleWriteNotNull(")as "); sqlStream.SimpleWriteNotNull(orderOverName); sqlStream.SimpleWriteNotNull(" from["); sqlStream.SimpleWriteNotNull(sqlTool.TableName); sqlStream.SimpleWriteNotNull("]with(nolock)"); if (query.WriteWhereOnly(sqlTool, sqlStream)) { sqlStream.SimpleWriteNotNull(")as T where "); sqlStream.SimpleWriteNotNull(orderOverName); sqlStream.SimpleWriteNotNull(" between "); number.ToString(query.SkipCount, sqlStream); sqlStream.SimpleWriteNotNull(" and "); number.ToString(query.SkipCount + query.GetCount - 1, sqlStream); sqlStream.Write(')'); if (count != 0) { sqlStream.Write(sqlStream.Char + startIndex, count); } return(sqlStream.ToString()); } } } finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); } return(null); }
/// <summary> /// 任意类型处理 /// </summary> /// <param name="type">类型</param> private void getFullName(Type type) { string value; if (!IsXml && typeNames.TryGetValue(type, out value)) { NameStream.WriteNotNull(value); } else if (type.IsGenericParameter) { NameStream.SimpleWriteNotNull(type.Name); } else if (type.IsArray) { array(type, true); } else if (type.IsGenericType) { genericFullName(type); } else { Type reflectedType = type.ReflectedType; if (reflectedType == null) { NameStream.WriteNotNull(type.Namespace); NameStream.Write('.'); NameStream.SimpleWriteNotNull(type.Name); } else { this.reflectedType(type, reflectedType); } } }
/// <summary> /// AJAX响应输出处理 /// </summary> /// <param name="js">JS输出流</param> protected unsafe override void ajax(charStream js) { js.WriteNotNull(@"{Return:"); { int _value1_ = Return; fastCSharp.web.ajax.ToString((int)_value1_, js); } js.Write('}'); }
/// <summary> /// AJAX响应输出处理 /// </summary> /// <param name="js">JS输出流</param> protected unsafe override void ajax(charStream js) { js.WriteNotNull(@"{Item:"); { fastCSharp.document.include.codeMenu.item _value1_ = Item; if (_value1_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.WriteNotNull(@"{File:"); { System.IO.FileInfo _value2_ = _value1_.File; if (_value2_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.WriteNotNull(@"{FullName:"); { string _value3_ = _value2_.FullName; if (_value3_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value3_, js); } } js.Write('}'); } } js.Write('}'); } } js.Write('}'); }
/// <summary> /// SQL语句字符串格式化(单引号变两个) /// </summary> /// <param name="sqlStream">SQL字符流</param> /// <param name="value">常量</param> protected virtual unsafe void convertString(charStream sqlStream, string value) { fixed(char *valueFixed = value) { int length = 0; for (char *start = valueFixed, end = valueFixed + value.Length; start != end; ++start) { if (*start == '\'') { ++length; } else if (*start == '\\') { if ((*(start + 1) == '\r' || *(start + 1) == '\n') && (int)(end - start) >= 2) { length += 2; ++start; } } } if (length == 0) { sqlStream.PrepLength(value.Length + 2); sqlStream.UnsafeWrite('\''); sqlStream.WriteNotNull(value); sqlStream.UnsafeWrite('\''); return; } sqlStream.PrepLength((length += value.Length) + 2); sqlStream.UnsafeWrite('\''); byte *write = (byte *)sqlStream.CurrentChar; for (char *start = valueFixed, end = valueFixed + value.Length; start != end; ++start) { if (*start != '\'') { if (*start == '\\') { if (*(start + 1) == '\n') { if ((int)(end - start) >= 2) { *(long *)write = '\\' + ('\\' << 16) + ((long)'\n' << 32) + ((long)'\n' << 48); ++start; write += sizeof(long); continue; } } else if (*(start + 1) == '\r' && (int)(end - start) >= 2) { *(long *)write = '\\' + ('\\' << 16) + ((long)'\n' << 32) + ((long)'\r' << 48); ++start; write += sizeof(long); continue; } } *(char *)write = *start; write += sizeof(char); } else { *(int *)write = ('\'' << 16) + '\''; write += sizeof(int); } } sqlStream.UnsafeAddLength(length); sqlStream.UnsafeWrite('\''); } }
/// <summary> /// AJAX响应输出处理 /// </summary> /// <param name="js">JS输出流</param> protected unsafe override void ajax(charStream js) { js.WriteNotNull(@"{Message:"); { fastCSharp.demo.chatWeb.poll.message _value1_ = Message; if (_value1_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.WriteNotNull(@"{Messages:"); { fastCSharp.demo.chatWeb.data.message[] _value2_ = _value1_.Messages; if (_value2_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.Write('['); { int _loopIndex2_ = _loopIndex_; _loopIndex_ = 0; foreach (fastCSharp.demo.chatWeb.data.message _value3_ in _value2_) { if (_loopIndex_ == 0) { js.Write(fastCSharp.web.ajax.Quote); js.WriteNotNull("Message,Time,User"); js.Write(fastCSharp.web.ajax.Quote); } js.Write(','); if (_value3_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.Write('['); { string _value4_ = _value3_.Message; if (_value4_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value4_, js); } } js.Write(','); { System.DateTime _value4_ = _value3_.Time; fastCSharp.web.ajax.ToString((System.DateTime)_value4_, js); } js.Write(','); { string _value4_ = _value3_.User; if (_value4_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value4_, js); } } js.Write(']'); } ++_loopIndex_; } _loopIndex_ = _loopIndex2_; } js.WriteNotNull(@"].FormatView()"); } } js.WriteNotNull(@",Users:"); { string[] _value2_ = _value1_.Users; if (_value2_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { js.Write('['); { int _loopIndex2_ = _loopIndex_; _loopIndex_ = 0; foreach (string _value3_ in _value2_) { if (_loopIndex_ != 0) { js.Write(','); } if (_value3_ == null) { fastCSharp.web.ajax.WriteNull(js); } else { fastCSharp.web.ajax.ToString(_value3_, js); } ++_loopIndex_; } _loopIndex_ = _loopIndex2_; } js.Write(']'); } } js.WriteNotNull(@",UserVersion:"); { int _value2_ = _value1_.UserVersion; fastCSharp.web.ajax.ToString((int)_value2_, js); } js.Write('}'); } } js.Write('}'); }