Ejemplo n.º 1
0
        public PartialViewResult EditForm(string id, string eid)
        {
            Turgunda.Models.PortraitModel portrait = (Turgunda.Models.PortraitModel)this.Session["portrait"];
            portrait = new Turgunda.Models.PortraitModel(id);
            //portrait.Eid = eid;
            Turgunda.Models.RecordModel record = new RecordModel(); //new RecordModel(portrait, eid);
            record.eid = eid;
            record.SetPortrait(portrait);
            record.Load();
            record.id = id;

            //SetViewData();
            return PartialView("EditForm", record);
        }
Ejemplo n.º 2
0
        public PartialViewResult SetVariantNew(RecordModel rmodel)
        {
            string ss = rmodel.name_to_set;
            string prop = rmodel.prop_to_set;
            string eid = rmodel.eid;
            string ty = rmodel.type_to_set;
            string sysobj_id = Sema2012.Engine.CreateSysObject(ty, ss, User.Identity.Name);

            Turgunda.Models.PortraitModel portrait = new Turgunda.Models.PortraitModel(rmodel.id);
            rmodel.SetPortrait(portrait);

            if (sysobj_id != null)
            {
                DirectLink target = RecordModel.GetTarget(rmodel, prop);
                target.target_id = sysobj_id;
                target.target_name = ss;
                RecordModel.SetTarget(rmodel, prop, target);
            }

            return PartialView("EditForm", rmodel);
        }
Ejemplo n.º 3
0
        public PartialViewResult SetVariant(RecordModel rmodel)
        {
            //RecordModel rmodel = new RecordModel();
            Turgunda.Models.PortraitModel portrait = (Turgunda.Models.PortraitModel)this.Session["portrait"];
            if (true || portrait == null)
                portrait = new Turgunda.Models.PortraitModel(rmodel.id);
            rmodel.SetPortrait(portrait);

            string prop = rmodel.prop_to_set;
            DirectLink target = RecordModel.GetTarget(rmodel, prop);
            target.target_id = rmodel.id_to_set;
            target.target_name = rmodel.name_to_set;
            RecordModel.SetTarget(rmodel, prop, target);
            //SetViewData();
            return PartialView("EditForm", rmodel);
        }
Ejemplo n.º 4
0
        public ActionResult Portrait(string id, string yakor)
        {
            if (!StaticObjects.Initiated) StaticObjects.Init(Request.MapPath("~/"));

            VIPars pars = (VIPars)Session["VIPars"];
            string item_id = id;
            if (Request.Params["doc"] != null && pars != null)
            {
                item_id = Request.Params["doc"];
                pars.page_id = id;
                pars.collection_id = null;
            }

            Turgunda.Models.PortraitModel portrait = new Turgunda.Models.PortraitModel(item_id);
            if (portrait.Typ == "") return RedirectToAction("Index");
            //Turgunda.Engine.connection_counter += 0;
            //Turgunda.Engine.message += "[" + Turgunda.Engine.connection_counter + "]";

            portrait.yakor = yakor;

            Podval(pars);

            return View("Portrait", portrait);
        }
Ejemplo n.º 5
0
        public PartialViewResult EditForm(/*string lang, */RecordModel rmodel)
        {
            var ok = rmodel.ok;
            var cancel = rmodel.cancel;
            var chk = rmodel.chk;
            var chlang = rmodel.l;

            Turgunda.Models.PortraitModel portrait = (Turgunda.Models.PortraitModel)this.Session["portrait"];
            if (true || portrait == null)
                portrait = new Turgunda.Models.PortraitModel(rmodel.id);
            rmodel.SetPortrait(portrait);

            if (chlang != null)
            {
                rmodel.lang = rmodel.lang == "ru" ? "en" : "ru";
                return PartialView("EditForm", rmodel);
            }

            if (cancel != null)
            {
                return PartialView("RecordView", rmodel);
            }
            if (ok != null)
            {
                // Если фиксация результата, то надо обратиться к сервису изменений, а также перевычислить
                // и переприсвоить портрет
                XElement rec = rmodel.MakeRecord();
                Sema2012.Engine.ReplaceRecord(rec, User.Identity.Name);
                //? if (dc == null) dc = new DbCreation(Engine.connectionstring, Engine._configuration);
                //? dc.SaveRecord(rmodel, User.Identity.Name);
                portrait = new Turgunda.Models.PortraitModel(rmodel.id);
                //Session["portrait"] = portrait;
                rmodel.SetPortrait(portrait);
                return PartialView("RecordView", rmodel);
            }

            // chk: Проверка. Для всех прямых ссылок нужно зафиксировать ситуацию, когда
            // идентификатор цели не установлен, но есть образец для просмотра, тогда в модель надо
            // "толкнуть" варианты, подходящие под образец
            foreach (var dir_format in rmodel.xformat.Elements("direct"))
            {
                string prop = dir_format.Attribute("prop").Value;
                DirectLink target = RecordModel.GetTarget(rmodel, prop);
                if (target.target_id != null || target.target_name == null) continue;
                string type = target.target_type ?? "person";
                var searchresults = new Turgunda.Models.SearchModel(target.target_name, type);
                target.target_list = searchresults.SearchResults
                    .Select(res => new DirectLink { target_id = res.Attribute("id").Value, target_name = res.Value })
                    .ToList();
                RecordModel.SetTarget(rmodel, prop, target);
            }
            //SetViewData();
            return PartialView("EditForm", rmodel);
        }
Ejemplo n.º 6
0
 public void SetPortrait(PortraitModel value)
 {
     _portrait = value;
     if (id == null) id = _portrait.Id;
     if (eid == null) eid = _portrait.Eid;
     // Временное решение - редактируется главная запись
     xrecord = _portrait.PortraitResult;
     xformat = _portrait.RecFormat;
     if (eid != id)
     {
         // Сначала выявим отношение, по которому "цепляется" таблица
         XElement rec = _portrait.PortraitResult.Elements("inverse").Elements("record")
             .Where(re => re.Attribute("id").Value == eid)
             .FirstOrDefault();
         string iprop_id = rec.Parent.Attribute("prop").Value;
         string rec_type = rec.Attribute("type").Value;
         xrecord = rec;
         xformat = xformat.Elements("inverse").First(i => i.Attribute("prop").Value == iprop_id)
             .Elements("record").First(r => r.Attribute("type").Value == rec_type);
     }
     //if (!_loaded) { Load(xrecord, xformat); _loaded = true; }
 }