Esempio n. 1
0
        public override void AfterCreateNewData(EventArgs e)
        {
            long personID = 0;

            base.AfterCreateNewData(e);
            string formId = "BD_Department";//部门FORMID

            Kingdee.BOS.Core.Metadata.FormMetadata formMetaData = MetaDataServiceHelper.GetFormMetaData(this.View.Context, formId);
            List <long> OrgIds = new List <long>();

            OrgIds.Add(this.Context.CurrentOrganizationInfo.ID);
            DataRuleFilterParamenter filterParameter = new DataRuleFilterParamenter(formId)
            {
                PermissionItemId = Kingdee.BOS.Core.Permission.PermissionConst.View,//查看权限项
                SubSystemId      = formMetaData.BusinessInfo.GetForm().SubsysId,
                BusinessInfo     = formMetaData.BusinessInfo,
                IsLookUp         = true,//是否基础资料权限
                bzIsolateOrgIds  = OrgIds,
                //OrgId = this.Context.CurrentOrganizationInfo.ID,
                ParentFormId = "PAEZ_DisPlayShow"//货架陈列展示FORMID
            };

            DataRuleFilterObject filterObject = PermissionServiceHelper.LoadDataRuleFilter(this.View.Context, filterParameter);//获取权限过滤条件

            Kingdee.BOS.Core.SqlBuilder.QueryBuilderParemeter queryParameter = new Kingdee.BOS.Core.SqlBuilder.QueryBuilderParemeter
            {
                FormId              = formId,
                BusinessInfo        = formMetaData.BusinessInfo,
                PermissionItemId    = Kingdee.BOS.Core.Permission.PermissionConst.View,
                FilterClauseWihtKey = filterObject.FilterString,//过滤条件
            };

            Kingdee.BOS.Orm.DataEntity.DynamicObject[] stockObjects = BusinessDataServiceHelper.Load(this.View.Context, formMetaData.BusinessInfo.GetDynamicObjectType(), queryParameter);
            if (stockObjects.Count() > 0)
            {
                string strSql = string.Format(@"/*dialect*/SELECT FLINKOBJECT FROM T_SEC_USER WHERE FUSERID = {0}", this.View.Context.UserId);
                personID = DBUtils.ExecuteScalar <long>(this.View.Context, strSql, 0, null);
                if (personID > 0)
                {
                    string searchSql = string.Format(@"SELECT COUNT(1) FROM USER_TABLES WHERE TABLE_NAME = 'TABLE{0}'", personID);
                    int    num       = DBUtils.ExecuteScalar <int>(this.View.Context, searchSql, 0, null);
                    if (num > 0)
                    {
                        string dropSql = string.Format(@"/*dialect*/drop table TABLE{0}", personID);
                        DBUtils.Execute(this.View.Context, dropSql);
                    }
                    string createSql = string.Format(@"/*dialect*/create table TABLE{0}
(
  DEPTID NUMBER(10) not null,
  DEPTNAME   NVARCHAR2(255) not null
)", personID);
                    DBUtils.Execute(this.View.Context, createSql);
                    object[] stockId   = (from c in stockObjects select c[0]).ToArray();
                    string   ids       = string.Join(",", stockId);
                    string   insertSql = string.Format(@"/*dialect*/INSERT INTO TABLE{0} SELECT DEPT.FDEPTID,DEPTL.FNAME FROM T_BD_DEPARTMENT DEPT INNER JOIN T_BD_DEPARTMENT_L DEPTL ON DEPT.FDEPTID = DEPTL.FDEPTID WHERE DEPT.FDEPTID IN ({1})", personID, ids);
                    DBUtils.Execute(this.View.Context, insertSql);
                }
            }
            JSONObject webobj = new JSONObject();

            webobj["source"] = string.Format(@"http://221.180.255.112:9000/taoli/action2/delivery_deliveryLinebMapWeb.action?orgID={0}&orgName={1}&personID={2}", this.View.Context.CurrentOrganizationInfo.ID, this.View.Context.CurrentOrganizationInfo.Name, personID);
            webobj["height"] = 545;
            webobj["width"]  = 810;
            webobj["isweb"]  = true; //是否新弹出一个浏览器窗口(or选项卡)打开网页地址
            webobj["title"]  = "金蝶官网";
            this.View.AddAction("ShowKDWebbrowseForm", webobj);
            this.View.SendDynamicFormAction(this.View);
            this.View.Close();
        }
        protected override void Bump()
        {
            FormMetadata formMetaData = MetaDataServiceHelper.GetFormMetaData(base.Context, "CRM_OPP_Opportunity");

            base.SetBumpData("CRM_OPP_Opportunity", formMetaData);
        }
Esempio n. 3
0
        private string SubmitWorkflow(Context ctx, string formId, string pKValue, string receiverName, string actionResult, string disposition, bool isApprovalFlow)
        {
            string  reason = "";
            DataSet ds     = DBUtils.ExecuteDataSet(ctx, @"select b.FASSIGNID,b.FAPPROVALASSIGNID,a.FACTINSTID,a.FRECEIVERNAMES
                                from t_wf_assign a 
                                join T_WF_APPROVALASSIGN b on a.fassignid=b.fassignid 
                                where b.Fobjecttypeid=@FormID 
                                and b.Fkeyvalue=@pKValue and a.FSTATUS=0",
                                                    new List <SqlParam>
            {
                new SqlParam("@FormID", DbType.String, formId),
                new SqlParam("@pKValue", DbType.String, pKValue)
            });
            DataRow row = ds.Tables[0].Rows.Cast <DataRow>().FirstOrDefault(dr => dr["FRECEIVERNAMES"].ToString().Split(',').Any(r => r == receiverName));

            if (row == null)
            {
                reason = "未找到待办任务";

                return(reason);
            }



            string        assignId         = row["FASSIGNID"].ToString();
            string        approvalAssignId = row["FAPPROVALASSIGNID"].ToString();
            string        _approvalItemId  = AssignmentServiceHelper.OpenApprovalItem(ctx, ctx.UserId, assignId, false);
            FormMetadata  formMetadata     = MetaDataServiceHelper.GetFormMetaData(ctx, formId);
            DynamicObject ObjData          = BusinessDataServiceHelper.LoadSingle(ctx, pKValue, formMetadata.BusinessInfo.GetDynamicObjectType());
            BusinessInfo  businessInfo     = formMetadata.BusinessInfo;

            var _approvalItem = AssignmentServiceHelper.GetApprovalItemById(ctx, _approvalItemId);

            if (_approvalItem == null)
            {
                reason = "待办任务所在的流程实例不在运行中,不能进行处理!";
                return(reason);
            }
            _approvalItem.ObjData        = ObjData;
            _approvalItem.ReceiverPostId = 0;
            _approvalItem.ActionResult   = actionResult;
            _approvalItem.Disposition    = disposition.ToString();
            AssignResult assignResult = _approvalItem.Actions != null?_approvalItem.Actions.FirstOrDefault(i => i.Id == actionResult) : null;

            AssignResultApprovalType approvalType = assignResult != null ? assignResult.ApprovalType : AssignResultApprovalType.None;

            _approvalItem.ActionResultType = approvalType;
            _approvalItem.Status           = ApprovalItemStatus.Completed;
            DateTime timeNow = TimeServiceHelper.GetSystemDateTime(ctx);

            _approvalItem.CompletedTime = timeNow;

            ObjectActivityInstance _activityInstance = AssignmentServiceHelper.ConvertActivityModel(
                ctx, businessInfo, approvalAssignId, _approvalItem);

            var option = OperateOption.Create();

            if (isApprovalFlow)
            {
                ApprovalAssignmentContext assignCtx = new ApprovalAssignmentContext()
                {
                    ApprovalItems = new List <ApprovalItem>()
                    {
                        _approvalItem
                    },
                    Info   = businessInfo,
                    Option = option
                };
                assignCtx.NextActHandler   = null;
                assignCtx.RejectReturn     = false;
                assignCtx.ActivityInstance = _activityInstance;
                if (actionResult == AssignResultApprovalType.Reject.ToString())
                {
                    var _policy           = AssignmentServiceHelper.GetApprovalAssignByAssignId(ctx, assignId);
                    var nextHandleWrapper = new Kingdee.BOS.ApprovalFlow.PlugIns.Mobile.MobNextHandleWrapper(assignId, ctx, _policy);
                    assignCtx.Target = nextHandleWrapper.RejectActivityModel.ActivityId;
                }
                ApprovalAssignmentServiceHelper.SubmitApprovalItem(ctx, assignCtx);
                reason = "";
                return(reason);
            }
            else
            {
                ApprovalAssignmentContext assignCtx = new ApprovalAssignmentContext()
                {
                    ApprovalItems = new List <ApprovalItem>()
                    {
                        _approvalItem
                    },
                    Info   = businessInfo,
                    Option = option
                };
                assignCtx.NextActHandler   = null;
                assignCtx.RejectReturn     = false;
                assignCtx.ActivityInstance = _activityInstance;
                ApprovalAssignmentServiceHelper.SubmitApprovalItem(ctx, assignCtx);
                reason = "";
                return(reason);
            }

            //if (actionResult == AssignResultApprovalType.Reject.ToString())
            //{
            //    string actInstId = row["FACTINSTID"].ToString();
            //    Kingdee.BOS.Workflow.App.Core.ProcInstService procInstService = new Kingdee.BOS.Workflow.App.Core.ProcInstService();
            //    var rejectActivityIds = procInstService.GetBackActInstList(ctx, actInstId, true).Select(r => r.ActivityId);
            //    if (!rejectActivityIds.Any())
            //    {

            //        reason = "无驳回节点";
            //        return reason;
            //    }
            //    assignCtx.Target = rejectActivityIds.FirstOrDefault();
            //}
        }