Ejemplo n.º 1
0
 public CmsPageEditMenuAction(CmsEditMenuActionCategory actionCategory, CmsEditMenuActionItem actionItem, CmsEditMode requiredEditMode, int sortOrdinal, RenderToString renderDelegate)
 {
     ActionCategory       = actionCategory;
     ActionItem           = actionItem;
     RequiredEditMode     = requiredEditMode;
     SortOrdinal          = sortOrdinal;
     doRenderToString     = renderDelegate;
     CreateNewPageOptions = new CmsCreateNewPageOptions();
 }
        public JsonResult HandleMatchProductErrors(BillingImport_Upload viewBillingData, FormCollection fc)
        {
            viewBillingData.productlist = BillingImport.GetProducts(viewBillingData.VendorID, viewBillingData.ImportID);
            viewBillingData.productlist.Find(
                delegate(SelectListItem tempitem)
            {
                return(tempitem.Value == fc["productlist"]);
            }
                ).Selected = true;


            return(new JsonResult
            {
                Data = new
                {
                    success = false,
                    view = RenderToString.RenderViewToString(this, "MatchDescToProduct", viewBillingData)
                }
            });
        }
Ejemplo n.º 3
0
        public JsonResult HandleCreateClientUserErrors(Security_Users viewSecuritySetup, FormCollection fc)
        {
            viewSecuritySetup.securitycompanieslist2 = Clients.GetClientListFromUser(SecurityExtension.GetCurrentUserID(this));
            viewSecuritySetup.securitycompanieslist2.Find(
                delegate(SelectListItem tempitem)
            {
                return(tempitem.Value == fc["primarycompany"]);
            }
                ).Selected = true;


            SelectListItem item1 = new SelectListItem();

            item1.Text  = "Client User";
            item1.Value = "Client";
            viewSecuritySetup.usertypelist.Add(item1);

            SelectListItem item2 = new SelectListItem();

            item2.Text  = "Sales User";
            item2.Value = "Sales";
            viewSecuritySetup.usertypelist.Add(item2);


            viewSecuritySetup.usertypelist.Find(
                delegate(SelectListItem tempitem)
            {
                return(tempitem.Value == fc["usertypelist"]);
            }
                ).Selected = true;

            return(new JsonResult
            {
                Data = new
                {
                    success = false,
                    view = RenderToString.RenderViewToString(this, "CreateClientUser", viewSecuritySetup)
                }
            });
        }
        public JsonResult MatchDescToProductPost(BillingImport_Upload viewBillingData, FormCollection fc) //id = vendorid
        {
            string productcode     = fc["productlist"];
            string searchtext      = fc["productdesc"];
            int    importid        = Int32.Parse(fc["importid"]);
            string errorcode       = fc["errorcodeval"];
            bool   permanentsearch = true;

            if (errorcode == "104")
            {
                if (fc["ispermanentsearch"].ToString().Contains("t"))
                {
                    permanentsearch = true;
                }
                else
                {
                    permanentsearch = false;
                }
            }

            if (productcode == "")
            {
                ViewData.ModelState.AddModelError("*", "Please select a product first.");
                HandleMatchProductErrors(viewBillingData, fc);
                return(new JsonResult
                {
                    Data = new
                    {
                        success = false,
                        view = RenderToString.RenderViewToString(this, "MatchDescToProduct", viewBillingData)
                    }
                });
            }

            string returnupdateresults = BillingImport.UpdateTazworksImport(importid, searchtext);

            if (returnupdateresults != "0")
            {
                ViewData.ModelState.AddModelError("*", "The description text could not be changed. ");
                HandleMatchProductErrors(viewBillingData, fc);
                return(new JsonResult
                {
                    Data = new
                    {
                        success = false,
                        view = RenderToString.RenderViewToString(this, "MatchDescToProduct", viewBillingData)
                    }
                });
            }

            string returnresults = BillingImport.InsertTazworks1SearchText(productcode, searchtext, errorcode, permanentsearch, importid);

            if (returnresults != "0")
            {
                ViewData.ModelState.AddModelError("*", "The desciption could not be matched to the product selected.  Please try again.");
                HandleMatchProductErrors(viewBillingData, fc);
                return(new JsonResult
                {
                    Data = new
                    {
                        success = false,
                        view = RenderToString.RenderViewToString(this, "MatchDescToProduct", viewBillingData)
                    }
                });
            }
            else
            {
                return(new JsonResult {
                    Data = new { success = true, importid = importid }
                });
            }
        }
Ejemplo n.º 5
0
        public JsonResult CreateClientUserPost(Security_Users viewSecuritySetup, FormCollection fc)
        {
            int    newuserclientid = Convert.ToInt32(fc["primarycompany"]);
            string newuserrole     = fc["usertypelist"];

            // Basic parameter validation
            if (String.IsNullOrEmpty(viewSecuritySetup.firstname))
            {
                ViewData.ModelState.AddModelError("firstname", " ");
                ViewData.ModelState.AddModelError("*", "Please enter a firstname.");
            }

            if (String.IsNullOrEmpty(viewSecuritySetup.lastname))
            {
                ViewData.ModelState.AddModelError("lastname", " ");
                ViewData.ModelState.AddModelError("*", "Please enter a lastname.");
            }

            if (String.IsNullOrEmpty(viewSecuritySetup.username))
            {
                ViewData.ModelState.AddModelError("username", " ");
                ViewData.ModelState.AddModelError("*", "Please enter a username.");
            }

            if (String.IsNullOrEmpty(viewSecuritySetup.email))
            {
                ViewData.ModelState.AddModelError("email", " ");
                ViewData.ModelState.AddModelError("*", "Please enter an email address.");
            }
            else
            {
                Regex emailregex = new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,7}$");

                Match m = emailregex.Match(viewSecuritySetup.email);
                if (m.Success == false)
                {
                    ViewData.ModelState.AddModelError("email", " ");
                    ViewData.ModelState.AddModelError("*", "Invalid email format.");
                }
            }

            if (viewSecuritySetup.password == null || viewSecuritySetup.password.Length < Provider.MinRequiredPasswordLength)
            {
                ViewData.ModelState.AddModelError("password", " ");
                ViewData.ModelState.AddModelError("*", String.Format(CultureInfo.InvariantCulture,
                                                                     "A password of {0} or more characters is required.",
                                                                     Provider.MinRequiredPasswordLength));
            }

            if (!String.Equals(viewSecuritySetup.password, viewSecuritySetup.confirmPassword, StringComparison.Ordinal))
            {
                ViewData.ModelState.AddModelError("confirmPassword", " ");
                ViewData.ModelState.AddModelError("*", "The password and confirmation do not match.");
            }

            if (ViewData.ModelState.IsValid)
            {
                string subject       = ConfigurationManager.AppSettings["CompanyName"] + " Billing: New Account";
                string clientname    = null;
                string clientaddr1   = null;
                string clientaddr2   = null;
                string clientcity    = null;
                string clientstate   = null;
                string clientzipcode = null;

                // Attempt to register the user
                MembershipCreateStatus createStatus;
                MembershipUser         newUser = Provider.CreateUser(viewSecuritySetup.username, viewSecuritySetup.password, viewSecuritySetup.email,
                                                                     "client", "client", true, null, out createStatus);

                if (newUser != null)
                {
                    var db     = new UsersDataContext();
                    var result = db.S1_Users_CreateUser(viewSecuritySetup.username, newuserclientid, 1, viewSecuritySetup.firstname, viewSecuritySetup.lastname).SingleOrDefault();
                    if (result.UserID > 0)
                    {
                        Roles.AddUserToRole(viewSecuritySetup.username, newuserrole);

                        if (String.IsNullOrEmpty(HttpUtility.UrlDecode(viewSecuritySetup.ReturnUrl)))
                        {
                            viewSecuritySetup.ReturnUrl = "/Account/Logon?portal=admin";
                        }

                        var db1 = new UsersDataContext();
                        //The following line is creating a message with a null status on purpose. Due to the actionGUID being used in the emails following. Note also this is S1_Users instead of S1_Messages
                        var results1 = db.S1_Users_CreateMessageWithAction(1, subject, result.UserID, 1, 0, 3, HttpUtility.UrlDecode(viewSecuritySetup.ReturnUrl), System.DateTime.Now, null).SingleOrDefault();

                        if (results1.ActionGUID != null)
                        {
                            string ReturnURL = "/Account/ConfirmEmail";

                            var db3     = new ClientsDataContext();
                            var result3 = db3.S1_Clients_GetClientsFromUser(result.UserID).SingleOrDefault();

                            if (result3 == null)
                            {
                                //todo;
                            }
                            else
                            {
                                clientname    = result3.ClientName;
                                clientaddr1   = result3.Address1;
                                clientaddr2   = result3.Address2;
                                clientcity    = result3.City;
                                clientstate   = result3.State;
                                clientzipcode = result3.ZipCode;
                            }

                            Provider.ChangePasswordQuestionAndAnswer(viewSecuritySetup.username, viewSecuritySetup.password, "What is your Company's zipcode?", clientzipcode);

                            Dictionary <string, string> messagevalues = new Dictionary <string, string>();
                            messagevalues.Add("[[USER_FIRSTNAME]]", "");
                            messagevalues.Add("[[USER_MI]]", "");
                            messagevalues.Add("[[USER_LASTNAME]]", "");
                            messagevalues.Add("[[USER_TITLE]]", "");
                            messagevalues.Add("[[COMPANY_ADDRESS_LINE1]]", clientaddr1);
                            messagevalues.Add("[[COMPANY_ADDRESS_LINE2]]", clientaddr2);
                            messagevalues.Add("[[COMPANY_ADDRESS_CITY]]", clientcity);
                            messagevalues.Add("[[COMPANY_ADDRESS_STATE]]", clientstate);
                            messagevalues.Add("[[COMPANY_ADDRESS_ZIPCODE]]", clientzipcode);
                            messagevalues.Add("[[USER_EMAIL]]", viewSecuritySetup.email);
                            messagevalues.Add("[[USER_PHONE]]", "");
                            messagevalues.Add("[[USERNAME]]", viewSecuritySetup.username);
                            messagevalues.Add("[[COMPANYNAME]]", clientname);
                            messagevalues.Add("[[GUIDURL]]", System.Configuration.ConfigurationManager.AppSettings["DefaultPath"] + ReturnURL + "/" + results1.ActionGUID.ToString() + "?portal=client");
                            messagevalues.Add("[[CORPORATENAME]]", System.Configuration.ConfigurationManager.AppSettings["CompanyName"]);

                            MailGun.SendEmailToUserFromTemplate(10, 0, "Create Client Account", 0, result.UserID.Value, 0, subject, messagevalues);

                            return(new JsonResult {
                                Data = new { success = true }
                            });

                            /*var messageRecord = Messages.GetMessageTemplateRecord(0, "Create Client Account", messagevalues);
                             *
                             * string messagebody = messageRecord != null ? messageRecord.MessageText : null;
                             *
                             * if (messagebody != null)
                             * {
                             *  int messageActionType = messageRecord.MessageActionTypeID.GetValueOrDefault();
                             *  int? MessageIDOutput = new int?();
                             *  Guid? MessageActionGuidOutput = new Guid?();
                             *
                             *  Messages.CreateMessageWithAction(messageActionType, subject, messagebody, result.UserID, 1, 0, 3, HttpUtility.UrlDecode(ReturnURL), System.DateTime.Now, null, "HTML", ref MessageIDOutput, ref MessageActionGuidOutput);
                             *  Messages.UpdateMessageAndMarkForSending(MessageIDOutput.Value, subject, messagebody);
                             *
                             *  return new JsonResult { Data = new { success = true } };
                             * }
                             * else
                             * {
                             *  ModelState.AddModelError("*", "There was a problem sending the confirmation email.  Please re-create a new account.  We apologize for the inconvenience.");
                             *  HandleCreateClientUserErrors(viewSecuritySetup, fc);
                             *  return new JsonResult
                             *  {
                             *      Data = new
                             *      {
                             *          success = false,
                             *          view = RenderToString.RenderViewToString(this, "CreateClientUser", viewSecuritySetup)
                             *      }
                             *  };
                             * }*/
                        }

                        ModelState.AddModelError("*", "There was a problem sending the confirmation email.  Please re-create a new account.  We apologize for the inconvenience.");
                        HandleCreateClientUserErrors(viewSecuritySetup, fc);
                        return(new JsonResult
                        {
                            Data = new
                            {
                                success = false,
                                view = RenderToString.RenderViewToString(this, "CreateClientUser", viewSecuritySetup)
                            }
                        });
                    }
                    else
                    {
                        ModelState.AddModelError("*", ErrorHandler.ErrorCodeToString(createStatus));
                        HandleCreateClientUserErrors(viewSecuritySetup, fc);
                        return(new JsonResult
                        {
                            Data = new
                            {
                                success = false,
                                view = RenderToString.RenderViewToString(this, "CreateClientUser", viewSecuritySetup)
                            }
                        });
                    }
                }
                else
                {
                    ViewData.ModelState.AddModelError("*", ErrorHandler.ErrorCodeToString(createStatus));
                    HandleCreateClientUserErrors(viewSecuritySetup, fc);
                    return(new JsonResult
                    {
                        Data = new
                        {
                            success = false,
                            view = RenderToString.RenderViewToString(this, "CreateClientUser", viewSecuritySetup)
                        }
                    });
                }
            }
            return(new JsonResult
            {
                Data = new
                {
                    success = false,
                    view = RenderToString.RenderViewToString(this, "CreateClientUser", viewSecuritySetup)
                }
            });
            //return new JsonResult { Data = new { success = true } };
        }
Ejemplo n.º 6
0
        public JsonResult CreateClientJSON(string ClientName, string Address1, string Address2, string City, string State, string Zip, bool Tazworks1Client, bool Tazworks2Client, bool NonTazworksClient)
        {
            System.Text.RegularExpressions.Regex nonUTF8 = new System.Text.RegularExpressions.Regex("[^\x00-\x7F]+");

            ClientName = ClientName == null ? "" : nonUTF8.Replace(ClientName, " ").SingleSpaceOnly();
            Address1   = Address1 == null ? "" : nonUTF8.Replace(Address1, " ").SingleSpaceOnly();
            Address2   = Address2 == null ? "" : nonUTF8.Replace(Address2, " ").SingleSpaceOnly();
            City       = City == null ? "" : nonUTF8.Replace(City, " ").SingleSpaceOnly();
            State      = State == null ? "" : nonUTF8.Replace(State, " ").SingleSpaceOnly();
            Zip        = Zip == null ? "" : nonUTF8.Replace(Zip, " ").SingleSpaceOnly();

            Clients_Details viewClients_Details = new Clients_Details();

            viewClients_Details.ClientName        = ClientName;
            viewClients_Details.Address1          = Address1;
            viewClients_Details.Address2          = Address2;
            viewClients_Details.City              = City;
            viewClients_Details.State             = State;
            viewClients_Details.Zip               = Zip;
            viewClients_Details.ClientID          = 0;
            viewClients_Details.Tazworks1Client   = Tazworks1Client;
            viewClients_Details.Tazworks2Client   = Tazworks2Client;
            viewClients_Details.NonTazworksClient = NonTazworksClient;


            if (String.IsNullOrEmpty(ClientName))
            {
                ViewData.ModelState.AddModelError("ClientName", " ");
                viewClients_Details.ClientName = "";
            }

            if (String.IsNullOrEmpty(Address1))
            {
                ViewData.ModelState.AddModelError("Address1", " ");
                viewClients_Details.Address1 = "";
            }

            if (String.IsNullOrEmpty(Address2))
            {
                viewClients_Details.Address2 = "";
            }

            if (String.IsNullOrEmpty(City))
            {
                ViewData.ModelState.AddModelError("City", " ");
                viewClients_Details.City = "";
            }

            if (String.IsNullOrEmpty(State))
            {
                ViewData.ModelState.AddModelError("State", " ");
                viewClients_Details.State = "";
            }

            if (String.IsNullOrEmpty(Zip))
            {
                ViewData.ModelState.AddModelError("Zip", " ");
                viewClients_Details.Zip = "";
            }

            if (!Tazworks1Client && !Tazworks2Client && !NonTazworksClient)
            {
                ViewData.ModelState.AddModelError("TazworksClient", "You must select at least 1 Tazworks system or select Non-Tazworks Client. ");
            }

            if (ViewData.ModelState.IsValid)
            {
                viewClients_Details.ClientID = Clients.CreateClient(ClientName, Address1, Address2, City, State, Zip, Tazworks1Client, Tazworks2Client, NonTazworksClient);

                if (viewClients_Details.ClientID == 0)
                {
                    return(new JsonResult
                    {
                        Data = new
                        {
                            success = false,
                            view = RenderToString.RenderViewToString(this, "CreateClient", viewClients_Details)
                        }
                    });
                }
                else
                {
                    return(new JsonResult
                    {
                        Data = new
                        {
                            success = true,
                            clientid = viewClients_Details.ClientID
                        }
                    });
                }
            }
            else
            {
                return(new JsonResult
                {
                    Data = new
                    {
                        success = false,
                        view = RenderToString.RenderViewToString(this, "CreateClient", viewClients_Details)
                    }
                });
            }
        }