Exemplo n.º 1
0
        public async Task <ModelMenuA2> GetFileDownloadHome2Async(string project_number)
        {
            string sql = "SELECT B.project_key_number, A.filename1, A.filename2 " +
                         "FROM Doc_MenuA2 A INNER JOIN Doc_MenuB2 B " +
                         "ON A.doc_id = B.project_id " +
                         "WHERE B.project_key_number='" + project_number + "'";

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand command = new SqlCommand(sql, conn))
                {
                    SqlDataReader reader = await command.ExecuteReaderAsync();

                    if (reader.HasRows)
                    {
                        ModelMenuA2 e = new ModelMenuA2();
                        while (await reader.ReadAsync())
                        {
                            e.filename1 = reader["filename1"].ToString();
                            e.filename2 = reader["filename2"].ToString();
                        }
                        return(e);
                    }
                }
                conn.Close();
            }
            return(null);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddDocMenuA2([FromBody] ModelMenuA2 model)
        {
            var    requestUri = $"{_WebApiModel.BaseURL}/{"PrivateDocMenuA"}/{"AddDocMenuA2"}";
            string authHeader = HttpContext.Request?.Headers["Authorization"];

            if (authHeader != null && authHeader.StartsWith("Bearer"))
            {
                BearerToken = authHeader.Substring("Bearer ".Length).Trim();
            }
            var response = await HttpRequestFactory.Post(requestUri, BearerToken, model);

            switch (response.StatusCode)
            {
            case HttpStatusCode.Unauthorized:
                return(Unauthorized(response.ContentAsString()));

            case HttpStatusCode.BadRequest:
                return(BadRequest(response.ContentAsString()));

            case HttpStatusCode.OK:
                return(Ok(response.ContentAsString()));

            default:
                return(StatusCode(500));
            }
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddDocMenuA2([FromBody] ModelMenuA2 model)
        {
            ModelResponseA2Message e = await _IDocMenuAService.AddDocMenuA2Async(model);

            if (e.Status)
            {
                return(Ok(e));
            }
            else
            {
                return(BadRequest());
            }
        }
Exemplo n.º 4
0
        public async Task <ModelResponseA2Message> AddDocMenuA2Async(ModelMenuA2 model)
        {
            model.docdate   = DateTime.Now;
            model.filename1 = string.IsNullOrEmpty(model.filename1) ? "" : GenerateToken.GetGuid() + Path.GetExtension(model.filename1);
            model.filename2 = string.IsNullOrEmpty(model.filename2) ? "" : GenerateToken.GetGuid() + Path.GetExtension(model.filename2);

            var resp = await _IDocMenuA2Repository.AddDocMenuA2Async(model);

            if (resp.Status)
            {
                if (!string.IsNullOrEmpty(model.filename1base64))
                {
                    ServerDirectorys.SaveFileFromBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA2, model.filename1, model.filename1base64);
                }
                if (!string.IsNullOrEmpty(model.filename2base64))
                {
                    ServerDirectorys.SaveFileFromBase64(_IEnvironmentConfig.PathDocument, FolderDocument.menuA2, model.filename2, model.filename2base64);
                }
            }

            return(resp);
        }
Exemplo n.º 5
0
        public async Task <ModelResponseA2Message> AddDocMenuA2Async(ModelMenuA2 model)
        {
            var cultureInfo = new CultureInfo("en-GB");

            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            ModelResponseA2Message resp = new ModelResponseA2Message();

            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("sp_doc_menu_a2", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@DocDate", SqlDbType.DateTime).Value               = model.docdate.ToString("yyyy-MM-dd");
                    cmd.Parameters.Add("@ProjectMethod", SqlDbType.VarChar, 2).Value       = model.projectaccordingtypemethod;
                    cmd.Parameters.Add("@FacultyLaboratory", SqlDbType.VarChar, 200).Value = model.facultylaboratory;
                    cmd.Parameters.Add("@Department", SqlDbType.VarChar, 200).Value        = ParseDataHelper.ConvertDBNull(model.department);
                    cmd.Parameters.Add("@LaboratoryAddress", SqlDbType.VarChar).Value      = ParseDataHelper.ConvertDBNull(model.laboratoryaddress);
                    cmd.Parameters.Add("@Building", SqlDbType.VarChar, 100).Value          = ParseDataHelper.ConvertDBNull(model.building);
                    cmd.Parameters.Add("@Floor", SqlDbType.VarChar, 10).Value              = ParseDataHelper.ConvertDBNull(model.floor);
                    cmd.Parameters.Add("@RoomNumber", SqlDbType.VarChar, 10).Value         = ParseDataHelper.ConvertDBNull(model.roomnumber);
                    cmd.Parameters.Add("@LabOtherName", SqlDbType.VarChar, 10).Value       = ParseDataHelper.ConvertDBNull(model.labothername);
                    cmd.Parameters.Add("@Telephone", SqlDbType.VarChar, 20).Value          = ParseDataHelper.ConvertDBNull(model.telephone);
                    cmd.Parameters.Add("@ReponsiblePerson", SqlDbType.VarChar, 100).Value  = ParseDataHelper.ConvertDBNull(model.responsibleperson);
                    cmd.Parameters.Add("@Workphone", SqlDbType.VarChar, 20).Value          = ParseDataHelper.ConvertDBNull(model.workphone);
                    cmd.Parameters.Add("@Mobile", SqlDbType.VarChar, 20).Value             = ParseDataHelper.ConvertDBNull(model.mobile);
                    cmd.Parameters.Add("@FileName1", SqlDbType.VarChar, 200).Value         = ParseDataHelper.ConvertDBNull(model.filename1);
                    cmd.Parameters.Add("@FileName2", SqlDbType.VarChar, 200).Value         = ParseDataHelper.ConvertDBNull(model.filename2);
                    cmd.Parameters.Add("@create_by", SqlDbType.NVarChar).Value             = Encoding.UTF8.GetString(Convert.FromBase64String(model.createby));

                    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_17_file rpt = await _IDocMenuReportRepository.GetReportR17_18Async((int)cmd.Parameters["@rDocId"].Value);

                        resp.filename   = rpt.filename;
                        resp.filebase64 = rpt.filebase64;
                    }
                    else
                    {
                        resp.Message = (string)cmd.Parameters["@rMessage"].Value;
                    }
                }
                conn.Close();
            }
            return(resp);
        }