在sharepoint 2010 中,我们对条目item的数据进行修改时,首先需要将web.AllowUnsafeUpdates这个属性设置为true,也就是web.AllowUnsafeUpdates = true;
接下来就是对item的项进行赋值,例如item["columnname"]="value1";最后就是item.Update();
这样我们就完成了对一个条目item的数据修改。
然而前天发现了一个很严重的问题,当我们启动了版本控制之后,每当修改一次,就会产生一个新版本,并且把当前版本变成草稿或者待定状态,想了很久,最后发现item里面有两个update的方法,一个是item.Update(),另一个是item.SystemUpdate(false);这两种方法,都能够实现对数据进行修改,同时也有区别,
item.Update()是会产生新版本,item.SystemUpdate(false)则不会有新版本。
下面是不产生新版本的一个实例:
SPWeb web = SPContext.Current.Web;
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["我的文档"];
SPListItem item = list.GetItemById(7);
item["字段名称"] = "6";
item.SystemUpdate(false);
广州京微信息科技有限公司,微软sharepoint解决方案提供商。
@implementation UIScrollView (UITouch) - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { //if(!self.dragging) { [[self nextResponder] touchesBegan:touches withEvent:event]; } [super touchesBegan:touches withEvent:event]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { //if(!self.dragging) { [[self nextResponder] touchesMoved:touches withEvent:event]; } [super touchesMoved:touches withEvent:event]; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { //if(!self.dragging) { [[self nextResponder] touchesEnded:touches withEvent:event]; } [super touchesEnded:touches withEvent:event]; } @end
然后重写nextResponder的touch方法就可以了。
在软件构建构成中,一个请求可能被多个对象处理,但是每个请求在运行时只能有一个接收者,如果显示指定,将必不可少地带来请求发送者与接收者的紧密耦合。COR(Chain
of Reposibility)设计模式可以使请求的发送者不需要指定具体的接收者,让请求的接收者自己在运行时决定来处理请求,从而使两者解耦。
#include <iostream> class Request { public: Request(double m) :money(m) {}; double getMoney(){return money;} private: double money; }; class IHandle { public: IHandle(IHandle *p) :nextHandle(p) {} virtual bool IsAuthority(Request r)=0; virtual void doHandle(Request r)=0; protected: IHandle * nextHandle; }; class headmanHandle:public IHandle { public: headmanHandle(IHandle *p) :IHandle(p) {} bool IsAuthority(Request r); void doHandle(Request r); }; bool headmanHandle::IsAuthority(Request r) { if(r.getMoney()>500)return false; else return true; } void headmanHandle::doHandle(Request r) { if(IsAuthority(r)) { std::cout<<"The headman do the request,which the request money is"<<r.getMoney()<<std::endl; } else { nextHandle->doHandle(r); } } class DepartmentMHandle:public IHandle { public: DepartmentMHandle(IHandle *p) :IHandle(p) {} bool IsAuthority(Request r); void doHandle(Request r); }; bool DepartmentMHandle::IsAuthority(Request r) { if(r.getMoney()>5000)return false; else return true; } void DepartmentMHandle::doHandle(Request r) { if(IsAuthority(r)) { std::cout<<"The department manager do the request,which the request money is"<<r.getMoney()<<std::endl; } else { nextHandle->doHandle(r); } } class CompanyDMHandle:public IHandle { public: CompanyDMHandle(IHandle *p) :IHandle(p) {} bool IsAuthority(Request r); void doHandle(Request r); }; bool CompanyDMHandle::IsAuthority(Request r) { if(r.getMoney()>50000)return false; else return true; } void CompanyDMHandle::doHandle(Request r) { if(IsAuthority(r)) { std::cout<<"The company deputy manager do the request,which the request money is"<<r.getMoney()<<std::endl; } else { nextHandle->doHandle(r); } } class CompanyMHandle:public IHandle { public: CompanyMHandle(IHandle *p) :IHandle(p) {} bool IsAuthority(Request r); void doHandle(Request r); }; bool CompanyMHandle::IsAuthority(Request r) { if(r.getMoney()>500000)return false; else return true; } void CompanyMHandle::doHandle(Request r) { if(IsAuthority(r)) { std::cout<<"The company manager do the request,which the request money is "<<r.getMoney()<<std::endl; } else { std::cout<<"You are the boss of thie company!Because you use up"<<r.getMoney()<<std::endl; } } int main(int argc,char ** argv) { IHandle *p4=new CompanyMHandle(NULL); IHandle *p3=new CompanyDMHandle(p4); IHandle *p2=new DepartmentMHandle(p3); IHandle *p1=new headmanHandle(p2); Request r1(300); Request r2(3000); Request r3(30000); Request r4(300000); Request r5(3000000); p1->doHandle(r1); p1->doHandle(r2); p1->doHandle(r3); p1->doHandle(r4); p1->doHandle(r5); delete p1; delete p2; delete p3; delete p4; return 0; }
运行结果为
如果有兴趣可以继续浏览该系列文章:
singleton pattern--单件模式