Exemple #1
0
 public IHttpActionResult commentAddition(dynamic data)
 {
     try
     {
         //string value = token_gen.Authorize_aesdecrpty(data);
         string          value   = JsonConvert.SerializeObject(data);
         commentAddition rootobj = JsonConvert.DeserializeObject <commentAddition>(value);
         return(Ok(Internalhel.commentAddition(rootobj)));
     }
     catch (Exception ex)
     {
         CatchData.Status = "Failure";
         CatchData.Reason = ex.Message;
         return(Ok(CatchData));
     }
 }
        public dynamic commentAddition(commentAddition obj)
        {
            dynamic objupdate = new ExpandoObject();

            try
            {
                if (commentAdditionHelper(obj))
                {
                    objupdate.Status = 200;
                    objupdate.Reason = "Your Record Updated Successfully";
                }
                else
                {
                    objupdate.Status = 400;
                    objupdate.Reason = "Data Not Submitted Please Try Again";
                }
            }
            catch (Exception ex)
            {
                objupdate.Status = 500;
                objupdate.Reason = ex.Message;
            }
            return(objupdate);
        }
Exemple #3
0
        public bool commentAdditionHelper(commentAddition obj)
        {
            OracleTransaction transaction;
            OracleCommand     cmd = new OracleCommand();

            try
            {
                string error_log = "{ 'IP_ADDRESS' : '" + HttpContext.Current.Request.UserHostAddress + "','DELETTION_TIME' : '" + DateTime.Now.ToString() + "' , 'DATA' : '" + JsonConvert.SerializeObject(obj) + "' }";
                string log_path  = HttpContext.Current.Server.MapPath("comment addition");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_ReportLog_Exception(log_path, error_log));

                ConnectionHelper _conHe = new ConnectionHelper();
                OracleConnection con    = new OracleConnection(_conHe.Congsws);

                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                // Start a local transaction
                transaction = con.BeginTransaction(IsolationLevel.ReadCommitted);

                try
                {
                    cmd = con.CreateCommand();

                    // Assign transaction object for a pending local transaction
                    cmd.Transaction = transaction;

                    cmd.CommandText = @"update gsws_report_issues set comp_status=:issue_status where report_id=:report_id";
                    cmd.Parameters.Add(":issue_status", OracleDbType.Varchar2).Value = obj.issue_status;
                    cmd.Parameters.Add(":report_id", OracleDbType.Varchar2).Value    = obj.report_id;
                    cmd.CommandType = CommandType.Text;

                    int i = cmd.ExecuteNonQuery();

                    cmd            = con.CreateCommand();
                    obj.comment_id = obj.report_id + DateTime.Now.ToString("yyyyMMddhhmmss");
                    obj.image_path = GetImagePath(obj.image, "IssuesComment", obj.report_id);

                    cmd.CommandText = @"insert into gsws_report_issues_cmts(REPORT_ID,COMMENTS,COMMENT_ID,LOGIN_USER,MSG_FLAG,IMAGE_PATH)values(:REPORT_ID,:COMMENTS,:COMMENT_ID,:LOGIN_USER,:MSG_FLAG,:IMAGE_PATH)";
                    cmd.Parameters.Add(":REPORT_ID", OracleDbType.Varchar2).Value      = obj.report_id;
                    cmd.Parameters.Add(":COMMENTS", OracleDbType.Varchar2, 2000).Value = obj.comment;
                    cmd.Parameters.Add(":COMMENT_ID", OracleDbType.Varchar2).Value     = obj.comment_id;
                    cmd.Parameters.Add(":LOGIN_USER", OracleDbType.Varchar2).Value     = obj.username;
                    cmd.Parameters.Add(":MSG_FLAG", OracleDbType.Varchar2).Value       = obj.message_flag ? 0 : 1;
                    cmd.Parameters.Add(":IMAGE_PATH", OracleDbType.Varchar2).Value     = obj.image_path;
                    cmd.CommandType = CommandType.Text;
                    i += cmd.ExecuteNonQuery();

                    transaction.Commit();
                    cmd.Dispose();

                    if (con.State == ConnectionState.Open)
                    {
                        con.Close();
                        con.Dispose();
                    }

                    if (i > 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    if (con != null)
                    {
                        if (con.State == ConnectionState.Open)
                        {
                            con.Close();
                            con.Dispose();
                        }
                    }
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                    throw ex;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }