コード例 #1
0
        public List <JsonMceTypeTree> getMceTypeTree()
        {
            if (LocalMode)
            {
                List <JsonMceTypeTree> nodes = new List <JsonMceTypeTree>();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            OrderByParameter orderBy = new OrderByParameter();
                            orderBy.Asc     = true;
                            orderBy.OrderBy = "CODE";
                            CauseObject_MCE_D_MCE_TYPE pType = new CauseObject_MCE_D_MCE_TYPE();
                            pType.SetCustomCondition(" and MCE_D_MCE_TYPE.PARENT_ID is null ");
                            EntityObject_MCE_D_MCE_TYPE[] types = HelperObject_MCE_D_MCE_TYPE.Query(pType, null, orderBy, transaction);
                            foreach (EntityObject_MCE_D_MCE_TYPE type in types)
                            {
                                JsonMceTypeTree tmp = new JsonMceTypeTree();
                                tmp.id       = type.ID.Trim();
                                tmp.text     = type.NAME;
                                tmp.state    = "open";
                                tmp.children = new List <JsonMceTypeTree>();
                                nodes.Add(tmp);
                            }

                            int count = 0;
                            CauseObject_MCE_D_MCE_TYPE pChild = new CauseObject_MCE_D_MCE_TYPE();
                            foreach (JsonMceTypeTree node in nodes)
                            {
                                addTreeNode(node, count, pChild, orderBy, transaction);
                            }

                            transaction.Commit();
                        }
                        catch (Exception expt)
                        {
                            nodes = null;
                            transaction.Rollback();
                            Error(expt);
                        }
                        finally
                        {
                            IDALProvider.IDAL.PushConnection(connection);
                        }
                    }
                }
                return(nodes);
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_D_MCE_TYPE> smgr = new ServiceManager <ServiceContract_MCE_D_MCE_TYPE>(ServiceUri))
                {
                    return(smgr.Service.getMceTypeTree());
                }
            }
        }
コード例 #2
0
 private void addTreeNode(JsonMceTypeTree node, int count, CauseObject_MCE_D_MCE_TYPE pChild, OrderByParameter orderBy, IDbTransaction transaction)
 {
     if (count > 5)
     {
         return;
     }
     pChild.PARENT_ID = node.id;
     EntityObject_MCE_D_MCE_TYPE[] typeChildren = HelperObject_MCE_D_MCE_TYPE.Query(pChild, null, orderBy, transaction);
     if (typeChildren == null || typeChildren.Length == 0)
     {
         node.state = "";
         return;
     }
     foreach (EntityObject_MCE_D_MCE_TYPE typeChild in typeChildren)
     {
         JsonMceTypeTree tmp = new JsonMceTypeTree();
         tmp.id       = typeChild.ID.Trim();
         tmp.text     = typeChild.NAME;
         tmp.state    = "closed";
         tmp.children = new List <JsonMceTypeTree>();
         node.children.Add(tmp);
         addTreeNode(tmp, count + 1, pChild, orderBy, transaction);
     }
 }