金蝶基础类(KFO)及其应用.ppt_第1页
金蝶基础类(KFO)及其应用.ppt_第2页
免费预览已结束,剩余33页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

kfo及其应用,应用集成部,kfo的对象模型 数据打包对象 注册表对象 全局对象 其他对象,提纲,kfo的对象模型 数据打包对象 注册表对象 全局对象 其他对象,提纲,kfo的对象模型,kfo的对象模型 数据打包对象 注册表对象 全局对象 其他对象,提纲,数据打包对象,dictionary对象 dictword对象 vector对象 linkedlist对象 node对象 idmap对象 mapword对象 isorthelper接口,dictionary对象特点,dictionary对象是一个数据字典 字典里可以存放不同的变量,它可以是任一个单值变量,也可以是一个对象。 在dictionary对象中主要通过变量名称来进行索引的。 dictionary对象可以进行跨进程调度,跨进程调度可以采用值拷贝调度和引用调度 dictionary对象支持系列化和持久化,dictionary对象的属性,属性 property value(name as string) property name(index as long) as string property count as long property modified as boolean property marshaloptions as marshaloptionsenum property repeated as boolean byrefmarshal,dictionary对象的方法,方法 function clone() as dictionary function getvalue(name as string, default) as variant function lookup(name as string, value) as boolean sub remove(name as string) sub removeall() sub resetmodified() sub append(pdict as dictionary,byval bcloneobject as boolean) sub initmaxcount(nmaxcount as long) function cloneall() as dictionary function load(source) as boolean function save(dest) as boolean,vector对象的特点,vector对象相当于一个不定长的向量数组 每一个元素可以是任一个单值变量,也可以是一个对象 在vector对象中主要通过索引来进行数据访问的 vector对象可以进行跨进程调度,跨进程调度可以采用值拷贝调度和引用调度 vector对象支持系列化和持久化,vector对象的属性,属性 property item(index as long) as variant property size as long property array as variant property lbound as long property ubound as long property growby as long property byrefmarshal as boolean,vector对象的方法,方法 function add(item) as long sub insert(index as long, item) sub append(newvector as vector) sub remove(index as long, ncount as long = 1) sub removeall() function clone() as vector sub freeextra() function bsearch(itemtosearch, index as long, sorthelper as isorthelper) as boolean function search(itemtosearch, index as long, sorthelper as isorthelper) as boolean sub sort(first, last, sorthelper as isorthelper) function cloneall() as vector function load(source) as boolean function save(dest) as boolean,linkedlist对象的特点,linkedlist对象相当于一个单线链表 每一个节点可以是任一个单值变量,也可以是一个对象 在linkedlist对象中主要通过索引或节点前后关系来进行数据访问的 linkedlist对象可以进行跨进程调度,跨进程调度可以采用值拷贝调度和引用调度 linkedlist对象支持系列化和持久化,linkedlist对象的属性,属性 property item(index as long) as node property count as long property head as node property tail as node property byrefmarshal as boolean,linkedlist对象的方法,方法 function addhead(value) as node function addtail(value) as node sub appendhead(list as linkedlist) sub appendtail(list as linkedlist) function removehead() as variant function removetail () as variant sub removeall() function clone() as linkedlist function search(itemtosearch, sorthelper as isorthelper) as node function cloneall() as linkedlist function load(source) as boolean function save(dest) as boolean,node对象的属性和方法,属性 property container as linkedlist property previous as node property next as node property value as variant 方法 function insertbefore(value) as node function insertafter(value) as node sub remove(),idmap对象的特点,idmap对象是一个数据字典 字典里可以存放不同的变量,它可以是任一个单值变量,也可以是一个对象 在idmap对象中主要通过一个整数值来进行数据访问的 idmap对象可以进行跨进程调度,跨进程调度可以采用值拷贝调度和引用调度 idmap对象支持系列化和持久化 与dictionary对象的区别就在于dictionary用名称访问变量,而idmap实用一个整数值访问元素变量的,idmap对象的属性和方法,属性 property value(id as long) as variant property ids(index as long) as long property count as long byrefmarshal 方法 function clone() as idmap function getvalue(id as long, default) as variant function lookup(id as long, value) as boolean sub remove(id as long) sub removeall() function cloneall() as idmap function load(source) as boolean function save(dest) as boolean,isorthelper接口,isorthelper接口是一个辅助的接口,需要开发人员自己实现 isorthelper接口对象应用于vector对象的sort、bsearch、search以及linkedlist对象的search方法 对于vector对象的sort、bsearch、search以及linkedlist对象的search方法,如果调用过程中没有制定具体的isorthelper实现,则采用系统默认的单值比较大小关系,但是我们建议采用自己实现的isorthelper,实现自己真正意义上的大小比较 仅有一个方法需要实现: function compare(item1, item2) as long 当item1 “大于” item2时返回大于0的数,如1 当item1 “等于” item2时返回等于0的数,如0 当item1 “小于” item2时返回小于0的数,如-1 示例一,dictionary对象打包数据的性能问题,以前的性能问题:dictionary对象在打包数据在20000个以内时,人的感觉是能够接受的,但超过20000个时,明显的感觉很慢,数据越大,所需要的时间,特别是在记录集转化成指数函数的方式迅速递增为kfo的dictionary对象时 解决的办法:应用initmaxcount方法和repeated属性 initmaxcount方法:如果需要打包的数据个数超过20000个,最好先调用initmaxcount方法,预先一次性分配内存,以提高内存分配的速度。在结合应用repeated属性,大包的数据速度成几十上百乃上千的倍数提高具体倍数与打包的数据量有关,数据量越大,倍数越大。 repeated属性:指明关键字是否允许重复,true表示允许重复,false表示不允许,默认值为false。如果将repeated设置为true,调用者需自己处理关键字不重复的问题 示例二,进程间调度问题,属性byrefmarshal :在当前进程内是否允许该对象采用引用调度方式到其他进程,true表示允许,调度到另外进程后不会生成原对象的副本,false表示不允许,调度到另外进程后会生成原对象的副本。默认值为false。 采用引用调度的场景: 对于进程内的调用,无论byrefmarshal 为true或是false,此属性值被忽略,不做任何处理。 在进行跨进程调度的过程中如果对调度后的对象进行修改并希望反映到原对象时,才有将原对象的属性byrefmarshal设置为true,否则应该尽量设置为false,以减少调度的频次和数据流量。 常用于插件调试过程中 示例三,系列化处理,以前在用金蝶核心对象kfo进行编程过程中,碰到以下两个现象: 当用kfo.vector、kfo.dictionary及kfo.linkedlist对象进行数据打包时,在vb及.net中的变量查看中均无法看到内部的数据及其结构,只能看到最上一级的对象所包含的元素个数,给调试带来不方便性 在用msmq消息对象msmqmessage、vb的propertybag对象时,直接使用kfo.vector、kfo.dictionary及kfo.linkedlist对象进行处理时提示错误 主要是因为原有kfo的vector、dictionary、linkedlist以及idmap对象没有支持系列化。从k/3 v10.2已经支持 示例四,克隆复制,clone与cloneall clone方法,只对本身一级内数据进行复制,对vector、dictionary、linkedlist以及idmap对象以及其他的可系列化对象的多层次嵌套时,只对vector、dictionary、linkedlist以及idmap对象以及其他的可系列化对象进行简单引用,不是完全意义上的数据复制克隆。 完全意义上的克隆复制,包含内嵌的其他可系列化队象,形成一个全新真正副本。但如果包含的对象不是一个持久化的对象,还是保留其原有的引用关系。 示例五,持久化处理,支持持久化有两个方法: function save(dest) as boolean 将对象数据存储到目标中 dest为一字串时,save方法会自动检查该字串是否为路径文件,若是路径文件,则保存为文件,否则将对象保存为一字串形式;若为variant变体应该代表的是字节数组,文件、字符串、对象流(stream),否则默认保存为字节数组 save 从源对象装载数据 dest为一字串时,load方法会自动检查该字串为文件路径,若是文件路径,则从文件中装载数据,否则从字串中装载数据;若为variant变体应该代表的是字节数组、文件、字符串、对象流(stream),且为通过对用的save方法生成的数据,否则会报错“无效的过程对象或参数” 示例六,kfo的对象模型 数据打包对象 注册表对象 全局对象 其他对象,提纲,reg对象特点,封装在kfo中的reg对象是的操作对象是windows系统的注册表 通过它来操纵我们k/3系统的一些系统内部的注册表内容 可以对通用windows注册表的项、值进行增加、删除、修改、查找等操作,reg对象的属性和方法(一),属性 property companyname as string 方法 sub addkey(keyname as string) function getkeyvalue(key as string, entry as string, default) as variant sub setkeyvalue(key as string, entry as string, value) sub deletekey(keyname as string) sub deletekeyvalue(key as string, entry as string) function keyexists(keyname as string) as boolean,reg对象的属性和方法(二),方法 function getsystemsetting(appname as string, section as string, entry as string, default) as variant sub setsystemsetting(appname as string, section as string, entry as string, value) sub deletesystemsetting(appname as string, section, entry) function getusersetting(appname as string, section as string, entry as string, default) as variant sub setusersetting(appname as string, section as string, entry as string, value) sub deleteusersetting(appname as string, section, entry),kfo的对象模型 数据打包对象 注册表对象 全局对象 其他对象,提纲,globals全局对象(一),该对象主要提供vb未能提供的一些公用函数 该对象属于全局对象,只要vb引用kfo,直接可用该对象的函数,不许创建此对象 属性 property reg as reg,globals全局对象(二),方法 function ascat(string as string, index as long) as integer function cnulls(value, default) as variant function ascata(string as string, index as long) as integer function lefta(string as string, length as long) as string function lena(string as string) as long function mida(string as string, start as long, length) as string function righta(string as string, length as long) as string function createenumerator(walkvariant as iwalkvariant) as u

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论