예제 #1
0
        public async Task <JsonResult> SendConfirmationToEmail(string email)
        {
            //check if it's org email
            if (RegexExtension.IsValidEmail(email))
            {
                UserBO user = await UserManager.FindByEmailAsync(email);

                if (user == null)
                {
                    return(Json(JsonResponse.Success("Please Check your email to Reset your Password")));
                }
                if (user.EmailConfirmed == true)
                {
                    return(Json(JsonResponse.Success("Your Email has been Confirmed")));
                }

                try
                {
                    string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    string callbackUrl = Url.Action("confirm", "account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    string emailBody   = await CreateEmailBodyAsync("../EmailTemplates/AccountConfirmation.html", user.Email, user.FirstName, callbackUrl, "");

                    await UserManager.SendEmailAsync(user.Id, "SiriusPM Account Confimation", emailBody);

                    return(Json(JsonResponse.Success("Please Check your email to Reset your Password")));
                }
                catch (Exception ex)
                {
                    LogError(ex, string.Empty);
                    return(Json(JsonResponse.Error("Unsuccesfull")));
                }
            }
            return(Json(JsonResponse.Error("Enter a valid Email Address")));
        }
예제 #2
0
        public async Task <JsonResult> SendPasswordResetEmail(string email)
        {
            if (RegexExtension.IsValidEmail(email))
            {
                UserBO user = await UserManager.FindByEmailAsync(email);

                if (user == null)
                {
                    return(Json(JsonResponse.Success("We've sent you an email to enable you reset your password. Please Check your email for instructions.")));
                }

                try
                {
                    string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                    var callbackUrl = Url.RouteUrl("Organization_PasswordReset",
                                                   new { email = user.Email, code = code }, protocol: Request.Url.Scheme);
                    //string route = "../reset/" + user.UserName + "/" + code; ;

                    string imageUrl = Url.Action("images", "EmailTemplates") + "/head1.png";

                    string emailBody = await CreateEmailBodyAsync("../EmailTemplates/AccountConfirmation.html", user.Email, user.FirstName, callbackUrl, imageUrl);

                    await UserManager.SendEmailAsync(user.Id, "SiriusPM Account Confimation", emailBody);

                    return(Json(JsonResponse.Success("We've sent you an email to enable you reset your password. Please Check your email for instructions.")));
                }
                catch (Exception ex)
                {
                    LogError(ex, string.Empty);
                    return(Json(JsonResponse.Error("Something went wrong, please try again.")));
                }
            }
            return(Json(JsonResponse.Error("Enter a valid Email Address")));
        }
예제 #3
0
        private static string GetRegion(WikiTableRowBase row)
        {
            var regionMatches = RegexExtension.GetMatches(row.Content[1], RegexPattern.LocationRegionMatchPattern);
            var region        = regionMatches[0].Groups[1].Value;

            return(region);
        }
        private static string GetHeaderContent(string @string)
        {
            var matches      = RegexExtension.GetMatches(@string, RegexPattern.TableTextHeaderMatchPattern);
            var contentValue = matches[0].Value;

            RegexExtension.Replace(ref contentValue, RegexPattern.BracesReplacePattern);

            return(contentValue);
        }
        protected override void HandlerRequestInternal(ref string content, List <WikiTableRowBase> rows)
        {
            var collections = RegexExtension.GetMatches(content, RegexPattern.TableHeaderMatchPattern);

            var header = new WikiTableRowBaseHeader();

            foreach (Match collection in collections)
            {
                header.Content.Add(GetHeaderContent(collection.Value));
            }

            rows.Add(header);
        }
예제 #6
0
        protected override void HandlerRequestInternal(ref string content, List <WikiTableRowBase> rows)
        {
            var collections = RegexExtension.GetMatches(content, RegexPattern.TableRowMatchPattern);

            foreach (Match collection in collections)
            {
                var group = collection.Groups[0];

                var row = new WikiTableRow();
                row.Content.AddRange(GetRowColumnsContent(group.Value));
                rows.Add(row);
            }
        }
예제 #7
0
        private static List <string> GetRowColumnsContent(string @string)
        {
            // Remove leading row separator (|-)
            RegexExtension.Replace(ref @string, RegexPattern.TableRowSeparatorMatchPattern);

            // Remove ending new line symbol
            @string = @string.Trim();

            // Split by new lines
            var columnsRow = @string.Split('\n');

            return(columnsRow.ToList());
        }
예제 #8
0
        /// <summary>
        /// list all files under folder with specify pattern
        /// </summary>
        /// <param name="folder">folder name</param>
        /// <param name="pattern">regular expression pattern to search</param>
        /// <returns>return list of files location</returns>
        public static List <string> ListFiles(string folder, string pattern)
        {
            FileAttributes attr = File.GetAttributes(folder);

            if (!attr.HasFlag(FileAttributes.Directory))
            {
                throw new ArgumentException("Folder must exist and be a directory");
            }
            List <string> files = Directory.GetFiles(folder)
                                  .Where(f => RegexExtension.IsMatch(f, pattern))
                                  .ToList();

            return(files);
        }
예제 #9
0
        private static string GetName(WikiTableRowBase row)
        {
            var nameMatches = RegexExtension.GetMatches(row.Content[0], RegexPattern.LocationNameMatchPattern);
            var name        = nameMatches[0].Groups[1].Value;

            var nameCorrectedMatches = RegexExtension.GetMatches(name, RegexPattern.LocationNameCorretionMatchPattern);

            if (nameCorrectedMatches.Count > 0)
            {
                var nameCorrected = nameCorrectedMatches[0].Groups[1].Value;
                name = nameCorrected;
            }

            return(name);
        }
예제 #10
0
        public int IsExistsPhone(string phone)
        {
            if (RegexExtension.IsValidPhone(phone))
            {
                Expression <Func <FL_Customer, bool> > pars = c => c.BridePhone == phone || c.GroomPhone == phone || c.OperatorPhone == phone;
                var model = _customerService.GetModel(pars);

                if (model != null)      //号码已经存在
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            else
            {
                return(2);
            }
        }
예제 #11
0
        protected override void HandlerRequestInternal(string content, SortedSet <WikiPageElement> elements)
        {
            var headerPattern = @"(={1,5}[^=]{1,200}?={1,5})";
            var collection    = RegexExtension.GetMatches(content, headerPattern);

            if (collection.Count == 0)
            {
                this.Logger.LogDebug("Headers content was not found");
                return;
            }

            foreach (Group group in collection[0].Groups)
            {
                elements.Add(new WikiPageElement
                {
                    StartIndex  = group.Index,
                    Length      = group.Length,
                    Content     = group.Value,
                    ContentType = WikiPageContentType.Header
                });
            }
        }
예제 #12
0
        protected override void HandlerRequestInternal(string content, SortedSet <WikiPageElement> elements)
        {
            var tablePattern = @"\{\|[\s\S]+?\|\}";
            var collection   = RegexExtension.GetMatches(content, tablePattern);

            if (collection.Count == 0)
            {
                this.Logger.LogDebug("Table content was not found");
                return;
            }

            foreach (Group group in collection[0].Groups)
            {
                elements.Add(new WikiPageElement
                {
                    StartIndex  = group.Index,
                    Length      = group.Length,
                    Content     = group.Value,
                    ContentType = WikiPageContentType.Table
                });
            }
        }
예제 #13
0
        /// <summary>
        /// 导入客户文件
        /// </summary>

        public void ImportFile(HttpContext context)
        {
            //获取上传的excel文件
            HttpFileCollection file = HttpContext.Current.Request.Files;
            int employeeId          = context.Request.Form["hideEmployee"].ToInt32(); //获取当前登录员工的id

            AjaxMessage ajax = new AjaxMessage();

            ajax.IsSuccess = false;

            string pathAddress = "";        //完整的excel保存路径
            string type        = "success"; //成功状态
            string suffix      = "";        //后缀名

            try
            {
                if (file.Count == 0)
                {
                    //直接点击导入 没有选择Excel文件
                    ajax.Message = "文件不能为空,请选择上传文件";
                    type         = "error";
                }
                else
                {
                    HttpPostedFile upFile = file[0];

                    #region 判断文件类型 大小 保存文件

                    if (type == "success")
                    {
                        int    filesize = upFile.ContentLength;                                         //excel文件大小
                        int    Maxsize  = 4000 * 1024;                                                  //最大空间大小为4M
                        string filename = DateTime.Now.ToString("HHmmssfff") + upFile.FileName;         //文件名
                        string path     = HttpContext.Current.Server.MapPath("/Template/");             //文件夹路径
                        pathAddress = path + filename;                                                  //完整的excel保存路径
                        suffix      = Path.GetExtension(pathAddress).ToString();                        //获取后缀名


                        if (suffix != ".xls" && suffix != ".xlsx")
                        {
                            ajax.Message = "上传文件必须是xlsx或xls文件";
                            type         = "error";
                        }
                        else
                        {
                            if (filesize > Maxsize)
                            {
                                ajax.Message = "文件大小不能超过4M";
                                type         = "error";
                            }
                            else
                            {
                                //判断文件夹是否存在  若不存在 就新建
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                //保存Excel
                                upFile.SaveAs(pathAddress);

                                type = "success";
                            }
                        }
                    }
                    #endregion

                    #region 验证excel模板(根据标题验证)
                    //获取excel的数据  用DataTable保存
                    DataTable dt       = null;
                    DataRow   rowTitle = null;
                    if (type == "success")
                    {
                        dt       = ExcelUtil.ExcelToDataTable(pathAddress, "getTitle");
                        rowTitle = dt.Rows[0];
                        if (dt != null)
                        {
                            if (dt.Rows.Count > 0)
                            {
                                if (rowTitle[0].ToString() != "新娘姓名" || rowTitle[1].ToString() != "新郎姓名" || rowTitle[2].ToString() != "经办人" || rowTitle[3].ToString() != "新娘联系电话" || rowTitle[4].ToString() != "新郎联系电话" || rowTitle[5].ToString() != "经办人联系电话" || rowTitle[6].ToString() != "婚期" || rowTitle[7].ToString() != "酒店" || rowTitle[8].ToString() != "渠道类型" || rowTitle[9].ToString() != "渠道名称" || rowTitle[10].ToString() != "推荐人" || rowTitle[11].ToString() != "沟通进度")
                                {
                                    ajax.Message = "当前文件模板错误,请参考当前页面的模板进行使用";
                                    type         = "errorr";
                                }
                                else if (dt.Rows.Count == 1)
                                {
                                    ajax.Message = "当前上传文件中没有客户信息,请填写客户信息";
                                    type         = "errorr";
                                }
                            }
                        }
                        else
                        {
                            ajax.Message = "请不要上传空白的Excel";
                            type         = "errorr";
                        }
                    }
                    #endregion

                    #region 循环验证excel里的内容
                    if (type == "success")
                    {
                        if (dt != null)
                        {
                            #region 验证内容是否完整

                            //记录列名
                            string columnName = "";

                            //循环遍历datatable里的数据 进行验证
                            for (int i = 1; i < dt.Rows.Count; i++)
                            {
                                //table中的每一行
                                DataRow row = dt.Rows[i];
                                //验证新人姓名是否为空
                                if (row[0].ToString() == "" && row[1].ToString() == "" && row[2].ToString() == "")
                                {
                                    ajax.Message += "新人姓名 至少一列不能为空,请补全信息 \n\r";
                                    type          = "error";
                                }

                                if (row[3].ToString() == "" && row[4].ToString() == "" && row[5].ToString() == "")
                                {
                                    ajax.Message += "新人联系电话 至少一列不能为空,请补全信息";
                                    type          = "error";
                                }

                                if (type == "success")
                                {
                                    for (int j = 8; j <= 10; j++)
                                    {
                                        if (row[j].ToString() == "")
                                        {
                                            columnName += rowTitle[j].ToString() + ",";
                                        }

                                        if (j == dt.Columns.Count - 1)
                                        {
                                            columnName    = columnName.Substring(0, columnName.Length - 1).ToString();
                                            ajax.Message += "第" + (i + 1) + "行," + columnName + "列不能为空,";
                                        }
                                    }
                                }
                            }
                            #endregion

                            #region Excel内容完整 判断Excel信息 (进行验证)

                            //Excel内容完整
                            if (type == "success")
                            {
                                for (int i = 1; i < dt.Rows.Count; i++)
                                {
                                    //table中的每一行
                                    DataRow row = dt.Rows[i];
                                    for (int j = 3; j <= 5; j++)
                                    {
                                        //新人电话验证
                                        if (row[j].ToString() != string.Empty)
                                        {
                                            if (row[j].ToString().Length != 11 || RegexExtension.IsValidPhone(row[j].ToString()) == false)
                                            {
                                                ajax.Message = "Excel文件中 " + rowTitle[j] + "格式不正确";
                                                type         = "error";
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 添加客户至数据库
                    if (type == "success")
                    {
                        FL_Customer        m_customer = new FL_Customer();
                        List <FL_Customer> cus_list   = new List <FL_Customer>();

                        int nums = 0;
                        if (dt.Rows.Count >= 2)
                        {
                            List <FL_Customer> customer_list = new List <FL_Customer>();
                            List <FL_Invite>   invite_list   = new List <FL_Invite>();
                            List <SS_Report>   report_list   = new List <SS_Report>();

                            for (int i = 1; i < dt.Rows.Count; i++)
                            {
                                DataRow row = dt.Rows[i];
                                m_customer               = new FL_Customer();
                                m_customer.CustomerID    = Guid.NewGuid();
                                m_customer.Bride         = row[0].ToString();
                                m_customer.Groom         = row[1].ToString();
                                m_customer.Operator      = row[2].ToString();
                                m_customer.BridePhone    = row[3].ToString();
                                m_customer.GroomPhone    = row[4].ToString();
                                m_customer.OperatorPhone = row[5].ToString();

                                //主要联系人
                                if (row[0].ToString() != string.Empty)
                                {
                                    m_customer.ContactMan = row[0].ToString();
                                }
                                else if (row[1].ToString() != string.Empty)
                                {
                                    m_customer.ContactMan = row[1].ToString();
                                }
                                else if (row[2].ToString() != string.Empty)
                                {
                                    m_customer.ContactMan = row[2].ToString();
                                }

                                //主要联系电话
                                if (row[3].ToString() != string.Empty)
                                {
                                    m_customer.ContactPhone = row[3].ToString();
                                }
                                else if (row[4].ToString() != string.Empty)
                                {
                                    m_customer.ContactPhone = row[4].ToString();
                                }
                                else if (row[5].ToString() != string.Empty)
                                {
                                    m_customer.ContactPhone = row[5].ToString();
                                }

                                m_customer.PartyDate = DateTime.FromOADate(double.Parse(row[6].ToString())).ToString("yyyy-MM-dd").ToDateTime();
                                m_customer.Hotel     = row[7].ToString().Substring(0, row[7].ToString().IndexOf('.'));
                                int length = row[8].ToString().Substring(row[8].ToString().LastIndexOf("M") + 1).Length;
                                m_customer.SaleType       = row[8].ToString().Substring(row[8].ToString().LastIndexOf('M') + 1, length).ToString().ToInt32();
                                m_customer.Channel        = row[9].ToString().Substring(0, row[9].ToString().IndexOf('.')).ToString().ToInt32();
                                m_customer.ReCommand      = row[10].ToString();
                                m_customer.State          = row[11].ToString().Substring(0, row[11].ToString().IndexOf('.')).ToInt32(); //沟通状态
                                m_customer.DeskCount      = 0;
                                m_customer.Budget         = 0;
                                m_customer.Type           = 1;        //1.婚宴  2.生日宴   3.宝宝宴
                                m_customer.BanqueType     = "1";      //1.午宴   2.晚宴
                                m_customer.IsVip          = 1;        //0.普通客户  1.会员客户
                                m_customer.CreateEmployee = employeeId;
                                m_customer.CreateDate     = DateTime.Now;
                                m_customer.IsFinish       = 0;      //是否完成
                                m_customer.EvalState      = 0;      //是否评价
                                m_customer.Status         = (byte)SysStatus.Enable;
                                m_customer.Description    = string.Empty;


                                //Report 信息
                                SS_Report report = new SS_Report();

                                report.CustomerId     = m_customer.CustomerID;
                                report.CreateEmployee = employeeId;
                                report.InviteEmployee = employeeId;
                                report.CreateDate     = DateTime.Now;
                                report.CustomerState  = m_customer.State;


                                //邀约信息
                                FL_Invite m_invite = new FL_Invite();
                                m_invite.CustomerID     = m_customer.CustomerID;
                                m_invite.EmployeeId     = employeeId;
                                m_invite.CreateEmployee = employeeId;
                                m_invite.CreateDate     = DateTime.Now;
                                m_invite.IsLose         = false;

                                FL_InviteDetails details = new FL_InviteDetails();
                                FL_Order         order   = new FL_Order();
                                if (m_customer.State == 5)        //确认到店
                                {
                                    //邀约内容
                                    m_invite.OrderEmployee = employeeId.ToString().ToInt32();

                                    details.CustomerId    = m_customer.CustomerID;
                                    details.EmployeeId    = employeeId;
                                    details.InviteState   = (int)CustomerState.ComeOrder;
                                    details.StateName     = details.StateValue.GetDisplayName();
                                    details.InviteContent = "Excel导入客户  直接确认到店";
                                    details.CreateDate    = DateTime.Now;

                                    //订单 统筹信息

                                    order.OrderID        = Guid.NewGuid();
                                    order.OrderCoder     = Guid.NewGuid().ToString().Replace("-", "");
                                    order.CustomerId     = m_customer.CustomerID;
                                    order.ComeDate       = DateTime.Now;
                                    order.EmployeeId     = employeeId;
                                    order.OrderState     = (int)CustomerState.ComeOrder;
                                    order.FollowCount    = 0;
                                    order.CreateEmployee = employeeId;
                                    order.CreateDate     = DateTime.Now;

                                    m_invite.FollowCount    = 1;
                                    m_invite.OrderEmployee  = employeeId.ToString().ToInt32();
                                    m_invite.LastFollowDate = DateTime.Now;

                                    report.OrderId       = order.OrderID;
                                    report.OrderEmployee = employeeId.ToString().ToInt32();
                                }

                                using (TransactionScope scope = new TransactionScope())
                                {
                                    if (m_customer.State == 5)        //确认到店
                                    {
                                        //添加客户
                                        _customerService.Add(m_customer);

                                        //添加邀约
                                        FL_Invite r_invite = _inviteService.Add(m_invite);
                                        details.InviteId = r_invite.InviteId;
                                        //添加邀约内容
                                        _inviteDetailsService.Add(details);


                                        //添加到店  订单
                                        FL_Order r_order = _orderService.Add(order);

                                        //添加统计
                                        _reportService.Add(report);
                                    }
                                    else
                                    {
                                        ////添加客户
                                        //_customerService.Add(m_customer);

                                        ////添加邀约
                                        //_inviteService.Add(m_invite);
                                        ////添加统计
                                        //_reportService.Add(report);

                                        customer_list.Add(m_customer);
                                        invite_list.Add(m_invite);
                                        report_list.Add(report);
                                    }


                                    scope.Complete();
                                }

                                nums++;
                            }
                            //批量添加
                            if (customer_list.Count > 0)
                            {
                                _customerService.InsertForList(customer_list);
                            }
                            if (invite_list.Count > 0)
                            {
                                _inviteService.InsertForList(invite_list);
                            }
                            if (report_list.Count > 0)
                            {
                                _reportService.InsertForList(report_list);
                            }
                        }


                        if (type == "success")
                        {
                            ajax.IsSuccess = true;
                            ajax.Message   = "导入成功,共导入" + nums.ToString() + "条数据";
                        }
                    }
                    #endregion
                }
            }
            catch (SqlException ex)
            {
                ajax.Message = ex.Message + "   请重新导入!";
                type         = "error";
            }
            catch (Exception e)
            {
                ajax.Message = e.Message;
                type         = "error";
            }
            finally
            {
                //删除Excel文件
                if (File.Exists(pathAddress))
                {
                    File.Delete(pathAddress);
                }
            }

            context.Response.Write(JsonConvert.SerializeObject(ajax));
        }
예제 #14
0
        public JsonResult Register(UserRegisterViewModel model)
        {
            bool   success         = false;
            string message         = "";
            var    emailControl    = RegexExtension.EmailRegexControl(model.Email);
            var    passwordControl = PasswordControlExtension.PasswordControl(model.Password, model.RePassword);
            var    hasEmail        = db.Users.FirstOrDefault(x => x.Email == model.Email);

            if (hasEmail != null || !passwordControl || !passwordControl ||
                string.IsNullOrEmpty(model.Email) ||
                string.IsNullOrEmpty(model.Password) ||
                string.IsNullOrEmpty(model.RePassword) ||
                string.IsNullOrEmpty(model.Name) ||
                string.IsNullOrEmpty(model.Surname) ||
                string.IsNullOrEmpty(model.PhoneNumber))
            {
                if (hasEmail != null)
                {
                    success = false;
                    message = "Email adresi sistemimizde kayıtlıdır.";
                }
                if (!emailControl)
                {
                    success = emailControl;
                    message = "Emailinizi kontrol ediniz";
                }
                if (!passwordControl)
                {
                    success = passwordControl;
                    message = "Şifreler eşleşmiyor";
                }
                if (string.IsNullOrEmpty(model.Email) || string.IsNullOrEmpty(model.Password) || string.IsNullOrEmpty(model.RePassword) || string.IsNullOrEmpty(model.Name) || string.IsNullOrEmpty(model.Surname) || string.IsNullOrEmpty(model.PhoneNumber))
                {
                    message = "Boş alanları doldurunuz!";
                }
            }
            else
            {
                var userRegisterModel = new Users
                {
                    Email       = model.Email,
                    Password    = model.Password,
                    CreatedDate = DateTime.Now,
                    Name        = model.Name,
                    Surname     = model.Surname,
                    TelNo       = model.PhoneNumber
                };
                var user = db.Users.Add(userRegisterModel);

                var userRoleRelationModel = new UserRoleRelation()
                {
                    FkUserId     = user.Id,
                    FkUserRoleId = 2,
                    Status       = 1,
                    CreatedDate  = DateTime.Now,
                };
                db.UserRoleRelation.Add(userRoleRelationModel);
                db.SaveChanges();
                success = true;
                message = $"{user.Name } {user.Surname} Kayıt işlemi başarıyla gerçekleşti.";
            }


            var result = new ResultViewModel()
            {
                Message = message,
                Success = success
            };

            return(Json(result));
        }
예제 #15
0
 protected override void HandlerRequestInternal(ref string content, List <WikiTableRowBase> rows)
 {
     RegexExtension.Replace(ref content, RegexPattern.TableRowSpanMatchPattern);
 }