public MainWindowViewModel()
        {
            Task.Factory.StartNew(() => Title = UIConfigServices.GetWindowTitle());
            Task.Factory.StartNew(
                () =>
            {
                var list   = new List <string>();
                var random = new Random();

                try
                {
                    list = new List <string>(FileServices.GetNames());
                }
                catch (Exception ex)
                {
                    Messenger.Default.Send(new NotificationMessage(ex.ToString()));
                }

                Names = new ObservableCollection <string>();

                while (list.Count > 0)
                {
                    var index = random.Next(0, list.Count - 1);
                    Names.Add(list.ElementAt(index));
                    list.RemoveAt(index);
                }
            }
                );
        }
Example #2
0
        //
        // GET: /File/
        public JsonResult Upload(string rootpath, string folder)
        {
            Message msg = new Message();

            if (Request.Files.Count > 0 && Request.Files[0] != null && !string.IsNullOrEmpty(Request.Files[0].FileName))
            {
                try
                {
                    string fileName = FileServices.Uploadfiles(rootpath, folder, Request.Files[0]);
                    msg.MessageStatus = "true";
                    msg.MessageInfo   = "上传成功";
                    msg.MessageUrl    = fileName;
                }
                catch (Exception ex)
                {
                    msg.MessageStatus = "false";
                    msg.MessageInfo   = "上传失败" + ex.Message;
                }
            }
            else
            {
                msg.MessageStatus = "false";
                msg.MessageInfo   = "未选择文件";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.CheckFileExists = true;
            openFileDialog.AddExtension    = true;
            openFileDialog.Multiselect     = true;
            openFileDialog.Filter          = "txt files (*.txt)|*.txt";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    DTO.File f = new DTO.File()
                    {
                        Path = openFileDialog.FileName
                    };
                    string fileContent = FileServices.ReadFile(f);
                    richTextBox1.Text = fileContent;
                }
                catch (Exception ex)
                {
                    richTextBox1.Text = string.Format("Exception : {0} ", ex.Message);
                }
            }
        }
    // Use this for initialization
    void Start()
    {
        IsUsingSlider = false;

        _timer              = 0;
        _cameraIsShifting   = false;
        _shiftEndPosition   = new Vector3(0, 0, -10);
        _shiftStartPosition = new Vector3(0, 0, -10);

        _camera                      = Camera.main;
        _lastScoreText               = GameObject.FindGameObjectWithTag("LastScoreText").GetComponent <Text>();
        _highScoreText               = GameObject.FindGameObjectsWithTag("HighScoreText");
        _sensitivitySlider           = GameObject.FindGameObjectWithTag("SensitivitySlider").GetComponent <Slider>();
        _ballSpeedSlider             = GameObject.FindGameObjectWithTag("BallSpeedSlider").GetComponent <Slider>();
        _controlSchemeToggleButtons  = GameObject.Find("ControlSchemeToggleButtons").transform.GetComponentsInChildren <Transform>();
        _controlSchemeDemoImages     = new GameObject[4];
        _controlSchemeDemoImages[0]  = GameObject.Find("FreeScheme");
        _controlSchemeDemoImages[1]  = GameObject.Find("PreciseScheme");
        _controlSchemeDemoImages[2]  = GameObject.Find("SliderScheme");
        _controlSchemeDemoImages[3]  = GameObject.Find("TapScheme");
        _muteSoundEffectsButtonImage = GameObject.Find("MuteSoundEffectsButton").GetComponent <Image>();
        _muteMusicButtonImage        = GameObject.Find("MuteMusicButton").GetComponent <Image>();
        _socialMenus                 = GameObject.Find("SocialMenus");

        _shiftStartPosition        = new Vector3(GameVariablesScript.ScreenToStartOn * 1080, 0, -10);
        _camera.transform.position = _shiftStartPosition;

        FileServices.LoadGame();

        BackgroundMusicScript.SetBackgroundMusicMute(GameVariablesScript.MusicMuted);

        SetUiFromGameVariables();
    }
Example #5
0
 public FileOp()
 {
     _target    = Settings.Default.DefaultRepo;
     Destiny    = new FileServices();
     XmlService = new XmlService();
     Guid       = new FileNameGenerator();
 }
Example #6
0
        public ActionResult _GetFiles(int entityId, string entityType, string fileType, string langCode)
        {
            var files = FileServices.GetFilesByEntity(entityId, entityType, null, langCode).OrderByDescending(x => x.CreatedOn).ToList();

            var isCancelled = false;

            if (entityType == EntityType.Edition.GetDescription())
            {
                var edition = EditionServices.GetEditionById(entityId, Constants.ValidEventTypesForCed);
                isCancelled = edition.IsCancelled();
            }

            var model = new FilesEditModel
            {
                EntityId        = entityId,
                EntityType      = entityType.ToEnumFromDescription <EntityType>(),
                EditionFileType = fileType.ToEnumFromDescription <EditionFileType>(),
                LanguageCode    = langCode,
                Files           = files,
                CurrentUser     = CurrentCedUser,
                IsCancelled     = isCancelled
            };

            return(PartialView("_EditionFiles", model));
        }
Example #7
0
        public FileResult GetImage(int?VesselId)
        {
            try
            {
                if (VesselId != null)
                {
                    FileServices fileServ  = new FileServices();
                    string       reference = string.Format("vessels/{0}/images/vesselimage-{0}.jpg", VesselId.ToString());
                    FileModel    fileData  = fileServ.GetFile(reference);
                    if (fileData != null)
                    {
                        var img = (MemoryStream)fileData.FileContent;
                        return(File(img.ToArray(), fileData.ContentType));
                    }
                }

                var        UrlImage = Server.MapPath("~/Content/Images/Barco-md.png");
                FileStream file     = new FileStream(UrlImage, FileMode.Open);
                return(File(file, "image/png"));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(null);
            }
        }
        public void TestForceCopyDelete()
        {
            string filename = "testfile_forced.txt";
            string filetext = "This is the file text. It is unique! " + Guid.NewGuid().ToString();

            File.WriteAllText(filename, filetext);
            File.SetAttributes(filename, FileAttributes.ReadOnly);
            MyAssert.ThrowsException(() => File.Delete(filename));
            Assert.IsTrue(File.ReadAllText(filename) == filetext);
            FileServices.ForceDelete(filename);
            Assert.IsFalse(File.Exists(filename));

            string copyname = "copy" + filename;
            string copytext = "It's a copy " + Guid.NewGuid().ToString();

            File.WriteAllText(filename, filetext);
            File.WriteAllText(copyname, copytext);
            File.SetAttributes(filename, FileAttributes.ReadOnly);
            MyAssert.ThrowsException(() => File.Copy(copyname, filename));
            Assert.IsTrue(File.ReadAllText(filename) == filetext);
            Assert.IsTrue(File.ReadAllText(copyname) == copytext);
            FileServices.ForceCopy(copyname, filename);
            Assert.IsTrue(File.ReadAllText(filename) == copytext);
            Assert.IsTrue(File.ReadAllText(copyname) == copytext);
        }
 public ToolsController(IWebHostEnvironment webHostEnvironment, ImageServices imageServices, FileServices fileServices, ILogger <ToolsController> logger)
 {
     this.webHostEnvironment = webHostEnvironment;
     this.imageServices      = imageServices;
     this.fileServices       = fileServices;
     this.logger             = logger;
 }
Example #10
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>

        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            TheCursor.Create(Content.Load <Texture2D>("ASCursor"), Content.Load <Texture2D>("CursorAim"), Content.Load <Texture2D>("CharacAim"), Color.White);


            // TODO: use this.Content to load your game content here

            List <String> TextureNames = FileServices.ReadFileLines(@"Files\TextureNames.txt");

            foreach (string TexName in TextureNames)
            {
                TextureHolder temp = new TextureHolder();
                temp.Texture  = Content.Load <Texture2D>(TexName);
                temp.Filename = TexName;
                TheContentHolder.Textures.Add(temp);
            }

            Areas.Create(TheContentHolder, graphics, TheCamera);

            List <string> WeaponLines = FileServices.ReadFileLines(@"Files\Weapons.txt");

            TheWeapons.Create(WeaponLines, TheContentHolder);

            //must make sure character spawns within normal camera boundaries
            TheMainCharacter.Create(150, 150, 0f, TheContentHolder.GetTexture("Man2"), TheContentHolder.GetTexture("Man_Aim2"), TheWeapons.WeaponList[0], TheCamera);
        }
 public BoardController(
     ForumServices forumServices,
     SearchServices searchServices,
     ThreadServices threadServices,
     PostServices postServices,
     PollServices pollServices,
     GlobalServices globalServices,
     IRepository <OnlineUser> onlineUserRepository,
     IRepository <OnlineGuest> onlineGuestRepository,
     IRepository <User> userRepository,
     UserServices usersServices,
     RoleServices roleServices,
     MessageServices messageServices,
     PermissionServices permissionServices,
     FileServices fileServices,
     User currentUser,
     Theme currentTheme)
 {
     _forumServices         = forumServices;
     _searchServices        = searchServices;
     _threadServices        = threadServices;
     _postServices          = postServices;
     _pollServices          = pollServices;
     _onlineUserRepository  = onlineUserRepository;
     _onlineGuestRepository = onlineGuestRepository;
     _userRepository        = userRepository;
     _userServices          = usersServices;
     _roleServices          = roleServices;
     _messageServices       = messageServices;
     _permissionServices    = permissionServices;
     _fileServices          = fileServices;
     _currentUser           = currentUser;
     _currentTheme          = currentTheme;
     SetTopBreadCrumb("Board");
 }
Example #12
0
        public async Task Update_Sponsor()
        {
            await AddNewSponsor();

            var sponsor = Context.Sponsors.FirstOrDefault();

            var file1     = File.OpenRead(@"Images\Blanco.png");
            var badgeFile = new StreamContent(file1);
            var formData  = new MultipartFormDataContent();

            formData.Add(badgeFile, nameof(NewSponsorCommand.ImageFile), $"NewImage.jpg");
            formData.Add(new StringContent("New Name"), nameof(NewSponsorCommand.Name));
            formData.Add(new StringContent("New Description"), nameof(NewSponsorCommand.Description));
            formData.Add(new StringContent("New SiteUrl"), nameof(NewSponsorCommand.SiteUrl));
            formData.Add(new StringContent("New Email"), nameof(NewSponsorCommand.Email));

            var response = await HttpClient.PutAsync($"/sponsors/{sponsor.Id}", formData);

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var oldLogoFileName = sponsor.LogoFileName;

            RefreshContext();
            sponsor = Context.Sponsors.FirstOrDefault();
            sponsor.Name.Should().Be("New Name");
            sponsor.Description.Should().Be("New Description");
            sponsor.SiteUrl.Should().Be("New SiteUrl");
            sponsor.Email.Should().Be("New Email");

            (await FileServices.GetAsync(oldLogoFileName, Api.Services.Container.Sponsors)).Should().BeNull();
            (await FileServices.GetAsync(sponsor.LogoFileName, Api.Services.Container.Sponsors)).Should().NotBeNull();
            await FileServices.DeleteAsync(sponsor.LogoFileName, Api.Services.Container.Sponsors);
        }
    public void SetControlScheme(int schemeNumber)
    {
        GameVariablesScript.ControlScheme = schemeNumber;

        SetControlSchemeUiFromGameVariables();

        FileServices.SaveGame();
    }
    public void ToggleMuteSounds()
    {
        GameVariablesScript.SoundEffectsMuted = !GameVariablesScript.SoundEffectsMuted;

        _muteSoundEffectsButtonImage.overrideSprite = GameVariablesScript.SoundEffectsMuted ? SoundEffectsOffImage : SoundEffectsOnImage;

        FileServices.SaveGame();
    }
Example #15
0
        public void ReadingFileTest_EmptyFile()
        {
            string expectedValue   = string.Empty;
            string filePath        = @"Data\TestFile2.txt";
            var    service         = new FileServices(filePath);
            string calculatedValue = service.ReadFile();

            Assert.AreEqual(calculatedValue, expectedValue);
        }
        public void TestFileVersion()
        {
            Version expectedVersion = new Version("9.8.7.6");
            var     actualVersion   = FileServices.GetFileVersionOfDll("MonolithicExtensions.UnitTest");

            Assert.IsTrue(actualVersion.Equals(expectedVersion));
            MyAssert.ThrowsException(() => FileServices.GetFileVersionOfDll("SomethingThatDoesntExist"));
            actualVersion = FileServices.GetOwnFileVersion();
        }
Example #17
0
 public UserController()
 {
     this._userServices  = new UserServices();
     this.fileServices   = new FileServices();
     this._emailServices = new EmailServices();
     //this._permissionServices = new PermissionServices();
     _log           = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
     _groupServices = new GroupServices();
 }
        /// <summary>
        /// Whenever the user wants to upload any picklist from another database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void settingLoadPicklistButton_TappedAsync(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
        {
            //Get local storage folder
            StorageFolder localFolder = await StorageFolder.GetFolderFromPathAsync(accessData.ProjectPath);

            //Create a file picker for sqlite
            var filesPicker = new Windows.Storage.Pickers.FileOpenPicker();

            filesPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Desktop;
            filesPicker.FileTypeFilter.Add(".sqlite");

            //Get users selected files
            StorageFile f = await filesPicker.PickSingleFileAsync();

            if (f != null)
            {
                // Create or overwrite file target file in local app data folder
                StorageFile fileToWrite = await localFolder.CreateFileAsync(f.Name, CreationCollisionOption.ReplaceExisting);

                //Copy else code won't be able to read it
                byte[] buffer = new byte[1024];
                using (BinaryWriter fileWriter = new BinaryWriter(await fileToWrite.OpenStreamForWriteAsync()))
                {
                    using (BinaryReader fileReader = new BinaryReader(await f.OpenStreamForReadAsync()))
                    {
                        long readCount = 0;
                        while (readCount < fileReader.BaseStream.Length)
                        {
                            int read = fileReader.Read(buffer, 0, buffer.Length);
                            readCount += read;
                            fileWriter.Write(buffer, 0, read);
                        }
                    }
                }

                //Connect to working database
                SQLiteConnection workingDBConnection = accessData.GetConnectionFromPath(DataAccess.DbPath);

                //Swap vocab
                accessData.DoSwapVocab(fileToWrite.Path, workingDBConnection);


                //Show end message
                var           loadLocalization = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
                ContentDialog addedLayerDialog = new ContentDialog()
                {
                    Title             = loadLocalization.GetString("SettingLoadPicklistProcessEndMessageTitle"),
                    Content           = loadLocalization.GetString("SettingLoadPicklistProcessEndMessage/Text"),
                    PrimaryButtonText = loadLocalization.GetString("SettingLoadPicklistProcessEndMessageOk")
                };

                ContentDialogResult cdr = await addedLayerDialog.ShowAsync();

                FileServices fs = new FileServices();
                fs.DeleteLocalStateFile(fileToWrite.Path);
            }
        }
Example #19
0
        public void ReadingFileTest_Success()
        {
            string expectedValue   = "Ceci est un test de lecture d'un fichier .txt";
            string filePath        = @"Data\TestFile1.txt";
            var    service         = new FileServices(filePath);
            string calculatedValue = service.ReadFile();

            Assert.AreEqual(calculatedValue, expectedValue);
        }
Example #20
0
        public void Create(string[] param, ContentHolder TCH, List <string> TilePlanRows)
        {
            // param of 0 is used for sorting earlier
            Width     = Convert.ToInt32(param[1]);
            Height    = Convert.ToInt32(param[2]);
            TilesWide = Convert.ToInt32(param[3]);
            TilesHigh = Convert.ToInt32(param[4]);
            TilePlan  = new int[TilesWide, TilesHigh];
            TileMap   = TCH.GetTexture(param[5]);
            int h = 0;

            foreach (string Row in TilePlanRows)
            {
                string[] temp = FileServices.LineCommaSplit(Row);
                int      k    = 0;
                foreach (string Tile in temp)
                {
                    TilePlan[k, h] = Convert.ToInt32(Tile);
                    k += 1;
                }
                h += 1;
            }


            Objects           = new List <Object>();
            SourceRect        = new Rectangle();
            SourceRect.Width  = Width / TilesWide;
            SourceRect.Height = Height / TilesHigh;
            if (Width % 100 == 0)
            {
                XZones = Width / 100;
            }
            else
            {
                XZones = (Width / 100) + 1;
            }
            if (Height % 100 == 0)
            {
                YZones = Height / 100;
            }
            else
            {
                YZones = (Height / 100) + 1;
            }
            Zones       = new List <Enemy> [XZones, YZones];
            ObjectZones = new List <Object> [XZones, YZones];

            for (int i = 0; i < XZones; i++)
            {
                for (int j = 0; j < YZones; j++)
                {
                    Zones[i, j]       = new List <Enemy>();
                    ObjectZones[i, j] = new List <Object>();
                }
            }
        }
Example #21
0
        public RequestResult <VesselModel> InsUpd(VesselModel model)
        {
            bool           isAdd             = model.VesselId == null;
            ImagesServices ImageServ         = new ImagesServices();
            FileServices   FileServ          = new FileServices();
            VesselDA       vesselDA          = new VesselDA();
            RequestResult <VesselModel> resp = new RequestResult <VesselModel>()
            {
                Status = Status.Success
            };
            TransactionOptions scopeOptions = new TransactionOptions();

            //scopeOptions.IsolationLevel = IsolationLevel.ReadCommitted;
            using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, scopeOptions))
            {
                try
                {
                    resp = vesselDA.InsUpd(model);

                    if (model.Image.FileContent != null && model.Image.FileContent.Length > 0)
                    {
                        Stream ProcessedImage = ImageServ.ResizeProfileImage(model.Image.FileContent);

                        ProcessedImage.Position = 0;

                        var FileNameExtension = ".jpg";
                        model.Image.FileName = "vesselimage-" + model.VesselId + FileNameExtension;
                        var path = "vessels/" + model.VesselId + "/images/";

                        model.Image.ContentType = "image/jpeg";
                        model.Image.Path        = path;
                        model.Image.FileContent = ProcessedImage;

                        FileServ.SaveFile(model.Image);

                        if (isAdd)
                        {
                            resp = vesselDA.InsUpd(model);
                        }
                    }

                    ts.Complete();
                }
                catch (Exception ex)
                {
                    ts.Dispose();
                    resp = new RequestResult <VesselModel>()
                    {
                        Status = Status.Error, Message = ex.Message
                    };
                    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                    throw ex;
                }
            }
            return(resp);
        }
Example #22
0
 private void SearchFiles()
 {
     using (var fileService = new FileServices())
     {
         var files = fileService.QueryByName(securityToken, "test", 0, 0);
         Assert.IsNotNull(files);
         Assert.IsTrue(files.Count > 0);
         Assert.AreEqual(idFile, files[0].Id);
     }
 }
Example #23
0
 public FileTypesController(
     IRepository <FileType> fileTypeRepository,
     FileServices fileServices,
     FileTypeServices fileTypeServices)
 {
     _fileTypeRepository = fileTypeRepository;
     _fileServices       = fileServices;
     _fileTypeServices   = fileTypeServices;
     SetCrumb("File Types");
 }
    public void ToggleMuteMusic()
    {
        GameVariablesScript.MusicMuted = !GameVariablesScript.MusicMuted;

        _muteMusicButtonImage.overrideSprite = GameVariablesScript.MusicMuted ? MusicOffImage : MusicOnImage;

        BackgroundMusicScript.SetBackgroundMusicMute(GameVariablesScript.MusicMuted);

        FileServices.SaveGame();
    }
#pragma warning restore 649

        // public void Initialize(Texture2D image, string title, long timestampTicks, bool isQuickSave)
        public void Initialize(SavedPosition position)
        {
            savedPosition = position;
            var previewImage = screenShotService.LoadScreenshot(position.ScreenShotFileName);
            var title        = FileServices.ExtractPositionTitleFromScreenshotPath(position.ScreenShotFileName);

            Image.texture      = previewImage;
            TitleMesh.text     = title;
            TimeStampMesh.text = new DateTime(position.DateTimeTicks).ToString("d MMMM yyyy hh:mm");
            QuickSaveIndicator.SetActive(position.positionType == SavedPositionType.QuickSave);
        }
        public void Setup()
        {
            string testPath = Directory.GetCurrentDirectory();

            _fileServices = new FileServices();

            _context = new ExecutionContext
            {
                FunctionAppDirectory = testPath
            };
        }
        public FileContentResult Download(int SolutionId)
        {
            CourseServices cs    = new CourseServices();
            SolutionModel  model = new SolutionModel();

            model = cs.GetSolution(SolutionId);
            FileServices fs          = new FileServices();
            string       ContentType = fs.GetContentType(model.Extension);

            return(File(model.Solution, ContentType, model.FileName));
        }
Example #28
0
        public static void LoadMaterial(MaterialProvider materialProvider, string folderLocation)
        {
            var materialPaths = FileServices.GetResourceFiles(folderLocation, ".mat");

            //build textures and sprite
            foreach (var path in materialPaths)
            {
                var material = FileServices.LoadMaterialResources(path);

                materialProvider.AddMaterial(material);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeRushProxy"/> class.
 /// </summary>
 public CodeRushProxy()
 {
   this.solution = GetNonNull(CodeRush.Solution, "CodeRush.Solution.");
   this.documents = GetNonNull(CodeRush.Documents, "CodeRush.Documents");
   this.file = GetNonNull(CodeRush.File, "CodeRush.File");
   this.textBuffers = GetNonNull(CodeRush.TextBuffers, "CodeRush.TextBuffers");
   this.language = GetNonNull(CodeRush.Language, "CodeRush.Language");
   this.markers = GetNonNull(CodeRush.Markers, "CodeRush.Markers");
   var source = GetNonNull(CodeRush.Source, "CodeRush.Source");
   this.source = new SourceModelProxy(source);
   this.undoStack = GetNonNull(CodeRush.UndoStack, "CodeRush.UndoStack");
 }
        public MapaController()
        {
            var unitOfWorkRepository = new NHUnitOfWorkRepository <Mapa>();
            var unitOfWork           = new NHUnitOfWork <Mapa>(unitOfWorkRepository);
            var mapaRepository       = new MapaRepository(unitOfWork);

            this._mapaServices = new MapaServices(mapaRepository);

            var fileRepostory = new MapaFileRepository();

            this._fileServices = new FileServices(fileRepostory);
        }
        public async Task <IActionResult> uploadDocs([FromForm] FileData data)
        {
            Stream fs     = data.File.OpenReadStream();
            String result = await FileServices.getDoc(fs, data.Name, data.token);

            var Doc = new
            {
                documentUrl = result
            };

            return(Created("/", Doc));
        }