private string BuildPlayerScript(IASpotFile spotFile) { if (spotFile.FilenameUnique.ToLower().EndsWith("mp3")) { var path = ResolveUrl(string.Format("~/spotfile/{0}", spotFile.IASpotFileID)); var playerID = string.Format("player{0}", spotFile.IASpotFileID); var divTag = "<div id=\"{0}\"></div>"; var scriptTag = string.Format("<script type=\"text/javascript\">setSamplePlayer('{0}','{1}');</script>", path, playerID); divTag = string.Format(divTag, playerID); return string.Format("{0}\n{1}", scriptTag, divTag); } return string.Empty; }
public IASpot DuplicateSpot(IASpot oIASpot, int iIAProductionOrderID) { // Duplicate Spot Record var oIASpotDuplicate = new IASpot(); oIASpotDuplicate.IAProductionOrderID = iIAProductionOrderID; oIASpotDuplicate.IASpotStatusID = GetSpotStatusID(SpotStatus.OnHold); oIASpotDuplicate.IASpotTypeID = oIASpot.IASpotTypeID; oIASpotDuplicate.PurchaseOrderNumber = oIASpot.PurchaseOrderNumber; oIASpotDuplicate.DueDateTime = oIASpot.DueDateTime; oIASpotDuplicate.Length = oIASpot.Length; oIASpotDuplicate.LengthActual = oIASpot.LengthActual; oIASpotDuplicate.Title = oIASpot.Title; oIASpotDuplicate.ProductionNotes = oIASpot.ProductionNotes; oIASpotDuplicate.Script = oIASpot.Script; oIASpotDuplicate.IsAsap = oIASpot.IsAsap; oIASpotDuplicate.IsReviewed = true; var oIAProductionOrder = DataAccess.IAProductionOrders.SingleOrDefault(row => row.IAProductionOrderID == iIAProductionOrderID); if (oIAProductionOrder != null) { if (oIAProductionOrder.IAJob.IAJobStatusID == GetJobStatusID(JobStatus.ReCutRequested)) { // Mark duplicates created from recut request as not having been reviewed to force SS staff to review each and every spot before // being able to send them off to production. oIASpotDuplicate.IsReviewed = false; } } oIASpotDuplicate.CreatedDateTime = DateTime.Now; oIASpotDuplicate.CompletedDateTime = DateTime.Now; DataAccess.IASpots.InsertOnSubmit(oIASpotDuplicate); DataAccess.SubmitChanges(); // Duplicate Spot Fee Records foreach (var oIASpotFee in oIASpot.IASpotFees) { var oIASpotFeeDuplicate = new IASpotFee(); oIASpotFeeDuplicate.IASpotID = oIASpotDuplicate.IASpotID; oIASpotFeeDuplicate.IASpotFeeTypeID = oIASpotFee.IASpotFeeTypeID; oIASpotFeeDuplicate.Fee = oIASpotFee.Fee; oIASpotFeeDuplicate.LengthActual = oIASpotFee.LengthActual; DataAccess.IASpotFees.InsertOnSubmit(oIASpotFeeDuplicate); DataAccess.SubmitChanges(); } // Duplicate Spot File Records foreach (var oIASpotFile in oIASpot.IASpotFiles.Where(row => row.IASpotFileTypeID == GetSpotFileTypeID(SpotFileTypes.Production))) { var sExtension = string.Empty; var iIndex = oIASpotFile.FilenameUnique.LastIndexOf("."); if (iIndex > 0) { sExtension = oIASpotFile.FilenameUnique.Substring(iIndex, oIASpotFile.FilenameUnique.Length - iIndex); } var sFilename = string.Format("{0}{1}", Guid.NewGuid(), sExtension); try { File.Copy(string.Format("{0}{1}", UploadPath, oIASpotFile.FilenameUnique), string.Format("{0}{1}", UploadPath, sFilename)); } catch (Exception) { } var oIASpotFileDuplicate = new IASpotFile(); oIASpotFileDuplicate.IASpotID = oIASpotDuplicate.IASpotID; oIASpotFileDuplicate.IASpotFileTypeID = oIASpotFile.IASpotFileTypeID; oIASpotFileDuplicate.Filename = oIASpotFile.Filename; oIASpotFileDuplicate.FilenameUnique = sFilename; oIASpotFileDuplicate.FileSize = oIASpotFile.FileSize; oIASpotFileDuplicate.IsDeletable = true; oIASpotFileDuplicate.CreatedDateTime = DateTime.Now; DataAccess.IASpotFiles.InsertOnSubmit(oIASpotFileDuplicate); DataAccess.SubmitChanges(); } return oIASpotDuplicate; }
private bool ProcessUploadedFiles(RadUpload oUpload, IASpot oIASpot) { if (oUpload.UploadedFiles.Count > 0) { if (oIASpot.IASpotStatusID == ApplicationContext.GetSpotStatusID(SpotStatus.NeedsFix)) { // Mark all older files as 'old' by appending the word to their filenames. foreach (var oIASpotFIle in oIASpot.IASpotFiles.Where(row => row.IASpotFileTypeID == ApplicationContext.GetSpotFileTypeID(SpotFileTypes.Talent))) { var sNewFilename = string.Empty; var sExtension = string.Empty; var iIndex = oIASpotFIle.Filename.LastIndexOf("."); if (iIndex > 0) { sExtension = oIASpotFIle.Filename.Substring(iIndex, oIASpotFIle.Filename.Length - iIndex); } sNewFilename = string.Format("{0}_old{1}", MemberProtect.Utility.Left(oIASpotFIle.Filename, iIndex), sExtension); oIASpotFIle.Filename = sNewFilename; DataAccess.SubmitChanges(); } } foreach (UploadedFile oFile in oUpload.UploadedFiles) { // Create file record var oIASpotFile = new IASpotFile(); oIASpotFile.IASpotFileTypeID = ApplicationContext.GetSpotFileTypeID(SpotFileTypes.Talent); oIASpotFile.Filename = oFile.GetName(); oIASpotFile.FilenameUnique = string.Format("{0}{1}", Guid.NewGuid(), oFile.GetExtension()); oIASpotFile.FileSize = oFile.ContentLength; oIASpotFile.IsDeletable = true; oIASpotFile.CreatedDateTime = DateTime.Now; oIASpot.IASpotFiles.Add(oIASpotFile); DataAccess.SubmitChanges(); // Save physical file under a new name oFile.SaveAs(string.Format("{0}{1}", ApplicationContext.UploadPath, oIASpotFile.FilenameUnique)); } return true; } else { return false; } }
private bool ProcessUploadedProducerFiles(int iIASpotID) { if(m_oUploadProducer.UploadedFiles.Count > 0) { foreach(UploadedFile oFile in m_oUploadProducer.UploadedFiles) { // Create file record IASpotFile oIASpotFile = new IASpotFile(); oIASpotFile.IASpotID = iIASpotID; oIASpotFile.IASpotFileTypeID = ApplicationContext.GetSpotFileTypeID(SpotFileTypes.Production); oIASpotFile.Filename = oFile.GetName(); oIASpotFile.FilenameUnique = string.Format("{0}{1}", Guid.NewGuid(), oFile.GetExtension()); oIASpotFile.FileSize = oFile.ContentLength; oIASpotFile.IsDeletable = true; oIASpotFile.CreatedDateTime = DateTime.Now; DataAccess.IASpotFiles.InsertOnSubmit(oIASpotFile); DataAccess.SubmitChanges(); // Save physical file under a new name oFile.SaveAs(string.Format("{0}{1}", ApplicationContext.UploadPath, oIASpotFile.FilenameUnique)); } return true; } else { return false; } }