Exemplo n.º 1
0
        public static string ProcessTemplate(object CommandArgument)
        {
            string detail = "";

            ///STEP 1 Split Details & Fetch Request Detail
            string[] p = Convert.ToString(CommandArgument).Split(';');

            long req_dlt_id                    = Convert.ToInt64(p[0]);
            CHRequestDetailManager cdm         = new CHRequestDetailManager();
            CH_Request_DtlDTO      request_dlt = cdm.FindRequestDetail(req_dlt_id);

            if (string.IsNullOrEmpty(p[5]))
            {
                p[5] = "No Remark";
            }
            ///STEP 2 Get Card Details Using Card Holder
            //long created_by = request_dlt.Created_by;
            //CardHolderManager chm = new CardHolderManager();
            //CardHolder_MstDTO ch = chm.getUserByID(created_by);
            //CardManager cm = new CardManager();
            //CH_CardDTO card = cm.GetCardByCreditCardNumber(new CH_CardDTO()
            //{
            //    card_number = ch.creditcard_acc_number
            //});
            //detail += GetRowTemplate("Name of Card-Holder", card.Embossed_Name);
            //detail += GetRowTemplate("Card Number", card.card_number);
            //detail += GetRowTemplate("Credit Account Number", card.Cr_Account_Nbr);
            detail += GetRowTemplate("Request Date", GeneralMethods.FormatDate(Convert.ToDateTime(p[1]))); //.ToString("dd/MM/yyyy"));
            detail += GetRowTemplate("Request Number", p[2]);
            detail += GetRowTemplate("RequestType Name", p[3]);
            detail += GetRowTemplate("Request Status", p[4]);

            ///STEP 3 Load Fields As Per
            string   request_type = p[3];
            XElement root         = XDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "Filters\\CH-Request.xml").Root;
            var      request      = from x in root.Descendants("Request") where x.Attribute("type").Value == request_type select x;
            var      fields       = from y in request.Descendants("field")
                                    select new Field()
            {
                Text  = y.Attribute("Text").Value,
                Value = y.Value,
            };


            ///STEP 4 Convert To DataDictionary & Compare
            Dictionary <string, string> FD = (from x in request_dlt.GetType().GetProperties() select x).ToDictionary(x => x.Name, x => (x.GetGetMethod().Invoke(request_dlt, null) == null ? "" : x.GetGetMethod().Invoke(request_dlt, null).ToString()));

            foreach (var field in fields)
            {
                detail += ProcessSwitch(FD, field);
            }
            detail += GetRowTemplate("Your Remark", p[5]);
            if (!string.IsNullOrEmpty(p[4]) && p[4].ToLower() == "pending")
            {
                detail += GetRowTemplate("Back-Office's Remark", "No Remark");
            }
            else if (!string.IsNullOrEmpty(p[4]) && p[4].ToLower() == "Approved")
            {
                detail += GetRowTemplate("Back-Office's Remark", p[6]);
            }
            else if (!string.IsNullOrEmpty(p[4]) && p[4].ToLower() == "Rejected")
            {
                detail += GetRowTemplate("Back-Office's Remark", p[6]);
            }
            else
            {
                detail += GetRowTemplate("Back-Office's Remark", p[6]);
            }
            return(detail);
        }