Ejemplo n.º 1
0
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <param name="connection">SQL连接</param>
        /// <param name="table">表格信息</param>
        internal unsafe override bool createTable(DbConnection connection, table table)
        {
            string name = table.Columns.Name;

            if (connection != null && name != null && name.Length != 0 && table.Columns != null && table.Columns.Columns.Length != 0)
            {
                pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();
                try
                {
                    using (charStream sqlStream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                    {
                        sqlStream.SimpleWriteNotNull("create table ");
                        sqlStream.SimpleWriteNotNull(name);
                        sqlStream.SimpleWriteNotNull(" (");
                        bool isNext = false;
                        foreach (column column in table.Columns.Columns)
                        {
                            if (isNext)
                            {
                                sqlStream.Write(',');
                            }
                            sqlStream.SimpleWriteNotNull(column.SqlName);
                            sqlStream.Write(' ');
                            sqlStream.Write(column.DbType.getSqlTypeName());
                            isNext = true;
                        }
                        sqlStream.Write(')');
                        return(executeNonQuery(connection, sqlStream.ToString()) >= 0);
                    }
                }
                finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
            }
            return(false);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取类型名称
 /// </summary>
 /// <param name="type">类型</param>
 /// <returns>类型名称</returns>
 public unsafe string GetName(Type type)
 {
     if (type.IsArray)
     {
         pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
         try
         {
             using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
             {
                 array(type, false);
                 return(NameStream.ToString());
             }
         }
         finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
     }
     if (type.IsGenericType)
     {
         pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
         try
         {
             using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
             {
                 genericName(type);
                 return(NameStream.ToString());
             }
         }
         finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
     }
     return(type.Name);
 }
Ejemplo n.º 3
0
        /// <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); }
        }
Ejemplo n.º 4
0
        /// <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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 创建SQL
        /// </summary>
        /// <param name="expression">委托关联表达式</param>
        /// <returns>SQL表达式</returns>
        internal unsafe string Create(LambdaExpression expression)
        {
            pointer buffer = fastCSharp.sql.client.SqlBuffers.Get();

            try
            {
                using (stream = new charStream(buffer.Char, fastCSharp.sql.client.SqlBufferSize))
                {
                    create(expression, stream);
                    return(stream.ToString());
                }
            }
            finally { fastCSharp.sql.client.SqlBuffers.Push(ref buffer); }
        }
Ejemplo n.º 6
0
            /// <summary>
            /// 获取类型名称
            /// </summary>
            /// <param name="type">类型</param>
            /// <returns>类型名称</returns>
            public unsafe string GetFullName(Type type)
            {
                if (type.IsArray)
                {
                    pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
                    try
                    {
                        using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
                        {
                            array(type, true);
                            return(NameStream.ToString());
                        }
                    }
                    finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
                }
                if (type.IsGenericType)
                {
                    pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
                    try
                    {
                        using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
                        {
                            genericFullName(type);
                            return(NameStream.ToString());
                        }
                    }
                    finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
                }
                Type reflectedType = type.ReflectedType;

                if (reflectedType == null)
                {
                    return(type.Namespace + "." + type.Name);
                }
                else
                {
                    pointer buffer = fastCSharp.unmanagedPool.TinyBuffers.Get();
                    try
                    {
                        using (NameStream = new charStream(buffer.Char, fastCSharp.unmanagedPool.TinyBuffers.Size >> 1))
                        {
                            this.reflectedType(type, reflectedType);
                            return(NameStream.ToString());
                        }
                    }
                    finally { fastCSharp.unmanagedPool.TinyBuffers.Push(ref buffer); }
                }
            }
Ejemplo n.º 7
0
 /// <summary>
 /// 获取类型名称
 /// </summary>
 /// <param name="type">类型</param>
 /// <returns>类型名称</returns>
 public string GetName(Type type)
 {
     if (type.IsArray)
     {
         nameStream = new charStream();
         array(type, false);
         return(nameStream.ToString());
     }
     if (type.IsGenericType)
     {
         nameStream = new charStream();
         genericName(type);
         return(nameStream.ToString());
     }
     return(type.Name);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 添加消息
        /// </summary>
        /// <param name="message">消息</param>
        private void newMessage(server.message message)
        {
            using (charStream charStream = new charStream())
            {
                charStream.Write(@"
");
                charStream.Write(message.User);
                charStream.Write(" ");
                charStream.Write(message.Time.toString());
                charStream.Write(@" :
");
                charStream.Write(message.Message);
                messageTextBox.AppendText(charStream.ToString());
            }
            messageTextBox.ScrollToCaret();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 获取属性信息
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 private xmlNode get(PropertyInfo property)
 {
     if (property != null)
     {
         xmlNode node;
         if (propertyLock.TryGetValue(property, out node))
         {
             return(node);
         }
         try
         {
             hashString propertyName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (propertyNameStream)
                 {
                     propertyNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = propertyNameStream, IsXml = true
                     };
                     nameBuilder.Xml(property.DeclaringType);
                     propertyNameStream.Write('.');
                     propertyNameStream.SimpleWriteNotNull(property.Name);
                     propertyName = propertyNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (properties.TryGetValue(propertyName, out node))
             {
                 properties.Remove(propertyName);
             }
             propertyLock.Set(property, node);
         }
         finally { propertyLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 获取字段信息
 /// </summary>
 /// <param name="field"></param>
 /// <returns></returns>
 private xmlNode get(FieldInfo field)
 {
     if (field != null)
     {
         xmlNode node;
         if (fieldLock.TryGetValue(field, out node))
         {
             return(node);
         }
         try
         {
             hashString fieldName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (fieldNameStream)
                 {
                     fieldNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = fieldNameStream, IsXml = true
                     };
                     nameBuilder.Xml(field.DeclaringType);
                     fieldNameStream.Write('.');
                     fieldNameStream.SimpleWriteNotNull(field.Name);
                     fieldName = fieldNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (fields.TryGetValue(fieldName, out node))
             {
                 fields.Remove(fieldName);
             }
             fieldLock.Set(field, node);
         }
         finally { fieldLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 11
0
 /// <summary>
 /// 获取类型信息
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private xmlNode get(Type type)
 {
     if (type != null)
     {
         xmlNode node;
         if (typeLock.TryGetValue(type, out node))
         {
             return(node);
         }
         try
         {
             hashString typeName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (typeNameStream)
                 {
                     typeNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = typeNameStream, IsXml = true
                     };
                     nameBuilder.Xml(type);
                     typeName = typeNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (types.TryGetValue(typeName, out node))
             {
                 types.Remove(typeName);
             }
             typeLock.Set(type, node);
         }
         finally { typeLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 12
0
            /// <summary>
            /// 获取类型名称
            /// </summary>
            /// <param name="type">类型</param>
            /// <returns>类型名称</returns>
            public string GetFullName(Type type)
            {
                if (type.IsArray)
                {
                    nameStream = new charStream();
                    array(type, true);
                    return(nameStream.ToString());
                }
                if (type.IsGenericType)
                {
                    nameStream = new charStream();
                    genericFullName(type);
                    return(nameStream.ToString());
                }
                Type reflectedType = type.ReflectedType;

                if (reflectedType == null)
                {
                    return(type.Namespace + "." + type.Name);
                }
                nameStream = new charStream();
                this.reflectedType(type, reflectedType);
                return(nameStream.ToString());
            }
Ejemplo n.º 13
0
 /// <summary>
 /// 获取方法信息
 /// </summary>
 /// <param name="method"></param>
 /// <returns></returns>
 private xmlNode get(MethodInfo method)
 {
     if (method != null)
     {
         xmlNode node;
         if (methodLock.TryGetValue(method, out node))
         {
             return(node);
         }
         try
         {
             hashString methodName;
             pointer    buffer = unmanagedPool.StreamBuffers.Get();
             try
             {
                 using (methodNameStream)
                 {
                     methodNameStream.UnsafeReset(buffer.Byte, unmanagedPool.StreamBuffers.Size);
                     type.nameBuilder nameBuilder = new type.nameBuilder {
                         NameStream = methodNameStream, IsXml = true
                     };
                     nameBuilder.Xml(method.DeclaringType);
                     methodNameStream.Write('.');
                     string name = method.Name;
                     if (name[0] == '.')
                     {
                         methodNameStream.Write('#');
                         methodNameStream.Write(subString.Unsafe(name, 1, name.Length - 1));
                     }
                     else
                     {
                         methodNameStream.SimpleWriteNotNull(name);
                     }
                     ParameterInfo[] parameters = method.GetParameters();
                     if (parameters.Length != 0)
                     {
                         bool isFirst = true;
                         methodNameStream.Write('(');
                         foreach (ParameterInfo parameter in parameters)
                         {
                             if (isFirst)
                             {
                                 isFirst = false;
                             }
                             else
                             {
                                 methodNameStream.Write(',');
                             }
                             nameBuilder.Xml(parameter.ParameterType);
                         }
                         methodNameStream.Write(')');
                     }
                     formatName(methodNameStream.Char, methodNameStream.CurrentChar);
                     methodName = methodNameStream.ToString();
                 }
             }
             finally { unmanagedPool.StreamBuffers.Push(ref buffer); }
             if (methods.TryGetValue(methodName, out node))
             {
                 methods.Remove(methodName);
             }
             methodLock.Set(method, node);
         }
         finally { methodLock.Exit(); }
         return(node);
     }
     return(default(xmlNode));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 生成HTML
 /// </summary>
 /// <param name="isTag">是否包含当前标签</param>
 /// <returns>HTML</returns>
 public string Html(bool isTag)
 {
     if (TagName != null)
     {
         if (web.html.NonanalyticTagNames.Contains(TagName))
         {
             if (isTag && TagName.Length != 1)
             {
                 using (charStream strings = new charStream())
                 {
                     tagHtml(strings);
                     strings.Write(nodeText.Html);
                     tagRound(strings);
                     return strings.ToString();
                 }
             }
         }
         else
         {
             using (charStream strings = new charStream())
             {
                 if (isTag) tagHtml(strings);
                 if (children.count() != 0)
                 {
                     htmlNode node;
                     list<nodeIndex> values = new list<nodeIndex>();
                     nodeIndex index = new nodeIndex { Values = children };
                     while (true)
                     {
                         if (index.Values == null)
                         {
                             if (values.Count == 0) break;
                             {
                                 index = values.Pop();
                                 index.Values[index.Index].tagRound(strings);
                                 if (++index.Index == index.Values.Count)
                                 {
                                     index.Values = null;
                                     continue;
                                 }
                             }
                         }
                         node = index.Values[index.Index];
                         string nodeTagName = node.TagName;
                         bool isNonanalyticTagNames = nodeTagName != null && web.html.NonanalyticTagNames.Contains(nodeTagName);
                         if (node.children.count() == 0 || nodeTagName == null || isNonanalyticTagNames)
                         {
                             if (nodeTagName != null && nodeTagName.Length != 1) node.tagHtml(strings);
                             strings.Write(node.nodeText.Html);
                             if (nodeTagName != null && nodeTagName.Length != 1) node.tagRound(strings);
                             if (++index.Index == index.Values.Count) index.Values = null;
                         }
                         else
                         {
                             node.tagHtml(strings);
                             values.Add(index);
                             index.Values = node.children;
                             index.Index = 0;
                         }
                     }
                 }
                 if (isTag) tagRound(strings);
                 return strings.ToString();
             }
         }
     }
     return nodeText.Html;
 }