Ejemplo n.º 1
0
        public JsonResult setPublicationInfo(ClimaticPublication publication)
        {
            if (HttpContext.Request.IsAjaxRequest())
            {
                try
                {
                    //Traking
                    String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                    location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                    TrackLog(location, "Create Publication: " + "Source: " + publication.idPublication);

                    if (publication.img != null)
                    {
                        if (publication.idDisplayMode == 1)
                        {
                            String path = publication.tagType;
                            if (path == null)
                            {
                                return(null);
                            }
                            path = path.Split('/').Last();

                            if (path.ToString().Length > 4)
                            {
                                //If is FIle, store it in local server and return saved virtual path String to pass it to ppub Source
                                FileContext.SaveByteArrayAsImage(path, publication.img, "/img");
                                publication.tagType = "";
                                publication.img     = null;
                                //get the source attribute
                                Boolean res = ClimaticPublication.setPublicationInfo(publication);
                                return(Json(res, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else if (publication.idDisplayMode == 3)
                        {
                            //Youtube update source
                            publication.source = publication.img;
                            publication.img    = null;

                            Boolean res = ClimaticPublication.setPublicationInfo_Source(publication);
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            //Clean flags
                            Boolean res = ClimaticPublication.setPublicationInfo(publication);
                            return(Json(res, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        //get the source attribute
                        Boolean res = ClimaticPublication.setPublicationInfo(publication);
                        return(Json(res, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception ex)
                {
                    //SAVE LOG
                    //Log error
                    string userIpAddress = this.Request.UserHostAddress;

                    DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA");

                    return(null);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public JsonResult setInterviewPublicationInfo(ClimaticPublication publication)
        {
            if (HttpContext.Request.IsAjaxRequest())
            {
                //validate USER VAR
                try
                {
                    //Traking
                    String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
                    location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name;
                    TrackLog(location, "Update publication id: " + publication.idPublication);

                    //THE NEXT RULE JUST ALLOW  INTERVIEWS AND BIBLIOTECA TO UPLOAD CONTENT
                    if (publication.idPublication == 32)
                    {
                        String res = "";
                        //Upload file for Biblioteca
                        try
                        {
                            if (publication.img != null)
                            {
                                if (publication.idDisplayMode == 2)
                                {
                                    String path = publication.tagType;
                                    path = path.Split('/').Last();

                                    if (path.ToString().Length > 4)
                                    {
                                        //If is FIle, store it in local server and return saved virtual path String to pass it to ppub Source
                                        FileContext.SaveByteArrayAsImage(path, publication.img, "/Biblioteca");
                                        publication.tagType = "";
                                        publication.img     = null;
                                        publication.source  = path;

                                        //SAVE ICON in Original URL column
                                        String ext = Path.GetExtension(path);
                                        publication.OriginalURL = loadIcon(ext);

                                        //get the source attribute
                                        res = ClimaticPublication.setInterviewPublicationInfo(publication);
                                        return(Json(res, JsonRequestBehavior.AllowGet));
                                    }
                                }
                                else
                                {
                                    //UPDATE
                                    res = ClimaticPublication.setPublicationInfo(publication).ToString();
                                    return(Json(res, JsonRequestBehavior.AllowGet));
                                }
                            }
                            else
                            {
                                //if cannot upload full do nothing
                                return(null);
                            }
                        }
                        catch (Exception ex)
                        {
                            //SAVE LOG
                            //Log error
                            string userIpAddress = this.Request.UserHostAddress;

                            DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA");

                            return(null);
                        }
                    }
                    else if (publication.idPublication == 19 || publication.idPublication == 20)
                    {
                        //get the source attribute
                        String res = ClimaticPublication.setInterviewPublicationInfo(publication);
                        return(Json(res, JsonRequestBehavior.AllowGet));
                    }
                    return(null);
                }
                catch (Exception ex)
                {
                    //Log error
                    string userIpAddress = this.Request.UserHostAddress;

                    DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA");
                }
            }
            return(null);
        }