Exemple #1
0
 // GET: Map
 public ActionResult Index(string id)
 {
     if (!string.IsNullOrEmpty(id))
     {
         var mId = new ObjectId(id);
         var map = _mapManager.GetMapById(mId);
         if (map != null)
         {
             var  userId      = User.Identity.GetUserId();
             bool isFollowing = map.Followers.Contains(new ObjectId(userId), new IDComparer());
             ViewBag.isFollowing = isFollowing;
             MapPermissionController mpc = new MapPermissionController();
             MapViewModel            mvm = new MapViewModel {
                 Id = map.Id, Name = map.Name, CreationTime = map.CreationTime, CreatorId = map.Creator, CreatorEmail = UserManager.GetEmail(map.Creator.ToString()), Description = map.Description, Model = map.Model, ModelArchive = map.MapsArchive
             };
             if (mpc.IsMapOwner(id, User.Identity.GetUserId()))
             {
                 return(View(mvm));
             }
             else
             {
                 return(View(mvm));
             }
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
Exemple #2
0
        public ActionResult LaunchMap5_test(string id)
        {
            if (id != null && !_mapManager.IsMapExist(new ObjectId(id)))
            {
                return(RedirectToAction("index", "Home"));
            }

            if (id != null)
            {
                var userId = User.Identity.GetUserId();
                MapPermissionController mpc = new MapPermissionController();
                MapPermissionType       userPermissionsAsUser  = mpc.GetUserPermissionToMapAsUser(id, userId);
                MapPermissionType       userPermissionsByGroup = mpc.GetUserPermissionToMapByGroup(id, userId);
                MapPermissionType       userPermissions        = MapPermissionType.NA;

                if (userPermissionsAsUser == MapPermissionType.RW || userPermissionsByGroup == MapPermissionType.RW)
                {
                    userPermissions = MapPermissionType.RW;
                }
                else if (userPermissionsAsUser == MapPermissionType.RO || userPermissionsByGroup == MapPermissionType.RO)
                {
                    userPermissions = MapPermissionType.RO;
                }
                else
                {
                    return(RedirectToAction("index", "Home"));
                }

                ViewBag.userPermission = userPermissions;

                var map = _mapManager.GetMapById(new ObjectId(id));
                ViewBag.isSaved = true;
                ViewBag.myMap   = map.Model.ToJson().ToString();

                //var refIDs = GetReferencesIDsFromMapModel(map.Model.ToJson());
                //var refsDict = GetReferencesFromIDs(refIDs);
                //ViewBag.refs = refsDict;
                //string t = map.Model.ToJson().ToString();
                //ViewBag.myMap = JsonConvert.SerializeObject(map.Model.ToJson());
                return(View(map));
            }
            else
            {
                ViewBag.userPermission = MapPermissionType.RW;
                ViewBag.isSaved        = false;
                var map = new Map {
                    Name = "(Unsaved File)", Model = null
                };
                ViewBag.myMap = "{}".ToJson().ToString();
                return(View(map));
            }
        }
Exemple #3
0
        public ActionResult LaunchMap5(string id, string currentFolderID, string searchedWord)
        {
            ViewBag.res             = null;
            _currentFolderID        = currentFolderID;
            ViewBag.currentFolderID = currentFolderID;
            if (id != null && !_mapManager.IsMapExist(new ObjectId(id)))
            {
                return(RedirectToAction("index", "Home"));
            }

            if (id != null)
            {
                var userId = User.Identity.GetUserId();
                MapPermissionController mpc = new MapPermissionController();
                MapPermissionType       userPermissionsAsUser  = mpc.GetUserPermissionToMapAsUser(id, userId);
                MapPermissionType       userPermissionsByGroup = mpc.GetUserPermissionToMapByGroup(id, userId);
                MapPermissionType       userPermissions        = MapPermissionType.NA;

                if (userPermissionsAsUser == MapPermissionType.RW || userPermissionsByGroup == MapPermissionType.RW)
                {
                    userPermissions = MapPermissionType.RW;
                }
                else if (userPermissionsAsUser == MapPermissionType.RO || userPermissionsByGroup == MapPermissionType.RO)
                {
                    userPermissions = MapPermissionType.RO;
                }
                else
                {
                    return(RedirectToAction("index", "Home"));
                }

                ViewBag.userPermission = userPermissions;

                var map   = _mapManager.GetMapById(new ObjectId(id));
                int count = 0;
                /////centering searched word if exists
                if (searchedWord != null && !searchedWord.Equals(""))
                {
                    var nodes = map.Model["nodeDataArray"];
                    foreach (var node in nodes.AsBsonArray)
                    {
                        string nodeText = node["text"].ToString();
                        if (nodeText.Contains(searchedWord))
                        {
                            _mapManager.UpdateMap(map);

                            double nodeP1 = 0;
                            double nodeP2 = 0;
                            var    links  = map.Model["linkDataArray"];
                            foreach (var link in links.AsBsonArray)
                            {
                                link["points"] = "";
                            }
                            if (count == 0)
                            {
                                node["loc"] = "";
                                count++;
                            }
                            //node["fill"] = "#FFFF00";
                        }
                    }
                }

                ViewBag.isSaved = true;
                ViewBag.myMap   = map.Model.ToJson().ToString();

                //var refIDs = GetReferencesIDsFromMapModel(map.Model.ToJson());
                //var refsDict = GetReferencesFromIDs(refIDs);
                //ViewBag.refs = refsDict;
                //string t = map.Model.ToJson().ToString();
                //ViewBag.myMap = JsonConvert.SerializeObject(map.Model.ToJson());
                return(View(map));
            }
            else
            {
                ViewBag.userPermission = MapPermissionType.RW;
                ViewBag.isSaved        = false;
                var map = new Map {
                    Name = "(Unsaved File)", Model = null
                };
                ViewBag.myMap = "{}".ToJson().ToString();
                return(View(map));
            }
        }