Exemplo n.º 1
0
        public ActionResult SetDatabase(baseData vData, int databaseId)
        {
            Response.Cookies["dbId"].Value   = databaseId.ToString();
            Response.Cookies["dbId"].Expires = DateTime.MaxValue;

            return(RedirectToAction("Index", "policy"));
        }
Exemplo n.º 2
0
        public ActionResult Import(baseData vData, FormCollection collection)
        {
            if (Request.Files.Count > 0)
            {
                // Save the uploaded file.
                string path       = string.Format("~/imports/{0}.xml", Path.GetRandomFileName());
                string mappedPath = Server.MapPath(path);

                Request.Files[0].SaveAs(mappedPath);

                try
                {
                    string title = Path.GetFileName(Request.Files[0].FileName);
                    if (Path.GetExtension(title) == ".xml" || Path.GetExtension(title) == ".conf")
                    {
                        title = Path.GetFileNameWithoutExtension(title);
                    }

                    PolicyDocumentEntity pde = importFile(vData, title, mappedPath);

                    return(RedirectToAction("EditPolicyDoc", "policy", new { id = pde.Id }));
                }
                catch (Exception ex)
                {
                    TempData["error"] = ex.Message;
                }
            }
            else
            {
                TempData["message"] = "select a file to upload";
            }

            return(RedirectToAction("Index", "policy"));
        }
Exemplo n.º 3
0
        public ActionResult ImportBondiSVN(baseData vData)
        {
            try
            {
                policyController.DeleteEntireLibrary(vData.Library.Id);
                importFolder(vData);
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }

            return(RedirectToAction("Index", "policy"));
        }
Exemplo n.º 4
0
        public ActionResult DeleteDatabase(baseData vData, int id)
        {
            vData.Library = new LibraryEntity(id);
            try
            {
                policyController.DeleteEntireLibrary(id, true);
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
            }

            Response.Cookies["dbId"].Value = string.Empty;

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 5
0
        public ActionResult Index(baseData vData, int?id)
        {
            if (id.HasValue)
            {
                vData.Library = new LibraryEntity(id.Value);
            }

            LibraryCollection lcoll = new LibraryCollection();

            lcoll.GetMulti(null);

            object selObj = vData.Library == null ? null : (object)vData.Library.Id;

            ViewData["databases"] = new SelectList(lcoll, "Id", "Name", selObj);

            return(View(vData));
        }
Exemplo n.º 6
0
        private PolicyDocumentEntity importFile(baseData vData, string title, string filepath)
        {
            AttributeCollection acoll = new AttributeCollection();

            acoll.GetMulti(AttributeFields.Name == "Literal");
            if (acoll.Count == 0)
            {
                throw new Exception("can't find literal attribute");
            }
            m_literalAttribute = acoll[0];

            XmlDocument doc = new XmlDocument();

            doc.Load(filepath);

            PolicyDocumentEntity pde = new PolicyDocumentEntity();

            pde.LibraryId = vData.Library.Id;
            pde.Name      = title;

            PolicyLinkEntity ple = new PolicyLinkEntity();

            ple.Policy           = new PolicyEntity();
            ple.Policy.LibraryId = pde.LibraryId;
            pde.PolicyLink       = ple;

            XmlNode policySet = doc.SelectSingleNode("policy-set");

            if (policySet != null)
            {
                loadPolicySet(1, title, ple, policySet);
            }
            else
            {
                XmlNode policy = doc.SelectSingleNode("policy");
                loadPolicy(1, title, ple, policy);
            }

            pde.Save(true);

            return(pde);
        }
Exemplo n.º 7
0
        public ActionResult EditDatabase(baseData vData, int id, FormCollection collection)
        {
            vData.Library = new LibraryEntity(id);
            bool isNew = vData.Library.IsNew;

            vData.Library.Name = Server.HtmlEncode(collection["Name"].ToString());
            vData.Library.Save();

            Response.Cookies["dbId"].Value   = vData.Library.Id.ToString();
            Response.Cookies["dbId"].Expires = DateTime.MaxValue;

            TempData["message"] = policyData.detailsSaved;

            if (isNew)
            {
                return(RedirectToAction("Index", "policy"));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 8
0
        private void importFolder(baseData vData)
        {
            string importFrom = Server.MapPath("~/bondiSVN");

            LibraryEntity li = vData.Library;

            li.Name = string.Format("Bondi SVN import at {0}", DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss"));
            li.Save();

            DirectoryInfo di = new DirectoryInfo(importFrom);

            FileInfo[] files = di.GetFiles("*.*");

            foreach (FileInfo fi in files)
            {
                try
                {
                    importFile(vData, fi.Name, fi.FullName);
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemplo n.º 9
0
        public ActionResult CreateDatabase(baseData vData)
        {
            Response.Cookies["dbId"].Value = "0";

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 10
0
        public ActionResult SelectDatabase(baseData vData)
        {
            Response.Cookies["dbId"].Value = string.Empty;

            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 11
0
 public ActionResult TimedOut(baseData vData)
 {
     TempData["message"] = "session timed out";
     return(RedirectToAction("Index"));
 }
Exemplo n.º 12
0
        //
        // GET: /import/

        public ActionResult Index(baseData vData)
        {
            return(View());
        }