示例#1
0
        public ResponseModel<List<ClientTemplateResponse>> GetAllTemplateInformation(string username)
        {            
            var response = new ResponseModel<List<ClientTemplateResponse>>();
            var templateData = _db.CreateTemplateQuestionInfoes.OrderByDescending(x => x.creationTime).Where(x=>x.username == username).ToList();

            response.Status = 200;
            response.Message = "success";
            response.Payload = new List<ClientTemplateResponse>();
            try
            {
                foreach (var job in templateData)
                {
                    if ((job.type == Constants.type_dataEntry && job.subType == Constants.subType_Transcription) ||
                   (job.type == Constants.type_moderation && job.subType == Constants.subType_moderatingPhotos))
                    {
                        long JobCompleted = _db.UserMultipleJobMappings.Where(x => x.refKey == job.referenceId && x.status == Constants.status_done && x.isFirst == Constants.status_true).Count();
                        long JobAssigned = _db.UserMultipleJobMappings.Where(x => x.refKey == job.referenceId && x.status == Constants.status_assigned && x.isFirst == Constants.status_true).Count();
                        long JobReviewed = (JobCompleted > 1) ? (JobCompleted) / 2 : 0;  // currently hard coded.
                        if (JobCompleted > Convert.ToInt32(job.totalThreads))
                            JobCompleted = Convert.ToInt32(job.totalThreads);
                        var clientTemplate = new ClientTemplateResponse
                        {
                            title = job.title,
                            creationDate = job.creationTime.Split(' ')[0],
                            showTime = " 4 hours",
                            editId = job.Id.ToString(CultureInfo.InvariantCulture),
                            showEllipse = true,
                            timeShowType = "success",
                            progressPercent = Convert.ToString(System.Math.Ceiling(((JobCompleted) * 100 / Convert.ToDouble(job.totalThreads)) * 100) / 100),
                            JobCompleted = Convert.ToString(JobCompleted),
                            JobAssigned = Convert.ToString(JobAssigned),
                            JobTotal = job.totalThreads,
                            JobReviewed = Convert.ToString(JobReviewed),
                            type = job.type,
                            subType = job.subType,
                            verified = job.verified
                        };
                        response.Payload.Add(clientTemplate);
                    }
                    else
                    {
                        long JobCompleted = _db.UserJobMappings.Where(x => x.refKey == job.referenceId && x.status == Constants.status_done).Count();
                        long JobAssigned = _db.UserJobMappings.Where(x => x.refKey == job.referenceId && x.status == Constants.status_assigned).Count();
                        long JobReviewed = (JobCompleted > 1) ? (JobCompleted) / 2 : 0;  // currently hard coded.
                        if (JobCompleted > Convert.ToInt32(job.totalThreads))
                            JobCompleted = Convert.ToInt32(job.totalThreads);
                        var clientTemplate = new ClientTemplateResponse
                        {
                            title = job.title,
                            creationDate = job.creationTime.Split(' ')[0],
                            showTime = " 4 hours",
                            editId = job.Id.ToString(CultureInfo.InvariantCulture),
                            showEllipse = true,
                            timeShowType = "success",
                            progressPercent = Convert.ToString(System.Math.Ceiling(((JobCompleted) * 100 / Convert.ToDouble(job.totalThreads)) * 100) / 100),
                            JobCompleted = Convert.ToString(JobCompleted),
                            JobAssigned = Convert.ToString(JobAssigned),
                            JobTotal = job.totalThreads,
                            JobReviewed = Convert.ToString(JobReviewed),
                            type = job.type,
                            subType = job.subType,
                            verified = job.verified
                        };
                        response.Payload.Add(clientTemplate);
                    }
                    
                }

                var FacebookLikeTemplateData = _db.CreateTemplateFacebookLikes.OrderByDescending(x => x.creationTime).Where(x => x.username == username).ToList();
                if (FacebookLikeTemplateData != null)
                {
                    foreach (var facebookJob in FacebookLikeTemplateData)
                    {
                        //var clientFacebookLikeJobInfo = _db.CreateTemplateFacebookLikes.SingleOrDefault(x => x.Id == id && x.username == username);

                        long JobCompleted = _db.facebookPageLikeMappings.Where(x => x.refKey == facebookJob.referenceId).Count();
                        if (JobCompleted > Convert.ToInt32(facebookJob.totalThreads))
                            JobCompleted = Convert.ToInt32(facebookJob.totalThreads);

                        long JobAssigned = 0;
                        long JobReviewed = JobCompleted;
                        var clientTemplate = new ClientTemplateResponse
                        {
                            title = facebookJob.title,
                            creationDate = facebookJob.creationTime,
                            showTime = " 4 hours",
                            editId = facebookJob.Id.ToString(CultureInfo.InvariantCulture),
                            showEllipse = true,
                            timeShowType = "success",
                            progressPercent = Convert.ToString(System.Math.Ceiling(((JobCompleted) * 100 / Convert.ToDouble(facebookJob.totalThreads)) * 100) / 100),
                            JobCompleted = Convert.ToString(JobCompleted),
                            JobAssigned = Convert.ToString(JobAssigned),
                            JobTotal = facebookJob.totalThreads,
                            JobReviewed = Convert.ToString(JobReviewed),
                            type = facebookJob.type,
                            subType = facebookJob.subType,
                            verified = facebookJob.verified
                        };
                        response.Payload.Add(clientTemplate);                 
                    }
                }
                response.Payload = response.Payload.OrderByDescending(x => x.creationDate).ToList();
                return response;
            }
            catch (Exception)
            {
                response.Status = 500;//some error occured
                response.Message = "failed";
                return response;
            }
            
        }
示例#2
0
        public ResponseModel<List<ClientTemplateResponse>> GetAllTemplateInformation(string username)
        {
            var response = new ResponseModel<List<ClientTemplateResponse>>();
            var templateData = _db.CreateTemplateQuestionInfoes.OrderByDescending(x => x.creationTime).ToList();
            response.Status = 200;
            response.Message = "success";
            response.Payload = new List<ClientTemplateResponse>();
            try
            {
                foreach (var job in templateData)
                {
                    var clientTemplate = new ClientTemplateResponse
                    {
                        title = job.title,
                        creationDate = job.creationTime.Split(' ')[0],
                        showTime = " 4 hours",
                        editId = job.Id.ToString(CultureInfo.InvariantCulture),
                        showEllipse = true,
                        timeShowType = "success"
                    };
                    response.Payload.Add(clientTemplate);
                }

                return response;
            }
            catch (Exception)
            {
                response.Status = 500;//some error occured
                response.Message = "failed";
                return response;
            }
        }
示例#3
0
        public ResponseModel<ClientTemplateResponse> GetTemplateInformationByRefKey(string username,long id,string type,string subType)
        {
            var response = new ResponseModel<ClientTemplateResponse>();                              
            //var job = _db.CreateTemplateQuestionInfoes.SingleOrDefault(x => x.referenceId == clientJobInfo.referenceId && x.username == username);
            response.Status = 200;
            response.Message = "success";
            response.Payload = new ClientTemplateResponse();
            try
            {
                if (type == Constants.type_Ads && subType == Constants.subType_facebookLike)
                {
                    var clientFacebookLikeJobInfo = _db.CreateTemplateFacebookLikes.SingleOrDefault(x => x.Id == id && x.username == username);

                    long JobCompleted = _db.facebookPageLikeMappings.Where(x => x.refKey == clientFacebookLikeJobInfo.referenceId).Count();
                    if (JobCompleted > Convert.ToInt32(clientFacebookLikeJobInfo.totalThreads))
                        JobCompleted = Convert.ToInt32(clientFacebookLikeJobInfo.totalThreads);

                    long JobAssigned = 0;
                    long JobReviewed = JobCompleted;
                    
                    var clientTemplate = new ClientTemplateResponse
                    {
                        title = clientFacebookLikeJobInfo.title,
                        creationDate = clientFacebookLikeJobInfo.creationTime,
                        showTime = " 4 hours",
                        editId = clientFacebookLikeJobInfo.Id.ToString(CultureInfo.InvariantCulture),
                        showEllipse = true,
                        timeShowType = "success",
                        progressPercent = Convert.ToString(System.Math.Ceiling(((JobCompleted) * 100 / Convert.ToDouble(clientFacebookLikeJobInfo.totalThreads)) * 100) / 100),
                        JobCompleted = Convert.ToString(JobCompleted),
                        JobAssigned = Convert.ToString(JobAssigned),
                        JobTotal = Convert.ToString(clientFacebookLikeJobInfo.totalThreads),
                        JobReviewed = Convert.ToString(JobReviewed),
                        type = clientFacebookLikeJobInfo.type,
                        subType = clientFacebookLikeJobInfo.subType,
                        refKey = clientFacebookLikeJobInfo.referenceId,
                        verified = clientFacebookLikeJobInfo.verified
                    };
                    response.Payload = clientTemplate;                
                }
                else
                {
                    var clientJobInfo = _db.CreateTemplateQuestionInfoes.SingleOrDefault(x => x.Id == id && x.username == username);  

                    if ((clientJobInfo.type == Constants.type_dataEntry && clientJobInfo.subType == Constants.subType_Transcription) ||
                    (clientJobInfo.type == Constants.type_moderation && clientJobInfo.subType == Constants.subType_moderatingPhotos))
                    {
                        long JobCompleted = 0;
                        long JobAssigned = 0;
                        if (clientJobInfo.type == Constants.type_dataEntry &&
                            clientJobInfo.subType == Constants.subType_Transcription)
                        {
                            JobCompleted = _db.UserMultipleJobMappings.Where(x => x.refKey == clientJobInfo.referenceId && x.status == Constants.status_done).Count();
                            JobAssigned = _db.UserMultipleJobMappings.Where(x => x.refKey == clientJobInfo.referenceId && x.status == Constants.status_assigned).Count();
                        }
                        else
                        {
                            JobCompleted = _db.UserMultipleJobMappings.Where(x => x.refKey == clientJobInfo.referenceId && x.status == Constants.status_done && x.isFirst == Constants.status_true).Count();
                            JobAssigned = _db.UserMultipleJobMappings.Where(x => x.refKey == clientJobInfo.referenceId && x.status == Constants.status_assigned && x.isFirst == Constants.status_true).Count();
                        }
                        
                        long JobReviewed = (JobCompleted > 1) ? (JobCompleted) / 2 : 0;  // currently hard coded.

                        if (JobCompleted > Convert.ToInt32(clientJobInfo.totalThreads))
                            JobCompleted = Convert.ToInt32(clientJobInfo.totalThreads);

                        var clientTemplate = new ClientTemplateResponse
                        {
                            title = clientJobInfo.title,
                            creationDate = clientJobInfo.creationTime,
                            showTime = " 4 hours",
                            editId = clientJobInfo.Id.ToString(CultureInfo.InvariantCulture),
                            showEllipse = true,
                            timeShowType = "success",
                            progressPercent = Convert.ToString(System.Math.Ceiling(((JobCompleted) * 100 / Convert.ToDouble(clientJobInfo.totalThreads)) * 100) / 100),
                            JobCompleted = Convert.ToString(JobCompleted),
                            JobAssigned = Convert.ToString(JobAssigned),
                            JobTotal = Convert.ToString(clientJobInfo.totalThreads),
                            JobReviewed = Convert.ToString(JobReviewed),
                            type = clientJobInfo.type,
                            subType = clientJobInfo.subType,
                            refKey = clientJobInfo.referenceId,
                            verified = clientJobInfo.verified
                        };
                        response.Payload = clientTemplate;

                    }
                    else
                    {
                        long JobCompleted = _db.UserJobMappings.Where(x => x.refKey == clientJobInfo.referenceId && x.status == Constants.status_done).Count();
                        long JobAssigned = _db.UserJobMappings.Where(x => x.refKey == clientJobInfo.referenceId && x.status == Constants.status_assigned).Count();
                        long JobReviewed = (JobCompleted > 1) ? (JobCompleted) / 2 : 0;  // currently hard coded.

                        if (JobCompleted > Convert.ToInt32(clientJobInfo.totalThreads))
                            JobCompleted = Convert.ToInt32(clientJobInfo.totalThreads);

                        var clientTemplate = new ClientTemplateResponse
                        {
                            title = clientJobInfo.title,
                            creationDate = clientJobInfo.creationTime,
                            showTime = " 4 hours",
                            editId = clientJobInfo.Id.ToString(CultureInfo.InvariantCulture),
                            showEllipse = true,
                            timeShowType = "success",
                            progressPercent = Convert.ToString(System.Math.Ceiling(((JobCompleted) * 100 / Convert.ToDouble(clientJobInfo.totalThreads)) * 100) / 100),
                            JobCompleted = Convert.ToString(JobCompleted),
                            JobAssigned = Convert.ToString(JobAssigned),
                            JobTotal = Convert.ToString(clientJobInfo.totalThreads),
                            JobReviewed = Convert.ToString(JobReviewed),
                            type = clientJobInfo.type,
                            subType = clientJobInfo.subType,
                            verified = clientJobInfo.verified
                        };
                        response.Payload = clientTemplate;
                    }
                }
                                
                return response;
            }
            catch (Exception)
            {
                response.Status = 500;//some error occured
                response.Message = "failed";
                return response;
            }

        }