Exemple #1
0
 public static string GetDefaultFilterWithSql(this Field field)
 {
     if (field.DefaultFilter.StartsWith("[") && field.DefaultFilter.EndsWith("]"))
     {
         DataAccess.SqlAccess dataAccess = new Durados.DataAccess.SqlAccess();
         return(dataAccess.ExecuteScalar(((Database)field.View.Database).ConnectionString, field.DefaultFilter.TrimStart('[').TrimEnd(']')));
     }
     else
     {
         var type = field.GetColumnFieldType();
         if (type == ColumnFieldType.DateTime || field.IsNumeric)
         {
             return(ColumnFieldViewer.WrapToken(field.DefaultFilter, Filter.TOKEN, Filter.TOKEN));
         }
         else
         {
             return(field.DefaultFilter);
         }
     }
 }
Exemple #2
0
        public JsonResult SignUp(string username, string password, string send, string phone, string fullname, string dbtype, string dbother)
        {
            int identity = -1;

            try
            {
                Durados.DataAccess.SqlAccess sql        = new Durados.DataAccess.SqlAccess();
                Dictionary <string, object>  parameters = new Dictionary <string, object>();

                string email = username.Trim();

                parameters.Add("@Email", email);
                parameters.Add("@Username", username);

                if (sql.ExecuteScalar(Map.Database.ConnectionString, "SELECT TOP 1 [Username] FROM [durados_User] WHERE [Username]=@Username", parameters) != string.Empty)
                {
                    return(Json(new { Success = false, Message = string.Format("{0} is already signed up.", username) }));
                }

                string email1 = email;
                try
                {
                    email1 = email.Split('@')[0];
                }
                catch { }

                email1 = email1.ReplaceNonAlphaNumeric();
                if (string.IsNullOrEmpty(email1))
                {
                    email1 = email;
                }

                string[] email1arr = email1.Split('_');
                string   firstName = string.Empty;
                if (email1arr.Length > 0)
                {
                    firstName = email1arr[0];
                }
                else
                {
                    firstName = email;
                }

                parameters.Add("@FirstName", firstName);
                string lastName = string.Empty;
                if (email1arr.Length > 0)
                {
                    lastName = email1arr[email1arr.Length - 1];
                }
                else
                {
                    lastName = email;
                }
                parameters.Add("@LastName", lastName);

                //Create random Password
                if (string.IsNullOrEmpty(password))
                {
                    password = new AccountMembershipService().GetRandomPassword(10);
                }
                parameters.Add("@Password", password);
                string role = "User";
                parameters.Add("@Role", role);

                Guid guid = Guid.NewGuid();
                parameters.Add("@Guid", guid);

                sql.ExecuteNonQuery(Map.Database.ConnectionString, "INSERT INTO [durados_User] ([Username],[FirstName],[LastName],[Email],[Role],[Guid]) VALUES (@Username,@FirstName,@LastName,@Email,@Role,@Guid)", parameters, CreateMembershipCallback);

                System.Web.Security.MembershipUser user = System.Web.Security.Membership.Provider.GetUser(username, true);
                if (user != null)
                {
                    if (!user.IsApproved && Maps.MultiTenancy)
                    {
                        user.IsApproved = true;
                        System.Web.Security.Membership.UpdateUser(user);
                    }
                }

                FormsAuth.SignIn(username, true);

                identity = Convert.ToInt32(Map.Database.GetUserRow(username)["Id"]);
                //CreatePendingDatabase(identity);

                bool sendEmail = false;
                sendEmail = send != null && send == "true";

                if (sendEmail)
                {
                    Durados.Web.Mvc.UI.Helpers.Account.SendRegistrationRequest(fullname, lastName, email, guid.ToString(), username, password, Map, DontSend);
                }

                try
                {
                    Durados.Web.Mvc.UI.Helpers.Account.UpdateWebsiteUsers(username, identity);
                }
                catch (Exception ex)
                {
                    Maps.Instance.DuradosMap.Logger.Log(RouteData.Values["Controller"].ToString(), RouteData.Values["Action"].ToString(), "SignUp", ex, 1, "failed to update websiteusercookie with userid");
                }

                //Insert into website users
                try
                {
                    Durados.Web.Mvc.UI.Helpers.Account.InsertContactUsUsers(username, fullname, null, phone, 10, int.Parse(dbtype), dbother); //10=welcome email
                }
                catch (Exception ex)
                {
                    Maps.Instance.DuradosMap.Logger.Log(RouteData.Values["Controller"].ToString(), RouteData.Values["Action"].ToString(), "SignUp", ex, 1, "failed to update websiteuser in ContactUs");
                }
            }
            catch (DuradosException exception)
            {
                Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 3, null);
                return(Json(new { Success = false, Message = "The server is busy, please try again later." }));
            }
            catch (Exception exception)
            {
                Map.Logger.Log(this.ControllerContext.RouteData.Values["controller"].ToString(), this.ControllerContext.RouteData.Values["action"].ToString(), exception.Source, exception, 1, null);
                //ViewData["confirmed"] = false;
                return(Json(new { Success = false, Message = "The server is busy, please try again later." }));
            }

            return(Json(new { Success = true, Message = "Success", identity = identity, DemoDefaults = GetDefaultDemo(identity) }));
        }