示例#1
0
        public bool SetInfoSetting(SettingView viewModel)
        {
            InfoSettings infoSettings = new InfoSettings();
            var          config       = new MapperConfiguration(cfg => cfg.CreateMap <InfoSettingView, InfoSettings>());
            var          mapper       = config.CreateMapper();

            infoSettings = mapper.Map <InfoSettings>(viewModel.InfoSettingView);
            if (viewModel.InfoSettingView.EnvironmentFile != null)
            {
                foreach (var file in viewModel.InfoSettingView.EnvironmentFile)
                {
                    if (file != null)
                    {
                        var fileName = new System.IO.FileInfo(file.FileName).Name;
                        var s        = MobileHis.Misc.Storage.GetStorage(StorageScope.HospitalEnvironment);

                        fileName = s.Write(fileName, file);
                        if (!string.IsNullOrEmpty(infoSettings.Hospital_Environment))
                        {
                            infoSettings.Hospital_Environment += ";";
                        }
                        infoSettings.Hospital_Environment += fileName;
                    }
                }
            }
            if (!ValidationDictionary.IsValid())
            {
                return(false);
            }
            SetGroupSetting(SettingTypes.Info, infoSettings);
            Save();
            return(true);
        }
示例#2
0
        public bool SetMailSetting(SettingView viewModel)
        {
            MailSettings mailSettings = new MailSettings();
            var          config       = new MapperConfiguration(cfg => cfg.CreateMap <MailSettingView, MailSettings>());
            var          mapper       = config.CreateMapper();

            mailSettings = mapper.Map <MailSettings>(viewModel.MailSettingView);
            if (!ValidationDictionary.IsValid())
            {
                return(false);
            }
            SetGroupSetting(SettingTypes.Mail, mailSettings);
            Save();
            return(true);
        }
示例#3
0
        public bool SetOthersSetting(SettingView viewModel)
        {
            OtherSettings otherSettings = new OtherSettings();
            var           config        = new MapperConfiguration(cfg => cfg.CreateMap <OthersSettingView, OtherSettings>());
            var           mapper        = config.CreateMapper();

            otherSettings = mapper.Map <OtherSettings>(viewModel.OthersSettingView);
            if (!ValidationDictionary.IsValid())
            {
                return(false);
            }
            SetGroupSetting(SettingTypes.Other, otherSettings);
            Save();
            return(true);
        }
示例#4
0
        public bool SetGeneralSetting(SettingView viewModel)
        {
            DefaultSettings generalSettings = new DefaultSettings();

            var config = new MapperConfiguration(cfg => cfg.CreateMap <SystemSettingView, DefaultSettings>());
            var mapper = config.CreateMapper();

            generalSettings = mapper.Map <DefaultSettings>(viewModel.SystemSettingView);

            if (!TestTimeValid(viewModel.SystemSettingView.Opd_Shift_Morning_Start))
            {
                ValidationDictionary.AddPropertyError <SettingView>(
                    s => s.SystemSettingView.Opd_Shift_Morning_Start, "Wrong Format");
            }
            if (!TestTimeValid(viewModel.SystemSettingView.Opd_Shift_Morning_End))
            {
                ValidationDictionary.AddPropertyError <SettingView>(
                    s => s.SystemSettingView.Opd_Shift_Morning_End, "Wrong Format");
            }
            if (!TestTimeValid(viewModel.SystemSettingView.Opd_Shift_Afternoon_Start))
            {
                ValidationDictionary.AddPropertyError <SettingView>(
                    s => s.SystemSettingView.Opd_Shift_Afternoon_Start, "Wrong Format");
            }
            if (!TestTimeValid(viewModel.SystemSettingView.Opd_Shift_Afternoon_End))
            {
                ValidationDictionary.AddPropertyError <SettingView>(
                    s => s.SystemSettingView.Opd_Shift_Afternoon_End, "Wrong Format");
            }
            if (!TestTimeValid(viewModel.SystemSettingView.Opd_Shift_Night_Start))
            {
                ValidationDictionary.AddPropertyError <SettingView>(
                    s => s.SystemSettingView.Opd_Shift_Night_Start, "Wrong Format");
            }
            if (!TestTimeValid(viewModel.SystemSettingView.Opd_Shift_Night_End))
            {
                ValidationDictionary.AddPropertyError <SettingView>(
                    s => s.SystemSettingView.Opd_Shift_Night_End, "Wrong Format");
            }
            if (viewModel.SystemSettingView.BK_img_file != null)
            {
                var s = MobileHis.Misc.Storage.GetStorage(StorageScope.backgroundImg);
                generalSettings.BK_img = s.Write(
                    viewModel.SystemSettingView.BK_img_file.FileName, viewModel.SystemSettingView.BK_img_file);
            }
            if (viewModel.SystemSettingView.Official_Banner_Img_file != null)
            {
                var s = MobileHis.Misc.Storage.GetStorage(StorageScope.Official);
                generalSettings.Official_Banner_Img = s.Write(
                    viewModel.SystemSettingView.Official_Banner_Img_file.FileName,
                    viewModel.SystemSettingView.Official_Banner_Img_file);
            }
            if (viewModel.SystemSettingView.Official_Logo_Img_file != null)
            {
                var s = MobileHis.Misc.Storage.GetStorage(StorageScope.Official);
                generalSettings.Official_Logo_Img = s.Write(
                    viewModel.SystemSettingView.Official_Logo_Img_file.FileName,
                    viewModel.SystemSettingView.Official_Logo_Img_file);
            }
            if (viewModel.SystemSettingView.PartnerFile != null)
            {
                var settings     = db.Repository <Setting>().ReadAll().Include(a => a.ParentSetting);
                var partnerImage = settings.Where(a => a.SettingName.Contains("Partner") &&
                                                  a.ParentSetting.SettingName == SettingTypes.Default.ToString() &&
                                                  string.IsNullOrEmpty(a.Value))
                                   .OrderBy(a => a.SettingName).ToList();
                var cnt = 0;
                foreach (var file in viewModel.SystemSettingView.PartnerFile)
                {
                    if (file != null)
                    {
                        var fileName = new System.IO.FileInfo(file.FileName).Name;
                        var s        = MobileHis.Misc.Storage.GetStorage(StorageScope.Official);
                        fileName = s.Write(fileName, file);
                        partnerImage[cnt].Value = fileName;
                        //settingDAL.Edit(partnerImage[cnt]);
                        cnt++;
                    }
                }
            }
            if (!ValidationDictionary.IsValid())
            {
                return(false);
            }
            SetGroupSetting(SettingTypes.Default, generalSettings);
            Save();
            return(true);
        }