private void CompareUserListInsert(DownloadShowList downloadShowList) { //Insert Show in UserList ShowList showList = UserDataMgr.GetThe().ShowList; bool bRentedShowIDFound_Flag = false; bool bNewShowInserted = false; if (downloadShowList != null) { foreach (DownloadShow downloadShow in downloadShowList) { bRentedShowIDFound_Flag = false; bRentedShowIDFound_Flag = showList.ContainsByRentedShowID(downloadShow.RentedShowID); if (!bRentedShowIDFound_Flag) { //Insert Show In User List Logger.LogInfo(this, "CompareUserListInsert", "Insert Show In User List"); AddDownloadShowToList(showList, downloadShow); bNewShowInserted = true; } } //Write User Xml if any show is inserted if (bNewShowInserted) { // Write user XML UserDataMgr.GetThe().SaveShowList(showList); //Session.GetThe().WriteUserDataToXML(userData); } } }
public bool DoUpdate(DownloadShowList downloadShowList) { //Omnie : Compare downloadlist item with UserList. If not found in User List then insert in UserList CompareUserListInsert(downloadShowList); //Omnie : Compare UserList item with DownloadList. If not found in DownloadList then Delete From UserList CompareUserListDelete(downloadShowList); //Omnie : Compare UserList item with HDD Files. If not found on HDD Delete From UserList & DownloadList CompareUserListHDDDelete(); //Omnie : If Not found on HDD and status is Notstarted then download file return(CompareUserListDownload()); }
private void RunOnce() { try { // get the Session Session session = Session.GetThe(); // get the user data manager UserDataMgr userDataMgr = UserDataMgr.GetThe(); // fetch next processing time long nextProcessTimeTicks = userDataMgr.GetNextProcessTick(); if (DateTime.Now.Ticks >= nextProcessTimeTicks) { Logger.LogInfo(this, "RunOnce", "Processing"); if (session.HaveUserCredentials && (!session.IsUserLoggedOn || session.HasSessionExpired)) { if (session.PingServer()) { session.Signon(); } } if (session.IsUserLoggedOn) { DownloadShowList downloadShowList = session.DownloadShowList(); if ((downloadShowList != null) && (new UpdateUserDataShowList()).DoUpdate(downloadShowList)) { return; // progess again immediately } } // increment next processing time in UserData userDataMgr.IncNextProcessTick(nextProcessTimeTicks); } } catch (Exception e) { Logger.LogError(this, "RunOnce", e.StackTrace); } }
private void CompareUserListDelete(DownloadShowList downloadShowList) { //Delete Show From UserList ShowList showList = UserDataMgr.GetThe().ShowList; ShowList newShowList = new ShowList(); bool bRentedShowIDFound_Flag = false; bool bShowDeleted = false; foreach (Show show in showList) { bRentedShowIDFound_Flag = downloadShowList.ContainsByRentedShowID(show.RentedShowID); if (!bRentedShowIDFound_Flag) { //Delete Show From User List Logger.LogInfo(this, "CompareUserListDelete", "Delete Show From User List and HDD"); try { DriveInfo.DeleteShowFromHDD(show.DataFileName.ToString()); bShowDeleted = true; } catch (Exception e) { Logger.LogError(this, "CompareUserListDelete", e); } } else { newShowList.Add(show); } } // Write user XML if any show is deleted if (bShowDeleted) { UserDataMgr.GetThe().SaveShowList(newShowList); } }
public void ReadFrom(DataReader reader) { fDownloadShowList = (DownloadShowList)reader.ReadList("DownloadShow", DownloadShowList.Ctor, DownloadShow.CtorDataReader); }