Example #1
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);
            }
        }
Example #2
0
        protected virtual void RunMarkSet(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            string key    = MarkKey(xrequest);
            string result = M740.GetParam(xrequest, "result");

            if (result == "OK")
            {
                string r = Session.GetString(key);
                if (string.IsNullOrEmpty(r))
                {
                    Session.Remove("~" + key);
                }
                else
                {
                    Session.SetString("~" + key, r);
                }
            }
            else
            {
                string r = Session.GetString("~" + key);
                if (string.IsNullOrEmpty(r))
                {
                    Session.Remove(key);
                }
                else
                {
                    Session.SetString(key, r);
                }
            }
        }
Example #3
0
        protected virtual void RunRefreshMark(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            string key = MarkKey(xrequest);
            string s   = Session.GetString(key);

            if (s == null)
            {
                s = "";
            }
            if (s != "")
            {
                foreach (XmlNode xrow in xresponse.SelectNodes("descendant::row"))
                {
                    string id      = XFunc.GetAttr(xrow, "id", "");
                    string rowtype = XFunc.GetAttr(xrow, "row.type", "");
                    if (rowtype != "")
                    {
                        id = rowtype + "." + id;
                    }
                    XFunc.SetAttr(xrow, "row.mark", s.Contains(id) ? "1" : "0");
                }
            }
            else
            {
                foreach (XmlNode xrow in xresponse.SelectNodes("descendant::row"))
                {
                    XFunc.SetAttr(xrow, "row.mark", "0");
                }
            }
            MarkSetCount(s, xresponse);
        }
Example #4
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);
        }
Example #5
0
        protected virtual void RunMarkClear(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            string key = MarkKey(xrequest);

            Session.Remove(key);
            MarkSetCount("", xresponse);
        }
Example #6
0
        protected override void RunDelete(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            MEDMDefClass dc = MEDMDefModel.MainDef.Find(name);

            if (dc != null)
            {
                if (dc.BaseClass == "MEDMObj")
                {
                    Type t = dc.GetClassType();
                    if (t != null)
                    {
                        string id = XFunc.GetAttr(xrequest, "id", "");
                        if (id == "")
                        {
                            throw new Exception("В параметрах запроса отсутствует id");
                        }
                        MEDMObj obj = model.MainDic.GetObj(t, id);
                        if (obj == null)
                        {
                            throw new Exception($"Не удалось создать объект типа {t}. Удаление невозможно.");
                        }
                        model.DeleteObject(obj);
                        model.Save(Session);
                    }
                }
                else
                {
                    throw new Exception($"Для автоматической генерации Delete класс источника данных {name} должен быть порожден от MEDMObj");
                }
            }
        }
Example #7
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);
            }
        }
Example #8
0
 public override void Run(string formName, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     base.Run(formName, model, xrequest, xresponse);
     if (!LoadFormFromXml(formName, model, xrequest, xresponse))
     {
         GenFormByDef(formName, model, xrequest, xresponse);
     }
     else
     {
         GenRowSetsAndPanels(formName, model, xrequest, xresponse);
     }
 }
Example #9
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");
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #10
0
        public static string MarkNames(string idlist, Type objtype, string section, MEDMSql model)
        {
            string result  = "";
            string idlist1 = MarkId(idlist, section);

            if (!string.IsNullOrEmpty(idlist1))
            {
                List <MObj> list = new List <MObj>();
                string      sql  = $"select * from [{MEDMDefModel.MainDef.GetTableNameByType(objtype)}] (nolock) where id!='{default(Guid)}' and id in ({idlist1})";
                model.Select(list, objtype, sql);
                foreach (MObj o in list)
                {
                    result += o.ToString() + "\r\n";
                }
            }
            return(result);
        }
Example #11
0
        protected override void RunJoin(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            MEDMDefClass dc = MEDMDefModel.MainDef.Find(name);

            if (dc == null)
            {
                throw new Exception($"Нет описателя класса соответстующго имени {name}");
            }
            MEDMDefProperty dp = dc.GetIdPropery();
            List <Guid>     l  = MarkId <Guid>(Session.GetString(MarkKey(xrequest)), name.ToLower());

            if (l.Count > 0)
            {
                object id = M740.GetParam(dp.GetPropertyType(), xrequest, "id", "");
                if (id != dp.GetDefaultValue())
                {
                    string sql = "";
                    foreach (MEDMDefClass dc1 in MEDMDefModel.MainDef.AllClasses)
                    {
                        foreach (MEDMDefProperty dp1 in dc1.Properties)
                        {
                            if (dp1.RefClass == dc)
                            {
                                sql += $"update [{dc1.Name}] set [{dp1.Name}]=@p0 where CountryPresentingDemandId=@p1\r\n";
                            }
                        }
                    }
                    sql += $"delete [{name}] where Id=@p1\r\n";

                    foreach (object joinid in l)
                    {
                        if (joinid != dp.GetDefaultValue() && joinid != id)
                        {
                            model.Exec(sql, "p0", id, "p1", joinid);
                        }
                    }
                    RunMarkClear(name, model, xrequest, xresponse);
                    XFunc.SetAttr(xresponse, "exec", "refresh");
                }
            }
            else
            {
                throw new Exception($"Нет омеченных элементов");
            }
        }
Example #12
0
        public virtual bool LoadFormFromXml(string formName, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            string formpath = Path.Combine(MFunc.GetBaseDir(AppContext.BaseDirectory), "Forms", formName + ".xml");

            if (System.IO.File.Exists(formpath))
            {
                XmlDocument xdoc = new XmlDocument();
                FileStream  fs   = new FileStream(formpath, FileMode.Open, FileAccess.Read, FileShare.Read);
                xdoc.Load(fs);
                fs.Dispose();
                string s = xdoc.InnerXml;
                int    i = s.IndexOf("?>");
                if (i > 0)
                {
                    s = s.Substring(i + 2);
                }
                xresponse.InnerXml = s;
                return(true);
            }
            return(false);
        }
Example #13
0
        protected XmlNode RefreshRow(string name, object id, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            XmlNode      xrow = null;
            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")
                        {
                            model.Select(list, t, $"select * from [{dc.Name}] (nolock) where id!=@p1 and id=@p2", "p1", dc.GetIdPropery().GetDefaultValue(), "p2", id);
                        }
                        else if (dc.ClassType == "session")
                        {
                            MObj o = model.CreateObject(t, Session.Id.ToString());
                            list.Add(o);

                            /* Если объекты хранятся в кеше то в сессии их запоминать не к чему
                             * model.SelectFromXML(list, t, Session.GetString(name), id);
                             */
                        }
                        else
                        {
                            throw new Exception($"Для автоматической генерации RefreshRow тип источника данных {dc.ClassType} не определен или задан неправильно.");
                        }
                        PutRefreshResult(list, dc, name, model, xrequest, xresponse);
                    }
                }
                else
                {
                    throw new Exception($"Для автоматической генерации RefreshRow класс источника данных {name} должен быть порожден от MEDMObj");
                }
            }
            return(xrow);
        }
Example #14
0
        protected override void RunSave(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            MEDMDefClass dc = MEDMDefModel.MainDef.Find(name);

            if (dc != null)
            {
                if (dc.BaseClass == "MEDMObj")
                {
                    Type t = dc.GetClassType();
                    if (t != null)
                    {
                        string id = XFunc.GetAttr(xrequest, "id", "");
                        if (id == "")
                        {
                            throw new Exception("В параметрах запроса отсутствует id");
                        }
                        MEDMObj obj = model.MainDic.GetObj(t, id);
                        if (obj == null)
                        {
                            throw new Exception($"Не удалось создать объект типа {t}. Сохранить изменения невозможно.");
                        }
                        foreach (XmlNode xparam in xrequest.ChildNodes)
                        {
                            if (xparam.Name == "param")
                            {
                                obj.SetStringValue(XFunc.GetAttr(xparam, "name", ""), xparam.InnerText);
                            }
                        }
                        model.Save(Session);
                        RefreshRow(name, id, model, xrequest, xresponse);
                    }
                }
                else
                {
                    throw new Exception($"Для автоматической генерации Save класс источника данных {name} должен быть порожден от MEDMObj");
                }
            }
        }
Example #15
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);
        }
Example #16
0
        protected override void RunAppend(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            MEDMDefClass dc = MEDMDefModel.MainDef.Find(name);

            if (dc != null)
            {
                if (dc.BaseClass == "MEDMObj")
                {
                    Type t = dc.GetClassType();
                    if (t != null)
                    {
                        FilterParamList l   = new FilterParamList(dc, xrequest);
                        MEDMObj         obj = model.CreateObject(t, null);
                        model.Save(Session);
                        foreach (FilterParam fp in l)
                        {
                            obj.SetValue(fp.Name, fp.Value);
                        }
                        model.Save(Session);
                        if (obj != null)
                        {
                            XmlNode xrow = RefreshRow(name, obj.GetId(), model, xrequest, xresponse);
                            if (xrow != null)
                            {
                                XFunc.SetAttr(xrow, "row.destmode", "after");
                                XFunc.SetAttr(xrow, "row.destid", XFunc.GetAttr(xrequest, "id", ""));
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception($"Для автоматической генерации Append класс источника данных {name} должен быть порожден от MEDMObj");
                }
            }
        }
Example #17
0
        protected override void RunRefreshSelect(List <MObj> list, MEDMDefClass dc, string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            FilterParamList l = new FilterParamList(dc, xrequest);

            object[] parms = new object[l.Count * 2 + 2];
            string   t     = l.Top > 0 ? "top " + l.Top.ToString():"";
            string   sql   = $"select {t} * from [{dc.Name}] (nolock) where id!=@p0";

            parms[0] = "p0";
            parms[1] = dc.GetIdPropery().GetDefaultValue();
            for (int i = 0; i < l.Count; i++)
            {
                switch (l[i].Mode)
                {
                case "":
                case "eq":
                    sql += $" and ( [{l[i].Name}]=@p{i + 1})";
                    break;

                case "ne":
                    sql += $" and ( [{l[i].Name}]!=@p{i + 1})";
                    break;

                case "eqornone":
                    sql += $" and ( [{l[i].Name}]=@p{i + 1} or  [{l[i].Name}]=@p0)";
                    break;
                }
                parms[(i + 1) * 2]     = $"p{i + 1}";
                parms[(i + 1) * 2 + 1] = l[i].Value;
            }
            {
                MEDMDefProperty dp = dc.Properties.Find(p => p.Name.ToLower() == "name");
                if (dp == null)
                {
                    dp = dc.Properties.Find(p => p.Name.ToLower().EndsWith("name"));
                }
                if (dp == null)
                {
                    dp = dc.Properties.Find(p => p.Name.ToLower().Contains("name"));
                }
                if (dp != null)
                {
                    sql += $" order by [{dp.Name}]";
                }
            }
            model.Select(list, dc.GetClassType(), sql, parms);
        }
Example #18
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);
        }
Example #19
0
 protected virtual void RunClone(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     throw new NotImplementedException($@"Медод ""RunClone"" для {name} не переопределен.");
 }
Example #20
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);
     }
 }
Example #21
0
 protected override void RunRefresh(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     Refresh(name, model, xrequest, xresponse);
 }
Example #22
0
 protected virtual void RunRequest(string name, string requestname, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     throw new Exception($"Источник данных {this.GetType().Name} не поддерживает запрос {requestname}");
 }
Example #23
0
 protected override void RunDefinition(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
     Definition(name, model, xrequest, xresponse, "", false, false, CurrentUser.UserIsReadOnly());
 }
Example #24
0
 protected virtual void PutRowResult(MObj obj, XmlNode xrow, MEDMDefClass dc, string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
 }
Example #25
0
        public virtual void Run(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
        {
            string requestname = XFunc.GetAttr(xrequest, "name", "").ToLower();

            switch (requestname)
            {
            case "definition":
                RunDefinition(name, model, xrequest, xresponse);
                break;

            case "expand":
            case "refresh":
                RunRefresh(name, model, xrequest, xresponse);
                RunRefreshMark(name, model, xrequest, xresponse);
                break;

            case "save":
                RunSave(name, model, xrequest, xresponse);
                break;

            case "append":
                RunAppend(name, model, xrequest, xresponse);
                break;

            case "delete":
                RunDelete(name, model, xrequest, xresponse);
                break;

            case "change":
                RunChange(name, model, xrequest, xresponse);
                break;

            case "mark":
                RunMark(name, model, xrequest, xresponse);
                break;

            case "markclear":
                RunMarkClear(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                RunRefreshMark(name, model, xrequest, xresponse);
                break;

            case "markset":
                RunMarkSet(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                break;

            case "join":
                RunJoin(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                break;

            case "copy":
                RunCopy(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                break;

            case "move":
                RunMove(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                break;

            case "link":
                RunLink(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                break;

            case "clone":
                RunClone(name, model, xrequest, xresponse);
                RunRefresh(name, model, xrequest, xresponse);
                break;

            default:
                RunRequest(name, requestname, model, xrequest, xresponse);
                break;
            }
        }
Example #26
0
 public virtual void Run(string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
 }
Example #27
0
 protected virtual void PutRefreshResult(List <MObj> list, MEDMDefClass dc, string name, MEDMSql model, XmlNode xrequest, XmlNode xresponse)
 {
 }