Ejemplo n.º 1
0
        /// <summary>
        /// 目录名称更新,
        /// 1.更新数据表中所有子级文件相对路径
        /// 2.更新数据表中所有子级目录相对路径
        /// </summary>
        /// <param name=""></param>
        void folder_renamed(string pathRelOld, string pathRelNew)
        {
            DBConfig cfg = new DBConfig();
            SqlExec  se  = cfg.se();
            string   sql = string.Format("update up6_files set f_pathRel=REPLACE(f_pathRel,'{0}/','{1}/') where CHARINDEX('{0}/',f_pathRel)>0",
                                         pathRelOld,
                                         pathRelNew
                                         );

            if (cfg.m_isOracle)
            {
                sql = string.Format("update up6_files set f_pathRel=REPLACE(f_pathRel,'{0}/','{1}/') where instr(f_pathRel,'{0}/')>0",
                                    pathRelOld,
                                    pathRelNew
                                    );
            }
            se.exec(sql);

            //更新目录表
            sql = string.Format("update up6_folders set f_pathRel=REPLACE(f_pathRel,'{0}/','{1}/') where CHARINDEX('{0}/',f_pathRel)>0",
                                pathRelOld,
                                pathRelNew
                                );
            if (cfg.m_isOracle)
            {
                sql = string.Format("update up6_folders set f_pathRel=REPLACE(f_pathRel,'{0}/','{1}/') where instr(f_pathRel,'{0}/')>0",
                                    pathRelOld,
                                    pathRelNew
                                    );
            }
            se.exec(sql);
        }
Ejemplo n.º 2
0
 public override DataType Bind( SqlExec e )
 {
   Type = E.Bind( e );
   if ( Type != DataType.Bigint && Type != DataType.Double && Type < DataType.Decimal )
     e.Error( "Unary minus needs numeric argument" );
   return Type;
 }
Ejemplo n.º 3
0
 public override DataType Bind( SqlExec e )
 {
   Lhs.Bind( e );
   Rhs.Bind( e );
   if ( Lhs.Type != Rhs.GetElementType() ) e.Error( "IN type mismatch" );
   return Type;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 批量删除
        /// </summary>
        void file_del_batch()
        {
            var par = Request.Form["data"];

            par = Server.UrlDecode(par);
            var obj = JToken.Parse(par);

            DBConfig cfg = new DBConfig();
            SqlExec  se  = cfg.se();

            //更新文件
            se.exec_batch("up6_files"
                          , "update up6_files set f_deleted=1 where f_id=@f_id"
                          , string.Empty
                          , "f_id"
                          , obj);

            //更新文件夹
            se.exec_batch("up6_folders"
                          , "update up6_folders set f_deleted=1 where f_id=@f_id"
                          , string.Empty
                          , "f_id"
                          , obj);

            PageTool.to_content(obj);
        }
Ejemplo n.º 5
0
 public override void Bind( SqlExec e )
 {
   E.Bind( e );
   Type = E.Type;
   if ( Type != DataType.Bigint && Type != DataType.Double && Type < DataType.Decimal )
     e.Error( "Unary minus needs numeric argument" );
 }
 public void CheckLabelsDefined(SqlExec e)
 {
     if (JumpUndefined != 0)
     {
         e.Error("Undefined Goto Label");
     }
 }
Ejemplo n.º 7
0
  public override DataType TypeCheck( SqlExec e )
  {
    DataType tL = Left.TypeCheck( e );
    DataType tR = Right.TypeCheck( e );

    if ( tL == DataType.Bigint && tR == DataType.Double )
    {
      Left = new IntToDoubleExp(Left);
      tL = DataType.Double;
    }
    else if ( tR == DataType.Bigint && tL == DataType.Double )
    {
      Right = new IntToDoubleExp(Right);
      tR = DataType.Double;
    }
    else if ( Operator != Token.VBar && ( tL >= DataType.Decimal || tR >= DataType.Decimal ) )
    {
      if ( tR == DataType.Bigint ) tR = DTI.Decimal(18,0);
      else if ( tL == DataType.Bigint ) tL = DTI.Decimal(18,0);
      else if ( tR == DataType.Float ) { Right = Right.Convert( tL ); tR = tL; }
      else if ( tL == DataType.Float ) { Left = Left.Convert( tR ); tL = tR; }

      int sL = DTI.Scale(tL);
      int sR = DTI.Scale(tR);

      if ( sL < 0 || sR < 0 ) e.Error( "Type error involving decimal" );

      switch( Operator )
      {
        case Token.Divide: tL = DTI.Decimal( 18, sL - sR ); break;
        case Token.Times:  tL = DTI.Decimal( 18, sL + sR );  break;
        case Token.Percent: break; 
        default: 
          if ( sL > sR ) { Right = new ExpScale( Right, tL, sL - sR ); tR = tL; }
          else if ( sL < sR ) { Left = new ExpScale( Left, tR, sR - sL ); tL = tR; }
          break;
      }
      tR = tL;
    }    
    if ( tL == tR )
    {
      if ( Operator <= Token.NotEqual ) 
        Type = DataType.Bool;
      else 
      {
        Type = tL;
        if ( !TokenInfo.OperatorValid( Operator, tL ) ) 
          e.Error ( "Type error " + TokenInfo.Name(Operator) + " not valid for type " + DTI.Name(tL) );
      }
    }
    else if ( tL == DataType.String && Operator == Token.VBar )
    {
      Type = DataType.String;
      Right = Right.Convert( DataType.String );
    }
    else e.Error( "Binary operator datatype error");
    return Type;
  }
 public override DataType Bind(SqlExec e)
 {
     SType = E.Bind(e);
     if (SType != DataType.String && SType != DataType.Binary)
     {
         e.Error("LEN argument must be string or binary");
     }
     return(Type);
 }
Ejemplo n.º 9
0
 public override void Bind(SqlExec e)
 {
     E.Bind(e);
     SType = E.Type;
     if (SType != DataType.String && SType != DataType.Binary)
     {
         e.Error("LEN argument must be string or binary");
     }
 }
Ejemplo n.º 10
0
        void mk_folder()
        {
            var obj  = this.request_to_json();
            var name = obj["f_nameLoc"].ToString().Trim();
            var pid  = obj["f_pid"].ToString().Trim();

            obj["f_pathRel"] = PathTool.combin(obj["f_pathRel"].ToString(), obj["f_nameLoc"].ToString());

            DbFolder df = new DbFolder();

            if (df.exist_same_folder(name, pid))
            {
                var ret = new JObject {
                    { "ret", false }, { "msg", "已存在同名目录" }
                };
                this.toContent(ret);
                return;
            }

            DBConfig cfg = new DBConfig();
            SqlExec  se  = cfg.se();

            //根目录
            if (string.IsNullOrEmpty(pid))
            {
                obj["f_id"] = Guid.NewGuid().ToString("N");

                se.insert("up6_files", new SqlParam[] {
                    new SqlParam("f_id", obj["f_id"].ToString())
                    , new SqlParam("f_pid", obj["f_pid"].ToString())
                    , new SqlParam("f_uid", int.Parse(obj["uid"].ToString()))
                    , new SqlParam("f_pidRoot", obj["f_pidRoot"].ToString())
                    , new SqlParam("f_nameLoc", obj["f_nameLoc"].ToString())
                    , new SqlParam("f_complete", true)
                    , new SqlParam("f_fdTask", true)
                    , new SqlParam("f_pathRel", obj["f_pathRel"].ToString())
                });
            }//子目录
            else
            {
                obj["f_id"] = Guid.NewGuid().ToString("N");
                se.insert("up6_folders"
                          , new SqlParam[] {
                    new SqlParam("f_id", obj["f_id"].ToString())
                    , new SqlParam("f_pid", obj["f_pid"].ToString())
                    , new SqlParam("f_uid", int.Parse(obj["uid"].ToString()))
                    , new SqlParam("f_pidRoot", obj["f_pidRoot"].ToString())
                    , new SqlParam("f_nameLoc", obj["f_nameLoc"].ToString())
                    , new SqlParam("f_complete", true)
                    , new SqlParam("f_pathRel", obj["f_pathRel"].ToString())
                });
            }

            obj["ret"] = true;
            this.toContent(obj);
        }
Ejemplo n.º 11
0
 public override DataType Bind( SqlExec e  )
 {
   for ( int i = 0; i < List.Length; i += 1 ) 
   {
     DataType dt = List[i].Bind( e );
     if ( i == 0 ) ElementType = dt;
     else if ( dt != ElementType ) e.Error( "Tuple type error" ); // Maybe should apply Exp.Convert if possible.
   } 
   return Type;
 }
Ejemplo n.º 12
0
  public override DataType Bind( SqlExec e  )
  {
    B = e.Db.GetRoutine( Schema, FuncName, true, e );
    Type = B.ReturnType;

    for ( int i = 0; i < Plist.Length; i += 1 )
      Plist[ i ].Bind( e );

    return TypeCheck( e );
  }
Ejemplo n.º 13
0
 public override void Bind( SqlExec e  )
 {
   for ( int i = 0; i < List.Length; i += 1 ) 
   {
     List[ i ].Bind( e );
     DataType dt = List[ i ].Type;
     if ( i == 0 ) Type = dt;
     else if ( dt != Type ) e.Error( "Tuple type error" ); // Maybe should apply Exp.Convert if possible.
   } 
   Dvs = Util.GetDVList( List );
 }
Ejemplo n.º 14
0
        void load_uncmp_down()
        {
            string   uid   = Request.QueryString["uid"];
            DBConfig cfg   = new DBConfig();
            SqlExec  se    = cfg.se();
            var      files = se.select("down_files"
                                       , "f_id,f_nameLoc,f_pathLoc,f_perLoc,f_sizeSvr,f_fdTask"
                                       , new SqlParam[] { new SqlParam("f_uid", int.Parse(uid)) });

            PageTool.to_content(files);
        }
Ejemplo n.º 15
0
 public override DataType Bind( SqlExec e )
 {
   for ( int i = 0; i < List.Length; i += 1 ) 
   {
     Exp test = List[i].Test;
     if ( test != null && test.Bind( e )!= DataType.Bool ) e.Error( "Case test must be Bool" );
     DataType dt = List[i].E.Bind( e );
     if ( i == 0 ) Type = dt;
     else if ( dt != Type ) e.Error( "Case expressions must all have same type" );
   } 
   return Type;
 }
Ejemplo n.º 16
0
 public override void Bind(SqlExec e)
 {
     for (int i = 0; i < Types.Length; i += 1)
     {
         Arg[i].Bind(e);
         DataType t = Arg[i].Type;
         if (t != Types[i])
         {
             e.Error(this + " parameter type error, arg " + i + " expected "
                     + DTI.Name(Types[i]) + " actual " + DTI.Name(t));
         }
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 加载未完成的文件和目录列表
        /// </summary>
        void load_uncomplete()
        {
            string   uid   = this.reqString("uid");
            DBConfig cfg   = new DBConfig();
            SqlExec  se    = cfg.se();
            string   sql   = string.Format("select f_id ,f_nameLoc ,f_pathLoc ,f_sizeLoc ,f_lenSvr ,f_perSvr ,f_fdTask ,f_md5 from up6_files where f_complete=0 and f_deleted=0 and f_uid={0}", int.Parse(uid));
            var      files = se.exec("up6_files"
                                     , sql
                                     , "f_id,f_nameLoc,f_pathLoc,f_sizeLoc,f_lenSvr,f_perSvr,f_fdTask,f_md5"
                                     , "id,nameLoc,pathLoc,sizeLoc,lenSvr,perSvr,fdTask,md5");

            this.toContent(files);
        }
Ejemplo n.º 18
0
 public override DataType TypeCheck( SqlExec e )
 {
   if ( B.Params.Count != Plist.Length ) e.Error( "Param count error calling function " + FuncName );
   for ( int i = 0; i < Plist.Length; i += 1 )
     if ( Plist[i].Type != B.Params.Types[i] )
     {
       Exp conv = Plist[i].Convert( B.Params.Types[i] );
       if ( conv != null ) Plist[i] = conv;
       else e.Error( "Parameter Type Error calling function " + FuncName 
          + " required type=" + DTI.Name( B.Params.Types[i] ) 
          + " supplied type=" + DTI.Name( Plist[i].Type ) + " exp=" + Plist[i] );
     }
   return Type;
 }
Ejemplo n.º 19
0
        public SqlExec se()
        {
            var exec = new SqlExec();

            if (this.m_isOracle)
            {
                exec = new OracleExec();
            }
            if (this.m_isOdbc)
            {
                exec = new OdbcExec();
            }
            exec.m_cfg = this;
            return(exec);
        }
Ejemplo n.º 20
0
 public override void Bind( SqlExec e )
 {
   for ( int i = 0; i < List.Length; i += 1 ) 
   {
     if ( List[ i ].Test != null )
     {
       List[ i ].Test.Bind( e );
       if ( List[ i ].Test.Type != DataType.Bool ) e.Error( "Case test must be Bool" );
     }
     List[ i ].E.Bind( e );
     DataType dt = List[ i ].E.Type;
     if ( i == 0 ) Type = dt;
     else if ( dt != Type ) e.Error( "Case expressions must all have same type" );
   } 
 }
Ejemplo n.º 21
0
  public override void Bind( SqlExec e )
  {
    var ci = e.CI;
    if ( ci == null ) e.Error( "Undeclared variable " + ColName );
    for ( int i=0; i < ci.Count; i += 1 ) 
      if ( ci.Name[ i ] == ColName ) 
      { 
        e.Used[ i ] = true;
        ColIx = i; 
        Type = DTI.Base( ci.Type[ i ] );
        return;
      }

    e.Error( "Column " + ColName + " not found" );
  }
Ejemplo n.º 22
0
        /// <summary>
        /// 删除文件
        /// </summary>
        void file_del()
        {
            var id      = this.reqString("id");
            var pathRel = this.reqStringDecode("pathRel");

            pathRel += '/';

            SqlWhereMerge swm = new SqlWhereMerge();
            DBConfig      cfg = new DBConfig();

            if (cfg.m_isOracle || cfg.m_isOdbc)
            {
                swm.instr(pathRel, "f_pathRel");
            }
            else
            {
                swm.charindex(pathRel, "f_pathRel");
            }
            string where = swm.to_sql();

            SqlExec se = cfg.se();

            se.update("up6_folders"
                      , new SqlParam[] { new SqlParam("f_deleted", true) }
                      , where
                      );

            se.update("up6_folders"
                      , new SqlParam[] { new SqlParam("f_deleted", true) }
                      , new SqlParam[] { new SqlParam("f_id", id) }
                      );

            se.update("up6_files"
                      , new SqlParam[] { new SqlParam("f_deleted", true) }
                      , where
                      );

            se.update("up6_files"
                      , new SqlParam[] { new SqlParam("f_deleted", true) }
                      , new SqlParam[] { new SqlParam("f_id", id) }
                      );

            PageTool.to_content(new JObject {
                { "ret", 1 }
            });
        }
Ejemplo n.º 23
0
  public override void Bind( SqlExec e  )
  {
    B = e.Db.GetRoutine( Schema, FuncName, true, e );
    Type = B.ReturnType;

    e.Bind( Plist );

    if ( B.Params.Count != Plist.Length ) e.Error( "Param count error calling function " + FuncName );
    for ( int i = 0; i < Plist.Length; i += 1 )
      if ( Plist[ i ].Type != B.Params.Type[ i ] )
      {
        Exp conv = Plist[ i ].Convert( B.Params.Type[ i ] );
        if ( conv != null ) Plist[ i ] = conv;
        else e.Error( "Parameter Type Error calling function " + FuncName 
           + " required type=" + DTI.Name( B.Params.Type[ i ] ) 
           + " supplied type=" + DTI.Name( Plist[ i ].Type ) + " exp=" + Plist[ i ] );
      }
  }
Ejemplo n.º 24
0
  public override DataType Bind( SqlExec e )
  {
    var ci = e.CI;
    if ( ci == null ) e.Error( "Undeclared variable " + ColName );
    for ( int i=0; i < ci.Count; i += 1 ) 
      if ( ci.Names[i] == ColName ) 
      { 
        e.Used[ i ] = true;
        ColIx = i; 
        Type = DTI.Base( ci.Types[i] );
        return Type;
      }

    // for ( int i=0; i < ci.Length; i += 1 ) System.Console.WriteLine( ci[i].Name );
    
    e.Error( "Column " + ColName + " not found" );
    return Type;
  }
Ejemplo n.º 25
0
  public TableExpression GetTableOrView( string schemaName, string name, Exec e )
  {
    Schema schema = GetSchema( schemaName, true, e );
    TableExpression result = schema.GetCachedTable( name ); 
    if ( result != null ) return result;

    bool isView; string definition;
    long tid = ReadTableId( schema, name, out isView, out definition );
    if ( tid < 0 ) e.Error( schemaName + "." + name + " not found" );

    if ( isView )
    {
      TableExpression te = SqlExec.LoadView( definition, schemaName + "." + name, this );
      te.TableId = tid;
      schema.TableDict[ name ] = te;
      return te;
    }
    else
    {
      // Fetch the Column Information from the SysColumn table.
      var names = new G.List<string>(); 
      var types = new G.List<DataType>();
      names.Add( "Id" ); types.Add( DataType.Bigint ); // Add the pre-defined "id" column.

      // Use SysColumnIndex to avoid scanning the entire SysColumn table.
      var start = new LongStart( tid );
      var r = new RowCursor( SysColumn );

      foreach( IndexFileRecord ixr in SysColumnIndex.From( start.Compare, false ) )
      {
        if ( ixr.Col[0].L == tid )
        {
          r.Get( ixr.Col[1].L );
          names.Add( r.V[2].S );
          types.Add( (DataType)r.V[3].L );
        }
        else break;
      }

      Table t = new Table( this, schema, name, ColInfo.New(names,types), tid );
      t.OpenIndexes();
      return t;
    }
  }
Ejemplo n.º 26
0
        void load_tree()
        {
            var pid = Request.QueryString["pid"];
            var swm = new SqlWhereMerge();

            swm.equal("f_fdChild", 0);
            swm.equal("f_fdTask", 1);
            swm.equal("f_deleted", 0);
            if (!string.IsNullOrEmpty(pid))
            {
                swm.equal("f_pid", pid);
            }

            DBConfig cfg  = new DBConfig();
            SqlExec  se   = cfg.se();
            JArray   arr  = new JArray();
            var      data = se.select("up6_files"
                                      , "f_id,f_pid,f_pidRoot,f_nameLoc"
                                      , swm.to_sql()
                                      , string.Empty);

            //查子目录
            if (!string.IsNullOrEmpty(pid))
            {
                data = se.select("up6_folders"
                                 , "f_id,f_pid,f_pidRoot,f_nameLoc"
                                 , new SqlParam[] {
                    new SqlParam("f_pid", pid)
                    , new SqlParam("f_deleted", false)
                });
            }

            foreach (var f in data)
            {
                var item = new JObject();
                item["id"]      = f["f_id"].ToString();
                item["text"]    = f["f_nameLoc"].ToString();
                item["parent"]  = "#";
                item["nodeSvr"] = f;
                arr.Add(item);
            }
            this.toContent(arr);
        }
  public Block GetRoutine( string schemaName, string name, bool func, Exec e )
  {
    Schema schema = GetSchema( schemaName, true, e );
    string cname = name + ( func ? "F" : "P" );

    // See if routine is cached.
    Block result; if( schema.BlockDict.TryGetValue( cname, out result ) ) return result;

    string sql = (string) ScalarSql( "SELECT Definition from sys." + (func?"Function":"Procedure") 
      + " where Name=" + Util.Quote(name) + " AND Schema=" + schema.Id )._O;

    if ( sql == null ) e.Error( "Function not found " + name );

    result = SqlExec.LoadRoutine( func, sql, this, schemaName + "." + name );

    // System.Console.WriteLine( "Loaded " + schemaName + "." + name );

    schema.BlockDict[ cname ] = result;
    return result;
  }
Ejemplo n.º 28
0
        /// <summary>
        /// 取根目录下所有子文件
        /// 注意:传进来的必须是根目录ID
        /// </summary>
        /// <param name="pidRoot"></param>
        /// <returns></returns>
        public string childs(string pidRoot)
        {
            var se = new SqlExec();
            var fs = (JArray)se.select("up6_files", "f_id,f_nameLoc,f_pathSvr,f_pathRel,f_lenSvr",
                                       new SqlParam[] { new SqlParam("f_pidRoot", pidRoot) }
                                       );

            var childs = new JArray();

            foreach (var o in fs)
            {
                childs.Add(new JObject {
                    { "f_id", o["f_id"] },
                    { "nameLoc", o["f_nameLoc"] },
                    { "pathSvr", o["f_pathSvr"] },
                    { "pathRel", o["f_pathRel"] },
                    { "lenSvr", o["f_lenSvr"] }
                });
            }
            return(JsonConvert.SerializeObject(childs));
        }
Ejemplo n.º 29
0
        public override void del(string id, int uid)
        {
            DBConfig cfg = new DBConfig();
            SqlExec  se  = cfg.se();

            se.update("up6_files",
                      new SqlParam[] {
                new SqlParam("f_deleted", true)
            },
                      new SqlParam[] {
                new SqlParam("f_id", id),
                new SqlParam("f_uid", uid)
            });
            se.update("up6_folders",
                      new SqlParam[] {
                new SqlParam("f_deleted", true)
            },
                      new SqlParam[]
            {
                new SqlParam("f_id", id),
                new SqlParam("f_uid", uid)
            });
        }
        // Statement execution.

        public void ExecProcedure(Block b, G.List <Exp> parms, SqlExec e)
        {
            // Allocate the local variables for the called procedure.
            var locals = new Value[b.LocalType.Count];

            // Evaluate the parameters to be passed, saving them in the newly allocated local variables.
            for (int i = 0; i < parms.Count; i += 1)
            {
                locals[i] = parms[i].Eval(this);
            }

            // Save local state.
            var save1 = b.Locals;
            var save2 = b.NextStatement;

            // Execute the procedure
            b.Locals = locals;
            b.ExecuteStatements(ResultSet);

            // Restore local state.
            b.NextStatement = save2;
            b.Locals        = save1;
        }
        public Error InsertDocumentacionDA(int IdSiniestro, int IdPaqueteria, string FechaEnvio, string NoGuia, int IdDocumentacion)
        {
            Error error;
            SqlExec sql = new SqlExec("InsertDocumencionSinDA");

            try
            {
                sql.AddParameter("@Id_Siniestro_DA", IdSiniestro, SqlDbType.Int);

                if (IdPaqueteria > 0)
                {
                    sql.AddParameter("@Id_Paqueteria", IdPaqueteria, SqlDbType.TinyInt);
                    sql.AddParameter("@Fecha_Env", DateTime.Parse(FechaEnvio), SqlDbType.DateTime);
                    sql.AddParameter("@No_Guia", NoGuia, SqlDbType.NVarChar);
                    sql.AddParameter("@Id_Documentacion", IdDocumentacion, SqlDbType.Int);
                }

                error = sql.Execute();
            }

            catch (Exception ex)
            {
                error = new Error();
                error.Mensaje = ex.Message;
                error.Valor = true;
            }

            finally
            {
                sql.FinalizaConexion();
            }

            return error;
        }