Ejemplo n.º 1
0
        public void setParameters(int cursor,
                                  IFieldSetter stmt,
                                  Object[] parms)
        {
            switch (cursor)
            {
            case 0:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 1:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 2:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;
            }
        }
Ejemplo n.º 2
0
        public void setParameters(int cursor,
                                  IFieldSetter stmt,
                                  Object[] parms)
        {
            switch (cursor)
            {
            case 0:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 1:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 2:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 3:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 4:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 5:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 6:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 7:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 8:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 9:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 10:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 11:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 12:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 13:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 14:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 15:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 16:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 17:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 18:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 19:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 20:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 21:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 22:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 23:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 24:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 25:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;

            case 26:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 27:
                stmt.SetParameter(1, (long)parms[0]);
                return;

            case 28:
                if ((bool)parms[0])
                {
                    stmt.setNull(1, SqlDbType.Decimal);
                }
                else
                {
                    stmt.SetParameter(1, (long)parms[1]);
                }
                return;
            }
        }
Ejemplo n.º 3
0
        public void setParameters(int cursor,
                                  IFieldSetter stmt,
                                  Object[] parms)
        {
            List <ParDef> parmdefs          = stmt.ParameterDefinition;
            int           idx               = 0;
            int           idxParmCollection = 1;

            object[] parmsValues = new object[parmdefs.Count];
            foreach (ParDef pdef in parmdefs)
            {
                bool valueIsNull = false;
                try
                {
                    if (pdef.InOut)
                    {
                        stmt.RegisterInOutParameter(idxParmCollection, null);
                    }
                    else if (pdef.Out)
                    {
                        stmt.RegisterOutParameter(idxParmCollection, null);
                        continue;
                    }

                    if (pdef.Nullable)
                    {
                        valueIsNull = (bool)parms[idx];
                        if (valueIsNull)
                        {
                            stmt.setNull(idxParmCollection, DBNull.Value);
                        }
                        idx += 1;
                    }
                    parmsValues[idxParmCollection - 1] = parms[idx];
                    if (!valueIsNull)
                    {
                        switch (pdef.GxType)
                        {
                        case GXType.Char:
                        case GXType.NChar:
                        case GXType.VarChar:
                            if (pdef.AddAtt && !pdef.Preload)
                            {
                                if (!string.IsNullOrEmpty(pdef.Tbl) && !string.IsNullOrEmpty(pdef.Fld))
                                {
                                    stmt.SetParameterMultimedia(idxParmCollection, (string)parms[idx], (string)parmsValues[pdef.ImgIdx], pdef.Tbl, pdef.Fld);
                                }
                                else
                                {
                                    stmt.SetParameterMultimedia(idxParmCollection, (string)parms[idx], (string)parmsValues[pdef.ImgIdx]);
                                }
                            }
                            else
                            {
                                if (pdef.GxType == GXType.VarChar)
                                {
                                    if (pdef.ChkEmpty)
                                    {
                                        stmt.SetParameterVChar(idxParmCollection, (string)parms[idx]);
                                    }
                                    else
                                    {
                                        stmt.SetParameterObj(idxParmCollection, parms[idx]);
                                    }
                                }
                                else
                                {
                                    if (pdef.ChkEmpty)
                                    {
                                        stmt.SetParameterChar(idxParmCollection, (string)parms[idx]);
                                    }
                                    else
                                    {
                                        stmt.SetParameter(idxParmCollection, (string)parms[idx]);
                                    }
                                }
                            }
                            break;

                        case GXType.NVarChar:
                            if (pdef.ChkEmpty)
                            {
                                stmt.SetParameterVChar(idxParmCollection, (string)parms[idx]);
                            }
                            else
                            {
                                stmt.SetParameter(idxParmCollection, (string)parms[idx]);
                            }
                            break;

                        case GXType.NClob:
                        case GXType.Clob:
                        case GXType.LongVarChar:
                            if (pdef.ChkEmpty)
                            {
                                stmt.SetParameterLVChar(idxParmCollection, (string)parms[idx]);
                            }
                            else
                            {
                                stmt.SetParameter(idxParmCollection, (string)parms[idx]);
                            }
                            break;

                        case GXType.Date:
                            stmt.SetParameter(idxParmCollection, (DateTime)parms[idx]);
                            break;

                        case GXType.DateAsChar:
                        case GXType.DateTime:
                            stmt.SetParameterDatetime(idxParmCollection, (DateTime)parms[idx]);
                            break;

                        case GXType.DateTime2:
                            stmt.SetParameterDatetime(idxParmCollection, (DateTime)parms[idx], true);
                            break;

                        case GXType.Blob:
                            stmt.SetParameterBlob(idxParmCollection, (string)parms[idx], pdef.InDB);
                            break;

                        case GXType.UniqueIdentifier:
                            stmt.SetParameter(idxParmCollection, (Guid)parms[idx]);
                            break;

                        case GXType.Geography:
                        case GXType.Geopoint:
                        case GXType.Geoline:
                        case GXType.Geopolygon:
                            stmt.SetParameter(idxParmCollection, (Geospatial)parms[idx], pdef.GxType);
                            break;

                        default:
                            stmt.SetParameterObj(idxParmCollection, parms[idx]);
                            break;
                        }
                    }
                    idx += 1;
                    idxParmCollection += 1;
                }
                catch (InvalidCastException ex)
                {
                    string msg = this.GetType() + ".setParameters error  parameterName:" + pdef.Name + " parameterType:" + pdef.GxType;
                    GXLogging.Error(log, ex, msg + " value:" + parms[idx]);
                    throw new Exception("Invalid parameter conversion at " + msg, ex);
                }
            }
        }
Ejemplo n.º 4
0
 public void setParameters(int cursor,
                           IFieldSetter stmt,
                           Object[] parms)
 {
     switch (cursor)
     {
     case 1:
         stmt.SetParameter(1, (long)parms[0]);
         if ((bool)parms[1])
         {
             stmt.setNull(2, SqlDbType.VarChar);
         }
         else
         {
             stmt.SetParameter(2, (String)parms[2]);
         }
         if ((bool)parms[3])
         {
             stmt.setNull(3, SqlDbType.VarChar);
         }
         else
         {
             stmt.SetParameter(3, (String)parms[4]);
         }
         if ((bool)parms[5])
         {
             stmt.setNull(4, SqlDbType.DateTime);
         }
         else
         {
             stmt.SetParameter(4, (DateTime)parms[6]);
         }
         if ((bool)parms[7])
         {
             stmt.setNull(5, SqlDbType.SmallInt);
         }
         else
         {
             stmt.SetParameter(5, (short)parms[8]);
         }
         if ((bool)parms[9])
         {
             stmt.setNull(6, SqlDbType.Bit);
         }
         else
         {
             stmt.SetParameter(6, (bool)parms[10]);
         }
         if ((bool)parms[11])
         {
             stmt.setNull(7, SqlDbType.Bit);
         }
         else
         {
             stmt.SetParameter(7, (bool)parms[12]);
         }
         if ((bool)parms[13])
         {
             stmt.setNull(8, SqlDbType.Bit);
         }
         else
         {
             stmt.SetParameter(8, (bool)parms[14]);
         }
         if ((bool)parms[15])
         {
             stmt.setNull(9, SqlDbType.VarChar);
         }
         else
         {
             stmt.SetParameter(9, (String)parms[16]);
         }
         if ((bool)parms[17])
         {
             stmt.setNull(10, SqlDbType.Decimal);
         }
         else
         {
             stmt.SetParameter(10, (long)parms[18]);
         }
         if ((bool)parms[19])
         {
             stmt.setNull(11, SqlDbType.VarChar);
         }
         else
         {
             stmt.SetParameter(11, (String)parms[20]);
         }
         return;
     }
 }