コード例 #1
0
ファイル: ArchModels.cs プロジェクト: agmarchuk/Turgunda
        public ArchModels(VIPars pars)
        {
            if (pars != null) _collection_list = new XElement[0];
            if (pars == null || (pars.collection_id == null && pars.page_id == null)) return;
            if (pars.page_id != null && pars.collection_id == null && pars.root_collection_id != null)
            {
                string found_coll_id = LookForPage(pars.root_collection_id, pars.page_id);
                if (found_coll_id != null)
                {
                    pars.collection_id = found_coll_id;
                }
            }
            if (pars.collection_id != null) _xcollection = Sema2012.Engine.GetRecordById(pars.collection_id,
                new XElement("record", new XAttribute("type", "collection"),
                    new XElement("field", new XAttribute("prop", "name")),
                    new XElement("inverse", new XAttribute("prop", "in-collection"),
                        new XElement("record", new XAttribute("type", "collection-member"),
                            new XElement("direct", new XAttribute("prop", "collection-item"),
                                new XElement("record", //new XAttribute("type", "photo-doc"),
                                    new XElement("field", new XAttribute("prop", "name")),
                                    new XElement("inverse", new XAttribute("prop", "forDocument"),
                                        new XElement("record", new XAttribute("type", "FileStore"),
                                            new XElement("field", new XAttribute("prop", "uri")))),
                                    new XElement("inverse", new XAttribute("prop", "partItem"),
                                        new XElement("record", // new XAttribute("type", "DocumentPart"),
                                            new XElement("direct", new XAttribute("prop", "inDocument"),
                                                new XElement("record", // new XAttribute("type", "document" or MultiPartDocument),
                                                    null)))))))))
                );
            else return;

            if (_xcollection != null)
                _collection_list = _xcollection.Elements("inverse")
                    .Where(i => i.Element("record") != null && i.Element("record").Element("direct") != null &&
                        i.Element("record").Element("direct").Element("record") != null)
                    .Select(i => i.Element("record").Element("direct").Element("record"))
                    .Where(r => {string type = r.Attribute("type").Value; return type == "photo-doc" || type == "collection";})
                    .ToArray();
            if (pars.page_id != null && _xcollection != null)
            {
                var qu = _collection_list.Select((el, ind) => new { element = el, index = ind })
                    .FirstOrDefault(ei => ei.element.Attribute("id").Value == pars.page_id);
                if (qu != null)
                {
                    _page_id = pars.page_id;
                    _page_ind = qu.index;
                    var pi = qu.element.Elements("inverse").Where(i => i.Attribute("prop").Value == "partItem").FirstOrDefault();
                    if (pi != null)
                    {
                        _doc_of_page = pi.Element("record").Element("direct").Element("record").Attribute("id").Value;
                    }
                }
            }
            //_theme_mpd_connection = pars.theme_mpd_connection;
            //_mpd_page_connection = pars.mpd_page_connection;
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: agmarchuk/Turgunda
        public PartialViewResult ArchiveSearchInCollection(string searchstring)
        {
            if (!StaticObjects.Initiated) StaticObjects.Init(Request.MapPath("~/"));
            VIPars pars = (VIPars)Session["VIPars"];
            if (pars == null)
            {
                // cassetterootcollection P1_1001
                pars = new VIPars() { collection_id = "P1_cassetteId" };
            }
            Session["VIPars"] = pars;
            ArchModels am = new ArchModels(pars);

            ViewData["searchresults"] = am.CList.Where(r =>
            {
                var nameEl = r.Elements("field").FirstOrDefault(f => f.Attribute("prop").Value == "name");
                return nameEl != null && nameEl.Value.EndsWith(searchstring);
            }).ToArray();
            return PartialView();
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: agmarchuk/Turgunda
        //public ActionResult ViewArchive()
        //{
        //    if (!StaticObjects.Initiated) StaticObjects.Init(Request.MapPath("~/"));
        //    VIPars pars = (VIPars)Session["VIPars"];
        //    if (pars == null)
        //    {
        //        // cassetterootcollection P1_1001
        //        pars = new VIPars() { collection_id = "P1_cassetteId" };
        //    }
        //    string co = Request.Params["co"];
        //    if (co != null) { pars.collection_id = co; pars.page_id = null; }
        //    string pg = Request.Params["pg"];
        //    if (pg != null) { pars.page_id = pg; }
        //    string mp = Request.Params["mp"];
        //    if (mp != null) { pars.mpd_id = mp; }
        //    Session["VIPars"] = pars;
        //    ArchModels am = new ArchModels(pars);
        //    return View("ViewArch", am);
        //}
        private void Podval(VIPars pars)
        {
            if (pars == null)
            {
                string cid = null;
                try
                {
                    var dirs = Sema2012.Engine.SearchByName(User.Identity.Name + "_directory", "collection", false).ToArray();
                    if (dirs.Length > 0) cid = dirs[0].Attribute("id").Value;
                    else return;
                }
                catch (Exception) { return; }
                pars = new VIPars() { collection_id = cid, root_collection_id = cid };
            }
            string co = Request.Params["co"];
            if (co != null) { pars.collection_id = co; pars.page_id = null; }
            string pg = Request.Params["pg"];
            if (pg != null)
            {
                if (pg == "up") pars.page_id = pars.collection_id;
                else if (pg == "beg")
                {
                    string cid = null;
                    try
                    {
                        var dirs = Sema2012.Engine.SearchByName(User.Identity.Name + "_directory", "collection", false).ToArray();
                        if (dirs.Length > 0) cid = dirs[0].Attribute("id").Value;
                        else return;
                    }
                    catch (Exception) { return; }
                    pars = new VIPars() { collection_id = cid, root_collection_id = cid };
                }
                else pars.page_id = pg;
            }
            //string mp = Request.Params["mp"];
            //if (mp != null) { pars.mpd_id = mp; }

            Session["VIPars"] = pars;
            var AM = new ArchModels(pars);
            ViewData["ArchModels"] = AM;
        }