public async Task <Flight> SaveFlight(ResAPI flight)
        {
            Flight newFlight = new Flight()
            {
                FlightCode       = flight.FlightNumber + flight.DepartureStation + flight.ArrivalStation + flight.DepartureDate.Day,
                DepartureStation = flight.DepartureStation,
                DepartureDate    = flight.DepartureDate,
                ArrivalStation   = flight.ArrivalStation,
                Currency         = flight.Currency,
                Price            = flight.Price,
                Transport        = new Transport()
                {
                    FlightNumber = flight.FlightNumber + flight.DepartureDate.Day
                },
                FkTransport = flight.FlightNumber + flight.DepartureDate.Day
            };

            if (newFlight.FlightCode == null || newFlight.DepartureStation == null || newFlight.DepartureDate == null ||
                newFlight.ArrivalStation == null || newFlight.Currency == null || newFlight.Price == 0 || newFlight.FkTransport == null)
            {
                throw new MissingFlightDataException("Any of the data to save for this flight is missed");
            }
            try
            {
                db.Flights.Add(newFlight);
                await db.SaveChangesAsync();

                return(newFlight);
            }
            catch (Exception)
            {
                throw new FlightDataAlreadySavedException($"The flight {newFlight.FlightCode} is already stored in the data base");
            }
        }
Example #2
0
    IEnumerator StartDeleteVideo(string name, string prefix)
    {
        //如果不延迟会删除失败
        yield return(new WaitForSeconds(0.2f));

        ResAPI.Delete(Prefix2Type[prefix], name);
        Panels[(int)Prefix2Type[prefix]].UpdateAll();

        // video player stop
        video.Stop();
    }
Example #3
0
    private void DeleteImage()
    {
        string name   = video.CurrentImageName;
        string prefix = name.Split('_')[0];

        ResAPI.Delete(Prefix2Type[prefix], name);
        Panels[(int)Prefix2Type[prefix]].UpdateAll();
        StartCoroutine(RefreshPanel(1.5f));

        // video player stop
        video.Stop();
    }
Example #4
0
    public void GeneratePreviewImage(string videoPath, string outImagePath)
    {
        var splitArray = Regex.Split(videoPath, "Resources/", RegexOptions.IgnoreCase);
        var ImageName  = Regex.Split(videoPath, "Videos/", RegexOptions.IgnoreCase);

        // 自己生成的缩略图都默认是 .png
        this.imagename = ResAPI.RemoveSuffix(ImageName[1]) + ".png";
        //this.imagename = ImageName[1] + ".png";
        this.outpath = outImagePath;

        UrlLoadAndPlay(videoPath);
    }
Example #5
0
        public async Task <ActionResult> Save([FromBody] ResAPI flight)
        {
            try
            {
                Flight model = await _dbAccess.SaveFlight(flight);

                return(View("Save", model));
            }
            catch (Exception ex)
            {
                throw new Exception("Mensaje de error " + ex.Message);
            }
        }
Example #6
0
    public void UpdateAll()
    {
        List <string> newNames = new List <string>();
        string        fullPath = Path.Combine(Application.streamingAssetsPath, "Resources", ResourcePath);

        // 生成 newNames:List 当前文件夹下所有 FileSuffix 后缀的文件名
        if (Directory.Exists(fullPath))
        {
            DirectoryInfo direction = new DirectoryInfo(fullPath);
            FileInfo[]    files     = direction.GetFiles("*", SearchOption.AllDirectories);

            foreach (FileInfo file in files)
            {
                if (ResAPI.HasSuffix(file.Name, false))
                {
                    newNames.Add(ResAPI.RemoveSuffix(file.Name));
                }
            }
        }

        // 删除:原List有 新List没有,需要删除
        IEnumerable <string> deleteList = imageNames.Except(newNames);
        // 添加:新List有 原List没有,需要添加
        IEnumerable <string> newList = newNames.Except(imageNames);

        // imageNames 列表更新,需及时更新,否则重复点击刷新可能会造成重复添加
        imageNames = newNames;

        // 添加的处理
        foreach (string name in newList)
        {
            StartCoroutine(AddNewImage(name));
        }

        // 删除的处理
        foreach (string name in deleteList)
        {
            Destroy(images[name].gameObject);
            images.Remove(name);
        }
    }
Example #7
0
    public void PlayHandle(object sender, string name)
    {
        string prefix = name.Split('_')[0];

        ResAPI.VideoType type;
        try {
            type = ResAPI.Prefix2Type[prefix];
        }
        catch (Exception) {
            Video_errorReceived(null, "[VideoManager.PlayHandle]: Convert Prefix to Type Error");
            throw;
        }

        if (ResAPI.TypeIsVideo(type))
        {
            Play(name);
        }
        else
        {
            PlayImage(name);
        }
    }
Example #8
0
    /// <summary>
    ///     用 IO 方式从外部加载图片到 Sprite
    /// </summary>
    /// <param name="path">
    ///     可以是 Resources/ 下的路径也可以是绝对路径,不加后缀
    /// </param>
    public static Sprite LoadSprite(string path)
    {
        // 路径格式处理
        if (!path.Contains(ResourcePath))
        {
            path = Path.Combine(ResourcePath, path);
        }
        if (!ResAPI.HasSuffix(path, false))
        {
            path = ResAPI.FillSuffix(path);
        }

        Texture2D texture = LoadTexture(path);

        if (texture == null)
        {
            return(null);
        }

        // 创建 Sprite
        Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));

        return(sprite);
    }
Example #9
0
 // 取消上传
 public void Cancel()
 {
     Close();
     ResAPI.Delete(ResAPI.VideoType.Product, videoName);
 }