protected void Insert_Click(object sender, EventArgs e)
    {
        DataClassesDataContext dc = new DataClassesDataContext();

        string confirmValue = Request.Form["confirm_value"]; // get the answer of the user decide.

        if (confirmValue != "Yes")                           // if no then do nothing.
        {
            return;
        }

        if (DocDList.Items.Count == 0)
        {
            Response.Write("<script>alert('There is no document to add workflow to it');</script>");
            return;
        }
        try
        {
            // get the last department to permet user from adding it to workflow again.
            var getLastDept = from w in dc.WorkflowDocuments
                              where w.IdStep == int.Parse(ViewState["Count"].ToString()) &&
                              w.IdDoc == int.Parse(DocDList.SelectedValue)
                              select w;
            int lastDept = 0;
            foreach (var item in getLastDept)
            {
                lastDept = item.IdDept;
            }

            if (lastDept == int.Parse(DeptInsertDList.SelectedValue))// same department as last one permet this .
            {
                Response.Write("<script>alert('You can not insert the same department again');</script>");
                return;
            }

            WorkflowDocument workflow = new WorkflowDocument
            {
                IdStep = int.Parse(ViewState["Count"].ToString()) + 1,
                IdDept = int.Parse(DeptInsertDList.SelectedValue),
                IdDoc  = int.Parse(DocDList.SelectedValue)
            };
            dc.WorkflowDocuments.InsertOnSubmit(workflow);
            dc.SubmitChanges();
            WorkflowGridView.DataBind();
            Response.Write("<script>alert('Done.');</script>");

            StepLabel.Text = (int.Parse(ViewState["Count"].ToString()) + 2).ToString();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message + "');</script>");
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// 输出流程模板包、流程模板
        /// </summary>
        public JsonResult RegisterActivityTemplateConfigs(string WorkflowCode, int WorkflowVersion, string InstanceID)
        {
            return(ExecuteFunctionRun(() =>
            {
                WorkflowCode = Server.UrlDecode(WorkflowCode); //解决WorkflowCode为汉字的情景
                ActivityTemplateConfigsViewModel model = new ActivityTemplateConfigsViewModel();
                if ((WorkflowCode == null || WorkflowCode == "") && WorkflowVersion == -1)
                {
                    Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(InstanceID);
                    if (InstanceContext != null)
                    {
                        WorkflowCode = InstanceContext.WorkflowCode;
                        WorkflowVersion = InstanceContext.WorkflowVersion;
                        model.InstanceContext = InstanceContext;
                        model.ExceptionActivities = this.ExceptionActivities(InstanceID);
                    }
                }

                #region 是否锁定
                model.IsControlUsable = BizWorkflowPackageLockByID(WorkflowCode);
                #endregion

                #region 流程模板

                WorkflowDocument WorkflowTemplate = null;
                if (WorkflowVersion == WorkflowDocument.NullWorkflowVersion)
                {
                    WorkflowTemplate = this.Engine.WorkflowManager.GetDraftTemplate(WorkflowCode);
                }
                else
                {
                    WorkflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(WorkflowCode, WorkflowVersion);
                }

                #endregion

                #region 数据模型

                //数据项
                List <string> lstDataItems = new List <string>();
                //所有属性
                List <object> lstProperties = new List <object>();
                //输出到前台的数据项
                List <object> lstFrontDataItems = new List <object>();
                //允许设置权限的数据项
                List <string> lstPermissionDataItems = new List <string>();

                //参与者数据项
                List <string> lstUserDataItems = new List <string>();
                //逻辑型数据项
                List <string> lstBoolDataItems = new List <string>();

                //业务方法名称列表
                List <string> lstBizMethodNames = new List <string>();
                List <object> lstAllDataItems = new List <object>();//系统数据项,+流程数据项,流程设计选择时使用

                WorkflowClause Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);
                if (Clause != null && Clause.BizSchemaCode != null)
                {
                    //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "ClauseName", "var ClauseName=" + JSSerializer.Serialize(Clause.DisplayName + string.Empty) + ";", true);
                    model.ClauseName = Clause.WorkflowName + string.Empty;
                    //流程模板浏览页面地址
                    // ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "WorkflowViewUrl", "var WorkflowViewUrl=" + JSSerializer.Serialize(GetPortalRoot(this.Page) + ConstantString.PagePath_WorkflowDesigner) + ";", true);
                    model.WorkflowViewUrl = PortalRoot + ConstantString.PagePath_WorkflowDesigner;
                    DataModel.BizObjectSchema BizObject = this.Engine.BizObjectManager.GetDraftSchema(Clause.BizSchemaCode);
                    if (BizObject != null)
                    {
                        //流程包
                        object Package = new
                        {
                            SchemaCode = BizObject.SchemaCode
                        };
                        //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "Package", "var Package=" + JSSerializer.Serialize(Package) + ";", true);
                        model.Package = Package;

                        #region 页标签

                        if (Clause != null)
                        {
                            string TabName = string.IsNullOrEmpty(Clause.WorkflowName) ? Clause.WorkflowCode : Clause.WorkflowName;
                            if (WorkflowVersion != WorkflowDocument.NullWorkflowVersion)
                            {
                                TabName += "[" + WorkflowVersion + "]";
                            }
                            else
                            {
                                TabName += "[设计]";
                            }
                            //SetTabHeader(TabName);//前台执行
                            model.TabName = TabName;
                        }

                        #endregion

                        List <object> lstBizMethods = new List <object>();
                        //可选的业务方法
                        if (BizObject.Methods != null)
                        {
                            foreach (var Method in BizObject.Methods)
                            {
                                if (!DataModel.BizObjectSchema.IsDefaultMethod(Method.MethodName) && Method.MethodType == DataModel.MethodType.Normal)
                                {
                                    lstBizMethodNames.Add(Method.MethodName);
                                    lstBizMethods.Add(new { Text = Method.FullName, Value = Method.MethodName });
                                }
                            }
                        }
                        model.BizMethods = lstBizMethods;
                        //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "BizMethods", "var BizMethods=" + JSSerializer.Serialize(lstBizMethods.ToArray()) + ";", true);

                        #region  数据项、参与者、逻辑型数据项
                        //数据项、参与者、逻辑型数据项
                        if (BizObject.Properties != null)
                        {
                            List <Object> listNotifyCondition = new List <object>();
                            List <Object> listApprovalDataItem = new List <object>();
                            List <Object> listCommentDataItem = new List <object>();

                            listNotifyCondition.Add(new { Text = string.Empty, Value = string.Empty });
                            listApprovalDataItem.Add(new { Text = string.Empty, Value = string.Empty });
                            listCommentDataItem.Add(new { Text = string.Empty, Value = string.Empty });

                            foreach (DataModel.PropertySchema Property in BizObject.Properties)
                            {
                                //不显示保留数据项
                                if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name))
                                {
                                    lstDataItems.Add(Property.Name);
                                    lstProperties.Add(new
                                    {
                                        Text = Property.DisplayName,
                                        Value = Property.Name
                                    });

                                    lstFrontDataItems.Add(new
                                    {
                                        Text = Property.DisplayName,
                                        Value = Property.Name,
                                        //标记子表标题行
                                        ItemType = Property.LogicType == Data.DataLogicType.BizObjectArray ? "SubTableHeader" : string.Empty
                                    });
                                    lstPermissionDataItems.Add(Property.Name);



                                    //通知条件 TODO
                                    // sltNotifyCondition.Items.Add(new ListItem(Property.DisplayName, Property.Name));
                                    listNotifyCondition.Add(new { Text = Property.DisplayName, Value = Property.Name });

                                    //子表
                                    if ((Property.LogicType == Data.DataLogicType.BizObject || Property.LogicType == Data.DataLogicType.BizObjectArray) &&
                                        Property.ChildSchema != null && Property.ChildSchema.Properties != null)
                                    {
                                        foreach (DataModel.PropertySchema ChildProperty in Property.ChildSchema.Properties)
                                        {
                                            if (!DataModel.BizObjectSchema.IsReservedProperty(ChildProperty.Name))
                                            {
                                                lstFrontDataItems.Add(new
                                                {
                                                    Text = Property.DisplayName + "." + ChildProperty.DisplayName,
                                                    Value = Property.Name + "." + ChildProperty.Name
                                                });
                                                lstPermissionDataItems.Add(Property.Name + "." + ChildProperty.Name);
                                            }
                                        }
                                    }
                                    //参与者
                                    else if (Property.LogicType == Data.DataLogicType.SingleParticipant ||
                                             Property.LogicType == Data.DataLogicType.MultiParticipant)
                                    {
                                        lstUserDataItems.Add(Property.Name);
                                    }
                                    //逻辑型
                                    else if (Property.LogicType == Data.DataLogicType.Bool)
                                    {
                                        lstBoolDataItems.Add(Property.Name);
                                        //TODO
                                        listApprovalDataItem.Add(new { Text = Property.DisplayName, Value = Property.Name });
                                    }
                                    //文本
                                    else if (Property.LogicType == Data.DataLogicType.String)
                                    {
                                        listCommentDataItem.Add(new { Text = Property.DisplayName, Value = Property.Name });
                                    }

                                    //else if (Property.LogicType == Data.DataLogicType.TimeSpan)
                                    //    sltAllowedTime.Items.Add(new ListItem(Property.DisplayName, Property.Name));
                                }
                            }
                            model.NotifyCondition = listNotifyCondition;
                            model.ApprovalDataItem = listApprovalDataItem;
                            model.CommentDataItem = listCommentDataItem;
                        }

                        #endregion

                        #region 关联对象权限

                        if (BizObject.Associations != null)
                        {
                            foreach (DataModel.BizObjectAssociation association in BizObject.Associations)
                            {
                                DataModel.BizObjectSchema AssociatedSchema = this.Engine.BizObjectManager.GetPublishedSchema(association.AssociatedSchemaCode);
                                if (AssociatedSchema != null && AssociatedSchema.Properties != null)
                                {
                                    lstFrontDataItems.Add(new
                                    {
                                        Text = association.DisplayName,
                                        Value = association.Name,
                                        //标记子表标题行
                                        ItemType = "SubTableHeader"
                                    });
                                    lstPermissionDataItems.Add(association.Name);

                                    foreach (DataModel.PropertySchema AssociatedChildProperty in AssociatedSchema.Properties)
                                    {
                                        if (!DataModel.BizObjectSchema.IsReservedProperty(AssociatedChildProperty.Name))
                                        {
                                            lstFrontDataItems.Add(new
                                            {
                                                Text = association.DisplayName + "." + AssociatedChildProperty.DisplayName,
                                                Value = association.Name + "." + AssociatedChildProperty.Name
                                            });
                                            lstPermissionDataItems.Add(association.Name + "." + AssociatedChildProperty.Name);
                                        }
                                    }
                                }
                            }
                        }

                        #endregion

                        #region 可选表单
                        //TODO
                        // sltSheetCodes.Items.Clear();
                        List <object> listSheetCodes = new List <object>();
                        Sheet.BizSheet[] Sheets = this.Engine.BizSheetManager.GetBizSheetBySchemaCode(Clause.BizSchemaCode);
                        if (Sheets != null)
                        {
                            foreach (Sheet.BizSheet Sheet in Sheets)
                            {
                                listSheetCodes.Add(new { Text = Sheet.DisplayName + "[" + Sheet.SheetCode + "]", Value = Sheet.SheetCode });
                            }
                        }
                        model.SheetCodes = listSheetCodes;
                        #endregion
                    }
                }
                model.DataItems = lstFrontDataItems;

                #endregion

                //设置可选的数据项 TODO 前台处理
                //SetDataItems(lstDataItems);

                #region 前置条件, Text前台需要解析多语言包
                // TODO
                List <object> listEntryCondition = new List <object>();
                listEntryCondition.Add(new { Text = "Designer.Designer_AnyOne", Value = (int)EntryConditionType.Any + string.Empty, Indext = 0 });
                listEntryCondition.Add(new { Text = "Designer.Designer_All", Value = (int)EntryConditionType.All + string.Empty, Index = 1 });
                model.EntryCondition = listEntryCondition;

                #endregion

                #region  步异步

                List <object> listSync = new List <object>();
                listSync.Add(new { Text = "Designer.Designer_Sync", Value = "true", Index = 0 });
                listSync.Add(new { Text = "Designer.Designer_Async", Value = "false", Index = 1 });
                model.SyncOrASync = listSync;
                #endregion

                #region 参与者策略
                //TODO
                List <object> listParAbNormalPolicy = GetParAbnormalPolicy();
                model.ParAbnormalPolicy = listParAbNormalPolicy;


                #endregion

                #region 发起者参与者策略
                List <object> listOriginatorParAbnormalPolicy = GetOriginatorParAbnormalPolicy();
                model.OriginatorParAbnormalPolicy = listOriginatorParAbnormalPolicy;
                #endregion

                #region 参与方式:单人/多人
                //TODO
                List <object> listParticipantMode = new List <object>();
                listParticipantMode.Add(new { Text = "Designer.Designer_Single", Value = (int)ActivityParticipateType.SingleParticipant + string.Empty, Index = 0 });
                listParticipantMode.Add(new { Text = "Designer.Designer_Mulit", Value = (int)ActivityParticipateType.MultiParticipants + string.Empty, Index = 1 });
                model.ParticipantMode = listParticipantMode;
                #endregion

                #region 可选参与方式:并行/串行
                //TODO
                List <object> listParticipateMethod = new List <object>();
                listParticipateMethod.Add(new { Text = "Designer.Designer_Parallel", Value = (int)ParticipateMethod.Parallel + string.Empty, Index = 0 });
                listParticipateMethod.Add(new { Text = "Designer.Designer_Serial", Value = (int)ParticipateMethod.Serial + string.Empty, Index = 1 });
                model.ParticipateMethod = listParticipateMethod;

                #endregion

                #region 提交时检查
                //TODO
                List <object> listSubmittingValidation = new List <object>();
                listSubmittingValidation.Add(new { Text = "Designer.Designer_NotCheck", Value = (int)SubmittingValidationType.None + string.Empty, Index = 0 });
                listSubmittingValidation.Add(new { Text = "Designer.Designer_CheckParticipant", Value = (int)SubmittingValidationType.CheckNextParIsNull + string.Empty, Index = 1 });
                model.SubmittingValidation = listSubmittingValidation;

                #endregion

                #region 子流程数据映射类型

                List <object> lstMapTypes = new List <object>();
                foreach (string WorkflowDataMapInOutType in Enum.GetNames(typeof(OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType)))
                {
                    //不需要使用InOutAppend
                    if (WorkflowDataMapInOutType != OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType.InOutAppend.ToString())
                    {
                        lstMapTypes.Add(new
                        {
                            Text = WorkflowDataMapInOutType,
                            Value = (int)Enum.Parse(typeof(OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType), WorkflowDataMapInOutType) + string.Empty
                        });
                    }
                }
                model.MapTypes = lstMapTypes;

                #endregion

                #region 表单锁
                //TODO

                List <object> listLockLevel = new List <object>();
                listLockLevel.Add(new { Text = "Designer.Designer_PopupManyPeople", Value = (int)LockLevel.Warning + string.Empty });
                listLockLevel.Add(new { Text = "Designer.Designer_ProhibitOneTime", Value = (int)LockLevel.Mono + string.Empty });
                listLockLevel.Add(new { Text = "Designer.Designer_CancelExclusive", Value = (int)LockLevel.CancelOthers + string.Empty });
                model.LockLevel = listLockLevel;

                #endregion

                #region 锁策略
                //TODO
                List <object> listLockPlicy = new List <object>();
                listLockPlicy.Add(new { Text = "Designer.Designer_NotLock", Value = (int)LockPolicy.None + string.Empty });
                listLockPlicy.Add(new { Text = "Designer.Designer_LockOpen", Value = (int)LockPolicy.Open + string.Empty });
                listLockPlicy.Add(new { Text = "Designer.Designer_LockRequest", Value = (int)LockPolicy.Request + string.Empty });
                model.LockPolicy = listLockPlicy;


                #endregion

                #region 超时策略
                //TODO
                List <object> listOvertimePolicy = new List <object>();
                listOvertimePolicy.Add(new { Text = "Designer.Designer_ExecuteStrategy", Value = (int)OvertimePolicy.None + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_Approval", Value = (int)OvertimePolicy.Approve + string.Empty });
                //超时审批拒绝,暂时关闭
                //listOvertimePolicy.Add(new { Text = "Designer.Designer_ApprovalVote", Value = (int)OvertimePolicy.Disapprove + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_AutoComplete", Value = (int)OvertimePolicy.Finish + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy1", Value = (int)OvertimePolicy.Remind1 + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy2", Value = (int)OvertimePolicy.Remind2 + string.Empty });
                //超时策略3,4在消息设置中去除,关闭
                //listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy3", Value = (int)OvertimePolicy.Remind3 + string.Empty });
                //listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy4", Value = (int)OvertimePolicy.Remind4 + string.Empty });
                model.OvertimePolicy = listOvertimePolicy;


                #endregion

                #region 数据项映射类型

                List <object> lstDataDisposalTypes = new List <object>();
                foreach (string DisposalTypeString in Enum.GetNames(typeof(DataDisposalType)))
                {
                    lstDataDisposalTypes.Add(new
                    {
                        Text = DisposalTypeString,
                        Value = (int)Enum.Parse(typeof(DataDisposalType), DisposalTypeString) + string.Empty
                    });
                }
                model.DataDisposalTypes = lstDataDisposalTypes;

                #endregion

                #region 初始化活动的数据权限

                if (WorkflowVersion == WorkflowDocument.NullWorkflowVersion && WorkflowTemplate != null && WorkflowTemplate.Activities != null)
                {//流程模板编码\显示名称
                    Dictionary <string, string> dicWorkflowNames = new Dictionary <string, string>();
                    //整理数据项权限
                    foreach (Activity Activity in WorkflowTemplate.Activities)
                    {
                        if (Activity is ParticipativeActivity)
                        {
                            ParticipativeActivity ParticipativeActivity = (ParticipativeActivity)Activity;

                            List <string> lstValidPermissionItemNames = new List <string>();
                            List <DataItemPermission> lstValidDataItemPermissions = new List <DataItemPermission>();
                            if (ParticipativeActivity.DataPermissions == null)
                            {
                                ParticipativeActivity.DataPermissions = lstValidDataItemPermissions.ToArray();
                            }

                            if (ParticipativeActivity.DataPermissions != null)
                            {
                                foreach (DataItemPermission DataItemPermission in ParticipativeActivity.DataPermissions)
                                {
                                    if (lstPermissionDataItems.Contains(DataItemPermission.ItemName))
                                    {
                                        lstValidDataItemPermissions.Add(DataItemPermission);
                                        lstValidPermissionItemNames.Add(DataItemPermission.ItemName);
                                    }
                                }
                            }

                            foreach (string ItemName in lstPermissionDataItems)
                            {
                                if (!lstValidPermissionItemNames.Contains(ItemName))
                                {
                                    lstValidDataItemPermissions.Add(new DataItemPermission()
                                    {
                                        ItemName = ItemName,
                                        Visible = true,
                                        MobileVisible = true
                                    });
                                    lstValidPermissionItemNames.Add(ItemName);
                                }
                            }

                            ParticipativeActivity.DataPermissions = lstValidDataItemPermissions.ToArray();
                        }
                        //子流程:获取流程模板显示名称
                        else if (Activity is SubInstanceActivity)
                        {
                            string _SubWorkflowCode = ((SubInstanceActivity)Activity).WorkflowCode;
                            if (!string.IsNullOrEmpty(_SubWorkflowCode) && !dicWorkflowNames.ContainsKey(_SubWorkflowCode.ToLower()))
                            {
                                WorkflowClause _SubClause = this.Engine.WorkflowManager.GetClause(_SubWorkflowCode);
                                dicWorkflowNames.Add(_SubWorkflowCode.ToLower(), _SubClause == null ? _SubWorkflowCode : _SubClause.WorkflowName);
                            }
                        }
                    }
                    //流程模板编码\显示名称
                    model.WorkflowNames = dicWorkflowNames;
                }

                #endregion
                model.WorkflowTemplate = WorkflowTemplate;

                #region 数据项

                model.DataItemsSelect = GetALLDataItems(WorkflowCode);
                #endregion

                return Json(model, JsonRequestBehavior.AllowGet);
            }));
        }
Exemplo n.º 3
0
        public void RaiseChangedLanguage()
        {
            this.SuspendLayout();

            //MenuSubList menuList = m_menuManager.GetMenu();
            List <MenuSub> menuList = m_menuController.LoadMenuHierachy();

            // Load buffer workflow document list.
            m_workflowDocumentList.Clear();
            for (int i = 0; i < menuList.Count; i++)
            {
                WorkflowDocument doc = WorkflowDocument.LoadDatabase(Common.CurrentDatabase, menuList[i].WORKFLOW_ID.NVL(String.Empty), Common.CurrentUserInfomation.UserCD);
                m_workflowDocumentList.Add(doc);
            }

            // Load Menu control.
            menuTree1.BeginUpdateMenuBar();
            menuTree1.ClearMenuBars();
            for (int i = 0; i < menuList.Count; i++)
            {
                MenuSub menuSub = menuList[i];

                MenuBar menuBar = new MenuBar();
                menuBar.Host = menuTree1;
                menuBar.Text = menuSub.MENU_SUB_DESC.NVL(string.Empty);
                menuBar.Tag  = menuSub;


                for (int iScreen = 0; iScreen < menuSub.MenuSubItemList.Count; iScreen++)
                {
                    MenuSubItemDTO menuSubItem = menuSub.MenuSubItemList[iScreen];

                    MenuItem menuItem = new MenuItem(menuBar);

                    DatabaseScreen dbScreen = m_databaseScreenCache[menuSubItem.SCREEN_CD.StrongValue];

                    if (dbScreen == null)
                    {
#if DEBUG
                        MessageDialog.ShowBusiness(this, "Not found screen code: " + menuSubItem.SCREEN_CD.StrongValue);
#endif
                        continue;
                    }
                    menuItem.Tag  = menuSubItem;
                    menuItem.Text = dbScreen.ScreenDescription.StrongValue;

                    ImageItem imgItem = m_imageCache.Get(dbScreen.ImageCD.NVL(String.Empty));
                    Image     img     = null;
                    if (imgItem != null)
                    {
                        img = imgItem.ImageBin;
                    }
                    if (img != null)
                    {
                        try
                        {
                            menuItem.Image = ImageHelper.GetThumbnailImage(img, 16, 16);
                        }
                        catch (Exception err)
                        {
                            MessageDialog.ShowBusiness(this, err.Message);
                        }
                    }
                    menuBar.MenuItems.Add(menuItem);
                }


                menuTree1.AddMenuBar(menuBar);
            }

            if (menuTree1.MenuBars.Count > 0)
            {
                menuTree1.MenuBarSelected = menuTree1.MenuBars[0];
            }

            menuTree1.EndUpdateMenuBar();

            // Load Favorite button
            flowFavorite.Controls.Clear();
            LoadFavorite();

            this.ResumeLayout(false);
        }