PortalPage.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:24k
源码类别:
OA系统
开发平台:
C#
- using System;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// 所有页面的基类
- /// </summary>
- public class PortalPage : System.Web.UI.Page
- {
- public PortalPage()
- {
- }
- public const string LackOfAuth = "您不具备该操作的权限";
- public const string PageName_Login = "Login.aspx";
- public const string PageName_CancelInstance = "CancelInstance.aspx";
- public const string PageName_EditCompany = "EditCompany.aspx";
- public const string PageName_EditOrganizationUnit = "EditOrganizationUnit.aspx";
- public const string PageName_EditOrganization = "EditOrganization.htm";
- public const string PageName_EditGroup = "EditGroup.aspx";
- public const string PageName_EditUser = "EditUser.aspx";
- public static string GetEditPageName(OThinker.Organization.UnitType UnitType, string ID)
- {
- switch (UnitType)
- {
- case OThinker.Organization.UnitType.Company:
- return PageName_EditCompany + "?" + Param_ID + "=" + ID;
- case OThinker.Organization.UnitType.OrganizationUnit:
- return PageName_EditOrganizationUnit + "?" + Param_ID + "=" + ID;
- case OThinker.Organization.UnitType.Group:
- return PageName_EditGroup + "?" + Param_ID + "=" + ID;
- case OThinker.Organization.UnitType.User:
- return PageName_EditUser + "?" + Param_ID + "=" + ID;
- default:
- throw new NotImplementedException();
- }
- }
- public const string PageName_SetPassword = "SetPassword.aspx";
- public const string PageName_RemoveUnit = "RemoveUnit.aspx";
- public const string PageName_SyncAD = "SyncAD.aspx";
- public const string PageName_SyncUser = "SyncUser.aspx";
- public const string PageName_SyncAllUsers = "SyncAllUsers.aspx";
- public const string PageName_EditTitle = "EditTitle.aspx";
- public const string PageName_EditUserTitle = "EditUserTitle.aspx";
- public const string PageName_QueryUser = "QueryUser.aspx";
- public const string PageName_QueryTransactionLog = "QueryTransactionLog.aspx";
- public const string PageName_InstanceStateChart = "InstanceStateChart.aspx";
- public const string PageName_ExceptionDetail = "ExceptionDetail.aspx";
- public const string PageName_QueryException = "QueryException.aspx";
- public const string PageName_AddInstanceAcl = "AddInstanceAcl.aspx";
- public const string PageName_WorkflowAcl = "WorkflowAcl.aspx";
- public const string PageName_UpdateWorkflowAcl = "UpdateWorkflowAcl.aspx";
- public const string PageName_UpdateSystemAcl = "UpdateSystemAcl.aspx";
- public const string PageName_InstanceDataTrack = "InstanceDataTrack.aspx";
- public const string PageName_ActivityReport = "ActivityReport.aspx";
- public const string PageName_Settings = "Settings.aspx";
- public const string PageName_InstanceAcl = "InstanceAcl.aspx";
- public const string PageName_InstanceDetail = "InstanceDetail.aspx";
- public const string PageName_InstanceDataReport = "InstanceDataReport.aspx";
- public const string PageName_EnabledActivity = "EnabledActivity.aspx";
- public const string PageName_MyInstance = "MyInstance.aspx";
- public const string PageName_MyDeptInstance = "MyDeptInstance.aspx";
- public const string PageName_MyHandledInstance = "MyHandledInstance.aspx";
- public const string PageName_MyWorkItem = "MyWorkItem.aspx";
- public const string PageName_MyDelegation = "MyDelegation.aspx";
- public const string PageName_NotifyMessage = "NotifyMessage.aspx";
- public const string PageName_QueryInstance = "QueryInstance.aspx";
- public const string PageName_QueryProject = "QueryProject.aspx";
- public const string PageName_InstanceToken = "InstanceToken.aspx";
- public const string PageName_InstanceData = "InstanceData.aspx";
- public const string PageName_QueryDelegation = "QueryDelegation.aspx";
- public const string PageName_HeapData = "HeapData.aspx";
- public const string PageName_QueryWorkItem = "QueryWorkItem.aspx";
- public const string PageName_StartInstance = "StartInstance.aspx";
- public const string PageName_WorkflowInfo = "WorkflowInfo.aspx";
- public const string PageName_SystemACL = "SystemACL.aspx";
- public const string PageName_UserReport = "UserReport.aspx";
- public const string PageName_UrgeInstance = "UrgeInstance.aspx";
- public const string PageName_InstanceSheets = "InstanceSheets.aspx";
- public const string PageName_UserSelector = "UserSelector.aspx";
- public const string PageName_ReadAttachment = "ReadAttachment.aspx";
- public const string PageName_MyNotification = "MyNotification.aspx";
- public const string PageName_NotificationDetail = "NotificationDetail.aspx";
- public const string PageName_EditForm = "EditForm.aspx";
- public const string PageName_EditProject = "EditProject.aspx";
- public const string PageName_DefaultSheet = "DefaultSheet.aspx";
- public const string PageName_WorkItemDetail = "WorkItemDetail.aspx";
- public const string PageName_ActionSheet = "ActionSheet.aspx";
- public const string PageName_QuerySchedule = "QuerySchedule.aspx";
- public const string PageName_WorkflowChart = "WorkflowChart.aspx";
- public const string PageName_AddWorkflowAcl = "AddWorkflowAcl.aspx";
- public const string PageName_SelectUser = "SelectUser.aspx";
- public const string PageName_SelectUserImage = "images/IB_SelectUser.GIF";
- public const string PageName_ActivateActivity = "ActivateActivity.aspx";
- public const string PageName_QueryInstanceByData = "QueryInstanceByData.aspx";
- public const string Param_ExpandPath = "ExpandPath";
- public const string Param_Q = "q";
- public const string Param_AttachmentID = "AttachmentID";
- public const string Param_UnitType = "UnitType";
- public const string Param_VisibleUnitType = "VisibleUnitType";
- public const string Param_VisibleType = "VisibleType";
- public const string Param_Description = "Description";
- public const string Param_Priority = "Priority";
- public const string Param_LeastRecurrences = "LeastRecurrences";
- public const string Param_OptionalConsultants = "OptionalConsultants";
- public const string Param_ProjectID = "ProjectID";
- public const string Param_NotificationID = "NotificationID";
- public const string Param_TrackID = "TrackID";
- public const string Param_TextBoxID = "TextBoxID";
- public const string Param_ControlID = "ControlID";
- public const string Param_SelectMode = "Mode";
- // 委托人
- public const string Param_Delegant = "Delegant";
- // 被委托人
- public const string Param_Delegatee = "Delegatee";
- public const string Param_Message = "Message";
- public const string Param_Mode = "Mode";
- public const string Param_State = "State";
- public const string Param_ItemName = "ItemName";
- public const string Param_InstanceId = "InstanceId";
- public const string Param_InstanceName = "InstanceName";
- public const string Param_WorkflowPackage = "WorkflowPackage";
- public const string Param_WorkflowName = "WorkflowName";
- public const string Param_WorkflowVersion = "WorkflowVersion";
- public const string Param_ExceptionID = "ExceptionID";
- public const string Param_AclID = "AclID";
- public const string Param_Alias = "Alias";
- public const string Param_From = "From";
- public const string Param_To = "To";
- public const string Param_Elapsed = "Elapsed";
- public const string Param_EstimatedElapsed = "EstimatedElapsed";
- // 工作项ID
- public const string Param_WorkItemID = "WorkItemID";
- // 目的活动
- public const string Param_DestActivityName = "DestActivityName";
- // 是否同意
- public const string Param_Approval = "Approval";
- public const string Param_Comment = "Comment";
- public const string Param_ParticipateGroup = "ParticipateGroup";
- // 是否是创建
- public const string Param_EditMode = "EditMode";
- public enum EditModeType
- {
- Create,
- Edit,
- Import
- }
- // 编辑的表单的名称
- public const string Param_FormName = "FormName";
- // 用户名
- public const string Param_UserID = "UserID";
- public const string Param_ID = "ID";
- public const string Param_ADUser = "ADUser";
- public const string Param_Parent = "Parent";
- public const string Param_ParentGroup = "ParentGroup";
- public const string Param_OriginateRole = "OriginateRole";
- public OThinker.H3.WorkflowTemplate.WorkflowTemplate GetWorkflow(
- string WorkflowPackageName,
- string WorkflowName,
- int WorkflowVersion)
- {
- string sessionName = OThinker.H3.WorkSheet.Sessions.GetWorkflow(
- WorkflowPackageName,
- WorkflowName,
- WorkflowVersion);
- if(this.Session[sessionName] == null)
- {
- this.Session[sessionName] = H3.Server.Engine.WorkflowManager.GetWorkflow(
- WorkflowPackageName,
- WorkflowName,
- WorkflowVersion);
- }
- return (H3.WorkflowTemplate.WorkflowTemplate)this.Session[sessionName];
- }
- // 获得当前登陆用户的Principal Name
- protected UserValidator UserValidator
- {
- get
- {
- return UserValidatorFactory.GetUserValidator(this);
- }
- }
- protected void NotifyMessage(string Message)
- {
- this.Response.Redirect(this.GetNotifyPage(Message));
- }
- protected string GetNotifyPage(string Message)
- {
- return "NotifyMessage.aspx" + "?" + "Message" + "=" + System.Web.HttpUtility.UrlEncode(Message);
- }
- /// <summary>
- /// 获得某一个表单的某一种操作对应的URL
- /// </summary>
- /// <param name="Mode"></param>
- /// <param name="Workflow"></param>
- /// <param name="SheetName"></param>
- /// <param name="InstanceId"></param>
- /// <returns></returns>
- public static string GetViewSheetUrl(
- WorkflowTemplate.Sheet Sheet,
- string InstanceId)
- {
- if (Sheet == null)
- {
- return null;
- }
- else
- {
- string baseUrl = GetSheetBaseUrl(Sheet.SheetType, Sheet.SheetAddress);
- return baseUrl +
- OThinker.H3.WorkSheet.SheetEnviroment.Param_Mode + "=" + WorkSheet.SheetMode.View + "&" +
- OThinker.H3.WorkSheet.SheetEnviroment.Param_InstanceId + "=" + InstanceId;
- }
- }
- public static string GetViewSheetUrl(WorkItem.WorkItem WorkItem)
- {
- string baseUrl = GetSheetBaseUrl(WorkItem.SheetType, WorkItem.SheetAddress);
- return baseUrl +
- OThinker.H3.WorkSheet.SheetEnviroment.Param_Mode + "=" + WorkSheet.SheetMode.View + "&" +
- OThinker.H3.WorkSheet.SheetEnviroment.Param_WorkItemID + "=" + WorkItem.WorkItemID;
- }
- public static string GetWorkSheetUrl(WorkItem.WorkItem WorkItem)
- {
- if (WorkItem == null)
- {
- return null;
- }
- else
- {
- string baseUrl = GetSheetBaseUrl(WorkItem.SheetType, WorkItem.SheetAddress);
- return baseUrl +
- OThinker.H3.WorkSheet.SheetEnviroment.Param_Mode + "=" + WorkSheet.SheetMode.Work + "&" +
- OThinker.H3.WorkSheet.SheetEnviroment.Param_WorkItemID + "=" + WorkItem.WorkItemID;
- }
- }
- public static string GetSheetBaseUrl(
- OThinker.H3.WorkflowTemplate.SheetType SheetType,
- string SheetAddress)
- {
- string baseUrl = null;
- switch (SheetType)
- {
- case OThinker.H3.WorkflowTemplate.SheetType.None:
- baseUrl = null;
- break;
- case OThinker.H3.WorkflowTemplate.SheetType.DefaultSheet:
- baseUrl = PageName_DefaultSheet + "?";
- break;
- case OThinker.H3.WorkflowTemplate.SheetType.CustomSheet:
- baseUrl = SheetAddress + "?";
- break;
- default:
- throw new NotImplementedException();
- }
- return baseUrl;
- }
- // 空元素只能设置为"",因为没有选中的值为""
- protected const string NullItemValue = "";
- protected bool IsSelectedNull(string SelectedValue)
- {
- if (
- SelectedValue == NullItemValue ||
- SelectedValue == "" ||
- SelectedValue == null)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- // 分析模板类型条件是否为空
- protected string ParseWorkflowPackage(string WorkflowPackage)
- {
- if (this.IsSelectedNull(WorkflowPackage))
- {
- return null;
- }
- else
- {
- return WorkflowPackage;
- }
- }
- protected string ParseWorkflowName(string WorkflowName)
- {
- if (this.IsSelectedNull(WorkflowName))
- {
- return null;
- }
- else
- {
- return WorkflowName;
- }
- }
- protected int ParseWorkflowVersion(string WorkflowVersion)
- {
- if (this.IsSelectedNull(WorkflowVersion))
- {
- return OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
- }
- else
- {
- try
- {
- return int.Parse(WorkflowVersion);
- }
- catch
- {
- return OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
- }
- }
- }
- #region 编辑组织结构的结果显示
- protected void NotifyResult(OThinker.Organization.HandleResult Result)
- {
- this.NotifyMessage(this.ParseResult(Result));
- }
- protected void NotifyResult(OThinker.Organization.HandleResult Result, bool Refresh, string ExpandPath)
- {
- string script_reload = null;
- if (Refresh)
- {
- script_reload =
- "var frm=this.parent.frames[1];" +
- "if(frm)" +
- "frm.window.location.href = '" + "EditOrganization.aspx?" + Param_ExpandPath + "=" + System.Web.HttpUtility.UrlEncode(ExpandPath) + "';";
- }
- string resultMessage = this.ParseResult(Result);
- string resultUrl = this.GetNotifyPage(resultMessage);
- string script =
- "<script>" +
- script_reload +
- "window.location.href='" + resultUrl + "'</script>";
- this.Response.Write(script);
- }
- protected string ParseResult(OThinker.Organization.HandleResult Result)
- {
- switch (Result)
- {
- case OThinker.Organization.HandleResult.ACTIVE_DIRECTORY_NOT_CONNECTED:
- return "无法连接到活动目录";
- case OThinker.Organization.HandleResult.ALIAS_INVALID:
- return "用户别名不合法";
- case OThinker.Organization.HandleResult.ALIAS_NULL:
- return "用户名为空";
- case OThinker.Organization.HandleResult.ALIAS_REDUPLICATE:
- return "用户名已经存在";
- case OThinker.Organization.HandleResult.CANNT_ITERATE_TO_COMPANY:
- return "无法从该组织单元路由到公司";
- case OThinker.Organization.HandleResult.CHILD_NOT_ALLOW_BELONG_TO_MULTI_GROUP:
- return "该组中存在某个组是其他组的子组,同时该子组又禁止了同时属于多个父组";
- case OThinker.Organization.HandleResult.COMPANY_INCONSISTENT:
- return "公司信息不一致";
- case OThinker.Organization.HandleResult.COMPANY_INVALIDATE:
- return "公司信息不合法";
- case OThinker.Organization.HandleResult.COMPANY_NOT_EXIST:
- return "指定的公司不存在";
- case OThinker.Organization.HandleResult.CYCLE_INVALIDATE:
- return "不允许有环状组织结构,请检查是否存在互相引用和间接的互相引用";
- case OThinker.Organization.HandleResult.DELEGANT_OR_DELEGATEE_NULL:
- return "委托人或者被委托人为空";
- case OThinker.Organization.HandleResult.DELEGATEE_EQUAL_DELEGANT:
- return "禁止委托给本人";
- case OThinker.Organization.HandleResult.EXTERNAL_ID_REDUPLICATE:
- return "外部ID重复";
- case OThinker.Organization.HandleResult.GROUP_CHILD_INVALIDATE:
- return "组成员不合法";
- case OThinker.Organization.HandleResult.GUID_REDUPLICATE:
- return "GUID重复";
- case OThinker.Organization.HandleResult.ID_INVALIDATE:
- return "ID不合法";
- case OThinker.Organization.HandleResult.ID_REDUPLICATE:
- return "ID重复";
- case OThinker.Organization.HandleResult.LOGIN_ACTIVE_DIRECTORY_FAILED:
- return "无法登录到活动目录,请检查登录活动目录的用户名和密码";
- case OThinker.Organization.HandleResult.MANAGER_INVALIDATE:
- return "经理属性设置不正确";
- case OThinker.Organization.HandleResult.NAME_INVALID:
- return "名称不合法";
- case OThinker.Organization.HandleResult.NAME_REDUPLICATE:
- return "出现重名错误";
- case OThinker.Organization.HandleResult.NOT_SUPPORT_UNIT:
- return "不支持这种类型";
- case OThinker.Organization.HandleResult.ORGANIZATION_UNIT_CYCLE_INVALIDATE:
- return "组织单元出现环,请检查是否存在互相引用和间接的互相引用";
- case OThinker.Organization.HandleResult.PARAM_IS_NULL:
- return "参数为空";
- case OThinker.Organization.HandleResult.PARENT_NULL:
- return "父属性设置为空";
- case OThinker.Organization.HandleResult.SECRETARY_INVALIDATE:
- return "秘书属性设置不正确";
- case OThinker.Organization.HandleResult.SUCCESS:
- return "成功";
- case OThinker.Organization.HandleResult.SUPERVISOR_INVALIDATE:
- return "监管人设置不正确";
- case OThinker.Organization.HandleResult.SYNCHRONING:
- return "正在同步";
- case OThinker.Organization.HandleResult.TITLE_NAME_DUPLICATE:
- return "职务名称重复";
- case OThinker.Organization.HandleResult.TITLE_NAME_NULL:
- return "职务名称为空";
- case OThinker.Organization.HandleResult.UNIT_ID_INVALIDATE:
- return "ID不正确";
- case OThinker.Organization.HandleResult.UNKNOWN_ERROR:
- return "未知的错误";
- case OThinker.Organization.HandleResult.USER_ALIAS_NOT_EXIST_IN_AD:
- return "用户名在活动目录中不存在";
- case OThinker.Organization.HandleResult.VICE_MANAGER_INVALIDATE:
- return "副经理设置不正确";
- default:
- return Result.ToString();
- }
- }
- #endregion
- #region 发起流程
- protected string OriginateInstance(string WorkflowPackage, string WorkflowName, int WorkflowVersion, Instance.PriorityType Priority, string InstanceName, string OriginateRole, System.Collections.Generic.Dictionary<string, object> ParameterTable)
- {
- string originator = this.UserValidator.UserID;
- string department = this.UserValidator.Department;
- // 检查该工作流是否存在
- OThinker.H3.WorkflowTemplate.WorkflowTemplate workflow = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
- WorkflowPackage,
- WorkflowName,
- WorkflowVersion);
- if (workflow == null)
- {
- this.NotifyMessage("该流程模板不存在!");
- }
- // 创建
- string instanceId = OThinker.H3.Server.Engine.InstanceManager.CreateInstance(
- WorkflowPackage,
- WorkflowName,
- WorkflowVersion,
- InstanceName,
- originator,
- null,
- department,
- false,
- OThinker.H3.Instance.InstanceContext.UnspecifiedID,
- null,
- Instance.Token.UnspecifiedID);
- // 判断是否创建失败
- if (instanceId == OThinker.H3.Instance.InstanceContext.UnspecifiedID)
- {
- this.NotifyMessage("无法创建流程:" + workflow.WorkflowFullName);
- }
- // 设置消息的紧急程度
- OThinker.H3.Messages.MessageEmergencyType emergency = Messages.MessageEmergencyType.Normal;
- // 如果是带表单方式的发起,则需要将紧急程度设置为高
- if (workflow.StartWithSheet)
- {
- emergency = OThinker.H3.Messages.MessageEmergencyType.High;
- }
- // 启动该流程
- OThinker.H3.Messages.StartInstanceMessage startMessage
- = new OThinker.H3.Messages.StartInstanceMessage(
- emergency,
- instanceId,
- ParameterTable,
- Priority,
- false,
- 0,
- OThinker.H3.Instance.Token.UnspecifiedID,
- null);
- OThinker.H3.Server.Engine.InstanceManager.SendMessage(startMessage);
- if (!workflow.StartWithSheet)
- {
- // 不需要进行操作,直接显示成功
- this.NotifyMessage("发起流程成功,流程ID为:" + instanceId);
- }
- // 获得该实例的任务
- string[] jobs = null;
- for (int triedTimes = 0; triedTimes < 10; triedTimes++)
- {
- System.Threading.Thread.Sleep(1500);
- jobs = OThinker.H3.Server.Engine.WorkItemManager.Query(
- null,
- new string[] { instanceId },
- new string[] { this.UserValidator.UserID },
- System.DateTime.MinValue,
- System.DateTime.MaxValue,
- OThinker.H3.WorkItem.WorkItemState.Unfinished);
- if (jobs != null && jobs.Length != 0)
- {
- break;
- }
- }
- if (jobs == null || jobs.Length == 0)
- {
- this.NotifyMessage(
- "超时,可能是如下原因造成的:" +
- "1、创建或启动流程的时候出现了异常,请点击Web控制台上的管理->异常,查看是否出现了异常" +
- "2、创建该流程的时间比较长,请点击Web控制台上的管理->未完成的工作项,查看是否存在该工作项" +
- "3、该流程的第一个环节的处理人并非发起人,请检查该流程模板的第一个环节的参与者属性");
- }
- return jobs[0];
- }
- #endregion
- }
- }