Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsAsyncRequest)
            {
                if (this.Request.QueryString["flowId"] != null)
                {
                    WorkflowInstance wi = WorkflowInstance.Find(this.Request.QueryString["flowId"]);
                    WorkflowTemplate tp = WorkflowTemplate.Find(wi.WorkflowTemplateID);

                    IList <EasyDictionary> dicts = DataHelper.DataTableToDictList(GetNodes(tp.XAML));
                    this.PageState.Add("FlowEnum", dicts);
                    tasks = Task.FindAll(Expression.Eq(Task.Prop_WorkflowInstanceID, wi.ID), Expression.Not(Expression.Eq("Status", 2))).OrderBy(ens => !ens.FinishTime.HasValue ? DateTime.Now : ens.FinishTime).OrderBy(ens => ens.CreatedTime).ToArray();
                    this.PageState.Add("SysWorkFlowTaskList", tasks);
                }
            }
            if (this.RequestActionString != null && this.RequestActionString == "sendMessage")
            {
                string flowId   = this.RequestData.Get <string>("flowId");
                string taskName = this.RequestData.Get <string>("TaskName");
                if (Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, flowId, Task.Prop_ApprovalNodeName, taskName).Length > 0)
                {
                    Task    task     = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, flowId, Task.Prop_ApprovalNodeName, taskName)[0];
                    string  userId   = task.OwnerId;
                    string  userName = task.Owner;
                    SysUser user     = SysUser.TryFind(userId);
                    if (userId == this.UserInfo.UserID)
                    {
                        PageState.Add("Message", "您是要催办的审批人,无需给自己发送短信催办!");
                    }
                    else if (user != null && (!string.IsNullOrEmpty(user.Phone) || !string.IsNullOrEmpty(user.Email)))
                    {
                        string method        = this.RequestData.Get <string>("Method").ToLower();
                        string mailTemplate  = SysParameter.FindAllByProperties("Code", "TaskAlertMail")[0].Description;  //{[AuditCount]} {[TaskName]}
                        string phoneTemplate = SysParameter.FindAllByProperties("Code", "TaskAlertPhone")[0].Description; //{[AuditCount]} {[LinkUrl]} {[SysEntry]}

                        string tName      = task.Title;
                        string linkUrl    = task.EFormName;
                        string sysEntry   = SysParameter.FindAllByProperties("Code", "SysEntry2")[0].Description;
                        string auditCount = DataHelper.QueryValue <int>("select count(*) from Task where status='0' and ownerId='" + userId + "'").ToString();

                        string mailContent  = mailTemplate.Replace("{[TaskName]}", tName).Replace("{[AuditCount]}", auditCount).Replace("{[SysEntry]}", sysEntry + task.ID);
                        string phoneContent = phoneTemplate.Replace("{[AuditCount]}", auditCount).Replace("{[TaskName]}", tName).Replace("{[LinkUrl]}", linkUrl).Replace("{[SysEntry]}", sysEntry);
                        //if (!string.IsNullOrEmpty(user.Phone) && method == "phone")
                        //    MessageTool.SendMessage(user.Phone, phoneContent);
                        //if (!string.IsNullOrEmpty(user.Email) && method == "mail")
                        //    MessageTool.SendMessageMail(mailContent, user.Email);
                    }
                    else
                    {
                        PageState.Add("Message", "系统尚未配置相关审批人电话号码及邮箱信息,无法发送短信和邮件!");
                    }
                }
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request.Files.Count > 0)
            {
                string guid     = Guid.NewGuid().ToString();
                string filePath = "//WorkTime//InputExcelFiles//" + Guid.NewGuid().ToString() + System.IO.Path.GetExtension(Request.Files[0].FileName);
                this.Request.Files[0].SaveAs(Server.MapPath(filePath));
                ExcelProcessor ep = ExcelService.GetProcessor(Server.MapPath(filePath));
                DataSet        ds = ep.GetDataSet();
                InputDatas(ds.Tables[0]);
                Response.Write("{success:true}");
                Response.End();
            }

            id   = RequestData.Get <string>("id", String.Empty);
            type = RequestData.Get <string>("type", String.Empty);

            SysUser usr = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Create:
                usr = this.GetPostedData <SysUser>();
                usr.DoCreate();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Update:
                usr = this.GetMergedData <SysUser>();
                usr.DoUpdate();
                this.SetMessage("保存成功!");
                break;

            case RequestActionEnum.Delete:
                usr = this.GetTargetData <SysUser>();
                usr.DoDelete();
                this.SetMessage("删除成功!");
                break;

            default:
                if (RequestActionString == "clearpass")
                {
                    usr          = SysUser.Find(this.RequestData.Get <string>("UserId"));
                    usr.Password = "";
                    usr.Remark   = "";
                    usr.Save();
                }
                else if (RequestActionString == "setpass")
                {
                    MD5Encrypt encrypt = new MD5Encrypt();
                    SysUser[]  users   = SysUser.FindAll();
                    foreach (SysUser user in users)
                    {
                        Random rnd           = new Random();
                        int    rndNum        = rnd.Next(10000000, 99999999);
                        string encryPassword = encrypt.GetMD5FromString(rndNum.ToString());
                        user.Password = encryPassword;
                        user.Remark   = rndNum.ToString();
                        user.Save();
                    }
                }
                else if (RequestActionString == "checkkey")
                {
                    if (SysUser.FindAllByProperties("Server_IAGUID", this.RequestData.Get <string>("usbguid")).Length > 0)
                    {
                        this.PageState.Add("UserName", SysUser.FindAllByProperties("Server_IAGUID", this.RequestData.Get <string>("usbguid"))[0].Name);
                    }
                    else
                    {
                        this.PageState.Add("UserName", "");
                    }
                }
                else if (RequestActionString == "setkey")
                {
                    SysUser user = SysUser.Find(this.RequestData.Get <string>("userid"));
                    user.Server_IAGUID = this.RequestData.Get <string>("usbguid");
                    user.Server_Seed   = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
                    user.ThreeDESKEY   = "ABCDEFGhijklmn0123456789";
                    user.Save();
                }
                else if (RequestActionString == "sendmail")
                {
                    IList <object> idList = RequestData.GetList <object>("IdList");
                    SysUser[]      tents  = SysUser.FindAll(Expression.In("UserID", idList.ToArray()));

                    foreach (SysUser user in tents)
                    {
                        string body = SysParameter.FindAllByProperties("Code", "MailText")[0].Description + "<br>";
                        body += "您的登录用户名:" + user.LoginName + ";密码:" + user.Remark;
                        string mailAccount       = SysParameter.FindAllByProperties("Code", "MailAccount")[0].Value;
                        string mailPass          = SysParameter.FindAllByProperties("Code", "MailPassword")[0].Value;
                        string mailServer        = SysParameter.FindAllByProperties("Code", "MailSmtpServer")[0].Value;
                        string mailSenderAddress = SysParameter.FindAllByProperties("Code", "MailSenderAddress")[0].Value;
                        MailHelper.SendMail(mailSenderAddress, user.Email, "工时分配系统邮件", body, mailAccount, mailPass, mailServer);
                    }
                }
                else
                {
                    SearchCriterion.AutoOrder = false;
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    string dName  = SearchCriterion.GetSearchValue <string>("Name");
                    string workNo = SearchCriterion.GetSearchValue <string>("WorkNo");
                    SearchCriterion.SetOrder(SysUser.Prop_WorkNo);
                    if (dName != null && dName.Trim() != "")
                    {
                        string where = "select * from SysUser where " + GetPinyinWhereString("Name", dName);
                        where       += " and WorkNo like '%" + workNo + "%'";
                        this.PageState.Add("UsrList", DataHelper.QueryDictList(where));
                    }
                    else
                    {
                        users = SysUserRule.FindAll(SearchCriterion);
                        this.PageState.Add("UsrList", users);
                    }
                }
                break;
            }
        }