Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op         = RequestData.Get <string>("op");
            id         = RequestData.Get <string>("id");
            typeid     = RequestData.Get <string>("TypeId");
            JsonString = RequestData.Get <string>("JsonString");
            if (!string.IsNullOrEmpty(id))
            {
                ent = News.Find(id);
            }
            switch (RequestActionString)
            {
            case "update":
                if (!string.IsNullOrEmpty(JsonString))
                {
                    News           tempEnt = JsonHelper.GetObject <News>(JsonString);
                    EasyDictionary dic     = JsonHelper.GetObject <EasyDictionary>(JsonString);
                    DataHelper.MergeData <News>(ent, tempEnt, dic.Keys);
                    ent.SaveAndFlush();
                }
                else
                {
                    ent = this.GetMergedData <News>();
                    ent.HomePagePopup = RequestData.Get <string>("HomePagePopup");
                    ent.SaveAndFlush();
                    if (RequestData["param"] + "" == "tj")
                    {
                        PageState.Add("rtnId", ent.Id);
                    }
                }
                InsertCompetence(ent.Id, ent.ReceiveDeptId, ent.ReceiveDeptName);
                break;

            case "create":
                ent = this.GetPostedData <News>();
                ent.HomePagePopup = RequestData.Get <string>("HomePagePopup");
                ent.AuthorId      = UserInfo.UserID;
                ent.AuthorName    = UserInfo.Name;
                ent.SaveTime      = DateTime.Now;
                ent.CreateTime    = DateTime.Now;
                ent.State         = "0";
                ent.CreateAndFlush();
                if (RequestData["param"] + "" == "tj")
                {
                    //ent.State = "1";
                    //提交流程
                    PageState.Add("rtnId", ent.Id);
                }
                InsertCompetence(ent.Id, ent.ReceiveDeptId, ent.ReceiveDeptName);
                break;

            case "submit":
                StartFlow(id);
                break;

            case "autoexecute":
                Task[] tasks = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"));
                if (tasks.Length == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                    tasks = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"));
                }
                if (tasks.Length > 0)
                {
                    PageState.Add("TaskId", tasks[0].ID);
                    string AuditUserId   = RequestData.Get <string>("AuditUserId");
                    string AuditUserName = RequestData.Get <string>("AuditUserName");
                    if (!string.IsNullOrEmpty(AuditUserId))
                    {
                        Aim.WorkFlow.WorkFlow.AutoExecute(tasks[0], new string[] { AuditUserId, AuditUserName });
                    }
                    else
                    {
                        PageState.Add("error", "自动提交申请人失败,请手动提交");
                    }
                }
                else
                {
                    PageState.Add("error", "自动提交申请人失败,请手动提交");
                }
                break;

            case "submitfinish":
                string ApproveResult = RequestData.Get <string>("ApproveResult");
                ent              = News.Find(id);
                ent.WFState      = "End";
                ent.WFResult     = ApproveResult;
                ent.PostUserId   = UserInfo.UserID;
                ent.PostUserName = UserInfo.Name;
                if (ApproveResult == "同意")
                {
                    ent.State = "2";
                }
                ent.PostTime = DateTime.Now;
                ent.Update();
                break;

            default:
                DoSelect();
                break;
            }
            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent    = News.Find(id);
                    typeid = ent.TypeId;
                    if (RequestData.Get <string>("InFlow") == "T")
                    {
                        sql = @"select * from Task where PatIndex('%" + ent.Id + "%',EFormName)>0  and Status='4' order by FinishTime asc";
                        IList <EasyDictionary> taskDics = DataHelper.QueryDictList(sql);
                        PageState.Add("Opinion", taskDics);
                        string taskId = RequestData.Get <string>("TaskId");//取审批暂存时所填写的意见
                        if (!string.IsNullOrEmpty(taskId))
                        {
                            Task tEnt = Task.Find(taskId);
                            if (tEnt.Status != 4 && !string.IsNullOrEmpty(tEnt.Description))
                            {
                                PageState.Add("UnSubmitOpinion", tEnt.Description);
                            }
                        }
                    }
                }
                SetFormData(ent);
            }
            else
            {
                sql = "select DeptId,ChildDeptName,ParentId,ParentDeptName,len(Path) LenPath from  dbo.View_SysUserGroup where UserId='" + UserInfo.UserID + "' and Type=2";
                DataTable dtt = DataHelper.QueryDataTable(sql);
                if (dtt.Rows.Count > 0)
                {
                    var DeptInfo = new { groupId = dtt.Rows[0]["DeptId"] + "", groupName = dtt.Rows[0]["ChildDeptName"] + "", deptId = dtt.Rows[0]["ParentId"] + "", deptName = dtt.Rows[0]["ParentDeptName"] + "" };
                    PageState.Add("DeptInfo", DeptInfo);
                }
            }
            sql = "select Id,TypeName from NewsType where TypeName!='图片新闻'and TypeName!='视频新闻'";
            PageState.Add("NewsTypeEnum", DataHelper.QueryDict(sql, "Id", "TypeName"));
        }