示例#1
0
        public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
        {
            var policys = Policys.Split(";").ToList();

            if (IsAnd)
            {
                foreach (var policy in policys)
                {
                    var authorized = await _authorization.AuthorizeAsync(context.HttpContext.User, policy);

                    if (!authorized.Succeeded)
                    {
                        context.Result = new ForbidResult();
                        return;
                    }
                }
            }
            else
            {
                foreach (var policy in policys)
                {
                    var authorized = await _authorization.AuthorizeAsync(context.HttpContext.User, policy);

                    if (authorized.Succeeded)
                    {
                        return;
                    }
                }
                context.Result = new ForbidResult();
                return;
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,PolicyNumber,DateBegin,DateEnd,Cost,Summ,TypeId,PaymentMark,EndMark,ClientId,StaffId")] Policys policys)
        {
            if (id != policys.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(policys);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PolicysExists(policys.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "ClientName");
            ViewData["StaffId"]  = new SelectList(_context.Staffs, "Id", "StaffName");
            ViewData["TypeId"]   = new SelectList(_context.PolicyTypes, "Id", "PolicyName");
            return(View(policys));
        }
示例#3
0
 public PolicyListVM()
 {
     init();
     Policys.Add(new PolicyDTOWithActions {
         Id = 4, Name = "Test"
     });
 }
示例#4
0
        private void AddPolicy(object parameter)
        {
            if (CheckDayOfWeek())
            {
                return;
            }

            CurrentPolicy.SelectedTime = (DateTime)parameter;//通过绑定无法获取到值 原因不明
            BackUpPolicy policy = Policys.FirstOrDefault(x => x.BackUpType == CurrentPolicy.BackUpType);

            if (policy == null)
            {
                Policys.Add(new BackUpPolicy()
                {
                    Sunday    = CurrentPolicy.Sunday,
                    Monday    = CurrentPolicy.Monday,
                    Tuesday   = CurrentPolicy.Tuesday,
                    Wednesday = CurrentPolicy.Wednesday,
                    Thursday  = CurrentPolicy.Thursday,
                    Friday    = CurrentPolicy.Friday,
                    Saturday  = CurrentPolicy.Saturday,

                    SelectedTime         = CurrentPolicy.SelectedTime,
                    IsTaskBackUpDataBase = CurrentPolicy.IsTaskBackUpDataBase,
                    IsTaskBackUpTables   = CurrentPolicy.IsTaskBackUpTables,
                    ItemString           = CurrentPolicy.PolicyToString
                });

                Notice.Show("策略已添加成功", "通知");
            }
            else
            {
                policy.Sunday               = CurrentPolicy.Sunday;
                policy.Monday               = CurrentPolicy.Monday;
                policy.Tuesday              = CurrentPolicy.Tuesday;
                policy.Wednesday            = CurrentPolicy.Wednesday;
                policy.Thursday             = CurrentPolicy.Thursday;
                policy.Friday               = CurrentPolicy.Friday;
                policy.Saturday             = CurrentPolicy.Saturday;
                policy.SelectedTime         = CurrentPolicy.SelectedTime;
                policy.IsTaskBackUpDataBase = CurrentPolicy.IsTaskBackUpDataBase;
                policy.IsTaskBackUpTables   = CurrentPolicy.IsTaskBackUpTables;
                policy.ItemString           = CurrentPolicy.PolicyToString;

                Notice.Show("策略已更新成功", "通知", 3, MessageBoxIcon.Success);
            }

            if (CurrentPolicy.BackUpType == BackUpType.DataBase)
            {
                ConfigHelper.WriterAppConfig("DataBaseBackUpJob", ConvertToCron(CurrentPolicy));
            }
            else
            {
                ConfigHelper.WriterAppConfig("TablesBackUpJob", ConvertToCron(CurrentPolicy));
            }

            WriteConfig();
        }
 /// <summary>
 /// 从配置文件读取策略
 /// </summary>
 /// <returns></returns>
 public void ReadPolicyConfig()
 {
     Policys.Clear();
     EnvironmentInfo.BackUpJobConfigs.ForEach(x =>
     {
         BackUpPolicy policy         = ConvertToPolicy(x);
         policy.Id                   = x.Id;
         policy.IsTaskBackUpTables   = x.BackUpType == 1 ? true : false;
         policy.IsTaskBackUpDataBase = x.BackUpType == 0 ? true : false;
         policy.ItemString           = policy.PolicyToString;
         Policys.Add(policy);
     });
 }
        private void AddPolicy(object parameter)
        {
            if (CheckDayOfWeek())
            {
                return;
            }

            CurrentPolicy.SelectedTime = (DateTime)parameter;//通过绑定无法获取到值 原因不明
            BackUpPolicy policy = Policys.FirstOrDefault(x => x.Id == CurrentPolicy.Id);

            if (policy == null)
            {
                Policys.Add(new BackUpPolicy()
                {
                    Id                   = Guid.NewGuid().ToString(),
                    Sunday               = CurrentPolicy.Sunday,
                    Monday               = CurrentPolicy.Monday,
                    Tuesday              = CurrentPolicy.Tuesday,
                    Wednesday            = CurrentPolicy.Wednesday,
                    Thursday             = CurrentPolicy.Thursday,
                    Friday               = CurrentPolicy.Friday,
                    Saturday             = CurrentPolicy.Saturday,
                    SelectedTime         = CurrentPolicy.SelectedTime,
                    IsTaskBackUpDataBase = CurrentPolicy.IsTaskBackUpDataBase,
                    IsTaskBackUpTables   = CurrentPolicy.IsTaskBackUpTables,
                    ItemString           = CurrentPolicy.PolicyToString,
                    DataBaseName         = CurrentPolicy.DataBaseName
                });
                Notice.Show("策略已添加成功", "通知", 3, MessageBoxIcon.Success);
            }
            else
            {
                policy.Id                   = CurrentPolicy.Id;
                policy.Sunday               = CurrentPolicy.Sunday;
                policy.Monday               = CurrentPolicy.Monday;
                policy.Tuesday              = CurrentPolicy.Tuesday;
                policy.Wednesday            = CurrentPolicy.Wednesday;
                policy.Thursday             = CurrentPolicy.Thursday;
                policy.Friday               = CurrentPolicy.Friday;
                policy.Saturday             = CurrentPolicy.Saturday;
                policy.SelectedTime         = CurrentPolicy.SelectedTime;
                policy.IsTaskBackUpDataBase = CurrentPolicy.IsTaskBackUpDataBase;
                policy.IsTaskBackUpTables   = CurrentPolicy.IsTaskBackUpTables;
                policy.ItemString           = CurrentPolicy.PolicyToString;
                policy.DataBaseName         = CurrentPolicy.DataBaseName;
                Notice.Show("策略已更新成功", "通知", 3, MessageBoxIcon.Success);
            }

            WritePolicyConfig();
            WriteTablesConfig(CurrentPolicy.DataBaseName);
        }
示例#7
0
        private void Search(int PnrSource = 1)
        {
            Policys.Clear();
            Action action = () =>
            {
                IsBusy = true;

                CommunicateManager.Invoke <IOrderService>(service =>
                {
                    var pnr = Trim(PnrCode);
                    //只有儿童编码和升舱换开时赋值成人(原)订单号
                    pip.OldOrderId        = pip.PnrImportType == Common.Enums.EnumPnrImportType.UpSeatChangePnrImport || pip.PnrImportType == Common.Enums.EnumPnrImportType.CHDPnrImport ? OrderID : string.Empty;
                    pip.PnrAndPnrContent  = pnr;
                    pip.IsChangePnrTicket = IsChangePnrTicket;
                    pip.IsLowPrice        = IsLowPrice;
                    var result            = service.ImportPnrContext(pip);//service.ImportPnrContext(pnr, PnrSource);
                    //只有儿童编码导入时返回儿童订单号
                    OrderId = pip.PnrImportType == Common.Enums.EnumPnrImportType.CHDPnrImport ? result.ChdOrderId : result.OrderId;
                    //SeatPrice = result.SeatPrice;
                    //PNR导入方式如果是升舱换开直接跳转到支付页面
                    //if (pip.PnrImportType == Common.Enums.EnumPnrImportType.UpSeatChangePnrImport)
                    //{
                    //    LocalUIManager.ShowPolicy(result.OrderId, null);
                    //    return;
                    //}
                    if (result.PolicyList == null || result.PolicyList.Count == 0)
                    {
                        return;
                    }

                    //导入成功,清空pnr
                    PnrCode = null;

                    //foreach (var item in result.PolicyList)
                    //{
                    //    DispatcherHelper.UIDispatcher.Invoke(new Action<PolicyDto>(Policys.Add), item);
                    //}
                    //非白屏预定和手机预定来源的订单政策过滤到动态特价
                    Policys = (result.OrderSource != EnumOrderSource.WhiteScreenDestine && result.OrderSource != EnumOrderSource.MobileDestine)
                        ? result.PolicyList.Where(p => p.PolicySpecialType != EnumPolicySpecialType.DynamicSpecial).ToList()
                        : result.PolicyList;
                }, UIManager.ShowErr);
            };

            Task.Factory.StartNew(action).ContinueWith(task =>
            {
                Action setBusyAction = () => { IsBusy = false; };
                DispatcherHelper.UIDispatcher.Invoke(setBusyAction);
            });
        }
        public async Task <IActionResult> Create([Bind("Id,PolicyNumber,DateBegin,DateEnd,Cost,Summ,TypeId,PaymentMark,EndMark,ClientId,StaffId")] Policys policys)
        {
            if (ModelState.IsValid)
            {
                _context.Add(policys);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ClientId"] = new SelectList(_context.Clients, "Id", "ClientName");
            ViewData["StaffId"]  = new SelectList(_context.Staffs, "Id", "StaffName");
            ViewData["TypeId"]   = new SelectList(_context.PolicyTypes, "Id", "PolicyName");
            return(View(policys));
        }
        private void RemovePolicy(object parameter)
        {
            BackUpPolicy policy = Policys.FirstOrDefault(x => x.Id == CurrentPolicy.Id);

            if (policy != null)
            {
                Policys.Remove(policy);
                manger.RemoveBackUpJobConfig(policy.Id);
                Clear();
                Notice.Show("策略已移除成功", "通知", 3, MessageBoxIcon.Success);
            }
            else
            {
                MessageBoxHelper.MessageBoxShowWarning("请选择你需要移除的策略");
            }
        }
        /// <summary>
        /// 更新策略到配置文件
        /// </summary>
        /// <returns></returns>
        public void WritePolicyConfig()
        {
            if (Policys == null)
            {
                return;
            }

            Policys.ToList().ForEach(x =>
            {
                BackUpJobConfig config = new BackUpJobConfig();
                config.Id           = x.Id;
                config.DataBaseName = x.DataBaseName;
                config.Cron         = ConvertToCron(x);
                config.BackUpType   = x.BackUpType == BackUpType.DataBase ? 0 : 1;
                manger.WriteBackUpJobConfig(config);
            });
        }
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Policys policy = new Policys();
                policy.CustomerNumber = cmbCustomerNumber.Text;
                policy.ProductID      = cmbProductID.Text;
                policy.InsuredName    = txtInsuredName.Text;
                policy.InsuredAge     = Convert.ToInt32(txtInsuredAge.Text);
                policy.Nominee        = txtNominee.Text;
                policy.Relation       = txtRelation.Text;
                if (rdAnnu.IsChecked == true)
                {
                    policy.PremiumFrequency = "Annually";
                }
                else if (rdHalfY.IsChecked == true)
                {
                    policy.PremiumFrequency = "Half Yearly";
                }
                else if (rdMon.IsChecked == true)
                {
                    policy.PremiumFrequency = "Monthly";
                }
                else if (rdQuat.IsChecked == true)
                {
                    policy.PremiumFrequency = "Quaterly";
                }

                bool res = PolicyBL.AddPolicyBL(policy);
                MessageBox.Show("Policy Details have been added successfully");
                BtnClear_Click(sender, e);
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (PolicyException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public bool UpdatePolicyBL(Policys policy)
        {
            bool recordupdated = false;

            try
            {
                PolicyDAL customerDAL = new PolicyDAL();
                recordupdated = customerDAL.UpdatePolicyDAL(policy);
            }
            catch (PolicyException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(recordupdated);
        }
        public static bool AddPolicyBL(Policys policy)
        {
            bool policyAdded = false;

            try
            {
                PolicyDAL policyDAL = new PolicyDAL();
                policyAdded = policyDAL.AddPolicyDAL(policy);
            }
            catch (PolicyException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(policyAdded);
        }
示例#14
0
        public bool UpdatePolicyDAL(Policys policy)
        {
            bool recordupdated = false;

            try
            {
                entities.prcPolicyUpdate(
                    policy.PolicyID,
                    policy.InsuredName,
                    policy.InsuredAge,
                    policy.Nominee,
                    policy.Relation,
                    policy.PremiumFrequency);
                recordupdated = true;
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            return(recordupdated);
        }
示例#15
0
        public bool AddPolicyDAL(Policys policy)
        {
            bool policyAdded = false;

            try
            {
                entities.prcPolicyInsert(policy.InsuredName,
                                         policy.InsuredAge,
                                         policy.Nominee,
                                         policy.Relation,
                                         policy.PremiumFrequency,
                                         policy.CustomerNumber,
                                         policy.ProductID);
                policyAdded = true;
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            return(policyAdded);
        }
        /// <summary>
        /// 校验周期中的星期几是否被占用
        /// 原则:避免同一天(只校验星期几,不校验时分秒)有多个策略,减少数据库压力。
        /// 修改前:由于最多只有两个策略(全库/业务表),所以只需判断周期中的某天是否存在两个一个类型的策略即可
        /// 修改后:由于可能存在多个库的多个策略,所以如果周期中的某天存在其他策略,即为占用。否则为未占用。
        /// </summary>
        /// <returns></returns>
        private bool CheckDayOfWeek()
        {
            if (!CurrentPolicy.Sunday &&
                !CurrentPolicy.Monday &&
                !CurrentPolicy.Monday &&
                !CurrentPolicy.Tuesday &&
                !CurrentPolicy.Wednesday &&
                !CurrentPolicy.Thursday &&
                !CurrentPolicy.Friday &&
                !CurrentPolicy.Saturday)
            {
                MessageBoxHelper.MessageBoxShowWarning("请至少选择一个周期!");
                return(true);
            }

            if (!CurrentPolicy.IsTaskBackUpDataBase && !CurrentPolicy.IsTaskBackUpTables)
            {
                MessageBoxHelper.MessageBoxShowWarning("请选择备份类型!");
                return(true);
            }

            BackUpPolicy policy;

            if (CurrentPolicy.Sunday)
            {
                policy = Policys.FirstOrDefault(x => x.Sunday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Sunday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Sunday = false;
                    }
                }
            }
            if (CurrentPolicy.Monday)
            {
                policy = Policys.FirstOrDefault(x => x.Monday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Monday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Monday = false;
                    }
                }
            }
            if (CurrentPolicy.Tuesday)
            {
                policy = Policys.FirstOrDefault(x => x.Tuesday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Tuesday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Tuesday = false;
                    }
                }
            }
            if (CurrentPolicy.Wednesday)
            {
                policy = Policys.FirstOrDefault(x => x.Wednesday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Wednesday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Wednesday = false;
                    }
                }
            }
            if (CurrentPolicy.Thursday)
            {
                policy = Policys.FirstOrDefault(x => x.Thursday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Thursday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Thursday = false;
                    }
                }
            }
            if (CurrentPolicy.Friday)
            {
                policy = Policys.FirstOrDefault(x => x.Friday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Friday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Friday = false;
                    }
                }
            }
            if (CurrentPolicy.Saturday)
            {
                policy = Policys.FirstOrDefault(x => x.Saturday &&
                                                x.DataBaseName == CurrentPolicy.DataBaseName);
                if (policy != null)
                {
                    if (policy.Id == CurrentPolicy.Id)//编辑
                    {
                        CurrentPolicy.Saturday = true;
                    }
                    else//新增
                    {
                        CurrentPolicy.Saturday = false;
                    }
                }
            }

            if (!CurrentPolicy.Sunday &&
                !CurrentPolicy.Monday &&
                !CurrentPolicy.Monday &&
                !CurrentPolicy.Tuesday &&
                !CurrentPolicy.Wednesday &&
                !CurrentPolicy.Thursday &&
                !CurrentPolicy.Friday &&
                !CurrentPolicy.Saturday)
            {
                MessageBoxHelper.MessageBoxShowWarning("已有策略占用了选定周期,请至少选择一个有效的周期!");
                return(true);
            }

            return(false);
        }
        private void ManualExecute(object parameter)
        {
            if (string.IsNullOrEmpty(TaskBackUpPath))
            {
                MessageBoxHelper.MessageBoxShowWarning("请配置文件的路径!");
                return;
            }

            if (!(CurrentPolicy.IsTaskBackUpDataBase || CurrentPolicy.IsTaskBackUpTables))
            {
                MessageBoxHelper.MessageBoxShowWarning("请选择备份类型!");
                return;
            }

            if (TaskBackUpPath.ToLower().StartsWith("c:"))
            {
                if (MessageBoxHelper.MessageBoxShowQuestion("请确认是否将备份文件保存的C盘?") == MessageBoxResult.No)
                {
                    return;
                }
            }

            if (CurrentPolicy.IsTaskBackUpDataBase)
            {
                var policy = Policys.Where(x => x.BackUpType == BackUpType.DataBase &&
                                           x.DataBaseName == CurrentPolicy.DataBaseName).FirstOrDefault();
                if (policy != null)
                {
                    ExecuteBackUp executeBackUp = new ExecuteBackUp();
                    string        dbName        = policy.DataBaseName;
                    Task.Factory.StartNew(() =>
                    {
                        executeBackUp.BackUpDataBase(dbName);
                    });
                }
                else
                {
                    MessageBoxHelper.MessageBoxShowWarning("未配置全库备份类型的策略,请确认!");
                    return;
                }
            }

            if (CurrentPolicy.IsTaskBackUpTables)
            {
                var policy = Policys.Where(x => x.BackUpType == BackUpType.Tables &&
                                           x.DataBaseName == CurrentPolicy.DataBaseName).FirstOrDefault();
                if (policy != null)
                {
                    ExecuteBackUp executeBackUp = new ExecuteBackUp();
                    string        dbName        = policy.DataBaseName;
                    Task.Factory.StartNew(() =>
                    {
                        executeBackUp.BackUpTables(dbName);
                    });
                }
                else
                {
                    MessageBoxHelper.MessageBoxShowWarning("未配置基础业务备份类型的策略,请确认!");
                    return;
                }
            }
        }
示例#18
0
        private void BtnAccept_Click(object sender, RoutedEventArgs e)
        {
            txtStatus.Background = new SolidColorBrush(Colors.Green);
            txtStatus.Text       = "Accepted";
            try
            {
                Endorsement endorsement = new Endorsement();
                endorsement.PolicyID         = txtPolicyID.Text;
                endorsement.InsuredName      = txtInsuredName.Text;
                endorsement.InsuredAge       = Convert.ToInt32(txtInsuredAge.Text);
                endorsement.Dob              = Convert.ToDateTime(txtDob.Text);
                endorsement.Gender           = txtGender.Text;
                endorsement.Nominee          = txtNominee.Text;
                endorsement.Relation         = txtRelation.Text;
                endorsement.Smoker           = txtSmoker.Text;
                endorsement.Address          = txtAddress.Text;
                endorsement.Telephone        = txtTelephone.Text;
                endorsement.PremiumFrequency = txtPreFreq.Text;
                PolicyBL policyBL = new PolicyBL();
                bool     res      = policyBL.UpdateEndorsementBL(endorsement);
                int      id       = Convert.ToInt32(txtTransactionID.Text);
                bool     result   = policyBL.UpdateEndorsementStatusBL(id, txtStatus.Text);

                if (res != false && result != false)
                {
                    Policys policy = new Policys();
                    policy.PolicyID         = txtPolicyID.Text;
                    policy.InsuredName      = txtInsuredName.Text;
                    policy.InsuredAge       = Convert.ToInt32(txtInsuredAge.Text);
                    policy.Nominee          = txtNominee.Text;
                    policy.Relation         = txtRelation.Text;
                    policy.PremiumFrequency = txtPreFreq.Text;
                    PolicyBL policyup = new PolicyBL();
                    bool     resut    = policyup.UpdatePolicyBL(policy);

                    Customer customer = new Customer();
                    customer.CustomerNumber = txtCustnum.Text;
                    customer.Dob            = Convert.ToDateTime(txtDob.Text);
                    customer.Gender         = txtGender.Text;
                    customer.Smoker         = txtSmoker.Text;
                    customer.Address        = txtAddress.Text;
                    customer.Telephone      = txtTelephone.Text;
                    PolicyBL policydate = new PolicyBL();
                    bool     resul      = policydate.UpdateCustomersBL(customer);

                    if (resut != false && resul != false)
                    {
                        DeleteEndorsement();
                    }
                }
            }

            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (PolicyException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#19
0
 public void OnLoaded()
 {
     Policys.Clear();
 }