コード例 #1
0
        /// <summary>
        /// Persists a new instance of SavedQuery.
        /// </summary>
        /// <returns></returns>
        public void Save(SavedQuery savedQuery)
        {
            if (savedQuery == null)
            {
                return;
            }

            if (savedQuery.Id == Guid.Empty)
            {
                savedQuery.Id = Guid.NewGuid();

                if (savedQuery.CreatedBy == Guid.Empty)
                {
                    savedQuery.CreatedBy = savedQuery.LastModBy;
                }

                DBSavedQuery.Create(
                    savedQuery.Id,
                    savedQuery.Name,
                    savedQuery.Statement,
                    savedQuery.CreatedUtc,
                    savedQuery.CreatedBy);
            }
            else
            {
                DBSavedQuery.Update(
                    savedQuery.Id,
                    savedQuery.Statement,
                    savedQuery.LastModUtc,
                    savedQuery.LastModBy);
            }
        }
コード例 #2
0
        private List <SavedQuery> LoadListFromReader(IDataReader reader)
        {
            List <SavedQuery> savedQueryList = new List <SavedQuery>();

            try
            {
                while (reader.Read())
                {
                    SavedQuery savedQuery = new SavedQuery();
                    savedQuery.Id         = new Guid(reader["Id"].ToString());
                    savedQuery.Name       = reader["Name"].ToString();
                    savedQuery.Statement  = reader["Statement"].ToString();
                    savedQuery.CreatedUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    savedQuery.CreatedBy  = new Guid(reader["CreatedBy"].ToString());
                    savedQuery.LastModUtc = Convert.ToDateTime(reader["LastModUtc"]);
                    savedQuery.LastModBy  = new Guid(reader["LastModBy"].ToString());
                    savedQueryList.Add(savedQuery);
                }
            }
            finally
            {
                reader.Close();
            }

            return(savedQueryList);
        }
コード例 #3
0
        public SavedQuery Fetch(string name)
        {
            using (IDataReader reader = DBSavedQuery.GetOne(name))
            {
                if (reader.Read())
                {
                    SavedQuery savedQuery = new SavedQuery();
                    savedQuery.Id         = new Guid(reader["Id"].ToString());
                    savedQuery.Name       = reader["Name"].ToString();
                    savedQuery.Statement  = reader["Statement"].ToString();
                    savedQuery.CreatedUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    savedQuery.CreatedBy  = new Guid(reader["CreatedBy"].ToString());
                    savedQuery.LastModUtc = Convert.ToDateTime(reader["LastModUtc"]);
                    savedQuery.LastModBy  = new Guid(reader["LastModBy"].ToString());

                    return(savedQuery);
                }
            }

            return(null);
        }
コード例 #4
0
        public SavedQuery Fetch(string name)
        {
            using (IDataReader reader = DBSavedQuery.GetOne(name))
            {
                if (reader.Read())
                {
                    SavedQuery savedQuery = new SavedQuery();
                    savedQuery.Id = new Guid(reader["Id"].ToString());
                    savedQuery.Name = reader["Name"].ToString();
                    savedQuery.Statement = reader["Statement"].ToString();
                    savedQuery.CreatedUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    savedQuery.CreatedBy = new Guid(reader["CreatedBy"].ToString());
                    savedQuery.LastModUtc = Convert.ToDateTime(reader["LastModUtc"]);
                    savedQuery.LastModBy = new Guid(reader["LastModBy"].ToString());

                    return savedQuery;

                }
            }

            return null;
        }
コード例 #5
0
        /// <summary>
        /// Persists a new instance of SavedQuery.
        /// </summary>
        /// <returns></returns>
        public void Save(SavedQuery savedQuery)
        {
            if (savedQuery == null) { return; }

            if (savedQuery.Id == Guid.Empty)
            {
                savedQuery.Id = Guid.NewGuid();

                if (savedQuery.CreatedBy == Guid.Empty) { savedQuery.CreatedBy = savedQuery.LastModBy; }

                DBSavedQuery.Create(
                    savedQuery.Id,
                    savedQuery.Name,
                    savedQuery.Statement,
                    savedQuery.CreatedUtc,
                    savedQuery.CreatedBy);
            }
            else
            {
                DBSavedQuery.Update(
                    savedQuery.Id,
                    savedQuery.Statement,
                    savedQuery.LastModUtc,
                    savedQuery.LastModBy);

            }
        }
コード例 #6
0
        private List<SavedQuery> LoadListFromReader(IDataReader reader)
        {
            List<SavedQuery> savedQueryList = new List<SavedQuery>();

            try
            {
                while (reader.Read())
                {
                    SavedQuery savedQuery = new SavedQuery();
                    savedQuery.Id = new Guid(reader["Id"].ToString());
                    savedQuery.Name = reader["Name"].ToString();
                    savedQuery.Statement = reader["Statement"].ToString();
                    savedQuery.CreatedUtc = Convert.ToDateTime(reader["CreatedUtc"]);
                    savedQuery.CreatedBy = new Guid(reader["CreatedBy"].ToString());
                    savedQuery.LastModUtc = Convert.ToDateTime(reader["LastModUtc"]);
                    savedQuery.LastModBy = new Guid(reader["LastModBy"].ToString());
                    savedQueryList.Add(savedQuery);

                }
            }
            finally
            {
                reader.Close();
            }

            return savedQueryList;
        }
コード例 #7
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByCreatedUtc(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.CreatedUtc.CompareTo(savedQuery2.CreatedUtc));
 }
コード例 #8
0
        void btnSave_Click(object sender, EventArgs e)
        {
            if (txtQuery.Text.Trim().Length == 0)
            {
                lblError.Text = DevTools.NoQueryWarning;
                return;
            }

            if (txtQueryName.Text.Trim().Length == 0)
            {
                lblError.Text = DevTools.QueryNameRequired;
                return;

            }

            SavedQuery q = repository.Fetch(txtQueryName.Text);
            if (q == null) { q = new SavedQuery(); }

            q.Statement = txtQuery.Text;
            q.Name = txtQueryName.Text;
            if (currentUser != null) { q.LastModBy = currentUser.UserGuid; }
            q.LastModUtc = DateTime.UtcNow;
            repository.Save(q);
            RedirectToQuery(q.Id.ToString());
        }
コード例 #9
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByName(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.Name.CompareTo(savedQuery2.Name));
 }
コード例 #10
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByStatement(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.Statement.CompareTo(savedQuery2.Statement));
 }
コード例 #11
0
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByLastModUtc(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return(savedQuery1.LastModUtc.CompareTo(savedQuery2.LastModUtc));
 }
コード例 #12
0
ファイル: SavedQuery.cs プロジェクト: saiesh86/TravelBlog
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByCreatedUtc(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return savedQuery1.CreatedUtc.CompareTo(savedQuery2.CreatedUtc);
 }
コード例 #13
0
ファイル: SavedQuery.cs プロジェクト: saiesh86/TravelBlog
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByStatement(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return savedQuery1.Statement.CompareTo(savedQuery2.Statement);
 }
コード例 #14
0
ファイル: SavedQuery.cs プロジェクト: saiesh86/TravelBlog
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByName(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return savedQuery1.Name.CompareTo(savedQuery2.Name);
 }
コード例 #15
0
ファイル: SavedQuery.cs プロジェクト: saiesh86/TravelBlog
 /// <summary>
 /// Compares 2 instances of SavedQuery.
 /// </summary>
 public static int CompareByLastModUtc(SavedQuery savedQuery1, SavedQuery savedQuery2)
 {
     return savedQuery1.LastModUtc.CompareTo(savedQuery2.LastModUtc);
 }