예제 #1
0
        public ActionResult DeleteStory(string storyId)
        {
            MomentDAL DAL = new MomentDAL();

            DAL.DeleteStory(storyId);
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult UploadText()
        {
            var parentId    = Request.Form["id"];
            var storyId     = Request.Form["story"];
            var contents    = Request.Form["contents"];
            var contentType = Request.Form["type"];

            if (contentType == "Video")
            {
                contents = contents.Replace("watch?v=", "embed/");
            }
            if (contentType == "Audio")
            {
                contents = Server.UrlDecode(contents);
                contents = Regex.Match(contents, "<iframe.+?src=[\"'](.+?)[\"'].*?>", RegexOptions.IgnoreCase).Groups[1].Value;
            }
            var service = new MomentDAL();
            var id      = service.AddNewNode(new Node
            {
                CreationDate = DateTime.Now,
                Active       = true,
                CreatedBy    = Convert.ToInt32(Session["UserProfileId"]),
                ParentId     = Convert.ToInt32(parentId),
                StoryId      = Convert.ToInt32(storyId),
                Contents     = contents,
                Type         = contentType
            });

            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult ChangeStoryStatus(string storyId)
        {
            MomentDAL DAL = new MomentDAL();

            DAL.ChnageStoryStatus(storyId);
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult UploadImage()
        {
            var parentId = Request.Form["id"];
            var storyId  = Request.Form["story"];

            var service = new MomentDAL();
            var id      = service.AddNewNode(new Node
            {
                CreationDate = DateTime.Now,
                Active       = true,
                CreatedBy    = Convert.ToInt32(Session["UserProfileId"]),
                ParentId     = Convert.ToInt32(parentId),
                StoryId      = Convert.ToInt32(storyId),
                Contents     = "Image Contents",
                Type         = "Image"
            });

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];
                var path = Path.Combine(Server.MapPath("~/App_Data/Images"), id + ".png");
                file.SaveAs(path);
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
        public ActionResult ViewStories()
        {
            MomentViewModel ViewModel = new MomentViewModel();
            MomentDAL       DAL       = new MomentDAL();

            ViewModel.GetAllStoriesList = DAL.GetStories(null, null, null, null);
            if (ViewModel.GetAllStoriesList != null && ViewModel.GetAllStoriesList.Any())
            {
                // ViewModel.GetAllStoriesList = ViewModel.GetAllStoriesList.Where(st => st.Id > 35).ToList();
            }
            return(View(ViewModel));
        }
예제 #6
0
        public ActionResult GetNetwrok(GetNetworkRequestModel request)
        {
            var service   = new MomentDAL();
            var dataModel = service.GetReporting(request);

            if (dataModel.Nodes.Any())
            {
                foreach (var item in dataModel.Nodes)
                {
                    item.image = GetImagePath(item.label, "X", item.id, ".png", Request, Server);
                }
            }
            return(Json(dataModel, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public ActionResult CreateStory1(string StoryId)
        {
            MomentViewModel ViewModel      = new MomentViewModel();
            MomentDAL       DAL            = new MomentDAL();
            int             StoryIdDynamic = 0;

            if (!string.IsNullOrEmpty(StoryId))
            {
                StoryIdDynamic     = Convert.ToInt32(StoryId);
                ViewModel.GetStory = DAL.GetStoryData(Convert.ToInt32(StoryId));
                ViewModel.Branches = DAL.GetStoryBranches(StoryId);
            }
            else
            {
            }

            ViewModel.StoriesNodeList = DAL.GetStoryNodes(StoryIdDynamic);
            return(View(ViewModel));
        }
예제 #8
0
        public ActionResult SearchStory(string searchStr)
        {
            MomentDAL DAL        = new MomentDAL();
            var       dataList   = new List <Sp_GetStories_Result>();
            var       allMoments = DAL.GetStories(null, null, null, null);

            if (allMoments.Any() && !string.IsNullOrEmpty(searchStr))
            {
                foreach (var item in allMoments)
                {
                    if (!string.IsNullOrEmpty(item.Name) && item.Name.ToLower().Contains(searchStr.ToLower()))
                    {
                        dataList.Add(item);
                    }
                }
                return(Json(dataList, JsonRequestBehavior.AllowGet));
            }
            return(Json(allMoments, JsonRequestBehavior.AllowGet));
        }
예제 #9
0
        public ActionResult SaveStoryNodes(List <StoriesNode> StoryNodesList)
        {
            List <StoriesNode> StoriesNodeList = new List <StoriesNode>();
            MomentDAL          DAL             = new MomentDAL();

            for (int i = 0; i < StoryNodesList.Count; i++)
            {
                StoriesNode StoriesNode = new StoriesNode();
                StoriesNode.LayerType     = StoryNodesList[i].LayerType;
                StoriesNode.Path          = StoryNodesList[i].Path;
                StoriesNode.CreatedBy     = Convert.ToInt32(Session["UserProfileId"]);
                StoriesNode.UserProfileId = Convert.ToInt32(Session["UserProfileId"]);
                StoriesNode.StoryId       = StoryNodesList[i].StoryId;

                StoriesNodeList.Add(StoriesNode);
            }

            int status = DAL.SaveStoryNodes(StoriesNodeList);

            return(RedirectToAction("Index"));
        }
예제 #10
0
        public ActionResult AddStory(Story story)
        {
            // string StoryName, string fileImage, bool Featured
            var  originalDirectory = new DirectoryInfo(string.Format("{0}Content\\Images\\StoryImages\\", Server.MapPath(@"\")));
            bool isExists          = System.IO.Directory.Exists(originalDirectory.ToString());

            if (!isExists)
            {
                System.IO.Directory.CreateDirectory(originalDirectory.ToString());
            }
            if (!string.IsNullOrEmpty(story.Path))
            {
                var    extention = story.Path.Split(',');
                string convert   = story.Path.Replace(extention[0] + ",", "");
                convert = convert.Replace('-', '+');
                convert = convert.Replace('_', '/');
                byte[] imageBytes = Convert.FromBase64String(convert);
                string fileName   = DateTime.Now.ToString("ddMMyyy") + Guid.NewGuid().ToString() + ".png";
                var    path       = Path.Combine(Server.MapPath("~/Content/Images/StoryImages"), fileName);
                // Convert byte[] to Image
                using (Image image = Image.FromStream(new MemoryStream(imageBytes)))
                {
                    image.Save(path, ImageFormat.Png);  // Or Png
                }
                story.Path = "/Content/Images/StoryImages/" + fileName;
            }
            Story     Story = new Story();
            MomentDAL DAL   = new MomentDAL();

            Story.Name       = story.Name;
            Story.Path       = story.Path;
            Story.CreatedBy  = Convert.ToInt32(Session["UserProfileId"]);
            Story.IsFeatured = false;
            Story.Status     = 1;

            int id = DAL.AddStory(Story);

            return(RedirectToAction("CreateStory", new { StoryId = id }));
        }
예제 #11
0
        public ActionResult ExportAsPdf(ExportNodesRequestModel model)
        {
            var list    = new List <NodeModel>();
            var service = new MomentDAL();
            var story   = service.GetStoryById(model.StoryId);

            model.Nodes.Reverse();
            foreach (var item in model.Nodes)
            {
                var obj = service.GetNodeById(item);
                if (obj != null)
                {
                    obj.image = Server.MapPath("~/App_Data/Images") + "/" + item + ".png";
                    list.Add(obj);
                }
            }

            PdfDocument pdf = new PdfDocument();

            pdf.Info.Title = "Moments - Data Export";

            foreach (var item in list)
            {
                if (item.type == "Text")
                {
                    int yPoint = 20;

                    PdfPage   pdfPage = pdf.AddPage();
                    XGraphics graph   = XGraphics.FromPdfPage(pdfPage);
                    XFont     font    = new XFont("Verdana", 12, XFontStyle.Regular);

                    var textPerLine = 90;
                    var startAt     = 0;
                    var text        = item.Contents;
                    var textcount   = text.Count();
                    var lineNumber  = 1;

                    while (true)
                    {
                        var TextToPrint = "";
                        if (startAt + textPerLine < textcount)
                        {
                            TextToPrint = text.Substring(startAt, textPerLine);
                            int textToReduce = 0;
                            while (!TextToPrint.EndsWith(" "))
                            {
                                TextToPrint  = TextToPrint.Substring(0, TextToPrint.Count() - 1);
                                textToReduce = textToReduce + 1;
                            }

                            startAt = startAt + textPerLine - textToReduce;
                        }
                        else
                        {
                            TextToPrint = text.Substring(startAt);
                            graph.DrawString(TextToPrint, font, XBrushes.Black, new XRect(30, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                            startAt = textcount;
                            break;
                        }

                        if (lineNumber % 42 == 0)
                        {
                            pdfPage = pdf.AddPage();
                            graph   = XGraphics.FromPdfPage(pdfPage);
                            yPoint  = 20;
                        }

                        graph.DrawString(TextToPrint, font, XBrushes.Black, new XRect(30, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                        yPoint = yPoint + 18;
                        lineNumber++;
                    }
                }
                else if (item.type == "Image")
                {
                    var imgPage = pdf.AddPage();
                    using (XImage img = XImage.FromFile(item.image))
                    {
                        var widht  = 600;
                        var height = (int)(((double)widht / (double)img.PixelWidth) * img.PixelHeight);
                        imgPage.Width  = widht;
                        imgPage.Height = height;
                        XGraphics gfx = XGraphics.FromPdfPage(imgPage);
                        gfx.DrawImage(img, 0, 0, widht, height);
                    }
                }
                else if (item.type == "Video")
                {
                    int       yPoint    = 60;
                    PdfPage   pdfPage   = pdf.AddPage();
                    XGraphics graph     = XGraphics.FromPdfPage(pdfPage);
                    XFont     font      = new XFont("Verdana", 12, XFontStyle.Regular);
                    var       text      = item.Contents;
                    var       textcount = text.Count();
                    var       contents  = item.Contents.Replace("embed/", "watch?v=");
                    graph.DrawString("YOUTUBE LINK (Click to open)", new XFont("Verdana", 12, XFontStyle.Regular), XBrushes.Black, new XRect(220, 20, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                    graph.DrawString(contents, font, XBrushes.Black, new XRect(30, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                }
                else if (item.type == "Audio")
                {
                    int       yPoint    = 60;
                    PdfPage   pdfPage   = pdf.AddPage();
                    XGraphics graph     = XGraphics.FromPdfPage(pdfPage);
                    XFont     font      = new XFont("Verdana", 7, XFontStyle.Regular);
                    var       text      = item.Contents;
                    var       textcount = text.Count();
                    graph.DrawString("SOUNDCLOUD LINK (Click to open)", new XFont("Verdana", 12, XFontStyle.Regular), XBrushes.Black, new XRect(220, 20, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                    graph.DrawString(item.Contents, font, XBrushes.Black, new XRect(30, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                }
            }
            var    filename    = story.Name + "_" + DateTime.Now.Second + ".pdf";
            string pdfFilename = Path.Combine(Server.MapPath("~/App_Data/Stories"), filename);

            pdf.Save(pdfFilename);
            return(Json(new { fileName = filename }, JsonRequestBehavior.AllowGet));
        }