예제 #1
0
    public void Init(FileJson fileJson)
    {
        authorName.text = fileJson.username;
        if (fileJson.anonymous)
        {
            authorName.text = "anonymous";
            authorProfileButton.interactable = false;
        }
        fileName.text  = fileJson.fileName;
        downloads.text = fileJson.downloadNum.ToString();
        likes.text     = fileJson.likes.ToString();
        string dateStr = System.DateTimeOffset.FromUnixTimeMilliseconds(long.Parse(fileJson.dateUpdated)).UtcDateTime.ToString("MM/dd/yyyy");

        date.text            = dateStr;
        rateText.text        = fileJson.rate.ToString();
        rateImage.fillAmount = fileJson.rate / 5;

        infoDownloadUrl = fileJson.infoDownloadUrl.URL;
        Debug.Log(fileJson.infoDownloadUrl.status + " " + infoDownloadUrl);

        key   = fileJson.key;
        email = fileJson.email;
        StartCoroutine(RequestDownloadInfoCoro());

        canvasTrans = GetComponentInParent <Canvas>().transform;

        authorProfileButton.GetComponent <AuthorButton>().email = fileJson.email;
    }
        public ActionResult <bool> Add(FileJson Json, [FromHeader] long accessToken)
        {
            var u = (from e in _context.Users where e.AccessToken == accessToken select e).FirstOrDefault();

            if (u != null)
            {
                var d = u.LastLogin.AddMinutes(15);
                if (d.TimeOfDay < DateTime.UtcNow.TimeOfDay)
                {
                    return(false);
                }
                else
                {
                    var l = (from x in _context.Lessons where x.Name == Json.Lesson.Name select x).FirstOrDefault();
                    if (l != null)
                    {
                        _context.Files.Add(new SharedCode.File {
                            Name = Json.Name, Body = Json.Body, CreatedAt = DateTime.UtcNow, Creator = u, Lesson = l
                        });
                        _context.Users.Where(e => e.Email == u.Email).FirstOrDefault().Experience += 10;
                        _context.SaveChanges();
                    }
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        public async Task <IActionResult> AddFileConfAsync(File f)
        {
            FileJson JsonU = new FileJson();

            JsonU.Name   = f.Name;
            JsonU.Body   = f.Body;
            JsonU.Lesson = new Lesson()
            {
                Name = "C# premier quad"
            };
            JsonU.CreatedAt = DateTime.Now;
            HttpClient client = new HttpClient();
            string     access = HttpContext.Session.GetString("test");

            client.DefaultRequestHeaders.Add("AccessToken", HttpContext.Session.GetString("AccessToken"));
            string json = JsonConvert.SerializeObject(JsonU);
            var    res  = await client.PostAsync("http://apimts.azurewebsites.net/api/File/AddFile", new StringContent(json, Encoding.UTF8, "application/json"));

            bool response = await res.Content.ReadAsAsync <bool>();

            if (response)
            {
                ViewBag.Message = "Fichier créé !";
            }
            else
            {
                ViewBag.Message = "Erreur lors de la création du fichier";
            }
            return(View("AddFile"));
        }
예제 #4
0
        /// <summary>
        /// Return a JSON representation of the asset.
        /// </summary>
        /// <returns>A string in JSON format that represents the static/configuration data present
        /// in the asset.</returns>
        /// <remarks>
        /// This will not save dynamic execution state such as callbacks installed on
        /// <see cref="InputAction">actions</see> or enabled/disabled states of individual
        /// maps and actions.
        ///
        /// Use <see cref="LoadFromJson"/> to deserialize the JSON data back into an InputActionAsset.
        /// </remarks>
        public string ToJson()
        {
            var fileJson = new FileJson
            {
                name           = name,
                maps           = InputActionMap.WriteFileJson.FromMaps(m_ActionMaps).maps,
                controlSchemes = InputControlScheme.SchemeJson.ToJson(m_ControlSchemes),
            };

            return(JsonUtility.ToJson(fileJson, true));
        }
예제 #5
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            if ((listItems.SelectedItem as Item).label != "")
            {
                bool check = true;

                if (string.IsNullOrEmpty(txtPath.Text))
                {
                    vldPath.Visibility = Visibility.Visible;
                    check = false;
                }

                if (string.IsNullOrEmpty(txtLabel.Text))
                {
                    vldLabel.Visibility = Visibility.Visible;
                    check = false;
                }

                if (check)
                {
                    Item             currentItem = Controller.Model.Playlists[Controller.CurrentDatabase].items.SingleOrDefault(i => i.id == (listItems.SelectedItem as Item).id);
                    MessageBoxResult result      = MessageBox.Show("Are you sure to edit?", "Edit", MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (result == MessageBoxResult.Yes && currentItem != null)
                    {
                        if (Controller.isCustom == false && picItem.Source != null && Controller.isImageEdit)
                        {
                            Controller.SaveImage(picItem.Source as BitmapImage, currentItem.label, txtLabel.Text);
                        }
                        saveInfo(currentItem);
                        if (Controller.isCustom)
                        {
                            FileJson <Root> .Write(Controller.customPath, Controller.Model.Playlists[Controller.CurrentDatabase]);
                        }
                        else
                        {
                            FileJson <Root> .Write(@"playlists\" + (cmbPlaylist.SelectedItem as string) + ".lpl", Controller.Model.Playlists[Controller.CurrentDatabase]);
                        }
                        MessageBox.Show("Playlist updated");
                        btnEdit.IsEnabled       = false;
                        Controller.CurrentIndex = listItems.SelectedIndex;
                        if (Controller.isCustom)
                        {
                            Controller.LoadCustomDatabase(Controller.customPath);
                        }
                        else
                        {
                            Controller.ReloadDatabase(cmbPlaylist.SelectedItem as string);
                        }
                        cmbPlaylist_SelectionChanged(sender, e as SelectionChangedEventArgs);
                    }
                }
            }
        }
        /// <summary>
        /// 拼接url获取List
        /// </summary>
        /// <param name="mql"></param>
        /// <returns></returns>
        public List <FileJson> GetFList(List <TT_FilesTransact> list)
        {
            List <FileJson> json = new List <FileJson>();

            if (list != null && list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    FileJson item = new FileJson();
                    item.ShowName = list[i].ShowName;
                    item.Url      = list[i].Route + list[i].RelativePath;
                    json.Add(item);
                }
            }

            return(json);
        }
예제 #7
0
    //添加文件地md5
    static void AddFileMD5(string source, List <FileJson> list)
    {
        string        root   = GameConfig.GetAssetBundleOutputPath();
        DirectoryInfo folder = new DirectoryInfo(source);

        FileSystemInfo[] files = folder.GetFileSystemInfos();
        int length             = files.Length;

        for (int i = 0; i < length; i++)
        {
            if (files[i] is DirectoryInfo)
            {
                AddFileMD5(files[i].FullName, list);
            }
            else
            {
                string fullName = FileHelper.UnixPath(files[i].FullName);
                if (fullName.EndsWith(GameConfig.AssetTail))
                {
                    string md5   = FileHelper.GetMD5HashFromFile(fullName);
                    int    index = fullName.LastIndexOf(GameConfig.GameName.ToLower() + "/");

                    FileJson fileJson = new FileJson();
                    fileJson.MD5      = md5;
                    fileJson.FileName = fullName.Substring(index);
                    list.Add(fileJson);
                }
                else if (root.EndsWith(files[i].Name))
                {
                    string md5 = FileHelper.GetMD5HashFromFile(fullName);

                    FileJson fileJson = new FileJson();
                    fileJson.MD5      = md5;
                    fileJson.FileName = files[i].Name;
                    list.Add(fileJson);
                }
            }
        }
    }
        public void Setup()
        {
            GameObject o = new GameObject("cavasObj");

            o.AddComponent <Canvas>();
            GameObject fileOverviewPanel = Object.Instantiate((GameObject)Resources.Load("Prefabs/File overview Panel"), o.transform);

            fileOverview = fileOverviewPanel.GetComponent <FileOverview>();
            Debug.Log(fileOverview);

            FileJson fileJson = new FileJson();

            fileJson.anonymous              = false;
            fileJson.email                  = "*****@*****.**";
            fileJson.dateUpdated            = "1561736000534";
            fileJson.fileName               = "";
            fileJson.infoDownloadUrl        = new InfoDownloadUrl();
            fileJson.infoDownloadUrl.status = 200;
            fileJson.infoDownloadUrl.URL    = "";
            fileJson.key = "[email protected]|SpangeBob";

            fileOverview.Init(fileJson);
        }
예제 #9
0
        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if ((listItems.SelectedItem as Item).label != "")
            {
                Item             currentItem = Controller.Model.Playlists[Controller.CurrentDatabase].items.SingleOrDefault(i => i.id == (listItems.SelectedItem as Item).id);
                MessageBoxResult result      = MessageBox.Show("Are you sure to remove it?", "Remove", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes && currentItem != null)
                {
                    bool deleteItem = false;
                    if (File.Exists(currentItem.path))
                    {
                        deleteItem = MessageBox.Show("Do you wanna remove item too?", "Remove item", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
                    }

                    Controller.RemoveItem(currentItem, Controller.CurrentDatabase, removeFile: deleteItem);
                    if (Controller.isCustom)
                    {
                        FileJson <Root> .Write(Controller.customPath, Controller.Model.Playlists[Controller.CurrentDatabase]);
                    }
                    else
                    {
                        FileJson <Root> .Write(@"playlists\" + (cmbPlaylist.SelectedItem as string) + ".lpl", Controller.Model.Playlists[Controller.CurrentDatabase]);
                    }
                    MessageBox.Show("Element removed");
                    if (Controller.isCustom)
                    {
                        Controller.LoadCustomDatabase(Controller.customPath);
                    }
                    else
                    {
                        Controller.ReloadDatabase(cmbPlaylist.SelectedItem as string);
                    }
                    cmbPlaylist_SelectionChanged(sender, e as SelectionChangedEventArgs);
                }
            }
        }