Esempio n. 1
0
 private static PointUserLoginResults CreateSession(string userID, string password)
 {
     try
     {
         PointSDK pointSDK = PointSDK.GetPDK();
         PointUserLoginResults loginResult = pointSDK.ClientLogin(userID, password);
         return(loginResult);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        private static LoanInfo GetLoanInfo(PointUserLoginResults loginResult, string loanFileName)
        {
            LoanInfo loanInfo = null;

            DataFolderInfo dataFolder = loginResult.UserInfo.DataFolders.FirstOrDefault();

            GetLoanResults loanResults = dataFolder.GetLoans(SearchLoanType.Borrower, SearchByType.FileName, Calyx.Point.Data.DataFolderServices.SearchOption.MatchesWith, loanFileName, "");

            foreach (var loan in loanResults.Loans)
            {
                loanInfo = loan;
            }

            return(loanInfo);
        }
Esempio n. 3
0
        private static void PutLoan(UpdateLoanRequest request)
        {
            try
            {
                PointUserLoginResults loginResult = CreateSession(request.userName, request.password);
                LoanInfo loanInfo = GetLoanInfo(loginResult, request.loanID);
                if (loanInfo != null)
                {
                    LoanFile loanFile = loanInfo.Open(false);
                    foreach (LoanField loanField in request.loanFields)
                    {
                        Bind_FieldID_Name();
                        int fieldID = GetFieldID(loanField.fieldName.ToLower().Trim());
                        if (fieldID > 0)
                        {
                            BorrowerSetPositionType positionType = (BorrowerSetPositionType)loanField.borrowerPosition;

                            loanFile.SetData(fieldID, BorrowerSetPositionType.Borrower, loanField.fieldValue);
                        }
                        else
                        {
                            OutputResult($"The field name : { loanField.fieldName } is invalid.");
                            return;
                        }
                    }

                    loanFile.Save();
                    loanFile.Close();
                    OutputResult($"Loan Updated Successfully With LoanFile Name : { loanFile.Info.Attributes.FileName}");
                }
                else
                {
                    string message = $"loanID : { request.loanID } is invalid or doesn't exists.";
                    OutputResult(message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseSession();
            }
        }
Esempio n. 4
0
        private static void PostLoan(PostNewLoanRequest request)
        {
            try
            {
                PointUserLoginResults loginResult = CreateSession(request.userName, request.password);

                string loanFileName = Guid.NewGuid().ToString();

                DataFolderInfo dataFolder = loginResult.UserInfo.DataFolders.FirstOrDefault();
                if (dataFolder != null)
                {
                    LoanFile loanFile = LoanInfo.Create(Calyx.Point.Data.Common.LoanType.Borrower);
                    foreach (LoanField loanField in request.loanFields)
                    {
                        Bind_FieldID_Name();
                        int fieldID = GetFieldID(loanField.fieldName.ToLower().Trim());
                        if (fieldID > 0)
                        {
                            BorrowerSetPositionType positionType = (BorrowerSetPositionType)loanField.borrowerPosition;
                            loanFile.SetData(fieldID, BorrowerSetPositionType.Borrower, loanField.fieldValue);
                        }
                        else
                        {
                            OutputResult($"The field name : { loanField.fieldName } is invalid.");
                            return;
                        }
                    }

                    loanFile.Save(loanFileName, dataFolder);
                    loanFile.Close();
                    OutputResult($"Loan Created Successfully With LoanFile Name : { loanFile.Info.Attributes.FileName }");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseSession();
            }
        }
Esempio n. 5
0
        private static void GetLoan(string userID, string password, string loanID)
        {
            try
            {
                PointUserLoginResults loginResult = CreateSession(userID, password);
                LoanInfo loanInfo = GetLoanInfo(loginResult, loanID);
                if (loanInfo != null)
                {
                    LoanFile    loanFile  = loanInfo.Open(true);
                    XmlDocument xmlResult = loanFile.ToMismo();
                    loanFile.Close();

                    string result = "";
                    using (var stringWriter = new StringWriter())
                    {
                        using (var xmlTextWriter = XmlWriter.Create(stringWriter))
                        {
                            xmlResult.WriteTo(xmlTextWriter);
                            xmlTextWriter.Flush();
                            result = stringWriter.GetStringBuilder().ToString();
                        }
                    }
                    OutputResult(result);
                }
                else
                {
                    string message = $"loanID : { loanID } is invalid or doesn't exists.";
                    OutputResult(message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                CloseSession();
            }
        }