Ejemplo n.º 1
0
        public async Task <ArtworkItemUploadOutputDto> CreateArtworkItem(ArtworkItemCreateInputDto inputDto)
        {
            var artworkItem = new ArtworkItem
            {
                LocalName  = inputDto.LocalName,
                Md5        = inputDto.Md5,
                RelatedUrl = inputDto.RelatedUrl,
                Seq        = 0,
            };

            var result = await _artworkItems.InsertAsync(artworkItem);

            if (result != default)
            {
                return(new ArtworkItemUploadOutputDto
                {
                    Id = result.Id,
                    Md5 = result.Md5,
                    LocalName = result.LocalName,
                    RelatedUrl = result.RelatedUrl,
                    AbsoluteUrl = CombineDomainToRelatedUri(result.RelatedUrl)
                });
            }
            else
            {
                throw new Exception("failed to create artwork item");
            }
        }
Ejemplo n.º 2
0
        private void Load(string grabstring, string siteUrl)
        {
            if (ArtworkList == null) ArtworkList = new List<ArtworkItem>();
              ArtworkList.Clear();
              var sepElements = new string[] { "," };
              string[] elements = grabstring.Split(sepElements, StringSplitOptions.RemoveEmptyEntries);
              int count = 0;
              foreach (string s in elements)
              {
            count += 1;
            var item = new ArtworkItem();

            if (s.Contains("("))
            {
              item.Url = s.Substring(0, s.IndexOf("(")).Trim(new Char[] { '(', ')' }).Trim();
              item.Name = s.Substring(s.IndexOf("(")).Trim(new Char[] { '(', ')' }).Trim();
            }
            else
            {
              item.Url = s.Trim();
              item.Name = "";
            }
            if (!item.Url.StartsWith("http"))
            {
              if (siteUrl.EndsWith(@"/")) siteUrl = siteUrl.TrimEnd(new Char[] { '/' });
              item.Url = item.Url.StartsWith(@"/") ? siteUrl + item.Url : siteUrl + @"/" + item.Url;
            }

            if (string.IsNullOrEmpty(item.Name))
              item.Name = "Image #" + count + "'";
            ArtworkList.Add(item);
              }
        }
    public GameObject prefab; // our prefab object

    public void setTemplateDrawingsRow(List <ArtworkItem> fiveMostRecentTemplates)
    {
        Debug.Log("setting drawing row");
        fiveDrawings = fiveMostRecentTemplates;

        GameObject tempObj    = GameObject.Find("HomeScreen");
        HomeScreen homeScreen = tempObj.GetComponent <HomeScreen>();

        GameObject newObj; // create gameobject instance

        for (int tileIdx = 0; tileIdx < fiveMostRecentTemplates.Count; tileIdx++)
        {
            ArtworkItem artworkItem = fiveMostRecentTemplates[tileIdx];
            // create new instances of prefab
            newObj = (GameObject)Instantiate(prefab, transform);
            string url = artworkItem.png;

            // if empty object then dont add anything
            if (!String.IsNullOrEmpty(url))
            {
                int j = tileIdx;

                // Add onClick to button
                Button button = newObj.transform.GetChild(0).GetComponent <Button>();
                button.onClick.AddListener(() => loadDrawingWithTemplate(j));

                // Set the image of the template
                RawImage image = newObj.transform.GetChild(0).GetChild(0).GetComponent <RawImage>();
                if (image != null)
                {
                    StartCoroutine(FetchImages(url, image));
                }

                // Set the time
                Text timeText = newObj.transform.GetChild(0).GetChild(1).GetChild(0).GetComponent <Text>();
                timeText.text = convertTime(artworkItem.time);
            }
        }
    }
Ejemplo n.º 4
0
    // gets five most recent drawings and template artworks
    IEnumerator fetchRecentArtwork()
    {
        string url = "https://uql53bqfta.execute-api.us-east-1.amazonaws.com/Artsy/get-user-art";

        // Using the static constructor
        var request = UnityWebRequest.Get(url);

        request.SetRequestHeader("deviceid", SystemInfo.deviceUniqueIdentifier.Replace("-", ""));

        // Wait for the response and then get our data
        yield return(request.SendWebRequest());

        var data = request.downloadHandler.text;

        ArtworkCollection collection = ArtworkCollection.CreateFromJSON(data);

        // original artworks
        // first sort
        Array.Sort(collection.canvas,
                   delegate(ArtworkItem x, ArtworkItem y) { return(y.time.CompareTo(x.time)); });
        // only want first five
        // but if less than five, just add empty objects
        List <ArtworkItem> fiveMostRecentDrawings = new List <ArtworkItem>();

        if (collection.canvas.Length < 5)
        {
            for (int idx = 0; idx < collection.canvas.Length; idx++)
            {
                ArtworkItem artworkItem = collection.canvas[idx];
                fiveMostRecentDrawings.Add(artworkItem);
            }
            for (int idx = collection.canvas.Length; idx < 5; idx++)
            {
                ArtworkItem emptyArtworkItem = new ArtworkItem();
                fiveMostRecentDrawings.Add(emptyArtworkItem);
            }
        }
        else
        {
            for (int idx = 0; idx < 5; idx++)
            {
                ArtworkItem artworkItem = collection.canvas[idx];
                fiveMostRecentDrawings.Add(artworkItem);
            }
        }

        GameObject          tempObj             = GameObject.Find("DrawingContainer");
        fetchRecentDrawings fetchRecentDrawings = tempObj.GetComponent <fetchRecentDrawings>();

        fetchRecentDrawings.setOriginalDrawingsRow(fiveMostRecentDrawings);


        // templates
        //
        //
        // first sort
        Array.Sort(collection.template,
                   delegate(ArtworkItem x, ArtworkItem y) { return(y.time.CompareTo(x.time)); });
        // only want first five
        // but if less than five, just add empty objects
        List <ArtworkItem> fiveMostRecentTemplates = new List <ArtworkItem>();

        if (collection.template.Length < 5)
        {
            for (int idx = 0; idx < collection.template.Length; idx++)
            {
                ArtworkItem artworkItem = collection.template[idx];
                fiveMostRecentTemplates.Add(artworkItem);
            }
            for (int idx = collection.template.Length; idx < 5; idx++)
            {
                ArtworkItem emptyArtworkItem = new ArtworkItem();
                fiveMostRecentTemplates.Add(emptyArtworkItem);
            }
        }
        else
        {
            for (int idx = 0; idx < 5; idx++)
            {
                ArtworkItem artworkItem = collection.template[idx];
                fiveMostRecentTemplates.Add(artworkItem);
            }
        }

        GameObject           tempObj2             = GameObject.Find("TemplateDrawingContainer");
        fetchRecentTemplates fetchRecentTemplates = tempObj2.GetComponent <fetchRecentTemplates>();

        fetchRecentTemplates.setTemplateDrawingsRow(fiveMostRecentTemplates);

        Debug.Log("done getting most recent artworks in main menu :)");
        // Show objects
        // GameObject loadingObj1 = GameObject.Find("Loading (1)");
        // GameObject loadingObj2 = GameObject.Find("Loading (2)");
        // GameObject loadingObj3 = GameObject.Find("Loading (3)");
        // GameObject loadingObj4 = GameObject.Find("Loading (4)");
        // GameObject loadingObj5 = GameObject.Find("Loading (5)");
        // GameObject loadingObj6 = GameObject.Find("Loading (6)");
        // GameObject loadingObj7 = GameObject.Find("Loading (7)");
        // GameObject loadingObj8 = GameObject.Find("Loading (8)");
        // GameObject loadingObj9 = GameObject.Find("Loading (9)");
        // GameObject loadingObj = GameObject.Find("LoadingFade");

        // yield return new WaitForSeconds((float) 0.25);
        // loadingObj1.SetActive(false);
        // yield return new WaitForSeconds((float) 0.06);
        // loadingObj2.SetActive(false);
        // yield return new WaitForSeconds((float) 0.05);
        // loadingObj3.SetActive(false);
        // yield return new WaitForSeconds((float) 0.05);
        // loadingObj4.SetActive(false);
        // yield return new WaitForSeconds((float) 0.04);
        // loadingObj5.SetActive(false);
        // yield return new WaitForSeconds((float) 0.04);
        // loadingObj6.SetActive(false);
        // yield return new WaitForSeconds((float) 0.03);
        // loadingObj7.SetActive(false);
        // yield return new WaitForSeconds((float) 0.03);
        // loadingObj8.SetActive(false);
        // yield return new WaitForSeconds((float) 0.02);
        // loadingObj9.SetActive(false);
        // // The Overall object being active until the load is complete makes sure the user does not click anywhere
        // loadingObj.SetActive(false);
    }
Ejemplo n.º 5
0
 public static UploadMedia FromArtwork(ArtworkItem artwork)
 {
     return(new UploadMedia(artwork.Image, MediaType.Image, "ARTW"));
 }