//[Route("api/Common/LogDataActivity")]
        public string LogDataActivity(DataActivityModel dataActivity)
        {
            string success;

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    db.ChangeLogs.Add(new MySqlDataContext.ChangeLog()
                    {
                        VisitorId    = dataActivity.VisitorId,
                        FolderId     = dataActivity.FolderId,
                        ActivityCode = dataActivity.ActivityCode,
                        Details      = dataActivity.Details,
                        Occured      = DateTime.Now
                    });
                    db.SaveChanges();
                }
                success = "ok";
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Beispiel #2
0
        public FolderInfoModel GetQuickFolderInfo(int folderId)
        {
            var folderInfo = new FolderInfoModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    var dbFolder = db.CategoryFolders.Where(f => f.Id == folderId).FirstOrDefault();
                    if (dbFolder == null)
                    {
                        folderInfo.Success = "folder not found";
                        return(folderInfo);
                    }
                    folderInfo.FolderType = dbFolder.FolderType;
                    folderInfo.FolderName = dbFolder.FolderName;
                    folderInfo.Parent     = dbFolder.Parent;
                    var dbFolderDetails = db.FolderDetails.Where(d => d.FolderId == folderId).FirstOrDefault();
                    if (dbFolderDetails != null)
                    {
                        folderInfo.FolderComments = dbFolderDetails.FolderComments;
                    }
                    folderInfo.Success = "ok";
                    folderInfo.Success = "ok";
                }
            }
            catch (Exception ex) { folderInfo.Success = Helpers.ErrorDetails(ex); }
            return(folderInfo);
        }
Beispiel #3
0
        public string AddFolderComment(FolderCommentModel folderCommentModel)
        {
            string success;

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    db.FolderComments.Add(new FolderComment()
                    {
                        PkId        = Guid.NewGuid().ToString(),
                        VisitorId   = folderCommentModel.VisitorId,
                        FolderId    = folderCommentModel.FolderId,
                        CommentText = folderCommentModel.CommentText,
                        Posted      = DateTime.Now
                    });
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
        public VerifyVisitorSuccessModel VerifyVisitor(string visitorId)
        {
            var verifyVisitorSuccess = new VerifyVisitorSuccessModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    Visitor dbVisitor = db.Visitors.Where(v => v.VisitorId == visitorId).FirstOrDefault();
                    if (dbVisitor == null)
                    {
                        verifyVisitorSuccess.VisitorIdExists = false;
                    }
                    else
                    {
                        verifyVisitorSuccess.VisitorIdExists = true;
                        verifyVisitorSuccess.Country         = dbVisitor.Country;
                        var dbRegisterUser = db.RegisteredUsers.Where(v => v.VisitorId == visitorId).FirstOrDefault();
                        if (dbRegisterUser == null)
                        {
                            verifyVisitorSuccess.IsRegisteredUser = false;
                        }
                        else
                        {
                            verifyVisitorSuccess.IsRegisteredUser = true;
                        }
                    }
                }
                verifyVisitorSuccess.Success = "ok";
            }
            catch (Exception ex) { verifyVisitorSuccess.Success = Helpers.ErrorDetails(ex); }
            return(verifyVisitorSuccess);
        }
        public string UpdateIfyVisitor(string visitorId, string ipAddress)
        {
            string success;

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    Visitor visitor1 = db.Visitors.Where(v => v.VisitorId == visitorId).FirstOrDefault();
                    if (visitor1 == null)
                    {
                        success = "VisitorId not exits";
                    }
                    else
                    {
                        visitor1.IpAddress = ipAddress;
                        db.SaveChanges();
                        success = "ok";
                    }
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Beispiel #6
0
        private string DownLoadImage(string ftpPath, string externalFileName, string newFileName)
        {
            string success = "ok";

            try
            {
                string extension   = newFileName.Substring(newFileName.Length - 4);
                string appDataPath = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/temp/");
                using (WebClient wc = new WebClient())
                {
                    wc.DownloadFile(new Uri(externalFileName), appDataPath + "tempImage" + extension);
                }

                FtpWebRequest webRequest = (FtpWebRequest)WebRequest.Create(ftpPath + "/" + newFileName);
                webRequest.Credentials = new NetworkCredential(ftpUserName, ftpPassword);
                webRequest.Method      = WebRequestMethods.Ftp.UploadFile;


                using (Stream requestStream = webRequest.GetRequestStream())
                {
                    byte[] fileContents = System.IO.File.ReadAllBytes(appDataPath + "tempImage" + extension);
                    webRequest.ContentLength = fileContents.Length;
                    requestStream.Write(fileContents, 0, fileContents.Length);
                    requestStream.Flush();
                    requestStream.Close();
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Beispiel #7
0
        public ActivityReportModel ActivityReport()
        {
            var activityReport = new ActivityReportModel();

            try
            {
                using (var db = new OggleBoobleMySqContext())
                {
                    db.EventLogs.RemoveRange(db.EventLogs.Where(e => e.VisitorId == "ec6fb880-ddc2-4375-8237-021732907510"));
                    db.SaveChanges();
                    List <DailyActivityReport> activityItems = db.DailyActivity.ToList();
                    foreach (var activityItem in activityItems)
                    {
                        activityReport.Items.Add(new ActiviyItem()
                        {
                            IpAddress  = activityItem.IpAddress,
                            City       = activityItem.City,
                            Region     = activityItem.Region,
                            Country    = activityItem.Country,
                            Event      = activityItem.Event,
                            CalledFrom = activityItem.CalledFrom,
                            Detail     = activityItem.Detail,
                            HitDate    = activityItem.HitDate,
                            HitTime    = activityItem.HitTime
                        });
                    }
                    activityReport.HitCount = db.EventLogs.Where(h => h.Occured > DateTime.Today).Count();
                }
                activityReport.Success = "ok";
            }
            catch (Exception ex) { activityReport.Success = Helpers.ErrorDetails(ex); }
            return(activityReport);
        }
Beispiel #8
0
        public BreadCrumbSuccessModel GetBreadcrumbs(int folderId)
        {
            var breadCrumbs = new BreadCrumbSuccessModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    CategoryFolder thisFolder = db.CategoryFolders.Where(f => f.Id == folderId).First();
                    breadCrumbs.BreadCrumbs.Add(new BreadCrumbItemModel()
                    {
                        FolderId        = thisFolder.Id,
                        FolderName      = thisFolder.FolderName,
                        ParentId        = thisFolder.Parent,
                        IsInitialFolder = true
                    });
                    var parent = thisFolder.Parent;
                    while (parent > 1)
                    {
                        CategoryFolder parentDb = db.CategoryFolders.Where(f => f.Id == parent).First();
                        breadCrumbs.BreadCrumbs.Add(new BreadCrumbItemModel()
                        {
                            FolderId        = parentDb.Id,
                            FolderName      = parentDb.FolderName,
                            IsInitialFolder = false
                        });
                        parent = parentDb.Parent;
                    }
                    breadCrumbs.Success = "ok";
                }
            }
            catch (Exception ex) { breadCrumbs.Success = Helpers.ErrorDetails(ex); }
            return(breadCrumbs);
        }
        //[Route("api/IndexPage/GetRandomGalleries")]
        public RandomGalleriesModel GetRandomGalleries(int take, string root)
        {
            RandomGalleriesModel randomGalleries = new RandomGalleriesModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    var temp1 = (from f in db.CategoryFolders
                                 join i in db.ImageFiles on f.FolderImage equals i.Id
                                 join f2 in db.CategoryFolders on i.FolderId equals f2.Id
                                 where f.RootFolder == root && f.SubFolders == 0
                                 select new RandomGalleyModel()
                    {
                        FolderId = f.Id,
                        FolderPath = f2.FolderPath,
                        FileName = i.FileName,
                        FolderName = f.FolderName
                    }).ToList();
                    foreach (RandomGalleyModel m in temp1)
                    {
                        m.RandomGuid = Guid.NewGuid().ToString();
                    }
                    randomGalleries.RandomGalleries = temp1.OrderBy(x => x.RandomGuid).Skip(0).Take(take).ToList();
                }
                randomGalleries.Success = "ok";
            }
            catch (Exception ex) { randomGalleries.Success = Helpers.ErrorDetails(ex); }
            return(randomGalleries);
        }
        public string MoveImageToRejects(string linkId)
        {
            string success;

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    var    dbSourceImage  = db.ImageFiles.Where(f => f.Id == linkId).First();
                    string dbRejectFolder = ftpHost + "/archive.OggleBooble.com/rejects/" + dbSourceImage.FileName;
                    var    dbSourceFolder = db.CategoryFolders.Where(f => f.Id == dbSourceImage.FolderId).First();
                    string ftpRepo        = imgRepo.Substring(7);
                    string sourceFtpPath  = ftpHost + ftpRepo + "/" + dbSourceFolder.FolderPath + "/" + dbSourceImage.FileName;
                    success = FtpUtilies.MoveFile(sourceFtpPath, dbRejectFolder);

                    var linksToRemove = db.CategoryImageLinks.Where(l => l.ImageLinkId == linkId).ToList();
                    db.CategoryImageLinks.RemoveRange(linksToRemove);



                    ImageFile reject = db.ImageFiles.Where(i => i.Id == linkId).First();
                    reject.FolderId = -6;
                    //db.ImageFiles.Remove(reject);
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
        public string BuildHtmlDirTree(int root)
        {
            string success;
            DirTreeSuccessModel dirTreeModel = new DirTreeSuccessModel();

            try
            {
                IEnumerable <VwDirTree> VwDirTrees = new List <VwDirTree>();
                using (var db = new OggleBoobleMySqlContext())
                {
                    // wow did this speed things up
                    VwDirTrees = db.VwDirTrees.ToList().OrderBy(v => v.Id);
                }

                var vRootNode             = VwDirTrees.Where(v => v.Id == root).First();
                DirTreeModelNode rootNode = new DirTreeModelNode()
                {
                    ThisNode = vRootNode
                };
                DirTreeModelNode startNode = new DirTreeModelNode();
                dirTreeModel.SubDirs.Add(startNode);
                startNode.SubDirs.Add(rootNode);
                GetDirTreeChildNodes(dirTreeModel, rootNode, VwDirTrees, "");

                HtmlDirTreeRecurr(startNode);
                sbDirTree.Append("<div id='dirTreeCtxMenu'></div>");

                WriteFileToDisk(sbDirTree.ToString());

                success = "ok";
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
        public string AttemptRemoveLink(string linkId, int folderId)
        {
            string success;

            using (var db = new OggleBoobleMySqlContext())
            {
                try
                {
                    var imageLinks = db.CategoryImageLinks.Where(l => l.ImageLinkId == linkId).ToList();
                    if (imageLinks.Count > 1)
                    {
                        var imageFile = db.ImageFiles.Where(i => i.Id == linkId).First();
                        if (imageFile.FolderId == folderId)
                        {
                            success = "home folder Link";
                        }
                        else
                        {
                            var linkToRemove = db.CategoryImageLinks.Where(l => l.ImageLinkId == linkId && l.ImageCategoryId == folderId).First();
                            db.CategoryImageLinks.Remove(linkToRemove);
                            db.SaveChanges();
                            success = "ok";
                        }
                    }
                    else
                    {
                        success = "single link";
                    }
                }
                catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            }
            return(success);
        }
        public string AddLink(string linkId, int destinationId)
        {
            string success;

            using (var db = new OggleBoobleMySqlContext())
            {
                try
                {
                    db.CategoryImageLinks.Add(new MySqlDataContext.CategoryImageLink()
                    {
                        ImageCategoryId = destinationId,
                        ImageLinkId     = linkId,
                        SortOrder       = 1456
                    });
                    db.SaveChanges();
                    success = "ok";
                }
                catch (Exception ex)
                {
                    db.Dispose();
                    success = Helpers.ErrorDetails(ex);
                }
            }
            return(success);
        }
        public DirTreeSuccessModel BuildDirTree(int root)
        {
            DirTreeSuccessModel dirTreeModel = new DirTreeSuccessModel();

            try
            {
                var timer = new System.Diagnostics.Stopwatch();
                timer.Start();
                IEnumerable <VwDirTree> VwDirTrees = new List <VwDirTree>();
                using (var db = new OggleBoobleMySqlContext())
                {
                    // wow did this speed things up
                    VwDirTrees = db.VwDirTrees.ToList().OrderBy(v => v.Id);
                }

                var vRootNode             = VwDirTrees.Where(v => v.Id == root).First();
                DirTreeModelNode rootNode = new DirTreeModelNode()
                {
                    ThisNode = vRootNode
                };
                dirTreeModel.SubDirs.Add(rootNode);

                GetDirTreeChildNodes(dirTreeModel, rootNode, VwDirTrees, "");
                timer.Stop();
                dirTreeModel.TimeTook = timer.Elapsed;
                System.Diagnostics.Debug.WriteLine("RebuildCatTree took: " + timer.Elapsed);
                dirTreeModel.Success = "ok";
            }
            catch (Exception ex) { dirTreeModel.Success = Helpers.ErrorDetails(ex); }
            return(dirTreeModel);
        }
Beispiel #15
0
        public static string[] GetDirectories(string ftpPath)
        {
            IList <string> dirs = new List <string>();

            try
            {
                FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(new Uri(ftpPath));
                ftpRequest.Credentials = networkCredentials;
                ftpRequest.Method      = WebRequestMethods.Ftp.ListDirectoryDetails;
                FtpWebResponse response     = (FtpWebResponse)ftpRequest.GetResponse();
                StreamReader   streamReader = new StreamReader(response.GetResponseStream());

                string line = streamReader.ReadLine();
                while (!string.IsNullOrEmpty(line))
                {
                    dirs.Add(line);
                    line = streamReader.ReadLine();
                }
                streamReader.Close();
            }
            catch (Exception ex)
            {
                dirs.Add(Helpers.ErrorDetails(ex));
            }
            return(dirs.ToArray());
        }
        //[Route("api/IndexPage/GetCarouselImages")]
        public CarouselInfoModel GetCarouselImages(string root, int skip, int take, bool includeLandscape, bool includePortrait)
        {
            CarouselInfoModel carouselInfo = new CarouselInfoModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    if (includeLandscape)
                    {
                        carouselInfo.Links.AddRange(db.VwCarouselImages.Where(v => v.RootFolder == root).Where(v => v.Height < v.Width)
                                                    .Where(v => v.Width > v.Height)
                                                    .OrderBy(v => v.LinkId).Skip(skip).Take(take).ToList());
                    }
                    if (includePortrait)
                    {
                        carouselInfo.Links.AddRange(db.VwCarouselImages.Where(v => v.RootFolder == root).Where(v => v.Height < v.Width)
                                                    .Where(v => v.Height >= v.Width)
                                                    .OrderBy(v => v.LinkId).Skip(skip).Take(take).ToList());
                    }
                }
                carouselInfo.Success = "ok";
            }
            catch (Exception ex)
            {
                carouselInfo.Success = Helpers.ErrorDetails(ex);
            }
            return(carouselInfo);
        }
Beispiel #17
0
        public static string MoveFile(string source, string destination)
        {
            string success = "";

            try
            {
                FtpWebRequest requestDir = (FtpWebRequest)WebRequest.Create(source);
                requestDir.Credentials = networkCredentials;
                requestDir.Method      = WebRequestMethods.Ftp.DownloadFile;
                FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse();
                if (response.StatusCode != FtpStatusCode.CommandOK)
                {
                    success = response.StatusCode.ToString();
                }
                Stream ftpStream = response.GetResponseStream();
                success = Upload(destination, ToByteArray(ftpStream));
                if (success == "ok")
                {
                    ftpStream.Close();
                    response.Close();
                    requestDir = null;
                    success    = DeleteFile(source);
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
        private string RecordPageCreation(int folderId, string httpFileName, OggleBoobleMySqlContext db)
        {
            string success;

            try
            {
                var dbFolderDetail = db.FolderDetails.Where(d => d.FolderId == folderId).FirstOrDefault();
                if (dbFolderDetail == null)
                {
                    db.FolderDetails.Add(new FolderDetail()
                    {
                        FolderId         = folderId,
                        StaticFile       = httpFileName,
                        StaticFileUpdate = DateTime.Now
                    });
                }
                else
                {
                    dbFolderDetail.StaticFile       = httpFileName;
                    dbFolderDetail.StaticFileUpdate = DateTime.Now;
                }
                db.SaveChanges();
                success = "ok";
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Beispiel #19
0
        public LatestImageHitsReportModel LatestImageHits()
        {
            var imageHitsReportModel = new LatestImageHitsReportModel();

            try
            {
                using (var db = new OggleBoobleMySqContext())
                {
                    db.ImageHits.RemoveRange(db.ImageHits.Where(i => i.VisitorId == "ec6fb880-ddc2-4375-8237-021732907510"));

                    List <vwImageHit> imageHits = db.vwImageHits.ToList();
                    foreach (vwImageHit imageHit in imageHits)
                    {
                        imageHitsReportModel.Items.Add(new LatestImageHitsItem()
                        {
                            IpAddress  = imageHit.IpAddress,
                            City       = imageHit.City,
                            Region     = imageHit.Region,
                            Country    = imageHit.Country,
                            FolderName = imageHit.FolderName,
                            PageId     = imageHit.PageId,
                            HitTime    = imageHit.HitTime,
                            Link       = imageHit.Link
                        });
                    }
                    imageHitsReportModel.HitCount = db.ImageHits.Where(h => h.HitDateTime > DateTime.Today).Count();
                }
                imageHitsReportModel.Success = "ok";
            }
            catch (Exception ex) { imageHitsReportModel.Success = Helpers.ErrorDetails(ex); }
            return(imageHitsReportModel);
        }
Beispiel #20
0
        public string Update(BlogComment entry)
        {
            string success = "";

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    var dbEntry = db.BlogComments.Where(b => b.Id == entry.Id).FirstOrDefault();
                    if (dbEntry == null)
                    {
                        return("Entry not found");
                    }

                    dbEntry.CommentTitle = entry.CommentTitle;
                    dbEntry.CommentText  = entry.CommentText;
                    dbEntry.CommentType  = entry.CommentType;
                    dbEntry.ImageLink    = entry.ImageLink;
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception e)
            {
                success = Helpers.ErrorDetails(e);
            }
            return(success);
        }
Beispiel #21
0
        public MetricsMatrixResults MetricsMatrixReport()
        {
            var metricsMatrixResults = new MetricsMatrixResults();

            try
            {
                using (OggleBoobleMySqContext db = new OggleBoobleMySqContext())
                {
                    db.PageHits.RemoveRange(db.PageHits.Where(h => h.VisitorId == "ec6fb880-ddc2-4375-8237-021732907510"));
                    db.ImageHits.RemoveRange(db.ImageHits.Where(i => i.VisitorId == "ec6fb880-ddc2-4375-8237-021732907510"));
                    db.SaveChanges();
                    //VwPageHit vwPageHit = dbm.VwPageHits.FirstOrDefault();
                    List <MetricsMatrix> matrices = db.VwMetricsMatrices.ToList();
                    foreach (MetricsMatrix matrix in matrices)
                    {
                        metricsMatrixResults.MatrixRows.Add(new MatrixRowModel()
                        {
                            Column         = matrix.Column,
                            Today          = matrix.Today,
                            Yesterday      = matrix.Yesterday,
                            Two_Days_ago   = matrix.Two_Days_ago,
                            Three_Days_ago = matrix.Three_Days_ago,
                            Four_Days_ago  = matrix.Four_Days_ago,
                            Five_Days_ago  = matrix.Five_Days_ago,
                            Six_Days_ago   = matrix.Six_Days_ago
                        });
                    }

                    metricsMatrixResults.Success = "ok";
                }
            }
            catch (Exception ex) { metricsMatrixResults.Success = Helpers.ErrorDetails(ex); }
            return(metricsMatrixResults);
        }
Beispiel #22
0
        public SingleBlogCommentModel GetBlogItem(string blogId)
        {
            var singleBlogComment = new SingleBlogCommentModel();

            try
            {
                //using (var db = new OggleBoobleMSSqlContext())
                using (var db = new OggleBoobleMySqlContext())
                {
                    VwBlogComment vwBlogComment = db.VwBlogComments.Where(b => b.PkId == blogId).FirstOrDefault();
                    if (vwBlogComment != null)
                    {
                        singleBlogComment.CommentTitle = vwBlogComment.CommentTitle;
                        singleBlogComment.CommentText  = vwBlogComment.CommentText;
                        singleBlogComment.ImageLink    = vwBlogComment.ImageLink;
                        singleBlogComment.ImgSrc       = vwBlogComment.ImgSrc;
                        singleBlogComment.CommentType  = vwBlogComment.CommentType;
                        singleBlogComment.Pdate        = vwBlogComment.Pdate;
                        singleBlogComment.Success      = "ok";
                    }
                    else
                    {
                        singleBlogComment.Success = "blog entry not found";
                    }
                }
            }
            catch (Exception ex)
            {
                singleBlogComment.Success = Helpers.ErrorDetails(ex);
            }
            return(singleBlogComment);
        }
        public SuccessModel GetVisitorFromIp(string ipAddress)
        {
            var successModel = new SuccessModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    Visitor dbVisitor = db.Visitors.Where(v => v.IpAddress == ipAddress).FirstOrDefault();
                    if (dbVisitor == null)
                    {
                        successModel.ReturnValue = "not found";
                        successModel.Success     = "ok";
                    }
                    else
                    {
                        successModel.ReturnValue = dbVisitor.VisitorId;
                        successModel.Success     = "ok";
                    }
                }
            }
            catch (Exception ex)
            {
                successModel.Success = Helpers.ErrorDetails(ex);
            }
            return(successModel);
        }
        public GetImageCommentModel GetImageComment(string linkId)
        {
            var imageComment = new GetImageCommentModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    imageComment = (from c in db.ImageComments
                                    join i in db.ImageFiles on c.ImageLinkId equals i.Id
                                    join f in db.CategoryFolders on i.FolderId equals f.Id
                                    select new GetImageCommentModel()
                    {
                        CommentId = c.Id,
                        CommentText = c.CommentText,
                        CommentTitle = c.CommentTitle,
                        ImageName = f.FolderPath + "/" + i.FileName,
                        Posted = c.Posted.ToShortDateString()
                    }).Where(c => c.ImageLinkId == linkId).FirstOrDefault();
                    imageComment.Success = "ok";
                }
            }
            catch (Exception ex)
            {
                imageComment.Success = Helpers.ErrorDetails(ex);
            }
            return(imageComment);
        }
Beispiel #25
0
        public string AddStepChild(StepchildModel stepchildModel)
        {
            string success = "";

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    var folderToMove = db.CategoryFolders.Where(f => f.Id == stepchildModel.SourceFileId).First();
                    db.StepChildren.Add(new MySqlDataContext.StepChild()
                    {
                        Parent     = stepchildModel.DestinationId,
                        Child      = stepchildModel.SourceFileId,
                        FolderName = stepchildModel.FolderName ?? folderToMove.FolderName,
                        Link       = stepchildModel.LinkId ?? folderToMove.FolderImage,
                        SortOrder  = stepchildModel.SortOrder
                    });
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
Beispiel #26
0
        public static string[] GetFiles(string ftpPath)
        {
            IList <string> ftpFiles = new List <string>();

            try
            {
                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(ftpPath);
                request.Method      = WebRequestMethods.Ftp.ListDirectoryDetails;
                request.Credentials = networkCredentials;
                FtpWebResponse response = (FtpWebResponse)request.GetResponse();

                Stream       responseStream = response.GetResponseStream();
                string       line           = "";
                StreamReader reader         = new StreamReader(responseStream);
                {
                    while (!reader.EndOfStream)
                    {
                        line = reader.ReadLine();
                        if (!line.Contains("<DIR>"))
                        {
                            ftpFiles.Add(line.Substring(39, line.Length - 39));
                        }
                    }
                }
                reader.Close();
                response.Close();
            }
            catch (Exception ex)
            {
                ftpFiles.Add(Helpers.ErrorDetails(ex));
            }
            return(ftpFiles.ToArray());
        }
Beispiel #27
0
        public TrackbackItemsModel GetTrackBackLinks(int folderId)
        {
            var trackbackItems = new TrackbackItemsModel();

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    var trackbackLinks = db.TrackbackLinks.Where(t => t.PageId == folderId).ToList();
                    foreach (TrackbackLink trackbackLink in trackbackLinks)
                    {
                        trackbackItems.TrackBackItems.Add(new TrackbackLink()
                        {
                            SiteCode   = trackbackLink.SiteCode,
                            Href       = trackbackLink.Href,
                            LinkStatus = trackbackLink.LinkStatus
                        });
                    }
                    trackbackItems.Success = "ok";
                }
            }
            catch (Exception ex)
            {
                trackbackItems.Success = Helpers.ErrorDetails(ex);
            }
            return(trackbackItems);
        }
Beispiel #28
0
        public static string MoveFolder(string source, string destination)
        {
            string success = "";

            try
            {
                if (!FtpUtilies.DirectoryExists(destination))
                {
                    FtpUtilies.CreateDirectory(destination);
                }

                FtpWebRequest requestDir = (FtpWebRequest)WebRequest.Create(source);
                requestDir.Credentials = networkCredentials;
                requestDir.UseBinary   = true;
                requestDir.UsePassive  = false;
                requestDir.KeepAlive   = false;
                requestDir.Proxy       = null;
                requestDir.Method      = WebRequestMethods.Ftp.Rename;
                requestDir.RenameTo    = destination;
                FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse();
                response.Close();
                success = "ok";
            }
            catch (Exception ex) { success = Helpers.ErrorDetails(ex); }
            return(success);
        }
        public string AwardCredits(UserCredit userCredit)
        {
            string success;

            try
            {
                userCredit.Occured = DateTime.Now;
                using (var db = new OggleBoobleMySqlContext())
                {
                    //UserCredit existingVisitor = db.UserCredits.Where(cr => cr.VisitorId == userCredit.VisitorId).FirstOrDefault();
                    //if (existingVisitor == null)
                    //{}

                    db.UserCredits.Add(userCredit);

                    //var dbUser = db.RegisteredUsers.Where(r => r.VisitorId == userCredit.VisitorId).FirstOrDefault();
                    //if (dbUser != null) {
                    //    dbUser.UserCredits = db.UserCredits.Where(c => c.VisitorId == userCredit.VisitorId).Sum(c => c.Credits);
                    //}
                    db.SaveChanges();
                    success = "ok";
                }
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }
        public string LogActivity(ActivityLogModel activityLogModel)
        {
            string success;

            try
            {
                using (var db = new OggleBoobleMySqlContext())
                {
                    db.ActivityLogs.Add(new ActivityLog()
                    {
                        ActivityCode = activityLogModel.ActivityCode,
                        FolderId     = activityLogModel.FolderId,
                        VisitorId    = activityLogModel.VisitorId,
                        CalledFrom   = activityLogModel.CalledFrom,
                        Occured      = DateTime.Now
                    });
                    db.SaveChanges();
                }
                success = "ok";
            }
            catch (Exception ex)
            {
                success = Helpers.ErrorDetails(ex);
            }
            return(success);
        }