public static bool InsertDownloadApp(SqlConnection conn, DownloadApp model)
        {
            string sql = @"   INSERT INTO Tuhu_huodong..DownloadApp
                                      ( Title ,
                                        BottomContent ,
                                        ImageContent ,
                                        TimerContent ,
                                        BottomStatus ,
                                        TimerStatus ,
                                        CreateTime  ,
                                        UpdateTime  ,Type                                 
                                      )
                              VALUES  ( @Title ,
                                        @BottomContent ,
                                        @ImageContent ,
                                        @TimerContent ,
                                        @BottomStatus ,
                                        @TimerStatus ,
                                        GETDATE() , -- CreateTime - datetime
                                        GETDATE() ,@Type
                                      )";

            var sqlPrams = new SqlParameter[]
            {
                new SqlParameter("@Title", model.Title ?? string.Empty),
                new SqlParameter("@BottomContent", model.BottomContent ?? string.Empty),
                new SqlParameter("@ImageContent", model.ImageContent ?? string.Empty),
                new SqlParameter("@BottomStatus", model.BottomStatus),
                new SqlParameter("@TimerStatus", model.TimerStatus),
                new SqlParameter("@TimerContent", model.TimerContent ?? string.Empty),
                new SqlParameter("@Type", model.Type)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlPrams) > 0);
        }
        public static bool UpdateDownloadApp(SqlConnection conn, DownloadApp model, int id)
        {
            string sql      = @"UPDATE    Tuhu_huodong..DownloadApp
                          SET       Title = @Title ,
                                    BottomContent = @BottomContent ,
                                    ImageContent = @ImageContent ,
                                    TimerContent = @TimerContent ,
                                    BottomStatus = @BottomStatus ,
                                    TimerStatus = @TimerStatus ,
                                    Type = @Type,
                                    UpdateTime = GETDATE()
                          WHERE     Id = @id";
            var    sqlPrams = new SqlParameter[]
            {
                new SqlParameter("@Title", model.Title ?? string.Empty),
                new SqlParameter("@BottomContent", model.BottomContent ?? string.Empty),
                new SqlParameter("@ImageContent", model.ImageContent ?? string.Empty),
                new SqlParameter("@BottomStatus", model.BottomStatus),
                new SqlParameter("@TimerStatus", model.TimerStatus),
                new SqlParameter("@TimerContent", model.TimerContent ?? string.Empty),
                new SqlParameter("@id", id),
                new SqlParameter("@Type", model.Type)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlPrams) > 0);
        }
示例#3
0
        public ActionResult EditNew(int id)
        {
            DownloadApp model = DownloadAppManager.GetDownloadAppById(id);

            ViewBag.DownloadApp = model;
            return(View());
        }
示例#4
0
        public override void Layout()
        {
            DownloadApp app = ctx.app.obj as DownloadApp;

            set("adminUrl", to(new Admin.FileController().List));
            set("appUrl", to(new DownloadController().Index));

            set("adminCheckUrl", t2(new SecurityController().CanAppAdmin, app.Id) + "?appType=" + typeof(DownloadApp).FullName);
        }
示例#5
0
        private DownloadApp createApp(MvcContext ctx, String appName)
        {
            IMember owner   = ctx.owner.obj;
            User    creator = ctx.viewer.obj as User;

            IMemberApp app = installService.Install(typeof(DownloadApp), owner, creator, appName) as IMemberApp;

            // 初始化权限,否则无法访问
            base.initAppPermission(app);

            DownloadApp obj = DownloadApp.findById(app.AppOid);

            return(obj);
        }
示例#6
0
        public ActionResult Index(DownloadApp model, int pageIndex = 1, int pageSize = 25)
        {
            int count = 0;

            List <DownloadApp> listModel = DownloadAppManager.GetDownloadAppList(model, pageSize, pageIndex, out count);

            var list  = new OutData <List <DownloadApp>, int>(listModel, count);
            var pager = new PagerModel(pageIndex, pageSize)
            {
                TotalItem = count
            };

            return(this.View(new ListModel <DownloadApp>(list.ReturnValue, pager)));
        }
        public static List <DownloadApp> GetDownloadAppList(SqlConnection conn, DownloadApp model, int pageSize, int pageIndex, out int recordCount)
        {
            string sqlStr = "";

            if (model.Id > 0)
            {
                sqlStr += " And Id = @Id";
            }
            if (!string.IsNullOrWhiteSpace(model.Title))
            {
                sqlStr += " And Title =@Title";
            }
            string sql      = @" 
                            SELECT  *
                            FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY UpdateTime DESC ) AS ROWNUMBER ,
                                                [Id] ,
                                                [Title] ,
                                                [BottomContent] ,
                                                [ImageContent] ,
                                                [TimerContent] ,
                                                BottomStatus ,
                                                TimerStatus ,
                                                [CreateTime] ,
                                                [UpdateTime],Type
                                      FROM      [Tuhu_huodong].[dbo].[DownloadApp] WITH ( NOLOCK )
                                      WHERE     1 = 1  " + sqlStr + @"
                                    ) AS PG
                            WHERE   PG.ROWNUMBER BETWEEN STR(( @PageIndex - 1 ) * @PageSize + 1)
                                                 AND     STR(@PageIndex * @PageSize)
                            ";
            string sqlCount = @"SELECT COUNT(1) FROM [Tuhu_huodong].[dbo].[DownloadApp]  WITH(NOLOCK)  WHERE 1=1    " + sqlStr;

            var sqlPrams = new SqlParameter[]
            {
                new SqlParameter("@PageSize", pageSize),
                new SqlParameter("@PageIndex", pageIndex),
                new SqlParameter("@Id", model.Id),
                new SqlParameter("@Title", model.Title)
            };

            recordCount = (int)SqlHelper.ExecuteScalar(conn, CommandType.Text, sqlCount, sqlPrams);

            return(SqlHelper.ExecuteDataTable(conn, CommandType.Text, sql, sqlPrams).ConvertTo <DownloadApp>().ToList());
        }
示例#8
0
        public override void Layout()
        {
            DownloadApp app = ctx.app.obj as DownloadApp;

            set("lnkFiles", to(new Admin.FileController().List));
            set("lnkAdd", to(new Admin.FileController().Add));

            set("lnkCateAdmin", to(new Admin.CategoryController().List));
            set("lnkSubCate", to(new Admin.SubCategoryController().List));
            set("lnkLicense", to(new Admin.LicenseController().List));
            set("lnkPlatform", to(new Admin.PlatformController().List));
            set("lnkLang", to(new Admin.LangController().List));


            set("adminCheckUrl", t2(new SecurityController().CanAppAdmin, app.Id) + "?appType=" + typeof(DownloadApp).FullName);


            // 当前app/module所有页面,所属的首页
            String[] moduleUrlList = new String[1];
            moduleUrlList[0] = to(new DownloadController().Index);

            ctx.SetItem("_moduleUrl", moduleUrlList);
        }
示例#9
0
        public ActionResult UpdateDownloadApp(DownloadApp model, int id)
        {
            var status = false;

            try
            {
                if (DownloadAppManager.UpdateDownloadApp(model, id))
                {
                    using (var client = new ActivityClient())
                    {
                        var result = client.CleanActivityConfigForDownloadAppCache(id);
                        status = result.Success;
                    }
                }
                return(Json(status));
            }
            catch (Exception ex)
            {
                return(Json(false));

                throw ex;
            }
        }
示例#10
0
        public void Init(MvcContext ctx, String appName, String fUrl)
        {
            DownloadApp downloadApp = createApp(ctx, appName);

            base.AddMenu(ctx, appName, alink.ToApp(downloadApp), fUrl);
        }
示例#11
0
        protected void SearchForAppropriateDownloads(List <TorrentEntry> downloading, DownloadApp tApp, TVDoc.ScanSettings settings)
        {
            ItemList newList  = new ItemList();
            ItemList toRemove = new ItemList();
            int      c        = ActionList.MissingItems().Count() + 2;
            int      n        = 1;

            UpdateStatus(n, c, "Searching torrent queue...");
            foreach (ItemMissing action in ActionList.MissingItems().ToList())
            {
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

                UpdateStatus(n++, c, action.Filename);

                foreach (TorrentEntry te in downloading)
                {
                    FileInfo file = new FileInfo(te.DownloadingTo);
                    if (!file.IsMovieFile()) // not a usefile file extension
                    {
                        continue;
                    }

                    //do any of the possible names for the series match the filename?
                    bool matched = action.Episode.Show.NameMatch(file, true);

                    if (!matched)
                    {
                        continue;
                    }

                    if (FinderHelper.FindSeasEp(file, out int seasF, out int epF, out int _, action.Episode.Show) && (seasF == action.Episode.AppropriateSeasonNumber) && (epF == action.Episode.AppropriateEpNum))
                    {
                        toRemove.Add(action);
                        newList.Add(new ItemDownloading(te, action.Episode, action.TheFileNoExt, tApp));
                        break;
                    }
                }
            }
            ActionList.Replace(toRemove, newList);
        }
示例#12
0
 public ActionResult AddDownloadApp(DownloadApp model)
 {
     return(Json(DownloadAppManager.InsertDownloadApp(model)));
 }
示例#13
0
        protected void SearchForAppropriateDownloads(List <TorrentEntry> downloading, DownloadApp tApp, TVDoc.ScanSettings settings)
        {
            ItemList newList  = new ItemList();
            ItemList toRemove = new ItemList();
            int      c        = ActionList.Missing.Count + 2;
            int      n        = 1;

            UpdateStatus(n, c, "Searching torrent queue...");
            foreach (ItemMissing?action in ActionList.Missing.ToList())
            {
                if (settings.Token.IsCancellationRequested)
                {
                    return;
                }

                UpdateStatus(n++, c, action.Filename);

                foreach (TorrentEntry te in downloading)
                {
                    FileInfo file = new FileInfo(te.DownloadingTo);
                    if (!file.IsMovieFile() && file.Extension != ".rar") // not a usefile file extension
                    {
                        continue;
                    }

                    if (action is ShowItemMissing showMissingAction)
                    {
                        //do any of the possible names for the cachedSeries match the filename?
                        ProcessedEpisode episode = showMissingAction.MissingEpisode;
                        bool             matched = episode.Show.NameMatch(file, true);

                        if (!matched)
                        {
                            continue;
                        }

                        if (FinderHelper.FindSeasEp(file, out int seasF, out int epF, out int _,
                                                    episode.Show) && seasF == episode.AppropriateSeasonNumber &&
                            epF == episode.AppropriateEpNum)
                        {
                            toRemove.Add(action);
                            newList.Add(new ItemDownloading(te, episode, action.TheFileNoExt, tApp, action));
                            break;
                        }
                    }

                    if (action is MovieItemMissing movieMissingAction)
                    {
                        //do any of the possible names for the cachedSeries match the filename?
                        MovieConfiguration movie = movieMissingAction.MovieConfig;
                        bool matched             = movie.NameMatch(file, true);

                        if (!matched)
                        {
                            continue;
                        }


                        toRemove.Add(action);
                        newList.Add(new ItemDownloading(te, movie, action.TheFileNoExt, tApp, action));
                        break;
                    }
                }
            }
            ActionList.Replace(toRemove, newList);
        }
示例#14
0
        protected void SearchForAppropriateDownloads(SetProgressDelegate prog, int startpct, int totPct, List <TorrentEntry> downloading, DownloadApp tApp)
        {
            ItemList newList  = new ItemList();
            ItemList toRemove = new ItemList();
            int      c        = ActionList.Count + 2;
            int      n        = 1;

            prog.Invoke(startpct);
            foreach (ItemMissing action in ActionList.MissingItems())
            {
                if (ActionCancel)
                {
                    return;
                }

                prog.Invoke(startpct + ((totPct - startpct) * (++n) / (c)));

                foreach (TorrentEntry te in downloading)
                {
                    FileInfo file = new FileInfo(te.DownloadingTo);
                    if (!TVSettings.Instance.UsefulExtension(file.Extension, false)) // not a usefile file extension
                    {
                        continue;
                    }

                    //do any of the possible names for the series match the filename?
                    bool matched = (action.Episode.Show.GetSimplifiedPossibleShowNames().Any(name => FileHelper.SimplifyAndCheckFilename(file.FullName, name)));

                    if (!matched)
                    {
                        continue;
                    }

                    if (TVDoc.FindSeasEp(file, out int seasF, out int epF, out int _, action.Episode.Show) && (seasF == action.Episode.AppropriateSeasonNumber) && (epF == action.Episode.AppropriateEpNum))
                    {
                        toRemove.Add(action);
                        newList.Add(new ItemDownloading(te, action.Episode, action.TheFileNoExt, tApp));
                        break;
                    }
                }
            }

            foreach (Item i in toRemove)
            {
                ActionList.Remove(i);
            }

            foreach (Item action in newList)
            {
                ActionList.Add(action);
            }

            prog.Invoke(totPct);
        }