示例#1
0
        public static string GetFormat(string id, out XElement rec_format)
        {
            string type_id;
            // Нам нужен формат.
            XElement f_primitive = new XElement("record");
            XElement xtree0      = SObjects.GetItemById(id, f_primitive);

            // Проверка на существование решения или формата
            if (xtree0 == null || xtree0.Attribute("id") == null || xtree0.Attribute("type") == null)
            {
                rec_format = null; return(null);
            }
            ;                                                                                                                            // Как-то надо поступить с диагностикой ошибок//
            type_id = xtree0.Attribute("type").Value;
            // Теперь установим нужный формат
            XElement xformat = ModelCommon.formats.Elements("record")
                               .FirstOrDefault(re => re.Attribute("type") != null && re.Attribute("type").Value == type_id);

            if (xformat == null)
            {
                xformat = new XElement("record",
                                       new XAttribute("type", type_id),
                                       new XElement("field", new XAttribute("prop", "http://fogid.net/o/name")));
            }
            rec_format = xformat;
            return(type_id);
        }
示例#2
0
        public PhysicalFileResult GetAudio(string u)
        {
            string audio_extension = "mp3";
            string filename        = SObjects.GetAudioFileName(u);

            return(new PhysicalFileResult(filename, "audio/" + audio_extension));
        }
示例#3
0
        //public FilePathResult GetVideo(string u, string ext)
        //{
        //    string filename = "question.jpg";
        //    string video_extension = ext;
        //    filename = SObjects.storage.GetVideoFileName(u) + "." + ext;
        //    return new FilePathResult(filename, "video/" + video_extension);
        //}
        //public FilePathResult GetAudio(string u)
        //{
        //    string audio_extension = "mp3";
        //    string filename = SObjects.storage.GetAudioFileName(u);

        //    return new FilePathResult(filename, "audio/" + audio_extension);
        //}
        public PhysicalFileResult GetVideo(string u, string ext)
        {
            string filename        = "question.jpg";
            string video_extension = ext;

            filename = SObjects.GetVideoFileName(u) + "." + ext;
            return(new PhysicalFileResult(filename, "video/" + video_extension));
        }
        public ActionResult AddUpdate(XElement record)
        {
            XElement res = SObjects.AddUpdate(record);

            return(new ContentResult {
                ContentType = "text/xml", Content = res.ToString()
            });
        }
        public ActionResult GetItemById(string id, string format)
        {
            XElement res = SObjects.GetItemById(id, XElement.Parse(format));

            return(new ContentResult {
                ContentType = "text/xml", Content = res.ToString(SaveOptions.DisableFormatting)
            });
        }
        public ActionResult Delete(string id)
        {
            XElement res = SObjects.Delete(id);

            return(new ContentResult {
                ContentType = "text/xml", Content = res.ToString()
            });
        }
        public ActionResult GetItemByIdBasic(string id, bool addinverse)
        {
            XElement res = SObjects.GetItemByIdBasic(id, addinverse);

            return(new ContentResult {
                ContentType = "text/xml", Content = res.ToString()
            });
        }
        public ActionResult GetItemByIdSpecial(string id)
        {
            XElement res = SObjects.GetItemByIdSpecial(id);

            return(new ContentResult {
                ContentType = "text/xml", Content = res.ToString()
            });
        }
        public ActionResult GetPhoto(string u, string s)
        {
            string filename = "/question.jpg";

            filename = SObjects.GetPhotoFileName(u, s) + ".jpg";
            //return new FilePathResult(filename, "image/jpeg");
            return(new PhysicalFileResult(filename, "image/jpeg"));
        }
示例#10
0
 public XElement CalculateFormat()
 {
     _format = SObjects.GetEditFormat(etype, iprop);
     if (_format == null)
     {
         _format = new XElement("record", new XAttribute("type", etype));
     }
     return(_format);
 }
示例#11
0
        public ActionResult SearchByName(string ss)
        {
            string   name = ss;
            XElement res  = new XElement("sequense", SObjects.SearchByName(name));

            return(new ContentResult {
                ContentType = "text/xml", Content = res.ToString()
            });
        }
 public IActionResult Init()
 {
     if (OAData.OADB.initiated)
     {
         OAData.OADB.Close();
     }
     OAData.OADB.configfilename = "config.xml";
     SObjects.Init();
     return(Redirect("~/Home/Index"));
 }
示例#13
0
        public SearchModel(string searchstring, string type)
        {
            DateTime tt0 = DateTime.Now;

            if (searchstring == null)
            {
                searchstring = "";
            }
            this.searchstring = searchstring;
            //type = "http://fogid.net/o/person"; // для отладки
            this.type = type;
            //if (string.IsNullOrEmpty(searchstring)) { _results = new SearchResult[0]; return; }
            var query = SObjects.SearchByName(searchstring)
                        .Select(xres =>
            {
                XElement name_el = xres
                                   .Elements("field").Where(f => f.Attribute("prop").Value == "http://fogid.net/o/name")
                                   .OrderByDescending(n => n.Attribute(ONames.xmllang) == null ? "ru" : n.Attribute(ONames.xmllang).Value)
                                   .FirstOrDefault();
                string name      = name_el == null ? "noname" : name_el.Value;
                SearchResult res = new SearchResult()
                {
                    id = xres.Attribute("id").Value, value = name
                };
                XAttribute t_att = xres.Attribute("type");
                if (t_att != null)
                {
                    res.type = t_att.Value;
                }
                string tname = "";
                if (!string.IsNullOrEmpty(res.type))
                {
                    ModelCommon.OntNames.TryGetValue(res.type, out tname);
                }
                res.type_name = tname;
                return(res);
            });

            if (this.type != null)
            {
                query = query.Where(res => res.type == this.type);
            }
            _results = query
                       .OrderBy(s => s.value)
                       .ToArray();
            timespan = DateTime.Now - tt0;
            message  = "duration=" + (timespan.Ticks / 10000L);
        }
        public async Task <Dictionary <string, string> > RetrieveSObjects(AuthenticationResponse Auth)
        {
            try {
                HttpRequestMessage RetrieveSObjects =
                    new HttpRequestMessage(HttpMethod.Get, Auth.instance_url + "/services/data/v45.0/sobjects/");
                RetrieveSObjects.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Auth.access_token);
                HttpResponseMessage RetrieveSObjectsResponse =
                    await httpClient.SendAsync(RetrieveSObjects);

                SObjects SObjectsPayload = JsonConvert.DeserializeObject <SObjects> (
                    await RetrieveSObjectsResponse.Content.ReadAsStringAsync());
                return(this.GeneratePrefixList(SObjectsPayload.Sobjects));
            } catch (Exception ex) {
                throw ex;
            }
        }
示例#15
0
        public IActionResult Portrait(string id, string eid) // eid (external id) - ид айтема, в котором есть список, в котором есть id
        {
            DateTime tt0 = DateTime.Now;

            //string id = Request.Query["id"];//.Params["id"];
            if (string.IsNullOrEmpty(id))
            {
                return(new RedirectResult("~/Home/Index"));
            }

            XElement special = SObjects.GetItemByIdBasic(id, false);

            if (special == null || special.Attribute("type") == null)
            {
                return(new RedirectResult("~/Home/Index"));
            }
            string type = special.Attribute("type").Value;

            if (type == "http://fogid.net/o/person")
            {
                return(View("PortraitPerson", new PortraitPersonModel(id)));
            }
            else if (type == "http://fogid.net/o/collection")
            {
                return(View("PortraitCollection", new PortraitCollectionModel(id)));
            }
            else if (type == "http://fogid.net/o/org-sys")
            {
                return(View("PortraitOrg", new PortraitOrgModel(id)));
            }
            else if (type == "http://fogid.net/o/document" || type == "http://fogid.net/o/photo-doc")
            {
                return(View("PortraitDocument", new PortraitDocumentModel(id, eid)));
            }
            else if (type == "http://fogid.net/o/city" || type == "http://fogid.net/o/country")
            {
                return(View("PortraitGeo", new PortraitGeoModel(id)));
            }
            else
            {
                //@RenderPage("PortraitAny.cshtml", new { id = id, type = type })
            }

            return(View());
        }
        public IActionResult Load(int nom)
        {
            if (OAData.OADB.initiated)
            {
                OAData.OADB.Close();
            }
            if (nom == 1)
            {
                OAData.OADB.configfilename = "config1.xml";
            }
            else
            {
                OAData.OADB.configfilename = "config.xml";
            }
            SObjects.Init();
            OAData.OADB.Load();

            return(Redirect("~/Home/Index"));
        }
示例#17
0
        public ActionResult GetPhoto(string u, string s)
        {
            string filename = "/question.jpg";

            if (SObjects.OADataUri != null)
            {
                return(Redirect(SObjects.OADataUri + $"docs/GetPhoto?u={u}&s={s}"));
            }
            else
            {
                filename = SObjects.GetPhotoFileName(u, s) + ".jpg";
                if (s == "normal" && !System.IO.File.Exists(filename))
                {
                    filename = SObjects.GetPhotoFileName(u, "medium") + ".jpg";
                }
                //return new FilePathResult(filename, "image/jpeg");
                return(new PhysicalFileResult(filename, "image/jpeg"));
            }
        }
示例#18
0
        public PortraitSpecialModel(string id)
        {
            DateTime tt0    = DateTime.Now;
            XElement record = SObjects.GetItemByIdSpecial(id);

            if (record == null)
            {
                return;
            }
            this.id = record.Attribute("id").Value;
            string type_id = record.Attribute("type") == null ? "notype" : record.Attribute("type").Value;

            this.type_id = type_id;
            this.type    = ModelCommon.OntNames.Where(pair => pair.Key == type_id).Select(pair => pair.Value).FirstOrDefault();
            if (this.type == null)
            {
                this.type = type_id;
            }
            var name_el = record.Elements("field").Where(f => f.Attribute("prop").Value == "http://fogid.net/o/name")
                          .FirstOrDefault();

            this.name = name_el == null ? "noname" : name_el.Value;
            farr      = record.Elements("field")
                        .Select(el => new Field()
            {
                prop = el.Attribute("prop").Value, value = el.Value, lang = el.Attribute(ONames.xmllang)?.Value
            })
                        .ToArray();
            darr = record.Elements("direct")
                   .Select(el => new Direct()
            {
                prop = el.Attribute("prop").Value, resource = el.Element("record").Attribute("id").Value
            })
                   .ToArray();
            iarr = record.Elements("inverse")
                   .Select(el => new Inverse()
            {
                prop = el.Attribute("prop").Value, about = el.Element("record").Attribute("id").Value
            })
                   .ToArray();
            duration = DateTime.Now - tt0;
        }
示例#19
0
        public ActionResult Registration(string uuser, string pass1, string pass2)
        {
            Turgunda7.Models.UserModel umodel = new Models.UserModel(this.Request);
            //umodel.ActivateUserMode(this.Response, uuser);
            if (!string.IsNullOrEmpty(pass1) &&
                pass1 == pass2 &&
                SObjects.accounts.Elements("account").All(a => a.Attribute("login").Value != uuser)
                )
            {
                XElement account =
                    new XElement("account",
                                 new XAttribute("login", uuser), new XAttribute("pass", pass1),
                                 new XElement("role", "user"),
                                 SObjects.accounts.Elements("account").Count() == 0 ? new XElement("role", "admin") : null);
                SObjects.accounts.Add(account);
                SObjects.AccountsSave();
                return(RedirectToAction("Logon", "Account"));
            }

            return(View());
        }
示例#20
0
 public void Save()
 {
     SObjects.SaveAccounts();
 }
示例#21
0
        // По идентификатору мы получаем 1) откорректированный идентификатор; 2) тип записи; 3) формат (раскрытия) записи
        // Эту информацию дополняем меткой типа, пытаемся прочитать и зафиксировать имя записи и uri документного контента
        public PortraitModel(string id, XElement rec_format)
        {
            DateTime tt0 = DateTime.Now;

            //XElement rec_format;
            if (rec_format == null)
            {
                this.type_id = GetFormat(id, out rec_format);
                if (rec_format == null)
                {
                    ok = false; return;
                }
            }
            else
            {
                this.type_id = rec_format.Attribute("type").Value;
            }

            this.typelabel = ModelCommon.OntNames.Where(pair => pair.Key == type_id).Select(pair => pair.Value).FirstOrDefault();
            if (this.typelabel == null)
            {
                this.typelabel = type_id;
            }
            // Получим портретное х-дерево
            this.xtree = SObjects.GetItemById(id, rec_format);
            if (this.xtree == null)
            {
                return;
            }
            // По дереву вычислим и зафиксируем остальные поля
            // поле идентификатора
            this.id = xtree.Attribute("id").Value;
            // поле имени
            XElement field_name = xtree.Elements("field")
                                  .Where(fi => fi.Attribute("prop").Value == "http://fogid.net/o/name")
                                  .OrderBy(fi => {
                XAttribute lang_att = fi.Attribute(ONames.xmllang);
                return(lang_att == null ? "" : lang_att.Value);
            })
                                  .FirstOrDefault();

            this.name = field_name == null ? "Noname" : field_name.Value;
            // поле uri
            if (type_id == "http://fogid.net/o/photo-doc" || type_id == "http://fogid.net/o/video-doc" || type_id == "http://fogid.net/o/audio-doc")
            {
                //var uri_el = GetUri(xtree);
                var uri_el = xtree.Elements("field")
                             .FirstOrDefault(fi => fi.Attribute("prop").Value == "http://fogid.net/o/uri");
                if (uri_el != null)
                {
                    uri = uri_el.Value;
                }
            }

            // ============================== Вычисления частей вышестоящего документа ============================
            if (type_id == "http://fogid.net/o/document" || type_id == "http://fogid.net/o/photo-doc" || type_id == "http://fogid.net/o/video-doc" || type_id == "http://fogid.net/o/audio-doc")
            {
                string mpDocId = xtree.Elements("inverse").FirstOrDefault(i => i.Attribute("prop").Value == "http://fogid.net/o/partItem")?
                                 .Element("record")?
                                 .Elements("direct").FirstOrDefault(i => i.Attribute("prop").Value == "http://fogid.net/o/inDocument")?
                                 .Element("record")?
                                 .Attribute("id")?.Value;
                XElement formatfordoc = new XElement("record", new XAttribute("type", "http://fogid.net/o/document"),
                                                     // Части документа
                                                     new XElement("inverse", new XAttribute("prop", "http://fogid.net/o/inDocument"),
                                                                  new XElement("record",
                                                                               new XElement("field", new XAttribute("prop", "http://fogid.net/o/pageNumbers")),
                                                                               new XElement("direct", new XAttribute("prop", "http://fogid.net/o/partItem"),
                                                                                            new XElement("record",
                                                                                                         new XElement("field", new XAttribute("prop", "http://fogid.net/o/name")))))));
                if (mpDocId != null)
                {
                    string[] doclist =             // Части документа
                                       SObjects.GetItemById(mpDocId, formatfordoc).Elements("inverse")
                                       .Where(inv => inv.Attribute("prop").Value == "http://fogid.net/o/inDocument")
                                       .Select(inv => inv.Element("record"))
                                       .Select(rec => new
                    {
                        docpart = rec.Element("direct")?.Element("record"),
                        page    = rec.Elements("field").FirstOrDefault(f => f.Attribute("prop").Value == "http://fogid.net/o/pageNumbers")?.Value
                    })
                                       .OrderBy(pair => pair.page)
                                       .ThenBy(pair => pair.docpart.Elements("field").FirstOrDefault(f => f.Attribute("prop").Value == "http://fogid.net/o/name")?.Value)
                                       .Select(pair => pair.docpart.Attribute("id").Value)
                                       .ToArray();
                    int ind = Array.IndexOf(doclist, id);
                    if (ind > 0)
                    {
                        prev = doclist[ind - 1];
                    }
                    if (ind < doclist.Length - 1)
                    {
                        next = doclist[ind + 1];
                    }
                }
            }
            this.xresult = ConvertToResultStructure(rec_format, xtree);
            //this.look = xtree;

            this.message = "duration=" + ((DateTime.Now - tt0).Ticks / 10000L);
            //this.look = xresult;
        }
示例#22
0
 public void LoadFromDb()
 {
     CalculateFormat();
     _xtree = SObjects.GetItemById(eid, _format);
 }