public void LoadData(DataGridView dtGridView)
        {
            IList <CRMGroup> CRMGroup = _CRMGroupInfo.GetAll();

            _dtCRMGroup = ListtoDataTable.ToDataTable(CRMGroup.ToList());
            loadDataOnGrid(dtGridView, _dtCRMGroup);
        }
        private void AuditTrail_Load(object sender, EventArgs e)
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + string.Format(AUDITLOGCONTROLLER_BY_USER, Program.CurrentUser.UserName);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);

            request.Method = "GET";
            String auditTrailJson = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                auditTrailJson = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            var auditTrailCollection = jsonSerialization.DeserializeFromString <Result <List <Activities> > >(auditTrailJson);

            if (auditTrailCollection.Value != null)
            {
                _dtAuditTrail = ListtoDataTable.ToDataTable(auditTrailCollection.Value);
                dtGridAuditTrail.DataSource = _dtAuditTrail;
                gridDisplaySetting();
            }
        }
        private void getConversationDetails()
        {
            if (_dtConversation != null && _dtConversation.Rows.Count > 0)
            {
                _dtConversation.Clear();
            }

            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + string.Format(CONVERSATIONBY_ID, _prospectClient.ID);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);

            request.Method = "GET";
            String prospClientResultJosn = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                prospClientResultJosn = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            var prospClientConversationCollection = jsonSerialization.DeserializeFromString <Result <List <ProspectClientConversation> > >(prospClientResultJosn);

            if (prospClientConversationCollection.Value != null)
            {
                _prospectClient.ProspectClientConversationList = prospClientConversationCollection.Value;
                _dtConversation = ListtoDataTable.ToDataTable(prospClientConversationCollection.Value);
                dataGridConversation.DataSource = _dtConversation;
                gridDisplaySetting();
            }
        }
示例#4
0
        private void frmUseList_Load(object sender, EventArgs e)
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + USERAPI;

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);

            request.Method = "GET";
            String userResultJson = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                userResultJson = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            var userCollection = jsonSerialization.DeserializeFromString <Result <List <User> > >(userResultJson);

            if (userCollection.Value != null)
            {
                _dtUser = ListtoDataTable.ToDataTable(userCollection.Value);
                dtGridUser.DataSource = _dtUser;
                gridDisplaySetting();
            }
        }
示例#5
0
        private void loadPlanData()
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_PLAN_BY_CLIENTID_API, ClientId);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);

            request.Method = "GET";
            String planerResultJson = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                planerResultJson = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            var plannerCollection = jsonSerialization.DeserializeFromString <Result <List <Planner> > >(planerResultJson);

            if (plannerCollection.Value != null)
            {
                _dtPlanner = ListtoDataTable.ToDataTable(plannerCollection.Value);
            }
        }
        public void LoadData(DataGridView dtGridView)
        {
            IList <Festivals> festivals = _festivalsInfo.GetAll();

            _dtFestivals = ListtoDataTable.ToDataTable(festivals.ToList());
            loadDataOnGrid(dtGridView, _dtFestivals);
        }
        private void loadApplicationConfig()
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + GET_APPLICATIONCONFIG_API;

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);
                request.Method = "GET";
                String appConfigJsobResult = String.Empty;
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    Stream dataStream = response.GetResponseStream();

                    StreamReader reader = new StreamReader(dataStream);
                    appConfigJsobResult = reader.ReadToEnd();
                    reader.Close();
                    dataStream.Close();
                }

                var appConfigCollection = jsonSerialization.DeserializeFromString <Result <List <ApplicationConfiguration> > >(appConfigJsobResult);

                if (appConfigCollection.Value != null)
                {
                    _dtAppConfig = ListtoDataTable.ToDataTable(appConfigCollection.Value);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Fail to load application data. Error:{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void loadArticleFormWithData()
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + GET_EMAILARTICLES_API;

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);
                request.Method = "GET";
                String emailArticleResultJson = String.Empty;
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    Stream dataStream = response.GetResponseStream();

                    StreamReader reader = new StreamReader(dataStream);
                    emailArticleResultJson = reader.ReadToEnd();
                    reader.Close();
                    dataStream.Close();
                }
                var emailArticleCollection = jsonSerialization.DeserializeFromString <Result <List <EmailArticle> > >(emailArticleResultJson);

                if (emailArticleCollection.Value != null)
                {
                    _dtArticle = ListtoDataTable.ToDataTable(emailArticleCollection.Value);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Fail to load application data. Error:{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#9
0
 private void GetQuoteById()
 {
     Business.Sales.Quote Obj   = new Business.Sales.Quote();
     Entity.Sales.Quote   Quote = Obj.GetQuoteById(QuoteId);
     if (Quote.Id != 0)
     {
         txtActualCloseDate.Text      = Quote.ActualCloseDate == null ? string.Empty : Quote.ActualCloseDate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtDateShipped.Text          = Quote.DateShipped == null ? string.Empty : Quote.DateShipped.GetValueOrDefault().ToString("dd MMM yyyy");
         txtValidTillDate.Text        = Quote.ValidTillDate == null ? string.Empty : Quote.ValidTillDate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtOriginalPODate.Text       = Quote.OriginalPODate == null ? string.Empty : Quote.OriginalPODate.GetValueOrDefault().ToString("dd MMM yyyy");
         txtQuoteNumber.Text          = Quote.QuoteNumber;
         txtPurchaseOrderNo.Text      = Quote.PurchaseOrderNo;
         txtShippingProvider.Text     = Quote.ShippingProvider;
         txtCurrencyCode.Text         = Quote.CurrencyCode;
         txtCurrencyName.Text         = Quote.CurrencyName;
         txtTaxRate.Text              = Quote.TaxRate == null ? string.Empty : Quote.TaxRate.ToString();
         ddlOpportunity.SelectedValue = Quote.OpportunityId == null ? "0" : Quote.OpportunityId.ToString();
         ddlPaymentTerm.SelectedValue = Quote.PaymentTermId == null ? "0" : Quote.PaymentTermId.ToString();
         ddlQuoteStage.SelectedValue  = Quote.QuoteStageId == null ? "0" : Quote.QuoteStageId.ToString();
         JavaScriptSerializer ser = new JavaScriptSerializer();
         List <Entity.Sales.QuoteLineItem> lst = ser.Deserialize <List <Entity.Sales.QuoteLineItem> >(Quote.QuoteLineItem);
         ListtoDataTable lsttodt = new ListtoDataTable();
         _ItemsList = lsttodt.ToDataTable(lst);
         LoadItemList();
     }
 }
        public void LoadData(DataGridView dtGridView)
        {
            IList <Area> Area = _AreaInfo.GetAll();

            _dtArea = ListtoDataTable.ToDataTable(Area.ToList());
            loadDataOnGrid(dtGridView, _dtArea);
        }
        public DataTable GetAll(int planId)
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + string.Format(GETALL_API, planId);

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);

            request.Method = "GET";
            String planerResultJson = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                planerResultJson = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            var plannerCollection = jsonSerialization.DeserializeFromString <Result <List <PlanOption> > >(planerResultJson);

            if (plannerCollection.Value != null)
            {
                return(ListtoDataTable.ToDataTable(plannerCollection.Value));
            }
            return(null);
        }
        private void loadEmailSchedulerData()
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + GET_EMAILSCHEDULER_API;

            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);

            request.Method = "GET";
            String emailSchedulerResultJosn = String.Empty;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            {
                Stream dataStream = response.GetResponseStream();

                StreamReader reader = new StreamReader(dataStream);
                emailSchedulerResultJosn = reader.ReadToEnd();
                reader.Close();
                dataStream.Close();
            }
            var emailSchedulerCollection = jsonSerialization.DeserializeFromString <Result <List <EmailScheduler> > >(emailSchedulerResultJosn);

            if (emailSchedulerCollection.Value != null)
            {
                _dtEmailScheduler = ListtoDataTable.ToDataTable(emailSchedulerCollection.Value);
                dataGridEmailScheduler.DataSource = _dtEmailScheduler;
                gridDisplaySetting();
            }
        }
        private void fillCurrentStatusToGoalData()
        {
            cmbCurrentStsatusToGoal.Items.Clear();

            foreach (var goal in _goals)
            {
                cmbCurrentStsatusToGoal.Items.Add(goal.Name);
            }

            _currentStatusToGoal = new CurrentStatusInfo().GetCurrentStatusToGoal(int.Parse(cmbPlanOption.Tag.ToString()));
            if (_currentStatusToGoal != null)
            {
                _dtCurrentStatustoGoals = ListtoDataTable.ToDataTable(_currentStatusToGoal.ToList());
                dtGridCurrentStatusToGoal.DataSource              = _dtCurrentStatustoGoals;
                dtGridCurrentStatusToGoal.Columns[0].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[1].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[2].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[3].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[6].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[7].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[8].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[9].Visible      = false;
                dtGridCurrentStatusToGoal.Columns[10].Visible     = false;
                dtGridCurrentStatusToGoal.Columns[11].Visible     = false;
                dtGridCurrentStatusToGoal.Columns[5].DisplayIndex = 0;
                dtGridCurrentStatusToGoal.Columns[5].HeaderText   = "Goal";
                dtGridCurrentStatusToGoal.Columns[4].DisplayIndex = 1;
                dtGridCurrentStatusToGoal.Columns[4].HeaderText   = "Fund Allocation";
            }
        }
示例#14
0
        public void CrearLista <T>(List <T> ListaDatos)
        {
            if (ListaDatos != null)
            {
                ListtoDataTable lsttodt = new ListtoDataTable();
                GetData = lsttodt.ToDataTable(ListaDatos);

                var bindingList = new BindingList <T>(ListaDatos);
                var source      = new BindingSource(bindingList, null);
                DGVlistaDatos.DataSource = source;
                DGVlistaDatos.Refresh();
                DGVlistaDatos.Update();
            }
        }
示例#15
0
 public ActionResult UpdateRfId()
 {
     try
     {
         int LoginID = GetLogin();
         if (Request.Files.Count > 0 && LoginID > 0)
         {
             int            FileID   = 0;
             int            RowCount = 0;
             string         path     = Server.MapPath(ConfigurationManager.AppSettings["INVUpload"].ToString());
             CommonFunction com      = new CommonFunction();
             //Guid guFileName = Guid.NewGuid();
             string FileName      = Request.Files[0].FileName.ToString();
             string FilePath      = Server.MapPath(ConfigurationManager.AppSettings["INVUpload"]);
             string FileExtension = Path.GetExtension(Request.Files[0].FileName);
             string ip            = CommonFunction.GetIpAddress(Request);
             FileID = this.objSDC.InsertFileUploadLog(FileName + FileExtension, "RFID_" + FileName + FileExtension, LoginID.ToString(), ip, "12", "RFID_UPDATE");
             Request.Files[0].SaveAs(FilePath + FileID.ToString() + FileExtension);
             DataTable dt = com.GetDataFromExcel2(FilePath + FileID + FileExtension, true);
             if (dt == null)
             {
                 throw new Exception("DataTable is null");
             }
             DataTable pDt = ParseToString(dt);
             if (dt.Rows.Count > 0)
             {
                 List <RFIDTempTableMiewModel> lstofRfid     = this.objSvc.InventoryUploadRFID(pDt, LoginID, ip, FileID);
                 List <RFIDTempTableMiewModel> objValidLst   = lstofRfid.Where(x => (x.Status != null && x.Status.ToLower() == "valid")).ToList();
                 List <RFIDTempTableMiewModel> objInValidLst = lstofRfid.Where(x => (x.Status != null && x.Status.ToLower().Contains("invalid"))).ToList();
                 DataTable dtValid    = ListtoDataTable.ToDataTable <RFIDTempTableMiewModel>(objValidLst);
                 DataTable dtNotValid = ListtoDataTable.ToDataTable <RFIDTempTableMiewModel>(objInValidLst);
                 ExportToExcel.SaveExcel(path, FileID.ToString() + "_Valid", "Valid", dtValid);
                 ExportToExcel.SaveExcel(path, FileID.ToString() + "_InValid", "InValid", dtNotValid);
             }
             return(Json(new Response {
                 IsSuccess = true, Result = new { FileID = FileID, RowCount = RowCount }
             }));
         }
         return(Json(new Response {
             IsSuccess = false, Message = "File not uploaded"
         }));
     }
     catch (Exception ex)
     {
         ErrorLog.Log("RFIDController", "UpdateRfId", ex);
         return(Json(new Response {
             IsSuccess = false, Message = ex.Message
         }));
     }
 }
        private void loadProspectCustomerData()
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + PROSPECT_CLIENTS_GETALL;

                RestAPIExecutor restApiExecutor = new RestAPIExecutor();

                var restResult = restApiExecutor.Execute <List <ProspectClient> >(apiurl, null, "GET");

                if (jsonSerialization.IsValidJson(restResult.ToString()))
                {
                    var prospClientCollection = jsonSerialization.DeserializeFromString <List <ProspectClient> >(restResult.ToString());
                    _dtProspClients = ListtoDataTable.ToDataTable(prospClientCollection);
                    fillTreeviewData(_dtProspClients);
                }
                else
                {
                    MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                Logger.LogDebug(ex);
            }


            //HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl);
            //request.Method = "GET";
            //String prospClientResultJosn = String.Empty;
            //using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
            //{
            //    Stream dataStream = response.GetResponseStream();

            //    StreamReader reader = new StreamReader(dataStream);
            //    prospClientResultJosn = reader.ReadToEnd();
            //    reader.Close();
            //    dataStream.Close();
            //}
            //var prospClientCollection = jsonSerialization.DeserializeFromString<Result<List<ProspectClient>>>(prospClientResultJosn);

            //if (prospClientCollection.Value != null)
            //{
            //    _dtProspClients = ListtoDataTable.ToDataTable(prospClientCollection.Value);
            //    //dataGridProspClients.DataSource = _dtProspClients;
            //    fillTreeviewData(_dtProspClients);
            //    //gridDisplaySetting();
            //}
        }
 public ActionResult PartialCancel(int OrderID, string LotNos, int FileNo = 0)
 {
     try
     {
         int LoginID = GetLogin();
         if (LoginID > 0)
         {
             OrderInfoViewModel objInfo = this.objMemoService.MemoInfo(OrderID);
             MemoDetail         obj     = this.objMemoService.CancelPartialMemo(OrderID, LotNos, LoginID);
             if (FileNo != 0)
             {
                 fileUploadLogModel objFile = this.objMemoService.GetFileByID(FileNo);
                 if (objFile != null)
                 {
                     String    path       = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["INVUpload"]);
                     DataTable dtValid    = ListtoDataTable.ToDataTable <InventoryUpload>(obj.Inv.Where(x => x.LotStatus == "Valid").ToList());
                     DataTable dtNotValid = ListtoDataTable.ToDataTable <InventoryUpload>(obj.Inv.Where(x => x.LotStatus == "InValid").ToList());
                     ExportToExcel.SaveExcel(path, FileNo.ToString() + "_Valid", "Valid", dtValid);
                     ExportToExcel.SaveExcel(path, FileNo.ToString() + "_InValid", "InValid", dtNotValid);
                     objFile.validInv   = obj.Inv.Where(x => x.LotStatus == "Valid").Count();
                     objFile.invalidInv = obj.Inv.Where(x => x.LotStatus == "InValid").Count();
                     this.objMemoService.UpdateFile(objFile);
                     if (obj.Counts.OrderId > 0)
                     {
                         this.objMemoService.UpdateFile(obj.Counts.OrderId, FileNo);
                     }
                 }
             }
             if (objInfo != null && obj.Counts != null && obj.Counts.OrderId > 0)
             {
                 this.objMemoService.SendMailMemo(obj.Counts.OrderId, GetEmailID(), GetFullName(), objInfo.UserDetail.loginID, "List of inventory Partial Canceled Memo from memo-", "", Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["EmailTemplate_CancelMemo"]), objInfo, LotNos);
                 bool log = this.objUDSvc.UserActivitylogs(LoginID, "Partial canceled memo", LotNos);
             }
             return(Json(new Response {
                 Code = 200, IsSuccess = true, Message = "", Result = obj.Counts.validCount
             }));
         }
         return(Json(new Response {
             IsSuccess = false, Message = string.Format(StringResource.Invalid, "Session")
         }));
     }
     catch (Exception ex)
     {
         ErrorLog.Log("MemoController", "PartialCancel", ex);
         return(Json(new Response {
             IsSuccess = false, Message = ex.Message
         }));
     }
 }
示例#18
0
        internal double GetProfileValue()
        {
            IList <FinancialPlanner.Common.Model.PlanOptions.CurrentStatusToGoal> currentStatusToGoals
                = new CurrentStatusInfo().GetCurrentStatusToGoal(_optionId);

            _dtcurrentStatusToGoal = ListtoDataTable.ToDataTable(currentStatusToGoals.ToList());

            DataRow[] dr = _dtcurrentStatusToGoal.Select(string.Format("GoalName = '{0}'", _goal.Name));
            if (dr != null && dr.Count() > 0)
            {
                return((string.IsNullOrEmpty(dr[0]["FundAllocation"].ToString())) ?
                       0  : double.Parse(dr[0]["FundAllocation"].ToString()));
            }
            return(0);
        }
 public ActionResult Book(string LotNos, int CustomerID, int isConfirmed, int isSellDirect, string Remark, int FileNo = 0)
 {
     try
     {
         int LoginID = GetLogin();
         if (LoginID > 0)
         {
             MemoDetail obj = this.objMemoService.CreateMemo(LotNos, LoginID, CustomerID, isConfirmed, isSellDirect, Remark);
             if (FileNo != 0)
             {
                 fileUploadLogModel objFile = this.objMemoService.GetFileByID(FileNo);
                 if (objFile != null)
                 {
                     String    path       = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["INVUpload"]);
                     DataTable dtValid    = ListtoDataTable.ToDataTable <InventoryUpload>(obj.Inv.Where(x => x.LotStatus == "Valid").ToList());
                     DataTable dtNotValid = ListtoDataTable.ToDataTable <InventoryUpload>(obj.Inv.Where(x => x.LotStatus == "InValid").ToList());
                     ExportToExcel.SaveExcel(path, FileNo.ToString() + "_Valid", "Valid", dtValid);
                     ExportToExcel.SaveExcel(path, FileNo.ToString() + "_InValid", "InValid", dtNotValid);
                     objFile.validInv   = obj.Inv.Where(x => x.LotStatus == "Valid").Count();
                     objFile.invalidInv = obj.Inv.Where(x => x.LotStatus == "InValid").Count();
                     this.objMemoService.UpdateFile(objFile);
                     if (obj.Counts.OrderId > 0)
                     {
                         this.objMemoService.UpdateFile(obj.Counts.OrderId, FileNo);
                     }
                 }
             }
             if (obj != null && obj.Counts.OrderId != 0)
             {
                 this.objMemoService.SendMailMemo(obj.Counts.OrderId, GetEmailID(), GetFullName(), CustomerID, "List of inventory put on memo to", "", Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["EmailTemplate_PutOnMemo"]));
                 bool log = this.objUDSvc.UserActivitylogs(LoginID, "Put on memo", LotNos);
             }
             return(Json(new Response {
                 Code = 200, IsSuccess = true, Message = "", Result = obj.Counts
             }));
         }
         return(Json(new Response {
             IsSuccess = false, Message = string.Format(StringResource.Invalid, "Session")
         }));
     }
     catch (Exception ex)
     {
         ErrorLog.Log("MemoController", "Book", ex);
         return(Json(new Response {
             IsSuccess = false, Message = ex.Message
         }));
     }
 }
示例#20
0
        internal DataTable GetMFTransactionsInfo(int plannerId)
        {
            IList <MFTransactions> MFTransactionsObj = new List <MFTransactions>();

            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL, plannerId);

                RestAPIExecutor restApiExecutor = new RestAPIExecutor();

                var restResult = restApiExecutor.Execute <IList <MFTransactions> >(apiurl, null, "GET");

                if (jsonSerialization.IsValidJson(restResult.ToString()))
                {
                    MFTransactionsObj = jsonSerialization.DeserializeFromString <IList <MFTransactions> >(restResult.ToString());
                }
                if (MFTransactionsObj != null)
                {
                    if (MFTransactionsObj.Count > 0)
                    {
                        dtMFTrans = ListtoDataTable.ToDataTable(MFTransactionsObj.ToList());
                    }
                    else
                    {
                        return(defaultTableStructure());
                    }
                }
                return(dtMFTrans);
            }
            catch (System.Net.WebException webException)
            {
                if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized."))
                {
                    MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                return(null);
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
                return(null);
            }
        }
        public void FillInvestmentBifurcationData(int riskProfileId, string investmentType, DataGridView dataGrid)
        {
            if (_dtInvestmentSegment != null)
            {
                _dtInvestmentSegment.Clear();
            }
            IList <InvestmentSegment> InvestmentSegmentObj = new List <InvestmentSegment>();

            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL, riskProfileId);

                RestAPIExecutor restApiExecutor = new RestAPIExecutor();

                var restResult = restApiExecutor.Execute <IList <InvestmentSegment> >(apiurl, null, "GET");

                if (jsonSerialization.IsValidJson(restResult.ToString()))
                {
                    InvestmentSegmentObj = jsonSerialization.DeserializeFromString <IList <InvestmentSegment> >(restResult.ToString());
                }
                if (InvestmentSegmentObj != null)
                {
                    _dtInvestmentSegment = ListtoDataTable.ToDataTable(InvestmentSegmentObj.ToList());
                }
                fillGrid(investmentType, dataGrid);
            }
            catch (System.Net.WebException webException)
            {
                if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized."))
                {
                    MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
            }
        }
        private void loadRiskProfileData()
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + RISKPROFILE_GETALL;

            RestAPIExecutor restApiExecutor = new RestAPIExecutor();

            var restResult = restApiExecutor.Execute <List <RiskProfiledReturnMaster> >(apiurl, null, "GET");

            if (jsonSerialization.IsValidJson(restResult.ToString()))
            {
                var riskProfileColleection = jsonSerialization.DeserializeFromString <List <RiskProfiledReturnMaster> >(restResult.ToString());
                _dtRiskProfile = ListtoDataTable.ToDataTable(riskProfileColleection);
                fillTreeviewData(_dtRiskProfile);
            }
            else
            {
                MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void loadCustomerData()
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + CLIENTS_GETALL;

            RestAPIExecutor restApiExecutor = new RestAPIExecutor();

            var restResult = restApiExecutor.Execute <List <Client> >(apiurl, null, "GET");

            if (jsonSerialization.IsValidJson(restResult.ToString()))
            {
                var clientColleection = jsonSerialization.DeserializeFromString <List <Client> >(restResult.ToString());
                _dtClient = ListtoDataTable.ToDataTable(clientColleection);
                fillTreeviewData(_dtClient);
            }
            else
            {
                MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        internal DataTable GetSchemes(int investmentsegmentId)
        {
            DataTable dtSchemes = new DataTable();
            IList <RecommendedSchemes> recommendedSchemesObj = new List <RecommendedSchemes>();

            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_RECOMMENDEDSCHEME, investmentsegmentId);

                RestAPIExecutor restApiExecutor = new RestAPIExecutor();

                var restResult = restApiExecutor.Execute <IList <RecommendedSchemes> >(apiurl, null, "GET");

                if (jsonSerialization.IsValidJson(restResult.ToString()))
                {
                    recommendedSchemesObj = jsonSerialization.DeserializeFromString <IList <RecommendedSchemes> >(restResult.ToString());
                }
                if (recommendedSchemesObj != null)
                {
                    dtSchemes = ListtoDataTable.ToDataTable(recommendedSchemesObj.ToList());
                }
            }
            catch (System.Net.WebException webException)
            {
                if (webException.Message.Equals("The remote server returned an error: (401) Unauthorized."))
                {
                    MessageBox.Show("You session has been expired. Please Login again.", "Session Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                MethodBase currentMethodName = sf.GetMethod();
                LogDebug(currentMethodName.Name, ex);
            }
            return(dtSchemes);
        }
示例#25
0
        public DataTable GetRiskProfileReturnById(int id)
        {
            FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
            string apiurl = Program.WebServiceUrl + "/" + string.Format(RISKPROFILERETURN_DETAIL_GETALL, id);

            RestAPIExecutor restApiExecutor = new RestAPIExecutor();

            var restResult = restApiExecutor.Execute <List <RiskProfiledReturn> >(apiurl, null, "GET");

            if (jsonSerialization.IsValidJson(restResult.ToString()))
            {
                var riskProfileColleection = jsonSerialization.DeserializeFromString <List <RiskProfiledReturn> >(restResult.ToString());
                _dtRiskProfileReturn.Clear();
                _dtRiskProfileReturn = ListtoDataTable.ToDataTable(riskProfileColleection);
            }
            else
            {
                MessageBox.Show(restResult.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(_dtRiskProfileReturn);
        }
        public async Task <DataResult <DecryptViewModel> > DECRYPTINDENTS(DecryptViewModel model)
        {
            var objDecrypt     = new DataResult <DecryptViewModel>();
            var listOfIndentId = new List <string>();
            var listSec        = new List <SecurityNumberUpdateVM>();

            try
            {
                var dModel = new DecryptViewModel();

                string outputFile = Path.Combine($"{model.OutputPath}\\DecryptedFile.xls");

                var decrypt = PGPDecryptMain.Decrypt(model.EncryptedFilePath, GetConfigValue("PFSPrivateKey"), HashUtil.DecryptStringValue(GetConfigValue("PGPPassword")), outputFile);
                dModel.OutputPath = outputFile;
                if (!string.IsNullOrEmpty(dModel.OutputPath))
                {
                    var excelToDT = ParseExcelNow(outputFile);

                    var excelToList = ConvertDataTableToList <ExcelFileViewModel>(excelToDT).Select(x => new ExcelFileViewModel {
                        //INDENTID =  x.INDENTID.Remove(0,1),
                        INDENTID      = x.INDENTID,
                        ACCOUNTNUMBER = x.ACCOUNTNUMBER,
                        ACCOUNTNAME   = x.ACCOUNTNAME,
                        //DOMICILEBRANCHNAME = x.DOMICILEBRANCHNAME,
                        DOMICILEBRANCHADDRESS = x.DOMICILEBRANCHADDRESS,
                        SORTCODE              = x.SORTCODE,
                        CHEQUETYPE            = x.CHEQUETYPE,
                        NOOFLEAVES            = x.NOOFLEAVES,
                        DELIVERYBRANCHADDRESS = x.DELIVERYBRANCHADDRESS,
                        SCHEMECODE            = x.SCHEMECODE,
                        DOMICILEBRANCHCODE    = x.DOMICILEBRANCHCODE,
                        //DELIVERYBRANCHCODE = x.DELIVERYBRANCHCODE,
                        RANGESTART = x.RANGESTART,
                        RANGESTOP  = x.RANGESTOP,
                        STARTAUDIT = x.STARTAUDIT
                    });

                    var accountNo = excelToList.FirstOrDefault().ACCOUNTNUMBER;

                    var parameter = new List <IDbDataParameter>();
                    parameter.Add(_db.CreateParameter("P_ACCOUNTNO", accountNo, OracleDbType.Varchar2, ParameterDirection.Input));
                    parameter.Add(_db.CreateParameter("P_BATCHGENERATED", OracleDbType.RefCursor, null));
                    parameter.Add(_db.CreateParameter("P_ERROR_MSG", 100, string.Empty, DbType.String, ParameterDirection.Output));

                    var generatedIndentsByAccountNo = _db.GetDataTable(STOREDPROC.GETGENERATEDINDENTSBYACCTNO, CommandType.StoredProcedure, 0, parameter);

                    if (generatedIndentsByAccountNo.Rows.Count == 0)
                    {
                        objDecrypt.Data    = null;
                        objDecrypt.Status  = true;
                        objDecrypt.Message = "No matching record in database";
                    }
                    var generatedIndentsByAccountNoToList = ConvertDataTableToList <LocalValidateIndents>(generatedIndentsByAccountNo);

                    foreach (var item in excelToList)
                    {
                        var objIndent = generatedIndentsByAccountNoToList.Where(x => x.ACCOUNTNO == item.ACCOUNTNUMBER && x.INDENT_ID == item.INDENTID).Select(x => new CompareObjectFromDb
                        {
                            INDENTID              = x.INDENT_ID,
                            ACCOUNTNUMBER         = x.ACCOUNTNO,
                            ACCOUNTNAME           = x.ACCOUNTNAME,
                            DOMICILEBRANCHADDRESS = x.DOM_BRANCH_ADD,
                            SORTCODE              = x.SORTCODE,
                            CHEQUETYPE            = x.CHEAQUETYPE,
                            NOOFLEAVES            = x.NUMBER_OF_LEAVES,
                            DELIVERYBRANCHADDRESS = x.DEL_BRANCH_ADD,
                            SCHEMECODE            = x.SCHEMECODE,
                            DOMICILEBRANCHCODE    = x.DOM_BRANCH_CODE,
                            RANGESTART            = x.RANGE_START,
                            RANGESTOP             = x.RANGE_STOP,
                        }).FirstOrDefault();

                        if (objIndent == null)
                        {
                            objDecrypt.Data    = null;
                            objDecrypt.Status  = false;
                            objDecrypt.Message = "Excel record(s) does not match generated indents";
                            ErrorWriter.WriteLog($"Decryption process returned : { objDecrypt.Message } at { DateTime.Now }");

                            return(objDecrypt);
                        }

                        if (item.CHEQUETYPE != objIndent.CHEQUETYPE || item.DELIVERYBRANCHADDRESS != objIndent.DELIVERYBRANCHADDRESS || item.DOMICILEBRANCHADDRESS != objIndent.DOMICILEBRANCHADDRESS ||
                            item.DOMICILEBRANCHCODE != objIndent.DOMICILEBRANCHCODE || item.RANGESTART != Convert.ToDouble(objIndent.RANGESTART) || item.RANGESTOP != Convert.ToDouble(objIndent.RANGESTOP) ||
                            item.NOOFLEAVES != Convert.ToDouble(objIndent.NOOFLEAVES) || item.SORTCODE != objIndent.SORTCODE)
                        {
                            objDecrypt.Data    = null;
                            objDecrypt.Status  = false;
                            objDecrypt.Message = "Excel record(s) does not match generated indents";
                            ErrorWriter.WriteLog($"Decryption process returned : { objDecrypt.Message } at { DateTime.Now }");

                            return(objDecrypt);
                        }
                        listOfIndentId.Add(item.INDENTID);

                        var secModel = new SecurityNumberUpdateVM()
                        {
                            ACCOUNTNUMBER             = item.ACCOUNTNUMBER,
                            APPROVED                  = "0",
                            CHEQUESTATE               = "0",
                            CHEQUE_NUMBER             = item.RANGESTART.ToString(),
                            CMC_CODE                  = "985",
                            DATECAPTURED              = DateTime.Now.ToString("dd-MMM-yy"),
                            INDENT_ID                 = item.INDENTID,
                            INITUPLOAD                = "1",
                            NUMBER_OF_CHEQUES_PRINTED = item.NOOFLEAVES.ToString(),
                            OPERATOR_ID               = "Superflux",
                            PREFIX          = "PO",
                            REPLACES        = "",
                            REPLACESPREFIX  = "",
                            SECURITY_NUMBER = item.STARTAUDIT.ToString(),
                            SEQ             = "",
                            SN       = "1",
                            UPLOADED = "0"
                        };

                        listSec.Add(secModel);
                    }

                    using (var orcl = new OracleConnection(_connectionString))
                    {
                        orcl.Open();
                        var command = new OracleCommand()
                        {
                            Connection  = orcl,
                            CommandText = STOREDPROC.UPDATEINDENTTABLE,
                            CommandType = CommandType.StoredProcedure,
                            BindByName  = true
                        };

                        command.Parameters.Add(new OracleParameter("P_ERROR_MSG", OracleDbType.Varchar2)).Direction = ParameterDirection.Output;
                        command.Parameters.Add(new OracleParameter("n_array", OracleDbType.Varchar2)
                        {
                            CollectionType = OracleCollectionType.PLSQLAssociativeArray,
                            Value          = listOfIndentId.ToArray()
                        });
                        try
                        {
                            command.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            ErrorWriter.WriteLog($"Decryption process returned error : { ex.Message } at { DateTime.Now }");
                        }
                        finally
                        {
                            orcl.Close();
                        }

                        var listSecDT = new ListtoDataTable().ToDataTable(listSec);
                        _db.BulkCopyWriteToServer(listSecDT, "SECURITYCHEQUENUMBEROLD");
                    }
                }

                objDecrypt.Status  = true;
                objDecrypt.Message = $"File successfully decrypted to { outputFile } at { DateTime.Now }";
                objDecrypt.Data    = dModel;

                ErrorWriter.WriteLog($"Decryption process returned : { objDecrypt.Message } at { DateTime.Now }");

                return(objDecrypt);
            }
            catch (Exception ex)
            {
                var error = await ExceptionRefiner.LogError(ex);

                ErrorWriter.WriteLog($"Decryption process returned error: { ex.Message } at { DateTime.Now }");
                objDecrypt.Status  = false;
                objDecrypt.Message = error;
                objDecrypt.Data    = null;

                return(objDecrypt);
            }
        }
示例#27
0
        public void GetProcessTable(ref DataTable dta)
        {
            int    iReturnCode;                         //Return code
            int    iStartAddr;
            int    iStart;
            string szAdd = "ZR";
            string szDeviceName;                //List data for 'DeviceName'
            int    iNumberOfData = 32;          //Data for 'DeviceSize'

            short[] arrDeviceValue   = new short[iNumberOfData];
            int     iProcessType     = 0;
            int     iProcessDepth    = 0;
            int     iNormalReverse   = 0;
            int     iReverseWidth    = 0;
            int     iMarginofAdvance = 0;
            int     iMarginofDelay   = 0;
            int     iCutOff          = 0;
            string  szProcessName    = "";
            List <ProcessTableData> processtables = new List <ProcessTableData>();

            //DataTable dta = new DataTable();

            try
            {
                int idx = 0;
                for (int cclink = 1; cclink <= 4; cclink++)
                {
                    iStart = ((cclink - 1) * 1000) + 3000;
                    for (int stno = 1; stno <= 30; stno++)
                    {
                        iStartAddr   = ((stno - 1) * 32) + iStart;
                        szDeviceName = szAdd + iStartAddr.ToString();
                        iReturnCode  = 0;
                        if (Connected == true)
                        {
                            iReturnCode = plc.ReadDeviceBlock2(szDeviceName, iNumberOfData, out arrDeviceValue[0]);
                        }
                        if (iReturnCode == 0)
                        {
                            int k = 0;
                            szProcessName = "";
                            foreach (var baca in arrDeviceValue)
                            {
                                if (k < 16)
                                {
                                    switch (k)
                                    {
                                    case 0:
                                        iProcessType = baca;
                                        break;

                                    case 1:
                                        iProcessDepth = baca;
                                        break;

                                    case 2:
                                        iNormalReverse = baca;
                                        break;

                                    case 3:
                                        iReverseWidth = baca;
                                        break;

                                    case 4:
                                        iMarginofAdvance = baca;
                                        break;

                                    case 5:
                                        iMarginofDelay = baca;
                                        break;

                                    case 6:
                                        iCutOff = baca;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                                else
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szProcessName += tchar.ToString();
                                    }
                                }
                                k++;
                            }
                            //insert to datatable
                            processtables.Add(new ProcessTableData
                            {
                                id              = idx,
                                cc_link_no      = cclink,
                                stno            = stno,
                                process_type    = iProcessType,
                                depth           = iProcessDepth,
                                normal_reverse  = iNormalReverse,
                                margin_reverse  = iReverseWidth,
                                margin_of_adv   = iMarginofAdvance,
                                margin_of_delay = iMarginofDelay,
                                cut_off         = iCutOff,
                                process_name    = szProcessName
                            });
                        }
                        idx++;
                    }
                }
                //ListtoDataTable lsttodt = new ListtoDataTable();
                dta = ListtoDataTable.ListToDataTable(processtables);
            }
            //Exception processing
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                string stringFormat = "Read Process Table Failed";
                StatusPLCLog = stringFormat;
            }
            //return dta;
        }
示例#28
0
        public int GetProcessStatusTable(ref DataTable dta)
        {
            int    iReturnCode   = 9;                   //Return code
            string szAdd         = "ZR";
            int    iNumberOfData = 94;                  //Data for 'DeviceSize'

            short[] arrDeviceValue = new short[iNumberOfData];
            List <ConvResultTableData> convtables = new List <ConvResultTableData>();

            try
            {
                if (Connected == true)
                {
                    //List<JobCode> jobcode = new List<JobCode>();
                    for (int id = 1; id <= 400; id++)
                    {
                        Debug.WriteLine("Ambil data untuk ind = " + id);
                        int    iStartAddr   = ((id - 1) * 100) + 11000;
                        string szDeviceName = szAdd + iStartAddr.ToString();

                        iReturnCode = plc.ReadDeviceBlock2(szDeviceName, iNumberOfData, out arrDeviceValue[0]);

                        if (iReturnCode == 0)
                        {
                            //int k = 0;
                            string  szPID       = "";
                            string  szVIN       = "";
                            string  szSuffix    = "";
                            string  szModelCode = "";
                            string  szWLCCode   = "";
                            string  szChassisNo = "";
                            short[] arrJob      = new short[60];
                            int     idxJob      = 0;
                            short   idx         = 0;

                            Debug.WriteLine("Start Baca PLC");
                            Debug.WriteLine("Jumlah yang akan dibace" + arrDeviceValue.Length);
                            for (int k = 0; k < arrDeviceValue.Length; k++)
                            {
                                short baca = arrDeviceValue[k];
                                //if (k < 95)
                                //{
                                //
                                if (k == 0)
                                {
                                    idx = baca;
                                }
                                else if (Enumerable.Range(1, 5).Contains(k))
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szPID += tchar.ToString();
                                    }
                                }
                                else if (Enumerable.Range(6, 9).Contains(k))
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szVIN += tchar.ToString();
                                    }
                                }
                                else if (k == 15)
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szSuffix += tchar.ToString();
                                    }
                                }
                                else if (Enumerable.Range(16, 2).Contains(k))
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szModelCode += tchar.ToString();
                                    }
                                }
                                else if (Enumerable.Range(18, 2).Contains(k))
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szWLCCode += tchar.ToString();
                                    }
                                }
                                else if (Enumerable.Range(20, 10).Contains(k))
                                {
                                    byte[] kon = BitConverter.GetBytes(baca);

                                    foreach (byte m in kon)
                                    {
                                        char tchar = Convert.ToChar(m);
                                        szChassisNo += tchar.ToString();
                                    }
                                }
                                else if (Enumerable.Range(35, 60).Contains(k))
                                {
                                    arrJob[idxJob] = baca;
                                    idxJob++;
                                }
                                //}
                                //k++;
                            }
                            //Debug.WriteLine("Data satu row = " + k.ToString());
                            //creat job list
                            List <JobCode> jobCodes = new List <JobCode>();
                            for (int ijob = 0; ijob < 30; ijob++)
                            {
                                Debug.WriteLine("Add Job Code idx = " + ijob.ToString() + "; Jumlahtotal job = " + arrJob.Length.ToString());
                                JobCode jobCode = new JobCode {
                                    B1 = arrJob[(ijob * 2)], B2 = arrJob[(ijob * 2) + 1]
                                };
                                jobCodes.Add(jobCode);
                            }

                            //insert to datatable
                            convtables.Add(new ConvResultTableData
                            {
                                Id             = idx,
                                pid            = szPID,
                                vin            = szVIN,
                                suffix         = szSuffix,
                                model_code     = szModelCode,
                                wlc_code       = szWLCCode,
                                chassis_number = szChassisNo,
                                jobCode        = jobCodes
                            });
                        }
                        else
                        {
                            iReturnCode = 8;
                        }
                    }
                }
                else
                {
                    iReturnCode = 7;
                }
                //ListtoDataTable lsttodt = new ListtoDataTable();
                dta = ListtoDataTable.ListToDataTable(convtables);
            }
            //Exception processing
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);
                string stringFormat = "Read Conversion Result Table Failed";
                StatusPLCLog = stringFormat;
                iReturnCode  = 9;
            }
            return(iReturnCode);
        }
        public async Task <DataResult <MfbViewModel> > UPLOADMFBEXCEL(HttpPostedFileBase upload, string username)
        {
            try
            {
                if (string.IsNullOrEmpty(username))
                {
                    throw new PlatformCustomException("invalid user");
                }

                var objResult = new DataResult <MfbViewModel>();
                var parameter = new List <IDbDataParameter>();

                //declare all variables for indents for excel
                #region IndentVariables
                var indentId               = string.Empty;
                var micrAccountNo          = string.Empty;
                var sortCode               = string.Empty;
                var lastSerialNumber       = 0;
                var branchCode             = string.Empty;
                var branchName             = string.Empty;
                var firstChequeNumber      = string.Empty;
                var numberOfCheques        = string.Empty;
                var numberOfChequesPrinted = string.Empty;
                var chequeType             = string.Empty;
                var dateOfRequest          = DateTime.Now.ToString("dd-MMM-yy");
                var dateEnterted           = DateTime.Now.ToString("dd-MMM-yy");
                var pulled             = string.Empty;
                var datePulled         = DateTime.Now.ToString("dd-MMM-yy");
                var printed            = string.Empty;
                var approved           = string.Empty;
                var approver           = string.Empty;
                var uploaded           = string.Empty;
                var requisitionId      = string.Empty;
                var scheduleNo         = string.Empty;
                var indentSource       = string.Empty;
                var deliveryBranchCode = string.Empty;
                var customerName       = string.Empty;
                var ranged             = string.Empty;
                var recieved           = string.Empty;
                var dateRecieved       = DateTime.Now.ToString("dd-MMM-yy");
                var deleted            = string.Empty;
                var acknowledged       = string.Empty;
                var dateAcknowledged   = DateTime.Now.ToString("dd-MMM-yy");
                var dispatched         = string.Empty;
                var dateDispatched     = DateTime.Now.ToString("dd-MMM-yy");
                var dispatchNumber     = string.Empty;
                var dateApproved       = DateTime.Now.ToString("dd-MMM-yy");
                var costOfBooklet      = string.Empty;
                var cancel             = string.Empty;
                var mult               = string.Empty;
                var cmcCode            = string.Empty;
                var batchId            = string.Empty;
                var generated          = string.Empty;
                var dateOfPrinting     = DateTime.Now.ToString("dd-MMM-yy");
                var receivedApprovedBy = string.Empty;
                int lastSerialCounter  = 0;
                #endregion

                var validateUpload = await MfbExcelValidation(upload);

                //convert excel to list
                var convertExcelToDT = FileUploadToDataTable(upload);
                //convert databaTable to List
                var convertDtToList = ConvertDataTableToList <MFBIndentsUpload>(convertExcelToDT);
                var listMfb         = new List <MFBIndentsUpload>();

                foreach (var item in convertDtToList)
                {
                    var          branchParam = new List <IDbDataParameter>();
                    DbConnection connection  = null;
                    branchParam.Add(_db.CreateParameter("p_branchname", 100, item.BRANCHNAME, DbType.String, ParameterDirection.Input));
                    branchParam.Add(_db.CreateParameter("p_branchcode", 5, string.Empty, DbType.String, ParameterDirection.Output));
                    branchParam.Add(_db.CreateParameter("p_sortcode", 9, string.Empty, DbType.String, ParameterDirection.Output));
                    branchParam.Add(_db.CreateParameter("p_cmcinuse", 5, string.Empty, DbType.String, ParameterDirection.Output));
                    branchParam.Add(_db.CreateParameter("p_error_msg", 200, string.Empty, DbType.String, ParameterDirection.Output));

                    if (string.IsNullOrEmpty(branchCode))
                    {
                        var getBranchCodeByName = _db.GetExecuteNonQuery(STOREDPROC.GETBRANCHCODEBYBRANCHNAME, CommandType.StoredProcedure, branchParam, 0, out connection);

                        branchCode = getBranchCodeByName.Parameters["p_branchcode"].Value.ToString();
                        sortCode   = getBranchCodeByName.Parameters["p_sortcode"].Value.ToString();
                        cmcCode    = getBranchCodeByName.Parameters["p_cmcinuse"].Value.ToString();
                        string error = getBranchCodeByName.Parameters["p_error_msg"].Value.ToString();

                        if (!string.IsNullOrEmpty(error))
                        {
                            objResult.Data    = null;
                            objResult.Status  = false;
                            objResult.Message = error;
                            ErrorWriter.WriteLog($"MFB upload process returned : { objResult.Message } at { DateTime.Now }");
                            return(objResult);
                        }
                    }
                    var currentUser = username;
                    var reqId       = item.REQUISITION_ID.ToString();

                    micrAccountNo      = item.MICR_ACCOUNT_NO;
                    requisitionId      = Convert.ToInt32(item.REQUISITION_ID).ToString("D8");
                    approved           = "N";
                    branchName         = item.BRANCHNAME;
                    cancel             = "N";
                    chequeType         = GetConfigValue("MFBChequeType");
                    deleted            = "N";
                    dispatched         = "N";
                    numberOfCheques    = item.NUMBEROFCHEQUES;
                    indentSource       = GetConfigValue("IndentSource");
                    pulled             = "N";
                    acknowledged       = "N";
                    printed            = "N";
                    scheduleNo         = item.SCHEDULE_NO;
                    deliveryBranchCode = item.DELIVERY_BRANCHCODE;
                    customerName       = item.CUSTOMER_NAME;
                    recieved           = "N";
                    deleted            = "N";
                    dispatched         = "N";

                    indentId = $"{branchCode}{micrAccountNo}{requisitionId}";

                    var lastSerialParam = new List <IDbDataParameter>();


                    if (lastSerialCounter <= Convert.ToInt32(lastSerialNumber))
                    {
                        var dR = new DataRead();
                        var dt = new DataTable();

                        var ds = dR.GetLastSerialNumberByBranchCode(branchCode);
                        if (ds.Tables[0].Rows.Count < 1)
                        {
                            //SETLAST_SERIAL_NUMBER TO 1
                            lastSerialCounter = 1;

                            var insertParams = new List <IDbDataParameter>();

                            insertParams.Add(_db.CreateParameter("p_branchcode", 13, branchCode, DbType.String, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_sortcode", 9, sortCode, DbType.String, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_lastserial", 12, 0, DbType.Decimal, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_cmccode", 3, cmcCode, DbType.String, ParameterDirection.Input));
                            insertParams.Add(_db.CreateParameter("p_error_msg", 200, string.Empty, DbType.String, ParameterDirection.Output));

                            //INSERT NEW RECORD FOR THE BRANCH
                            _db.InsertWithTransaction(STOREDPROC.INSERTINTOLASTSERIALNUMBER, CommandType.StoredProcedure, insertParams, 0);
                        }
                        else
                        {
                            dt = ds.Tables[0];
                            var getLastSerial = dt.Rows[0]["LAST_SERIAL_NUMBER"].ToString();

                            lastSerialNumber = Convert.ToInt32(getLastSerial);
                            var lastSerialNumberToUse = Convert.ToInt32(lastSerialNumber) + 1;
                            lastSerialCounter = Convert.ToInt32(lastSerialNumberToUse);
                        }
                    }

                    var objMfb = new MFBIndentsUpload()
                    {
                        INDENT_ID              = indentId,
                        MICR_ACCOUNT_NO        = micrAccountNo,
                        SORTCODE               = sortCode,
                        BRANCHNAME             = branchName,
                        BRANCHCODE             = branchCode,
                        FIRST_CHEQUE_NUMBER    = lastSerialCounter.ToString(),
                        NUMBEROFCHEQUES        = numberOfCheques,
                        NUMBEROFCHEQUESPRINTED = numberOfChequesPrinted,
                        CHEQUETYPE             = chequeType,
                        DATEOFREQUEST          = dateOfRequest,
                        DATEENTERED            = dateEnterted,
                        PULLED              = pulled,
                        DATEPULLED          = datePulled,
                        PRINTED             = printed,
                        DATEOFPRINTING      = dateOfPrinting,
                        RECEIVEDAPPROVED_BY = receivedApprovedBy,
                        ORIGINATOR          = currentUser,
                        APPROVED            = approved,
                        APPROVER            = approver,
                        UPLOADED            = uploaded,
                        REQUISITION_ID      = requisitionId,
                        SCHEDULE_NO         = scheduleNo,
                        INDENTSOURCE        = indentSource,
                        DELIVERY_BRANCHCODE = deliveryBranchCode,
                        CUSTOMER_NAME       = customerName,
                        RANGED              = ranged,
                        RECEIVED            = recieved,
                        DATERECEIVED        = dateRecieved,
                        DELETED             = deleted,
                        ACKNOWLEDGED        = acknowledged,
                        DATEACKNOWLEDGED    = dateAcknowledged,
                        DISPATCHED          = dispatched,
                        DATEDISPATCHED      = dateDispatched,
                        DISPATCHNUMBER      = dispatchNumber,
                        DATEAPPROVED        = dateApproved,
                        COST_OF_BOOKLET     = costOfBooklet,
                        CANCEL              = cancel,
                        MULT      = mult,
                        BATCHID   = batchId,
                        GENERATED = generated
                    };

                    lastSerialCounter++;
                    listMfb.Add(objMfb);
                }

                var listMfbDT = new ListtoDataTable().ToDataTable(listMfb);

                _db.BulkCopyWriteToServer(listMfbDT, "INDENTS_TEST");

                //update last serial table with the last id used by branch code
                var updateParam = new List <IDbDataParameter>();

                updateParam.Add(_db.CreateParameter("p_lastserialnumber", 100, lastSerialCounter - 1, DbType.String, ParameterDirection.Input));
                updateParam.Add(_db.CreateParameter("p_branchcode", 5, branchCode, DbType.String, ParameterDirection.Input));
                updateParam.Add(_db.CreateParameter("p_error_msg", 200, string.Empty, DbType.String, ParameterDirection.Output));

                _db.Update(STOREDPROC.UPDATELASTSERIALNUMBER, CommandType.StoredProcedure, updateParam, 0);

                objResult.Data    = null;
                objResult.Status  = true;
                objResult.Message = listMfbDT.Rows.Count.ToString();

                ErrorWriter.WriteLog($"MFB upload process returned : { objResult.Message } indents processed at { DateTime.Now }");

                return(objResult);
            }
            catch (Exception ex)
            {
                var error = await ExceptionRefiner.LogError(ex);

                ErrorWriter.WriteLog($"MFB upload process returned error: { ex.Message } at { DateTime.Now }");
                return(new DataResult <MfbViewModel>()
                {
                    Data = null,
                    Message = error,
                    Status = false
                });
            }
        }
        public async Task <DataResult <IndentsToGenerate> > GENERATEDINDENTSANDENCRYPT(string userId)
        {
            var objIndents        = new DataResult <IndentsToGenerate>();
            var parameter         = new List <IDbDataParameter>();
            var exportDataToExcel = false;
            var listIndents       = new List <GeneratedIndents>();
            //var copyOfGeneratedIndents = new DataTable();
            DbConnection db        = null;
            var          transCode = GetConfigValue("TransactionCode");


            try
            {
                parameter.Add(_db.CreateParameter("P_ERROR_MSG", string.Empty, DbType.String));
                parameter.Add(_db.CreateParameter("P_INDENTGENERATED", OracleDbType.RefCursor, null));
                parameter.Add(_db.CreateParameter("p_transcode", 13, transCode, DbType.String, ParameterDirection.Input));

                var generateIndentsForProcessing = _db.GetDataTable(STOREDPROC.GENERATEINDENTFORPROC, CommandType.StoredProcedure, 0, parameter);
                if (generateIndentsForProcessing.Rows.Count == 0)
                {
                    objIndents.Data    = null;
                    objIndents.Status  = false;
                    objIndents.Message = "No record currently available for processing.";
                    ErrorWriter.WriteLog($"Fetch indetns for encryption returned : { objIndents.Message } at { DateTime.Now }");

                    return(objIndents);
                }

                //This part is used to remove indentId column from excel report. Uncomment if you want to generate indents without Indent_Id
                //copyOfGeneratedIndents = generateIndentsForProcessing.Copy();
                //generateIndentsForProcessing.Columns.RemoveAt(0);

                DeleteExistingFilesInFolder(GetConfigValue("GeneratedIndentLocation"));
                var fullPath = ServerPath();
                var fileName = Path.GetFileName(fullPath);
                exportDataToExcel = await ExportDataToExcelAndEncrypt(generateIndentsForProcessing, fileName, fullPath);

                var convertDTToList = ConvertDataTableToList <IndentsToGenerate>(generateIndentsForProcessing);

                string id = DateTime.Now.ToFileTimeUtc().ToString();


                foreach (var item in convertDTToList)
                {
                    var model = new GeneratedIndents();
                    model.GENERATED_ID     = id;
                    model.BATCHID          = id;
                    model.INDENT_ID        = item.INDENT_ID;
                    model.STATUSID         = 0;
                    model.DOM_BRANCH_ADD   = item.DOMICILEBRANCHADDRESS;
                    model.DOM_BRANCH_CODE  = item.DOMICILEBRANCHCODE;
                    model.SORTCODE         = item.SORTCODE;
                    model.CHEAQUETYPE      = item.CHEQUETYPE;
                    model.NUMBER_OF_LEAVES = item.NOOFLEAVES.ToString();
                    model.DEL_BRANCH_ADD   = item.DELIVERYBRANCHADDRESS;
                    model.SCHEMECODE       = item.SCHEMECODE;
                    model.DEL_BRANCH_CODE  = item.DELIVERYBRANCHCODE;
                    model.RANGE_START      = item.RANGESTART.ToString();
                    model.RANGE_STOP       = item.RANGESTOP.ToString();
                    model.GENERATEDBY      = userId;
                    model.GENERATEDON      = DateTime.Now.ToString("dd-MMMM-yy");
                    model.SECNUM           = null;
                    model.DATECAPTURED     = DateTime.Now.ToString("dd-MMMM-yy");
                    model.ACCOUNTNO        = item.ACCOUNTNUMBER;
                    model.ACCOUNTNAME      = item.ACCOUNTNAME;
                    model.CURRENCY         = item.CURRENCY;

                    listIndents.Add(model);
                }

                var listIndentDT = new ListtoDataTable().ToDataTable(listIndents);

                var updateParam = new List <IDbDataParameter>();
                updateParam.Add(_db.CreateParameter("P_ERROR_MSG", 200, string.Empty, DbType.String, ParameterDirection.Output));

                var updateCommand = _db.UpdateWithTransaction(STOREDPROC.UPDATEGENERATEDINDENTS, CommandType.StoredProcedure, updateParam, 0);

                _db.BulkCopyWriteToServer(listIndentDT, "GENERATEDINDENTS");

                objIndents.Data    = null;
                objIndents.Status  = true;
                objIndents.Message = generateIndentsForProcessing.Rows.Count.ToString();
                return(objIndents);
            }
            catch (Exception ex)
            {
                var error = await ExceptionRefiner.LogError(ex);

                ErrorWriter.WriteLog($"Encryption process returned error: { ex.Message } at { DateTime.Now }");
                objIndents.Data    = null;
                objIndents.Status  = false;
                objIndents.Message = error;

                return(objIndents);
            }
        }