Ejemplo n.º 1
0
        private string BuilderSeals(int sealRequestId)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<table border='0' ><tbody>");

            List <SealsEntity>             list          = app.GetList().FindAll(r => r.Status == Status.Active);
            List <SealUnionRequestsEntity> listUnioSeals = app.GetSealUnionRequestsList(sealRequestId);

            foreach (SealsEntity entity in list)
            {
                SealUnionRequestsEntity unionEntity = listUnioSeals.Find(r => r.SealID == entity.ID);
                if (unionEntity != null)
                {
                    sb.AppendFormat("<tr><td><span disabled=\"disabled\"><input type=\"checkbox\" disabled=\"disabled\" {0}> <label>{1}</label></span>",
                                    unionEntity == null ? "" : "checked=\"checked\"", entity.SealName);

                    if (unionEntity != null && unionEntity.SealedDate > MinDate)
                    {
                        sb.AppendFormat("<span style='margin-left:20px'><span class=\"sealinfo\">Sealed By:</span> {0} <span class=\"sealinfo\">Sealed Date:</span> {1} </span>",
                                        new App.UserApplication().GetUser(unionEntity.SealedBy).FirstName, unionEntity.SealedDate.ToString("MM/dd/yyyy"));
                    }
                    sb.Append("</td></tr>");
                }
            }
            sb.Append("</tbody></table>");
            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Approved
        /// </summary>
        protected string Approved(int sealRequestID, HttpServerUtility server)
        {
            SealRequestsEntity sealRequestsEntity = CheckData(sealRequestID);

            if (sealRequestsEntity != null)
            {
                if (sealRequestsEntity.Status == RequestStatus.Submit)
                {
                    List <SealUnionRequestsEntity> list = app.GetSealUnionRequestsList(sealRequestsEntity.ID);
                    if (list.Find(r => r.ApprovedBy == UserID) != null)
                    {
                        if (app.SealRequestApproved(sealRequestsEntity.ID, true))
                        {
                            string mailTemplatePath = server.MapPath(@"~\Template\SendEmailToSealed.txt");
                            string mailTemplate     = File.ReadAllText(mailTemplatePath);
                            string mailTitle        = "[批准使用公章] " + sealRequestsEntity.Title;

                            UsersEntity usersEntity = new App.UserApplication().GetUser(sealRequestsEntity.RequestedBy);

                            foreach (SealUnionRequestsEntity user_unionEntity in app.GetSealedByList(sealRequestsEntity.ID))
                            {
                                string content = mailTemplate.Replace("[ClientName]", user_unionEntity.FirstName).Replace("[applicant]", usersEntity.FirstName)
                                                 .Replace("[content]", sealRequestsEntity.Description);

                                if (Config.IsTest)
                                {
                                    new SmtpClientEmailSender(new TextFileLogger()).SendMail(Config.TestMails, Config.DefaultSendEmail, mailTitle, content);
                                }
                                else
                                {
                                    new SmtpClientEmailSender(new TextFileLogger()).SendMail(user_unionEntity.Email, Config.DefaultSendEmail, mailTitle, content);
                                }
                            }
                            return("1");
                        }
                        else
                        {
                            return("2");
                        }
                    }
                    else
                    {
                        return("0");
                    }
                }
            }
            return("2");
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            string         type      = context.Request.QueryString["RequestType"];
            int            requestID = int.Parse(context.Request.QueryString["RequestID"]);
            WorkflowAction action    = (WorkflowAction)Enum.Parse(typeof(WorkflowAction), context.Request.QueryString["Action"]);

            List <UsersEntity> lstUser = new List <UsersEntity>();

            // Get some entity
            SealsApplication   sealApp           = new SealsApplication();
            SealRequestsEntity sealRequestEntity = sealApp.GetSealRequests(requestID);

            UserApplication userApp = new UserApplication();

            if (action == WorkflowAction.Deny || action == WorkflowAction.FinishProcess)
            {
                lstUser.Add(userApp.GetUser(sealRequestEntity.RequestedBy));
            }

            else if (action == WorkflowAction.Cancel || action == WorkflowAction.Complete || action == WorkflowAction.Pending || action == WorkflowAction.Save)
            {
            }

            else if (type == "Seal")
            {
                // Get Seal entity list
                List <SealUnionRequestsEntity> listSealUnionReq = sealApp.GetSealUnionRequestsList(requestID);
                List <SealsEntity>             listSeal         = new List <SealsEntity>();
                foreach (SealUnionRequestsEntity ent in listSealUnionReq)
                {
                    SealsEntity sealEntity = sealApp.GetList().Find(r => r.ID == ent.SealID);
                    listSeal.Add(sealEntity);
                }

                if (action == WorkflowAction.Submit)
                {
                    foreach (SealsEntity ent in listSeal)
                    {
                        lstUser.Add(userApp.GetUser(ent.Approver));
                    }
                }
                else if (action == WorkflowAction.Approve)
                {
                    foreach (SealsEntity ent in listSeal)
                    {
                        lstUser.Add(userApp.GetUser(ent.Owner));
                    }
                }
                else
                {
                    SearchUsersRequest requestUser = new SearchUsersRequest(SearchUsersType.All, false, " FirstName ", " ASC ");
                    requestUser.IsSunnet = true;
                    SearchUserResponse responseuser = userApp.SearchUsers(requestUser);
                    lstUser = responseuser.ResultList.FindAll(r => r.ID != UserInfo.ID && r.Status == "ACTIVE");
                }
            }

            else
            {
                SearchUsersRequest requestUser = new SearchUsersRequest(SearchUsersType.All, false, " FirstName ", " ASC ");
                requestUser.IsSunnet = true;
                SearchUserResponse responseuser = userApp.SearchUsers(requestUser);
                lstUser = responseuser.ResultList.FindAll(r => r.ID != UserInfo.ID && r.Status == "ACTIVE");//(r.Role == RolesEnum.PM || r.Role== RolesEnum.Sales) &&
            }

            lstUser = lstUser.Distinct().ToList();

            Dictionary <string, object> result = new Dictionary <string, object>();

            result.Add("list", lstUser);
            context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            context.Response.End();
        }