Python 写上机日志及发送邮件

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

Python 写上机日志及发送邮件

import clr
#添加对cloud插件开发的常用组件的引用
clr.AddReference('System')
clr.AddReference('System.Data')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.App.Core')
clr.AddReference('Kingdee.BOS.App')
clr.AddReference('Kingdee.BOS.Log')
clr.AddReference('Kingdee.BOS.ServiceHelper')
#导入cloud基础库中的常用实体对象(分命名空间导入,不会递归导入)
from Kingdee.BOS import *
from Kingdee.BOS.App import *
from Kingdee.BOS.App.Core import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Computing import *
from Kingdee.BOS.Contracts import *
from Kingdee.BOS.Core.Log import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.Log import *
from Kingdee.BOS.ServiceHelper import *
from Kingdee.BOS.Util import *
from System import *
from System.Data import *
from System.Collections.Generic import *
from System.ComponentModel import *


def AfterBindData(e):
    fid=this.View.OpenParameter.GetCustomParameter("fid"); 
    fzz=this.View.OpenParameter.GetCustomParameter("fzz"); 
    fzd=this.View.OpenParameter.GetCustomParameter("fzd");     
    this.View.Model.SetValue("FID",fid)
    this.View.Model.SetValue("FZZ",fzz)
    this.View.Model.SetValue("FZD",fzd) 
    this.View.UpdateView('F_xgxm');
    this.View.UpdateView('FZZ'); 
    this.View.UpdateView('FZD');    
    this.View.UpdateView('FID');
    this.Model.SetValue('F_xgxm','66912de32826b3');
    this.View.GetControl("F_xgzd").SetFocus();
    return;

def DataChanged(e):
    if e.OldValue!=e.NewValue:
        this.View.UpdateView(e.Field.Key)

def ButtonClick(e):
    key=e.Key.ToUpper();
    fid=this.View.OpenParameter.GetCustomParameter("fid"); 
    zz=this.View.OpenParameter.GetCustomParameter("fzz"); 
    zd=this.View.OpenParameter.GetCustomParameter("fzd"); 
    zdlx ="bywb"; 
    #this.View.ShowNotificationMessage(str(key)+str(fid));
    if(key=="F_X_BUTTON_QD".ToUpper()):
        newValue=this.View.Model.GetValue("F_xgzd")
        if zdlx=="byid":xz="'"+str(newValue.id)+"'" 
        if zdlx=="byno":xz="'"+str(newValue.number)+"'" 
        if zdlx=="bywb":xz=str(newValue)      
        if  xz is None:return;
        # 写个上机操作日志
        logObjs = List[LogObject]()
        log = LogObject()
        log.Description = "当前声明的操作人:{0}".format(xz)
        log.OperateName = "操作名称"
        log.ObjectTypeId = this.View.BillBusinessInfo.GetForm().Id
        log.SubSystemId = this.View.BillBusinessInfo.GetForm().SubsysId
        log.Environment = OperatingEnvironment.BizOperate
        logObjs.Add(log)
        LogServiceHelper.BatchWriteLog(this.View.Context, logObjs)
        LogServiceHelper.WriteLog(this.View.Context, log)
        
        # 给当前用户发个邮件
        userId = this.View.Context.UserId
        email = SendMailService().GetEmailMessageInfoByUserId(this.View.Context, userId)
        if email is not None:
            email.To = List[str](["xxx@163.com","yyy@263.com"])
            email.Subject = "当前声明的操作人:{0}".format(xz)
            email.Body = "Powered by KD"
            MailUtils.Sendmail(email)
        msg="使用登记完成"
        this.View.ReturnToParentWindow(msg);#将构建的列表数据返回父页面
        this.View.Close();

相关C#代码见

#星空云诊所#在开发中使用并行多线程操作一定能提高运行速度吗? (kingdee.com)

https://wenku.my7c.com/article/310770015119715840?productLineId=1&lang=zh-CN


Python 写上机日志及发送邮件

import clr#添加对cloud插件开发的常用组件的引用clr.AddReference('System')clr.AddReference('System.Data')clr.AddReference('Kingdee.B...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息