Exemplo n.º 1
0
        private ParameterSchema ParseProcedure_param(CodeObject decl)
        {
            //procedure_param ::=
            //	parameter ["AS"]
            //	data_type [varying_tag]
            //	["=" param_init_value ]
            //	[output_tag] ;
            ParameterSchema param = new ParameterSchema();

            CodeObject obj = decl.FirstChild();

            while (obj != null)
            {
                switch (obj.Type)
                {
                case "parameter":
                    param.Name = obj.Text;
                    break;

                case "data_type":
                case "param_init_value":
                case "output_tag":
                    break;

                default:
                    throw new NotImplementedException("Not Implemented Type: " + obj.Type);
                }
                obj = obj.NextSibling();
            }
            return(param);
        }
Exemplo n.º 2
0
        public string GetStorePreceduresParamerDataType(ParameterSchema perameter)
        {
            switch (perameter.DataType)
            {
            case DbType.AnsiString: return("string");

            case DbType.AnsiStringFixedLength: return("string");

            case DbType.Binary: return("byte[]");

            case DbType.Boolean: return("bool");

            case DbType.Byte: return("byte");

            case DbType.Currency: return("decimal");

            case DbType.Date: return("DateTime");

            case DbType.DateTime: return("DateTime");

            case DbType.Decimal: return("decimal");

            case DbType.Double: return("double");

            case DbType.Guid: return("Guid");

            case DbType.Int16: return("short");

            case DbType.Int32: return("int");

            case DbType.Int64: return("long");

            case DbType.Object: return("object");

            case DbType.SByte: return("sbyte");

            case DbType.Single: return("float");

            case DbType.String: return("string");

            case DbType.StringFixedLength: return("string");

            case DbType.Time: return("TimeSpan");

            case DbType.UInt16: return("ushort");

            case DbType.UInt32: return("uint");

            case DbType.UInt64: return("ulong");

            case DbType.VarNumeric: return("decimal");

            case DbType.Xml: return("string");

            default:
            {
                return("__UNKNOWN__" + perameter.NativeType);
            }
            }
        }
Exemplo n.º 3
0
        public object Invoke(string sessionId, WbdlSchema wbdlSchema, WbapRequest request)
        {
            Object[] parameters = new Object[methodSchema.Parameters.Count];
            for (int j = 0; j < methodSchema.Parameters.Count; j++)
            {
                ParameterSchema paramSchema = methodSchema.Parameters[j];

                object paramValue = null;
                if (string.IsNullOrEmpty(paramSchema.Value))
                {
                    parameters[j] = null;
                    continue;
                }

                if (paramSchema.Value[0] == '#')
                {
                    paramValue = request.ElementBinds.GetTable(paramSchema.Value.Remove(0, 1), wbdlSchema);
                }
                else if (paramSchema.Value[0] == '$')
                {
                    paramValue = request.ElementBinds[paramSchema.Value];
                }
                else
                {
                    paramValue = paramSchema.Value;
                }

                parameters[j] = paramValue;
            }

            Object invokeRet = Umc.InvokeFunction(sessionId, null, methodSchema.MethodName, parameters);


            return(invokeRet);
        }
Exemplo n.º 4
0
        public string GetSqlDbTypeProce(ParameterSchema peramete)
        {
            switch (peramete.NativeType)
            {
            case "bigint": return("BigInt");

            case "binary": return("Binary");

            case "bit": return("Bit");

            case "char": return("Char");

            case "datetime": return("DateTime");

            case "decimal": return("Decimal");

            case "float": return("Float");

            case "image": return("Image");

            case "int": return("Int");

            case "money": return("Money");

            case "nchar": return("NChar");

            case "ntext": return("NText");

            case "numeric": return("Decimal");

            case "nvarchar": return("NVarChar");

            case "real": return("Real");

            case "smalldatetime": return("SmallDateTime");

            case "smallint": return("SmallInt");

            case "smallmoney": return("SmallMoney");

            case "sql_variant": return("Variant");

            case "sysname": return("NChar");

            case "text": return("Text");

            case "timestamp": return("Timestamp");

            case "tinyint": return("TinyInt");

            case "uniqueidentifier": return("UniqueIdentifier");

            case "varbinary": return("VarBinary");

            case "varchar": return("VarChar");

            default: return("__UNKNOWN__" + peramete.NativeType);
            }
        }
Exemplo n.º 5
0
 public ParameterContainer(ParameterSchema parameter)
 {
     if (parameter == null)
     {
         throw new ArgumentNullException("parameter");
     }
     this.parameter = parameter;
 }
Exemplo n.º 6
0
        public string GetMemberVariableNameProc(ParameterSchema column)
        {
            //string propertyName = GetPropertyName(column);
            string propertyName       = column.Name.Substring(1);
            string memberVariableName = "_" + propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1);

            return(memberVariableName);
        }
Exemplo n.º 7
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, ref string label, ref Gdk.Pixbuf icon, ref Gdk.Pixbuf closedIcon)
        {
            ParameterSchema parameter = dataObject as ParameterSchema;

            label = parameter.Name + " (" + parameter.ParameterType.ToString() + ")";
            icon  = Context.GetIcon("md-db-column");
            //TODO: icon based on column type
        }
Exemplo n.º 8
0
        public override void BuildNode(ITreeBuilder treeBuilder, object dataObject, NodeInfo nodeInfo)
        {
            ParameterSchema parameter = dataObject as ParameterSchema;

            nodeInfo.Label = parameter.Name + " (" + parameter.ParameterType.ToString() + ")";
            nodeInfo.Icon  = Context.GetIcon("md-db-column");
            //TODO: icon based on column type
        }
Exemplo n.º 9
0
        //private WbapResponse InvokeFarAction(WbapRequest wbapRequest)
        //{
        //    WbapResponse response = new WbapResponse();
        //    response.PageName = schema.Id;

        //    Dictionary<string, Object> namedParams = new Dictionary<string, object>();

        //    foreach (KeyValuePair<string, Object> elementItem in wbapRequest.ElementBinds)
        //    {
        //        string retElement = null;
        //        if (elementItem.Key.Equals("ReturnValue"))
        //        {
        //            retElement = elementItem.Value.ToString();
        //        }
        //        else
        //        {
        //            namedParams.Add(elementItem.Key, GetParamVarValue(elementItem.Value.ToString()));
        //        }
        //    }

        //    Umc.Umc.InvokeFunction("sid", "msid", wbapRequest.ActionId, namedParams);

        //    return response;

        //}

        private void BuildServerRequest(WbapRequest request, ActionFlowSchema action, int Step)
        {
            request.Step     = Step;
            request.PageName = WbdlSchema.Id;
            request.ActionId = action.Id;

            for (int i = Step; i < action.Actions.Count; i++)
            {
                ActionSchema methodSchema = action.Actions[i];

                if (methodSchema.IsRunAtClient())
                {
                    break;
                }

                for (int j = 0; j < methodSchema.Parameters.Count; j++)
                {
                    ParameterSchema paramSchema = methodSchema.Parameters[j];
                    if (string.IsNullOrEmpty(paramSchema.Value))
                    {
                        continue;
                    }
                    string[] realParamValues = paramSchema.Value.Split(PARAM_SPLITOR);

                    foreach (string realParamValue in realParamValues)
                    {
                        if (Array.IndexOf(VAR_TYPES, realParamValue[0]) == (int)VarFlagType.Element)
                        {
                            string key = realParamValue.Remove(0, 1);

                            if (!request.ElementBinds.ContainsKey(key))
                            {
                                request.ElementBinds.Add(key, "");
                            }
                        }
                        else if (Array.IndexOf(VAR_TYPES, realParamValue[0]) == (int)VarFlagType.Table)
                        {
                            request.ElementBinds.ImportTableSchema(realParamValue.Remove(0, 1), WbdlSchema);
                        }
                        else if (realParamValue[0].Equals('$'))
                        {
                            request.ElementBinds.Add(realParamValue, "");
                        }
                        else if (pageCtr.ContainsDataTable(realParamValue))
                        {
                            pageCtr.BuildRequestDataBodyWithTable(request.ElementBinds, realParamValue, null);
                        }
                        else if (methodSchema.MethodName.Equals("UpdateDataSet", StringComparison.OrdinalIgnoreCase))
                        {
                            pageCtr.BuildRequestDataBodyWithDataSet(request.ElementBinds);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
    public string GetParameterSize(ParameterSchema parameter)
    {
        string parameterSize = parameter.Size.ToString();

        if (parameter.NativeType == "numeric" && parameter.Precision != 0)
        {
            parameterSize += "(" + parameter.Precision.ToString() + "," + parameter.Scale + ")";
        }

        return(parameterSize);
    }
Exemplo n.º 11
0
        internal CanvasDocument(CanvasDocument other)
        {
            foreach (var kvp in other._unknownFiles)
            {
                _unknownFiles.Add(kvp.Key, new FileEntry(kvp.Value));
            }

            foreach (var kvp in other._assetFiles)
            {
                _assetFiles.Add(kvp.Key, new FileEntry(kvp.Value));
            }

            foreach (var kvp in other._screens)
            {
                _screens.Add(kvp.Key, kvp.Value.Clone());
            }

            foreach (var kvp in other._components)
            {
                _components.Add(kvp.Key, kvp.Value.Clone());
            }

            _editorStateStore = new EditorStateStore(other._editorStateStore);
            _templateStore    = new TemplateStore(other._templateStore);

            _dataSources = other._dataSources.JsonClone();
            _screenOrder = new List <string>(other._screenOrder);

            _header               = other._header.JsonClone();
            _properties           = other._properties.JsonClone();
            _parameterSchema      = other._parameterSchema.JsonClone();
            _publishInfo          = other._publishInfo.JsonClone();
            _templates            = other._templates.JsonClone();
            _themes               = other._themes.JsonClone();
            _resourcesJson        = other._resourcesJson.JsonClone();
            _appCheckerResultJson = other._appCheckerResultJson.JsonClone();
            _pcfControls          = other._pcfControls.JsonClone();

            _appInsights = other._appInsights.JsonClone();

            _connections = other._connections.JsonClone();

            _dataSourceReferences = other._dataSourceReferences.JsonClone();
            _libraryReferences    = other._libraryReferences.JsonClone();

            _logoFile = other._logoFile != null ? new FileEntry(other._logoFile) : null;
            _entropy  = other._entropy.JsonClone();
            _checksum = other._checksum.JsonClone();

            this._idRestorer = new UniqueIdRestorer(this._entropy);

            _localAssetInfoJson = other._localAssetInfoJson.JsonClone();
        }
Exemplo n.º 12
0
        public void AddParameter()
        {
            var message   = new MessageSchema("A");
            var parameter = new ParameterSchema("X", new RecordSchema("Y"));

            Assert.DoesNotThrow(
                () => message.AddParameter(parameter)
                );

            Assert.Throws(
                typeof(AvroException),
                () => message.AddParameter(parameter)
                );
        }
Exemplo n.º 13
0
    public static string GetCType(ParameterSchema para,
                                  SchemaExplorer.ExtendedPropertyCollection extendedProperties)
    {
        if (extendedProperties["enum"] != null)
        {
            string retEnum = GetEnumFromEp(extendedProperties["enum"].Value.ToString(), para.Name);
            if (retEnum != null)
            {
                return(retEnum);
            }
        }

        return(GetCType(para.DataType, false));
    }
Exemplo n.º 14
0
		protected override DataParameter BuildProcedureParameter(ParameterSchema p)
		{
			if (p.DataType == DataType.Structured)
				return new DataParameter
				{
					Name      = p.ParameterName,
					DataType  = p.DataType,
					Direction =
						p.IsIn ?
							p.IsOut ?
								ParameterDirection.InputOutput :
								ParameterDirection.Input :
							ParameterDirection.Output,
					DbType   = p.SchemaType
				};

			return base.BuildProcedureParameter(p);
		}
Exemplo n.º 15
0
        private void CreateParameter(Function function, ParameterSchema parameterSchema)
        {
            Parameter parameter;

            if (function.Parameters.Contains(parameterSchema.Name))
            {
                parameter = function.Parameters[parameterSchema.Name];
            }
            else
            {
                parameter = new Parameter(parameterSchema.Name, GetSystemType(parameterSchema));
                function.Parameters.Add(parameter);
            }

            //Parameter/@Parameter is safe
            if (string.IsNullOrEmpty(parameter.ParameterName))
            {
                string parameterName = parameterSchema.Name;
                if (parameterName.StartsWith("@"))
                {
                    parameterName = parameterName.Substring(1);
                }

                parameter.ParameterName = ToParameterName(parameterName);
            }

            parameter.Type   = GetSystemType(parameterSchema);
            parameter.DbType = GetDbType(parameterSchema);

            switch (parameterSchema.Direction)
            {
            case System.Data.ParameterDirection.Input:
                parameter.Direction = ParameterDirection.In;
                break;

            case System.Data.ParameterDirection.InputOutput:
                parameter.Direction = ParameterDirection.InOut;
                break;

            case System.Data.ParameterDirection.Output:
                parameter.Direction = ParameterDirection.Out;
                break;
            }
        }
Exemplo n.º 16
0
        private static string GetDbType(ParameterSchema parameterSchema)
        {
            if (parameterSchema.Database.Provider.Name != "SqlSchemaProvider")
            {
                return(parameterSchema.NativeType);
            }

            SqlParameter param = new SqlParameter();

            param.DbType = parameterSchema.DataType;

            return(GetSqlTypeDeclaration(
                       parameterSchema.NativeType,
                       parameterSchema.Size,
                       parameterSchema.Precision,
                       parameterSchema.Scale,
                       false,
                       false));
        }
Exemplo n.º 17
0
        public ParameterSchema[] GetCommandParameters(string connectionString, CommandSchema command)
        {
            ADOX.Catalog   catalog       = GetCatalog(connectionString);
            ADOX.Procedure adoxprocedure = catalog.Procedures[command.Name];

            ADODB.Command cmd = (ADODB.Command)adoxprocedure.Command;
            cmd.Parameters.Refresh();

            ParameterSchema[] parameters = new ParameterSchema[cmd.Parameters.Count];

            for (int i = 0; i < cmd.Parameters.Count; i++)
            {
                var  properties  = new ExtendedPropertyCollection(ConvertToExtendedProperties(cmd.Parameters[i].Properties));
                bool allowDBNull = false;

                try
                {
                    allowDBNull = cmd.Parameters[i].Properties["Nullable"] != null && (bool)cmd.Parameters[i].Properties["Nullable"].Value;

                    if (cmd.Parameters[i].Properties["Default"] != null)
                    {
                        properties.Add(new ExtendedProperty(ExtendedPropertyNames.DefaultValue, cmd.Parameters[i].Properties["Default"].Value, DbType.String, PropertyStateEnum.ReadOnly));
                    }
                }
                catch {}

                parameters[i] = new ParameterSchema(
                    command,
                    cmd.Parameters[i].Name,
                    GetParameterDirection(cmd.Parameters[i].Direction),
                    GetDbType(cmd.Parameters[i].Type),
                    cmd.Parameters[i].Type.ToString(),
                    cmd.Parameters[i].Size,
                    cmd.Parameters[i].Precision,
                    cmd.Parameters[i].NumericScale,
                    allowDBNull,
                    properties.ToArray());
            }

            Cleanup();

            return(parameters);
        }
Exemplo n.º 18
0
        public void Create(string filePath, ParameterSchema schema, string path = null, bool overwrite = false)
        {
            var fullPath = filePath;

            if (!string.IsNullOrEmpty(path))
            {
                fullPath = Path.Combine(path, Path.GetFileName(filePath));
            }

            using FileStream fileStream =
                      System.IO.File.Open(fullPath, !overwrite ? FileMode.Append : FileMode.Create);
            using StreamWriter file = new StreamWriter(fileStream);

            JsonSerializer serializer = new JsonSerializer()
            {
                Formatting = Formatting.Indented
            };

            serializer.Serialize(file, schema);
        }
Exemplo n.º 19
0
        public void TestUnknownParamType()
        {
            string          json  = @"
                {
                  ""Name"": ""i"",
                  ""TypeName"": ""System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"",
                  ""Attributes"": []
                }";
            ParameterSchema param = JsonConvert.DeserializeObject <ParameterSchema>(json);

            Assert.IsNotNull(param.Type);

            json  = @"
                {
                  ""Name"": ""i"",
                  ""TypeName"": ""System.Int33, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"",
                  ""Attributes"": []
                }";
            param = JsonConvert.DeserializeObject <ParameterSchema>(json);
            Assert.IsNull(param.Type);
            Assert.IsTrue(param.TypeName == "System.Int33, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
        }
Exemplo n.º 20
0
        public string GetMemberVariableDefaultValueProc(ParameterSchema column)
        {
            switch (column.DataType)
            {
            case DbType.Guid:
            {
                return("Guid.Empty");
            }

            case DbType.AnsiString:
            case DbType.AnsiStringFixedLength:
            case DbType.String:
            case DbType.StringFixedLength:
            {
                return("String.Empty");
            }

            case DbType.Boolean:
                return("false");

            case DbType.Int32:
                return("0");

            case DbType.DateTime:
                return("new DateTime(1900,1,1)");

            case DbType.Single:
                return("0");

            case DbType.Double:
                return("0");

            default:
            {
                return("");
            }
            }
        }
        public ParameterSchema[] GetCommandParameters(string connectionString, CommandSchema command)
        {
            var parameters         = new List <ParameterSchema>();
            var extendedProperties = new List <ExtendedProperty>();

            string sql = string.Format("SELECT PARAM_ORDER, PARAM_NAME, PARAM_TYPE, IS_PARAM_OUT, DEFAULT_VALUE FROM sp_stored_procedures() WHERE PROC_NAME = '{0}'", command.Name);

            using (VistaDBConnection connection = GetConnection(connectionString))
                using (var adapter = new VistaDBDataAdapter(sql, connection))
                    using (var table = new DataTable())
                    {
                        adapter.Fill(table);

                        foreach (DataRow row in table.Rows)
                        {
                            string name         = row["PARAM_NAME"].ToString();
                            var    vistaType    = (VistaDBType)(row["PARAM_TYPE"] ?? VistaDBType.Unknown);
                            var    isOut        = (bool)(row["IS_PARAM_OUT"] ?? false);
                            string defaultValue = row["DEFAULT_VALUE"].ToString();

                            extendedProperties.Clear();
                            extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.Description, string.Empty));
                            extendedProperties.Add(ExtendedProperty.Readonly(ExtendedPropertyNames.DefaultValue, defaultValue));

                            var parameter = new ParameterSchema(command, name,
                                                                isOut ? ParameterDirection.InputOutput : ParameterDirection.Input,
                                                                GetDbType(vistaType.ToString()),
                                                                vistaType.ToString(), 0, 0, 0, true,
                                                                extendedProperties.ToArray());

                            parameters.Add(parameter);
                        }
                    }

            return(parameters.ToArray());
        }
Exemplo n.º 22
0
 public string GetMemberVariableDeclarationStatementProc(ParameterSchema param)
 {
     return(GetMemberVariableDeclarationStatementProc("private", param));
 }
		public override ParameterSchemaCollection GetProcedureParameters (ProcedureSchema procedure)
		{
			ParameterSchemaCollection parameters = new ParameterSchemaCollection ();
			
			using (IPooledDbConnection conn = connectionPool.Request ())  {
				using (IDbCommand command = conn.CreateCommand (string.Concat (
				                                                 	"SELECT param_list FROM mysql.proc where name = '",
																	procedure.Name, "'"))) {
					try {
						if (GetMainVersion (command) >= 5) {
						    	using (IDataReader r = command.ExecuteReader()) {
						    		while (r.Read ()) {
						    			if (r.IsDBNull (0))
						    				continue;
						
										string[] field = Encoding.ASCII.GetString (
									                            (byte[])r.GetValue (0)).Split (
																				new char[] { ',' }, 
						    													StringSplitOptions.RemoveEmptyEntries);
						    			foreach (string chunk in field) {
											ParameterSchema param = new ParameterSchema (this);
											param.Definition = chunk;
							    				
											string[] tmp = chunk.TrimStart (new char[] { ' ' }).Split (new char[] { ' ' });
											int nameIndex = 0;
											if (String.Compare (tmp[0], "OUT", true) == 0) {
												nameIndex = 1;
												param.ParameterType = ParameterType.Out;
											} else if (String.Compare (tmp[0], "INOUT", true) == 0) {
												nameIndex = 1;
												param.ParameterType = ParameterType.InOut;
											} else {
												param.ParameterType = ParameterType.In;
											}
						    				param.Name = tmp[nameIndex];
						    				param.OwnerName = procedure.Name;
											param.DataTypeName = tmp[nameIndex + 1];
						    				parameters.Add (param);
						    			}
						    		}
								r.Close ();
							}
						}
					} catch (Exception e) {
						QueryService.RaiseException (e);
					} finally {
						conn.Release ();
					}			
				}
			}
			return parameters;
		}
Exemplo n.º 24
0
        private void CreateParameter(Function function, ParameterSchema parameterSchema)
        {
            Parameter parameter;
            if (function.Parameters.Contains(parameterSchema.Name))
            {
                parameter = function.Parameters[parameterSchema.Name];
            }
            else
            {
                parameter = new Parameter(parameterSchema.Name, GetSystemType(parameterSchema));
                function.Parameters.Add(parameter);
            }

            //Parameter/@Parameter is safe
            if (string.IsNullOrEmpty(parameter.ParameterName))
            {
                string parameterName = parameterSchema.Name;
                if (parameterName.StartsWith("@"))
                    parameterName = parameterName.Substring(1);

                parameter.ParameterName = ToParameterName(parameterName);
            }

            parameter.Type = GetSystemType(parameterSchema);
            parameter.DbType = GetDbType(parameterSchema);

            switch (parameterSchema.Direction)
            {
                case System.Data.ParameterDirection.Input:
                    parameter.Direction = ParameterDirection.In;
                    break;
                case System.Data.ParameterDirection.InputOutput:
                    parameter.Direction = ParameterDirection.InOut;
                    break;
                case System.Data.ParameterDirection.Output:
                    parameter.Direction = ParameterDirection.Out;
                    break;
            }
        }
Exemplo n.º 25
0
        public override ParameterSchemaCollection GetProcedureParameters(ProcedureSchema procedure)
        {
            ParameterSchemaCollection parameters = new ParameterSchemaCollection();

            using (IPooledDbConnection conn = connectionPool.Request())  {
                using (IDbCommand command = conn.CreateCommand(string.Concat(
                                                                   "SELECT param_list FROM mysql.proc where name = '",
                                                                   procedure.Name, "'"))) {
                    try {
                        if (GetMainVersion(command) >= 5)
                        {
                            using (IDataReader r = command.ExecuteReader()) {
                                while (r.Read())
                                {
                                    if (r.IsDBNull(0))
                                    {
                                        continue;
                                    }

                                    string[] field = Encoding.ASCII.GetString(
                                        (byte[])r.GetValue(0)).Split(
                                        new char[] { ',' },
                                        StringSplitOptions.RemoveEmptyEntries);
                                    foreach (string chunk in field)
                                    {
                                        ParameterSchema param = new ParameterSchema(this);
                                        param.Definition = chunk;

                                        string[] tmp       = chunk.TrimStart(new char[] { ' ' }).Split(new char[] { ' ' });
                                        int      nameIndex = 0;
                                        if (String.Compare(tmp[0], "OUT", true) == 0)
                                        {
                                            nameIndex           = 1;
                                            param.ParameterType = ParameterType.Out;
                                        }
                                        else if (String.Compare(tmp[0], "INOUT", true) == 0)
                                        {
                                            nameIndex           = 1;
                                            param.ParameterType = ParameterType.InOut;
                                        }
                                        else
                                        {
                                            param.ParameterType = ParameterType.In;
                                        }
                                        param.Name         = tmp[nameIndex];
                                        param.OwnerName    = procedure.Name;
                                        param.DataTypeName = tmp[nameIndex + 1];
                                        parameters.Add(param);
                                    }
                                }
                                r.Close();
                            }
                        }
                    } catch (Exception e) {
                        QueryService.RaiseException(e);
                    } finally {
                        conn.Release();
                    }
                }
            }
            return(parameters);
        }
Exemplo n.º 26
0
 public string GetStorePreceduresParamerName(ParameterSchema perameter)
 {
     return("obj" + perameter.Name.Replace('@', '.'));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Returns the C# variable type based on the given parameter.
 /// </summary>
 /// <param name="column"></param>
 /// <returns></returns>
 public string GetVBVariableType(ParameterSchema column)
 {
     return(GetVBVariableType(column as DataObjectBase));
 }
Exemplo n.º 28
0
 public static int GetParamSize(ParameterSchema param)
 {
     return(GetParamSize(param.NativeType, param.Size));
 }
Exemplo n.º 29
0
 public static string GetUIControlConversionType(ParameterSchema parameter, string value)
 {
     switch (parameter.DataType)
     {
         case DbType.AnsiString: return string.Format("Convert.ToString({0})",value);
         case DbType.AnsiStringFixedLength: return string.Format("Convert.ToString({0})",value);
         case DbType.Binary: return string.Format("Convert.ToString({0})",value);
         case DbType.Boolean: return string.Format("Convert.ToBoolean({0})",value);
         case DbType.Byte: return string.Format("Convert.ToBoolean({0})",value);
         case DbType.Currency: return string.Format("Convert.ToString({0})",value);
         case DbType.Date: return string.Format("Convert.ToDateTime({0})",value);
         case DbType.DateTime: return string.Format("Convert.ToDateTime({0})",value);
         case DbType.Decimal: return string.Format("Convert.ToString({0})",value);
         case DbType.Double: return string.Format("Convert.ToString({0})",value);
         case DbType.Guid: return string.Format("Convert.ToString({0})",value);
         case DbType.Int16: return string.Format("Convert.ToString({0})",value);
         case DbType.Int32: return string.Format("Convert.ToString({0})",value);
         case DbType.Int64: return string.Format("Convert.ToString({0})",value);
         case DbType.Object: return string.Format("Convert.ToString({0})",value);
         case DbType.SByte: return string.Format("Convert.ToBoolean({0})",value);
         case DbType.Single: return string.Format("Convert.ToString({0})",value);
         case DbType.String: return string.Format("Convert.ToString({0})",value);
         case DbType.StringFixedLength: return string.Format("Convert.ToString({0})",value);
         //case DbType.Time: return canBeNullable ? "TimeSpan?" : "TimeSpan";
         case DbType.UInt16: return string.Format("Convert.ToString({0})",value);
         case DbType.UInt32: return string.Format("Convert.ToString({0})",value);
         case DbType.UInt64: return string.Format("Convert.ToString({0})",value);
         case DbType.VarNumeric: return string.Format("Convert.ToString({0})",value);
         default:
         {
             return string.Format("txt{0}.Text;",GetPropertyName(parameter));
         }
     }
 }
Exemplo n.º 30
0
        public static string GetUICheckBoxSetupDeclaration(ParameterSchema parameter, System.Drawing.Point point, System.Drawing.Size size, int tabIndex)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();

            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t// chk{0}\r\n",GetPropertyName(parameter)));
            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t this.chk{0}.AutoSize = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.chk{0}.Checked = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.chk{0}.CheckState = System.Windows.Forms.CheckState.Checked;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.chk{0}.Location = new System.Drawing.Point({1}, {2});\r\n",GetPropertyName(parameter),point.X,point.Y));
            builder.Append(string.Format("\t\t this.chk{0}.Name = \"chk{0}\";\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.chk{0}.Size = new System.Drawing.Size({1}, {2});\r\n",GetPropertyName(parameter),size.Width,size.Height));
            builder.Append(string.Format("\t\t this.chk{0}.TabIndex = {1}\r\n;",GetPropertyName(parameter),tabIndex));

            return builder.ToString();
        }
Exemplo n.º 31
0
        public static string GetPublicMemberVariableName(ParameterSchema parameter)
        {
            string propertyName = GetPropertyName(parameter);
            if (propertyName.StartsWith("@")) propertyName = propertyName.Substring(1);
            string memberVariableName = GetCamelCaseName(propertyName);

            return memberVariableName;
        }
Exemplo n.º 32
0
        public static string GetPropertyName(ParameterSchema parameter)
        {
            string propertyName = parameter.Name.Replace(" ", "");
            if (propertyName.StartsWith("@")) propertyName = propertyName.Substring(1);

            return StringUtil.ToPascalCase(propertyName);
        }
Exemplo n.º 33
0
        public static string GetOriginalPropertyName(ParameterSchema parameter)
        {
            string propertyName = parameter.Name;
            if (propertyName.StartsWith("@")) propertyName = propertyName.Substring(1);

            return propertyName;
        }
Exemplo n.º 34
0
        public static string GetMemberVariableDeclarationStatement(string protectionLevel, ParameterSchema parameter, bool canBeNullable)
        {
            string statement = protectionLevel + " ";
            statement += GetCSharpVariableType(parameter.DataType, canBeNullable) + " " + GetMemberVariableName(parameter);

            string defaultValue = GetMemberVariableDefaultValue(parameter.DataType, canBeNullable, parameter.Name == "@TransactionType");
            if (defaultValue != "")
            {
                statement += " = " + defaultValue;
            }

            statement += ";";

            return statement;
        }
Exemplo n.º 35
0
 public static string GetMemberVariableDeclarationStatement(ParameterSchema parameter, bool canBeNullable)
 {
     return GetMemberVariableDeclarationStatement("private", parameter, canBeNullable);
 }
Exemplo n.º 36
0
 public static string GetUIControlName(ParameterSchema parameter, bool withInput)
 {
     switch (parameter.DataType)
     {
         case DbType.AnsiString: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         case DbType.AnsiStringFixedLength: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         case DbType.Binary: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         case DbType.Boolean: return withInput ? string.Format("chk{0}.Checked",GetPropertyName(parameter)) : string.Format("chk{0}",GetPropertyName(parameter));
         case DbType.Byte: return withInput ? string.Format("chk{0}.Checked",GetPropertyName(parameter)) : string.Format("chk{0}",GetPropertyName(parameter));
         case DbType.Currency: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.Date: return withInput ? string.Format("dtp{0}.Value",GetPropertyName(parameter)) : string.Format("dtp{0}",GetPropertyName(parameter));
         case DbType.DateTime: return withInput ? string.Format("dtp{0}.Value",GetPropertyName(parameter)) : string.Format("dtp{0}",GetPropertyName(parameter));
         case DbType.Decimal: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.Double: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.Guid: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         case DbType.Int16: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.Int32: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.Int64: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.Object: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         case DbType.SByte: return withInput ? string.Format("chk{0}.Checked",GetPropertyName(parameter)) : string.Format("chk{0}",GetPropertyName(parameter));
         case DbType.Single: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.String: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         case DbType.StringFixedLength: return withInput ? string.Format("txt{0}.Text",GetPropertyName(parameter)) : string.Format("txt{0}",GetPropertyName(parameter));
         //case DbType.Time: return canBeNullable ? "TimeSpan?" : "TimeSpan";
         case DbType.UInt16: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.UInt32: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.UInt64: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         case DbType.VarNumeric: return withInput ? string.Format("mtb{0}.Text",GetPropertyName(parameter)) : string.Format("mtb{0}",GetPropertyName(parameter));
         default:
         {
             return string.Format("txt{0}",GetPropertyName(parameter));
         }
     }
 }
Exemplo n.º 37
0
		
		private ParameterSchemaCollection GetParams (string names, string directions, string types, IPooledDbConnection conn)
		{
			ParameterSchemaCollection pars = new ParameterSchemaCollection ();
			
			if (names == string.Empty || directions == string.Empty || types == String.Empty)
				return pars;
			
			// Array always start with { and end with }
			if (!names.StartsWith ("{") || !names.EndsWith ("}"))
				throw new ArgumentOutOfRangeException ("names");
			
			string[] namesArray = names.Substring(1, names.Length -2).Split (',');
			string[] directionsArray = directions.Substring(1, directions.Length -2).Split (',');
			string[] typesArray = types.Substring(1, types.Length -2).Split (',');
			
			for (int idx = 0; idx < namesArray.Length; idx++) {
				ParameterSchema ps = new ParameterSchema (this);
				// Name
				if (namesArray[idx] != "\"\"") 
					ps.Name = namesArray[idx];
				
				// Direction
				string d = directionsArray[idx];
				if (d == "i")
					ps.ParameterType = ParameterType.In;
				else if (d == "o")
					ps.ParameterType = ParameterType.Out;
				else
					ps.ParameterType = ParameterType.InOut;
				
				// Type
				using (IDbCommand cmd = conn.CreateCommand (string.Format (
					"select format_type(oid, null) from pg_type WHERE oid = '{0}'::oid", typesArray[idx]))) {
					using (IDataReader r = cmd.ExecuteReader()) 
						if (r.Read ())
							ps.DataTypeName = r.GetString (0);
				}
				pars.Add (ps);
			}
			return pars;
Exemplo n.º 38
0
 public static string GetUIControlSetupStatement(ParameterSchema parameter, System.Drawing.Point point, System.Drawing.Size size, int tabIndex)
 {
     switch (parameter.DataType)
     {
         case DbType.AnsiString: return GetUITextBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.AnsiStringFixedLength: return GetUITextBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.Binary: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#","0");
         case DbType.Boolean: return GetUICheckBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.Byte: return GetUICheckBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.Currency: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0.00","0000000000");
         case DbType.Date: return GetUIDateTimePickerSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.DateTime: return GetUIDateTimePickerSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.Decimal: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0.00","0000000000");
         case DbType.Double: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0.00","0000000000");
         case DbType.Guid: return GetUITextBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.Int16: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.Int32: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.Int64: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.Object: return GetUITextBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.SByte: return GetUICheckBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.Single: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.String: return GetUITextBoxSetupDeclaration(parameter, point, size, tabIndex);
         case DbType.StringFixedLength: return GetUITextBoxSetupDeclaration(parameter, point, size, tabIndex);
         //case DbType.Time: return canBeNullable ? "TimeSpan?" : "TimeSpan";
         case DbType.UInt16: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.UInt32: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.UInt64: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         case DbType.VarNumeric: return GetUIMaskedTextBoxSetupDeclaration(parameter, point, size, tabIndex, "#######0","0000000)");
         default:
         {
             return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         }
     }
 }
Exemplo n.º 39
0
 public string GetStorePreceduresParamer(ParameterSchema perameter)
 {
     return(perameter.Name);
 }
Exemplo n.º 40
0
 public static string GetUIControlValueStatementOUT(ParameterSchema parameter)
 {
     switch (parameter.DataType)
     {
         case DbType.AnsiString: return string.Format("txt{0}.Text",GetPropertyName(parameter));
         case DbType.AnsiStringFixedLength: return string.Format("txt{0}.Text",GetPropertyName(parameter));
         case DbType.Binary: return string.Format("new byte[]{Convert.ToByte(txt{0}.Text)}",GetPropertyName(parameter));
         case DbType.Boolean: return string.Format("chk{0}.Checked",GetPropertyName(parameter));
         case DbType.Byte: return string.Format("Convert.ToByte(chk{0}.Checked)",GetPropertyName(parameter));
         case DbType.Currency: return string.Format("Convert.ToDecimal(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.Date: return string.Format("dtp{0}.Value",GetPropertyName(parameter));
         case DbType.DateTime: return string.Format("dtp{0}.Value",GetPropertyName(parameter));
         case DbType.Decimal: return string.Format("Convert.ToDecimal(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.Double: return string.Format("Convert.ToDouble(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.Guid: return string.Format("new Guid(txt{0}.Text)",GetPropertyName(parameter));
         case DbType.Int16: return string.Format("Convert.ToInt16(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.Int32: return string.Format("Convert.ToInt32(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.Int64: return string.Format("Convert.ToInt64(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.Object: return string.Format("txt{0}.Text",GetPropertyName(parameter));
         case DbType.SByte: return string.Format("Convert.ToSByte(chk{0}.Checked)",GetPropertyName(parameter));
         case DbType.Single: return string.Format("Convert.ToSingle(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.String: return string.Format("txt{0}.Text",GetPropertyName(parameter));
         case DbType.StringFixedLength: return string.Format("txt{0}.Text",GetPropertyName(parameter));
         //case DbType.Time: return canBeNullable ? "TimeSpan?" : "TimeSpan";
         case DbType.UInt16: return string.Format("Convert.ToUInt16(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.UInt32: return string.Format("Convert.ToUInt32(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.UInt64: return string.Format("Convert.ToUInt64(mtb{0}.Text)",GetPropertyName(parameter));
         case DbType.VarNumeric: return string.Format("Convert.ToDecimal(mtb{0}.Text)",GetPropertyName(parameter));
         default:
         {
             return string.Format("txt{0}.Text;",GetPropertyName(parameter));
         }
     }
 }
Exemplo n.º 41
0
    public string GetParameterSize(ParameterSchema parameter)
    {
        string parameterSize = parameter.Size.ToString();

        if (parameter.NativeType == "numeric" && parameter.Precision != 0)
        {
            parameterSize += "(" + parameter.Precision.ToString() + "," + parameter.Scale + ")";
        }

        return parameterSize;
    }
Exemplo n.º 42
0
        public static string GetUIDateTimePickerSetupDeclaration(ParameterSchema parameter, System.Drawing.Point point, System.Drawing.Size size, int tabIndex)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();

            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t// dtp{0}\r\n",GetPropertyName(parameter)));
            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t this.dtp{0}.CustomFormat = \"MM/dd/yyyy hh:mm tt\";\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.dtp{0}.Checked = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.dtp{0}.Format = System.Windows.Forms.DateTimePickerFormat.Custom;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.dtp{0}.Location = new System.Drawing.Point({1}, {2});\r\n",GetPropertyName(parameter),point.X,point.Y));
            builder.Append(string.Format("\t\t this.dtp{0}.Name = \"dtp{0}\";\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.dtp{0}.Size = new System.Drawing.Size({1}, {2});\r\n",GetPropertyName(parameter),size.Width,size.Height));
            builder.Append(string.Format("\t\t this.dtp{0}.TabIndex = {1};\r\n",GetPropertyName(parameter),tabIndex));
            //builder.Append(string.Format("\t\t this.dtp{0}.ShowUpDown = true;\r\n",GetPropertyName(parameter)));

            return builder.ToString();
        }
Exemplo n.º 43
0
        private static string GetDbType(ParameterSchema parameterSchema)
        {
            if (parameterSchema.Database.Provider.Name != "SqlSchemaProvider")
                return parameterSchema.NativeType;

            SqlParameter param = new SqlParameter();
            param.DbType = parameterSchema.DataType;

            return GetSqlTypeDeclaration(
                parameterSchema.NativeType,
                parameterSchema.Size,
                parameterSchema.Precision,
                parameterSchema.Scale,
                false,
                false);
        }
Exemplo n.º 44
0
        public static string GetUIMaskedTextBoxSetupDeclaration(ParameterSchema parameter, System.Drawing.Point point, System.Drawing.Size size, int tabIndex, string mask, string text)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();

            builder.Append("// \r\n");
            builder.Append(string.Format("\t\t// mtb{0}\r\n",GetPropertyName(parameter)));
            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t this.mtb{0}.AllowPromptAsInput = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.mtb{0}.Enabled = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.mtb{0}.HidePromptOnLeave = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.mtb{0}.Location = new System.Drawing.Point({1}, {2});\r\n",GetPropertyName(parameter),point.X,point.Y));
            builder.Append(string.Format("\t\t this.mtb{0}.Mask = \"{1}\";\r\n",GetPropertyName(parameter),mask));
            builder.Append(string.Format("\t\t this.mtb{0}.Name = \"mtb{0}\";\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.mtb{0}.Size = new System.Drawing.Size({1}, {2});\r\n",GetPropertyName(parameter),size.Width,size.Height));
            builder.Append(string.Format("\t\t this.mtb{0}.TabIndex = {1};\r\n",GetPropertyName(parameter),tabIndex));
            builder.Append(string.Format("\t\t this.mtb{0}.Text = \"{1}\";\r\n",GetPropertyName(parameter),text));

            return builder.ToString();
        }
Exemplo n.º 45
0
        public string GetMemberVariableDeclarationStatementProc(string protectionLevel, ParameterSchema param)
        {
            string statement = protectionLevel + " ";

            statement += GetCSharpVariableTypeProc(param) + " " + GetMemberVariableNameProc(param);
            string defaultValue = GetMemberVariableDefaultValueProc(param);

            if (defaultValue != "")
            {
                statement += " = " + defaultValue;
            }
            statement += ";";
            return(statement);
        }
Exemplo n.º 46
0
        public static string GetUITextBoxSetupDeclaration(ParameterSchema parameter, System.Drawing.Point point, System.Drawing.Size size, int tabIndex)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();

            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t// txt{0}\r\n",GetPropertyName(parameter)));
            builder.Append("\t\t// \r\n");
            builder.Append(string.Format("\t\t this.txt{0}.Enabled = true;\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.txt{0}.Location = new System.Drawing.Point({1}, {2});\r\n",GetPropertyName(parameter),point.X,point.Y));
            builder.Append(string.Format("\t\t this.txt{0}.Name = \"txt{0}\";\r\n",GetPropertyName(parameter)));
            builder.Append(string.Format("\t\t this.txt{0}.Size = new System.Drawing.Size({1}, {2});\r\n",GetPropertyName(parameter),size.Width,size.Height));
            builder.Append(string.Format("\t\t this.txt{0}.TabIndex = {1};\r\n",GetPropertyName(parameter),tabIndex));

            return builder.ToString();
        }
Exemplo n.º 47
0
        public string GetCSharpVariableTypeProc(ParameterSchema column)
        {
            if (column.Name.EndsWith("TypeCode"))
            {
                return(column.Name);
            }
            switch (column.DataType)
            {
            case DbType.AnsiString: return("string");

            case DbType.AnsiStringFixedLength: return("string");

            case DbType.Binary: return("byte[]");

            case DbType.Boolean: return("bool");

            case DbType.Byte: return("byte");

            case DbType.Currency: return("decimal");

            case DbType.Date: return("DateTime");

            case DbType.DateTime: return("DateTime");

            case DbType.Decimal: return("decimal");

            case DbType.Double: return("double");

            case DbType.Guid: return("Guid");

            case DbType.Int16: return("short");

            case DbType.Int32: return("int");

            case DbType.Int64: return("long");

            case DbType.Object: return("object");

            case DbType.SByte: return("sbyte");

            case DbType.Single: return("float");

            case DbType.String: return("string");

            case DbType.StringFixedLength: return("string");

            case DbType.Time: return("TimeSpan");

            case DbType.UInt16: return("ushort");

            case DbType.UInt32: return("uint");

            case DbType.UInt64: return("ulong");

            case DbType.VarNumeric: return("decimal");

            case DbType.Xml: return("string");

            default:
            {
                return("__UNKNOWN__" + column.NativeType);
            }
            }
        }
Exemplo n.º 48
0
 /// <summary>
 /// Get the cleaned, camelcased name of a parameter
 /// </summary>
 /// <param name="par">Command Parameter</param>
 /// <returns>the cleaned, camelcased name </returns>
 public string GetCleanParName(ParameterSchema par)
 {
     return GetCleanParName(par.Name);
 }
Exemplo n.º 49
0
        private void CreateFunction(CommandSchema commandSchema)
        {
            Function function;
            string   key   = commandSchema.FullName;
            bool     isNew = !Database.Functions.Contains(key);

            if (isNew)
            {
                function = new Function(key);
                Database.Functions.Add(function);
            }
            else
            {
                function = Database.Functions[key];
            }

            //Function/@Method is safe to update
            if (string.IsNullOrEmpty(function.Method))
            {
                string methodName = ToLegalName(commandSchema.Name);
                if (ClassNames.Contains(methodName))
                {
                    methodName += "Procedure";
                }

                function.Method = MakeUnique(FunctionNames, methodName);
            }

            function.IsComposable = IsFunction(commandSchema);

            ParameterSchema returnParameter = null;

            function.Parameters.Clear();
            foreach (ParameterSchema p in commandSchema.Parameters)
            {
                if (p.Direction == System.Data.ParameterDirection.ReturnValue)
                {
                    returnParameter = p;
                }
                else
                {
                    CreateParameter(function, p);
                }
            }

            try
            {
                for (int i = 0; i < commandSchema.CommandResults.Count; i++)
                {
                    var    r           = commandSchema.CommandResults[i];
                    string defaultName = function.Method + "Result";
                    if (commandSchema.CommandResults.Count > 1)
                    {
                        defaultName += (i + 1).ToString();
                    }

                    CreateResult(function, r, defaultName, i);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error reading result schema: " + ex.Message);
            }

            function.HasMultipleResults = function.Types.Count > 1;
            function.IsProcessed        = true;

            if (function.Types.Count != 0)
            {
                return;
            }

            if (function.Return == null)
            {
                function.Return = new Return("System.Int32");
            }

            if (commandSchema.ReturnValueParameter != null)
            {
                function.Return.Type   = GetSystemType(commandSchema.ReturnValueParameter);
                function.Return.DbType = GetDbType(commandSchema.ReturnValueParameter);
            }
            else if (returnParameter != null)
            {
                function.Return.Type   = GetSystemType(returnParameter);
                function.Return.DbType = GetDbType(returnParameter);
            }
            else
            {
                function.Return.Type   = "System.Int32";
                function.Return.DbType = "int";
            }
        }
Exemplo n.º 50
0
		/// <summary>
		/// Adds a ParameterSchema
		/// </summary>
		/// <param name="p"></param>
		public void AddParameter(ParameterSchema p)
		{
			parameters[p.Name] = p;
		}
Exemplo n.º 51
0
 public static string GetUIControlInstanceStatement(ParameterSchema parameter)
 {
     switch (parameter.DataType)
     {
         case DbType.AnsiString: return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         case DbType.AnsiStringFixedLength: return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         case DbType.Binary: return string.Format("this.mtb{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         case DbType.Boolean: return string.Format("this.chk{0} = new System.Windows.Forms.CheckBox();",GetPropertyName(parameter));
         case DbType.Byte: return string.Format("this.chk{0} = new System.Windows.Forms.CheckBox();",GetPropertyName(parameter));
         case DbType.Currency: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.Date: return string.Format("this.dtp{0} = new System.Windows.Forms.DateTimePicker();",GetPropertyName(parameter));
         case DbType.DateTime: return string.Format("this.dtp{0} = new System.Windows.Forms.DateTimePicker();",GetPropertyName(parameter));
         case DbType.Decimal: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.Double: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.Guid: return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         case DbType.Int16: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.Int32: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.Int64: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.Object: return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         case DbType.SByte: return string.Format("this.chk{0} = new System.Windows.Forms.CheckBox();",GetPropertyName(parameter));
         case DbType.Single: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.String: return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         case DbType.StringFixedLength: return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         //case DbType.Time: return canBeNullable ? "TimeSpan?" : "TimeSpan";
         case DbType.UInt16: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.UInt32: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.UInt64: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         case DbType.VarNumeric: return string.Format("this.mtb{0} = new System.Windows.Forms.MaskedTextBox();",GetPropertyName(parameter));
         default:
         {
             return string.Format("this.txt{0} = new System.Windows.Forms.TextBox();",GetPropertyName(parameter));
         }
     }
 }
Exemplo n.º 52
0
        public static string BuildXmlParameterComment(ParameterSchema parameter)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();

            builder.Append("/// <summary>\r\n");
            builder.Append("\t\t/// <param name=\"");
            builder.Append(parameter.Name);
            builder.Append("\">");
            builder.Append("Type:");
            builder.Append(parameter.DataType);
            builder.Append("\r\n\t\t/// </param>\r\n");
            builder.Append("\t\t/// <remarks>");
            builder.Append("\r\n\t\t/// " + parameter.Description);
            builder.Append("\r\n\t\t/// </remarks>\r\n");
            builder.Append("\t\t/// </summary>");

            return builder.ToString();
        }