コード例 #1
0
        public async Task <ActionResult <BaseResponse> > PostStageDetail(StageDetail stageDetail)
        {
            if (String.IsNullOrEmpty(stageDetail.StarTime) || String.IsNullOrEmpty(stageDetail.EndTime) || String.IsNullOrEmpty(stageDetail.Interview))
            {
                return(new BaseResponse
                {
                    ErrorCode = 0,
                    Messege = "Thêm mới thất bại!!"
                });
            }
            else
            {
                try
                {
                    _context.StageDetails.Add(stageDetail);
                    await _context.SaveChangesAsync();

                    return(new BaseResponse
                    {
                        ErrorCode = 1,
                        Messege = "Thêm mới thành công!!",
                        Data = CreatedAtAction("GetStageDetail", new { id = stageDetail.Id }, stageDetail)
                    });
                }
                catch (Exception ex)
                {
                    return(StatusCode(500, ex.Message));
                }
            }
        }
コード例 #2
0
        public async Task <ActionResult <BaseResponse> > PostStageDetail(StageDetail stageDetail)
        {
            var datas = _context.StageDetails.Where(x => x.Stage_ID.Equals(Convert.ToInt32(stageDetail.Stage_ID))).Where(y => y.Major_ID.Equals(Convert.ToInt32(stageDetail.Major_ID))).Where(z => z.Exam_ID.Equals(Convert.ToInt32(stageDetail.Exam_ID))).ToList();

            if (String.IsNullOrEmpty(stageDetail.StarTime) || String.IsNullOrEmpty(stageDetail.EndTime) || String.IsNullOrEmpty(stageDetail.Interview) || Convert.ToInt32(stageDetail.Stage_ID) == 0 || Convert.ToInt32(stageDetail.Major_ID) == 0 || Convert.ToInt32(stageDetail.Exam_ID) == 0)
            {
                return(new BaseResponse
                {
                    ErrorCode = 0,
                    Messege = "Not be emty!!"
                });
            }
            else if (datas.Count != 0)
            {
                return(new BaseResponse
                {
                    ErrorCode = 2,
                    Messege = "Stage Detail already exist!!"
                });
            }
            else
            {
                _context.StageDetails.Add(stageDetail);
                await _context.SaveChangesAsync();

                return(new BaseResponse
                {
                    ErrorCode = 1,
                    Messege = "Thêm mới thành công!!",
                    Data = CreatedAtAction("GetStageDetail", new { id = stageDetail.Id }, stageDetail)
                });
            }
        }
コード例 #3
0
        public async Task <ActionResult <BaseResponse> > PutStageDetail(int id, StageDetail stageDetail_update)
        {
            var datas  = _context.StageDetails.Where(x => x.Stage_ID.Equals(Convert.ToInt32(stageDetail_update.Stage_ID))).Where(y => y.Major_ID.Equals(Convert.ToInt32(stageDetail_update.Major_ID))).Where(z => z.Exam_ID.Equals(Convert.ToInt32(stageDetail_update.Exam_ID))).ToList();
            var StageD = await _context.StageDetails.FindAsync(id);

            if (StageD == null)
            {
                return(NotFound());
            }
            else if (String.IsNullOrEmpty(stageDetail_update.StarTime) || String.IsNullOrEmpty(stageDetail_update.EndTime) || String.IsNullOrEmpty(stageDetail_update.Interview) || Convert.ToInt32(stageDetail_update.Stage_ID) == 0 || Convert.ToInt32(stageDetail_update.Major_ID) == 0 || Convert.ToInt32(stageDetail_update.Exam_ID) == 0)
            {
                return(new BaseResponse
                {
                    ErrorCode = 0,
                    Messege = "Not be emty!!"
                });
            }
            else if (datas.Count != 0)
            {
                return(new BaseResponse
                {
                    ErrorCode = 2,
                    Messege = "Stage Detail already exist!!"
                });
            }
            else
            {
                StageD.Major_ID  = stageDetail_update.Major_ID;
                StageD.Stage_ID  = stageDetail_update.Stage_ID;
                StageD.Exam_ID   = stageDetail_update.Exam_ID;
                StageD.StarTime  = stageDetail_update.StarTime;
                StageD.EndTime   = stageDetail_update.EndTime;
                StageD.Interview = stageDetail_update.Interview;

                _context.StageDetails.Update(StageD);
                await _context.SaveChangesAsync();

                return(new BaseResponse
                {
                    ErrorCode = 1,
                    Messege = "Update thành công!!"
                });
            }
        }
コード例 #4
0
        public async Task <IActionResult> PutStageDetail(int id, StageDetail stageDetail_update)
        {
            var StageD = await _context.StageDetails.FindAsync(id);

            if (StageD == null)
            {
                return(NotFound());
            }

            StageD.Major_ID  = stageDetail_update.Major_ID;
            StageD.Stage_ID  = stageDetail_update.Stage_ID;
            StageD.Exam_ID   = stageDetail_update.Exam_ID;
            StageD.StarTime  = stageDetail_update.StarTime;
            StageD.EndTime   = stageDetail_update.EndTime;
            StageD.Interview = stageDetail_update.Interview;

            _context.StageDetails.Update(StageD);
            await _context.SaveChangesAsync();

            return(Ok(StageD));
        }
コード例 #5
0
        public async Task <IActionResult> UpdatingActivityDetail([FromBody] JsonElement id)
        {
            string DownloadDirectory = _configuration["Configuration:DownloadPath"].Replace("/", "\\");
            int    Status            = 0;
            string JournalName       = string.Empty;
            string filename          = string.Empty;
            var    responsedetail    = new Response();
            string sCaptureError     = "";
            var    fileDetail        = new FileDetail();

            // client.BaseAddress = new Uri(_configuration["Configuration:Uri"]);
            // client.DefaultRequestHeaders.Accept.Clear();
            // client.DefaultRequestHeaders.Accept.Add(
            //  new MediaTypeWithQualityHeaderValue("application/json"));
            // client.DefaultRequestHeaders.Add("clientid", _configuration["Configuration:ClientId"]);
            // client.DefaultRequestHeaders.Add("apikey", _configuration["Configuration:apiKey"]);
            var data = id.ToString();

            JObject jObject = JObject.Parse(data);
            string  value   = (string)jObject.SelectToken("id");
            var     ids     = "{\n\t\"ids\":[" + value + "]\n}".ToString();
            // var response = client.PostAsync(_configuration["Configuration:GetActivityFiles"], new StringContent(data, Encoding.UTF8, "application/json")).Result;

            var client  = new RestClient(_configuration["Configuration:LiveUri"] + _configuration["Configuration:GetActivityFiles"]);
            var request = new RestRequest(Method.POST);

            request.AddHeader("content-type", "application/json");
            request.AddHeader("clientid", _configuration["Configuration:ClientId"]);
            request.AddHeader("apikey", _configuration["Configuration:apiKey"]);
            request.AddParameter("application/json", data, ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            if (response.IsSuccessful)
            {
                responsedetail = JsonConvert.DeserializeObject <Response>(response.Content.ToString());
            }

            if (responsedetail.is_success)
            {
                //updating Status to Trn File Property Details
                Status      = responsedetail.data.Status;
                JournalName = responsedetail.data.JournalName;
                filename    = responsedetail.data.ArticleName;

                var bookdetails = _context.BookDetails.FirstOrDefault(x => x.bookName == JournalName);
                fileDetail = _context.FileDetails.FirstOrDefault(x => x.fileName == filename);

                try
                {
                    //  var fileDetail = await _context.FileDetails.FirstOrDefaultAsync(x => x.fileName == filename);
                    if (fileDetail == null)
                    {
                        return(StatusCode(200, new
                        {
                            is_success = false,
                            data = "",
                            message = string.Format("File Details Not exist for given Articlname {0} ", filename)
                        }));
                    }
                    else if (fileDetail != null)
                    {
                        var FileProplold = await _context.trnFilePropertyDetails.FirstOrDefaultAsync(x => x.fileId == fileDetail.fileID && x.bookId == bookdetails.bookId && x.id == 195);


                        if (FileProplold != null)
                        {
                            try
                            {
                                FileProplold.value = Status.ToString();
                                //  _context.Recorddetails.Attach(recordetailold);
                                //  _context.Entry(recordetailold).Property(x=>x.status & x.bookid &x.fileID).IsModified=true;
                                //  _context.SaveChanges();
                                _context.trnFilePropertyDetails.Update(FileProplold);

                                await _context.SaveChangesAsync();
                            }
                            catch (Exception ex)
                            {
                                return(StatusCode(200, new
                                {
                                    is_success = false,
                                    data = "",
                                    message = "Error in Updating FilePropertDetails Error Desc: " + ex.Message.ToString()
                                }));
                            }
                        }
                        else
                        {
                            var recordetail = new trnFilePropertyDetail
                            {
                                // id = 195, //Customer Category file Property
                                fileId = fileDetail.fileID,
                                bookId = bookdetails.bookId,
                                value  = Status.ToString()
                            };
                            try
                            {
                                await _context.AddAsync(recordetail);

                                await _context.SaveChangesAsync();
                            }
                            catch (Exception ex)
                            {
                                return(StatusCode(200, new
                                {
                                    is_success = false,
                                    data = "",
                                    message = "Error in Inserting FilePropertDetails  Error Desc: " + ex.Message.ToString()
                                }));
                            }
                        }
                    }


                    //For CustomerID IOPP from Iatuhor
                    if (responsedetail.data.CustomerId == Customers.IOPPCustomer)

                    {
                        if (responsedetail.data.WorkflowId == (int)WorkFlowIds.authorProofing2 && Status == 3)
                        {
                            //adding Activity and Stage Detail for abovedotne Workflow ID's Enabling HTML Download Acitivity in Copy Editing Stage
                            stageid    = (int)IOPPStages.fromAuthor;
                            activityid = (int)activities.HTMLDownload;
                        }
                        else
                        {
                            //adding Activity and Stage Detail for abovedotne Workflow ID's Enabling Pdf Creation Acitivity in Copy Editing Stage
                            stageid    = (int)IOPPStages.Copyediting;
                            activityid = (int)activities.IOPPHtmlToPDF;
                        }
                        try
                        {
                            if (fileDetail != null)
                            {
                                var recordetailold = await _context.Recorddetails37.FirstOrDefaultAsync(x => x.fileID == fileDetail.fileID && x.activityid == activityid);

                                if (recordetailold != null)
                                {
                                    try
                                    {
                                        if (recordetailold.status == 0)
                                        {
                                            recordetailold.status = 1;
                                            _context.Recorddetails37.Update(recordetailold);
                                            await _context.SaveChangesAsync();
                                        }
                                        else
                                        {
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        return(StatusCode(200, new
                                        {
                                            is_success = false,
                                            data = "",
                                            message = "Error in Updating Activity Details  Error Desc: " + ex.Message.ToString()
                                        }));
                                    }
                                }
                                else
                                {
                                    var recordetail = new Recorddetail37
                                    {
                                        fileID     = fileDetail.fileID,
                                        activityid = (Int16)activityid,
                                        stageId    = (Int16)stageid,
                                        bookid     = (Int16)fileDetail.bookid,
                                    };
                                    try
                                    {
                                        await _context.AddAsync(recordetail);

                                        await _context.SaveChangesAsync();
                                    }
                                    catch (Exception ex)
                                    {
                                        return(StatusCode(200, new
                                        {
                                            is_success = false,
                                            data = "",
                                            message = "Error in Inserting Activity Details  Error Desc: " + ex.Message.ToString()
                                        }));
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            return(StatusCode(200, new
                            {
                                is_success = false,
                                data = "",
                                message = ex.Message.ToString()
                            }));
                        }
                    }
                    //For CustomerID BMJ from Iatuhor
                    else if (responsedetail.data.CustomerId == Customers.BMJCustomer)
                    {
                        try
                        {
                            ActivityDetail activityDetail = new ActivityDetail();
                            StageDetail    StageDetail    = new StageDetail();
                            string         FileName       = Path.GetFileName(responsedetail.data.path.ToString());
                            DownloadDirectory = DownloadDirectory.Replace(";bookname;", responsedetail.data.JournalName.ToString());
                            String DownloadPath = DownloadDirectory + filename + "\\" + FileName;
                            int    WorkflowId   = responsedetail.data.WfdId;
                            string ArticleName  = responsedetail.data.ArticleName;
                            Status = responsedetail.data.Status;
                            string UriPath            = responsedetail.data.path.ToString();
                            bool   IsitrackStageAdded = false;
                            // string pdfName = Path.GetFileName(jobinputs.pdfPath);
                            // string xmlFName = Path.GetFileName(jobinputs.xmlPath);
                            // string appFName = Path.GetFileName(jobinputs.ApplicationPath);


                            // if (jobinputs.Wfdid == "23" || jobinputs.Wfdid == "24")
                            if (bmjworkflowids.Contains(WorkflowId))
                            {
                                if (bmjworkflowids.Contains(WorkflowId) && Status == 17)
                                {
                                    //adding Activity and Stage Detail for abovedotne Workflow ID's
                                    stageid    = (int)BMJStages.Revises1; //
                                    activityid = (int)activities.BMJXMLCorrection;
                                    //dynamically Create folder structure based on
                                    activityDetail = _context.ActivityDetails.FirstOrDefault(x => x.activityid == activityid);
                                    StageDetail    = _context.StageDetails.FirstOrDefault(x => x.stageid == stageid);
                                    DownloadPath   = DownloadPath.Replace(";stageDetail;", StageDetail.sfoldername);
                                    DownloadPath   = DownloadPath.Replace(";ActivityDetail;", activityDetail.folderName);

                                    IsitrackStageAdded = AddtoItrackStage(ArticleName, "", 128, 513, 3, 1, ref sCaptureError);
                                }
                                else if (bmjworkflowids.Contains(WorkflowId) && Status == 3)
                                {
                                    stageid    = (int)BMJStages.Preview;
                                    activityid = (int)activities.BMJOnlinePDFCreation;

                                    activityDetail = await _context.ActivityDetails.FirstAsync(x => x.activityid == activityid);

                                    StageDetail        = _context.StageDetails.FirstOrDefault(x => x.stageid == stageid);
                                    DownloadPath       = DownloadPath.Replace(";stageDetail;", StageDetail.sfoldername);
                                    DownloadPath       = DownloadPath.Replace(";ActivityDetail;", activityDetail.folderName);
                                    IsitrackStageAdded = AddtoItrackStage(ArticleName, "", 128, 513, 63, 1, ref sCaptureError);
                                }
                                else
                                {
                                    stageid        = (int)BMJStages.XMLValidation;
                                    activityid     = (int)activities.BMJXMLValidation;
                                    activityDetail = _context.ActivityDetails.FirstOrDefault(x => x.activityid == activityid);
                                    StageDetail    = _context.StageDetails.FirstOrDefault(x => x.stageid == stageid);
                                    DownloadPath   = DownloadPath.Replace(";stageDetail;", StageDetail.sfoldername);
                                    DownloadPath   = DownloadPath.Replace(";ActivityDetail;", activityDetail.folderName);
                                }

                                if (!string.IsNullOrEmpty(UriPath))
                                {
                                    if ((bmjworkflowids.Contains(WorkflowId)))
                                    {
                                        try
                                        {
                                            fileDetail = await _context.FileDetails.FirstOrDefaultAsync(x => x.fileName == filename);


                                            if (Decompress(DownloadPath, Path.GetDirectoryName(DownloadPath), UriPath, ref sCaptureError))
                                            {
                                                if (fileDetail != null)
                                                {
                                                    var recordetailold = await _context.Recorddetails.FirstOrDefaultAsync(x => x.fileID == fileDetail.fileID && x.activityid == activityid);


                                                    if (recordetailold != null)
                                                    {
                                                        try
                                                        {
                                                            if (recordetailold.status == 0)
                                                            {
                                                                recordetailold.status = 1;
                                                                //  _context.Recorddetails.Attach(recordetailold);
                                                                //  _context.Entry(recordetailold).Property(x=>x.status & x.bookid &x.fileID).IsModified=true;
                                                                //  _context.SaveChanges();
                                                                _context.Recorddetails.Update(recordetailold);

                                                                await _context.SaveChangesAsync();
                                                            }
                                                            else
                                                            {
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            return(StatusCode(200, new
                                                            {
                                                                is_success = false,
                                                                data = "",
                                                                message = "Error in Updating Activity Details Error Desc: " + ex.Message.ToString()
                                                            }));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        var recordetail = new Recorddetail
                                                        {
                                                            fileID     = fileDetail.fileID,
                                                            activityid = (Int16)activityid,
                                                            stageId    = (Int16)stageid,
                                                            bookid     = (Int16)fileDetail.bookid
                                                        };
                                                        try
                                                        {
                                                            await _context.AddAsync(recordetail);

                                                            await _context.SaveChangesAsync();
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            return(StatusCode(200, new
                                                            {
                                                                is_success = false,
                                                                data = "",
                                                                message = "Error in Inserting Activity Details  Error Desc: " + ex.Message.ToString()
                                                            }));
                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                return(StatusCode(200, new
                                                {
                                                    is_success = false,
                                                    data = "",
                                                    message = sCaptureError
                                                }));
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            return(StatusCode(200, new
                                            {
                                                is_success = false,
                                                data = "",
                                                message = ex.Message.ToString()
                                            }));
                                        }
                                    }
                                    else
                                    {
                                        return(StatusCode(200, new
                                        {
                                            is_success = false,
                                            data = "",
                                            message = ""
                                        }));
                                    }
                                }
                                else
                                {
                                    return(StatusCode(200, new
                                    {
                                        is_success = false,
                                        data = "",
                                        message = "File Path Should not be empty"
                                    }));
                                }
                            }
                            else
                            {
                                return(StatusCode(200, new
                                {
                                    is_success = false,
                                    data = "",
                                    message = " workflow id is not configured for id: " + WorkflowId
                                }));
                            }
                        }
                        catch (Exception ex)
                        {
                            return(StatusCode(200, new
                            {
                                is_success = false,
                                data = "",
                                message = ex.Message.ToString()
                            }));
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(StatusCode(200, new
                    {
                        is_success = false,
                        data = "",
                        message = ex.Message.ToString()
                    }));
                }

                var clientupdate  = new RestClient(_configuration["Configuration:Uri"] + _configuration["Configuration:GetActivityFiles"]);
                var requestupdate = new RestRequest(Method.POST);
                requestupdate.AddHeader("content-type", "application/json");
                requestupdate.AddHeader("clientid", _configuration["Configuration:ClientId"]);
                requestupdate.AddHeader("apikey", _configuration["Configuration:apiKey"]);
                requestupdate.AddParameter("application/json", ids, ParameterType.RequestBody);
                IRestResponse responsenew = client.Execute(request);

                if (responsenew.IsSuccessful)
                {
                    responsedetail = JsonConvert.DeserializeObject <Response>(response.Content.ToString());
                    if (responsedetail.is_success)
                    {
                        return(StatusCode(200, new
                        {
                            is_success = true,
                            data = "",
                            message = "Success"
                        }));
                    }
                    else
                    {
                        return(StatusCode(200, new
                        {
                            is_success = true,
                            data = "",
                            message = "Success"
                        }));
                    }
                }
                else
                {
                    return(StatusCode(200, new
                    {
                        is_success = false,
                        data = "",
                        message = "Error in Updating Status"
                    }));
                }
            }
            else
            {
                return(StatusCode(200, new
                {
                    is_success = false,
                    data = "",
                    message = "No Respond from IAuthor URL "
                }));
            }
        }