Beispiel #1
0
        private List <string> ListMatchingUserName(string startsWith)
        {
            // To avoid lots of SQL calls here, we try to make use of caching as best we can

            // 1. Have we got a cached Dictionary to check yet?
            Dictionary <string, List <string> > dictionary = Cache[Globals.CacheKeys.UserNameDictionaryCacheEntry] as Dictionary <string, List <string> >;

            if (null == dictionary) // Create one
            {
                dictionary = new Dictionary <string, List <string> >();
            }

            // 2. Do we have an entry in the dictionary already or do we have to fetch and store?
            List <string> resultList = null;

            if (dictionary.ContainsKey(startsWith))
            {
                resultList = dictionary[startsWith];
            }
            else
            {
                int?orgId = null;
                OrganisationSettings settings = new OrganisationSettings();
                if (!string.IsNullOrEmpty(settings.OrganisationId))
                {
                    orgId = Convert.ToInt32(settings.OrganisationId);
                }

                resultList = ApartmentMethods.ListUserName(Membership.ApplicationName, orgId, startsWith);
                dictionary.Add(startsWith, resultList);
                Cache[Globals.CacheKeys.UserNameDictionaryCacheEntry] = dictionary;
            }

            return(resultList);
        }
        public GlobalVariable GetGlobalVariable()
        {
            GlobalVariable result = new GlobalVariable();

            result.AppSettings = GetAppSettings();
            result.UserLogin   = GetUserLogin();
            result.TagVersion  = ApartmentMethods.GetLatestTagVersion();
            //result.Licenses = General.ListLicense(null);
            //result.UserLogin.UserModuleTypes = new List<ModuleTypes>();


            return(result);
        }
        private void SendOnePaymentMail(SmtpClient smtpClient, BookingPayment paymentItem)
        {
            MailMessage     message   = new MailMessage();
            List <Customer> customers = ApartmentMethods.ListCustomer(null, paymentItem.CustomerId, null, null, null, false, null, null, true);
            string          email     = string.Empty;

            if (customers.Count > 0 && customers[0].ContactInformation != null && !string.IsNullOrEmpty(customers[0].ContactInformation.Email))
            {
                email = customers[0].ContactInformation.Email;
            }

            if (!string.IsNullOrEmpty(email))
            {
                string dateFormat  = "dd-MMM-yyyy";
                string moneyFormat = "C0";
                message.To.Add(new MailAddress(email));
                string subject = string.Format("Payment Details from {0} to {1}", paymentItem.DateStart.ToString(dateFormat), paymentItem.DateEnd.ToString(dateFormat));
                message.Subject    = subject;
                message.IsBodyHtml = true;

                using (FileStream stream = File.OpenRead(HttpContext.Current.Server.MapPath("/EmailTemplates/MonthlyPayment.htm")))
                {
                    StringBuilder strb = new StringBuilder();
                    byte[]        b    = new byte[stream.Length];
                    UTF8Encoding  temp = new UTF8Encoding(true);
                    while (stream.Read(b, 0, b.Length) > 0)
                    {
                        strb.Append(temp.GetString(b));
                    }
                    string content = strb.ToString();

                    CultureInfo customCultureInfo = new CultureInfo(MimosaSettings.GloblaCulture());
                    customCultureInfo.NumberFormat   = (new CultureInfo(MimosaSettings.NumberFormatCulture())).NumberFormat;
                    customCultureInfo.DateTimeFormat = (new CultureInfo(MimosaSettings.DateTimeFormatCulture())).DateTimeFormat;

                    Thread.CurrentThread.CurrentCulture = customCultureInfo;

                    content = string.Format(content, paymentItem.CustomerName, subject, paymentItem.SiteName, paymentItem.RoomName,
                                            paymentItem.DateStart.ToString(dateFormat), paymentItem.DateEnd.ToString(dateFormat),
                                            paymentItem.RoomPrice.ToString(moneyFormat),
                                            paymentItem.EquipmentPrice.ToString(moneyFormat),
                                            paymentItem.ServicePrice.ToString(moneyFormat),
                                            paymentItem.TotalPrice.ToString(moneyFormat),
                                            paymentItem.CustomerPaid.ToString(moneyFormat),
                                            paymentItem.MoneyLeft.ToString(moneyFormat));
                    message.Body = content;

                    smtpClient.Send(message);
                }
            }
        }
        public UserLogin GetUserLogin()
        {
            MembershipUser loginUser = Membership.GetUser();
            UserLogin      settings  = new UserLogin();

            if (loginUser != null)
            {
                settings.UserName   = loginUser.UserName;
                settings.UserUserId = Utilities.ToGuid(loginUser.ProviderUserKey);
                //settings.UserSiteId = SiteMethods.GetSiteIdForEmployee(settings.UserUserId);
                //settings.UserLicenseKeys = General.ListLicenseKeyByUserId(settings.UserUserId);

                OrganisationSettings orgSetting = new OrganisationSettings();
                settings.UserOrganisationId = Convert.ToInt32(orgSetting.OrganisationId);

                settings.UserOrganisation = ApartmentMethods.GetOrganisation(settings.UserOrganisationId);
                //settings.UserSite = settings.UserSiteId.HasValue ? SiteMethods.GetSite(settings.UserSiteId.Value) : null;


                //settings.ActiveModules = Role.ListActiveModules();
                settings.AspUser = GetAspUser(settings.UserUserId);
                //settings.UserEmployeeId = EmployeeMethods.GetEmployeeId(settings.UserUserId);

                settings.RoleComponentPermissions = ApartmentMethods.ListRoleComponentPermissionByUser(settings.UserUserId);
                if (!settings.AspUser.OrganisationId.HasValue)
                {
                    settings.UserRoleAuths = ApartmentMethods.ListUserRoleAuth(null, settings.UserUserId, null);
                }
                else
                {
                    settings.UserRoleAuths = ApartmentMethods.ListUserRoleAuth(settings.UserOrganisationId, settings.UserUserId, null);
                }

                if (settings.UserSite == null && settings.UserRoleAuths != null && settings.UserRoleAuths.Count > 0 &&
                    settings.UserRoleAuths.Count(i => i.SiteId.HasValue) > 0)
                {
                    settings.UserSiteId = settings.UserRoleAuths.FirstOrDefault(i => i.SiteId.HasValue).SiteId.Value;
                    List <Site> sites = ApartmentMethods.ListSite(null, settings.UserSiteId.Value, true, false);
                    if (sites.Count > 0)
                    {
                        settings.UserSite = sites[0];
                    }
                }
            }
            return(settings);
        }
Beispiel #5
0
        // If we're using the combo, put combo value into the original username textbox so normal processing can occur
        private void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
        {
            Login1.UserName = _userNameCombo.AllowCustomText && _userNameCombo.Value == string.Empty ? _userNameCombo.Text : _userNameCombo.Value;
            MembershipUser userInfo = Membership.GetUser(Login1.UserName);

            if (userInfo != null)
            {
                OrganisationSettings settings    = new OrganisationSettings();
                List <AspUser>       aspUserList = ApartmentMethods.ListAspUser(null, (Guid)userInfo.ProviderUserKey, null);
                if (aspUserList == null || aspUserList.Count == 0 ||
                    (aspUserList[0].OrganisationId.HasValue && aspUserList[0].OrganisationId != Convert.ToInt32(settings.OrganisationId)))
                {
                    this.ExtraErrorInformation.Text = Properties.Resources.UserLoginWrongOrg;
                    e.Cancel = true;
                }
            }
            Response.Cookies["ActiveModule"].Value = string.Empty;
        }
        public void ValidateApartment_NotEmptyStringReturned()
        {
            var apartment = new Apartment()
            {
                BedId  = 1,
                RoomId = 1,
                Id     = 1,
                Clinic = new Clinic1()
                {
                    Id      = 1,
                    Code    = "",
                    Name    = "Clinic",
                    Address = "Address"
                }
            };

            string result = ApartmentMethods.ValidateApartment(apartment);

            Assert.IsNotNullOrEmpty(result);
        }
Beispiel #7
0
        /// <summary>
        /// Validates if the authorisation code as passed is the code for any organisation in the db
        /// or is the special non-organisation high level portal admin password as defined in web.config
        /// </summary>
        /// <param name="authorisationCode">User entered authorisation code.</param>
        /// <returns>An OrganisationSettings with IsValid=true where authcode/password valid.
        /// Else an OrganisationSettings with IsValid=false.
        /// </returns>
        public static OrganisationSettings Validate(string authorisationCode)
        {
            OrganisationSettings result = null;

            // Portal Admins gain access to the login controls by entering config code in org authorisation code.
            // All other users need to have an organisation cookie set before logging in.
            if (authorisationCode == _portalAdminOrgCode)
            {
                result = new OrganisationSettings(true, _portalAdminDisplay, _portalAdminDisplay);
                result.Save();
            }
            else
            {
                Organisation org = ApartmentMethods.GetOrganisation(authorisationCode);
                if (null != org)
                {
                    result = new OrganisationSettings(false, org.NullableRecordId.ToString(), org.Name);
                    result.Save();
                }
            }

            return(result);
        }
 public void SaveBookingRoomServiceDetail(List <BookingRoomServiceDetail> saveList)
 {
     ApartmentMethods.SaveBookingRoomServiceDetail(saveList);
 }
 public List <BookingRoomServiceDetail> ListBookingRoomServiceDetail(int?bookingRoomServiceDetailId, int?bookingRoomServiceId,
                                                                     int?bookingId, DateTime?dateStart, DateTime?dateEnd)
 {
     return(ApartmentMethods.ListBookingRoomServiceDetail(bookingRoomServiceDetailId, bookingRoomServiceId, bookingId, dateStart, dateEnd));
 }
 public List <BookingRoomService> ListBookingRoomService(int?bookingRoomServiceId, int?bookingId, int?roomServiceId)
 {
     return(ApartmentMethods.ListBookingRoomService(bookingRoomServiceId, bookingId, roomServiceId));
 }
 public void SaveRoomService(List <RoomService> saveList)
 {
     ApartmentMethods.SaveRoomService(saveList);
 }
 public List <SiteGroupSite> ListSiteGroupSite(int?siteGroupId, int?siteId)
 {
     return(ApartmentMethods.ListSiteGroupSite(siteGroupId, siteId));
 }
 public void SaveRoom(List <Room> saveList)
 {
     ApartmentMethods.SaveRoom(saveList);
 }
 public List <BookingRoomEquipment> ListBookingRoomEquipment(int?bookingRoomEquipmentId, int?bookingId, int?roomEquipmentId)
 {
     return(ApartmentMethods.ListBookingRoomEquipment(bookingRoomEquipmentId, bookingId, roomEquipmentId));
 }
 public List <BookingPayment> ListBookingPayment(int?orgId, int?siteId, int?roomId, int?bookingId, int?bookingPaymentId,
                                                 DateTime dateStart, DateTime dateEnd, int payment)
 {
     return(ApartmentMethods.ListBookingPayment(orgId, siteId, roomId, bookingId, bookingPaymentId, dateStart, dateEnd, payment));
 }
 public void SaveBooking(List <Booking> saveList)
 {
     ApartmentMethods.SaveBooking(saveList);
 }
 public bool CheckExistBooking(int roomId, DateTime dateStart, DateTime dateEnd)
 {
     return(ApartmentMethods.CheckExistBooking(roomId, dateStart, dateEnd));
 }
 public List <Booking> ListBooking(int orgId, int?siteId, int?roomId, string roomName, int?bookingId, string bookingStatusIds,
                                   int?customerId, string customerName, DateTime?bookDateStart, DateTime?bookDateEnd)
 {
     return(ApartmentMethods.ListBooking(orgId, siteId, roomId, roomName, bookingId, bookingStatusIds,
                                         customerId, customerName, bookDateStart, bookDateEnd));
 }
 public void SaveImage(List <Image> saveList)
 {
     ApartmentMethods.SaveImage(saveList);
 }
 public List <Image> ListImage(int?imageId, int?itemId, int?imageTypeId, int loadType)
 {
     return(ApartmentMethods.ListImage(imageId, itemId, imageTypeId, loadType));
 }
 public List <SiteGroup> ListSiteGroup(int?orgId, int?siteGroupId)
 {
     return(ApartmentMethods.ListSiteGroup(orgId, siteGroupId));
 }
 public void SaveRoomEquipment(List <RoomEquipment> saveList)
 {
     ApartmentMethods.SaveRoomEquipment(saveList);
 }
 public List <Site> ListSiteBySiteGroup(int?siteGroupId, bool?showLegacy, bool loadContact)
 {
     return(ApartmentMethods.ListSiteBySiteGroup(siteGroupId, showLegacy, loadContact));
 }
 public void SaveBookingPayment(List <BookingPayment> saveList)
 {
     ApartmentMethods.SaveBookingPayment(saveList);
 }
 public void SaveSiteGroupSites(List <SiteGroupSite> saveList)
 {
     ApartmentMethods.SaveSiteGroupSites(saveList);
 }
 public List <RoomEquipment> ListRoomEquipment(int?roomEquipmentId, int?roomId)
 {
     return(ApartmentMethods.ListRoomEquipment(roomEquipmentId, roomId));
 }
 public List <Room> ListRoom(int orgId, int?siteId, int?roomId, string roomName, string roomStatusIds, string roomTypeIds, int?floor, bool showLegacy)
 {
     return(ApartmentMethods.ListRoom(orgId, siteId, roomId, roomName, roomStatusIds, roomTypeIds, floor, showLegacy));
 }
 public void SaveBookingRoomEquipmentDetail(List <BookingRoomEquipmentDetail> saveList)
 {
     ApartmentMethods.SaveBookingRoomEquipmentDetail(saveList);
 }
 public List <BookingPayment> ListHistoryPayment(int?orgId, int?siteId, int?roomId, int?customerId,
                                                 DateTime dateStart, DateTime dateEnd, int payment)
 {
     return(ApartmentMethods.ListHistoryPayment(orgId, siteId, roomId, customerId, dateStart, dateEnd, payment));
 }
 public List <RoomService> ListRoomService(int?roomServiceId, int?roomId)
 {
     return(ApartmentMethods.ListRoomService(roomServiceId, roomId));
 }