Exemplo n.º 1
0
        // GET: Transcripts/Details/5
        public ActionResult Play(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Transcript transcript = db.Transcripts.Find(id);

            if (transcript == null)
            {
                return(HttpNotFound());
            }

            if (!transcript.Active)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            string fn = Path.GetFileNameWithoutExtension(transcript.PlayFile);

            ViewBag.srtFile = fn + ".txt";
            string inFile = Server.MapPath("~/temp") + "\\" + ViewBag.srtFile;

            System.IO.File.WriteAllText(inFile, transcript.Text_Sort);

            EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Load_Play", null, null, null, null);


            return(View(transcript));
        }
Exemplo n.º 2
0
        public ActionResult Login(ProjectLoginViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            Project project = db.Projects.Find(model.id);

            if (project.Password == model.Password)
            {
                Session["loggedIn"]  = "True";
                Session["ProjectId"] = model.id;
                EventLoad.LogEvent(User.Identity.Name, null, "Project_Login", null, null, null, model.id);
                return(RedirectToAction("Unit", new { id = model.id }));
            }
            else
            {
                ModelState.AddModelError("", "Invalid login attempt.");
                model.DeptName  = project.DeptName;
                model.PageTitle = project.PageTitle;
                model.PageLogo  = "https://torquexstorage01.blob.core.windows.net/torquexmediaplayer/" + project.PageLogo;
                return(View(model));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            // This doesn't count login failures towards account lockout
            // To enable password failures to trigger account lockout, change to shouldLockout: true
            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false);

            switch (result)
            {
            case SignInStatus.Success:
                EventLoad.LogEvent(User.Identity.Name, null, "Account_Login", null, null, null, null);
                return(RedirectToLocal("~/Transcripts"));

            case SignInStatus.LockedOut:
                return(View("Lockout"));

            case SignInStatus.RequiresVerification:
                return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));

            case SignInStatus.Failure:
            default:
                ModelState.AddModelError("", "Invalid login attempt.");
                return(View(model));
            }
        }
Exemplo n.º 4
0
        // GET: Projects
        public ActionResult Index()
        {
            var projects = from s in db.Projects select s;

            projects = projects.Where(s => s.CreateBy.Equals(User.Identity.Name));
            EventLoad.LogEvent(User.Identity.Name, null, "List_Projects", null, null, null, null);
            return(View(projects.ToList()));
        }
Exemplo n.º 5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Transcript transcript = db.Transcripts.Find(id);

            EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Delete_Transcript", null, null, null, null);
            transcript.Active          = false;
            db.Entry(transcript).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public JsonResult EventLog(JsonEventLog sEvent)
        {
            var query = from s in db.Transcripts select s;

            query = query.Where(s => s.mediaId.Equals(sEvent.mediaId));
            Transcript transcript = query.FirstOrDefault();

            EventLoad.LogEvent(User.Identity.Name, transcript.Id, sEvent.eventType, sEvent.eventValue, null, null, transcript.ProjectId);
            return(Json(new { status = "SUCCESS" }));
        }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Project project = db.Projects.Find(id);

            db.Projects.Remove(project);
            db.SaveChanges();
            var sId = new SqlParameter("@id", id);

            db.Database.ExecuteSqlCommand("update Transcripts set ProjectId = null, Project = null where ProjectId = @id;", sId);
            EventLoad.LogEvent(User.Identity.Name, null, "Project_Delete", null, null, null, id);
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
        // GET: Projects/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Project project = db.Projects.Find(id);

            EventLoad.LogEvent(User.Identity.Name, null, "Project_Details", null, null, null, id);
            if (project == null)
            {
                return(HttpNotFound());
            }
            return(View(project));
        }
Exemplo n.º 9
0
        // GET: Transcripts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Transcript transcript = db.Transcripts.Find(id);

            if (transcript == null)
            {
                return(HttpNotFound());
            }
            EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Transcript_Details", null, null, null, null);

            return(View(transcript));
        }
Exemplo n.º 10
0
        public ActionResult Unit(int?id, string currentFilter, string searchString)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if ((Session["loggedIn"] == null) || (Session["loggedIn"].ToString() != "True") || (Session["ProjectId"].ToString() != id.ToString()))
            {
                return(RedirectToAction("Login", new { id = id }));
            }
            Project project = db.Projects.Find(id);

            if (searchString == null)
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;

            if (project == null)
            {
                return(HttpNotFound());
            }

            var projectUnit = new PublicProject();

            projectUnit.DeptName    = project.DeptName;
            projectUnit.PageFooter  = project.PageFooter;
            projectUnit.PageLogo    = "https://torquexstorage01.blob.core.windows.net/torquexmediaplayer/" + project.PageLogo;
            projectUnit.PageTitle   = project.PageTitle;
            projectUnit.ProjectName = project.ProjectName;
            projectUnit.ID          = project.ID;

            var transcripts = from s in db.Transcripts select s;

            transcripts = transcripts.Where(s => s.ProjectId == id && s.Active == true);

            if (!String.IsNullOrEmpty(searchString))
            {
                transcripts = transcripts.Where(s => s.Text_Plain.Contains(searchString));
            }

            projectUnit.Transcripts = transcripts.ToList();
            EventLoad.LogEvent(User.Identity.Name, null, "Project_View", null, null, null, project.ID);

            return(View(projectUnit));
        }
Exemplo n.º 11
0
        public ActionResult Create(ProjectUpload formdata)
        {
            if (ModelState.IsValid)
            {
                var project = new Project();
                project.CreateBy    = User.Identity.Name;
                project.CreateDate  = DateTime.Now;
                project.PageFooter  = formdata.PageFooter;
                project.PageTitle   = formdata.PageTitle;
                project.ProjectName = formdata.ProjectName;
                project.DeptName    = formdata.DeptName;
                project.Password    = formdata.Password;
                project.Email       = formdata.Email;
                if (formdata.file != null)
                {
                    CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"]);

                    CloudBlobClient    blobClient    = storageAccount.CreateCloudBlobClient();
                    CloudBlobContainer blobContainer = blobClient.GetContainerReference("torquexmediaplayer");

                    string ext    = Path.GetExtension(formdata.file.FileName);
                    string fn     = Path.GetFileNameWithoutExtension(formdata.file.FileName);
                    string random = "_" + Path.GetRandomFileName().Replace(".", "").Substring(0, 8);
//                    string saveFile = Server.MapPath("~/Content/ProjectLogos") + "\\" + fn + random + ext;
                    project.PageLogo = fn + random + ext;

                    string blockName = StringUtils.blockName(project.PageLogo);

                    if (!string.IsNullOrEmpty(blockName))
                    {
                        CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blockName);
                        //upload files
                        blob.UploadFromStream(formdata.file.InputStream);
                    }


//                    formdata.file.SaveAs(saveFile);
                }
                db.Projects.Add(project);
                db.SaveChanges();
                EventLoad.LogEvent(User.Identity.Name, null, "Project_Details", null, null, null, project.ID);
                ViewBag.Message = "File has been uploaded successfully";
                ModelState.Clear();
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Exemplo n.º 12
0
        public FileResult downloadTranscript(string mediaid, string format)
        {
            Transcript transcript = db.Transcripts.FirstOrDefault(s => s.mediaId == mediaid);

            string filepath = Server.MapPath("~/temp/");
            string fname    = mediaid;
            string filename = filepath + fname;

            EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Download", format, null, null, null);


            switch (format)
            {
            case "rtf":
                fname    = mediaid + ".docx";
                filename = filepath + fname;
                CreateFormatWordDoc(filename, transcript.JSON);
                break;

            case "srt":
                fname    = mediaid + ".srt";
                filename = filepath + fname;
                System.IO.File.WriteAllText(@filename, transcript.Text_Sort);
                break;

            case "docd":
                fname    = mediaid + ".docx";
                filename = filepath + fname;
                CreateTimeStampWordDoc(filename, transcript.JSON);
                break;

            default:
                fname    = mediaid + ".txt";
                filename = filepath + fname;
                System.IO.File.WriteAllText(@filename, transcript.Text_Plain);
                break;
            }
            return(File(filename, System.Net.Mime.MediaTypeNames.Application.Octet, fname));
        }
Exemplo n.º 13
0
        public ActionResult Edit(Transcript transcript)
        {
            if (ModelState.IsValid)
            {
                Transcript updatedtrans = (from s in db.Transcripts
                                           where s.Id == transcript.Id
                                           select s).FirstOrDefault();
                updatedtrans.Filename = transcript.Filename;
                var project = db.Projects.Where(s => s.ID == transcript.ProjectId)
                              .Select(s => new { s.ProjectName })
                              .ToList();
                if (project.Count == 1)
                {
                    updatedtrans.Project = project[0].ProjectName;
                }
                updatedtrans.ProjectId       = transcript.ProjectId;
                db.Entry(updatedtrans).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Edit_Transcript", null, null, null, null);

            return(View(transcript));
        }
Exemplo n.º 14
0
        // GET: Transcripts/Details/5
        public ActionResult Play(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Transcript transcript = db.Transcripts.Find(id);

            if (transcript == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (!transcript.Active)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if ((Session["loggedIn"] == null) || (Session["loggedIn"].ToString() != "True") || (Session["ProjectId"].ToString() != transcript.ProjectId.ToString()))
            {
                return(RedirectToAction("Login", new { id = transcript.ProjectId }));
            }


            if (transcript == null)
            {
                return(HttpNotFound());
            }

            var PlayProject = new ProjectTranscript();

            Project project = db.Projects.Find(transcript.ProjectId);

            PlayProject.transcript = transcript;
            PlayProject.PageLogo   = "https://torquexstorage01.blob.core.windows.net/torquexmediaplayer/" + project.PageLogo;

            string fn = Path.GetFileNameWithoutExtension(transcript.PlayFile);

            PlayProject.srtFile = fn + ".txt";
            string inFile = Server.MapPath("~/temp") + "\\" + PlayProject.srtFile;

            System.IO.File.WriteAllText(inFile, transcript.Text_Sort);

            // Update srt file to blob storage to get over CORs issues and get the latest version.

            /*            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"]);
             *          CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
             *          CloudBlobContainer blobContainer = blobClient.GetContainerReference("torquexmediaplayer");
             *
             *          string blockName = StringUtils.blockName(PlayProject.srtFile);
             *          CloudBlockBlob blob = blobContainer.GetBlockBlobReference(blockName);
             *
             *          using (var stream = new MemoryStream(Encoding.Default.GetBytes(transcript.Text_Sort), false))
             *          {
             *              blob.UploadFromStream(stream);
             *          }
             *
             */
            EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Project_Load_Play", null, null, null, transcript.ProjectId);

            return(View(PlayProject));
        }
Exemplo n.º 15
0
        public ActionResult Update(PUpload updata)
        {
            List <Words> wordlist = new List <Words>();
            Media        VB;
            Media        JSONout;
            Words        word;
            Words        wordout;
            Words        oldWord;
            PWords       newWord;
            var          data = new ResponseData();

            data.requestStatus = "FAILED";
            Transcript transcript = (from s in db.Transcripts
                                     where s.mediaId == updata.mediaId
                                     select s).FirstOrDefault();
            string JSON             = transcript.JSON;
            var    json_serializer1 = new JavaScriptSerializer();
            var    json_serializer2 = new JavaScriptSerializer();

            VB      = json_serializer1.Deserialize <Media>(JSON);
            JSONout = json_serializer2.Deserialize <Media>(JSON);
            JSONout.media.transcripts.latest.words = wordlist.ToArray();

            // Get Txt Srt file into memory.
            List <SrtFile> srtList    = new List <SrtFile>();
            SrtFile        srtIntance = new SrtFile();
            SrtFile        srtObj     = (SrtFile)srtIntance.Clone();
            int            sPos       = 0;


            using (StringReader reader = new StringReader(transcript.Text_Sort))
            {
                string line = string.Empty;
                do
                {
                    line = reader.ReadLine();
                    if (line != null)
                    {
                        if (line.Length == 0)
                        {
                            srtList.Add(srtObj);
                            srtObj         = (SrtFile)srtIntance.Clone();
                            sPos           = 0;
                            srtObj.content = "";
                        }
                        else
                        {
                            switch (sPos)
                            {
                            case 0:
                                srtObj.pos = line;
                                sPos++;
                                break;

                            case 1:
                                sPos++;
                                string[] separators = { " --> " };
                                string[] times      = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                                srtObj.s    = StringUtils.timeToMilliseconds(times[0]);
                                srtObj.e    = StringUtils.timeToMilliseconds(times[1]);
                                srtObj.time = line;
                                break;

                            default:
                                srtObj.content += line + "\n";
                                break;
                            }
                        }
                    }
                } while (line != null);
                srtList.Add(srtObj);
            }

            int numwords   = updata.content.Count();
            int i          = 0;
            int outcounter = 0;

            while (outcounter < numwords)
            {
                word    = VB.media.transcripts.latest.words[i];
                newWord = updata.content[outcounter];

                // Check if speaker insertion
                if ((newWord.m != null) && ((word.m == null) || (word.m == "punc")))
                {
                    wordout   = (Words)word.Clone();
                    wordout.p = outcounter;
                    wordout.e = wordout.s + 1000;
                    wordout.w = newWord.w.Trim();
                    wordout.m = "turn";
                    wordlist.Add(wordout);
                    outcounter++;
                    newWord = updata.content[outcounter];
                }

                // Check if word deleted
                if (word.s < newWord.s)
                {
                    i++;
                }
                else
                {
                    wordout   = (Words)word.Clone();
                    wordout.p = outcounter;
                    wordout.w = newWord.w.Trim();
                    wordlist.Add(wordout);
                    if (word.w != newWord.w.Trim())  // write a record to the change log table.
                    {
                        var wChange = new WordChange();
                        wChange.changeBy     = User.Identity.Name;
                        wChange.changeDate   = DateTime.Now;
                        wChange.p            = i;
                        wChange.TranscriptId = transcript.Id;
                        wChange.m            = wordout.m;
                        wChange.oldWord      = word.w;
                        wChange.newWord      = newWord.w.Trim();
                        wChange.s            = word.s;
                        db.WordChanges.Add(wChange);
                        db.SaveChanges();

                        // Update Srt
                        // Find relevant object.
                        int j = 0;
                        do
                        {
                            if ((srtList[j].s <= word.s) && (srtList[j].e >= word.s))
                            {
                                srtList[j].content = srtList[j].content.Replace(word.w, newWord.w.Trim());
                            }
                            j++;
                        } while (j < srtList.Count);

                        EventLoad.LogEvent(User.Identity.Name, transcript.Id, "Word_Change", null, wChange.oldWord, wChange.newWord, null);
                    }
                    outcounter++;
                    i++;
                }
            }

            JSONout.media.transcripts.latest.words = wordlist.ToArray();
            var sJSONout = new JavaScriptSerializer().Serialize(JSONout);

            //updated text srt file
            string srtString = "";
            int    cnt       = 0;

            do
            {
                srtString += srtList[cnt].pos + "\n";
                srtString += srtList[cnt].time + "\n";
                srtString += srtList[cnt].content + "\n";
                cnt++;
            } while (cnt < srtList.Count);


            transcript.JSON            = sJSONout;
            transcript.Text_Sort       = srtString;
            db.Entry(transcript).State = EntityState.Modified;
            db.SaveChanges();

            data.requestStatus = "SUCCESS";
            data.id            = transcript.Id;

            //return RedirectToAction("Play", new { id = transcript.Id });

            return(Json(data));
        }
Exemplo n.º 16
0
        // GET: Transcripts
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            ViewBag.CurrentSort      = sortOrder;
            ViewBag.CreateSortParm   = String.IsNullOrEmpty(sortOrder) ? "CreateTime_desc" : "";
            ViewBag.FileNameSortParm = sortOrder == "Filename" ? "Filename_desc" : "Filename";
            ViewBag.ProjectSortParm  = sortOrder == "Project" ? "Project_desc" : "Project";
            var transcripts = from s in db.Transcripts select s;

            transcripts = transcripts.Where(s => s.createby.Equals(User.Identity.Name) && s.Active == true);// override object.Equals

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;


            if (!String.IsNullOrEmpty(searchString))
            {
                transcripts = transcripts.Where(s => s.Text_Plain.Contains(searchString));
            }

            switch (sortOrder)
            {
            case "Filename_desc":
                transcripts = transcripts.OrderByDescending(s => s.Filename);
                break;

            case "Filename":
                transcripts = transcripts.OrderBy(s => s.Filename);
                break;

            case "CreateTime_desc":
                transcripts = transcripts.OrderByDescending(s => s.CreateTime);
                break;

            case "CreateTime":
                transcripts = transcripts.OrderBy(s => s.CreateTime);
                break;

            case "Project_desc":
                transcripts = transcripts.OrderByDescending(s => s.Project);
                break;

            case "Project":
                transcripts = transcripts.OrderBy(s => s.Project);
                break;

            default:
                transcripts = transcripts.OrderByDescending(s => s.Id);
                break;
            }
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            EventLoad.LogEvent(User.Identity.Name, null, "List_Transcripts", null, null, null, null);
            return(View(transcripts.ToPagedList(pageNumber, pageSize)));
        }