Exemple #1
0
        protected XmlNode DefinitionForMarkList(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse, string sectiontype = "", bool addExpand = false)
        {
            bool isdefultsection = false;

            if (sectiontype.ToLower() == "default")
            {
                isdefultsection = true;
                sectiontype     = "";
            }
            XmlNode xrowset  = XFunc.AppendWithFind(xresponse, "rowset", "rowset", name.ToLower(), "datasource", name.ToLower());
            XmlNode xsection = XFunc.Append(xrowset, "section", "row.type", sectiontype);

            XmlNode xrequests = XFunc.Append(xsection, "requests");

            XFunc.Append(xrequests, "request", "name", "refresh");
            XFunc.Append(xrequests, "request", "name", "mark");
            if (addExpand)
            {
                XFunc.Append(xrequests, "request", "name", "expand");
            }
            if (isdefultsection)
            {
                return(xsection);
            }
            XmlNode xfields = XFunc.Append(xsection, "fields");

            {
                XFunc.SetAttr(xfields, "name", "_tostring_");
                XFunc.Append(xfields, "field", "name", "_tostring_", "type", "string", "caption", "", "len", "255");
            }
            return(xsection);
        }
Exemple #2
0
        protected virtual void RunMark(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            string rowtype   = XFunc.GetAttr(xrequest, "row.type", "");
            string marktypes = M740.GetParam(xrequest, "marktypes");

            if (marktypes == "" || marktypes.Contains(rowtype))
            {
                string id = XFunc.GetAttr(xrequest, "id", "");

                string key = MarkKey(xrequest);
                string s   = Session.GetString(key);
                if (s == null)
                {
                    s = "";
                }

                if (rowtype != "")
                {
                    id = rowtype + "." + id;
                }
                if (s.Contains(id))
                {
                    s = s.Replace(id + ";", "");
                    XFunc.Append(xresponse, "row", "row.mark", "0");
                }
                else
                {
                    s += id + ";";
                    XFunc.Append(xresponse, "row", "row.mark", "1");
                }

                Session.SetString(key, s);
                MarkSetCount(s, xresponse);
            }
        }
Exemple #3
0
        protected void Refresh(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            if (name == "empty")
            {
                XmlNode xrow = XFunc.Append(xresponse, "row", "id", "0");
                return;
            }
            MEDMDefClass dc = MEDMDefModel.MainDef.Find(name);

            if (dc != null)
            {
                if (dc.BaseClass == "MEDMObj")
                {
                    Type t = dc.GetClassType();
                    if (t != null)
                    {
                        List <MObj> list = new List <MObj>();
                        if (dc.ClassType == "edm")
                        {
                            RunRefreshSelect(list, dc, name, model, xrequest, xresponse);
                        }
                        else if (dc.ClassType == "session")
                        {
                            MObj o = model.CreateObject(t, Session.Id.ToString());
                            list.Add(o);

                            /* Если объекты хранятся в кеше то в сессии их запоминать не к чему
                             * string id = XFunc.GetText(xrequest.SelectSingleNode("param[@name='id']"), Session.Id);
                             * model.SelectFromXML(list, t, Session.GetString(name), id);
                             * if (list.Count == 0)
                             * {
                             *  MObj o = model.CreateObject(t, Session.Id.ToString());
                             *  list.Add(o);
                             *  model.Save(Session);
                             * }
                             */
                        }
                        else
                        {
                            throw new Exception($"Для автоматической генерации Refresh тип источника данных {dc.ClassType} не определен или задан неправильно.");
                        }
                        PutRefreshResult(list, dc, name, model, xrequest, xresponse);
                    }
                }
                else
                {
                    throw new Exception($"Для автоматической генерации Refresh класс источника данных {name} должен быть порожден от MEDMObj");
                }
            }
            else
            {
                List <MObj> list = new List <MObj>();
                RunRefreshSelect(list, dc, name, model, xrequest, xresponse);
                PutRefreshResult(list, dc, name, model, xrequest, xresponse);
            }
        }
Exemple #4
0
 /// <summary>
 /// Генерит описания источников данных, по описанию модели.
 /// Описание для источника генерится только в том случае если своего описание rowset не имеет
 /// </summary>
 /// <param name="formName"></param>
 /// <param name="model"></param>
 /// <param name="xrequest"></param>
 /// <param name="xresponse"></param>
 public virtual void GenRowSetsAndPanels(string formName, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     foreach (XmlNode xpanel in xresponse.SelectNodes("descendant::panel"))
     {
         if (XFunc.GetAttr(xpanel, "autogen", false))
         {
             string name = XFunc.GetAttr(xpanel, "rowset", "");
             if (name != "")
             {
                 MEDMDefClass ds = MEDMDefModel.MainDef.Find(name);
                 if (ds != null)
                 {
                     if (ds.Properties.Count > 0)
                     {
                         if (xpanel.SelectSingleNode("toolbar") == null)
                         {
                             XFunc.Append(xpanel, "toolbar", "default", "1");
                         }
                         if (xpanel.SelectSingleNode("fields") == null)
                         {
                             XmlNode xfields = XFunc.Append(xpanel, "fields");
                             foreach (MEDMDefProperty dp in ds.Properties)
                             {
                                 if (dp.IsVisible)
                                 {
                                     if (!MEDMObj.IsEmptyId(dp.RefClassId))
                                     {
                                         XmlNode xreffield = XFunc.Append(xfields, "field", "name", (dp.GetRefName() + "_tostring_").ToLower(), "stretch", "1");
                                     }
                                     else
                                     {
                                         if (dp.IsInterval)
                                         {
                                             XFunc.Append(xfields, "field", "name", (dp.Name + ".Min").ToLower());
                                             XFunc.Append(xfields, "field", "name", (dp.Name + ".Max").ToLower());
                                         }
                                         else
                                         {
                                             XFunc.Append(xfields, "field", "name", dp.Name.ToLower(), "stretch", dp.DataType == "string"?"1":"0");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemple #5
0
        public virtual bool GenFormByDef(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            MEDMDefClass ds = MEDMDefModel.MainDef.Find(name);

            if (ds != null)
            {
                XmlNode xform    = XFunc.Append(xresponse, "form", "name", ds.Name.ToLower(), "caption", ds.Header);
                XmlNode xrowsets = XFunc.Append(xform, "rowsets");
                XmlNode xrowset  = XFunc.Append(xrowsets, "rowset", "rowset", ds.Name.ToLower(), "datasourse", ds.Name.ToLower());
                XmlNode xpanels  = XFunc.Append(xform, "panels");
                XmlNode xpanel   = XFunc.Append(xpanels, "panel", "type", "grid", "caption", ds.Header, "rowset", ds.Name.ToLower());
                XmlNode xtoolbar = XFunc.Append(xpanel, "toolbar", "default", "1");
                foreach (MEDMDefProperty dp in ds.Properties)
                {
                    if (dp.Name.ToLower() != "id")
                    {
                        XmlNode xfield = XFunc.Append(xpanel, "field", "name", dp.Name.ToLower());
                    }
                }
                return(true);
            }
            return(false);
        }
Exemple #6
0
 protected override void PutRefreshResult(List <MObj> list, MEDMDefClass dc, string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     foreach (MObj obj in list)
     {
         XmlNode xrow = XFunc.Append(xresponse, "row");
         if (dc == null)
         {
             dc = MEDMDefModel.MainDef.Find(obj.GetType());
         }
         if (dc != null)
         {
             foreach (MEDMDefProperty dp in dc.Properties)
             {
                 if (dp.IsInterval)
                 {
                     XFunc.SetAttr(xrow, dp.Name.ToLower() + ".min", obj.GetValueAsString(dp.Name + ".Min"));
                     XFunc.SetAttr(xrow, dp.Name.ToLower() + ".max", obj.GetValueAsString(dp.Name + ".Max"));
                 }
                 else
                 {
                     XFunc.SetAttr(xrow, dp.Name.ToLower(), obj.GetValueAsString(dp.Name));
                 }
                 if (!MEDMObj.IsEmptyId(dp.RefClassId))
                 {
                     string n = dp.GetRefName().ToLower();
                     XFunc.SetAttr(xrow, n + "_tostring_", obj.GetValueAsString(n));
                 }
             }
         }
         else if (obj is MEDMObj)
         {
             XFunc.SetAttr(xrow, "id", (obj as MEDMObj).GetId().ToString());
         }
         XFunc.SetAttr(xrow, "_tostring_", obj.ToString());
         PutRowResult(obj, xrow, dc, name, model, xrequest, xresponse);
     }
 }
Exemple #7
0
        protected XmlNode Definition(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse, string sectiontype = "", bool addExpand = false, bool addToString = false, bool isReadOnly = false)
        {
            MEDMDefClass dc = MEDMDefModel.MainDef.Find(name);

            if (sectiontype != "")
            {
                dc = MEDMDefModel.MainDef.Find(sectiontype);
            }

            bool isdefultsection = false;

            if (name == "empty")
            {
                XmlNode xrowset   = XFunc.AppendWithFind(xresponse, "rowset", "rowset", "empty", "datasource", "empty");
                XmlNode xsection  = XFunc.Append(xrowset, "section", "row.type", sectiontype);
                XmlNode xrequests = XFunc.Append(xsection, "requests");
                XFunc.Append(xrequests, "request", "name", "refresh");
                return(xsection);
            }
            else if (dc != null)
            {
                isReadOnly = isReadOnly || dc.IsReadOnly;
                if (sectiontype.ToLower() == "default")
                {
                    isdefultsection = true;
                    sectiontype     = "";
                }
                XmlNode xrowset  = XFunc.AppendWithFind(xresponse, "rowset", "rowset", name.ToLower(), "datasource", name.ToLower(), "readonly", isReadOnly ? "1" : "0");
                XmlNode xsection = XFunc.Append(xrowset, "section", "row.type", sectiontype);

                XmlNode xrequests = XFunc.Append(xsection, "requests");
                XFunc.Append(xrequests, "request", "name", "refresh");
                if (addExpand)
                {
                    XFunc.Append(xrequests, "request", "name", "expand");
                }
                if (isdefultsection)
                {
                    return(xsection);
                }
                if (dc != null && dc.BaseClass == "MEDMObj" && !isReadOnly)
                {
                    XFunc.Append(xrequests, "request", "name", "save");
                    XFunc.Append(xrequests, "request", "name", "append");
                    XFunc.Append(xrequests, "request", "name", "delete");
                }
                if (dc.IsMark)
                {
                    XFunc.Append(xrequests, "request", "name", "mark");
                    XFunc.Append(xrequests, "request", "name", "markclear");
                    XmlNode xparams = XFunc.AppendWithFind(xrequests, "params");
                    XFunc.Append(xparams, "param", "name", "markmode", "value", name.ToLower());
                    XFunc.Append(xparams, "param", "name", "markfield", "value", name.ToLower() + "list");
                }
                if (dc.IsJoin && !isReadOnly)
                {
                    XmlNode xr = XFunc.Append(xrequests, "request", "name", "join");
                    if (dc.CaptionJoin == "*")
                    {
                        XFunc.SetAttr(xr, "caption", "Объединить отмеченные строки...");
                    }
                    else if (dc.CaptionJoin != "")
                    {
                        XFunc.SetAttr(xr, "caption", dc.CaptionJoin);
                    }
                    if (dc.ConfirmJoin == "*")
                    {
                        XFunc.SetAttr(xr, "confirm", "Отмеченные строки будут объединены с текущей строкой...");
                    }
                    else if (dc.ConfirmJoin != "")
                    {
                        XFunc.SetAttr(xr, "confirm", dc.ConfirmJoin);
                    }
                }
                if (dc.IsCopy && !isReadOnly)
                {
                    XmlNode xr = XFunc.Append(xrequests, "request", "name", "copy");
                    if (dc.CaptionCopy == "*")
                    {
                        XFunc.SetAttr(xr, "caption", "Копировать отмеченные строки...");
                    }
                    else if (dc.CaptionCopy != "")
                    {
                        XFunc.SetAttr(xr, "caption", dc.CaptionCopy);
                    }
                    if (dc.ConfirmCopy == "*")
                    {
                        XFunc.SetAttr(xr, "confirm", "Отмеченные строки будут скопированы...");
                    }
                    else if (dc.ConfirmCopy != "")
                    {
                        XFunc.SetAttr(xr, "confirm", dc.ConfirmCopy);
                    }
                }
                if (dc.IsMove && !isReadOnly)
                {
                    XmlNode xr = XFunc.Append(xrequests, "request", "name", "move");
                    if (dc.CaptionMove == "*")
                    {
                        XFunc.SetAttr(xr, "caption", "Перенести отмеченные строки...");
                    }
                    else if (dc.CaptionMove != "")
                    {
                        XFunc.SetAttr(xr, "caption", dc.CaptionMove);
                    }
                    if (dc.ConfirmMove == "*")
                    {
                        XFunc.SetAttr(xr, "confirm", "Отмеченные строки будут перенесены...");
                    }
                    else if (dc.ConfirmMove != "")
                    {
                        XFunc.SetAttr(xr, "confirm", dc.ConfirmMove);
                    }
                }
                if (dc.IsLink && !isReadOnly)
                {
                    XmlNode xr = XFunc.Append(xrequests, "request", "name", "link");
                    if (dc.CaptionLink == "*")
                    {
                        XFunc.SetAttr(xr, "caption", "Присоединить отмеченные строки...");
                    }
                    else if (dc.CaptionLink != "")
                    {
                        XFunc.SetAttr(xr, "caption", dc.CaptionLink);
                    }
                    if (dc.ConfirmLink == "*")
                    {
                        XFunc.SetAttr(xr, "confirm", "Отмеченные строки будут присоединены...");
                    }
                    else if (dc.ConfirmLink != "")
                    {
                        XFunc.SetAttr(xr, "confirm", dc.ConfirmLink);
                    }
                }
                if (dc.IsClone && !isReadOnly)
                {
                    XmlNode xr = XFunc.Append(xrequests, "request", "name", "clone");
                    if (dc.CaptionClone == "*")
                    {
                        XFunc.SetAttr(xr, "caption", "Клонировать отмеченные строки...");
                    }
                    else if (dc.CaptionClone != "")
                    {
                        XFunc.SetAttr(xr, "caption", dc.CaptionClone);
                    }
                    if (dc.ConfirmClone == "*")
                    {
                        XFunc.SetAttr(xr, "confirm", "Отмеченные строки будут клонированы...");
                    }
                    else if (dc.ConfirmClone != "")
                    {
                        XFunc.SetAttr(xr, "confirm", dc.ConfirmClone);
                    }
                }
                XmlNode xfields = XFunc.Append(xsection, "fields");
                foreach (MEDMDefProperty dp in dc.Properties)
                {
                    if (dp.IsVisible)
                    {
                        if (dp.IsInterval)
                        {
                            XFunc.Append(xfields, "field", "name", (dp.Name + ".Min").ToLower(), "type", dp.GetDataTypeFor740(), "caption", dp.Header + " от", "len", GetLen(dp));
                            XFunc.Append(xfields, "field", "name", (dp.Name + ".Max").ToLower(), "type", dp.GetDataTypeFor740(), "caption", "до", "len", GetLen(dp));
                        }
                        else
                        {
                            string t    = dp.GetDataTypeFor740();
                            string list = "";
                            if (!string.IsNullOrEmpty(dp.Items))
                            {
                                foreach (string item in dp.Items.Split(itemd, StringSplitOptions.RemoveEmptyEntries))
                                {
                                    string item1 = item.Replace(";", ",").Trim();
                                    if (!string.IsNullOrEmpty(item1))
                                    {
                                        if (!string.IsNullOrEmpty(list))
                                        {
                                            list += ";";
                                        }
                                        list += item1;
                                    }
                                }
                            }
                            if (list != "")
                            {
                                t = "list";
                            }
                            XmlNode xfield = XFunc.Append(xfields, "field", "name", dp.Name.ToLower(), "type", t, "caption", dp.Header, "len", GetLen(dp), "list", list);
                            if (t == "radio")
                            {
                                if (dp.DataType == "int" || dp.DataType == "long" || dp.DataType == "short" || dp.DataType == "byte")
                                {
                                    XFunc.SetAttr(xfield, "basetype", "num");
                                    XFunc.SetAttr(xfield, "default", MFunc.StringToInt(dp.DefValue, 1).ToString());
                                }
                                else
                                {
                                }
                            }
                            if (!MEDMObj.IsEmptyId(dp.RefClassId))
                            {
                                XFunc.Append(xfield, "ref", "datasource", dp.RefClass.Name.ToLower());
                                XFunc.SetAttr(xfield, "type", "ref");
                                XFunc.SetAttr(xfield, "visible", "0");
                                XmlNode xreffield = XFunc.Append(xfields, "field", "name", (dp.GetRefName() + "_tostring_").ToLower(), "type", "string", "refid", dp.Name.ToLower(), "refname", "_tostring_", "caption", dp.Header, "len", GetLen(dp));
                            }
                        }
                    }
                }
                if (addToString)
                {
                    XFunc.SetAttr(xfields, "name", "_tostring_");
                    XFunc.Append(xfields, "field", "name", "_tostring_", "type", "string", "caption", "", "len", "255");
                }
                return(xsection);
            }
            return(null);
        }