예제 #1
0
        public IsbNode Load()
        {
            IsbNode listNode = null;

            if (this.CheckTableExist("SBRouteBlock"))
            {
                listNode = new IsbNode("Блок типового маршрута");

                var listGroups = LoadGroups(listNode);
                foreach (var groupNode in listGroups)
                {
                    SqlCommand command = new SqlCommand();
                    command.Connection  = Connection;
                    command.CommandText = "select XRecID, Name, Comment, Properties, LastUpdate from SBRouteBlock where BlockGroup=@groupID order by Name";
                    SqlParameter paramGroupId = new SqlParameter("@groupID", SqlDbType.Int);
                    paramGroupId.Value = groupNode.Id;
                    command.Parameters.Add(paramGroupId);
                    command.Prepare();
                    SqlDataReader reader = command.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            var routeBlockNode = new IsbNode();
                            routeBlockNode.Type = IsbNodeType.RouteBlock;
                            //ИД
                            routeBlockNode.Id = reader.GetInt32(0);
                            //Имя
                            if (!reader.IsDBNull(1))
                            {
                                routeBlockNode.Name = reader.GetString(1);
                            }
                            //Комментарий
                            if (!reader.IsDBNull(2))
                            {
                                routeBlockNode.Text = reader.GetString(2);
                            }
                            //Свойства
                            if (!reader.IsDBNull(3))
                            {
                                var    schemaBytes  = (byte[])reader.GetValue(3);
                                string schemaString = System.Text.Encoding.GetEncoding(1251).GetString(schemaBytes);
                                RouteParser.ParseBlockProperties(schemaString, routeBlockNode);
                            }
                            if (!reader.IsDBNull(4))
                            {
                                routeBlockNode.LastUpdate = reader.GetDateTime(4);
                            }
                            groupNode.Nodes.Add(routeBlockNode);
                        }
                    }
                    reader.Close();
                }
            }
            return(listNode);
        }
예제 #2
0
        public IsbNode Load()
        {
            IsbNode listNode = null;

            listNode = new IsbNode("Типовой маршрут");

            var listGroups = LoadGroups(listNode);

            foreach (var groupNode in listGroups)
            {
                SqlCommand command = new SqlCommand();
                command.Connection  = Connection;
                command.CommandText = @"
select MBAnalit.Analit
    , ltrim(MBAnalit.Kod)
    , MBAnalit.NameAn + ' (' + ltrim(MBAnalit.Kod) + ')'
    , MBText.SearchCondition 
    , (select max(prot.DateAct)
        from XProtokol prot 
        where prot.SrcObjID = 119 and prot.SrcRecID = MBAnalit.Analit) as LastUpd
from MBAnalit
    join MBText on MBAnalit.Analit = MBText.SrcRecID and MBText.SrcObjID = 119
where MBAnalit.HighLvl=@groupID
    and MBAnalit.Vid = (select Vid from MBVidAn where Kod = 'STANDARD_ROUTES' or Kod = 'ТМТ') 
order by MBAnalit.NameAn";
                SqlParameter paramGroupId = new SqlParameter("@groupID", SqlDbType.Int);
                paramGroupId.Value = groupNode.Id;
                command.Parameters.Add(paramGroupId);
                command.Prepare();
                SqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var routeNode = new IsbNode(reader.GetString(2));
                        routeNode.Type = IsbNodeType.StandardRoute;
                        routeNode.Id   = reader.GetInt32(0);
                        routeNode.Code = reader.GetString(1);
                        // Схема
                        if (!reader.IsDBNull(3))
                        {
                            var    schemaBytes  = (byte[])reader.GetValue(3);
                            string schemaString = System.Text.Encoding.GetEncoding(1251).GetString(schemaBytes);
                            RouteParser.ParseRoute(schemaString, routeNode);
                        }
                        if (!reader.IsDBNull(4))
                        {
                            routeNode.LastUpdate = reader.GetDateTime(4);
                        }
                        groupNode.Nodes.Add(routeNode);
                    }
                }
                reader.Close();
            }
            return(listNode);
        }