Пример #1
0
 public List <CustomCollectionFiles> GetCollectionListForMaster(int TopicId, char status)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout = Settings.CommandTimeout;
         var query = from gtf in context.Gallery_Topics
                     join cl in context.Gallery_Collections
                     on gtf.Gallery_TopicId equals cl.TopicId
                     where gtf.Status == status && gtf.Gallery_TopicId == TopicId
                     select new { gtf, cl };
         List <CustomCollectionFiles> list = new List <CustomCollectionFiles>();
         foreach (var c in query)
         {
             CustomCollectionFiles file_obj = new CustomCollectionFiles();
             file_obj.TopicId           = c.gtf.Gallery_TopicId;
             file_obj.CollectionId      = c.cl.CollectionId;
             file_obj.Title             = c.cl.Title;
             file_obj.IconFile          = c.cl.IconFile;
             file_obj.Description       = c.cl.Description;
             file_obj.ListOrder         = Convert.ToInt32(c.cl.ListOrder);
             file_obj.Tags              = c.cl.Tags;
             file_obj.Url               = c.cl.Url;
             file_obj.CreatedOnDate     = Convert.ToDateTime(c.cl.CreatedOnDate);
             file_obj.LastModifieddDate = Convert.ToDateTime(c.cl.LastModifieddDate);
             file_obj.UserLog           = c.cl.UserLog.ToString();
             file_obj.UserLastUpdate    = c.cl.UserLastUpdate.ToString();
             file_obj.IPLog             = c.cl.IPLog;
             file_obj.IPLastUpdate      = c.cl.IPLastUpdate;
             file_obj.Status            = c.cl.Status;
             list.Add(file_obj);
         }
         return(list);
     }
 }
Пример #2
0
 public Gallery_Collection GetDetails(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString)){
         context.CommandTimeout = Settings.CommandTimeout;
         Gallery_Collection collection = context.Gallery_Collections.Where(p => p.CollectionId == Idx).SingleOrDefault();
         return(collection);
     }
 }
Пример #3
0
 public static Gallery_Topic GetDetails(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout         = Settings.CommandTimeout;
         context.DeferredLoadingEnabled = false;
         return((from g in context.Gallery_Topics
                 where g.Gallery_TopicId == Idx
                 select g).FirstOrDefault());
     }
 }
Пример #4
0
 public void Delete(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout         = Settings.CommandTimeout;
         context.DeferredLoadingEnabled = false;
         Gallery_Collection collection_obj = context.Gallery_Collections.Single(p => p.CollectionId == Idx);
         context.Gallery_Collections.DeleteOnSubmit(collection_obj);
         context.SubmitChanges();
     }
 }
Пример #5
0
        //================================================================================

        public List <Gallery_Collection> GetList(int topicid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString)){
                context.CommandTimeout = Settings.CommandTimeout;
                var query = from g in context.Gallery_Collections
                            where g.Status == status && g.TopicId == topicid
                            select g;
                List <Gallery_Collection> lst = query.ToList();
                return(lst);
            }
        }
Пример #6
0
 public static int?InsertData(Gallery_Topic entity)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         int?   o_return = 0;
         string UserLog  = Convert.ToString(entity.UserLog);
         var    q        = context.Gallery_Topics_Insert(UserLog, IP, entity.Gallery_TopicName,
                                                         entity.Alias, entity.ParentId, entity.Description, entity.Status, ref o_return);
         context.SubmitChanges();
         return(o_return);
     }
 }
Пример #7
0
        public static List <Gallery_Topic> GetList(char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.CommandTimeout = Settings.CommandTimeout;
                var query = from g in context.Gallery_Topics
                            where g.Status == status
                            select g;

                List <Gallery_Topic> lst = query.ToList();
                return(lst);
            }
        }
Пример #8
0
 public static List <Gallery_File> GetActiveList(int CollectionId)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         //context.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, context.Gallery_Files);
         context.CommandTimeout = Settings.CommandTimeout;
         var list = (from f in context.Gallery_Files
                     join gcf in context.Gallery_Collection_Files
                     on f.FileId equals gcf.FileId
                     where f.Status == '1' && gcf.CollectionId == CollectionId
                     select f).ToList();
         return(list);
     }
 }
Пример #9
0
        public bool UpdateData(int Idx, int CollectionFileId, int CollectionId, string FileName, string FileUrl,
                               int ListOrder, string Description, string Tags, string Status, DateTime CreatedOnDate, string IPLog, string UserLog, string UserLastUpdate)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.DeferredLoadingEnabled = false;
                Gallery_File file = new Gallery_File();
                file.FileId            = Idx;
                file.FileName          = FileName;
                file.FileUrl           = FileUrl;
                file.Description       = Description;
                file.ListOrder         = ListOrder;
                file.UserLog           = Guid.Parse(UserLog);
                file.UserLastUpdate    = Guid.Parse(UserLastUpdate);
                file.CreatedOnDate     = CreatedOnDate;
                file.LastModifieddDate = System.DateTime.Now;
                file.Status            = Convert.ToChar(Status);
                file.Tags         = Tags;
                file.IPLog        = IPLog;
                file.IPLastUpdate = IP;

                ChangeSet changeSet   = null;
                int       changeCount = 0;
                context.Gallery_Files.Attach(file);
                context.Refresh(RefreshMode.KeepCurrentValues, file);
                changeSet   = context.GetChangeSet();
                changeCount = changeSet.Updates.Count;
                context.SubmitChanges();

                bool result = false;
                if (changeCount > 0)
                {
                    Gallery_Collection_File collection_file = new Gallery_Collection_File();
                    collection_file.CollectionFileId = CollectionFileId;
                    collection_file.CollectionId     = CollectionId;
                    collection_file.FileId           = Idx;

                    context.Gallery_Collection_Files.Attach(collection_file);
                    context.Refresh(RefreshMode.KeepCurrentValues, collection_file);
                    context.SubmitChanges();
                    result = true;
                }
                return(result);
            }
        }
Пример #10
0
        public void UpdateStatus(string userid, int topicid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                var query = from x in context.Gallery_Topics
                            where x.Gallery_TopicId == topicid
                            select x;

                foreach (Gallery_Topic topic in query)
                {
                    topic.Status          = status;
                    topic.IPLastUpdate    = IP;
                    topic.UserLastUpdate  = Guid.Parse(userid);
                    topic.LastUpdatedDate = System.DateTime.Now;
                }
                context.SubmitChanges();
            }
        }
Пример #11
0
        public void UpdateStatus(string userid, int topicid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                var query = from x in context.Gallery_Collections
                            where x.CollectionId == topicid
                            select x;

                foreach (Gallery_Collection cllection in query)
                {
                    cllection.Status            = status;
                    cllection.IPLastUpdate      = IP;
                    cllection.UserLastUpdate    = Guid.Parse(userid);
                    cllection.LastModifieddDate = System.DateTime.Now;
                }
                context.SubmitChanges();
            }
        }
Пример #12
0
        public void UpdateStatus(string userid, int fileid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                var query = from x in context.Gallery_Files
                            where x.FileId == fileid
                            select x;

                foreach (Gallery_File file in query)
                {
                    file.Status            = status;
                    file.UserLastUpdate    = Guid.Parse(userid);
                    file.IPLastUpdate      = IP;
                    file.LastModifieddDate = System.DateTime.Now;
                }
                context.SubmitChanges();
            }
        }
Пример #13
0
 //================================================================================
 public static List <Gallery_Collection> GetActiveListByFixedNum(int iTotalItemCount, int topicId)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout = Settings.CommandTimeout;
         var query          = from x in context.Gallery_Collections where x.TopicId == topicId && x.Status.Equals("1") orderby x.CollectionId descending select x;
         int TotalItemCount = 0;
         if (query.Count() > 0)
         {
             if (iTotalItemCount <= query.Count())
             {
                 TotalItemCount = iTotalItemCount;
             }
             else
             {
                 TotalItemCount = query.Count();
             }
         }
         return(query.Take(TotalItemCount).ToList());
     }
 }
Пример #14
0
        public static List <CustomGalleryFiles> GetList(int CollectionId, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.CommandTimeout = Settings.CommandTimeout;
                var query = from f in context.Gallery_Files
                            join gcf in context.Gallery_Collection_Files
                            on f.FileId equals gcf.FileId
                            join cl in context.Gallery_Collections
                            on gcf.CollectionId equals cl.CollectionId
                            where f.Status == status && gcf.CollectionId == CollectionId
                            select new { f, gcf, cl };
                List <CustomGalleryFiles> list = new List <CustomGalleryFiles>();
                foreach (var c in query)
                {
                    CustomGalleryFiles file_obj = new CustomGalleryFiles();
                    file_obj.Gallery_TopicId   = c.cl.TopicId;
                    file_obj.FileId            = c.f.FileId;
                    file_obj.FileName          = c.f.FileName;
                    file_obj.FileUrl           = c.f.FileUrl;
                    file_obj.Description       = c.f.Description;
                    file_obj.ListOrder         = Convert.ToInt32(c.f.ListOrder);
                    file_obj.Tags              = c.f.Tags;
                    file_obj.CreatedOnDate     = Convert.ToDateTime(c.f.CreatedOnDate);
                    file_obj.LastModifieddDate = Convert.ToDateTime(c.f.LastModifieddDate);
                    file_obj.UserLog           = c.f.UserLog.ToString();
                    file_obj.UserLastUpdate    = c.f.UserLastUpdate.ToString();
                    file_obj.IPLog             = c.f.IPLog;
                    file_obj.IPLastUpdate      = c.f.IPLastUpdate;
                    file_obj.Status            = c.f.Status;

                    file_obj.CollectionId = Convert.ToInt32(c.gcf.CollectionId);
                    list.Add(file_obj);
                }
                return(list);
            }
        }
Пример #15
0
        public bool InsertData(int TopicId, string Title, string IconFile, string Description, string Tags, string Url,
                               string UserLog, string Status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                System.Nullable <Int32> ListOrder  = (int?)context.Gallery_Collections.Max(x => (int?)x.CollectionId) ?? 0;
                Gallery_Collection      collection = new Gallery_Collection();
                collection.TopicId           = TopicId;
                collection.Title             = Title;
                collection.IconFile          = IconFile;
                collection.Description       = Description;
                collection.ListOrder         = ListOrder + 1;
                collection.UserLog           = Guid.Parse(UserLog);
                collection.UserLastUpdate    = Guid.Parse(UserLog);
                collection.CreatedOnDate     = System.DateTime.Now;
                collection.LastModifieddDate = System.DateTime.Now;
                collection.Status            = Convert.ToChar(Status);
                collection.Tags         = Tags;
                collection.Url          = Url;
                collection.IPLog        = IP;
                collection.IPLastUpdate = IP;


                context.Gallery_Collections.InsertOnSubmit(collection);
                context.SubmitChanges();
                int newCollectionId = collection.CollectionId;
                if (newCollectionId > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Пример #16
0
        public bool InsertData(int CollectionId, string FileName, string FileUrl,
                               string Description, string UserLog, string Status, string Tags)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                int?ListOrder = (int?)context.Gallery_Collections.Max(x => (int?)x.CollectionId) ?? 0;

                Gallery_File file = new Gallery_File();
                file.FileName      = FileName;
                file.FileUrl       = FileUrl;
                file.ListOrder     = ListOrder + 1;
                file.Description   = Description;
                file.UserLog       = Guid.Parse(UserLog);
                file.CreatedOnDate = System.DateTime.Now;
                file.Status        = Convert.ToChar(Status);
                file.Tags          = Tags;
                file.IPLog         = IP;

                bool result = false;
                context.DeferredLoadingEnabled = false;
                context.Gallery_Files.InsertOnSubmit(file);
                context.SubmitChanges();
                int FileId = file.FileId;
                if (FileId > 0)
                {
                    Gallery_Collection_File collection_file = new Gallery_Collection_File();
                    collection_file.CollectionId = CollectionId;
                    collection_file.FileId       = FileId;

                    context.Gallery_Collection_Files.InsertOnSubmit(collection_file);
                    context.SubmitChanges();
                    result = true;
                }
                return(result);
            }
        }
Пример #17
0
 public static CustomGalleryFiles GetDetails(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout         = Settings.CommandTimeout;
         context.DeferredLoadingEnabled = false;
         var query = (from f in context.Gallery_Files
                      join gcf in context.Gallery_Collection_Files
                      on f.FileId equals gcf.FileId
                      join cl in context.Gallery_Collections
                      on gcf.CollectionId equals cl.CollectionId
                      join gt in context.Gallery_Topics
                      on cl.TopicId equals gt.Gallery_TopicId
                      where f.FileId == Idx
                      select new CustomGalleryFiles
         {
             FileId = f.FileId,
             FileName = f.FileName,
             FileUrl = f.FileUrl,
             Description = f.Description,
             ListOrder = Convert.ToInt32(f.ListOrder),
             Tags = f.Tags,
             CreatedOnDate = Convert.ToDateTime(f.CreatedOnDate),
             LastModifieddDate = Convert.ToDateTime(f.LastModifieddDate),
             UserLog = f.UserLog.ToString(),
             UserLastUpdate = f.UserLastUpdate.ToString(),
             IPLog = f.IPLog,
             IPLastUpdate = f.IPLastUpdate,
             Status = f.Status,
             CollectionId = Convert.ToInt32(gcf.CollectionId),
             CollectionFileId = Convert.ToInt32(gcf.CollectionFileId),
             Gallery_TopicId = Convert.ToInt32(cl.TopicId)
         }).SingleOrDefault();
         return(query);
     }
 }
Пример #18
0
        public bool UpdateData(int Idx, int TopicId, string Title, string IconFile, string Description, int ListOrder, string Tags, string Url,
                               string UserLog, string UserLastUpdate, DateTime CreatedOnDate, string IPLog, string Status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.Connection.Open();
                Gallery_Collection collection_obj = new Gallery_Collection();
                collection_obj.CollectionId      = Idx;
                collection_obj.TopicId           = TopicId;
                collection_obj.Title             = Title;
                collection_obj.IconFile          = IconFile;
                collection_obj.Description       = Description;
                collection_obj.ListOrder         = ListOrder;
                collection_obj.UserLog           = Guid.Parse(UserLog);
                collection_obj.UserLastUpdate    = Guid.Parse(UserLastUpdate);
                collection_obj.CreatedOnDate     = CreatedOnDate;
                collection_obj.LastModifieddDate = DateTime.Now;
                collection_obj.Status            = Convert.ToChar(Status);
                collection_obj.Tags         = Tags;
                collection_obj.Url          = Url;
                collection_obj.IPLog        = IPLog;
                collection_obj.IPLastUpdate = IP;

                ChangeSet     changeSet   = null;
                int           changeCount = 0;
                DbTransaction trans       = context.Connection.BeginTransaction();
                try
                {
                    context.Transaction = trans;
                    context.Gallery_Collections.Attach(collection_obj);
                    context.Refresh(RefreshMode.KeepCurrentValues, collection_obj);
                    changeSet   = context.GetChangeSet();
                    changeCount = changeSet.Updates.Count;
                    context.SubmitChanges();

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    throw ex;
                }
                finally
                {
                    if (context.Connection != null && context.Connection.State == System.Data.ConnectionState.Open)
                    {
                        context.Connection.Close();
                    }
                }

                if (changeCount > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }