예제 #1
0
        public void SetConfig(RLib.DB.DbConn dbconn, string config)
        {
            string sql  = "update RuanalCfg set [Value]=@value where [Key]=@key;";
            string sql1 = "insert into RuanalCfg([Key],[Value]) values(@key,@value);";
            var    para = new { key = KEY, value = config ?? "" };
            int    r    = dbconn.ExecuteSql(sql, para);

            if (r == 0)
            {
                dbconn.ExecuteSql(sql1, para);
            }
            return;
        }
예제 #2
0
        public int DeleteRunLog(RLib.DB.DbConn dbconn, DateTime endtime)
        {
            int    timeOut = 2;//mins
            string sql     = "delete from taskRunLog where runServerTime<@endtime ";
            int    r       = dbconn.ExecuteSql(sql, new { endtime = endtime }, timeOut);
            var    obj     = dbconn.ExecuteScalar("select min(logid) from taskRunLog", null);

            if (RLib.Utils.Converter.ObjToInt(obj) > 5000 * 10000)
            {
                dbconn.ExecuteSql("DBCC CHECKIDENT (taskrunlog,reseed,1) ", new { });
            }
            return(r);
        }
예제 #3
0
        public int DeleteDispatchLog(RLib.DB.DbConn dbconn, DateTime endtime)
        {
            int    timeOut = 2;//mins
            string sql     = "delete from dispatch where createTime<@endtime ";
            int    r       = dbconn.ExecuteSql(sql, new { endtime = endtime }, timeOut);
            var    obj     = dbconn.ExecuteScalar("select min(dispatchId) from dispatch", null);

            if (RLib.Utils.Converter.ObjToInt(obj) > 5000 * 10000)
            {
                dbconn.ExecuteSql("DBCC CHECKIDENT (dispatch,reseed,1) ", new { });
            }
            return(r);
        }
예제 #4
0
        public int UpdateTaskLastRunTime(RLib.DB.DbConn dbconn, int nodeId, int taskId)
        {
            string sql = " update taskbinding set lastruntime=getdate() where taskid=@taskid and nodeid=@nodeid;";
            int    r   = dbconn.ExecuteSql(sql, new { taskid = taskId, nodeid = nodeId });

            return(r);
        }
예제 #5
0
        public int UpdateLastHeart(RLib.DB.DbConn dbconn, int nodeId)
        {
            string sql = "update  [dbo].[node] set lastHeartTime=getdate() WHERE nodeId=@nodeId;";
            int    r   = dbconn.ExecuteSql(sql, new { nodeId = nodeId });

            return(r);
        }
예제 #6
0
        public int Delete(RLib.DB.DbConn dbconn, int taskId)
        {
            string sql = "update task set [state]=-1 where taskid=@taskid;";
            int    r   = dbconn.ExecuteSql(sql, new { taskid = taskId });

            return(r);
        }
예제 #7
0
        public int Update(RLib.DB.DbConn dbconn, Model.Node model)
        {
            string sql = @"UPDATE [dbo].[node]
                     SET [clientId] =@clientId
                   ,title = @title
                  ,[nodeConfig] = @nodeConfig
              --     ,[nodeType] =@nodeType 
                  ,[macs] = @macs
                  ,[ips] = @ips 
                  ,[remark] =@remark
                WHERE nodeId=@nodeId";
            int    r   = dbconn.ExecuteSql(sql, new
            {
                nodeId     = model.NodeId,
                clientId   = model.ClientId ?? "",
                nodeConfig = model.NodeConfig ?? "",
                title      = model.Title ?? "",
                // nodeType = model.NodeType,
                macs   = model.Macs ?? "",
                ips    = model.IPS ?? "",
                state  = 0,
                remark = model.Remark ?? ""
            });

            return(r);
        }
예제 #8
0
        public int SetDispatchState(RLib.DB.DbConn dbconn, int nodeId, int stopDispathState)
        {
            string sql = "update  [dbo].[node] set stopDispatch=@stopdispatch WHERE nodeId=@nodeId;";
            int    r   = dbconn.ExecuteSql(sql, new { nodeId = nodeId, stopdispatch = stopDispathState });

            return(r);
        }
예제 #9
0
        public int SetNodeType(RLib.DB.DbConn dbconn, int nodeId, int nodeType)
        {
            string sql = "update  [dbo].[node] set nodeType=@nodetype WHERE nodeId=@nodeId and nodeType=-1;";
            int    r   = dbconn.ExecuteSql(sql, new { nodeId = nodeId, nodeType = nodeType });

            return(r);
        }
예제 #10
0
        public int Update(RLib.DB.DbConn dbconn, Model.Task model)
        {
            string sql = @"UPDATE [dbo].[task]
                               SET [title] =@title
                                  ,[taskType] = @taskType
                                  ,[runCron] =@runCron
                                  ,[taskConfig] = @taskConfig
                                  ,[taskTags] = @taskTags
                                  ,[enterDll] = @enterDll
                                  ,[enterClass] = @enterClass
                                  ,[dispatchClass]=@dispatchClass
                                    ,expireMins = @expireMins
                                  ,[updateTime] = getdate()
                                  ,[remark] = @remark
                             WHERE taskId=@taskId ";
            int    r   = dbconn.ExecuteSql(sql, new
            {
                taskId        = model.TaskId,
                title         = model.Title ?? "",
                taskTags      = model.TaskTags,
                taskType      = model.TaskType,
                runCron       = model.RunCron ?? "",
                taskConfig    = model.TaskConfig ?? "",
                enterDll      = model.EnterDll ?? "",
                enterClass    = model.EnterClass ?? "",
                dispatchClass = model.DispatchClass ?? "",
                expireMins    = model.ExpireMins,
                remark        = model.Remark ?? ""
            });

            return(r);
        }
예제 #11
0
        public int SetDispatch(RLib.DB.DbConn dbconn, int dispatchid, int nodeId)
        {
            string sql = "update dispatch set dispatchState=1,dispatchTime = getdate(),nodeId=@nodeid where dispatchId=@dispatchid and dispatchState=0 ";
            int    r   = dbconn.ExecuteSql(sql, new { dispatchid = dispatchid, nodeid = nodeId });

            return(r);
        }
예제 #12
0
        public int DeleteBind(RLib.DB.DbConn dbconn, int taskid, int nodeid)
        {
            string sql = " update taskbinding set localState=-1 where taskid=@taskid and nodeid=@nodeid and localState<>-1; ";
            int    r   = dbconn.ExecuteSql(sql, new { taskid = taskid, nodeid = nodeid });

            return(r);
        }
예제 #13
0
        public int UpdateBindLocalState(RLib.DB.DbConn dbconn, int bindid, int localstate)
        {
            string sql = " update taskbinding set localState=@localstate where bindid=@bindid;";
            int    r   = dbconn.ExecuteSql(sql, new { bindid = bindid, localstate = localstate });

            return(r);
        }
예제 #14
0
        public int DeleteBind(RLib.DB.DbConn dbconn, int bindId)
        {
            string sql = " update taskbinding set localState=-1 where bindId=@bindId; ";
            int    r   = dbconn.ExecuteSql(sql, new { bindId = bindId });

            return(r);
        }
예제 #15
0
        public Model.TaskBinding AddBinding(RLib.DB.DbConn dbconn, Model.TaskBinding model)
        {
            string sql = @"INSERT INTO [dbo].[taskBinding]
           ([taskId]
           ,[nodeId]
            ,[runVersion]
           ,[localState]
        --   ,[lastRunTime]
           ,[serverState])
     VALUES
           (@taskId
           ,@nodeId
            ,@runVersion
           ,@localState
      --     ,@lastRunTime
           ,@serverState)";

            dbconn.ExecuteSql(sql, new
            {
                taskId      = model.TaskId,
                nodeId      = model.NodeId,
                localState  = 0,
                serverState = 0,
                //   lastRunTime = model.LastRunTime,
                runVersion = 0
            });

            model.BindId = dbconn.GetIdentity();
            return(model);
        }
예제 #16
0
        public int DeleteVersion(RLib.DB.DbConn dbconn, int versionId)
        {
            string sql = "update taskVersion set vstate=-1 where versionId = @versionId";
            int    r   = dbconn.ExecuteSql(sql, new { versionId = versionId });

            return(r);
        }
예제 #17
0
        public Model.TaskVersion AddVersion(RLib.DB.DbConn dbconn, Model.TaskVersion model)
        {
            string sql = @"INSERT INTO [dbo].[taskVersion]
           ([taskId]
           ,[versionNO]
           ,[filePath]
           ,[fileSize]
           ,[vstate]
           ,[createTime]
           ,[remark])
     VALUES
           (@taskId
           ,@versionNO
           ,@filePath
           ,@fileSize
           ,@vstate
           ,getdate()
           ,@remark)";

            dbconn.ExecuteSql(sql, new
            {
                taskId    = model.TaskId,
                versionNO = model.VersionNO ?? "",
                filePath  = model.FilePath ?? "",
                fileSize  = model.FileSize,
                vstate    = 0,
                remark    = model.Remark ?? ""
            });

            model.VersionId = dbconn.GetIdentity();
            return(model);
        }
예제 #18
0
        public int SetVersion(RLib.DB.DbConn dbconn, int taskId, int versionId)
        {
            string sql = "update task set currVersionId=@versionid where taskid=@taskid";
            int    r   = dbconn.ExecuteSql(sql, new { versionid = versionId, taskid = taskId });

            return(r);
        }
예제 #19
0
        public int SetExec(RLib.DB.DbConn dbconn, int dispatchid)
        {
            string sql = "update dispatch set dispatchState=2,executeTime = getdate() where dispatchId=@dispatchid and dispatchState=1;";
            int    r   = dbconn.ExecuteSql(sql, new { dispatchid = dispatchid });

            return(r);
        }
예제 #20
0
        public int SetDispatchState(RLib.DB.DbConn dbconn, int taskId, int nodeId, int stopDispathState)
        {
            string sql = "update  [dbo].[taskbinding] set stopDispatch=@stopdispatch WHERE taskId=@taskId and nodeId=@nodeId;";
            int    r   = dbconn.ExecuteSql(sql, new { taskId = taskId, nodeId = nodeId, stopdispatch = stopDispathState });

            return(r);
        }
예제 #21
0
        public Model.Cmd AddCmd(RLib.DB.DbConn dbconn, Model.Cmd model)
        {
            string sql = @"INSERT INTO [dbo].[cmd]
           ([nodeId]
           ,[cmdType]
           ,[cmdArgs]
           ,[createTime]
           ,[cmdState]
      --     ,[callTime]
      --     ,[endTime]
      --     ,[resultText]
        )
     VALUES
           (@nodeid
           ,@cmdtype
           ,@cmdargs
           ,getdate()
           ,@cmdstate
     --      ,@callTime
     --      ,@endTime
      --     ,@resultText
      )";

            dbconn.ExecuteSql(sql, new
            {
                nodeid   = model.NodeId,
                cmdtype  = model.CmdType ?? "",
                cmdargs  = model.CmdArgs ?? "",
                cmdstate = 0
            });
            model.CmdId = dbconn.GetIdentity();
            return(model);
        }
예제 #22
0
        public int DeleteCmd(RLib.DB.DbConn dbconn, int cmdid)
        {
            string sql = "update cmd set cmdState=-1 where cmdid=@cmdid";
            int    r   = dbconn.ExecuteSql(sql, new { cmdid = cmdid });

            return(r);
        }
예제 #23
0
        public int Delete(RLib.DB.DbConn dbconn, int nodeId)
        {
            string sql = "update [dbo].[node] set state=-1 WHERE nodeId=@nodeId;";
            int    r   = dbconn.ExecuteSql(sql, new { nodeId = nodeId });

            return(r);
        }
예제 #24
0
        public int CallCmd(RLib.DB.DbConn dbconn, int cmdid)
        {
            string sql = "update cmd set cmdState=1 ,callTime=getdate() where cmdid=@cmdid and cmdState=0 ";
            int    r   = dbconn.ExecuteSql(sql, new { cmdid = cmdid });

            return(r);
        }
예제 #25
0
        public int EndCmd(RLib.DB.DbConn dbconn, int cmdid, bool success, string msg)
        {
            string sql = "update cmd set cmdState=@cmdstate ,endTime=getdate(),resultText = @resulttext where cmdid=@cmdid and cmdState=1 ;";
            int    r   = dbconn.ExecuteSql(sql, new { cmdid = cmdid, cmdstate = success ? 2 : 3, resulttext = msg ?? "" });

            return(r);
        }
예제 #26
0
        public int Delete(RLib.DB.DbConn dbconn, int dispatchid)
        {
            string sql = "update dispatch set dispatchState=-1  where dispatchId=@dispatchid ;";
            int    r   = dbconn.ExecuteSql(sql, new { dispatchid = dispatchid });

            return(r);
        }
예제 #27
0
        public int AutoExpire(RLib.DB.DbConn dbconn)
        {
            string sql    = " update  dispatch set dispatchState=10 where  dispatchState=0 and expireTime<getdate()   ;";
            var    models = dbconn.ExecuteSql(sql, new { });

            return(models);
        }
예제 #28
0
        public void SetTaskDispatchKeyRunning(RLib.DB.DbConn dbconn, int taskid, string runkey, int dispathid)
        {
            if (string.IsNullOrWhiteSpace(runkey))
            {
                return;
            }
            string sql  = "update dispatchKeyState set [keyState]=1,[dispatchId]=@dispatchid where [disKey]=@diskey ;";
            string sql2 = "insert into dispatchKeyState(disKey,[keyState],[dispatchId]) values (@diskey,1,@dispatchid) ;";
            var    key  = BuildDispatchKey(taskid, runkey);
            int    r    = dbconn.ExecuteSql(sql, new { diskey = key, dispatchid = dispathid });

            if (r == 0)
            {
                r = dbconn.ExecuteSql(sql2, new { diskey = key, dispatchid = dispathid });
            }
        }
예제 #29
0
        public int SuccessEndExec(RLib.DB.DbConn dbconn, int dispatchid)
        {
            string sql = "update dispatch set dispatchState=@rstate,endtime = getdate() " +
                         " where dispatchId=@dispatchid;";
            int r = dbconn.ExecuteSql(sql, new { rstate = 3, dispatchid = dispatchid });

            return(r);
        }
예제 #30
0
        public int SkipExec(RLib.DB.DbConn dbconn, int dispatchid)
        {
            string sql = "update dispatch set dispatchState=@rstate,resultText=@resulttext,endTime=getdate() " +
                         " where dispatchId=@dispatchid and dispatchState=2;";
            int r = dbconn.ExecuteSql(sql, new { rstate = 5, dispatchid = dispatchid, resulttext = "" });

            return(r);
        }