Exemplo n.º 1
0
        private void tlSysObject_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (e.Node == null)
            {
                this.ucSysModule1.Visible     = false;
                this.ucSysObject1.Visible     = false;
                this.bbiEditModule.Visibility = BarItemVisibility.Never;
                this.bbiEditObject.Visibility = BarItemVisibility.Never;
                this.bbiAddObject.Visibility  = BarItemVisibility.Never;
                return;
            }

            string code       = e.Node.GetValue(this.tlcCode).ToString();
            string moduleCode = e.Node.GetValue(tlcParentCode).ToString();

            if (string.IsNullOrEmpty(moduleCode))
            {
                CDictModule module = e.Node.Tag as CDictModule;
                this.FreshModule(module);
            }
            else
            {
                CDictObject obj        = e.Node.Tag as CDictObject;
                string      objectCode = obj.Code;
                var         parmList   = new List <KeyValuePair <string, string> >
                {
                    new KeyValuePair <string, string>("objectCode", objectCode)
                };
                CustomException ce = null;
                //  获取功能对应的功能点
                List <CDictFunctionPoint> fps = HttpDataHelper.GetWithInfo <List <CDictFunctionPoint> >("BASE", "/setup/fplist", out ce, parmList);
                obj.FunctionPointList = fps;
                this.FreshObject(obj);
            }
        }
Exemplo n.º 2
0
 private void FreshObject(CDictObject obj)
 {
     this.ucSysModule1.Visible     = false;
     this.ucSysObject1.Visible     = true;
     this.bbiAddObject.Visibility  = BarItemVisibility.Always;
     this.bbiEditModule.Visibility = BarItemVisibility.Never;
     this.bbiEditObject.Visibility = BarItemVisibility.Always;
     this.ucSysObject1.Init(obj);
     this.ucSysObject1.SetStatus(false);
 }
Exemplo n.º 3
0
        private void bbiEditObject_ItemClick(object sender, ItemClickEventArgs e)
        {
            TreeListNode mnode = this.tlSysObject.FocusedNode;

            if (mnode != null)
            {
                CDictObject data = mnode.Tag as CDictObject;
                if (data != null)
                {
                    //  重新获取功能对象信息, 防止对象信息变更。
                    //  TODO:未验证?
                    string   module_obj = this.tlSysObject.FocusedNode.ParentNode.GetValue(this.tlcObject).ToString();
                    Assembly theDll     = Assembly.LoadFrom(EnvInfo.RunPath + module_obj + ".dll");
                    Type     type       = theDll.GetType(module_obj + "." + data.Object);
                    data.IsFunction       = type.IsSubclassOf(typeof(FrmBase)) ? 1 : 0;
                    data.HasFunctionPoint = typeof(IFunctionPoint).IsAssignableFrom(type) ? 1 : 0;
                    if (data.HasFunctionPoint == 1)
                    {
                        List <CDictFunctionPoint> listObjectFp = new List <CDictFunctionPoint>();
                        foreach (Attribute attr in type.GetCustomAttributes(typeof(FunctionPointAttribute)))
                        {
                            FunctionPointAttribute fpattr = attr as FunctionPointAttribute;
                            CDictFunctionPoint     fp     = new CDictFunctionPoint();
                            fp.Code       = data.Code + "-" + fpattr.Code;
                            fp.Name       = fpattr.Name;
                            fp.ObjectCode = data.Code;
                            fp.Describe   = fpattr.Describe;

                            listObjectFp.Add(fp);
                        }
                        if (listObjectFp.Count > 0)
                        {
                            data.FunctionPointList = listObjectFp;
                        }
                        else
                        {
                            data.HasFunctionPoint = 0;      //  没有设置具体功能点认为无功能点
                        }
                    }

                    FrmObjectEdit frm = new FrmObjectEdit();
                    frm.Init(data);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        data = frm.DataObject;
                        mnode.SetValue(tlcName, data.Name);
                        mnode.SetValue(tlcUsedFlag, data.UsedFlag);
                        mnode.Tag = data;
                        this.ucSysObject1.Init(data);
                    }
                    frm.Dispose();
                }
            }
        }
Exemplo n.º 4
0
        public void Init(List <CDictModule> module_list, List <CDictObject> object_list, string object_code)
        {
            this.objectList          = object_list;
            this.gcModule.DataSource = module_list;
            CDictObject obj = object_list.Find(o => { return(o.Code == object_code); });

            if (obj != null)
            {
                this.objectCode = object_code;
                int idx = module_list.FindIndex(o => { return(o.Code == obj.ModuleCode); });
                this.gvModule.FocusedRowHandle = idx;
            }
        }
Exemplo n.º 5
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     //  保存数据
     this.DataObject = this.ucSysObject1.GetData();
     if (this.DataObject != null)
     {
         String          str    = StringHelper.SerializeObject <CDictObject>(this.DataObject);
         CustomException ce     = null;
         String          result = HttpDataHelper.HttpPostWithInfo("BASE", "/setup/objectset", out ce, str);
         if (result == "1")
         {
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             MessageHelper.ShowError("保存失败");
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        ///  获取对象名称(模块名 + 对象名)
        /// </summary>
        /// <returns></returns>
        private string getObjectName()
        {
            string object_name = string.Empty;

            if (!string.IsNullOrEmpty(this.objectCode))
            {
                CDictObject obj = this.ObjectList.Find(o => { return(o.Code == this.objectCode); });
                if (obj != null)
                {
                    CDictModule module = this.ModuleList.Find(o => { return(o.Code == obj.ModuleCode); });
                    if (module != null)
                    {
                        object_name = module.Name + " --- " + obj.Name;
                        try
                        {
                            //  查找参数说明
                            Assembly theDll            = Assembly.LoadFrom(EnvInfo.RunPath + module.FileName + ".dll");
                            Type     type              = theDll.GetType(module.FileName + "." + obj.Object);
                            FormParmDescAttribute attr = type.GetCustomAttribute(typeof(FormParmDescAttribute)) as FormParmDescAttribute;
                            if (attr != null)
                            {
                                this.beParameter.Properties.Buttons[0].Visible = true;
                                this.beParameter.Properties.Buttons[0].ToolTip = "描述:" + attr.Description + "\r\n实例:" + attr.Example;
                            }
                            else
                            {
                                this.beParameter.Properties.Buttons[0].Visible = false;
                            }
                        }
                        catch { }
                    }
                }
            }

            return(object_name);
        }
Exemplo n.º 7
0
        private List <CDictObject> getModuleObjectList(Assembly theDll, String moduleCode)
        {
            Type[]             types      = theDll.GetTypes();
            List <CDictObject> listObject = new List <CDictObject>();

            foreach (Type type in types)
            {
                if (type.GetInterface("IManagedControl") != null)
                {
                    try
                    {
                        IManagedControl mc    = (IManagedControl)theDll.CreateInstance(type.FullName);
                        string          _name = mc.ControlName;
                        string          _code = mc.ControlCode;

                        if (!string.IsNullOrEmpty(_code))
                        {
                            CDictObject obj = new CDictObject();
                            obj.Code             = _code;
                            obj.Name             = _name;
                            obj.Object           = type.Name;
                            obj.UsedFlag         = 1;
                            obj.ModuleCode       = moduleCode;
                            obj.IsFunction       = (mc is FrmBase) ? 1 : 0;
                            obj.HasFunctionPoint = (mc is IFunctionPoint) ? 1 : 0;

                            listObject.Add(obj);

                            //  有功能点时自动获取功能点信息
                            if (obj.HasFunctionPoint == 1)
                            {
                                List <CDictFunctionPoint> listObjectFp = new List <CDictFunctionPoint>();
                                foreach (DataFunctionPoint fpi in ((IFunctionPoint)mc).FunctionPointList)
                                {
                                    CDictFunctionPoint fp = new CDictFunctionPoint();
                                    fp.Code       = fpi.Code;
                                    fp.Name       = fpi.Name;
                                    fp.ObjectCode = obj.Code;
                                    fp.Describe   = fpi.Target.ToString();

                                    listObjectFp.Add(fp);
                                }
                                if (listObjectFp.Count > 0)
                                {
                                    obj.FunctionPointList = listObjectFp;
                                }
                                else
                                {
                                    obj.HasFunctionPoint = 0;      //  没有设置具体功能点认为无功能点
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageHelper.ShowWarning(ex.Message);
                        continue;
                    }
                }
            }
            return(listObject);
        }
Exemplo n.º 8
0
        private List <CDictObject> getModuleObjectListNew(Assembly theDll, String moduleCode, string moduleObject)
        {
            List <CDictObject> listObject = new List <CDictObject>();

            //  获取模块信息中全部可管理的对象attribute
            object[] attributes = theDll.GetCustomAttributes(typeof(ManagedObjectAttribute), false);
            for (int i = 0; i < attributes.Length; i++)
            {
                ManagedObjectAttribute obj_attr = attributes[i] as ManagedObjectAttribute;

                CDictObject obj = new CDictObject();
                obj.Code       = obj_attr.Code;
                obj.Name       = obj_attr.Name;
                obj.Object     = obj_attr.ObjectName;
                obj.UsedFlag   = 1;
                obj.ModuleCode = moduleCode;

                try
                {
                    Type type = theDll.GetType(moduleObject + "." + obj.Object);
                    obj.IsFunction       = type.IsSubclassOf(typeof(FrmBase)) ? 1 : 0;
                    obj.HasFunctionPoint = typeof(IFunctionPoint).IsAssignableFrom(type) ? 1 : 0;

                    listObject.Add(obj);

                    //  有功能点时自动获取功能点信息
                    if (obj.HasFunctionPoint == 1)
                    {
                        List <CDictFunctionPoint> listObjectFp = new List <CDictFunctionPoint>();
                        try
                        {
                            foreach (Attribute attr in type.GetCustomAttributes(typeof(FunctionPointAttribute)))
                            {
                                FunctionPointAttribute fpattr = attr as FunctionPointAttribute;
                                CDictFunctionPoint     fp     = new CDictFunctionPoint();
                                fp.Code       = obj.Code + "-" + fpattr.Code;
                                fp.Name       = fpattr.Name;
                                fp.ObjectCode = obj.Code;
                                fp.Describe   = fpattr.Describe;

                                listObjectFp.Add(fp);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageHelper.ShowWarning(moduleObject + "." + obj.Object + "功能点分析出现问题。\r\n" + ex.Message);
                        }
                        if (listObjectFp.Count > 0)
                        {
                            obj.FunctionPointList = listObjectFp;
                        }
                        else
                        {
                            obj.HasFunctionPoint = 0;      //  没有设置具体功能点认为无功能点
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageHelper.ShowWarning(moduleObject + "." + obj.Object + "对象分析出现问题。\r\n" + ex.Message);
                }
            }
            return(listObject);
        }
Exemplo n.º 9
0
 public void Init(CDictObject obj)
 {
     this.ucSysObject1.Init(obj);
     this.ucSysObject1.SetStatus(true);
 }
Exemplo n.º 10
0
        private void bbiAddObject_ItemClick(object sender, ItemClickEventArgs e)
        {
            //  获取模块名称
            TreeListNode rnode = this.tlSysObject.FocusedNode;

            if (rnode == null)
            {
                return;
            }
            if (rnode.ParentNode != null)
            {
                //  选择对象时获取其对应的模块节点
                rnode = rnode.ParentNode;
            }
            string module_obj  = rnode.GetValue(this.tlcObject).ToString();
            string module_code = rnode.GetValue(this.tlcCode).ToString();
            string module_name = rnode.GetValue(this.tlcName).ToString();

            //  获取已经加入的功能
            List <string> existsObjectList = new List <string>();

            foreach (TreeListNode objnode in rnode.Nodes)
            {
                existsObjectList.Add(objnode.GetValue(this.tlcCode).ToString());
            }

            //  获取对应模块可用功能
            List <CDictObject> objectList = new List <CDictObject>();

            try
            {
                Assembly theDll = Assembly.LoadFrom(EnvInfo.RunPath + module_obj + ".dll");

                //  找出未加入的对象到noexistsObjectList
                List <string> noexistsObjectList = new List <string>();       //  未加入的对象列表
                object[]      customs            = theDll.GetCustomAttributes(false);
                foreach (var item in customs)
                {
                    if (item.GetType() == typeof(ManagedObjectAttribute))
                    {
                        ManagedObjectAttribute objAttr = item as ManagedObjectAttribute;

                        string code = objAttr.Code;
                        if (existsObjectList.Find(o => o == code) == null)
                        {
                            noexistsObjectList.Add(objAttr.ObjectName);
                        }
                    }
                }

                //  找出可用对象完整信息到listObject
                //  获取模块信息中全部可管理的对象attribute
                object[] attributes = theDll.GetCustomAttributes(typeof(ManagedObjectAttribute), false);
                for (int i = 0; i < attributes.Length; i++)
                {
                    ManagedObjectAttribute obj_attr = attributes[i] as ManagedObjectAttribute;
                    //  判断是否已经加入
                    if (noexistsObjectList.Find(o => o == obj_attr.ObjectName) != null)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(obj_attr.Code))
                            {
                                CDictObject obj = new CDictObject();
                                obj.Code       = obj_attr.Code;
                                obj.Name       = obj_attr.Name;
                                obj.Object     = obj_attr.ObjectName;
                                obj.UsedFlag   = 1;
                                obj.ModuleCode = module_code;

                                Type type = theDll.GetType(module_obj + "." + obj.Object);
                                obj.IsFunction       = type.IsSubclassOf(typeof(FrmBase)) ? 1 : 0;
                                obj.HasFunctionPoint = typeof(IFunctionPoint).IsAssignableFrom(type) ? 1 : 0;

                                objectList.Add(obj);

                                //  有功能点时自动获取功能点信息
                                if (obj.HasFunctionPoint == 1)
                                {
                                    List <CDictFunctionPoint> listObjectFp = new List <CDictFunctionPoint>();
                                    foreach (Attribute attr in type.GetCustomAttributes(typeof(FunctionPointAttribute)))
                                    {
                                        FunctionPointAttribute fpattr = attr as FunctionPointAttribute;
                                        CDictFunctionPoint     fp     = new CDictFunctionPoint();
                                        fp.Code       = obj.Code + "-" + fpattr.Code;
                                        fp.Name       = fpattr.Name;
                                        fp.ObjectCode = obj.Code;
                                        fp.Describe   = fpattr.Describe;

                                        listObjectFp.Add(fp);
                                    }
                                    if (listObjectFp.Count > 0)
                                    {
                                        obj.FunctionPointList = listObjectFp;
                                    }
                                    else
                                    {
                                        obj.HasFunctionPoint = 0;      //  没有设置具体功能点认为无功能点
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageHelper.ShowWarning(ex.Message);
                            continue;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageHelper.ShowWarning(ex.Message);
            }
            finally
            {
                //  选择对象
                if (objectList.Count > 0)
                {
                    //  按代码排序
                    objectList.Sort((left, right) =>
                    {
                        int result = left.Code.CompareTo(right.Code);
                        if (result > 0)
                        {
                            return(1);
                        }
                        else if (result < 0)
                        {
                            return(-1);
                        }
                        return(0);
                    });
                    FrmObjectAdd frm = new FrmObjectAdd();
                    frm.Init(objectList, module_name);
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        //  添加节点
                        this.tlSysObject.FocusedNodeChanged -= tlSysObject_FocusedNodeChanged;
                        this.tlSysObject.BeginUpdate();    //  停止控件刷新

                        foreach (CDictObject obj in frm.DataObjectList)
                        {
                            TreeListNode onode = rnode.Nodes.Add(new object[] { obj.Code, obj.Name, obj.Object, obj.UsedFlag, obj.ModuleCode });
                            onode.Tag = obj;
                        }
                        this.tlSysObject.FocusedNodeChanged += tlSysObject_FocusedNodeChanged;
                        this.tlSysObject.EndUpdate();       //  控件刷新从BeginUpdate开始的改变
                    }
                    frm.Dispose();
                }
            }
        }