Ejemplo n.º 1
0
    public void AddTopartner(string id, string groupid)
    {
        try
        {
            DbTask db  = new DbTask();
            string Sql = string.Empty;
            Sql = "UPDATE " + TableName + " SET idx = idx + 1";
            db.ExecuteNonQuery(Sql);

            DateTime sStartDate = DateTime.Now;
            DateTime dt         = DateTime.Now;
            int      nYear      = dt.Year + 1;
            dt = new DateTime(nYear, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);

            Sql  = "INSERT INTO " + TableName + "(groupid, id, startdate, enddate, idx) ";
            Sql += " VALUES(?groupid, ?id, ?startdate, ?enddate, ?idx)";
            DataTable datatable = null;
            db.AddParameters(ref datatable, "groupid", DbType.NVarChar, groupid);
            db.AddParameters(ref datatable, "id", DbType.NVarChar, id);
            db.AddParameters(ref datatable, "startdate", DbType.Datetime, sStartDate);
            db.AddParameters(ref datatable, "enddate", DbType.Datetime, dt);
            db.AddParameters(ref datatable, "idx", DbType.Int32, 1);

            db.ExecuteNonQuery(Sql, datatable);
        }
        catch (Exception ae)
        {
            string error = ae.ToString();
        }
    }
Ejemplo n.º 2
0
    public void SetStatusDefault(string id)
    {
        DbTask  db = new DbTask();
        DataRow dr = this.GetInfoStatusDefault(id);

        if (dr == null)
        {
            return;
        }
        int status;

        if (Convert.ToInt32(dr["status"].ToString()) == 0)
        {
            status = 1;
        }
        else
        {
            status = 0;
        }
        int    vid = Convert.ToInt32(id);
        string Sql = "UPDATE " + TableNameDefault + " SET ";

        Sql += " status = " + status + " ";
        Sql += " WHERE id = " + vid + " ";
        db.ExecuteNonQuery(Sql);
    }
Ejemplo n.º 3
0
    public DataTable Searching(int Status, int CurrentPage, int RecordPerPages, out int TotalRecords, out int TotalPages)
    {
        DbTask db = new DbTask();
        DataTable dt = null;
        TotalRecords = 0;
        TotalPages = 0;

        string Sql = string.Empty;
        Sql = "SELECT COUNT(ID) AS Total FROM " + TableName + "  ";
        if (Status < 2)
            Sql += "WHERE status = " + Status + " ";
        dt = db.GetData(Sql);
        if (dt == null || dt.Rows.Count == 0)
            return null;

        TotalRecords = Convert.ToInt32(dt.Rows[0]["Total"]);
        TotalPages = (int)TotalRecords / RecordPerPages;
        if ((int)TotalRecords % RecordPerPages > 0)
            TotalPages = TotalPages + 1;

        Sql = "Select " + TableName + ".*, row_number() over (order by id ASC) as row_index INTO #Temp_Table ";
        Sql += "From " + TableName + " ";
        Sql += "Where 1 = 1 ";
        int nS = RecordPerPages * (CurrentPage - 1);
        int record_next = nS + RecordPerPages;
        Sql += "Select * from #Temp_Table ";
        if (nS == 0)
            Sql += " WHERE (row_index >=" + nS + ") AND (row_index <=" + record_next + ")";
        else
            Sql += " WHERE (row_index >" + nS + ") AND (row_index <=" + record_next + ")";
        Sql += " ORDER BY row_index ASC ";
        dt = db.GetData(Sql);
        return dt;
    }
Ejemplo n.º 4
0
 public void UpdateTask(DbTask task)
 {
     using (var connection = new NpgsqlConnection(settings.ConnectionString))
     {
         connection.Update(task);
     }
 }
Ejemplo n.º 5
0
    public DataTable GetNotNull(string ParentID)
    {
        DbTask dbtask = new DbTask();
        string parent = (ParentID == null || ParentID == string.Empty || ParentID == "") ? "00" : ParentID;
        string Sql    = "Select a.id AS pid, a.col, a.shortlink, a.icon as icon, a.fimages, a.summary, a.title AS ptitle, a.parentid as pparentid, a.link as plink, a.idx as idx, ";

        Sql += "(SELECT COUNT(c.id) FROM " + TableName + " as c WHERE c.parentid = a.id) AS nextchild ";
        Sql += " FROM " + TableName + " as a ";
        if (parent == "00")
        {
            Sql += " ," + _TableName + " as b  ";
        }

        Sql += " WHERE a.parentid = '" + parent + "' AND a.status = 1  ";

        if (parent == "00")
        {
            Sql += " AND b.groupid = '1' AND a.id = b.id ";
            Sql += "ORDER BY b.idx ASC";
        }
        if (parent != "00")
        {
            Sql += "ORDER BY a.idx ASC";
        }

        return(dbtask.GetData(Sql));
    }
Ejemplo n.º 6
0
    public DataTable GetmenuLeftNHS(string ParentID)
    {
        DbTask dbtask = new DbTask();
        string parent = (ParentID == null || ParentID == string.Empty || ParentID == "") ? "" : ParentID;
        string Sql    = "Select a.id AS pid, a.title AS ptitle, a.parentid as pparentid,a.fimages as pfimages, a.link as plink,a.kind as kind, a.idx as idx ";

        Sql += " FROM " + TableName + " as a ";
        if (parent == "00")
        {
            Sql += " ," + _TableName + " as b  ";
        }

        Sql += " WHERE a.parentid = '" + parent + "'  AND a.status = 1 AND a.home = 1 ";

        if (parent == "00")
        {
            Sql += " AND b.groupid = '" + _GroupID + "' AND a.id = b.id ";
            Sql += "ORDER BY b.idx ASC";
        }
        if (parent != "00")
        {
            Sql += "ORDER BY a.idx ASC";
        }

        return(dbtask.GetData(Sql));
    }
Ejemplo n.º 7
0
    public DataTable Get_Images(string id, string productid)
    {
        DbTask    db    = new DbTask();
        DataTable dt    = null;
        string    dtNow = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

        string Sql = "SELECT  distinct a.* FROM " + TableName + " as a ";

        Sql += " WHERE a.status = 1 ";
        Sql += " AND a.created <= '" + dtNow + "' ";
        if (id != null && id != string.Empty && id != "")
        {
            Sql += " AND a.id = '" + id + "'";
        }
        if (productid != null && productid != string.Empty && productid != "")
        {
            Sql += " AND a.productid= '" + productid + "'";
        }
        Sql += " ORDER BY a.created DESC ";
        dt   = db.GetData(Sql);

        if (id.Length > 0 || id != string.Empty)
        {
            return(dt);
        }
        else
        {
            return(null);
        }
    }
Ejemplo n.º 8
0
 private void MapTaskToDb(DbTask dbTask, TaskDomain taskDomain)
 {
     dbTask.State       = taskDomain.State;
     dbTask.DueDate     = taskDomain.DueDate;
     dbTask.Priority    = taskDomain.Priority;
     dbTask.Description = taskDomain.Description;
 }
        public void result(string taskid, string pipelineid, int state)
        {
            using (MDB db = new MDB())
            {
                MaratonAPI api  = new MaratonAPI();
                DbTask     task = db.Find <DbTask>(x => x.Id == taskid).FirstOrDefault();
                task.State = state;

                if (task == null)
                {
                    return;
                }

                for (int i = 0; i < task.Pipelines.Count; i++)
                {
                    if (task.Pipelines[i] != pipelineid)
                    {
                        continue;
                    }

                    if (task.Pipelines[i] == pipelineid &&
                        i < (task.Pipelines.Count - 1))
                    {
                        api.TaskDeliver(task, db.FindOne <DbPipeline>(x => x.Id == task.Pipelines[i + 1]));
                    }
                }

                db.UpdateOne <DbTask>(x => x.Id == taskid, task);
            }
        }
Ejemplo n.º 10
0
    public DataTable GetALLBlogMember()
    {
        DbTask db  = new DbTask();
        string Sql = "SELECT * FROM " + TableName + "";

        return(db.GetData(Sql));
    }
Ejemplo n.º 11
0
    public DataTable GetAllYahoo()
    {
        DbTask db  = new DbTask();
        string Sql = "Select * from " + TableName + " Order by idx ASC ";

        return(db.GetData(Sql));
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Lấy danh sách các Yahoo trong nhóm hỗ trợ
    /// </summary>
    /// <param name="groupid">id của nhóm</param>
    /// <returns>Datatabe</returns>
    public DataTable GetYahooFromGroup(string groupid)
    {
        DbTask db  = new DbTask();
        string Sql = "Select * from " + TableName + " Where groupid = '" + groupid + "'";

        return(db.GetData(Sql));
    }
Ejemplo n.º 13
0
    /// <summary>
    /// Delete nick Yahoo theo id
    /// </summary>
    /// <param name="id"></param>
    public void DeleteYahooforID(string id)
    {
        DbTask db  = new DbTask();
        string sql = "Delete From " + TableName + " where id = '" + id + "'";

        db.ExecuteNonQuery(sql);
    }
Ejemplo n.º 14
0
    public DataTable GetgroupYahoo()
    {
        DbTask db  = new DbTask();
        string Sql = "Select * from " + tblgroupYahoo + "";

        return(db.GetData(Sql));
    }
Ejemplo n.º 15
0
        public override void Execute()
        {
            LoadProcess = new LoadProcess();
            var sql = new SqlTask(this, Sql)
            {
                DisableLogging   = true,
                DisableExtension = true,
                Actions          = new List <Action <object> >()
                {
                    result => {
                        LoadProcess.LoadProcessKey        = (int)DbTask.GetValueFromReader(result, "LoadProcessKey");
                        LoadProcess.StartDate             = (DateTime)DbTask.GetValueFromReader(result, "StartDate");
                        LoadProcess.TransferCompletedDate = (DateTime?)DbTask.GetValueFromReader(result, "TransferCompletedDate");
                        LoadProcess.EndDate             = (DateTime?)DbTask.GetValueFromReader(result, "EndDate");
                        LoadProcess.ProcessName         = (string)DbTask.GetValueFromReader(result, "ProcessName");
                        LoadProcess.StartMessage        = (string)DbTask.GetValueFromReader(result, "StartMessage");
                        LoadProcess.IsRunning           = (bool)DbTask.GetValueFromReader(result, "IsRunning");
                        LoadProcess.EndMessage          = (string)DbTask.GetValueFromReader(result, "EndMessage");
                        LoadProcess.WasSuccessful       = (bool)DbTask.GetValueFromReader(result, "WasSuccessful");
                        LoadProcess.AbortMessage        = (string)DbTask.GetValueFromReader(result, "AbortMessage");
                        LoadProcess.WasAborted          = (bool)DbTask.GetValueFromReader(result, "WasAborted");
                        LoadProcess.IsFinished          = (bool)DbTask.GetValueFromReader(result, "IsFinished");
                        LoadProcess.IsTransferCompleted = (bool)DbTask.GetValueFromReader(result, "IsTransferCompleted");
                    }
                }
            };

            if (ReadOption == ReadOptions.ReadAllProcesses)
            {
                sql.BeforeRowReadAction = () => AllLoadProcesses = new List <LoadProcess>();
                sql.AfterRowReadAction  = () => AllLoadProcesses.Add(LoadProcess);
            }
            sql.ExecuteReader();
        }
Ejemplo n.º 16
0
    public DataTable GetVideo()
    {
        DbTask db  = new DbTask();
        string Sql = "Select * from " + TableName + "";

        return(db.GetData(Sql));
    }
Ejemplo n.º 17
0
 public void Update(string id, DateTime startdate, DateTime enddate, int idx)
 {
     try
     {
         string Sql = "UPDATE " + _TableName + " SET ";
         Sql += " idx = ?idx,  ";
         Sql += " startdate = ?startdate,  ";
         Sql += " enddate = ?enddate  ";
         Sql += "WHERE groupid = '" + _GroupID + "' ";
         Sql += "AND id = '" + id + "' ";
         Sql += "AND col = '" + _Col + "' ";
         DbTask    db = new DbTask();
         DataTable dt = null;
         db.AddParameters(ref dt, "groupid", DbType.NVarChar, _GroupID);
         db.AddParameters(ref dt, "id", DbType.NVarChar, id);
         db.AddParameters(ref dt, "col", DbType.NVarChar, _Col);
         db.AddParameters(ref dt, "startdate", DbType.Datetime, startdate);
         db.AddParameters(ref dt, "enddate", DbType.Datetime, enddate);
         db.AddParameters(ref dt, "idx", DbType.Int32, idx);
         db.ExecuteNonQuery(Sql, dt);
     }
     catch (Exception ae)
     {
         string error = ae.ToString();
     }
 }
Ejemplo n.º 18
0
    public DataTable GetGroupForSearch()
    {
        DbTask db  = new DbTask();
        string Sql = "Select title, id from " + TableName + " where parentid = 00 And kind = 1";

        return(db.GetData(Sql));
    }
Ejemplo n.º 19
0
    public void SetStatus(string id)
    {
        DbTask  db = new DbTask();
        DataRow dr = GetInfoKeyWord(id);

        if (dr == null)
        {
            return;
        }
        int status;

        if (Convert.ToInt32(dr["status"].ToString()) == 0)
        {
            status = 1;
        }
        else
        {
            status = 0;
        }
        string Sql = "UPDATE " + TableName + " SET ";

        Sql += " status = " + status + " ";
        Sql += " WHERE id = '" + id.Trim() + "' ";
        db.ExecuteNonQuery(Sql);
    }
Ejemplo n.º 20
0
    public DataTable GetChild_Home(string ParentID)
    {
        DbTask dbtask = new DbTask();
        string parent = (ParentID == null || ParentID == string.Empty || ParentID == "") ? "00" : ParentID;
        string Sql    = "Select a.id AS pid, a.shortlink as shortlink, a.sluongtin, a.title AS ptitle, a.parentid as pparentid,a.fimages as pfimages, a.link as plink,a.kind as kind, a.idx as idx ";

        //Sql += "(SELECT COUNT(c.id) FROM " + TableName + " as c WHERE c.parentid = pid) AS nextchild ";
        Sql += " FROM " + TableName + " as a ";
        if (parent == "00")
        {
            Sql += " ," + _TableName + " as b  ";
        }

        Sql += " WHERE a.parentid = '" + parent + "'  AND a.status = 1 AND a.home = 1 ";

        if (parent == "00")
        {
            Sql += " AND b.groupid = '" + _GroupID + "' AND a.id = b.id ";
            Sql += "ORDER BY b.idx ASC";
        }
        if (parent != "00")
        {
            Sql += "ORDER BY a.idx ASC";
        }
        return(dbtask.GetData(Sql));
    }
Ejemplo n.º 21
0
    public DataTable GetAllDatabaseActive(string TenBang)
    {
        DbTask db  = new DbTask();
        string sql = "Select * from " + TenBang + " Where status = 1 Order by idx ";

        return(db.GetData(sql));
    }
Ejemplo n.º 22
0
    public Member()
    {
        if (Globals.CheckExist)
        {
            try
            {
                string Sql = "CREATE TABLE " + TableName + " (";
                Sql += "id nvarchar(10) NOT NULL default '', ";
                Sql += "username nvarchar(255) default NULL, ";
                Sql += "password nvarchar(100) default NULL, ";
                Sql += "fullname nvarchar(255) default NULL, ";
                Sql += "tel nvarchar(15) default NULL, ";
                Sql += "email nvarchar(255) default NULL, ";
                Sql += "address nvarchar(255) default NULL, ";
                Sql += "jobtitle nvarchar(255) default NULL, ";
                Sql += "status int(4) default 0, ";
                Sql += "PRIMARY KEY  (id))";
                Sql += "ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;";

                DbTask db = new DbTask();
                db.ExecuteNonQuery(Sql);
            }
            catch
            {

            }
        }
    }
Ejemplo n.º 23
0
    public void Delete(string id, string TenBang)
    {
        DbTask db  = new DbTask();
        string SQL = "Delete from " + TenBang + " where id = '" + id + "'";

        db.ExecuteNonQuery(SQL);
    }
Ejemplo n.º 24
0
        public async void AddAsync_NewTaskAdded()
        {
            var newTask     = _fixture.Create <TaskDomain>();
            var newGuid     = _fixture.Create <Guid>();
            var newDateTime = _fixture.Create <DateTime>();

            var dbTask = new DbTask
            {
                Id          = newGuid,
                AddedDate   = newDateTime,
                State       = newTask.State,
                DueDate     = newTask.DueDate,
                Priority    = newTask.Priority,
                Description = newTask.Description
            };

            _guidFactory.Setup(x => x.Create()).Returns(newGuid).Verifiable();
            _dateTimeProvider.Setup(x => x.Now).Returns(newDateTime).Verifiable();
            _dbRepository
            .Setup(x => x.Add(It.IsAny <DbTask>()))
            .Callback <DbTask>(x => x.Should().BeEquivalentTo(dbTask))
            .Verifiable();

            await _tasksRepository.AddAsync(newTask);

            _dateTimeProvider.VerifyAll();
            _dbRepository.VerifyAll();
            _guidFactory.VerifyAll();
        }
Ejemplo n.º 25
0
    public void Update(string id, string title, string linkurl, string summary, string filename, string sWidth, string sHeight)
    {
        string Sql = "UPDATE " + TableName + " SET ";

        Sql += " title = ?title,  ";
        Sql += " linkurl = ?linkurl,  ";
        Sql += " summary = ?summary,  ";
        Sql += " created = ?created,  ";
        Sql += " filename = ?filename, ";
        Sql += " fwidth = ?fwidth, ";
        Sql += " fHeight = ?fheight, ";
        Sql += " userid = ?userid ";
        Sql += " WHERE id=?id";
        DbTask    db = new DbTask();
        DataTable dt = null;

        db.AddParameters(ref dt, "id", DbType.NVarChar, id);
        db.AddParameters(ref dt, "title", DbType.NVarChar, title);
        db.AddParameters(ref dt, "summary", DbType.NVarChar, summary);
        db.AddParameters(ref dt, "fwidth", DbType.NVarChar, sWidth);
        db.AddParameters(ref dt, "fheight", DbType.NVarChar, sHeight);
        db.AddParameters(ref dt, "linkurl", DbType.NVarChar, linkurl);
        db.AddParameters(ref dt, "created", DbType.Datetime, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
        db.AddParameters(ref dt, "filename", DbType.NVarChar, filename);
        db.AddParameters(ref dt, "userid", DbType.NVarChar, Membertask.Name);
        db.ExecuteNonQuery(Sql, dt);
    }
Ejemplo n.º 26
0
 public int InsertTask(DbTask task)
 {
     using (var connection = new NpgsqlConnection(settings.ConnectionString))
     {
         return(connection.Insert(task));
     }
 }
Ejemplo n.º 27
0
    public void Delete(string id)
    {
        DbTask db  = new DbTask();
        string Sql = "DELETE FROM " + TableName + " WHERE id = '" + id.Trim() + "'";

        db.ExecuteNonQuery(Sql);
    }
Ejemplo n.º 28
0
        public IEnumerable <DbTaskList> GetTaskLists()
        {
            var readTasksSql = "SELECT title, id_list, id, description, deadline, is_done FROM task";
            var tasksGrouped = ReadEntities(readTasksSql,
                                            r =>
            {
                var task         = new DbTask();
                task.Title       = r.GetString(0);
                task.ListId      = r.GetInt32(1);
                task.Id          = r.GetInt32(2);
                task.Description = r.GetValue(3).ToString();
                task.Date        = r.GetValue(4).ToString();
                task.IsDone      = r.GetBoolean(5);
                return(task);
            }).ToArray().GroupBy(x => x.ListId);

            var readTaskListsSql = "SELECT title, id FROM tasks_list";
            var taskListsSeq     = ReadEntities(readTaskListsSql,
                                                r =>
            {
                var taskList  = new DbTaskList();
                taskList.Name = r.GetString(0);
                taskList.Id   = r.GetInt32(1);
                return(taskList);
            }).ToArray();

            return(taskListsSeq.Select(lst =>
            {
                var tasksGroup = tasksGrouped.FirstOrDefault(x => x.Key == lst.Id);
                lst.Tasks = tasksGroup == null? new DbTask[] { } : tasksGroup.ToArray();
                return lst;
            }).ToArray());
        }
Ejemplo n.º 29
0
    public void DeleteLog(string vLogId)
    {
        DbTask db  = new DbTask();
        string Sql = "DELETE FROM " + TableName + " WHERE LogId = '" + vLogId.Trim() + "' ";

        db.ExecuteNonQuery(Sql);
    }
Ejemplo n.º 30
0
    public void Delete(string id)
    {
        string Sql = "DELETE FROM " + TableName + " WHERE id = " + Convert.ToInt32(id) + " ";
        DbTask db  = new DbTask();

        db.ExecuteNonQuery(Sql);
    }
Ejemplo n.º 31
0
 public static Task ToTask(DbTask task)
 {
     return new Task(task.Uid, task.Title, task.Description, task.IsDone, task.Due)
     {
         DbId = task.Id
     };
 }