Esempio n. 1
0
 protected void loginBtn_Click(object sender, EventArgs e)
 {
     if (loginName.Text == "" || password.Text == "")
     {
     }
     else
     {
         ApiClass             apiClass = new ApiClass();
         string               url      = "http://api.traffiti.co/api/Author/AuthorLogin";
         string               json     = "{'authorLogin': '******', 'authorPassword': '******'}";
         string               result   = apiClass.PostCallApi(url, json);
         JavaScriptSerializer js       = new JavaScriptSerializer();
         Author               author   = js.Deserialize <Author>(result);
         if (!string.IsNullOrEmpty(author.access_key) && author.author_id > 0)
         {
             HttpCookie myCookie = new HttpCookie("AccessKey");
             //myCookie.Domain = "traffiti.co";
             myCookie.Value = author.access_key;
             //myCookie["accessKey"] = author.access_key;
             myCookie.Expires = DateTime.Now.AddMonths(1);
             Response.Cookies.Add(myCookie);
             Session["author_id"] = author.author_id;
             Response.Redirect("ProfilePage.aspx");
         }
     }
 }
Esempio n. 2
0
    public static string AddLike(int wall_id)
    {
        ApiClass apiClass = new ApiClass();
        string   url      = "http://api.traffiti.co/api/Wall/AddLike";
        string   json     = "{'wall_id': " + wall_id + "}";
        string   result   = apiClass.PostCallApi(url, json);

        return(result);
    }
Esempio n. 3
0
 private void GetCurrentUser()
 {
     if (Request.Cookies["AccessKey"] != null)
     {
         string               value    = Request.Cookies["AccessKey"].Value;
         ApiClass             apiClass = new ApiClass();
         string               url      = "http://api.traffiti.co/api/Author/AuthorLogin";
         string               json     = "{'accessKey': '" + value + "'}";
         string               result   = apiClass.PostCallApi(url, json);
         JavaScriptSerializer js       = new JavaScriptSerializer();
         author = js.Deserialize <Author>(result);
         GetSetting(author);
     }
 }
Esempio n. 4
0
    public void ShowCurrentTemp()
    {
        ApiClass             apiClass = new ApiClass();
        string               url      = "http://api.traffiti.co/api/Wall/GetTempPhoto";
        string               json     = "{'authorID': " + Session["author_id"] + "}";
        string               result   = apiClass.PostCallApi(url, json);
        JavaScriptSerializer js       = new JavaScriptSerializer();

        tempPhotoList = js.Deserialize <List <TempPhoto> >(result);

        for (int i = 0; i < tempPhotoList.Count; i++)
        {
            tempPhotoList[i].photo_path = ConfigurationSettings.AppSettings["imageDomain"] + tempPhotoList[i].photo_path;
        }

        tempImageRepeater.DataSource = tempPhotoList;
        tempImageRepeater.DataBind();
    }
Esempio n. 5
0
    public void LoadData()
    {
        ApiClass apiClass = new ApiClass();
        string   url      = "http://api.traffiti.co/api/Wall/GetWall";
        string   lang     = "2"; //default lang

        if (Request.Cookies["PresetLang"] != null)
        {
            lang = Request.Cookies["PresetLang"].Value;
        }
        string json                   = "{'pageNum': 1, 'lang_id': " + lang + "}";
        string result                 = apiClass.PostCallApi(url, json);
        JavaScriptSerializer js       = new JavaScriptSerializer();
        List <Wall>          wallList = js.Deserialize <List <Wall> >(result);

        wallRepeater.DataSource = wallList;
        wallRepeater.DataBind();
    }
Esempio n. 6
0
    public void uploadTemp()
    {
        if (imagesUploader.HasFile)
        {
            //client = new AmazonS3Client(Amazon.RegionEndpoint.APSoutheast1);

            HttpFileCollection uploadedFiles = Request.Files;
            for (int i = 0; i < uploadedFiles.Count; i++)
            {
                HttpPostedFile userPostedFile = uploadedFiles[i];
                try
                {
                    string fileName = userPostedFile.FileName;
                    string fileExt  = fileName.Substring(fileName.LastIndexOf(".") + 1, fileName.Length - (fileName.LastIndexOf(".") + 1));
                    if (userPostedFile.ContentLength > 0 && userPostedFile.ContentLength < 2048000 && (fileExt.ToLower() == "png" || fileExt.ToLower() == "jpeg" || fileExt.ToLower() == "jpg"))
                    {
                        byte[] fileData   = null;
                        Stream fileStream = null;
                        int    length     = 0;

                        length     = userPostedFile.ContentLength;
                        fileData   = new byte[length + 1];
                        fileStream = userPostedFile.InputStream;
                        fileStream.Read(fileData, 0, length);
                        MemoryStream stream = new MemoryStream(fileData);

                        UploadImageS3("client_temp/" + Session["author_id"] + "/" + fileName, stream);

                        ApiClass apiClass = new ApiClass();
                        string   url      = "http://api.traffiti.co/api/Wall/SaveTempPhoto";
                        string   json     = "{'authorID': " + Session["author_id"] + ", 'photoPath': '" + "client_temp/" + Session["author_id"] + "/" + fileName + "'}";
                        string   result   = apiClass.PostCallApi(url, json);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
    }
Esempio n. 7
0
    public void LoadData()
    {
        ApiClass             apiClass = new ApiClass();
        string               url      = "http://api.traffiti.co/api/Wall/GetWallDetail";
        string               json     = "{'wall_id': " + Request.QueryString["wall_id"] + ", 'lang_id': 1}";
        string               result   = apiClass.PostCallApi(url, json);
        JavaScriptSerializer js       = new JavaScriptSerializer();

        wallList = js.Deserialize <WallDetail>(result);
        StringBuilder sb = new StringBuilder();

        wallList.photoList.Remove("");

        for (int i = 0; i < wallList.photoList.Count; i++)
        {
            if (i == 0)
            {
                sb.AppendLine("<div class=\"carousel-item active\">");
            }
            else
            {
                sb.AppendLine("<div class=\"carousel-item\">");
            }
            sb.AppendLine("<img class=\"d-block img-fluid\" src=\"" + wallList.photoList[i] + "\" alt=\"" + wallList.photoList[i] + "\">");
            sb.AppendLine("</div>");
        }
        imageList = sb.ToString();

        for (int i = 0; i < wallList.contentList.Count; i++)
        {
            contentList += wallList.contentList[i] + "<br/>";
        }



        //imageRepeater.DataSource = wallList.photoList;
        //imageRepeater.DataBind();
    }
Esempio n. 8
0
 private void CheckAccessKey()
 {
     if (Request.Cookies["AccessKey"] != null)
     {
         string               value    = Request.Cookies["AccessKey"].Value;
         ApiClass             apiClass = new ApiClass();
         string               url      = "http://api.traffiti.co/api/Author/AuthorLogin";
         string               json     = "{'accessKey': '" + value + "'}";
         string               result   = apiClass.PostCallApi(url, json);
         JavaScriptSerializer js       = new JavaScriptSerializer();
         Author               author   = js.Deserialize <Author>(result);
         if (!string.IsNullOrEmpty(author.access_key) && author.author_id > 0)
         {
             HttpCookie myCookie = new HttpCookie("AccessKey");
             //myCookie.Domain = "traffiti.co";
             myCookie.Value = author.access_key;
             //myCookie["accessKey"] = author.access_key;
             myCookie.Expires = DateTime.Now.AddMonths(1);
             Response.Cookies.Add(myCookie);
             Session["author_id"] = author.author_id;
             Response.Redirect("ProfilePage.aspx");
         }
     }
 }
Esempio n. 9
0
    private void GetWall(int authorID, int page, int lang_id)
    {
        ApiClass             apiClass = new ApiClass();
        string               url      = "http://api.traffiti.co/api/Wall/GetProfileWallList";
        string               json     = "{'pageNum': " + page + ", 'lang_id': " + lang_id + ", 'authorID': " + authorID + "}";
        string               result   = apiClass.PostCallApi(url, json);
        JavaScriptSerializer js       = new JavaScriptSerializer();
        List <WallDetail>    wdList   = js.Deserialize <List <WallDetail> >(result);

        for (int i = 0; i < wdList.Count; i++)
        {
            for (int j = 0; j < wdList[i].photoList.Count; j++)
            {
                wdList[i].photos += "<div class=\"col\">";
                wdList[i].photos += "<a href = 'PostDetail.aspx?wall_id=" + wdList[i].wall_id + "'>";
                wdList[i].photos += "<img src=\" " + wdList[i].photoList[j] + "\" class=\"img-fluid\" alt=\"wall_item_cover\">";
                wdList[i].photos += "</a>";
                wdList[i].photos += "</div>";
            }
        }

        wallRepeater.DataSource = wdList;
        wallRepeater.DataBind();
    }
Esempio n. 10
0
    protected void postBtn_Click(object sender, EventArgs e)
    {
        try
        {
            if (Session["author_id"] == null)
            {
                content.Text = "Empty session";
            }
            else
            {
                ShowCurrentTemp();
                ApiClass         apiClass = new ApiClass();
                string           url      = "http://api.traffiti.co/api/Wall/CreateWall";
                ComingCreateWall ccw      = new ComingCreateWall();
                ccw.author_id = Convert.ToInt32(Session["author_id"]);
                if (!string.IsNullOrEmpty(hiddenLocation.Value))
                {
                    ccw.location = hiddenLocation.Value;
                }
                else
                {
                    ccw.location = "";
                }
                if (!string.IsNullOrEmpty(lat.Value))
                {
                    ccw.lat = lat.Value;
                }
                else
                {
                    ccw.lat = "";
                }
                if (!string.IsNullOrEmpty(lat.Value))
                {
                    ccw.lon = lon.Value;
                }
                else
                {
                    ccw.lon = "";
                }
                ccw.message   = content.Text;
                ccw.photoList = new List <string>();
                for (int i = 0; i < tempPhotoList.Count; i++)
                {
                    ccw.photoList.Add(tempPhotoList[i].photo_path);
                }
                ccw.publishList = new List <string>();
                JavaScriptSerializer js          = new JavaScriptSerializer();
                string           json            = js.Serialize(ccw);
                string           result          = apiClass.PostCallApi(url, json);
                ComingCreateWall afterCreateWall = js.Deserialize <ComingCreateWall>(result);


                for (int i = 0; i < tempPhotoList.Count; i++)
                {
                    //copy photo
                    WebClient    WC     = new WebClient();
                    MemoryStream stream = new MemoryStream(WC.DownloadData(tempPhotoList[i].photo_path));
                    UploadImageS3("client_upload/" + Session["author_id"] + "/" + afterCreateWall.publishList[i], stream);
                }
            }
            //Response.Redirect("Recently.aspx");
        }
        catch (Exception ex)
        {
            content.Text = ex.Message;
        }

        Response.Redirect("RecentlyList.aspx");
        //if (imagesUploader.HasFile)
        //{
        //    //client = new AmazonS3Client(Amazon.RegionEndpoint.APSoutheast1);

        //    HttpFileCollection uploadedFiles = Request.Files;
        //    for(int i = 0;i < uploadedFiles.Count;i++)
        //    {
        //        HttpPostedFile userPostedFile = uploadedFiles[i];
        //        try
        //        {
        //            string fileName = userPostedFile.FileName;
        //            string fileExt = fileName.Substring(fileName.LastIndexOf(".") + 1, fileName.Length - (fileName.LastIndexOf(".") + 1));
        //            if (userPostedFile.ContentLength > 0 && userPostedFile.ContentLength < 2048000 && (fileExt.ToLower() == "png" || fileExt.ToLower() == "jpeg" || fileExt.ToLower() == "jpg"))
        //            {
        //                byte[] fileData = null;
        //                Stream fileStream = null;
        //                int length = 0;

        //                length = userPostedFile.ContentLength;
        //                fileData = new byte[length + 1];
        //                fileStream = userPostedFile.InputStream;
        //                fileStream.Read(fileData, 0, length);
        //                MemoryStream stream = new MemoryStream(fileData);

        //                UploadImageS3("client_temp/" + Session["author_id"] + "/" + fileName, stream);
        //            }
        //        }
        //        catch (Exception ex)
        //        {

        //        }
        //    }
        //}
    }