Example #1
0
 ABaseObject _createApiObject(IPBaseObject obj)
 {
     if (obj != null)
         return new ABaseObject()
         {
             Id = obj.Id,
             platformObject = obj
         };
     else
         return null;
 }
Example #2
0
 public string GetTemplateName(IPBaseObject obj, string attrTemplate)
 {
     string ret = "";
     PCollection c = this._ownerCollection;
     string attrVal = "";
     if (obj.GetAttr(attrTemplate, true, out attrVal) && attrVal != "")
     {
         ret = attrVal;
     }
     else
     {
         while (c != null)
         {
             if (c.Owner.GetAttr(attrTemplate, true, out attrVal) && attrVal != "")
             {
                 ret = attrVal;
                 break;
             }
             c = c.Owner._ownerCollection;
         }
     }
     return ret;
 }
Example #3
0
 //public List<PModelObjectNavigatorPathLevel> GetLevels()
 //{
 //    return _navigator.Levels;
 //}
 //public IPBaseObject GetPointer()
 //{
 //    return _navigator._pointer;
 //}
 public List<string> GetPathFromObject(IPBaseObject obj)
 {
     List<string> lst = new List<string>();
     PCollection c = this._ownerCollection;
     while (c != null)
     {
         lst.Insert(0, c.Name);
         if (c.Owner == obj)
             break;
         c = c.Owner._ownerCollection;
     }
     return lst;
 }
Example #4
0
        public string Format(string template, IPBaseObject obj)
        {
            List<RTemplateAttr> attrs;
            List<RTemplateCollection> fcollects;

            _parse(template, out attrs, out fcollects);

            template = template.Replace("%id%", obj.Id.ToString());
            foreach (var attr in attrs)
            {
                string val = "";
                if (attr.Module == "")
                {
                    if (!obj.GetAttr(attr.Name, true, out val))
                    {
                        //throw new Exception(String.Format("Не найден объект с атрибутом {0} содержащим текст шаблона", attr.Name));
                        val = NotFoundMarks.attrs.Begin + attr.Name + NotFoundMarks.attrs.End;
                    }
                }
                else
                {
                    val = _queryToOutside(attr.Module, attr.Name);
                }

                template = template.Replace(attr.OperatorText, val);
            }

            foreach (var fcollect in fcollects)
            {
                PCollection coll = obj.GetCollection(fcollect.collectionName, false);
                if (coll != null)
                {
                    string val = "";
                    for (int ii = 0; ii < coll.Count(); ii++)
                    {
                        PBaseObject cobj = coll.GetObject(ii);
                        /*bool addNext = (addPath && fcollect.navigatorLevelText != "");
                        if (addNext)
                        {
                            path += ((path != "") ? "/" : "") + fcollect.collectionName + ":" + fcollect.navigatorLevelText;
                            addPath = false;
                        }*/

                        string tmp = "";
                        if (cobj.GetAttr(fcollect.templateName, true, out tmp))
                        {
                            string carret = "";
                            string format = this.Format(tmp, cobj);//, ref path, addNext);
                            if (fcollect.endsWithNewLine)
                            {
                                carret = "\n";
                            }
                            else
                            {
                                // г.к. выпилить при следующем диплое
                                if (format.IndexOf("PAGE") >= 0)
                                    carret = "\n";
                            }
                            val += (format + carret);
                        }
                        else
                        {
                            val += NotFoundMarks.attrs.Begin + fcollect.templateName + NotFoundMarks.attrs.End;
                        }
                    }
                    template = template.Replace(fcollect.OperatorText, val);
                }
            }

            return template;
        }
Example #5
0
 //, Dictionary<string,string>overloads, ref string path, bool addPath)
 // ответ от Api
 //public void ProcessHostResponse(object sender, HostQueryEventArgs e)
 //{
 //    // ответ от Api сохраним в
 //    _hostResponseText = e.Text;
 //}
 public string TransformText(string templateName, IPBaseObject obj)
 {
     string template = "";
     if (obj.GetAttr(templateName, true, out template))
     {
         //return Format(template, obj, overloads);//,ref path, addPath);
         return Format(template, obj);
     }
     else
     {
         return NotFoundMarks.attrs.Begin + templateName + NotFoundMarks.attrs.End;
     }
 }