Exemplo n.º 1
0
        public async Task <ActionResult <CreationResult> > CreateVersionInfo(AppVersionData newAppVersion, int id = -1)
        {
            int appId = id == -1 ? (int)newAppVersion.AppID : id;


            AppVersion toAdd = new AppVersion
            {
                AppID         = appId,
                Changelog     = newAppVersion.Changelog,
                VresionName   = newAppVersion.VresionName,
                VresionNumber = newAppVersion.VresionNumber,
                ReleaseDate   = newAppVersion.ReleaseDate,
                ChannelID     = newAppVersion.ChannelID
            };

            _context.AppVersions.Add(toAdd);
            await _context.SaveChangesAsync();

            _context.Entry(toAdd).Reference(x => x.Channel).Load();
            _context.Entry(toAdd).Reference(x => x.App).Load();
            Channel channel = toAdd.Channel;

            if (channel.ChannelName.ToLower() == "release")
            {
                App app = toAdd.App;
                if (app.Published)
                {
                    await _notificationsHub.SendNotification("new version" + newAppVersion.VresionNumber + " of " + app.Name);
                }
            }
            return(new CreationResult {
                txt = "Done", ID = toAdd.ID + ""
            });
        }
Exemplo n.º 2
0
        public async Task <ActionResult <CreationResult> > CreateStageInfo(StageData newStage, int id = -1)
        {
            int versionID = id == -1 ? (int)newStage.AppVersionID : id;

            AppVersion appvr = _context.AppVersions.Where(x => x.ID == versionID).SingleOrDefault();

            _context.Entry(appvr).Reference(c => c.App).Load();

            App app = appvr.App;

            String fileSrc  = "";
            float  fileSize = 0.0f;

            if (app.Public)
            {
                fileSrc  = newStage.FSsource;;
                fileSize = 0.0f; //GetFileSize(fileSrc);
            }
            else
            {
                _context.Entry(app).Reference(c => c.Enviroment).Load();

                String iconsSrc = app.FSiconsSources;

                if (app.Enviroment.EnviromentName.ToLower() == "android")
                {
                    fileSrc = _fileHander.acceptableName("Apk", newStage.FSsource);
                    _fileHander.saveFile("Apk", newStage.FSsource, fileSrc);
                    fileSize = _fileHander.FileSize("Apk", fileSrc);
                }
                else if (app.Enviroment.EnviromentName.ToLower() == "ios")
                {
                    String tmpIpaSrc = _fileHander.acceptableName("Ipa", newStage.FSsource);
                    _fileHander.saveFile("Ipa", newStage.FSsource, tmpIpaSrc);
                    fileSrc = _fileHander.GenerateManifest(tmpIpaSrc, iconsSrc, versionID);
                }
            }
            Stage toAdd = new Stage
            {
                AppVersionID = versionID,
                FSsource     = fileSrc,
                Size         = fileSize,
            };

            _context.Stages.Add(toAdd);
            await _context.SaveChangesAsync();

            return(new CreationResult {
                txt = "Done", ID = toAdd.ID + ""
            });
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutChannelData(int?id, ChannelData channelData)
        {
            Channel toChange = new Channel {
                ChannelName = channelData.ChannelName, ID = (int)id
            };

            if (id != toChange.ID)
            {
                return(BadRequest());
            }

            _context.Entry(toChange).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChannelDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutApp(int id, App app)
        {
            if (id != app.ID)
            {
                return(BadRequest());
            }

            _context.Entry(app).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AppExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> PutEnviromentData(int?id, EnviromentData enviromentData)
        {
            Enviroment tochange = new Enviroment {
                ID = (int)id, EnviromentName = enviromentData.EnviromentName
            };

            if (id != tochange.ID)
            {
                return(BadRequest());
            }

            _context.Entry(tochange).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EnviromentDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 6
0
        List <ToseeApp> GetToseeApps()
        {
            var             apps = _context.Apps.ToList();
            List <ToseeApp> aa   = apps.ConvertAll(x => {
                _context.Entry(x).Reference(c => c.Enviroment).Load();
                _context.Entry(x).Reference(c => c.User).Load();
                var appvs = (from q in _context.AppVersions where q.AppID == x.ID select q).AsEnumerable();
                AppVersion appv;
                Stage stage;
                String channel;
                if (appvs.Count() > 0)
                {
                    appv = appvs.Last();
                    _context.Entry(appv).Reference(c => c.Channel).Load();
                    channel = appv.Channel.ChannelName;

                    var stages = (from q in _context.Stages where q.AppVersionID == appv.ID select q).AsEnumerable();
                    if (stages.Count() > 0)
                    {
                        stage = stages.Last();
                    }
                    else
                    {
                        stage = new Stage {
                            FSsource = "", Size = 0.0f
                        }
                    };
                }
                else
                {
                    appv = new AppVersion {
                        Changelog = "", ReleaseDate = "", VresionName = "", VresionNumber = ""
                    };
                    channel = "";
                    stage   = new Stage {
                        FSsource = "", Size = 0.0f
                    };
                }

                return(new ToseeApp
                {
                    ID = x.ID,
                    Name = x.Name,
                    Description = x.Description,
                    PackageName = x.PackageName,
                    Downloads = x.Downloads,
                    WebSite = x.WebSite,
                    Published = x.Published,
                    Public = x.Public,
                    Enviroment = x.Enviroment.EnviromentName,
                    FSiconsSources = x.FSiconsSources,
                    ScreenShots = x.ScreenShots,
                    Video = x.Video,
                    SupportedDevices = x.SupportedDevices,
                    Changelog = appv.Changelog,
                    VresionName = appv.VresionName,
                    VresionNumber = appv.VresionNumber,
                    ReleaseDate = appv.ReleaseDate,
                    FSsource = stage.FSsource,
                    Size = stage.Size,
                    Developer = x.User.FullName,
                    Channel = channel
                });
            });

            return(aa);
        }