public async Task <ModelResponseC2Message> AddDocMenuC2Async(ModelMenuC2 model) { var cultureInfo = new CultureInfo("en-GB"); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; ModelResponseC2Message resp = new ModelResponseC2Message(); try { using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); IList <ModelSelectOption> list_assign_seq = new List <ModelSelectOption>(); int assig_seq = 0; string sqlA = "SELECT board_code_array FROM Doc_MenuC1 WHERE project_number='" + model.projectnumber + "'"; using (SqlCommand cmdA = new SqlCommand(sqlA, conn)) { SqlDataReader reader = await cmdA.ExecuteReaderAsync(); if (reader.HasRows) { while (await reader.ReadAsync()) { list_assign_seq = JsonConvert.DeserializeObject <List <ModelSelectOption> >(reader["board_code_array"].ToString()); } if (list_assign_seq != null && list_assign_seq.Count > 0) { int seq = 1; foreach (var item in list_assign_seq) { if (item.value == model.assignercode) { assig_seq = seq; } seq++; } } } reader.Close(); } StringBuilder array_comment_date = new StringBuilder(); string sqlB = "SELECT committee_comment_date FROM Transaction_Document WHERE project_number='" + model.projectnumber + "'"; using (SqlCommand cmdB = new SqlCommand(sqlB, conn)) { SqlDataReader reader = await cmdB.ExecuteReaderAsync(); if (reader.HasRows) { while (await reader.ReadAsync()) { array_comment_date.AppendLine(reader["committee_comment_date"].ToString().Trim()); array_comment_date.AppendLine("คนที่ " + assig_seq.ToString() + ". " + DateTime.Now.ToString("dd/MM/yyyy")); } } reader.Close(); } using (SqlCommand cmd = new SqlCommand("sp_doc_menu_c2", conn)) { cmd.CommandType = CommandType.StoredProcedure; string assigner_code = Encoding.UTF8.GetString(Convert.FromBase64String(model.assignercode)); cmd.Parameters.Add("@assigner_code", SqlDbType.VarChar, 50).Value = ParseDataHelper.ConvertDBNull(assigner_code); cmd.Parameters.Add("@position_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.positionname); cmd.Parameters.Add("@assigner_seq", SqlDbType.Int).Value = ParseDataHelper.ConvertDBNull(model.assignerseq); cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 20).Value = ParseDataHelper.ConvertDBNull(model.projectnumber); cmd.Parameters.Add("@project_head_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectheadname); cmd.Parameters.Add("@faculty_name", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.facultyname); cmd.Parameters.Add("@project_name_thai", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectnamethai); cmd.Parameters.Add("@project_name_eng", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(model.projectnameeng); cmd.Parameters.Add("@safety_type", SqlDbType.VarChar, 2).Value = ParseDataHelper.ConvertDBNull(model.safetytype); cmd.Parameters.Add("@approval_type", SqlDbType.VarChar, 2).Value = ParseDataHelper.ConvertDBNull(model.approvaltype); cmd.Parameters.Add("@comment_consider", SqlDbType.VarChar).Value = ParseDataHelper.ConvertDBNull(model.commentconsider); cmd.Parameters.Add("@committee_comment_date", SqlDbType.VarChar, 200).Value = ParseDataHelper.ConvertDBNull(array_comment_date.ToString()); cmd.Parameters.Add("@round_of_meeting", SqlDbType.Int).Value = model.roundofmeeting; cmd.Parameters.Add("@year_of_meeting", SqlDbType.Int).Value = model.yearofmeeting; cmd.Parameters.Add("@create_by", SqlDbType.VarChar, 50).Value = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby)); SqlParameter rStatus = cmd.Parameters.Add("@rStatus", SqlDbType.Int); rStatus.Direction = ParameterDirection.Output; SqlParameter rMessage = cmd.Parameters.Add("@rMessage", SqlDbType.NVarChar, 500); rMessage.Direction = ParameterDirection.Output; SqlParameter rDocId = cmd.Parameters.Add("@rDocId", SqlDbType.Int); rDocId.Direction = ParameterDirection.Output; await cmd.ExecuteNonQueryAsync(); if ((int)cmd.Parameters["@rStatus"].Value > 0) { resp.Status = true; model_rpt_10_file rpt = await _IDocMenuReportRepository.GetReportR10Async((int)cmd.Parameters["@rDocId"].Value); resp.filename = rpt.filename; resp.filebase64 = rpt.filebase64; } else { resp.Message = (string)cmd.Parameters["@rMessage"].Value; } } conn.Close(); } } catch (Exception ex) { throw ex; } return(resp); }
public async Task <model_rpt_10_file> GetReportR10Async(int doc_id) { return(await _IDocMenReportRepository.GetReportR10Async(doc_id)); }