示例#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);
        }
示例#2
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);
        }
示例#3
0
        protected void MarkSetCount(string idlist, XmlNode xresponse)
        {
            int count = 0;

            char[] d = { ';' };
            if (!string.IsNullOrEmpty(idlist))
            {
                count = idlist.Split(d, StringSplitOptions.RemoveEmptyEntries).Length;
            }
            XFunc.SetAttr(xresponse, "markcount", count.ToString());
        }
示例#4
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($"Нет омеченных элементов");
            }
        }
示例#5
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);
     }
 }
示例#6
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");
                }
            }
        }
示例#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);
        }