コード例 #1
0
        public void LoadEmotionsForUser(int userId)
        {
            _userId = userId;
            using (var db = new PrototypingContext())
            {
                User user = db.Users
                            .Include(u => u.Records)
                            .ThenInclude(r => r.ResultEmotion)
                            .ThenInclude(f => f.Scores)
                            .Single(u => u.UserId == userId);

                foreach (Record record in user.Records)
                {
                    foreach (EmotionFragment fragment in record.ResultEmotion)
                    {
                        foreach (EmotionMeanScores score in fragment.Scores)
                        {
                            scores.AngerScore     += score.AngerScore;
                            scores.ContemptScore  += score.ContemptScore;
                            scores.DisgustScore   += score.DisgustScore;
                            scores.FearScore      += score.FearScore;
                            scores.HappinessScore += score.HappinessScore;
                            scores.NeutralScore   += score.NeutralScore;
                            scores.SadnessScore   += score.SadnessScore;
                            scores.SurpriseScore  += score.SurpriseScore;
                            max++;
                        }
                    }
                }
            }

            SortAndChangeToPercentResult();
        }
コード例 #2
0
        public async Task HeatSaveScreens(List <RecordScreenModel> reviewModels)
        {
            RingContentVisibility = true;
            using (var db = new PrototypingContext())
            {
                RecordModel = db.Records.Last();
                if (!string.IsNullOrEmpty(RecordModel.PathToVideo))
                {
                    StorageFile videoFile = await StorageFile.GetFileFromPathAsync(RecordModel.PathToVideo);

                    await Task.Delay(1000);

                    Windows.UI.Xaml.Controls.MediaPlayerElement player = new Windows.UI.Xaml.Controls.MediaPlayerElement();
                    player.AreTransportControlsEnabled = true;
                    player.Source       = MediaSource.CreateFromStorageFile(videoFile);
                    RecordVideo         = player;
                    VideoIconVisibility = true;
                }
                else
                {
                    VideoIconVisibility = false;
                }
            }
            Screens = await HeatingScreens(reviewModels);

            RingContentVisibility = false;
        }
コード例 #3
0
        private async void RemoveFunc()
        {
            using (var db = new PrototypingContext())
            {
                User user = db.Users.Single(u => u.UserId == UserModel.UserId);
                await db.Entry(user).Reference(u => u.Prototype).LoadAsync();

                try
                {
                    StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(user.Prototype.Name + "_" + user.PrototypeId);

                    StorageFolder userFolder = await prototypeFolder.GetFolderAsync(user.Name + "_" + user.UserId);

                    await userFolder.DeleteAsync();
                }
                catch (System.IO.FileNotFoundException)
                {
                    System.Diagnostics.Debug.WriteLine("User folder not found");
                }

                db.Users.Remove(user);
                db.SaveChanges();
            }
            ((Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content).Navigate(typeof(DetailsPrototypePage), UserModel.PrototypeId);
        }
コード例 #4
0
        public async Task DeleteUser(User user)
        {
            using (var db = new PrototypingContext())
            {
                User findUser = db.Users.Single(u => u.UserId == user.UserId);
                await db.Entry(findUser).Reference(u => u.Prototype).LoadAsync();

                try
                {
                    StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(findUser.Prototype.Name + "_" + findUser.PrototypeId);

                    StorageFolder userFolder = await prototypeFolder.GetFolderAsync(findUser.Name + "_" + findUser.UserId);

                    await userFolder.DeleteAsync();
                }
                catch (System.IO.FileNotFoundException)
                {
                    System.Diagnostics.Debug.WriteLine("Prototype/User folder not found");
                }

                db.Users.Remove(findUser);
                db.SaveChanges();
            }
            UpdateUserList(user.PrototypeId);
        }
コード例 #5
0
        private async Task <string> CreateVideoFile(int recordId)
        {
            string pathToVideo = string.Empty;

            using (var db = new PrototypingContext())
            {
                User user = db.Users.Single(u => u.UserId == userId);
                await db.Entry(user).Reference(u => u.Prototype).LoadAsync();

                string prototypeName = user.Prototype.Name + "_" + user.PrototypeId;
                string userName      = user.Name + "_" + user.UserId;
                string recordName    = "Record_" + recordId;

                StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(prototypeName, CreationCollisionOption.OpenIfExists); //PrototypeName + Id

                StorageFolder userFolder = await prototypeFolder.CreateFolderAsync(userName, CreationCollisionOption.OpenIfExists);                               //UserName + Id

                StorageFolder recordFolder = await userFolder.CreateFolderAsync(recordName, CreationCollisionOption.OpenIfExists);

                videoFile = await recordFolder.CreateFileAsync("videoRecord.mp4", CreationCollisionOption.GenerateUniqueName);

                pathToVideo = videoFile.Path;
            }
            return(pathToVideo);
        }
コード例 #6
0
        public async Task DeleteRecord(Record record)
        {
            using (var db = new PrototypingContext())
            {
                Record findRecord = db.Records.Single(r => r.RecordId == record.RecordId);
                await db.Entry(findRecord).Reference(r => r.User).LoadAsync();

                User userParent = findRecord.User;
                await db.Entry(userParent).Reference(u => u.Prototype).LoadAsync();

                try
                {
                    StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(userParent.Prototype.Name + "_" + userParent.PrototypeId);

                    StorageFolder userFolder = await prototypeFolder.GetFolderAsync(userParent.Name + "_" + userParent.UserId);

                    StorageFolder recordFolder = await userFolder.GetFolderAsync("Record_" + findRecord.RecordId);

                    await recordFolder.DeleteAsync();
                }
                catch (System.IO.FileNotFoundException)
                {
                    System.Diagnostics.Debug.WriteLine("Prototype/User folder not found");
                }

                db.Records.Remove(findRecord);
                db.SaveChanges();
            }
            UpdateRecordList(record.UserId);
        }
コード例 #7
0
        private async void CancelFunc()
        {
            if (!_ringContentVisibility)
            {
                using (var db = new PrototypingContext())
                {
                    User   user   = db.Users.Single(u => u.UserId == userId);
                    Record record = db.Records.Last();
                    db.Entry(user).Reference(u => u.Prototype).Load();
                    try
                    {
                        StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(user.Prototype.Name + "_" + user.PrototypeId);

                        StorageFolder userFolder = await prototypeFolder.GetFolderAsync(user.Name + "_" + user.UserId);

                        StorageFolder recordFolder = await userFolder.GetFolderAsync("Record_" + recordSettings.RecordId);

                        await recordFolder.DeleteAsync();
                    }
                    catch (System.IO.FileNotFoundException) { }

                    db.Records.Remove(record);
                    db.SaveChanges();
                }
                Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content;
                frame.BackStack.Clear();
                frame.Navigate(typeof(DetailsUserPage), userId);
            }
        }
コード例 #8
0
        private void UpdateGroups()
        {
            using (var db = new PrototypingContext())
            {
                List <Prototype> prototypes = db.Prototypes.ToList();

                List <PrototypeGroup> protGroups = prototypes.GroupBy(p => p.Name[0], (key, items) => new PrototypeGroup()
                {
                    Name     = key.ToString(),
                    Items    = items.ToList(),
                    IsEnable = true
                }).ToList();

                string[] inDB = (from g in protGroups
                                 select g.Name).ToArray();
                List <PrototypeGroup> notInDB = (from n in semanticZoomNames
                                                 where !inDB.Contains(n)
                                                 select(new PrototypeGroup()
                {
                    Name = n
                })).ToList();
                protGroups.AddRange(notInDB);
                protGroups = (from g in protGroups
                              orderby g.Name
                              select g).ToList();
                PrototypesGroup = new ObservableCollection <PrototypeGroup>(protGroups);
            }
        }
コード例 #9
0
        public async Task LoadData(int _userId)
        {
            userId   = _userId;
            _webview = new Windows.UI.Xaml.Controls.WebView();
            _webview.Settings.IsJavaScriptEnabled = true;
            _webview.NavigationStarting          += WebView_NavigationStarting;
            _webview.NavigationFailed            += Webview_NavigationFailed;
            _webview.NavigationCompleted         += WebView_NavigationCompleted;
            _webview.ScriptNotify += WebView_ScriptNotify;

            using (var db = new PrototypingContext())
            {
                User user = db.Users.Single(u => u.UserId == userId);
                db.Entry(user).Reference(u => u.Prototype).Load();
                recordSettings = db.RecordSettings.Last();

                WebView.Navigate(new Uri(user.Prototype.Url));
            }

            if (!recordSettings.Touches && !recordSettings.FrontCamera)
            {
                StartIconVisibility = false;
            }
            if (!recordSettings.FrontCamera)
            {
                VideoIconVisibility = false;
            }
            else
            {
                await MediaCaptureInitialization();
            }
        }
コード例 #10
0
        public async Task HeatingAllRecordScreens(User user)
        {
            userId = user.UserId;
            RingContentVisibility = true;
            using (var db = new PrototypingContext())
            {
                List <RecordScreen> allScreen = db.RecordScreens
                                                .Include(rs => rs.Record)
                                                .Where(rs => rs.Record.UserId == user.UserId)
                                                .OrderByDescending(rs => rs.UriPage)
                                                .ToList();
                Screens = await HeatingRecordScreens(allScreen);

                List <Record> records = db.Records
                                        .Where(rp => rp.User.UserId == user.UserId)
                                        .OrderBy(rp => rp.CreatedDate)
                                        .ToList();
                Records = new ObservableCollection <Record>(records);
                if (records.Count != 0)
                {
                    string[] pathsToFiles = (from r in records
                                             select r.PathToVideo).ToArray();
                    videoList = new List <StorageFile>();
                    await LoadigVideoFiles(pathsToFiles);

                    SelectedRecord      = Records.First();
                    VideoIconVisibility = true;
                }
            }
            RingContentVisibility = false;
        }
コード例 #11
0
        public async Task GetRecordScreens(Record record)
        {
            RingContentVisibility = true;
            using (var db = new PrototypingContext())
            {
                RecordModel = db.Records.Single(r => r.RecordId == record.RecordId);
                await db.Entry(RecordModel).Collection(r => r.Screens).LoadAsync();

                if (!string.IsNullOrEmpty(RecordModel.PathToVideo))
                {
                    StorageFile videoFile = await StorageFile.GetFileFromPathAsync(RecordModel.PathToVideo);

                    Windows.UI.Xaml.Controls.MediaPlayerElement player = new Windows.UI.Xaml.Controls.MediaPlayerElement();
                    player.AreTransportControlsEnabled = true;
                    player.Source       = MediaSource.CreateFromStorageFile(videoFile);
                    RecordVideo         = player;
                    VideoIconVisibility = true;
                }
                else
                {
                    VideoIconVisibility = false;
                }
                Screens = await FileToImageTransform(RecordModel.Screens);
            }
            RingContentVisibility = false;
        }
コード例 #12
0
 private void UpdateUserList(int prototypeId)
 {
     using (var db = new PrototypingContext())
     {
         PrototypeModel = db.Prototypes.Single(p => p.PrototypeId == prototypeId);
         Users          = new ObservableCollection <User>(db.Users.Where(u => u.PrototypeId == prototypeId));
     }
 }
コード例 #13
0
 private void UpdateRecordList(int userId)
 {
     using (var db = new PrototypingContext())
     {
         UserModel = db.Users.Single(u => u.UserId == userId);
         Records   = new ObservableCollection <Record>(db.Records.Where(r => r.UserId == userId));
     }
 }
コード例 #14
0
        //public static string SubscriptionKey = "3c9741c55fec4fc8ba1bba2550e494bd";
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using (var db = new PrototypingContext())
            {
                db.Database.Migrate();
            }
        }
コード例 #15
0
        private async Task StartStopFunc()
        {
            if (_isOnStart)
            {
                TimerInit();
                IsOnStart           = false;
                IsSplitViewPaneOpen = false;

                currentRecordScreen = new RecordScreenModel(_webview.Source.AbsoluteUri, await DoCaptureWebView());
                _screens.Add(currentRecordScreen);

                using (var db = new PrototypingContext())
                {
                    Record record = db.Records.Single(rp => rp.RecordId == recordSettings.RecordId);
                    createdDate        = DateTime.Now;
                    record.CreatedDate = createdDate;
                    db.Records.Update(record);

                    if (recordSettings.FrontCamera)
                    {
                        string pathtoVideo = await CreateVideoFile(record.RecordId);

                        record.PathToVideo = pathtoVideo;
                        db.Records.Update(record);

                        var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto);
                        if (AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Mobile"))
                        {
                            encodingProfile.Video.Properties.Add(RotationKey, 270);
                        }
                        await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile);

                        _isRecording = true;
                    }
                    db.SaveChanges();
                }
            }
            else
            {
                //add lastRecordingDate in user and prototype
                using (var db = new PrototypingContext())
                {
                    Record record = db.Records.Single(rp => rp.RecordId == recordSettings.RecordId);
                    User   user   = db.Users.Single(u => u.UserId == record.UserId);
                    user.LastRecordingDate = createdDate;
                    db.Users.Update(user);
                    Prototype prototype = db.Prototypes.Single(p => p.PrototypeId == user.PrototypeId);
                    prototype.LastRecordingDate = createdDate;
                    db.Prototypes.Update(prototype);
                    db.SaveChanges();
                }
                ((Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content).Navigate(typeof(ResultRecordPage), _screens);
            }
        }
コード例 #16
0
        private async Task SaveResultInDb(VideoAggregateRecognitionResult videoResult)
        {
            RingText = "Save in DB...";
            using (var db = new PrototypingContext())
            {
                Record record = db.Records.Single(r => r.RecordId == recordModel.RecordId);
                record.EmotionVideoTimeScale = videoResult.Timescale;

                List <EmotionFragment> fragments = new List <EmotionFragment>();
                foreach (var videoFragment in videoResult.Fragments)
                {
                    if (videoFragment != null && videoFragment.Events != null)
                    {
                        List <EmotionMeanScores> scores = new List <EmotionMeanScores>();
                        foreach (VideoAggregateEvent[] videoEvents in videoFragment.Events)
                        {
                            if (videoEvents.Length > 0)
                            {
                                Scores videoScores = videoEvents[0].WindowMeanScores;
                                scores.Add(new EmotionMeanScores()
                                {
                                    AngerScore     = videoScores.Anger,
                                    ContemptScore  = videoScores.Contempt,
                                    DisgustScore   = videoScores.Disgust,
                                    FearScore      = videoScores.Fear,
                                    HappinessScore = videoScores.Happiness,
                                    NeutralScore   = videoScores.Neutral,
                                    SadnessScore   = videoScores.Sadness,
                                    SurpriseScore  = videoScores.Surprise
                                });
                            }
                        }
                        fragments.Add(new EmotionFragment()
                        {
                            Duration = videoFragment.Duration,
                            Interval = videoFragment.Interval,
                            Start    = videoFragment.Start,
                            Scores   = scores
                        });
                    }
                }

                record.ResultEmotion = fragments;
                await db.SaveChangesAsync();

                recordModel.EmotionVideoTimeScale = record.EmotionVideoTimeScale;
                recordModel.ResultEmotion         = fragments;
            }
        }
コード例 #17
0
 public void LoadUser(int _userId)
 {
     HeaderText = "Edit user";
     IsEdit     = true;
     using (var db = new PrototypingContext())
     {
         User _user = db.Users.Single(u => u.UserId == _userId);
         prototypeId   = _user.PrototypeId;
         NameText      = _user.Name;
         BiographyText = _user.Biography;
         user          = new User()
         {
             UserId = _userId
         };
     }
 }
コード例 #18
0
 public void LoadPrototype(int _prototypeId)
 {
     HeaderText = "Edit prototype";
     IsEdit     = true;
     using (var db = new PrototypingContext())
     {
         Prototype _prototype = db.Prototypes.Single(p => p.PrototypeId == _prototypeId);
         UrlText         = _prototype.Url;
         NameText        = _prototype.Name;
         DescriptionText = _prototype.Description;
     }
     prototype = new Prototype()
     {
         PrototypeId = _prototypeId
     };
 }
コード例 #19
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            int    Id         = (int)value;
            string resultText = "";

            using (var db = new PrototypingContext())
            {
                if (parameter.ToString().Equals("prototype"))
                {
                    int users = db.Users.Count(u => u.PrototypeId == Id);
                    if (users > 0)
                    {
                        resultText = users + " users";

                        int records = db.Users.Where(u => u.PrototypeId == Id).Sum(u => u.Records.Count());
                        if (records > 0)
                        {
                            resultText += ", " + records + "records";
                        }
                        else
                        {
                            resultText = "No records yet";
                        }
                    }
                    else
                    {
                        resultText = "No records yet";
                    }
                }
                if (parameter.ToString().Equals("user"))
                {
                    int records = db.Records.Count(r => r.UserId == Id);
                    if (records > 0)
                    {
                        resultText += records + " records";
                    }
                    else
                    {
                        resultText = "No records yet";
                    }
                }
            }

            return(resultText);
        }
コード例 #20
0
        public EmotionsViewModel(int recordId)
        {
            cropEmotions      = new WriteableBitmap[8];
            _subscriptionKey  = string.Empty;
            operationLocation = string.Empty;

            using (var db = new PrototypingContext())
            {
                //check for saving result emotion in the db
                recordModel = db.Records
                              .Include(r => r.ResultEmotion)
                              .ThenInclude(f => f.Scores)
                              .Single(r => r.RecordId == recordId);
            }

            //GoBack Navigation
            RegisterGoBackEventHandlers();
        }
コード例 #21
0
        private void DoneFunc()
        {
            using (var db = new PrototypingContext())
            {
                Record recod = db.Records.Add(new Record()
                {
                    UserId = userId
                }).Entity;
                db.RecordSettings.Add(new RecordSettings()
                {
                    RecordId    = recod.RecordId,
                    FrontCamera = _fronCameraIsOn,
                    Touches     = _touchesIsOn
                });
                db.SaveChanges();
            }

            ((Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content).Navigate(typeof(ReviewPrototypePage), userId);
        }
コード例 #22
0
 private void GoToLookEmotions()
 {
     Windows.UI.Xaml.Controls.Frame frame = (Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content;
     using (var db = new PrototypingContext())
     {
         if (prototypeId >= 0)
         {
             frame.Navigate(typeof(SummaryEmotionsPage), db.Prototypes.Single(p => p.PrototypeId == prototypeId));
         }
         if (userId >= 0)
         {
             frame.Navigate(typeof(SummaryEmotionsPage), db.Users.Single(u => u.UserId == userId));
         }
         if (RecordModel != null)
         {
             frame.Navigate(typeof(EmotionsPage), RecordModel.RecordId);
         }
     }
 }
コード例 #23
0
        private async Task <ObservableCollection <RecordScreenModel> > HeatingScreens(List <RecordScreenModel> screens)
        {
            ObservableCollection <RecordScreenModel> result = new ObservableCollection <RecordScreenModel>();

            using (var db = new PrototypingContext())
            {
                User user = db.Users.Single(u => u.UserId == RecordModel.UserId);
                await db.Entry(user)
                .Reference(u => u.Prototype)
                .LoadAsync();

                string prototypeName = user.Prototype.Name + "_" + user.PrototypeId;
                string userName      = user.Name + "_" + user.UserId;
                string recordName    = "Record_" + RecordModel.RecordId;

                StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(prototypeName, CreationCollisionOption.OpenIfExists); //PrototypeName + Id

                StorageFolder userFolder = await prototypeFolder.CreateFolderAsync(userName, CreationCollisionOption.OpenIfExists);                               //UserName + Id

                StorageFolder recordFolder = await userFolder.CreateFolderAsync(recordName, CreationCollisionOption.OpenIfExists);

                foreach (RecordScreenModel screen in screens)
                {
                    screen.HeatMapScreen = await HeatMapFunctions.CreateProcessHeatMap(screen.OriginalScreen, screen.ListPoints);

                    result.Add(screen);

                    string[] screenPaths = await SaveImagesInStorage(screen.OriginalScreen, screen.HeatMapScreen, recordFolder); //saving images in prototype -> user -> record path

                    RecordScreen rScreen = new RecordScreen()
                    {
                        RecordId             = RecordModel.RecordId,
                        Points               = screen.ListPoints,
                        UriPage              = screen.UriPage,
                        PathToOriginalScreen = screenPaths[0],
                        PathToHeatMapScreen  = screenPaths[1]
                    };
                    db.RecordScreens.Add(rScreen);
                    db.SaveChanges();
                }
            }
            return(result);
        }
コード例 #24
0
        private async Task <VideoAggregateRecognitionResult> UploadAndDetectEmotions(StorageFile videoFile)
        {
            VideoAggregateRecognitionResult aggResult            = null;
            EmotionServiceClient            emotionServiceClient = new EmotionServiceClient(_subscriptionKey);

            try
            {
                using (Stream videoFileStream = await videoFile.OpenStreamForReadAsync()) //File.OpenRead(videoFilePath)
                {
                    RingText = "Uploading video...";
                    byte[] bytesVideo;
                    using (var memoryStream = new MemoryStream())
                    {
                        await videoFileStream.CopyToAsync(memoryStream);

                        bytesVideo = memoryStream.ToArray();
                    }
                    //get operation id on service
                    operationLocation = await UploadEmotion(bytesVideo);

                    //save operation-location
                    using (var db = new PrototypingContext())
                    {
                        Record record = db.Records.Single(r => r.RecordId == recordModel.RecordId);
                        record.OperationLocation = operationLocation;
                        db.SaveChanges();
                        recordModel.OperationLocation = operationLocation;
                    }
                    //get result emotions from id operation
                    aggResult = await DetectEmotion(operationLocation);
                }
            }
            catch (Exception)
            {
                await ErrorMessageDialog("Oops, error. Check your internet connection.");

                GoBackFunc();
            }


            return(aggResult);
        }
コード例 #25
0
        private async void RemoveFunc()
        {
            using (var db = new PrototypingContext())
            {
                try
                {
                    StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(PrototypeModel.Name + "_" + PrototypeModel.PrototypeId);

                    await prototypeFolder.DeleteAsync();
                }
                catch (System.IO.FileNotFoundException)
                {
                    System.Diagnostics.Debug.WriteLine("Prototype folder not found");
                }

                db.Prototypes.Remove(PrototypeModel);
                db.SaveChanges();
            }
            ((Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content).Navigate(typeof(PrototypesPage));
        }
コード例 #26
0
 private async void SaveFunc()
 {
     if (!NameText.Equals("") && !BiographyText.Equals(""))
     {
         using (var db = new PrototypingContext())
         {
             User findUser = db.Users.Single(u => u.UserId == user.UserId);
             findUser.Name      = NameText;
             findUser.Biography = BiographyText;
             db.Users.Update(findUser);
             db.SaveChanges();
         }
         GoBackFunc();
     }
     else
     {
         var message = new MessageDialog("Please fill in all the fields.");
         await message.ShowAsync();
     }
 }
コード例 #27
0
        public async Task DeletePrototype(Prototype prototype)
        {
            using (var db = new PrototypingContext())
            {
                Prototype findPrototype = db.Prototypes.Single(p => p.PrototypeId == prototype.PrototypeId);
                try
                {
                    StorageFolder prototypeFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(findPrototype.Name + "_" + findPrototype.PrototypeId);

                    await prototypeFolder.DeleteAsync();
                }
                catch (System.IO.FileNotFoundException)
                {
                    System.Diagnostics.Debug.WriteLine("Prototype folder not found");
                }

                db.Prototypes.Remove(findPrototype);
                db.SaveChanges();
            }
            UpdateGroups();
        }
コード例 #28
0
 private async void SaveFunc()
 {
     if (!UrlText.Equals("") && !NameText.Equals("") && !DescriptionText.Equals(""))
     {
         using (var db = new PrototypingContext())
         {
             Prototype findPrototype = db.Prototypes.Single(p => p.PrototypeId == prototype.PrototypeId);
             findPrototype.Url         = UrlText;
             findPrototype.Name        = NameText;
             findPrototype.Description = DescriptionText;
             db.Prototypes.Update(findPrototype);
             db.SaveChanges();
         }
         GoBackFunc();
     }
     else
     {
         var message = new MessageDialog("Please fill in all the fields.");
         await message.ShowAsync();
     }
 }
コード例 #29
0
 private async void CreateFunc()
 {
     if (!NameText.Equals("") && !BiographyText.Equals(""))
     {
         using (var db = new PrototypingContext())
         {
             db.Users.Add(new User()
             {
                 Name        = NameText,
                 Biography   = BiographyText,
                 AddedDate   = DateTime.Now,
                 PrototypeId = prototypeId
             });
             db.SaveChanges();
         }
         GoBackFunc();
     }
     else
     {
         var message = new MessageDialog("Please fill in all the fields.");
         await message.ShowAsync();
     }
 }
コード例 #30
0
 private async void CreateFunc()
 {
     if (!UrlText.Equals("") && !NameText.Equals("") && !DescriptionText.Equals(""))
     {
         using (var db = new PrototypingContext())
         {
             db.Prototypes.Add(new Prototype()
             {
                 Name        = NameText,
                 Url         = UrlText,
                 Description = DescriptionText,
                 CreatedDate = DateTime.Now
             });
             db.SaveChanges();
         }
         GoBackFunc();
     }
     else
     {
         var message = new MessageDialog("Please fill in all the fields.");
         await message.ShowAsync();
     }
 }