private void SaveClick(object sender, RoutedEventArgs e)
        {
            ConfigurationVariable cv = DataContext as ConfigurationVariable;

            if (original_CV == null)
            {
                if (!(cv.IsImplicit && cv.ContainsMetaData()) || UserAwerOfMetaDataWithImplicit())
                {
                    original_CV = cv;
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (!(cv.IsImplicit && original_CV.IsExplicit && cv.ContainsMetaData()) || UserAwerOfMetaDataWithImplicit())
                {
                    original_CV.UpdateBy(cv);
                }
                else
                {
                    return;
                }
            }
            Window.GetWindow(this).Close();
        }
示例#2
0
        }         // PayLoan

        /// <summary>
        /// Сколько будет сэкономлено денег, если пользователь погасит все свои кредиты.
        /// How much money will be saved, if customer pay all his loans now
        /// </summary>
        /// <param name="customer"></param>
        /// <param name="term"></param>
        /// <returns></returns>
        /// <exception cref="InvalidCastException"><paramref /> cannot be cast to the element type of the current <see cref="T:System.Array" />.</exception>
        public decimal CalculateSavings(Customer customer, DateTime?term = null)
        {
            if (term == null)
            {
                term = DateTime.UtcNow;
            }

            decimal totalToPay = customer.TotalEarlyPayment();

            decimal oldInterest = customer.Loans.Sum(l => l.Interest);

            Customer clonedCustomer = new Customer();

            clonedCustomer.Loans.AddAll(customer.Loans.Select(l => l.Clone()).ToList());
            clonedCustomer.Id = customer.Id;
            PayAllLoansForCustomer(clonedCustomer, totalToPay, "", term);

            decimal newInterest = clonedCustomer.Loans.Sum(l => l.Interest);

            decimal savedSetupFee  = 0;
            string  setupFeeCharge = new ConfigurationVariable(CurrentValues.Instance.SpreadSetupFeeCharge).Name;

            clonedCustomer.Loans.ForEach(l => l.Charges
                                         .Where(c => (c.ChargesType.Name == setupFeeCharge) && (c.State == "Active"))
                                         .ForEach(c => savedSetupFee += c.Amount - c.AmountPaid)
                                         );

            return(oldInterest - newInterest + savedSetupFee);
        }         // CalculateSavings
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Course currentCourse = AngelSession.CurrentAngelSession.Section;

                ProvisionLink.NavigateUrl = String.Format("{0}ProvisionCourse.aspx?id={1}", cNuggetRoot, currentCourse.CourseId);

                using (var clientData = new ClientDataProxy())
                {
                    List <CourseInfo> courses = new List <CourseInfo>(clientData.GetCourses(Util.GetUserKey(), Util.GetAuthCode()));

                    string panoptoCourseID = ConfigurationVariable.GetValue("PanoptoCourseID", null, null, null, currentCourse.CourseId, null);

                    if (String.IsNullOrEmpty(panoptoCourseID))
                    {
                        courses.Insert(0, new CourseInfo()
                        {
                            DisplayName = "-- Select an Existing Course --"
                        });
                    }

                    bool isProvisioned = false;
                    bool canSync       = false;

                    // Populate course drop down.
                    CoursesDropDown.Items.Clear();
                    foreach (CourseInfo course in courses)
                    {
                        ListItem item = new ListItem(course.DisplayName, course.PublicID.ToString());

                        // Select course if it matches the current Panopto course setting
                        if (course.PublicID.ToString() == panoptoCourseID)
                        {
                            item.Selected = true;
                        }

                        CoursesDropDown.Items.Add(item);

                        // Check for matching external ID indicating the course has already been provisioned
                        if (course.ExternalCourseID == Util.GetExternalCourseID(currentCourse.CourseId))
                        {
                            isProvisioned = true;

                            // If provisioned course is already selected, show "Sync users" link
                            if (course.PublicID.ToString() == panoptoCourseID)
                            {
                                canSync = true;
                            }
                        }
                    }

                    ProvisionPanel.Visible = (!isProvisioned || canSync);
                    ProvisionLink.Text     =
                        canSync
                            ? "Sync Users"
                            : "Add this course to Panopto";
                }
            }
        }
示例#4
0
文件: Util.cs 项目: leader001/Angel
        /// <summary>
        /// Set Panopto "notify" setting environment variable.
        /// </summary>
        public static void SetNotify(bool notify)
        {
            // Convert bool to string.
            string settingText = notify ? "true" : "false";

            ConfigurationVariable.SetValue(NotificationsVarName, null, null, null, null, null, VariableType.DefaultSetting, settingText);
        }
示例#5
0
        public ClientDataProxy()
        {
            string serverName = ConfigurationVariable.GetValue("PANOPTO_SERVER");

            string serviceLocation = String.Format(serviceLocationFormatString, serverName);

            m_service = new ServiceProxy <IClientDataService>(serviceLocation);
        }
示例#6
0
        public override Core.Variable[] CreateVariables()
        {
            var configuration = Configuration.NewRadom();
            var variable      = new ConfigurationVariable(configuration);
            var variables     = new Core.Variable[NumberOfVariables] {
                variable
            };

            return(variables);
        }
        private static void UpdateRemappedVariable(ScriptAction action, ConfigurationVariable configVar, string newVariableName)
        {
            action.Arguments = action.Arguments?.Replace($"${configVar.RemappedName}", $"${newVariableName}");
            var commandHasParameter = action.Command?.Contains(configVar.RemappedName);

            if (commandHasParameter.HasValue && commandHasParameter.Value)
            {
                action.Command = action.Command?.Replace($"${configVar.RemappedName}", $"${newVariableName}");
            }
            configVar.RemappedName = newVariableName;
        }
示例#8
0
文件: Util.cs 项目: leader001/Angel
        /// <summary>
        /// Get auth code for specified payload for use in SSO process.
        /// </summary>
        /// <param name="payload">Payload to sign</param>
        /// <returns>Specified payload signed with app key and hashed with SHA-1.</returns>
        public static String GetAuthCode(string payload)
        {
            // Get the app key setting.
            string applicationKey = ConfigurationVariable.GetValue(AppKeyVarName);

            String signedPayload = payload + "|" + applicationKey;

            String authCode = FormsAuthentication.HashPasswordForStoringInConfigFile(signedPayload, "SHA1").ToUpper();

            return(authCode);
        }
示例#9
0
 public static ConfigurationVariableModel FromConfigurationVariable(ConfigurationVariable variable)
 {
     return(variable == null
                ? null
                : new ConfigurationVariableModel
     {
         Id = variable.Id,
         Name = variable.Name,
         Value = variable.Value,
         Description = variable.Description
     });
 }
示例#10
0
 public AddedValue(ConfigurationVariable cv)
 {
     if (!(cv is ConfigurationList || cv is ConfigurationComposite))
     {
         throw new Exception("whattt");
     }
     if (cv.Variables.Count > 0)
     {
         current_value = cv.Variables.First().GetType().GetConstructor(new Type[0]).Invoke(new Type[0]) as ConfigurationVariable;
     }
     else
     {
         current_value = new ConfigurationInteger();
     }
     current_value.IsNameVisable = cv is ConfigurationComposite;
     is_name_visible             = current_value.IsNameVisable;
     _current_type = current_value.GetType().Name.Substring(13);
 }
示例#11
0
        public bool EditConfigurationVariable(string applicationId, ConfigurationVariable configurationVariable)
        {
            CheckArgumentNull("applicationId", applicationId);
            CheckArgumentNull("configurationVariable", configurationVariable);
            CheckArgumentNull("configurationVariable.Key ", configurationVariable.Key);
            CheckArgumentNull("configurationVariable.Value", configurationVariable.Value);

            var request = new RestRequest(Method.PUT);

            request.RequestFormat = DataFormat.Json;
            request.Resource      = "applications/{applicationId}/configurationvariables/{id}";
            request.AddParameter("applicationId", applicationId, ParameterType.UrlSegment);
            request.AddParameter("id", configurationVariable.Id, ParameterType.UrlSegment);
            request.AddBody(new
            {
                key   = configurationVariable.Key,
                value = configurationVariable.Value
            });
            return(ExecuteEdit(request));
        }
示例#12
0
		public static NLFeeTypes ConfVarToNLFeeType(ConfigurationVariable confVar) {
			if( confVar.Name == CurrentValues.Instance.AdministrationCharge)
				return NLFeeTypes.AdminFee;
			
			if (confVar.Name == CurrentValues.Instance.SpreadSetupFeeCharge)
				return NLFeeTypes.ServicingFee;
			
			if (confVar.Name == CurrentValues.Instance.LatePaymentCharge)
				return NLFeeTypes.LatePaymentFee;

			if (confVar.Name == CurrentValues.Instance.PartialPaymentCharge)
				return NLFeeTypes.PartialPaymentFee;

			if (confVar.Name == CurrentValues.Instance.RolloverCharge)
				return NLFeeTypes.RolloverFee;

			if (confVar.Name == CurrentValues.Instance.OtherCharge)
				return NLFeeTypes.OtherCharge;

			return NLFeeTypes.OtherCharge;
		}
        public async Task <IEnumerable <ConfigurationVariable> > GetComponentConfigurationVariablesAsync(Guid workflowGuid, int stageId)
        {
            var sqlQuery =
                $@"SELECT cv.Name, cvv.Value, cv.IsParameter, cv.TypeId                                            
                FROM {this.tableNamePrefix}ConfigurationVariable cv	                                        
	            inner join {this.tableNamePrefix}ConfigurationVariableValue cvv
		        ON cv.Id = cvv.ConfigurationVariableId		
			    inner join {this.tableNamePrefix}ApplicationVersionStageActivity avsa
				ON cvv.ApplicationVersionStageActivityId = avsa.Id		                                        
                WHERE avsa.ApplicationVersionStageId = @StageId
                AND avsa.WorkflowActivityId = @WorkflowActivityId";

            using (var sqlConnection = new SqlConnection {
                ConnectionString = this.connectionString
            })
                using (var command = new SqlCommand(sqlQuery, sqlConnection))
                {
                    command.Parameters.AddWithValue("@stageId", stageId);
                    command.Parameters.AddWithValue("@WorkflowActivityId", workflowGuid);
                    await sqlConnection.OpenAsync();

                    var configVars = new List <ConfigurationVariable>();
                    using (var sqlReader = await command.ExecuteReaderAsync())
                    {
                        while (await sqlReader.ReadAsync())
                        {
                            var cv = new ConfigurationVariable
                            {
                                OriginalName = sqlReader.GetFieldValue <string>(0),
                                Value        = sqlReader.GetFieldValue <string>(1),
                                IsParameter  = sqlReader.GetFieldValue <bool>(2),
                                Encrypted    = sqlReader.GetFieldValue <int>(3) == 2
                            };
                            configVars.Add(cv);
                        }

                        return(configVars);
                    }
                }
        }
示例#14
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Set Panopto server name environment variable.
 /// </summary>
 public static void SetServerName(string serverName)
 {
     ConfigurationVariable.SetValue(ServerVarName, null, null, null, null, null, VariableType.DefaultSetting, serverName);
 }
 public AddValue(ConfigurationVariable cv)
 {
     CV          = cv;
     DataContext = new AddedValue(cv);
     InitializeComponent();
 }
        public async Task<IEnumerable<ConfigurationVariable>> GetComponentConfigurationVariablesAsync(Guid workflowGuid, int stageId)
        {
            var sqlQuery = 
                $@"SELECT cv.Name, cvv.Value, cv.IsParameter, cv.TypeId                                            
                FROM {this.tableNamePrefix}ConfigurationVariable cv	                                        
	            inner join {this.tableNamePrefix}ConfigurationVariableValue cvv
		        ON cv.Id = cvv.ConfigurationVariableId		
			    inner join {this.tableNamePrefix}ApplicationVersionStageActivity avsa
				ON cvv.ApplicationVersionStageActivityId = avsa.Id		                                        
                WHERE avsa.ApplicationVersionStageId = @StageId
                AND avsa.WorkflowActivityId = @WorkflowActivityId";

            using (var sqlConnection = new SqlConnection { ConnectionString = this.connectionString })     
            using (var command = new SqlCommand(sqlQuery, sqlConnection))
            {
                command.Parameters.AddWithValue("@stageId", stageId);
                command.Parameters.AddWithValue("@WorkflowActivityId", workflowGuid);
                await sqlConnection.OpenAsync();

                var configVars = new List<ConfigurationVariable>();
                using (var sqlReader = await command.ExecuteReaderAsync())
                {
                    while (await sqlReader.ReadAsync())
                    {
                        var cv = new ConfigurationVariable
                                        {
                                            OriginalName = sqlReader.GetFieldValue<string>(0),
                                            Value = sqlReader.GetFieldValue<string>(1),
                                            IsParameter = sqlReader.GetFieldValue<bool>(2),
                                            Encrypted = sqlReader.GetFieldValue<int>(3) == 2
                                        };
                        configVars.Add(cv);
                    }

                    return configVars;
                }
             }
        }
示例#17
0
 public GeneralEditWindow(ConfigurationVariable cv)
 {
     DataContext = cv;
     InitializeComponent();
 }
 public ConfigurationVariableContent(ConfigurationVariable cv)
 {
     DataContext = cv;
     InitializeComponent();
 }
示例#19
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Set the ID of the Panopto course to pull content from for the specified Angel course.
 /// </summary>
 /// <param name="angelCourseID">ID of the Angel course to set the setting on.</param>
 /// <param name="panoptoCourseID">ID of the Panopto course to pull content from.</param>
 public static void SetPanoptoCourseID(string angelCourseID, Guid panoptoCourseID)
 {
     ConfigurationVariable.SetValue(PanoptoCourseIDVarName, null, null, null, angelCourseID, null, VariableType.CourseSetting, panoptoCourseID.ToString());
 }
示例#20
0
        }         // PayAllLateLoansForCustomer

        /// <summary>
        /// Main method for making payments
        /// </summary>
        /// <param name="transId">pay point transaction id</param>
        /// <param name="amount"></param>
        /// <param name="ip"></param>
        /// <param name="type"></param>
        /// <param name="loanId"></param>
        /// <param name="customer"></param>
        /// <param name="date">payment date</param>
        /// <param name="description"></param>
        /// <param name="paymentType">If payment type is null - ordinary payment(reduces principal),
        /// if nextInterest then it is for Interest Only loans, and reduces interest in the future.</param>
        /// <param name="sManualPaymentMethod"></param>
        /// <param name="nlPayment"></param>
        /// <returns></returns>
        /// <exception cref="OverflowException">The sum is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
        /// <exception cref="InvalidCastException"><paramref /> cannot be cast to the element type of the current <see cref="T:System.Array" />.</exception>
        public PaymentResult MakePayment(
            string transId,
            decimal amount,
            string ip,
            string type,
            int loanId,
            Customer customer,
            DateTime?date               = null,
            string description          = "payment from customer",
            string paymentType          = null,
            string sManualPaymentMethod = null,
            NL_Payments nlPayment       = null)
        {
            Log.DebugFormat(
                "MakePayment transId: {0}, amount: {1}, ip: {2}, type: {3}, loanId: {4}, customer: {5}," +
                "date: {6}, description: {7}, paymentType: {8}, manualPaymentMethod: {9}, nlPayment: {10}",
                transId,
                amount,
                ip,
                type,
                loanId,
                customer.Id,
                date,
                description,
                paymentType,
                sManualPaymentMethod,
                nlPayment
                );

            decimal oldInterest;
            decimal newInterest;
            bool    rolloverWasPaid = false;

            description = string.Format("{0} {1} {2}", description, type, paymentType);

            SortedSet <int> openLoansBefore = new SortedSet <int>(
                customer.Loans.Where(l => l.Status != LoanStatus.PaidOff).Select(l => l.Id)
                );

            if (type == "total")
            {
                oldInterest = customer.Loans.Sum(l => l.Interest);

                rolloverWasPaid = (
                    from l in customer.Loans
                    from s in l.Schedule
                    from r in s.Rollovers
                    where r.Status == RolloverStatus.New
                    select r
                    ).Any();

                PayAllLoansForCustomer(
                    customer,
                    amount,
                    transId,
                    date,
                    description,
                    sManualPaymentMethod
                    , nlPayment
                    );

                newInterest = customer.Loans.Sum(l => l.Interest);
            }
            else if (type == "totalLate")
            {
                rolloverWasPaid = (
                    from l in customer.Loans
                    from s in l.Schedule
                    from r in s.Rollovers
                    where r.Status == RolloverStatus.New
                    select r
                    ).Any();

                oldInterest = customer.Loans.Sum(l => l.Interest);

                PayAllLateLoansForCustomer(
                    customer,
                    amount,
                    transId,
                    date,
                    description,
                    sManualPaymentMethod
                    );

                newInterest = customer.Loans.Sum(l => l.Interest);
            }
            else if (paymentType == "nextInterest")
            {
                oldInterest = 0;
                var loan = customer.GetLoan(loanId);

                if (nlPayment != null)
                {
                    var nlLoanId = serviceInstance.GetLoanByOldID(loanId, customer.Id);
                    if (nlLoanId > 0)
                    {
                        nlPayment.Amount          = amount;
                        nlPayment.CreationTime    = DateTime.UtcNow;
                        nlPayment.LoanID          = nlLoanId;
                        nlPayment.PaymentTime     = DateTime.UtcNow;
                        nlPayment.Notes           = description;
                        nlPayment.PaymentStatusID = (int)NLPaymentStatuses.Active;
                        //CreatedByUserID = userId,
                        //PaymentMethodID = (int)NLLoanTransactionMethods.CustomerAuto,
                        //PaymentSystemType = (transId == PaypointTransaction.Manual ? NLPaymentSystemTypes.None : NLPaymentSystemTypes.Paypoint)
                    }
                }

                PayLoan(loan, transId, amount, ip, date, description, true, sManualPaymentMethod, nlPayment);
                newInterest = 0;
            }
            else
            {
                Loan loan = customer.GetLoan(loanId);

                oldInterest = loan.Interest;

                var rollover = (
                    from s in loan.Schedule
                    from r in s.Rollovers
                    where r.Status == RolloverStatus.New
                    select r
                    ).FirstOrDefault();

                long nlLoanId = 0;
                if (nlPayment != null)
                {
                    nlLoanId = serviceInstance.GetLoanByOldID(loanId, customer.Id);
                    if (nlLoanId > 0)
                    {
                        nlPayment.Amount             = amount;
                        nlPayment.CreationTime       = DateTime.UtcNow;
                        nlPayment.LoanID             = nlLoanId;
                        nlPayment.PaymentTime        = DateTime.UtcNow;
                        nlPayment.Notes              = description;
                        nlPayment.PaymentStatusID    = (int)NLPaymentStatuses.Active;
                        nlPayment.PaymentDestination = rollover != null?NLPaymentDestinations.Rollover.ToString() : null;

                        //CreatedByUserID = userId,
                        //PaymentMethodID = (int)NLLoanTransactionMethods.CustomerAuto,
                        //PaymentSystemType = (transId == PaypointTransaction.Manual ? NLPaymentSystemTypes.None : NLPaymentSystemTypes.Paypoint)
                    }
                }

                PayLoan(loan, transId, amount, ip, date, description, false, sManualPaymentMethod, nlPayment);

                newInterest = loan.Interest;

                rolloverWasPaid = rollover != null && rollover.Status == RolloverStatus.Paid;

                if (rolloverWasPaid && nlLoanId > 0)
                {
                    serviceInstance.AcceptRollover(customer.Id, nlLoanId);
                }
            }             // if

            SortedSet <int> openLoansAfter = new SortedSet <int>(
                customer.Loans.Where(l => l.Status != LoanStatus.PaidOff).Select(l => l.Id)
                );

            var loansClosedNow = new SortedSet <int>(openLoansBefore.Except(openLoansAfter));

            decimal savedSetupFee  = 0;
            string  setupFeeCharge = new ConfigurationVariable(CurrentValues.Instance.SpreadSetupFeeCharge).Name;

            customer.Loans.Where(l => loansClosedNow.Contains(l.Id)).ForEach(l => l.Charges
                                                                             .Where(c => (c.ChargesType.Name == setupFeeCharge) && (c.State == "Active"))
                                                                             .ForEach(c => savedSetupFee += c.Amount - c.AmountPaid)
                                                                             );

            var savedPounds = oldInterest - newInterest + savedSetupFee;

            var transactionRefNumbers =
                from l in customer.Loans
                from t in l.TransactionsWithPaypoint
                where t.Id == 0
                select t.RefNumber;

            var payFastModel = new PaymentResult {
                PaymentAmount         = amount,
                Saved                 = oldInterest + savedSetupFee > 0 ? Math.Round(savedPounds / (oldInterest + savedSetupFee) * 100) : 0,
                SavedPounds           = savedPounds,
                TransactionRefNumbers = transactionRefNumbers.ToList(),
                RolloverWasPaid       = rolloverWasPaid
            };

            customer.TotalPrincipalRepaid = customer.Loans
                                            .SelectMany(l => l.Transactions)
                                            .OfType <PaypointTransaction>()
                                            .Where(l => l.Status != LoanTransactionStatus.Error)
                                            .Sum(l => l.LoanRepayment);

            return(payFastModel);
        }         // MakePayment
示例#21
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Get Angel instance name setting from Angel environment variable.
 /// </summary>
 public static String GetInstanceName()
 {
     return(ConfigurationVariable.GetValue(InstanceVarName));
 }
示例#22
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Set Angel instance name environment variable.
 /// </summary>
 public static void SetInstanceName(string instanceName)
 {
     ConfigurationVariable.SetValue(InstanceVarName, null, null, null, null, null, VariableType.DefaultSetting, instanceName);
 }
示例#23
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Get Panopto "notify" setting from Angel environment variable.
 /// </summary>
 public static bool GetNotify()
 {
     // Default to "true" if no setting.
     return(ConfigurationVariable.GetValue(NotificationsVarName) != "false");
 }
示例#24
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Set Panopto application key environment variable.
 /// </summary>
 public static void SetAppKey(string appKey)
 {
     ConfigurationVariable.SetValue(AppKeyVarName, null, null, null, null, null, VariableType.DefaultSetting, appKey);
 }
示例#25
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Get Panopto application key setting from Angel environment variable.
 /// </summary>
 public static String GetAppKey()
 {
     return(ConfigurationVariable.GetValue(AppKeyVarName));
 }
示例#26
0
文件: Util.cs 项目: leader001/Angel
 /// <summary>
 /// Get Panopto server name setting from Angel environment variable.
 /// </summary>
 public static String GetServerName()
 {
     return(ConfigurationVariable.GetValue(ServerVarName));
 }