コード例 #1
0
        /// <summary>
        /// Creates the user and profile.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public static string CreateUserAndProfile(UserDetails user)
        {
            if (user.IsValid)
            {
                //save profile details too
                ProfileCommon p          = new ProfileCommon();
                ProfileCommon newProfile = p.GetProfile(user.UserName);
                newProfile.WarehouseId     = user.WarehouseId;
                newProfile.RegionId        = user.RegionId;
                newProfile.OpCoId          = user.OpCoId;
                newProfile.SalesLocationId = user.SalesLocationId;
                newProfile.OpCoCode        = "";
                newProfile.RegionCode      = "";
                if (user.OpCoId != -1)
                {
                    newProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code;
                }

                if (user.RegionId != -1)
                {
                    newProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code;
                }

                newProfile.Save();


                Membership.CreateUser(user.UserName, user.NewPassword, user.Email);
                return(user.UserName);
            }
            return("");
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:UserDetails"/> class.
        /// </summary>
        /// <param name="membershipUser">The membership user.</param>
        /// <param name="getProfile">if set to <c>true</c> [get profile].</param>
        public UserDetails(MembershipUser membershipUser, bool getProfile)
        {
            if (membershipUser != null)
            {
                UserName         = membershipUser.UserName;
                Email            = membershipUser.Email;
                LastActivityDate = membershipUser.LastActivityDate.ToShortDateString();

                if (getProfile)
                {
                    ProfileCommon p       = new ProfileCommon();
                    ProfileCommon profile = p.GetProfile(membershipUser.UserName);


                    if (profile != null)
                    {
                        OpCoId          = profile.OpCoId;
                        OpCoCode        = profile.OpCoCode;
                        RegionId        = profile.RegionId;
                        RegionCode      = profile.RegionCode;
                        WarehouseId     = profile.WarehouseId;
                        SalesLocationId = profile.SalesLocationId;
                        SalesLocation   = SalesLocationController.GetLocation(salesLocationId, false);
                        OpCo            = OpcoController.GetOpCo(OpCoId, false);
                        Warehouse       = WarehouseController.GetWarehouse(WarehouseId);
                        Region          = OptrakRegionController.GetRegion(RegionId);
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Processes the request.
        /// </summary>
        /// <param name="requestMessage">The request message.</param>
        public override void ProcessRequest(RequestMessage requestMessage)
        {
            Trip.SetTripSchema(textFieldParser.TextFields);

            //get all warehouse objects in one hit for performance
            allWarehouses = WarehouseController.GetWarehouses(false);

            //get all regions in one hit for performance
            allRegions = OptrakRegionController.GetRegions();

            try
            {
                textFieldParser.FirstLineIsHeader = true;
                textFieldParser.FileType          = TextFieldParser.FileFormat.Delimited;
                textFieldParser.Delimiter         = '|';
                textFieldParser.TrimWhiteSpace    = true;
                // Set up event handlers for when a row is read and when a row is read but failes to match the expected schema
                textFieldParser.RecordFound  += new TextFieldParser.RecordFoundHandler(textParser_RecordFound);
                textFieldParser.RecordFailed += new TextFieldParser.RecordFailedHandler(RecordFailed);

                // parse the message
                textFieldParser.ParseFileContents(requestMessage.Body);

                // Processed
                Status = SaveTrips();
            }
            catch (Exception ex)
            {
                // Store the exception
                LastError = ex;

                // Failed
                Status = SubscriberStatusEnum.Failed;
            }
        }
コード例 #4
0
        /// <summary>
        /// Updates the user and profile.
        /// </summary>
        /// <param name="user">The user.</param>
        public static string UpdateUserAndProfile(UserDetails user)
        {
            if (user.IsValid)
            {
                MembershipUser membershipUser = Membership.GetUser(user.UserName);
                membershipUser.Email = user.Email;
                bool success = true;
                if (!string.IsNullOrEmpty(user.OldPassword) && !string.IsNullOrEmpty(user.NewPassword))
                {
                    success = membershipUser.ChangePassword(user.OldPassword, user.NewPassword);
                }
                if (success)
                {
                    Membership.UpdateUser(membershipUser);

                    //update profile too
                    ProfileCommon p = new ProfileCommon();
                    ProfileCommon selectedProfile = p.GetProfile(user.UserName);
                    selectedProfile.WarehouseId     = user.WarehouseId;
                    selectedProfile.RegionId        = user.RegionId;
                    selectedProfile.SalesLocationId = user.SalesLocationId;
                    selectedProfile.OpCoId          = user.OpCoId;
                    selectedProfile.OpCoCode        = "";
                    selectedProfile.RegionCode      = "";
                    if (user.OpCoId != -1)
                    {
                        selectedProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code;
                    }

                    if (user.RegionId != -1)
                    {
                        selectedProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code;
                    }

                    selectedProfile.Save();

                    return(user.UserName);
                }
                else
                {
                    throw new SystemException("The Password has not be successfully changed.");
                }
            }
            return("");
        }
コード例 #5
0
        private void PopulateRegions()
        {
            // Get the region drop down
            DropDownList dropDownListRegion    = GetControl <DropDownList>("ddlRegion", PageFormView);
            DropDownList dropDownListWarehouse = GetControl <DropDownList>("ddlWarehouse", PageFormView);

            // Populate the list of regions
            dropDownListRegion.DataSource = OptrakRegionController.GetRegions();
            dropDownListRegion.DataBind();

            // Now add the all
            dropDownListRegion.Items.Insert(0, new ListItem("All", "-1"));
            dropDownListWarehouse.Items.Insert(0, new ListItem("All", "-1"));

            // Now disable the warehouse
            dropDownListWarehouse.Items[0].Selected = true;
            dropDownListWarehouse.Enabled           = false;
        }
コード例 #6
0
ファイル: Region.cs プロジェクト: PaulNichols/Old-Projects
 public void GetItems()
 {
     using (TransactionScope scope = new TransactionScope())
     {
         //add a region
         int id = OptrakRegionController.SaveRegion(PopulateNewItem());
         if (id > -1)
         {
             //retrieve all regions and the one we saved should return at least
             List <OptrakRegion> regions = OptrakRegionController.GetRegions();
             //so the count should be >0
             Assert.IsTrue(regions.Count > 0);
             //check for our new id
             Assert.IsTrue(regions.Find(delegate(OptrakRegion currentItem)
             {
                 return(currentItem.Id == id);
             }) != null);
         }
     }
 }
コード例 #7
0
ファイル: Region.cs プロジェクト: PaulNichols/Old-Projects
 internal OptrakRegion GetItem(int id)
 {
     return(OptrakRegionController.GetRegion(id));
 }
コード例 #8
0
ファイル: Region.cs プロジェクト: PaulNichols/Old-Projects
 internal int SaveItem(OptrakRegion optrakRegion)
 {
     return(OptrakRegionController.SaveRegion(optrakRegion));
 }
コード例 #9
0
ファイル: Region.cs プロジェクト: PaulNichols/Old-Projects
 internal bool DeleteItem(OptrakRegion optrakRegion)
 {
     return(OptrakRegionController.DeleteRegion(optrakRegion));
 }