Beispiel #1
0
        private void SendResult()                  // send all relevant statistics to database
        {
            LocalDataStorage.RefreshSaveFileXML(); // insure we have last progress in local storage
            Guid gamerGuid = LocalDataStorage.GetGamerGuid();

            if (gamerGuid == Guid.Empty) // completely new gamer
            {
                gamerGuid = Guid.NewGuid();
                ResultDO.SendGamerToDatabase(gamerGuid, GamerNameTextBox.Text); // send new gamer to database
            }
            else if (!ResultDO.IsGuidInDatabase(gamerGuid))                     // wrong Guid of gamer, which isn't in database
            {
                gamerGuid = Guid.NewGuid();
                ResultDO.SendGamerToDatabase(gamerGuid, GamerNameTextBox.Text); // send new gamer to database
            }

            ResultDO.SendResultToDatabaseAsync(
                gamerGuid,
                LocalDataStorage.GetLastCurrentScore(),
                GameBoard.GetBiggestTile()
                );
            this.Visibility = Visibility.Collapsed;
            LocalDataStorage.SetGamerGuid(gamerGuid); // insure, that program will recognize gamer next time

            LocalDataStorage.ClearSaveFileBeforeNewGame();
        }
Beispiel #2
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (MainWindowFrame.Source == new Uri("GamePage.xaml", UriKind.Relative)) // perform action only from game page
     {
         LocalDataStorage.RefreshSaveFileXML();                                // save progress before application is closed
     }
 }
Beispiel #3
0
        private void NewGameButton_Click(object sender, RoutedEventArgs e) // start new game
        {
            LocalDataStorage.ClearSaveFileBeforeNewGame();
            NavigationService nav = NavigationService.GetNavigationService(this);

            nav.Navigate(new Uri("GamePage.xaml", UriKind.RelativeOrAbsolute));
        }
Beispiel #4
0
        // ------[ UPDATE ]------
        public void OnUpdate()
        {
            if (LocalDataStorage.GetFileExists(logoLocation))
            {
                try
                {
                    FileInfo imageInfo = new FileInfo(logoLocation);
                    if (lastLogoWriteTime < imageInfo.LastWriteTime)
                    {
                        byte[] data = null;

                        if (LocalDataStorage.ReadFile(logoLocation, out data))
                        {
                            logoTexture       = IOUtilities.ParseImageData(data);
                            lastLogoWriteTime = imageInfo.LastWriteTime;
                            isRepaintRequired = true;
                        }
                    }
                }
                catch (Exception e)
                {
                    Debug.LogWarning("[mod.io] Unable to read updates to the logo image file.\n\n"
                                     + Utility.GenerateExceptionDebugString(e));
                }
            }
        }
Beispiel #5
0
        private void GameBoardInit()
        {
            PrepareGameBoard(GAME_BOARD_SIZE);            // prepare empty gameboard
            GameBoard.gameBoardGrid = GetGameBoardGrid(); // make reference on gameboard grid in GameBoard class
            switch (LocalDataStorage.GetGameState())
            {
            // continue game
            case GameBoard.GameState.InProgress:
            case GameBoard.GameState.Paused:
                GameBoard.AddTiles(LocalDataStorage.GetTileMatrix());     // get tile's matrix from local storage
                break;

            // start new game
            default:
                LocalDataStorage.ClearSaveFileBeforeNewGame();
                GameBoard.AddTiles(STARTUP_TILE_COUNT);     // randomly add specified number of tiles on gameboard
                GameBoard.SetGameStateNewGame();
                break;
            }
            GameBoard.SetGameStateInProgress();                                                                   // change game state on "InProgress"

            GamePageViewModel.InitMoveCommandsInWindow();                                                         // add move commands

            GetGamePageResourceDictionary()["BestScore"]    = GameBoard.ScoreFormat(GameBoard.GetBestScore());    // fulfill best score
            GetGamePageResourceDictionary()["CurrentScore"] = GameBoard.ScoreFormat(GameBoard.GetCurrentScore()); // fulfill current score
            LocalDataStorage.RefreshSaveFileXML();
        }
Beispiel #6
0
        private static ITestExecutor CreateTestExecutor(Options options)
        {
            var testExecutionOptions = new TestExecutionOptions(
                xunitPath: options.XunitPath,
                procDumpInfo: options.UseProcDump ? GetProcDumpInfo(options) : null,
                outputDirectory: options.TestResultXmlOutputDirectory,
                trait: options.Trait,
                noTrait: options.NoTrait,
                useHtml: options.UseHtml,
                test64: options.Test64,
                testVsi: options.TestVsi);
            var processTestExecutor = new ProcessTestExecutor(testExecutionOptions);

            if (!options.UseCachedResults)
            {
                return(processTestExecutor);
            }

            // The web caching layer is still being worked on.  For now want to limit it to Roslyn developers
            // and Jenkins runs by default until we work on this a bit more.  Anyone reading this who wants
            // to try it out should feel free to opt into this.
            IDataStorage dataStorage = new LocalDataStorage();

            if (CanUseWebStorage())
            {
                dataStorage = new WebDataStorage();
            }

            return(new CachingTestExecutor(processTestExecutor, dataStorage));
        }
Beispiel #7
0
        public static void TryAgain() // refresh game board
        {
            GameBoard.SetGameStateNewGame();
            NavigationService nav = NavigationService.GetNavigationService(GamePage.GetGamePageInstance());

            nav.Refresh();
            LocalDataStorage.RefreshSaveFileXML();
        }
Beispiel #8
0
        private void MainMenuButton_Click(object sender, RoutedEventArgs e) // navigate to main menu page
        {
            NavigationService nav = NavigationService.GetNavigationService(this);

            nav.Navigate(new Uri("MainMenuPage.xaml", UriKind.RelativeOrAbsolute));
            GameBoard.SetGameStatePaused();
            LocalDataStorage.RefreshSaveFileXML();
        }
Beispiel #9
0
 public static void SetGameStateInProgress()
 {
     if (CurrentGameState != GameState.GameOver) // Game State "InProgress" can't be set after GameOver
     {
         CurrentGameState = GameState.InProgress;
         currentScore     = LocalDataStorage.GetCurrentScore(); // load current score from local storage
         bestScore        = LocalDataStorage.GetBestScore();    // load best score from local storage
     }
 }
Beispiel #10
0
 public static long CheckAndRefreshBestScore() // refresh best score only in case it smaller current total score
 {
     if (currentScore > bestScore)
     {
         LocalDataStorage.SetBestScore(currentScore);
         return(bestScore = currentScore);
     }
     return(bestScore);
 }
        /// <summary>
        /// This method creates an object used to
        /// track changes for future replications.
        /// In this case, a delete trigger is added to a specified table.
        /// Note: If the data-source already has a process for tracking changes, this
        ///       method will only need to return a positive success in the method result
        /// </summary>
        /// <param name="methodInput">Method input used for the replication object.
        /// This is the name of the table that we need to extract.
        /// methodInput.Input.properties["ObjectName"]
        /// </param>
        /// <returns></returns>
        public MethodResult InitReplicationObject(MethodInput methodInput)
        {
            MethodResult methodResult = null;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(
                       Globals.ConnectorName, "InitReplication"))
            {
                //First ensure the change history table exists
                MethodResult initReplicationResult = InitReplication();

                //If the replication table already exist then
                //our work here is done and no other action is required
                if (initReplicationResult.Success)
                {
                    string tableName =
                        GetPropertyValueName("EntityName", methodInput.Input.Properties);
                    string triggerName =
                        string.Format("{0}_Deleted_TRG", tableName);

                    if (CheckForTrigger(triggerName, tableName) == false)
                    {
                        //Use the ConnectorApi provided local data storage to retrieve
                        //and read the sql scripts contents
                        LocalDataStorage localDataStorage    = new LocalDataStorage();
                        string           deleteTriggerString =
                            localDataStorage.ReadData(TriggerFileName);

                        if (string.IsNullOrWhiteSpace(deleteTriggerString))
                        {
                            throw new InvalidExecuteOperationException(string.Format("Unable to locate file: {0}", TriggerFileName));
                        }

                        string query = string.Format(deleteTriggerString, tableName);
                        //Execute the query to create the change history table.
                        _dataAccess.ExecuteNonQuery(query);
                    }

                    //If there were no errors in processing then
                    //just set the Success for the method result to true.
                    methodResult = new MethodResult {
                        Success = true
                    };
                }
                else
                {
                    methodResult = SetErrorMethodResult(ErrorCodes.InitReplication.Number,
                                                        ErrorCodes.InitReplication.Description);
                }
            }

            return(methodResult);
        }
Beispiel #12
0
 public static void RemoveAllInstalledMods()
 {
     if (LocalDataStorage.DeleteDirectory(PluginSettings.INSTALLATION_DIRECTORY))
     {
         Debug.Log("[mod.io] Mod Installation Data removed.");
     }
     else
     {
         Debug.Log("[mod.io] Failed to removed installed mods.");
     }
 }
Beispiel #13
0
 public static void ClearCachedGameProfile()
 {
     if (LocalDataStorage.DeleteFile(CacheClient.gameProfileFilePath))
     {
         Debug.Log("[mod.io] Cached Game Data Deleted.");
     }
     else
     {
         Debug.Log("[mod.io] Failed to delete Cached Game Data.");
     }
 }
Beispiel #14
0
 public static void ClearCache()
 {
     if (LocalDataStorage.DeleteDirectory(PluginSettings.CACHE_DIRECTORY))
     {
         Debug.Log("[mod.io] Cache Cleared.");
     }
     else
     {
         Debug.Log("[mod.io] Failed to clear cache.");
     }
 }
Beispiel #15
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     // show or hide continue button
     if (LocalDataStorage.GetGameState() == GameBoard.GameState.InProgress || LocalDataStorage.GetGameState() == GameBoard.GameState.Paused)
     {
         ContinueButton.Visibility = Visibility.Visible;
     }
     else
     {
         ContinueButton.Visibility = Visibility.Collapsed;
     }
 }
Beispiel #16
0
        private Texture2D GetGalleryImageByIndex(int index)
        {
            string imageFileName             = GetGalleryImageFileName(index);
            GalleryImageLocator imageLocator = null;

            if (this.profile != null &&
                this.profile.media != null)
            {
                imageLocator = this.profile.media.GetGalleryImageWithFileName(imageFileName);
            }

            Texture2D texture;

            if (String.IsNullOrEmpty(imageFileName))
            {
                return(null);
            }
            // - Get -
            else if (this.textureCache.TryGetValue(imageFileName, out texture))
            {
                return(texture);
            }
            // - LoadOrDownload -
            else if (imageLocator != null)
            {
                this.textureCache.Add(imageFileName, EditorImages.LoadingPlaceholder);

                ModManager.GetModGalleryImage(this.profile.id,
                                              imageLocator,
                                              IMAGE_PREVIEW_SIZE,
                                              (t) => { this.textureCache[imageFileName] = t; isRepaintRequired = true; },
                                              null);

                return(this.textureCache[imageFileName]);
            }
            // - Load -
            else
            {
                string imageSource = GetGalleryImageSource(index);

                byte[]    data      = null;
                Texture2D imageData = null;

                if (LocalDataStorage.ReadFile(imageSource, out data))
                {
                    imageData = IOUtilities.ParseImageData(data);
                }

                this.textureCache.Add(imageFileName, imageData);

                return(this.textureCache[imageFileName]);
            }
        }
Beispiel #17
0
        public static void ClearCachedModData()
        {
            string modDir = IOUtilities.CombinePath(PluginSettings.CACHE_DIRECTORY, "mods");

            if (LocalDataStorage.DeleteDirectory(modDir))
            {
                Debug.Log("[mod.io] Cached Mod Data Deleted.");
            }
            else
            {
                Debug.Log("[mod.io] Failed to clear cached Mod Data.");
            }
        }
Beispiel #18
0
        // ------[ INITIALIZATION ]------
        public void OnEnable(SerializedProperty serializedEditableModProfile, ModProfile baseProfile, UserProfile user)
        {
            this.profile           = baseProfile;
            this.youTubeURLsProp   = serializedEditableModProfile.FindPropertyRelative("youTubeURLs");
            this.sketchfabURLsProp = serializedEditableModProfile.FindPropertyRelative("sketchfabURLs");
            this.galleryImagesProp = serializedEditableModProfile.FindPropertyRelative("galleryImageLocators");

            this.isYouTubeExpanded   = false;
            this.isSketchFabExpanded = false;
            this.isImagesExpanded    = false;

            // Initialize textureCache
            int arraySize = galleryImagesProp.FindPropertyRelative("value").arraySize;

            this.textureCache = new Dictionary <string, Texture2D>(arraySize);
            for (int i = 0;
                 i < arraySize;
                 ++i)
            {
                string imageFileName = GetGalleryImageFileName(i);
                string imageURL      = GetGalleryImageSource(i);

                if (!String.IsNullOrEmpty(imageFileName) &&
                    !String.IsNullOrEmpty(imageURL))
                {
                    GalleryImageLocator imageLocator = baseProfile.media.GetGalleryImageWithFileName(imageFileName);
                    this.textureCache[imageFileName] = EditorImages.LoadingPlaceholder;

                    if (imageLocator != null)
                    {
                        ModManager.GetModGalleryImage(baseProfile.id,
                                                      imageLocator,
                                                      IMAGE_PREVIEW_SIZE,
                                                      (t) => { this.textureCache[imageFileName] = t; isRepaintRequired = true; },
                                                      null);
                    }
                    else
                    {
                        byte[] data    = null;
                        bool   success = false;

                        success = LocalDataStorage.ReadFile(imageURL, out data);

                        if (success)
                        {
                            this.textureCache[imageFileName] = IOUtilities.ParseImageData(data);
                        }
                    }
                }
            }
        }
Beispiel #19
0
 private UserOperHttpDownloadDealer()
 {
     _key = Guid.NewGuid().ToString();
     m_LocalDataStorage = LocalDataStorage.Current;
     m_controler        = new HttpDownloadControler(_key, MAX_COUNT, ControlName);
     m_controler.GetNextWairForDownloadResource += () =>
     {
         return(m_LocalDataStorage.GetNextWairForDownloadAutoResource());
     };
     m_controler.OnUpdateStatusCallBack += (obj, e) =>
     {
         m_LocalDataStorage.UpdateAutoResourceStatus(e.DownloadResource.ResourceInfo.DatabaseID, e.DownloadStatus);
     };
 }
Beispiel #20
0
        private async Task PrepareGamerNameTextBox() // handling of gamer name textbox
        {
            Guid gamerGuid = LocalDataStorage.GetGamerGuid();

            if (await ResultDO.IsGuidInDatabaseAsync(gamerGuid))
            {
                GamerNameTextBox.Text = await ResultDO.GetGamerNameByGuidAsync(gamerGuid); // get gamer name from database using Guid

                GamerNameTextBox.IsEnabled = false;
            }
            else // allow gamer to add new name in text box
            {
                GamerNameTextBox.IsEnabled = true;
                this.Resources["GamerNamePlaceholderText"] = "Your name...";
            }
        }
        /// <summary>
        /// This method defines the process for tracking changes to data.
        /// This particular example shows one way how this operation may work.
        /// Note: A seperate method will create triggers for each table that will fill this table with deletions.
        /// Note: If the data-source already has a process for tracking changes, this
        ///       method will only need to return a positive success in the method result
        /// </summary>
        /// <returns></returns>
        public MethodResult InitReplication()
        {
            MethodResult methodResult = null;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(
                       Globals.ConnectorName, "InitReplication"))
            {
                //First retrieve the object definition of the
                //default table that is used for replication.
                MethodInput objectDefinitionInput = new MethodInput();
                objectDefinitionInput.Input.Properties.Add(
                    "ObjectName", "ScribeChangeHistory");
                MethodResult objectDefinitionResult =
                    GetObjectDefinition(objectDefinitionInput);

                //If the replication table already exist then our work
                //here is done. No other action is required.
                if (objectDefinitionResult.Success == false)
                {
                    //Use the Sribe-provided local data storage
                    //to retrieve and read the sql scripts contents.
                    LocalDataStorage localDataStorage = new LocalDataStorage();
                    string           query            =
                        localDataStorage.ReadData(ChangeHistoryFileName);

                    //Throw an error message if the file was not found
                    if (string.IsNullOrWhiteSpace(query))
                    {
                        throw new InvalidExecuteOperationException(string.Format("Unable to locate file: {0}", ChangeHistoryFileName));
                    }

                    //Execute the query to create the change history table.
                    _dataAccess.ExecuteNonQuery(query);
                }

                //If there were no errors in processing, then
                //set the Success for the method result to true.
                methodResult = new MethodResult {
                    Success = true
                };
            }

            return(methodResult);
        }
Beispiel #22
0
        public static void CreateAssetInstance()
        {
            ScriptableModProfile asset = ScriptableObject.CreateInstance <ScriptableModProfile>();

            int profileCount
                = LocalDataStorage.GetFiles(Application.dataPath, "NewModProfile*.asset", false).Count;

            string fileNameAddition = (profileCount > 0
                                       ? " (" + profileCount.ToString() + ")"
                                       : "");

            AssetDatabase.CreateAsset(asset, "Assets/NewModProfile" + fileNameAddition + ".asset");
            AssetDatabase.SaveAssets();

            EditorUtility.FocusProjectWindow();

            Selection.activeObject = asset;
        }
Beispiel #23
0
        // ------[ INITIALIZATION ]------
        public void OnEnable(SerializedProperty serializedEditableModProfile, ModProfile baseProfile, UserProfile user)
        {
            this.editableProfileProperty = serializedEditableModProfile;
            this.profile       = baseProfile;
            this.isUndoEnabled = (baseProfile != null);

            isTagsExpanded = false;
            isKVPsExpanded = false;

            // - Game Profile -
            ModManager.GetGameProfile((g) => { this.gameProfile = g; isRepaintRequired = true; },
                                      null);

            // - Configure Properties -
            logoProperty = editableProfileProperty.FindPropertyRelative("logoLocator");

            // - Load Textures -
            if (logoProperty.FindPropertyRelative("isDirty").boolValue == true)
            {
                logoLocation = logoProperty.FindPropertyRelative("value.url").stringValue;

                byte[] data = null;

                if (LocalDataStorage.ReadFile(logoLocation, out data))
                {
                    lastLogoWriteTime = (new FileInfo(logoLocation)).LastWriteTime;
                    logoTexture       = IOUtilities.ParseImageData(data);
                }
            }
            else if (profile != null)
            {
                logoLocation = profile.logoLocator.GetSizeURL(LOGO_PREVIEW_SIZE);
                logoTexture  = EditorImages.LoadingPlaceholder;

                ModManager.GetModLogo(profile, LOGO_PREVIEW_SIZE,
                                      (t) => { logoTexture = t; isRepaintRequired = true; },
                                      null);
            }
            else
            {
                logoLocation = string.Empty;
                logoTexture  = null;
            }
        }
Beispiel #24
0
        private static ITestExecutor CreateTestExecutor(Options options)
        {
            var processTestExecutor = new ProcessTestExecutor(options);

            if (!options.UseCachedResults)
            {
                return(processTestExecutor);
            }

            // The web caching layer is still being worked on.  For now want to limit it to Roslyn developers
            // and Jenkins runs by default until we work on this a bit more.  Anyone reading this who wants
            // to try it out should feel free to opt into this.
            IDataStorage dataStorage = new LocalDataStorage();

            if (CanUseWebStorage())
            {
                dataStorage = new WebDataStorage();
            }

            return(new CachingTestExecutor(options, processTestExecutor, dataStorage));
        }
Beispiel #25
0
        protected virtual void LayoutProfileInitialization()
        {
            EditorGUILayout.LabelField("Initialize Mod Profile");

            // ---[ DISPLAY ]---
            EditorGUILayout.Space();

            if (GUILayout.Button("Create New"))
            {
                EditorApplication.delayCall += () =>
                {
                    ScriptableModProfile smp = this.target as ScriptableModProfile;
                    Undo.RecordObject(smp, "Initialize Mod Profile");

                    smp.modId = 0;
                    smp.editableModProfile = new EditableModProfile();

                    OnDisable();
                    OnEnable();
                    isRepaintRequired = true;
                };
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("---- OR ----");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Load Existing Profile");

            if (user == null)
            {
                EditorGUILayout.HelpBox("Log in required to load existing mods",
                                        MessageType.Info);
                if (GUILayout.Button("Log In to mod.io"))
                {
                    LoginWindow.GetWindow <LoginWindow>("Login to mod.io");
                }
            }
            else if (modOptions.Length > 0)
            {
                using (new EditorGUI.DisabledScope(isModListLoading))
                {
                    modInitializationOptionIndex = EditorGUILayout.Popup("Select Mod", modInitializationOptionIndex, modOptions);
                    if (GUILayout.Button("Load"))
                    {
                        ModProfile profile = modList[modInitializationOptionIndex];
                        EditorApplication.delayCall += () =>
                        {
                            ScriptableModProfile smp = this.target as ScriptableModProfile;
                            Undo.RecordObject(smp, "Initialize Mod Profile");

                            smp.modId = profile.id;
                            smp.editableModProfile = EditableModProfile.CreateFromProfile(profile);

                            string smpFilePath = AssetDatabase.GetAssetPath(smp);
                            string smpDir      = Path.GetDirectoryName(smpFilePath);

                            int profileCount
                                = LocalDataStorage.GetFiles(smpDir, profile.name + "*.asset", false).Count;

                            string fileNameAddition = (profileCount > 0
                                                       ? " (" + profileCount.ToString() + ")"
                                                       : "");

                            AssetDatabase.RenameAsset(smpFilePath, profile.name + fileNameAddition + ".asset");

                            OnDisable();
                            OnEnable();
                            isRepaintRequired = true;
                        };
                    }
                }
            }
            else
            {
                EditorGUILayout.HelpBox("No loadable mod profiles detected.",
                                        MessageType.Info);
            }
        }
Beispiel #26
0
 public PeopleController(LocalDataStorage data)
 {
     this.data = data;
 }
Beispiel #27
0
        /// <summary>
        /// This method defines the process for tracking changes to data.
        /// This particular example shows one way how this operation may work. 
        /// Note: A seperate method will create triggers for each table that will fill this table with deletions.
        /// Note: If the data-source already has a process for tracking changes, this 
        ///       method will only need to return a positive success in the method result
        /// </summary>
        /// <returns></returns>
        public MethodResult InitReplication()
        {
            MethodResult methodResult = null;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(
                Globals.ConnectorName, "InitReplication"))
            {
                //First retrieve the object definition of the
                //default table that is used for replication.
                MethodInput objectDefinitionInput = new MethodInput();
                objectDefinitionInput.Input.Properties.Add(
                    "ObjectName", "ScribeChangeHistory");
                MethodResult objectDefinitionResult =
                    GetObjectDefinition(objectDefinitionInput);

                //If the replication table already exist then our work
                //here is done. No other action is required.
                if (objectDefinitionResult.Success == false)
                {
                    //Use the Sribe-provided local data storage
                    //to retrieve and read the sql scripts contents.
                    LocalDataStorage localDataStorage = new LocalDataStorage();
                    string query =
                        localDataStorage.ReadData(ChangeHistoryFileName);

                    //Throw an error message if the file was not found
                    if (string.IsNullOrWhiteSpace(query))
                    {
                        throw new InvalidExecuteOperationException(string.Format("Unable to locate file: {0}", ChangeHistoryFileName));
                    }

                    //Execute the query to create the change history table.
                    _dataAccess.ExecuteNonQuery(query);
                }

                //If there were no errors in processing, then
                //set the Success for the method result to true.
                methodResult = new MethodResult { Success = true };
            }

            return methodResult;
        }
Beispiel #28
0
        /// <summary>
        /// This method creates an object used to 
        /// track changes for future replications.
        /// In this case, a delete trigger is added to a specified table. 
        /// Note: If the data-source already has a process for tracking changes, this 
        ///       method will only need to return a positive success in the method result
        /// </summary>
        /// <param name="methodInput">Method input used for the replication object.
        /// This is the name of the table that we need to extract.
        /// methodInput.Input.properties["ObjectName"]
        /// </param>
        /// <returns></returns>
        public MethodResult InitReplicationObject(MethodInput methodInput)
        {
            MethodResult methodResult = null;

            // Use LogMethodExecution to add entry and exit tracing to a method.
            // When wrapped in a using statement, the exit point
            // is written during garbage collection.
            using (new LogMethodExecution(
                Globals.ConnectorName, "InitReplication"))
            {
                //First ensure the change history table exists
                MethodResult initReplicationResult = InitReplication();

                //If the replication table already exist then
                //our work here is done and no other action is required
                if (initReplicationResult.Success)
                {
                    string tableName =
                         GetPropertyValueName("EntityName", methodInput.Input.Properties);
                    string triggerName =
                        string.Format("{0}_Deleted_TRG", tableName);

                    if (CheckForTrigger(triggerName, tableName) == false)
                    {
                        //Use the ConnectorApi provided local data storage to retrieve
                        //and read the sql scripts contents
                        LocalDataStorage localDataStorage = new LocalDataStorage();
                        string deleteTriggerString =
                            localDataStorage.ReadData(TriggerFileName);

                        if (string.IsNullOrWhiteSpace(deleteTriggerString))
                        {
                            throw new InvalidExecuteOperationException(string.Format("Unable to locate file: {0}", TriggerFileName));
                        }

                        string query = string.Format(deleteTriggerString, tableName);
                        //Execute the query to create the change history table.
                        _dataAccess.ExecuteNonQuery(query);
                    }

                    //If there were no errors in processing then
                    //just set the Success for the method result to true.
                    methodResult = new MethodResult { Success = true };
                }
                else
                {
                    methodResult = SetErrorMethodResult(ErrorCodes.InitReplication.Number,
                                                        ErrorCodes.InitReplication.Description);
                }
            }

            return methodResult;
        }
 public PeopleController(LocalDataStorage db)
 {
     this.db = db;
 }
Beispiel #30
0
        // - Image Locator Layouting -
        private void LayoutGalleryImageProperty(int elementIndex,
                                                SerializedProperty elementProperty)
        {
            bool   doBrowse      = false;
            bool   doClear       = false;
            string imageFileName = elementProperty.FindPropertyRelative("fileName").stringValue;
            string imageSource   = elementProperty.FindPropertyRelative("url").stringValue;

            // - Browse Field -
            EditorGUILayout.BeginHorizontal();
            doBrowse |= EditorGUILayoutExtensions.BrowseButton(imageSource,
                                                               new GUIContent("Image " + elementIndex));
            doClear = EditorGUILayoutExtensions.ClearButton();
            EditorGUILayout.EndHorizontal();

            // - Draw Texture -
            Texture2D imageTexture = GetGalleryImageByIndex(elementIndex);

            if (imageTexture != null)
            {
                EditorGUI.indentLevel += 2;
                EditorGUILayout.LabelField("File Name", imageFileName);
                Rect imageRect = EditorGUILayout.GetControlRect(false, 180.0f);
                imageRect = EditorGUI.IndentedRect(imageRect);
                EditorGUI.DrawPreviewTexture(new Rect(imageRect.x,
                                                      imageRect.y,
                                                      320.0f,
                                                      imageRect.height),
                                             imageTexture, null, ScaleMode.ScaleAndCrop);
                doBrowse |= GUI.Button(imageRect, "", GUI.skin.label);
                EditorGUI.indentLevel -= 2;
            }

            if (doBrowse)
            {
                EditorApplication.delayCall += () =>
                {
                    string path = EditorUtility.OpenFilePanelWithFilters("Select Gallery Image",
                                                                         "",
                                                                         ModMediaViewPart.IMAGE_FILE_FILTER);

                    bool   success = false;
                    byte[] data    = null;

                    success = LocalDataStorage.ReadFile(path, out data);

                    Texture2D newTexture = null;
                    if (success)
                    {
                        newTexture = IOUtilities.ParseImageData(data);
                    }

                    if (newTexture != null)
                    {
                        string fileName = GenerateUniqueFileName(path);

                        elementProperty.FindPropertyRelative("url").stringValue      = path;
                        elementProperty.FindPropertyRelative("fileName").stringValue = fileName;

                        galleryImagesProp.FindPropertyRelative("isDirty").boolValue = true;
                        galleryImagesProp.serializedObject.ApplyModifiedProperties();

                        textureCache.Add(fileName, newTexture);
                    }
                };
            }
            if (doClear)
            {
                elementProperty.FindPropertyRelative("url").stringValue      = string.Empty;
                elementProperty.FindPropertyRelative("fileName").stringValue = string.Empty;

                galleryImagesProp.FindPropertyRelative("isDirty").boolValue = true;
                galleryImagesProp.serializedObject.ApplyModifiedProperties();
            }
        }
Beispiel #31
0
        private void ModProfileSubmissionSucceeded(ModProfile updatedProfile,
                                                   string profileFilePath)
        {
            if (updatedProfile == null)
            {
                isAwaitingServerResponse = false;
                return;
            }


            uploadFailedMessage = null;

            // Update ScriptableModProfile
            profile.modId = updatedProfile.id;
            profile.editableModProfile = EditableModProfile.CreateFromProfile(updatedProfile);
            EditorUtility.SetDirty(profile);
            AssetDatabase.SaveAssets();

            // Upload Build
            #if UPLOAD_MOD_BINARY_AS_DIRECTORY
            if (LocalDataStorage.GetDirectoryExists(buildFilePath))
            #else
            if (LocalDataStorage.GetFileExists(buildFilePath))
            #endif
            {
                Action <WebRequestError> onSubmissionFailed = (e) =>
                {
                    EditorUtility.DisplayDialog("Upload Failed",
                                                "Failed to upload the mod build to the server.\n"
                                                + e.displayMessage,
                                                "Close");

                    uploadFailedMessage = e.displayMessage;
                    if (e.fieldValidationMessages != null &&
                        e.fieldValidationMessages.Count > 0)
                    {
                        foreach (var kvp in e.fieldValidationMessages)
                        {
                            uploadFailedMessage += "\n [" + kvp.Key + "]: " + kvp.Value;
                        }
                    }

                    isAwaitingServerResponse = false;
                    Repaint();
                };

                #if UPLOAD_MOD_BINARY_AS_DIRECTORY
                ModManager.UploadModBinaryDirectory(profile.modId,
                                                    buildProfile,
                                                    buildFilePath,
                                                    true,
                                                    mf => NotifySubmissionSucceeded(updatedProfile.name,
                                                                                    updatedProfile.profileURL),
                                                    onSubmissionFailed);
                #else
                ModManager.UploadModBinary_Unzipped(profile.modId,
                                                    buildProfile,
                                                    buildFilePath,
                                                    true,
                                                    mf => NotifySubmissionSucceeded(updatedProfile.name,
                                                                                    updatedProfile.profileURL),
                                                    onSubmissionFailed);
                #endif
            }
            else
            {
                NotifySubmissionSucceeded(updatedProfile.name, updatedProfile.profileURL);
            }
        }
Beispiel #32
0
        // ------[ LOGIN PROMPT ]------
        protected virtual void LayoutSubmissionFields()
        {
            using (new EditorGUI.DisabledScope(isAwaitingServerResponse))
            {
                // - Account Header -
                EditorGUILayout.BeginHorizontal();
                {
                    if (this.user == null)
                    {
                        EditorGUILayout.LabelField("Not logged in to mod.io");
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Log In"))
                        {
                            LoginWindow.GetWindow <LoginWindow>("Login to mod.io");
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Logged in as:  " + this.user.username);
                        GUILayout.FlexibleSpace();
                        if (GUILayout.Button("Log Out"))
                        {
                            EditorApplication.delayCall += () =>
                            {
                                if (EditorDialogs.ConfirmLogOut(this.user.username))
                                {
                                    this.user = null;

                                    LocalUser.instance = new LocalUser();
                                    LocalUser.Save();

                                    isAwaitingServerResponse = false;

                                    Repaint();
                                }
                            };
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

                // - Submission Section -
                if (!String.IsNullOrEmpty(uploadSucceededMessage))
                {
                    EditorGUILayout.HelpBox(uploadSucceededMessage,
                                            MessageType.Info);
                }
                else if (!String.IsNullOrEmpty(uploadFailedMessage))
                {
                    EditorGUILayout.HelpBox(uploadFailedMessage,
                                            MessageType.Error);
                }
                else if (profile == null)
                {
                    EditorGUILayout.HelpBox("Please select a mod profile as a the upload target.",
                                            MessageType.Info);
                }
                else if (profile.modId > 0)
                {
                    EditorGUILayout.HelpBox(profile.editableModProfile.name.value
                                            + " will be updated as used as the upload target on the server.",
                                            MessageType.Info);
                }
                else
                {
                    EditorGUILayout.HelpBox(profile.editableModProfile.name.value
                                            + " will be created as a new profile on the server.",
                                            MessageType.Info);
                }
                EditorGUILayout.Space();


                // TODO(@jackson): Support mods that haven't been downloaded?
                profile = EditorGUILayout.ObjectField("Mod Profile",
                                                      profile,
                                                      typeof(ScriptableModProfile),
                                                      false) as ScriptableModProfile;

                // - Build Profile -
                using (new EditorGUI.DisabledScope(profile == null))
                {
                    EditorGUILayout.BeginHorizontal();
                    if (EditorGUILayoutExtensions.BrowseButton(buildFilePath, new GUIContent("Modfile")))
                    {
                        EditorApplication.delayCall += () =>
                        {
                                #if UPLOAD_MOD_BINARY_AS_DIRECTORY
                            string path = EditorUtility.OpenFolderPanel("Set Build Location",
                                                                        "",
                                                                        "ModBinary");
                                #else
                            string path = EditorUtility.OpenFilePanelWithFilters("Set Build Location",
                                                                                 "",
                                                                                 modBinaryFileExtensionFilters);
                                #endif

                            if (path.Length != 0)
                            {
                                buildFilePath = path;
                            }
                        };
                    }
                    if (EditorGUILayoutExtensions.ClearButton())
                    {
                        buildFilePath = string.Empty;
                    }
                    EditorGUILayout.EndHorizontal();

                    // - Build Profile -
                    #if UPLOAD_MOD_BINARY_AS_DIRECTORY
                    using (new EditorGUI.DisabledScope(!LocalDataStorage.GetDirectoryExists(buildFilePath)))
                    #else
                    using (new EditorGUI.DisabledScope(!LocalDataStorage.GetFileExists(buildFilePath)))
                    #endif
                    {
                        // - Version -
                        EditorGUI.BeginChangeCheck();
                        buildProfile.version.value = EditorGUILayout.TextField("Version",
                                                                               buildProfile.version.value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            buildProfile.version.isDirty = true;
                        }
                        // - Changelog -
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PrefixLabel("Changelog");
                        buildProfile.changelog.value = EditorGUILayoutExtensions.MultilineTextField(buildProfile.changelog.value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            buildProfile.changelog.isDirty = true;
                        }
                        // - Metadata -
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.PrefixLabel("Metadata");
                        buildProfile.metadataBlob.value = EditorGUILayoutExtensions.MultilineTextField(buildProfile.metadataBlob.value);
                        if (EditorGUI.EndChangeCheck())
                        {
                            buildProfile.metadataBlob.isDirty = true;
                        }
                    }

                    // TODO(@jackson): if(profile) -> show build list?
                    EditorGUILayout.Space();
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Upload to Server"))
                    {
                        UploadToServer();
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();
                }
            }
        }