Exemple #1
0
        public DataTable GetJobCardDetailsbyTransIdandUID(JobCardModel Lobj)
        {
            try
            {
                cmd = new OracleCommand();
                cmd.InitialLONGFetchSize = 1000;
                cmd.CommandType          = CommandType.StoredProcedure;
                cmd.CommandText          = "PR_GET_GSWS_PRRD_JOB_CARD_DTLS";
                cmd.Parameters.Add("P_TYPE", OracleDbType.Int32, 10).Value               = 7;
                cmd.Parameters.Add("P_JC_ID", OracleDbType.Varchar2, 500).Value          = Lobj.P_JC_ID;
                cmd.Parameters.Add("P_MANDAL_ID", OracleDbType.Varchar2, 50).Value       = Lobj.P_LGD_MANDAL_CODE;
                cmd.Parameters.Add("P_GP_ID", OracleDbType.Varchar2, 50).Value           = Lobj.P_GP_ID;
                cmd.Parameters.Add("P_SACHIVALAYAM_ID", OracleDbType.Varchar2, 50).Value = Lobj.P_SACHIVALAYAM_ID;
                cmd.Parameters.Add("P_UID_NO", OracleDbType.Varchar2, 50).Value          = Lobj.P_UID_NO;
                cmd.Parameters.Add("P_USER_ID", OracleDbType.Varchar2, 50).Value         = Lobj.P_USER_ID;
                cmd.Parameters.Add("P_STATUS", OracleDbType.Varchar2, 50).Value          = Lobj.P_STATUS;
                cmd.Parameters.Add("P_CUR", OracleDbType.RefCursor).Direction            = ParameterDirection.Output;
                DataTable dtLogin = GetgswsDataAdapter(cmd);

                if (dtLogin != null)
                {
                    return(dtLogin);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public DataTable UpdateStatus(JobCardModel ObjLGD)
        {
            try
            {
                cmd = new OracleCommand();
                cmd.InitialLONGFetchSize = 1000;
                cmd.CommandType          = CommandType.StoredProcedure;
                cmd.CommandText          = "PR_GET_GSWS_PRRD_JOB_CARD_DTLS";
                cmd.Parameters.Add("P_TYPE", OracleDbType.Varchar2, 10).Value            = ObjLGD.P_TYPE;
                cmd.Parameters.Add("P_JC_ID", OracleDbType.Varchar2, 100).Value          = ObjLGD.P_JC_ID;
                cmd.Parameters.Add("P_MANDAL_ID", OracleDbType.Varchar2, 10).Value       = ObjLGD.P_LGD_MANDAL_CODE;
                cmd.Parameters.Add("P_GP_ID", OracleDbType.Varchar2, 10).Value           = ObjLGD.P_GP_ID;
                cmd.Parameters.Add("P_SACHIVALAYAM_ID", OracleDbType.Varchar2, 50).Value = ObjLGD.P_SACHIVALAYAM_ID;
                cmd.Parameters.Add("P_UID_NO", OracleDbType.Varchar2, 50).Value          = ObjLGD.P_UID_NO;
                cmd.Parameters.Add("P_USER_ID", OracleDbType.Varchar2, 10).Value         = ObjLGD.P_USER_ID;
                cmd.Parameters.Add("P_STATUS", OracleDbType.Varchar2, 10).Value          = ObjLGD.P_STATUS;
                cmd.Parameters.Add("P_CUR", OracleDbType.RefCursor).Direction            = ParameterDirection.Output;
                DataTable dtLogin = GetgswsDataAdapter(cmd);

                if (dtLogin != null)
                {
                    return(dtLogin);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("JobCardExceptions");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "Error Getting Update Status:" + ex.Message.ToString()));
                throw ex;
            }
        }
        public dynamic GetJobCardDataHel(JobCardModel Lobj)
        {
            PRRDSPHelper spobj   = new PRRDSPHelper();
            dynamic      objdata = new ExpandoObject();

            try
            {
                //_log.Info("In the PRRDHelper=>GetJobCardData : " + JsonConvert.SerializeObject(Lobj));
                DataTable dtLgd = spobj.GetJobCardSP(Lobj);
                if (dtLgd != null && dtLgd.Rows.Count > 0)
                {
                    objdata.Status   = 100;
                    objdata.Reason   = "Data Loaded successfully";
                    objdata.DataList = dtLgd;
                }
                else
                {
                    objdata.Status = 102;
                    objdata.Reason = "No Data Found";
                }
            }
            catch (Exception ex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("JobcardHelperExceptions");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "getting error GetJobCardDataHel :" + ex.Message.ToString()));
                objdata.Status = 102;
                objdata.Reason = "Data not found";
            }
            return(objdata);
        }
        public dynamic UpdateJobcardStatus(JobCardModel ObjLGD)
        {
            dynamic      obj   = new ExpandoObject();
            PRRDSPHelper spobj = new PRRDSPHelper();

            try
            {
                DataTable dt = spobj.UpdateStatus(ObjLGD);
                if (dt != null && dt.Rows.Count > 0)
                {
                    obj.Status         = 100;
                    obj.Reason         = "";
                    obj.Jobcarddetails = dt;
                }
                else
                {
                    obj.Status = 101;
                    obj.Reason = "No Data Found";
                }
            }
            catch (Exception ex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("JobcardHelperExceptions");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "getting error UpdateJobcardStatus :" + ex.Message.ToString()));
                obj.Status = 102;
                obj.Reason = "Error Occued While Loading Data";
                return(obj);
            }
            return(obj);
        }
        public dynamic RejectJobcard(dynamic data)
        {
            string       jsondata  = token_gen.Authorize_aesdecrpty(data);
            JobCardModel val       = JsonConvert.DeserializeObject <JobCardModel>(jsondata);
            LogModel     ologmodel = new LogModel();

            //ologmodel.UserId = val.UserId;
            //ologmodel.SacId = val.SacId;
            //ologmodel.DesignId = val.DesignId;
            //ologmodel.DeptId = string.Empty;
            //ologmodel.TranId = val.TranId;
            ////olog.WriteLogParameters(ologmodel);
            try
            {
                JobCardHelper hel = new JobCardHelper();
                //_log.Info("In the PRRDController => EachJobCardData: " + jsondata.ToString());

                return(Ok(hel.UpdateJobcardStatus(val)));

                // return "SuccessEncryptDataModel
            }
            catch (Exception ex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("JobcardControllrExceptions");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "getting error RejectJobcard :" + ex.Message.ToString()));
                CatchData.Status = "Failure";
                CatchData.Reason = CommonSPHel.ThirdpartyMessage;
                return(Ok(CatchData));
            }
        }
        public IHttpActionResult GetJobcardetails(dynamic data)
        {
            string       value     = token_gen.Authorize_aesdecrpty(data);
            JobCardModel root      = JsonConvert.DeserializeObject <JobCardModel>(value);
            LogModel     ologmodel = new LogModel();

            ologmodel.UserId   = root.UserId;
            ologmodel.SacId    = root.SacId;
            ologmodel.DesignId = root.DesignId;
            ologmodel.DeptId   = "";          //Departments.Panchayati_Raj.ToString();
            ologmodel.TranId   = root.TranId;
            //olog.WriteLogParameters(ologmodel);
            JobCardHelper hlpval = new JobCardHelper();

            try
            {
                //_log.Info("In the PRRDController => GetJobcardetails: " + value.ToString());
                return(Ok(hlpval.GetJobcardetails(root)));
            }
            catch (Exception ex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("JobcardControllrExceptions");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "getting error GetJobcardetails :" + ex.Message.ToString()));
                CatchData.Status = 102;
                CatchData.Reason = "Error Occured While Getting Data";
                return(Ok(CatchData));
            }
        }
        public dynamic SendJobCardAPI(dynamic objdata)
        {
            dynamic objResponse = new ExpandoObject();

            try
            {
                string ourtransid = objdata["data"][0]["InterfaceUniqueId"];

                using (var client = new HttpClient())
                {
                    ServicePointManager.Expect100Continue = true;
                    ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;

                    System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); };

                    var req = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["ApiBaseAddress"].ToString() + "Rural-Development/v1/api/v1/ruralDevelopment");
                    req.ContentType = "application/json";
                    req.Method      = "POST";


                    req.Headers.Add("Authorization", "Bearer 16cce3cd-15d5-3c19-8691-14203061b278");

                    req.AllowAutoRedirect = false;
                    string str = JsonConvert.SerializeObject(objdata);

                    str = str.Replace("null", "\"\"");
                    var _jsonObject = str;

                    //var _jsonObject = JsonConvert.SerializeObject(str);
                    string mappath   = HttpContext.Current.Server.MapPath("SendJobcardAPIJSON");
                    Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "JSON :" + str));
                    if (!String.IsNullOrEmpty(_jsonObject))
                    {
                        using (System.IO.Stream s = req.GetRequestStream())
                        {
                            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(s))
                                sw.Write(_jsonObject);
                        }
                    }

                    var resp = (HttpWebResponse)req.GetResponse();
                    var sr   = new StreamReader(resp.GetResponseStream());

                    if ((resp.StatusCode == HttpStatusCode.Redirect) || (resp.StatusCode == HttpStatusCode.SeeOther) ||
                        (resp.StatusCode == HttpStatusCode.RedirectMethod))
                    {
                        objResponse.Status = "Failed";
                        objResponse.data   = "";
                    }
                    else
                    {
                        string data = sr.ReadToEnd().Trim();
                        if (!data.Contains("An error has occurred"))
                        {
                            List <JobCardAPIModel> objjobcard = new List <JobCardAPIModel>();

                            //objResponse.Status = "Success";
                            objjobcard = JsonConvert.DeserializeObject <List <JobCardAPIModel> >(data);

                            string outputdata = string.Empty;
                            objResponse.data = objjobcard;
                            foreach (var item in objjobcard)
                            {
                                outputdata += item.Remarks + "/";
                            }
                            objResponse.REASON = outputdata.TrimEnd('/');
                            objResponse.Status = objjobcard[0].Transactionid;
                            if (objResponse.Status != "")
                            {
                                try
                                {
                                    transactionModel objtrans = new transactionModel();
                                    objtrans.TYPE        = "2";
                                    objtrans.TXN_ID      = ourtransid;
                                    objtrans.DEPT_ID     = "3301";
                                    objtrans.DEPT_TXN_ID = objjobcard[0].Transactionid;
                                    objtrans.STATUS_CODE = "01";
                                    objtrans.REMARKS     = objjobcard[0].Remarks;

                                    DataTable    dt           = new transactionHelper().transactionInsertion(objtrans);
                                    JobCardModel updatestatus = new JobCardModel();
                                    updatestatus.P_TYPE   = "11";
                                    updatestatus.P_JC_ID  = ourtransid;
                                    updatestatus.P_STATUS = "1";
                                    UpdateJobcardStatus(updatestatus);
                                }
                                catch (Exception ex)
                                {
                                    string mappath3   = HttpContext.Current.Server.MapPath("JobcardHelperExceptions");
                                    Task   WriteTask3 = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath3, "Send Jobcard API Error:" + ex.Message.ToString()));
                                }
                            }
                        }
                        else
                        {
                            objResponse.Status = "428";
                            objResponse.REASON = CommonSPHel.ThirdpartyMessage;
                        }
                    }
                }
            }
            catch (WebException ex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("JobcardHelperExceptions");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_Log_Exception(mappath, "Error Getting Send Jobcard API :" + ex.Message.ToString()));

                objResponse.Status = "Failed";
                objResponse.REASON = CommonSPHel.ThirdpartyMessage;
            }
            return(objResponse);
        }