Example #1
0
        public ActionResult GetNewsletter(long id)
        {
            try
            {
                #region Logics
                SubmissionLogic _SubmissionLogic = new SubmissionLogic();
                #endregion

                if (Session["userId"] == null)
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                DynamicResponse <NewsletterLO> response = new DynamicResponse <NewsletterLO>();
                response = _SubmissionLogic.GetNewsLetter(id);
                if (response.HttpStatusCode != HttpStatusCode.OK)
                {
                    return(RedirectToAction("Index", "Oops"));
                }

                return(View(response.Data));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Oops"));
            }
        }
Example #2
0
        private void WriteResponse(HttpContext context, string id)
        {
            DynamicResponse response = null;

            if (!DynamicOperation.Responses.ContainsKey(id) || (response = DynamicOperation.Responses[id]) == null)
            {
                this.logger?.Log(EventType.OperationInformation, "Id '{0}' isn't set up yet!", id);

                throw new NotFoundException($"Unable to find response for given id: '{id}'.");
            }

            this.logger?.Log(EventType.OperationInformation, "Found reponse for id '{0}': '{1}'.", id, this.TrimString(JsonConvert.SerializeObject(response, Formatting.Indented)));

            /* Set status code */
            context.Response.StatusCode = response.StatusCode;

            /* Set headers */
            if (response.Headers != null)
            {
                foreach (DynamicResponse.Header header in response.Headers)
                {
                    context.Response.Headers.Add(header.Name, header.Value);
                }
            }

            /* Set body */
            if (!string.IsNullOrEmpty(response.Body))
            {
                context.Response.WriteContent(response.Body);
            }
        }
Example #3
0
        public XDocument generateXml(long submissionid)
        {
            DynamicResponse <SubmissionLO> submission = _HomeServices.GetArticle((long)submissionid);
            XDocument srcTree = new XDocument(
                new XComment("This is a comment"),
                new XElement("Root",
                             new XElement("Title", submission.Data.Title),
                             new XElement("SubTitle", submission.Data.SubTitle),
                             new XElement("Author", submission.Data.Author.FirstName + " " + submission.Data.Author.LastName),
                             new XElement("PublishDate", submission.Data.PublishDate.ToString()),
                             new XElement("ArticleType", submission.Data.Type),
                             new XElement("Category", submission.Data.Specialit)

                             ));
            //if (submission.Data.Tags.Count != 0) {

            //    srcTree.Add(new XElement("TagsInfo",
            //         submission.Data.Tags.Select(item =>
            //         new XElement("Tags",
            //         new XElement("FirstName", item.FirstName),
            //         new XElement("LastName", item.LastName)))));
            //}

            XDocument doc = new XDocument(
                new XComment("This is a comment"),
                new XElement("Root",
                             from el in srcTree.Element("Root").Elements()
                             select el
                             )
                );

            return(doc);
        }
        /// <summary>
        /// Use text analytics services and detect whether a review is positive or not positive and print out the result to the console
        /// </summary>
        static async Task Task1()
        {
            var request   = client.GetSentimentRequest();
            var documents = request.Body.SetEmptyArray("documents");

            int i = 0;

            foreach (string review in ReadReviewsFromJson().Take(10))
            {
                var document = documents.AddEmptyObject();
                document["id"]   = (++i).ToString();
                document["text"] = review;
            }

            DynamicResponse response = await request.SendAsync();

            if (response.Status == 200)
            {
                foreach (var document in response.Body["documents"].Items)
                {
                    Console.WriteLine($"{document["id"]} is {document["sentiment"]}");
                }
            }
            else
            {
                Console.Error.WriteLine(response.Body["error"]);
            }
        }
Example #5
0
        public JsonResult GetCitationForm(long id, long articleid)
        {
            try
            {
                if (id == 0)
                {
                    return(Json("error"));
                }
                CitationType data = new CitationType();

                data = _ContentServices.GetContentOfItem <CitationType>(ContentServices.ServiceTables.Citation, 1, id).Contents.FirstOrDefault();
                string        source    = data.Text;
                List <string> attrname  = source.EverythingBetween("[[[", "]]]");
                List <string> attrvalue = new List <string>();


                DynamicResponse <SubmissionLO> submission = _HomeServices.GetArticle((long)articleid);

                string value = "";
                var    t     = source;
                //StringBuilder s = StringBuilder(source);
                for (int i = 0; i < attrname.Count; i++)
                {
                    value  = Helper.GetPropValue <string>(submission.Data, attrname[i]);
                    source = source.Replace("[[[" + attrname [i] + "]]]", value);
                }

                return(Json(source));
            }
            catch (Exception ex)
            {
                return(Json("error"));
            }
        }
Example #6
0
        /// <summary>
        /// Use text analytics services and detect whether a review is positive or not positive and print out the result to the console
        /// </summary>
        static async Task Task1()
        {
            var request   = client.GetSentimentRequest();
            var documents = request.Body.SetEmptyArray("documents");

            int i = 0;

            foreach (string review in ReadReviewsFromJson().Take(10))
            {
                var document = documents.AddEmptyObjet();
                document["id"]   = (++i).ToString();
                document["text"] = review;
            }

            DynamicResponse response = await request.SendAsync();

            if (response.Status == 200)
            {
                foreach (var document in response.Body["documents"].Items)
                {
                    // NOTE(ellismg): There are quotes around these values in the output because ToString() JSON Serializes the value.
                    Console.WriteLine($"{document["id"]} is {document["sentiment"]}");
                }
            }
            else
            {
                Console.Error.WriteLine(response.Body["error"]);
            }
        }
Example #7
0
        private static void AssertResponse(DynamicResponse response)
        {
            response.Success.Should().BeTrue();
            object o = response.Body;

            o.Should().NotBeNull();

            var b = response.Body;

            object[] responses = b.responses;
            responses.Count().Should().Be(4);

            object r = b.responses[0];

            r.Should().NotBeNull();

            object shards = b.responses[0]._shards;

            shards.Should().NotBeNull();

            int totalShards = b.responses[0]._shards.total;

            totalShards.Should().BeGreaterThan(0);
//			JArray responses = r.responses;
//
//			responses.Count().Should().Be(4);
        }
        static void HandleBulkResponse(DynamicResponse response, List <string> payload)
        {
            int i     = 0;
            var items = response.Body["items"];

            if (items == null)
            {
                return;
            }
            foreach (dynamic item in items)
            {
                long?status = item.index?.status;
                i++;
                if (!status.HasValue || status < 300)
                {
                    continue;
                }

                var id    = item.index?._id;
                var error = item.index?.error;
                if (int.TryParse(id.Split('_')[0], out int index))
                {
                    SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.",
                                      status, error.ToString(),
                                      payload.ElementAt(index * 2 + 1));
                }
                else
                {
                    SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}.",
                                      status, error.ToString());
                }
            }
        }
Example #9
0
        /// <summary>
        ///  Detect Person entities that may have entries in the Wikipedia and print all associated hyperlinks to the console
        /// </summary>
        /// <returns></returns>
        static async Task Task3()
        {
            var request   = client.GetLinkedEntitiesRequest();
            var documents = request.Body.SetEmptyArray("documents");

            int i = 0;

            foreach (string review in ReadReviewsFromJson().Take(5))
            {
                var document = documents.AddEmptyObjet();
                document["id"]   = (++i).ToString();
                document["text"] = review;
            }

            DynamicResponse response = await request.SendAsync();

            if (response.Status == 200)
            {
                foreach (var document in response.Body["documents"].Items)
                {
                    foreach (var entity in document["entities"].Items)
                    {
                        // NOTE(ellismg): Would be nice if we overloaded == against a string here.
                        if ((string)entity["dataSource"] == "Wikipedia")
                        {
                            Console.WriteLine($"Learn more about {entity["text"]} on ${entity["dataSource"]} ({entity["url"]})");
                        }
                    }
                }
            }
            else
            {
                Console.Error.WriteLine(response.Body["error"]);
            }
        }
Example #10
0
        // GET: Dashboard
        public ActionResult Index()
        {
            #region Services
            ManagementService _ManagementService = new ManagementService();
            #endregion
            try
            {
                if (Session["userId"] == null)
                {
                    return(RedirectToAction("Index", "Admin"));
                }
                long userId = long.Parse(Session["userId"].ToString());
                DynamicResponse <UserQueueLO>          queue      = _ManagementService.GetQueue(userId, 1);
                DynamicResponse <List <SubmissionLO> > unassigned = _ManagementService.GetUnAssigned(userId);


                if (queue.HttpStatusCode != HttpStatusCode.OK)
                {
                    return(RedirectToAction("Index", "Oops"));
                }

                ViewBag.unassigned = unassigned.Data;
                ViewBag.queue      = queue.Data;
                return(View());
            }
            catch (Exception ex)
            {
                return(RedirectToAction(""));
            }
        }
Example #11
0
        public ActionResult ArticlesByIssueId(long IssueId)
        {
            DynamicResponse <List <SubmissionLO> > submission = new DynamicResponse <List <SubmissionLO> >();
            DynamicResponse <SelectLO>             options    = new DynamicResponse <SelectLO>();
            DynamicResponse <IssueLO> response = new DynamicResponse <IssueLO>();


            try
            {
                submission        = _HomeServices.ArticlesByIssueId((long)IssueId);
                ViewBag.articles  = submission.Data.OrderByDescending(e => DateTime.Parse(e.PublishDate.ToString())).ToList();
                response          = _HomeServices.GetIssueInfo((long)IssueId);
                ViewBag.issuedata = response.Data;

                if (submission.HttpStatusCode != HttpStatusCode.OK)
                {
                    return(RedirectToAction("Index", "Oops"));
                }
                return(View("Articles"));
            }


            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Oops"));
            }
        }
Example #12
0
 public ActionResult ArticleDetails(long id)
 {
     try
     {
         DynamicResponse <SubmissionLO> submission = _HomeServices.GetArticle((long)id);
         ViewBag.detail = submission.Data;
         if (submission.Data.MaxStars.Count != 0)
         {
             ViewBag.rating = (double)GetRating(submission.Data.MaxStars[0].nbstars, submission.Data.MaxStars[0].nbstars, submission.Data.MaxStars[0].nbstars, submission.Data.MaxStars[0].nbstars, submission.Data.MaxStars[0].nbstars);
         }
         List <CitationType> citation = new List <CitationType>();
         citation             = _ContentServices.GetContent <CitationType>(ContentServices.ServiceTables.Citation, 9999).Contents.ToList();
         ViewBag.CitationType = citation;
         DynamicResponse <SelectLO> options = new DynamicResponse <SelectLO>();
         options         = _HomeServices.GetOption();
         ViewBag.options = options.Data;
         DynamicResponse <List <SubmissionLO> > data = _HomeServices.GetRelatedIssues(id, 3);
         ViewBag.relatedissue = data.Data;
         UserLogic _UserLogic = new UserLogic();
         DynamicResponse <UserLO> response = new DynamicResponse <UserLO>();
         return(View("ArticleDetail"));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "Oops"));
     }
 }
        public void DynamicResponse_WhenCreated_CreateBody()
        {
            // Create a new response
            var response = new DynamicResponse("Test");

            // Check the result
            Assert.That(response.ResponseBody, Is.EqualTo("Test"));
        }
        private InvalidResult GetInvalidPayloadAsync(DynamicResponse baseResult, List <string> payload, out List <string> cleanPayload)
        {
            int i = 0;

            cleanPayload = new List <string>();
            var items = baseResult.Body["items"];

            if (items == null)
            {
                return(null);
            }
            List <string> badPayload = new List <string>();

            bool hasErrors = false;

            foreach (dynamic item in items)
            {
                var  itemIndex = item?[ElasticsearchSink.BulkAction(_elasticOpType)];
                long?status    = itemIndex?["status"];
                i++;
                if (!status.HasValue || status < 300)
                {
                    continue;
                }

                hasErrors = true;
                var id          = itemIndex?["_id"];
                var error       = itemIndex?["error"];
                var errorString = $"type: {error?["type"] ?? "Unknown"}, reason: {error?["reason"] ?? "Unknown"}";

                if (int.TryParse(id.Split('_')[0], out int index))
                {
                    SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.", status, errorString, payload.ElementAt(index * 2 + 1));
                    badPayload.Add(payload.ElementAt(index * 2));
                    badPayload.Add(payload.ElementAt(index * 2 + 1));
                    if (_cleanPayload != null)
                    {
                        cleanPayload.Add(payload.ElementAt(index * 2));
                        cleanPayload.Add(_cleanPayload(payload.ElementAt(index * 2 + 1), status, errorString));
                    }
                }
                else
                {
                    SelfLog.WriteLine($"Received failed ElasticSearch shipping result {status}: {errorString}.");
                }
            }

            if (!hasErrors)
            {
                return(null);
            }
            return(new InvalidResult()
            {
                StatusCode = baseResult.HttpStatusCode ?? 500,
                Content = baseResult.ToString(),
                BadPayLoad = String.Join(Environment.NewLine, badPayload)
            });
        }
Example #15
0
 public override object DeserializeObject(object value, Type type)
 {
     if (type == typeof(DynamicResponse))
     {
         var dict = base.DeserializeObject(value, typeof(Dictionary <string, object>)) as IDictionary <string, object>;
         return(dict == null ? null : DynamicResponse.Create(dict));
     }
     return(base.DeserializeObject(value, type));
 }
Example #16
0
        public ActionResult Footer()
        {
            try{
                List <long> ids = new List <long>();
                DynamicResponse <SelectLO>             options      = new DynamicResponse <SelectLO>();
                DynamicResponse <List <Options> >      articlestype = new DynamicResponse <List <Options> >();
                DynamicResponse <List <SubmissionLO> > response     = new DynamicResponse <List <SubmissionLO> >();

                options         = _HomeServices.GetOption();
                ViewBag.options = options.Data;
                Footer footer = _ContentServices.GetContent <Footer>(ContentServices.ServiceTables.Footer, 1).Contents.FirstOrDefault();
                ViewBag.footer = footer;
                string[] arr = footer.CategoryIds.Split(',');
                foreach (string id in (arr))
                {
                    ids.Add(long.Parse(id));
                }
                articlestype = _HomeServices.GetArticlesType(ids);
                if (articlestype.HttpStatusCode != HttpStatusCode.OK)
                {
                    return(RedirectToAction("Index", "Oops"));
                }
                ViewBag.articlestype = articlestype.Data;
                arr = footer.RecentArticleIds.Split(',');
                foreach (string id in (arr))
                {
                    ids.Add(long.Parse(id));
                }
                response = _HomeServices.GetArticles(ids);
                if (response.HttpStatusCode != HttpStatusCode.OK)
                {
                    return(RedirectToAction("Index", "Oops"));
                }
                ViewBag.Issues  = response.Data;
                arr             = footer.ContactIds.Split(',');
                ViewBag.contact = arr;
                var html = new StringBuilder("");

                Contact contact = _ContentServices.GetContent <Contact>(ContentServices.ServiceTables.Contact, 1).Contents.FirstOrDefault();
                for (int i = 0; i < arr.Length; i++)
                {
                    html.Append("<strong>" + arr[i].Trim() + "</strong>: " + Helper.GetPropValue <string>(contact, arr[i].Trim()) + "<br/>");
                }
                ViewBag.contactdata = html;
                ViewBag.contact     = contact;
                List <FooterMenu> footerlinks = _ContentServices.GetContent <FooterMenu>(ContentServices.ServiceTables.FooterMenu, 9999).Contents.ToList();
                ViewBag.footerlinks = footerlinks;

                return(PartialView("_PartialViewFooter", new ViewDataDictionary {
                    new KeyValuePair <string, object>("footer", ViewBag.footer), new KeyValuePair <string, object>("footerlinks", ViewBag.footerlinks), new KeyValuePair <string, object>("contactdata", ViewBag.contactdata), new KeyValuePair <string, object>("contact", ViewBag.contact), new KeyValuePair <string, object>("options", ViewBag.options), new KeyValuePair <string, object>("articlestype", ViewBag.articlestype), new KeyValuePair <string, object>("Issues", ViewBag.Issues)
                }));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Oops"));
            }
        }
        /// <summary>
        /// Method for reading all the meta information from the documents within product type within the specified branch
        /// and return a list of the string ids of those documents
        /// </summary>
        /// <param name="branchId"></param>
        /// <returns></returns>
        public List <string> ReadListOfProductsByBranch(string branchId)
        {
            int elasticSearchCursor = 0;

            string json = JsonConvert.SerializeObject(BuildBranchMetaQuery(Configuration.ElasticSearchBatchSize));

            string scroll = "1m"; //the scroll api is used to read a large dataset, this is the scroll name

            var request = new RestRequest(string.Format("{0}/product/_search?scroll={1}", branchId, scroll), Method.POST);

            request.AddParameter("application/json", json, ParameterType.RequestBody);
            var             res = client.Execute(request);
            DynamicResponse dd  = JsonConvert.DeserializeObject <DynamicResponse>(res.Content);

            int totalproducts = dd["hits"]["total"];

            string scrollid = dd["_scroll_id"]; //this scroll id is read in the first time and then is passed into subsequent calls

            dynamic Ids = dd["hits"]["hits"];

            List <string> existing = new List <string>();

            foreach (var Id in Ids)
            {
                existing.Add(Id._id.ToString());
            }

            elasticSearchCursor += Configuration.ElasticSearchBatchSize;

            while (elasticSearchCursor < totalproducts)
            {
                json = JsonConvert.SerializeObject(BuildScrollQuery(scroll, scrollid));

                request = new RestRequest("_search/scroll", Method.POST);
                request.AddParameter("application/json", json, ParameterType.RequestBody);
                res = client.Execute(request);
                dd  = JsonConvert.DeserializeObject <DynamicResponse>(res.Content);

                Ids = dd["hits"]["hits"];

                if (Ids != null)
                {
                    foreach (var Id in Ids)
                    {
                        if (Id != null && Id._id != null && existing.Contains(Id._id.ToString()) == false)
                        {
                            existing.Add(Id._id.ToString());
                        }
                    }
                }

                elasticSearchCursor += Configuration.ElasticSearchBatchSize;
            }

            return(existing);
        }
Example #18
0
        private InvalidResult GetInvalidPayloadAsync(DynamicResponse baseResult, List <string> payload, out List <string> cleanPayload)
        {
            int i = 0;

            cleanPayload = new List <string>();
            var items = baseResult.Body["items"];

            if (items == null)
            {
                return(null);
            }
            List <string> badPayload = new List <string>();

            bool hasErrors = false;

            foreach (dynamic item in items)
            {
                long?status = item.index?.status;
                i++;
                if (!status.HasValue || status < 300)
                {
                    continue;
                }

                hasErrors = true;
                var id    = item.index?._id;
                var error = item.index?.error;
                if (int.TryParse(id.Split('_')[0], out int index))
                {
                    SelfLog.WriteLine("Received failed ElasticSearch shipping result {0}: {1}. Failed payload : {2}.", status, error?.ToString(), payload.ElementAt(index * 2 + 1));
                    badPayload.Add(payload.ElementAt(index * 2));
                    badPayload.Add(payload.ElementAt(index * 2 + 1));
                    if (_cleanPayload != null)
                    {
                        cleanPayload.Add(payload.ElementAt(index * 2));
                        cleanPayload.Add(_cleanPayload(payload.ElementAt(index * 2 + 1), status, error?.ToString()));
                    }
                }
                else
                {
                    SelfLog.WriteLine($"Received failed ElasticSearch shipping result {status}: {error?.ToString()}.");
                }
            }

            if (!hasErrors)
            {
                return(null);
            }
            return(new InvalidResult()
            {
                StatusCode = baseResult.HttpStatusCode ?? 500,
                Content = baseResult.ToString(),
                BadPayLoad = String.Join(Environment.NewLine, badPayload)
            });
        }
Example #19
0
        public DynamicResponse <Process> GetLastProcessForSubmission(long submissionId)
        {
            #region Accessors
            SubmissionInProcessAccessor _SubmissionInProcessAccessor = new SubmissionInProcessAccessor();
            ProcessAccessor             _ProcessAccessor             = new ProcessAccessor();
            #endregion
            DynamicResponse <Process> response = new DynamicResponse <Process>();
            try
            {
                //get the last submission in process
                SubmissionInProcess submissionInProcess = _SubmissionInProcessAccessor.GetLast(submissionId);

                Process process = new Process();

                //if null, not assigned
                if (submissionInProcess == null)
                {
                    //get process of not assigned
                    process = _ProcessAccessor.Get(ProcessCodes.unassigned.ToString());
                }
                //else get the process
                else
                {
                    //get process by the id
                    process = _ProcessAccessor.Get((long)submissionInProcess.ProcessId);
                }

                if (process == null)
                {
                    //return error
                    response.HttpStatusCode = HttpStatusCode.InternalServerError;
                    response.Message        = "Please try again later.";
                    response.ServerMessage  = "Process in empty";

                    return(response);
                }
                else
                {
                    //return response with displayed name of the process
                    response.HttpStatusCode = HttpStatusCode.OK;
                    response.Data           = process;

                    return(response);
                }
            }
            catch (Exception ex)
            {
                //return error
                response.HttpStatusCode = HttpStatusCode.InternalServerError;
                response.Message        = "Please try again later.";
                response.ServerMessage  = ex.Message;

                return(response);
            }
        }
Example #20
0
        private DynamicResponse <List <DiscussionParticipantsLO> > GetDiscussionParticipants(long discussionId)
        {
            #region Accessors
            DiscussionParticipantAccessor _DiscussionParticipantAccessor = new DiscussionParticipantAccessor();
            UserAccessor _UserAccessor = new UserAccessor();
            #endregion
            DynamicResponse <List <DiscussionParticipantsLO> > response = new DynamicResponse <List <DiscussionParticipantsLO> >();
            try
            {
                List <DiscussionParticipant> participantsModel = new List <DiscussionParticipant>();
                participantsModel = _DiscussionParticipantAccessor.GetList(discussionId);

                List <DiscussionParticipantsLO> data = new List <DiscussionParticipantsLO>();

                //get user for each useid in the discussion participants
                User user = new User();
                foreach (DiscussionParticipant item in participantsModel)
                {
                    user = new User();
                    user = _UserAccessor.Get(item.UserId);

                    if (user == null)
                    {
                        response.HttpStatusCode = HttpStatusCode.InternalServerError;
                        response.Message        = "Please try again later";
                        response.ServerMessage  = "no participant";

                        return(response);
                    }

                    data.Add(new DiscussionParticipantsLO {
                        Email     = user.Email,
                        FirstName = user.FirstName,
                        LastName  = user.LastName
                    });
                }

                response.Data           = data;
                response.HttpStatusCode = HttpStatusCode.OK;

                return(response);
            }
            catch (Exception ex)
            {
                response.HttpStatusCode = HttpStatusCode.InternalServerError;
                response.Message        = "Please try again later.";
                response.ServerMessage  = ex.Message;

                return(response);
            }
        }
Example #21
0
        public ActionResult AddSubmissionFiles(SubmissionFilesLO files, long submissionid)
        {
            #region Logics
            SubmissionLogic _SubmissionLogic = new SubmissionLogic();
            #endregion
            DynamicResponse <SubmissionLO> response = new DynamicResponse <SubmissionLO>();
            long userId = long.Parse(Session["userId"].ToString());
            try
            {
                string path = Server.MapPath("~/files/");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                List <SubmissionFilesLO> filesupload = new List <SubmissionFilesLO>();

                if (files.FilesToUpload.Length != 0)
                {
                    FileTypeLogic _FileTypeLogic = new FileTypeLogic();
                    filesupload = new List <SubmissionFilesLO>();

                    for (int i = 0; i < files.TypesId.Length; i++)
                    {
                        string extension = Path.GetExtension(files.FilesToUpload[i].FileName);
                        string Name      = Path.GetFileNameWithoutExtension(files.FilesToUpload[i].FileName);
                        string newName   = Name + DateTime.Now.ToString("yyyyMMddHHmmss") + extension;
                        files.FilesToUpload[i].SaveAs(path + newName);

                        filesupload.Add(new SubmissionFilesLO
                        {
                            Name     = newName,
                            TypeId   = (long)files.TypesId[i],
                            TypeName = _FileTypeLogic.GetFileType((long)files.TypesId[i])
                        });
                    }
                }


                response = _SubmissionLogic.AddSubmissionFiles(filesupload, files.submissionid, userId, files.attr);
                if (response.HttpStatusCode != HttpStatusCode.OK)
                {
                    return(RedirectToAction("Index", "Oops"));
                }

                return(RedirectToAction("index", new { id = submissionid }));
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Oops"));
            }
        }
Example #22
0
        public ActionResult Index()
        {
            DynamicResponse <SelectLO> options = new DynamicResponse <SelectLO>();

            options         = _HomeServices.GetOption();
            ViewBag.options = options.Data;
            Hero_Banner banner = _ContentServices.GetContent <Hero_Banner>(ContentServices.ServiceTables.Hero_Banner, 1).Contents.FirstOrDefault();

            ViewBag.Banner = banner;
            DynamicResponse <List <SubmissionLO> > response = _HomeServices.GetSubmissionLatestArticles(3);

            if (response.HttpStatusCode != HttpStatusCode.OK)
            {
                return(RedirectToAction("Index", "Oops"));
            }
            ViewBag.latestarticles = response.Data;
            DynamicResponse <IssueLO> latestissues = _HomeServices.GetLatestIssues();

            if (latestissues.HttpStatusCode != HttpStatusCode.OK)
            {
                return(RedirectToAction("Index", "Oops"));
            }
            ViewBag.latestIssues = latestissues.Data;
            DynamicResponse <List <IssueLO> > allissues = _HomeServices.GetAllIssues();

            if (allissues.HttpStatusCode != HttpStatusCode.OK)
            {
                return(RedirectToAction("Index", "Oops"));
            }
            ViewBag.allissues = allissues.Data.OrderByDescending(e => e.Date).ToList();;
            IssueFilter issuefilter = new IssueFilter();

            issuefilter         = _ContentServices.GetContent <IssueFilter>(ContentServices.ServiceTables.IssueFilter, 1).Contents.FirstOrDefault();
            ViewBag.issuefilter = issuefilter;
            List <Events> ourevents = _ContentServices.GetContent <Events>(ContentServices.ServiceTables.Events, 3).Contents.ToList();

            ourevents      = ourevents.OrderBy(e => DateTime.Parse(e.EventDate)).ToList();
            ViewBag.Events = ourevents;
            List <Videos> ourvideos = _ContentServices.GetContent <Videos>(ContentServices.ServiceTables.Videos, 4).Contents.ToList();

            ourvideos      = ourvideos.OrderBy(e => DateTime.ParseExact(e.VideoDate, "dd-MM-yyyy", CultureInfo.InvariantCulture)).ToList();
            ViewBag.Videos = ourvideos;
            DynamicResponse <List <SubmissionLO> > submission = _HomeServices.GetAllArticles();

            if (submission.HttpStatusCode != HttpStatusCode.OK)
            {
                return(RedirectToAction("Index", "Oops"));
            }
            ViewBag.articles = submission.Data;
            return(View(options));
        }
Example #23
0
        public JsonResult AddReviewByUser(ReviewLO toAdd)
        {
            try
            {
                DynamicResponse <long> response = _HomeServices.AddReviewByUser(toAdd);

                return(Json(response, JsonRequestBehavior.AllowGet));
            }


            catch (Exception ex)
            {
                return(Json("error"));
            }
        }
        private static void AssertOnResponse(DynamicResponse response)
        {
            response.Get <string>("object.first")
            .Should()
            .NotBeEmpty()
            .And.Be("value1");

            response.Get <string>("object._arbitrary_key_")
            .Should()
            .NotBeEmpty()
            .And.Be("first");

            response.Get <int>("array.1").Should().Be(2);
            response.Get <long>("array.1").Should().Be(2);
            response.Get <long>("number").Should().Be(29);
            response.Get <long?>("number").Should().Be(29);
            response.Get <long?>("number_does_not_exist").Should().Be(null);
            response.Get <long?>("number").Should().Be(29);

            response.Get <string>("array_of_objects.1.second")
            .Should()
            .NotBeEmpty()
            .And.Be("value22");

            response.Get <string>("array_of_objects.1.complex\\.nested.x")
            .Should()
            .NotBeEmpty()
            .And.Be("value6");

            /**
             * You can project into arrays using the dot notation
             */
            response.Get <string[]>("array_of_objects.first")
            .Should()
            .NotBeEmpty()
            .And.HaveCount(2)
            .And.BeEquivalentTo(new[] { "value11", "value21" });

            /**
             * You can even peek into array of arrays
             */
            var nestedZs = response.Get <int[][]>("array_of_objects.nested.z.id")
                           //.SelectMany(d=>d.Get<int[]>("id"))
                           .Should()
                           .NotBeEmpty()
                           .And.HaveCount(2)
                           .And.BeEquivalentTo(new[] { new[] { 1 }, new[] { 3, 2 } });
        }
Example #25
0
        public DynamicResponse <List <DiscussionLO> > GetListOfBasicDiscussionsForSubmission(long submissionId, bool isPrereview, bool isReview, bool isCopyEditing, bool isProofReading)
        {
            DynamicResponse <List <DiscussionLO> > response = new DynamicResponse <List <DiscussionLO> >();

            #region Accessors
            DiscussionAccessor _DiscussionAccessor = new DiscussionAccessor();
            #endregion

            List <DiscussionLO> data = new List <DiscussionLO>();
            try
            {
                //get list of discussion
                List <Discussion> disucssionsModel = _DiscussionAccessor.GetList(submissionId, isPrereview, isReview, isCopyEditing, isProofReading);

                //use GetBasicInfo for each discussion
                DynamicResponse <DiscussionLO> discussionLO = new DynamicResponse <DiscussionLO>();
                foreach (Discussion item in disucssionsModel)
                {
                    if (item.ChannelId == null)
                    {
                        discussionLO = new DynamicResponse <DiscussionLO>();

                        discussionLO = GetBasicInfo(item);

                        if (discussionLO.HttpStatusCode != HttpStatusCode.OK)
                        {
                            response.HttpStatusCode = HttpStatusCode.InternalServerError;
                            response.Message        = "Please try again later.";
                            response.ServerMessage  = "no discussion reply";

                            return(response);
                        }

                        data.Add(discussionLO.Data);
                    }
                }

                response.HttpStatusCode = HttpStatusCode.OK;
                response.Data           = data;

                return(response);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #26
0
        public JsonResult NewsLetter()
        {
            #region Logics
            SubmissionLogic _SubmissionLogic = new SubmissionLogic();
            #endregion

            try
            {
                DynamicResponse <List <NewsletterLO> > response = new DynamicResponse <List <NewsletterLO> >();
                response = _SubmissionLogic.GetNewsLetter();
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #27
0
        public JsonResult GetParticipant(long submissionid)
        {
            #region Logic
            UserLogic _UserLogic = new UserLogic();
            #endregion

            DynamicResponse <List <UserLO> > response = new DynamicResponse <List <UserLO> >();
            try
            {
                response = _UserLogic.GetParticipant(submissionid);
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("error"));
            }
        }
Example #28
0
        public JsonResult GetAcceptanceFiles(long submissionid, bool isAcceptedforReview, bool isAcceptedforCopyEditing, bool isAcceptedforProduction)
        {
            #region Logic
            SubmissionLogic _SubmissionLogic = new SubmissionLogic();
            #endregion

            DynamicResponse <List <SubmissionFilesLO> > response = new DynamicResponse <List <SubmissionFilesLO> >();
            try
            {
                response = _SubmissionLogic.GetAcceptanceFiles(submissionid, isAcceptedforReview, isAcceptedforCopyEditing, isAcceptedforProduction);
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("error"));
            }
        }
Example #29
0
        public JsonResult GetFiles(long submissionid, bool isSubmission, bool isRevision, bool isCopyEdited)
        {
            #region Logic
            SubmissionLogic _SubmissionLogic = new SubmissionLogic();
            #endregion

            DynamicResponse <List <SubmissionFilesLO> > response = new DynamicResponse <List <SubmissionFilesLO> >();
            try
            {
                response = _SubmissionLogic.GetFiles(submissionid, isSubmission, isRevision, isCopyEdited);
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json("error"));
            }
        }
Example #30
0
        public JsonResult GetDiscussionDetail(long discussionId)
        {
            #region Logics
            DiscussionLogic _DiscussionLogic = new DiscussionLogic();
            #endregion

            try
            {
                DynamicResponse <DiscussionLO> response = new DynamicResponse <DiscussionLO>();
                response = _DiscussionLogic.GetWholeDiscussion(discussionId);
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw;
            }
        }