public byte[] ReadHoldingRegisters(byte slaveAddress, string startAddress, ushort nuMBErOfPoints)
        {
            var Address = DMT.DevToAddrW("DVP", startAddress, slaveAddress);
            var frame   = ReadHoldingRegistersMessage(slaveAddress, Convert.ToUInt32(Address), nuMBErOfPoints);

            SerialAdaper.WriteLine(frame);
            Thread.Sleep(DELAY);
            var buffReceiver = SerialAdaper.ReadLine();

            if (string.IsNullOrEmpty(buffReceiver))
            {
                return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }
            }
            ;
            var tempStrg        = buffReceiver.Substring(1, buffReceiver.Length - 2);
            var messageReceived = Conversion.HexToBytes(tempStrg);

            if (buffReceiver.Length == 10)
            {
                ModbusExcetion(messageReceived);
            }
            var data = new byte[messageReceived[2]];

            Array.Copy(messageReceived, 3, data, 0, data.Length);
            return(data);
        }
        public byte[] ReadCoilStatus(byte slaveAddress, string startAddress, ushort nuMBErOfPoints)
        {
            var stopwatch = Stopwatch.StartNew();

            var Address = DMT.DevToAddrW("DVP", startAddress, slaveAddress);
            var frame   = ReadCoilStatusMessage(slaveAddress, $"{Address}", nuMBErOfPoints);

            stopwatch.Stop();
            //   RequestAndResponseMessage _RequestAndResponseMessage = new RequestAndResponseMessage("RequestRead", frame);

            EthernetAdaper.Write(frame);
            Thread.Sleep(DELAY);
            var buffReceiver = EthernetAdaper.Read();

            if (FUNCTION_01 != buffReceiver[7])
            {
                var errorbytes = new byte[3];
                Array.Copy(buffReceiver, 6, errorbytes, 0, errorbytes.Length);
                ModbusExcetion(errorbytes);
            }

            int SizeByte = buffReceiver[8]; // Số lượng byte dữ liệu thu được.
            var data     = new byte[SizeByte];

            Array.Copy(buffReceiver, 9, data, 0,
                       data.Length); // Dữ liệu cần lấy bắt đầu từ byte có chỉ số 9 trong buffReceive.
            return(Bit.ToByteArray(Bit.ToArray(data)));
        }
Beispiel #3
0
        public TValue[] Read <TValue>(string address, ushort length)
        {
            int Address = DMT.DevToAddrW("DVP", address, Station);

            if (typeof(TValue) == typeof(bool))
            {
                bool[] b = busTcpClient.ReadCoil($"{Address}", length).Content;
                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(ushort))
            {
                ushort[] b = busTcpClient.ReadUInt16($"{Address}", length).Content;

                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(int))
            {
                int[] b = busTcpClient.ReadInt32($"{Address}", length).Content;

                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(uint))
            {
                uint[] b = busTcpClient.ReadUInt32($"{Address}", length).Content;
                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(long))
            {
                long[] b = busTcpClient.ReadInt64($"{Address}", length).Content;
                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(ulong))
            {
                ulong[] b = busTcpClient.ReadUInt64($"{Address}", length).Content;
                return((TValue[])(object)b);
            }

            if (typeof(TValue) == typeof(short))
            {
                short[] b = busTcpClient.ReadInt16($"{Address}", length).Content;
                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(double))
            {
                double[] b = busTcpClient.ReadDouble($"{Address}", length).Content;
                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(float))
            {
                float[] b = busTcpClient.ReadFloat($"{Address}", length).Content;
                return((TValue[])(object)b);
            }
            if (typeof(TValue) == typeof(string))
            {
                string b = busTcpClient.ReadString($"{Address}", length).Content;
                return((TValue[])(object)b);
            }

            throw new InvalidOperationException(string.Format("type '{0}' not supported.", typeof(TValue)));
        }
        public JsonResult DeleteBeneficary(Guid benificaryid)
        {
            registerresponse rr = new registerresponse();

            try
            {
                using (BAL.DMT_BeneficiaryRegister objBAL = new BAL.DMT_BeneficiaryRegister())
                {
                    ENT.DMT_BeneficiaryRegisterAdminView BR = objBAL.GetBenificarybyId(benificaryid);

                    if (BR != null)
                    {
                        DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                        GENERALRESPONSE GR = new GENERALRESPONSE();

                        object postdata = new
                        {
                            CustomerMobile  = BR.dmt_beneficiarymobile,
                            BeneficiaryCode = BR.dmt_requestno,
                            RemitterId      = BR.dmt_remitterId
                        };

                        string response = dmt.DeleteBeneficary(postdata, "DMT_DeleteBeneficiary");

                        GR = JsonConvert.DeserializeObject <GENERALRESPONSE>(response);

                        if (GR.code == 0)
                        {
                            if (GR.message.ToString().ToUpper() == "OTC SEND SUCCESSFULLY")
                            {
                                rr.message    = GR.message.ToString().ToUpper();
                                rr.code       = 1;
                                rr.customerid = BR.dmt_beneficiaryid;
                            }
                            GlobalVarible.AddMessage("SUCCESS");
                        }
                        else
                        {
                            GlobalVarible.AddError(GR.message.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(new { MySession.Current.MessageResult, rr }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteBeneficiaryConfirm(customerverificationmodel model)
        {
            GlobalVarible.Clear();
            try
            {
                DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                OTPVALIDATIONRESPONSE OV = new OTPVALIDATIONRESPONSE();

                // get customer information by id
                using (BAL.DMT_BeneficiaryRegister objBAL = new BAL.DMT_BeneficiaryRegister())
                {
                    ENT.DMT_BeneficiaryRegisterAdminView BR = objBAL.GetBenificarybyId(model.dmt_customerid);

                    //ENT.DMT_BeneficiaryRegisterAdminView BR = objBAL.GetBenificarybyId(Guid.Parse("1E2C4B19-1229-4ECE-9C04-464AA8907ADC"));

                    var postdata = new
                    {
                        BeneficiaryCode = BR.dmt_requestno,
                        RemitterId      = BR.dmt_remitterId,
                        OTP             = model.verificationotp,
                        CustomerMobile  = BR.dmt_requestno
                    };

                    string response = dmt.ValidateCustomerOTP(postdata, "DMT_DeleteBeneficiaryConfirm");

                    OV = JsonConvert.DeserializeObject <OTPVALIDATIONRESPONSE>(response);

                    if (OV.code == 0)
                    {
                        objBAL.Entity.dmt_beneficiaryid = model.dmt_customerid;

                        objBAL.Delete(objBAL.Entity);

                        GlobalVarible.AddMessage("Beneficiary Deleted Successfully.");
                    }
                    else
                    {
                        GlobalVarible.AddError(OV.message.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        public bool Write(string address, dynamic value)
        {
            int Address = DMT.DevToAddrW("DVP", address, Station);

            if (value is bool)
            {
                busTcpClient.Write($"{Address}", value);
            }
            else
            {
                busTcpClient.Write($"{Address}", value);
            }

            return(true);
        }
        public byte[] WriteSingleRegister(byte slaveAddress, string startAddress, byte[] values)
        {
            var Address = DMT.DevToAddrW("DVP", startAddress, slaveAddress);
            var frame   = WriteSingleRegisterMessage(slaveAddress, $"{Address}", values);

            SerialAdaper.Write(frame, 0, frame.Length);
            Thread.Sleep(DELAY);
            var buffReceiver = SerialAdaper.Read();

            if (buffReceiver.Length == 5)
            {
                ModbusExcetion(buffReceiver);
            }
            return(buffReceiver);
        }
Beispiel #8
0
        public HttpResponseMessage VerifyCustomer(customerverificationmodel model)
        {
            GlobalVarible.Clear();
            try
            {
                DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                OTPVALIDATIONRESPONSE OV = new OTPVALIDATIONRESPONSE();

                // get customer information by id
                using (BAL.DMT_CustomerRegister objBAL = new BAL.DMT_CustomerRegister())
                {
                    objBAL.Entity.dmt_customerid = model.dmt_customerid;
                    ENT.DMT_CustomerRegister customerRegister = (ENT.DMT_CustomerRegister)objBAL.GetByPrimaryKey(objBAL.Entity);

                    var postdata = new
                    {
                        RemitterId     = customerRegister.dmt_requestno,
                        OTP            = model.verificationotp,
                        CustomerMobile = customerRegister.dmt_mobile
                    };

                    string response = dmt.ValidateCustomerOTP(postdata, "DMT_OTP_Customer_Confirmation");

                    OV = JsonConvert.DeserializeObject <OTPVALIDATIONRESPONSE>(response);

                    if (OV.code == 0)
                    {
                        objBAL.Entity.dmt_status = 1;
                        objBAL.UpdateStatus(objBAL.Entity);

                        GlobalVarible.AddMessage("Customer Verified Successfully.");
                    }
                    else
                    {
                        GlobalVarible.AddError(OV.message.ToString());
                    }
                }
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
                ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty);
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult }));
            }
        }
Beispiel #9
0
        public JsonResult VerifyCustomer(customerverificationmodel model)
        {
            GlobalVarible.Clear();
            try
            {
                DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                OTPVALIDATIONRESPONSE OV = new OTPVALIDATIONRESPONSE();

                // get customer information by id
                using (BAL.DMT_CustomerRegister objBAL = new BAL.DMT_CustomerRegister())
                {
                    objBAL.Entity.dmt_customerid = model.dmt_customerid;
                    ENT.DMT_CustomerRegister customerRegister = (ENT.DMT_CustomerRegister)objBAL.GetByPrimaryKey(objBAL.Entity);

                    var postdata = new
                    {
                        RemitterId     = customerRegister.dmt_requestno,
                        OTP            = model.verificationotp,
                        CustomerMobile = customerRegister.dmt_mobile
                    };

                    string response = dmt.ValidateCustomerOTP(postdata, "DMT_OTP_Customer_Confirmation");

                    OV = JsonConvert.DeserializeObject <OTPVALIDATIONRESPONSE>(response);

                    if (OV.code == 0)
                    {
                        objBAL.Entity.dmt_status = 1;
                        objBAL.UpdateStatus(objBAL.Entity);

                        GlobalVarible.AddMessage("Customer Verified Successfully.");
                    }
                    else
                    {
                        GlobalVarible.AddError(OV.message.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
        public byte[] WriteSingleRegister(byte slaveAddress, string startAddress, byte[] values)
        {
            var Address = DMT.DevToAddrW("DVP", startAddress, slaveAddress);
            var frame   = WriteSingleRegisterMessage(slaveAddress, Convert.ToUInt32(Address), values);

            SerialAdaper.WriteLine(frame);
            Thread.Sleep(DELAY);
            var buffReceiver = SerialAdaper.ReadLine();
            var tempStrg     = buffReceiver.Substring(1, buffReceiver.Length - 2);
            var data         = Conversion.HexToBytes(tempStrg);

            if (buffReceiver.Length == 10)
            {
                ModbusExcetion(data);
            }
            return(data);
        }
        public byte[] ReadHoldingRegisters(byte slaveAddress, string startAddress, ushort nuMBErOfPoints)
        {
            var Address = DMT.DevToAddrW("DVP", startAddress, slaveAddress);
            var frame   = ReadHoldingRegistersMessage(slaveAddress, $"{Address}", nuMBErOfPoints);

            SerialAdaper.Write(frame, 0, frame.Length);
            Thread.Sleep(DELAY);
            var buffReceiver = SerialAdaper.Read();

            if (buffReceiver.Length == 5)
            {
                ModbusExcetion(buffReceiver);
            }
            var data = new byte[buffReceiver.Length - 5];

            Array.Copy(buffReceiver, 3, data, 0, data.Length);
            return(data);
        }
        public byte[] WriteMultipleRegisters(byte slaveAddress, string startAddress, byte[] values)
        {
            var Address = DMT.DevToAddrW("DVP", startAddress, slaveAddress);
            var frame   = WriteMultipleRegistersMessage(slaveAddress, $"{Address}", values);

            EthernetAdaper.Write(frame);
            // RequestAndResponseMessage _RequestAndResponseMessage = new RequestAndResponseMessage("RequestWrite", frame);

            Thread.Sleep(DELAY);
            var buffReceiver = EthernetAdaper.Read();

            if (FUNCTION_16 != buffReceiver[7])
            {
                var errorbytes = new byte[3];
                Array.Copy(buffReceiver, 6, errorbytes, 0, errorbytes.Length);
                ModbusExcetion(errorbytes);
            }

            return(buffReceiver);
        }
Beispiel #13
0
        private void SrednicePrzedObrobka()
        {
            var index = 0;

            foreach (var srednica in SrednicaStopnia)
            {
                if (IZ[index] <= 2)
                {
                    DFN.Add(srednica);
                }
                else
                {
                    DFN.Add(SrednicaStopnia[index] + QFN);
                }
                index++;
            }

            index = 0;
            foreach (var srednica in SrednicaStopnia)
            {
                if (IZ[index] == 1)
                {
                    DMT.Add(srednica);
                }
                else
                {
                    DMT.Add(DFN[index] + QMT);
                }
                index++;
            }

            index = 0;
            foreach (var srednica in SrednicaStopnia)
            {
                DRG.Add(DMT[index] + QRG);
                index++;
            }
        }
Beispiel #14
0
        public JsonResult SaveEntry(ENT.DMT_CustomerRegister model)
        {
            // in this method we return one json with two properties.with code and message.
            // if code is 1 then we have to open box for otp verification.

            registerresponse rr = new registerresponse();

            try
            {
                List <string> result = new List <string>();

                result = ValidateRequest(model);

                if (result.Count <= 0)
                {
                    if (model.EntryMode == COM.Enumration.EntryMode.ADD)
                    {
                        model.CreatedBy       = _LoginUserId;
                        model.dmt_userid      = _LoginUserId;
                        model.CreatedDateTime = DateTime.Now;
                        model.dmt_customerid  = Guid.NewGuid();

                        using (BAL.DMT_CustomerRegister objBAL = new BAL.DMT_CustomerRegister())
                        {
                            if (objBAL.Insert(model))
                            {
                                // api call for register customer in api
                                DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                                GENERALRESPONSE RR = new GENERALRESPONSE();

                                CUSTOMERREGISTRATIONRESPONSE CR = new CUSTOMERREGISTRATIONRESPONSE();

                                // prepare post data object to check if customer is available or not
                                object postdata = new
                                {
                                    CustomerMobile = model.dmt_mobile
                                };

                                string response = dmt.CheckUser(postdata, "DMT_CustomerValidate");

                                CR = JsonConvert.DeserializeObject <CUSTOMERREGISTRATIONRESPONSE>(response);

                                if (CR.Code == "224")
                                {
                                    postdata = new
                                    {
                                        FirstName   = model.dmt_firstname,
                                        LastName    = model.dmt_lastname,
                                        MobileNo    = model.dmt_mobile,
                                        DateOfBirth = model.dmt_dateofbirth,
                                        Address     = model.dmt_address,
                                        Pincode     = model.dmt_pincode,
                                    };

                                    response = dmt.RegisterCustomer(postdata, "DMT_CustomerRegistration");

                                    RR = new GENERALRESPONSE();

                                    RR = JsonConvert.DeserializeObject <GENERALRESPONSE>(response);

                                    if (RR.code == 0)
                                    {
                                        Message message = JsonConvert.DeserializeObject <Message>(RR.message.ToString());

                                        // update remitter id of registered customer.
                                        model.dmt_requestno = message.data.remitter.id;
                                        objBAL.UpdateRemitter(model);

                                        rr.code       = 1;
                                        rr.message    = "Customer Added Successfully.Please verify Customer Now.";
                                        rr.customerid = model.dmt_customerid;
                                        GlobalVarible.AddMessage("SUCCESS");
                                    }
                                    else
                                    {
                                        GlobalVarible.AddError(RR.message.ToString());
                                        // unable to register user so deleteing from our local database.
                                        objBAL.Delete(model);
                                    }
                                }
                                else if (CR.Code == "1")
                                {
                                    string message = CR.Message.ToString();
                                    GlobalVarible.AddError(message);
                                    // unable to register user so deleteing from our local database.
                                    objBAL.Delete(model);
                                }
                                else
                                {
                                    Message message = JsonConvert.DeserializeObject <Message>(CR.Message.ToString());

                                    if (!String.IsNullOrEmpty(message.data.remitter.mobile))
                                    {
                                        // update remitter id of registered customer.
                                        model.dmt_requestno = message.data.remitter.id;
                                        model.dmt_status    = 1;
                                        objBAL.UpdateStatusWithRemitter(model);

                                        // add all beneficary which already registered.
                                        if (message.data.beneficiary.Count > 0)
                                        {
                                            List <ENT.DMT_BeneficiaryRegister> lstEntity = new List <ENT.DMT_BeneficiaryRegister>();

                                            foreach (BENEFICIARY B in message.data.beneficiary)
                                            {
                                                lstEntity.Add(new ENT.DMT_BeneficiaryRegister
                                                {
                                                    dmt_beneficiaryid     = Guid.NewGuid(),
                                                    userid                = _LoginUserId,
                                                    dmt_beneficiaryname   = B.name,
                                                    dmt_beneficiarymobile = B.mobile,
                                                    dmt_customerid        = model.dmt_customerid,
                                                    dmt_bankname          = B.bank,
                                                    dmt_ifsc              = B.ifsc,
                                                    dmt_accountnumber     = B.account,
                                                    dmt_address           = string.Empty,
                                                    dmt_addharcard        = string.Empty,
                                                    dmt_status            = 1,
                                                    dmt_requestno         = B.id,
                                                    dmt_response          = string.Empty,
                                                    dmt_pincode           = string.Empty
                                                });
                                            }

                                            using (BAL.DMT_BeneficiaryRegister objBenificary = new BAL.DMT_BeneficiaryRegister())
                                            {
                                                objBenificary.BulkInsert(lstEntity);
                                            }
                                        }

                                        rr.code       = 2;
                                        rr.message    = "Customer Added Successfully.";
                                        rr.customerid = model.dmt_customerid;
                                        GlobalVarible.AddMessage("SUCCESS");
                                    }
                                }
                            }
                            else
                            {
                                GlobalVarible.AddError("Some error occured while saving the customer.");
                            }
                        }
                    }
                    else
                    {
                        model.UpdatedDateTime = DateTime.Now;
                        model.UpdatedBy       = _LoginUserId;
                        GlobalVarible.AddMessage("Customer Updated Successfully.");
                    }
                }
                else
                {
                    GlobalVarible.AddErrors(result);
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(new { MySession.Current.MessageResult, rr }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult TransferMoney(moneytransfermodel model)
        {
            GlobalVarible.Clear();
            try
            {
                // check for user password
                if (checkpassword(model.password))
                {
                    using (BAL.DMT_MoneyRemittance objTranfer = new BAL.DMT_MoneyRemittance())
                    {
                        // check balance in local.

                        MEMBERS.SQLReturnMessageNValue retVal = objTranfer.DMT_VALIDATE_Transaction(_LoginUserId.ToString(), model.transferamount.ToString());


                        if (retVal.Outval == 1)
                        {
                            DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                            GENERALRESPONSE GR = new GENERALRESPONSE();

                            ENT.DMT_BeneficiaryRegisterAdminView BD = new ENT.DMT_BeneficiaryRegisterAdminView();

                            ENT.DMT_CustomerRegisterAdminView CD = new ENT.DMT_CustomerRegisterAdminView();

                            // get customer information by id
                            using (BAL.DMT_BeneficiaryRegister objBAL = new BAL.DMT_BeneficiaryRegister())
                            {
                                BD = objBAL.GetBenificarybyId(model.benificaryid);
                            }

                            using (BAL.DMT_CustomerRegister objBAL = new BAL.DMT_CustomerRegister())
                            {
                                CD = objBAL.GetCustomerById(model.customerid);
                            }

                            var postdata = new
                            {
                                BeneficiryCode   = BD.dmt_requestno.ToString(),
                                BeneficiryMobile = BD.dmt_beneficiarymobile.ToString(),
                                CustomerMobile   = CD.dmt_mobile.ToString(),
                                IFSC             = BD.dmt_ifsc.ToString(),
                                AccountNo        = BD.dmt_accountnumber.ToString(),
                                RountingType     = model.transfertype.ToString(),
                                BeneficiaryName  = BD.dmt_beneficiaryname.ToString(),
                                Remakrs          = model.remarks.ToString(),
                                Amount           = model.transferamount,
                                Mode             = "WEB",
                                RemitterId       = CD.dmt_requestno.ToString(),
                            };

                            string response = dmt.TransferAmount(postdata, "DMT_MoneyRemittance");

                            GR = JsonConvert.DeserializeObject <GENERALRESPONSE>(response);

                            if (GR.code == 0)
                            {
                                // amount credited successfully then calculate the commission and charge.

                                objTranfer.Entity.userid              = _LoginUserId;
                                objTranfer.Entity.mt_beneficiarycode  = BD.dmt_requestno;
                                objTranfer.Entity.mt_BeneficiryMobile = BD.dmt_beneficiarymobile;
                                objTranfer.Entity.mt_customermobile   = CD.dmt_mobile;
                                objTranfer.Entity.mt_ifsc             = BD.dmt_ifsc;
                                objTranfer.Entity.mt_accountnumber    = BD.dmt_accountnumber;
                                objTranfer.Entity.mt_routingtype      = model.transfertype;
                                objTranfer.Entity.mt_BeneficiaryName  = BD.dmt_beneficiaryname;
                                objTranfer.Entity.mt_remarks          = model.remarks;
                                objTranfer.Entity.mt_amount           = (decimal)model.transferamount;
                                objTranfer.Entity.mt_mode             = "WEB";
                                objTranfer.Entity.mt_Ipaddress        = GlobalVarible.GETIPADDRESS();
                                objTranfer.Entity.mt_RemitterId       = CD.dmt_requestno;
                                objTranfer.Entity.mt_RequestNo        = string.Empty;
                                objTranfer.Entity.mt_Response         = response;

                                retVal = objTranfer.DMT_REMITTANCE(objTranfer.Entity);

                                if (retVal.Outval == 1)
                                {
                                    GlobalVarible.AddMessage("Amount Transfered Successfully.");
                                }
                                else
                                {
                                    GlobalVarible.AddError(retVal.Outmsg);
                                }
                            }
                            else
                            {
                                GlobalVarible.AddError(GR.message.ToString());
                            }
                        }
                        else
                        {
                            GlobalVarible.AddError(retVal.Outmsg);
                        }
                    }
                }
                else
                {
                    GlobalVarible.AddError("Invalid User Password.");
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(MySession.Current.MessageResult, JsonRequestBehavior.AllowGet));
        }
Beispiel #16
0
        public bool[] ReadDiscrete(string address, ushort length)
        {
            int Address = DMT.DevToAddrW("DVP", address, Station);

            return(busTcpClient.ReadDiscrete($"{Address}", length).Content);
        }
        public JsonResult SaveEntry(ENT.DMT_BeneficiaryRegister model)
        {
            // in this method we return one json with two properties.with code and message.
            // if code is 1 then we have to open box for otp verification.
            registerresponse rr = new registerresponse();

            try
            {
                List <string> result = new List <string>();

                result = ValidateRequest(model);

                if (result.Count <= 0)
                {
                    if (model.EntryMode == COM.Enumration.EntryMode.ADD)
                    {
                        model.CreatedBy         = _LoginUserId;
                        model.userid            = _LoginUserId;
                        model.CreatedDateTime   = DateTime.Now;
                        model.dmt_beneficiaryid = Guid.NewGuid();

                        using (BAL.DMT_BeneficiaryRegister objBAL = new BAL.DMT_BeneficiaryRegister())
                        {
                            if (objBAL.Insert(model))
                            {
                                // api call for register benificary in api
                                DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                                GENERALRESPONSE RR = new GENERALRESPONSE();

                                BENEFICIARYREGISTRATIONRESPONSE BR = new BENEFICIARYREGISTRATIONRESPONSE();

                                ENT.DMT_CustomerRegister customer = null;

                                using (BAL.DMT_CustomerRegister customerBAL = new BAL.DMT_CustomerRegister())
                                {
                                    customerBAL.Entity.dmt_customerid = model.dmt_customerid;
                                    customer = (ENT.DMT_CustomerRegister)customerBAL.GetByPrimaryKey(customerBAL.Entity);
                                }

                                // prepare post data object to check if beneficiary is available
                                object postdata = new
                                {
                                    FirstName         = model.dmt_beneficiaryname,
                                    LastName          = model.dmt_beneficiaryname,
                                    BeneficiaryMobile = model.dmt_beneficiarymobile,
                                    CustomerMobile    = customer.dmt_mobile,
                                    BankName          = model.dmt_bankname,
                                    IfscCode          = model.dmt_ifsc,
                                    AccountNumber     = model.dmt_accountnumber,
                                    BranchName        = model.dmt_branchname,
                                    Address           = model.dmt_address,
                                    AddharCard        = model.dmt_addharcard,
                                    Pincode           = model.dmt_pincode,
                                    RemitterId        = customer.dmt_requestno
                                };

                                string response = dmt.RegisterBenificary(postdata, "DMT_BeneficiaryRegistration");

                                BR = JsonConvert.DeserializeObject <BENEFICIARYREGISTRATIONRESPONSE>(response);

                                if (BR.Code == 0)
                                {
                                    if (BR.Message.data.beneficiary.id > 0)
                                    {
                                        model.dmt_status    = 1;
                                        model.dmt_requestno = BR.Message.data.beneficiary.id.ToString();

                                        objBAL.UpdateStatusWithId(model);

                                        rr.code       = 2;
                                        rr.message    = "Benificary Added Successfully.";
                                        rr.customerid = model.dmt_beneficiaryid;

                                        GlobalVarible.AddMessage("SUCCESS");
                                    }
                                }
                                else if (BR.Code == 1)
                                {
                                    GlobalVarible.AddError(BR.Message.ToString());
                                }
                            }
                            else
                            {
                                GlobalVarible.AddError("Some error occured while saving the benificary.");
                            }
                        }
                    }
                    else
                    {
                        model.UpdatedDateTime = DateTime.Now;
                        model.UpdatedBy       = _LoginUserId;
                        GlobalVarible.AddMessage("Benificary Updated Successfully.");
                    }
                }
                else
                {
                    GlobalVarible.AddErrors(result);
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
            }
            MySession.Current.MessageResult.MessageHtml = GlobalVarible.GetMessageHTML();
            return(Json(new { MySession.Current.MessageResult, rr }, JsonRequestBehavior.AllowGet));
        }
Beispiel #18
0
        public DaneWalkaDoTabel GetDataToTable()
        {
            var list = new List <object>
            {
                Srednica,
                SRC,
                Dlugosc,
                DLC,
                MaterialPn,
                GestoscMaterialu,
                Stopnie,
                S,
                O,
                MPO,
                MPF,
                MW,
                TPF,
                DSR,
                SRPF,
                DLPF,
                QRG,
                QMT,
                QFN,
                QLRG,
                QLMT
            };

            var atname = new List <string>
            {
                "Średnica [mm]",
                "Średnica PF [mm]",
                "Długość [mm]",
                "Długość PF [mm]",
                "Materiał",
                "Gęstość materiału [kg/m3]",
                nameof(Stopnie),
                "S ",
                "O [%]",
                "mPO [kg]",
                "mPF [kg]",
                "mW [kg]",
                "TPF [μm]",
                "dśr [mm]",
                "SRPF [mm]",
                "DLPF [mm]",
                "Qzgr [mm]",
                "Qkszt [mm]",
                "Qwyk [mm]",
                "QPLzgr [mm]",
                "QPKksz [mm]"
            };

            var stopienWalu = new List <int>();

            for (int i = 0; i < Stopnie; i++)
            {
                stopienWalu.Add(i + 1);
            }
            var listList = new List <object[]>
            {
                stopienWalu.Cast <object>().ToArray(),
                DlugoscStopnia.Cast <object>().ToArray(),
                SrednicaStopnia.Cast <object>().ToArray(),
                KlasaTolerancji.Cast <object>().ToArray(),
                TPO.Cast <object>().ToArray(),
                KO.Cast <object>().ToArray(),
                IZ.Cast <object>().ToArray(),
                DFN.Cast <object>().ToArray(),
                DMT.Cast <object>().ToArray(),
                DRG.Cast <object>().ToArray(),
                APMAX.Cast <object>().ToArray()
            };

            var listname = new List <string>
            {
                "Stopień wału",
                "Długość stopnia [mm]",
                "Średnica stopnia [mm]",
                "Klasa Tolerancji",
                "TPO [μm]",
                "Ko",
                nameof(IZ),
                "Di Wyk [mm]",
                "Di Kszt [mm]",
                "Di Zgr [mm]",
                "apmax [mm]"
            };

            var naddatki = new List <List <object> >
            {
                new List <object>
                {
                    "Wykańczający",
                    "Kształtujący",
                    "Zgrubny"
                },
                new List <object>
                {
                    QFND,
                    QMTD,
                    QRGD
                },
                new List <object>
                {
                    QFN,
                    QMT,
                    QRG
                }
            };

            var naddatkiNames = new List <string>
            {
                "Rodzaj naddatku",
                "Naddatki dobrane [mm]",
                "Naddatki do obliczeń [mm]"
            };

            return(new DaneWalkaDoTabel
            {
                AtributeValue = list,
                ListValue = listList,
                AtributeName = atname,
                ListName = listname,
                NaddatkiValues = naddatki,
                NaddatkiNames = naddatkiNames,
                ImageWalek = Image
            });
        }
Beispiel #19
0
        public HttpResponseMessage RegisterCustomer(ENT.DMT_CustomerRegister model)
        {
            GlobalVarible.Clear();
            registerresponse rr = new registerresponse();

            try
            {
                List <string> result = new List <string>();
                result = ValidateRequest(model);

                if (result.Count <= 0)
                {
                    model.CreatedBy       = _LOGINUSERID;
                    model.dmt_userid      = _LOGINUSERID;
                    model.CreatedDateTime = DateTime.Now;
                    model.dmt_customerid  = Guid.NewGuid();

                    using (BAL.DMT_CustomerRegister objBAL = new BAL.DMT_CustomerRegister())
                    {
                        if (objBAL.Insert(model))
                        {
                            // api call for register customer in api
                            DMT dmt = new DMT(APICONSTANT.USERNAME, APICONSTANT.PASSWORD, APICONSTANT.URL);

                            GENERALRESPONSE RR = new GENERALRESPONSE();

                            CUSTOMERREGISTRATIONRESPONSE CR = new CUSTOMERREGISTRATIONRESPONSE();

                            // prepare post data object to check if customer is available or not
                            object postdata = new
                            {
                                CustomerMobile = model.dmt_mobile
                            };

                            string response = dmt.CheckUser(postdata, "DMT_CustomerValidate");

                            CR = JsonConvert.DeserializeObject <CUSTOMERREGISTRATIONRESPONSE>(response);

                            if (CR.Code == "224")
                            {
                                postdata = new
                                {
                                    FirstName   = model.dmt_firstname,
                                    LastName    = model.dmt_lastname,
                                    MobileNo    = model.dmt_mobile,
                                    DateOfBirth = model.dmt_dateofbirth,
                                    Address     = model.dmt_address,
                                    Pincode     = model.dmt_pincode,
                                };

                                response = dmt.RegisterCustomer(postdata, "DMT_CustomerRegistration");

                                RR = new GENERALRESPONSE();

                                RR = JsonConvert.DeserializeObject <GENERALRESPONSE>(response);

                                if (RR.code == 0)
                                {
                                    Message message = JsonConvert.DeserializeObject <Message>(RR.message.ToString());

                                    // update remitter id of registered customer.
                                    model.dmt_requestno = message.data.remitter.id;
                                    objBAL.UpdateRemitter(model);

                                    rr.code       = 1;
                                    rr.message    = "Customer Added Successfully.Please verify Customer Now.";
                                    rr.customerid = model.dmt_customerid;
                                    GlobalVarible.AddMessage("SUCCESS");
                                }
                                else
                                {
                                    GlobalVarible.AddError(RR.message.ToString());
                                    // unable to register user so deleteing from our local database.
                                    objBAL.Delete(model);
                                }
                            }
                            else if (CR.Code == "1")
                            {
                                string message = CR.Message.ToString();
                                GlobalVarible.AddError(message);
                                // unable to register user so deleteing from our local database.
                                objBAL.Delete(model);
                            }
                            else
                            {
                                Message message = JsonConvert.DeserializeObject <Message>(CR.Message.ToString());

                                if (!String.IsNullOrEmpty(message.data.remitter.mobile))
                                {
                                    // update remitter id of registered customer.
                                    model.dmt_requestno = message.data.remitter.id;
                                    model.dmt_status    = 1;
                                    objBAL.UpdateStatusWithRemitter(model);

                                    // add all beneficary which already registered.
                                    if (message.data.beneficiary.Count > 0)
                                    {
                                        List <ENT.DMT_BeneficiaryRegister> lstEntity = new List <ENT.DMT_BeneficiaryRegister>();

                                        foreach (BENEFICIARY B in message.data.beneficiary)
                                        {
                                            lstEntity.Add(new ENT.DMT_BeneficiaryRegister
                                            {
                                                dmt_beneficiaryid     = Guid.NewGuid(),
                                                userid                = _LOGINUSERID,
                                                dmt_beneficiaryname   = B.name,
                                                dmt_beneficiarymobile = B.mobile,
                                                dmt_customerid        = model.dmt_customerid,
                                                dmt_bankname          = B.bank,
                                                dmt_ifsc              = B.ifsc,
                                                dmt_accountnumber     = B.account,
                                                dmt_address           = string.Empty,
                                                dmt_addharcard        = string.Empty,
                                                dmt_status            = 1,
                                                dmt_requestno         = B.id,
                                                dmt_response          = string.Empty,
                                                dmt_pincode           = string.Empty
                                            });
                                        }

                                        using (BAL.DMT_BeneficiaryRegister objBenificary = new BAL.DMT_BeneficiaryRegister())
                                        {
                                            objBenificary.BulkInsert(lstEntity);
                                        }
                                    }
                                    rr.code       = 2;
                                    rr.message    = "Customer Added Successfully.";
                                    rr.customerid = model.dmt_customerid;
                                    GlobalVarible.AddMessage("SUCCESS");
                                }
                                else
                                {
                                    rr.code       = 1;
                                    rr.message    = "Customer Added Successfully.Please verify Customer Now.";
                                    rr.customerid = model.dmt_customerid;
                                    GlobalVarible.AddMessage("SUCCESS");
                                }
                            }
                            return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult, rr }));
                        }
                        else
                        {
                            GlobalVarible.AddError("Some error occured while saving the customer.");
                            return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult, rr }));
                        }
                    }
                }
                else
                {
                    GlobalVarible.AddErrors(result);
                    return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult, rr }));
                }
            }
            catch (Exception ex)
            {
                GlobalVarible.AddError(ex.Message);
                ERRORREPORTING.Report(ex, _REQUESTURL, _LOGINUSERID, _ERRORKEY, string.Empty);
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { GlobalVarible.FormResult, rr }));
            }
        }