Esempio n. 1
0
        public void AddFile(string wikiname, WikiFile tfile, int tid, ApplicationUser user)
        {
            try
            {
                if (wikiname != null && this.WikiExists(wikiname) != false
                    && tfile !=null && tid>0 && user!=null)
                {

                    Wiki wk = this.GetWiki(wikiname);
                    WikiTitle title = this.Get(wikiname, tid);
                    //if (this.CountWithTitleId(wikiname, title.Id) > 0)
                    //{
                    //    tfile.Version = this.CountWithTitleId(wikiname, title.Id) + 1;
                    //}
                    //else
                    //{
                    //    tfile.Version = 1;
                    //}

                    tfile.Wiki = wk;
                    tfile.VersionDate = DateTime.Now;
                    tfile.Title = title;
                    tfile.Owner = user.Id;
                    wk.Files.Add(tfile);

                    this.db.Files.Add(tfile);
                    this.MarkWikiAsUpdated(wk);
                    this.db.SaveChanges();

                }
            }
            catch (ValidationException ex) { CommonTools.ValidationErrorReporting(ex); }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                //return null;
            }
        }
Esempio n. 2
0
        public void ImportFromModel(WikiFile md)
        {
            try
            {
                if (md != null && CommonTools.isEmpty(md.Owner) == false)
                {
                    ApplicationUser user = CommonTools.usrmng.GetUserbyID(md.Owner);
                    if (user != null)
                    {
                        this.Id = md.Id;
                        this.FileName = md.FileName;
                        this.RelativePath = md.RelativePath;
                        this.AbsolutePath = md.AbsolutePath;
                        this.FileType= md.FileType;
                        this.isImage = md.isImage;
                        this.Title = md.Title;
                        this.Version = md.Version;
                        this.VersionDate = md.VersionDate;
                        this.Owner = user;
                        this.Wiki = md.Wiki;

                    }
                }
            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);

            }
        }
Esempio n. 3
0
        public WikiFile ExportToModel()
        {
            try
            {
                WikiFile ap = new WikiFile();

                        ap.Id = Id;
                        ap.FileName = FileName;
                        ap.RelativePath = RelativePath;
                        ap.AbsolutePath = AbsolutePath;
                        ap.FileType = FileType;
                        ap.isImage = isImage;
                        ap.Title = Title;
                        ap.Version = Version;
                       ap.VersionDate =VersionDate;
                        ap.Owner = Owner.Id;
                        ap.Wiki = Wiki;
                return ap;

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return null;

            }
        }
Esempio n. 4
0
        public WikiFile MarkAFileAsImage(HttpPostedFileBase pfile , WikiFile wfile)
        {
            try
            {
                WikiFile ap = wfile;

                 if ( pfile !=null && wfile!=null )
                {
                    ap.isImage = this.isUplaodedFileImage(pfile);
                }
                return ap;

            }
            catch (Exception ex)
            {

                CommonTools.ErrorReporting(ex);
                return wfile;

            }
        }