Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("Id,HomeFileId,HomeFileName,RemoteFileName,RemoteBaseUri,AcceptFrom,SendTo")] LinkedFile linkedFile)
        {
            if (ModelState.IsValid)
            {
                if (!linkedFile.RemoteBaseUri.EndsWith('/'))
                {
                    linkedFile.RemoteBaseUri = linkedFile.RemoteBaseUri.TrimEnd(' ') + "/";
                }

                LinkProcessor lp = new LinkProcessor(_context);

                if (await lp.Test(linkedFile.RemoteBaseUri))
                {
                    _context.Add(linkedFile);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(RedirectToAction(nameof(Error)));
                }
            }
            return(View(linkedFile));
        }
Ejemplo n.º 2
0
        private void BtnFileLinking_Click(object sender, EventArgs e)
        {
            var newLinkedFile  = new LinkedFile();
            var newFileLinking = new FileAdder(ref newLinkedFile);

            newFileLinking.ShowDialog();
        }
Ejemplo n.º 3
0
    void Start()
    {
        ShahRukhKhanKeBache = 34;
        root.nameOfFolder   = "C Drive";
        root.value          = 324234;

        root.parentFolder = null;
        root.childFolder  = cF;

        cF.nameOfFolder = "Program Files";


        print(root.childFolder.nameOfFolder);

        ccF.nameOfFolder = "Study Material";
        cF.childFolder   = ccF;

        print(cF.childFolder.nameOfFolder);

        ccF.renameFolder("XXX");

        print(ccF.nameOfFolder);

        print("niche ek object ban raha hai or uska constuctor chalega");
        LinkedFile nayaObject = new LinkedFile();
    }
Ejemplo n.º 4
0
        public async Task Delete(string Id)
        {
            int        myId   = int.Parse(Id);
            LinkedFile myFile = await _db.LinkedFile.SingleOrDefaultAsync(p => p.Id == myId);

            _db.LinkedFile.Remove(myFile);
            await _db.SaveChangesAsync();
        }
Ejemplo n.º 5
0
            private static LinkedFile GetFile(int number)
            {
                LinkedFile linkedFile = LinkedFile.Root;

                while ((linkedFile != null) && linkedFile.NumberRange.ValueWithinRange(number) == false)
                {
                    linkedFile = linkedFile.Next;
                }
                return(linkedFile);
            }
Ejemplo n.º 6
0
            public static void Save()
            {
                LinkedFile linkedFile = LinkedFile.Root;

                while (linkedFile != null)
                {
                    linkedFile.Writer.Close();
                    linkedFile = linkedFile.Next;
                }
            }
Ejemplo n.º 7
0
        private async void BtnAddFile_Click(object sender, EventArgs e)
        {
            var db = new DataBase();

            if (_linkedFile.Id != 0)
            {
                _linkedFile.Description     = TbDescription.Text;
                _linkedFile.Directory       = TbFilepath.Text;
                _linkedFile.FileName        = TbFilename.Text;
                db.Entry(_linkedFile).State = EntityState.Modified;
                var containsConnection = db.FileToOverheadNode.Any(d =>
                                                                   !d.Deleted && d.FileOverheadId == ((FileOverhead)CbFileOverhead.SelectedItem).Id &&
                                                                   d.LinkedFileId == _linkedFile.Id);
                if (!containsConnection)
                {
                    var fileToOverheadNode = new FileToOverhead
                    {
                        Deleted        = false,
                        CreateDate     = DateTime.Now,
                        FileOverheadId = ((FileOverhead)CbFileOverhead.SelectedItem).Id,
                        LinkedFileId   = _linkedFile.Id
                    };
                    db.FileToOverheadNode.Add(fileToOverheadNode);
                }
                await db.SaveChangesAsync();

                return;
            }
            var fileOverhead = (FileOverhead)CbFileOverhead.SelectedItem;
            var file         = new LinkedFile
            {
                CreateDate  = DateTime.Now,
                Deleted     = false,
                Description = TbDescription.Text,
                Directory   = TbFilepath.Text,
                FileName    = TbFilename.Text,
                LastAccess  = DateTime.Now
            };

            db.LinkedFiles.Add(file);
            var fileToOverhead = new FileToOverhead
            {
                Deleted        = false,
                CreateDate     = DateTime.Now,
                FileOverheadId = fileOverhead.Id,
                LinkedFileId   = file.Id
            };

            db.FileToOverheadNode.Add(fileToOverhead);
            await db.SaveChangesAsync();

            Close();
        }
Ejemplo n.º 8
0
            public static void Merge(string outputFile)
            {
                var        outputFileStream = new FileStream(outputFile, FileMode.Create);
                LinkedFile linkedFile       = LinkedFile.Root;

                while (linkedFile != null)
                {
                    linkedFile.Reader.CopyTo(outputFileStream);
                    linkedFile.Reader.Close();
                    File.Delete(linkedFile.Reader.Name);
                    linkedFile = linkedFile.Next;
                }
                outputFileStream.Close();
            }
Ejemplo n.º 9
0
        /// <summary>
        /// Обновляет данные о текущей версии базы данных и записывает данные в файл
        /// </summary>
        /// <param name="version">Новая версия БД. Должна быть больше имеющейся, в противном случае будет выброшено исключение <see cref="ArgumentException"/></param>
        /// <returns></returns>
        public async Task WriteVersion(double version)
        {
            if (version <= Data.InstalledVersionNumber)
            {
                throw new ArgumentException("New version must more than exists");
            }

            Data.InstalledVersionNumber = version;

            using (var stream = await LinkedFile.OpenStreamForWriteAsync())
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(XmlDBInfoLocal));
                xmlSerializer.Serialize(stream, Data);
            }
        }
Ejemplo n.º 10
0
        private void ByteRead()
        {
            this.MeasureTimeStart(MethodBase.GetCurrentMethod().Name, "Sort the numbers on the disk file");

            var outputFileDetails = new FileDetails(this.Output);

            // 1 MB memory available
            var memorySize   = 1024 * 1024;
            var memoryLength = memorySize / 4;
            var memory       = new int[memoryLength];

            var inputStream   = new FileStream(this.Input, FileMode.Open);
            var dataLength    = inputStream.Length;
            var numberStr     = string.Empty;
            var memoryCounter = 0;

            LinkedFile.Build(500, 1, 20000, outputFileDetails.Directory);

            while (inputStream.Position < dataLength)
            {
                var byteData = inputStream.ReadByte();
                if ((byteData == 32) && (numberStr != string.Empty))
                {
                    memory[memoryCounter++] = Convert.ToInt32(numberStr);
                    numberStr = string.Empty;
                }
                else
                {
                    numberStr += (char)byteData;
                }

                if ((memoryCounter == memory.Length) || (inputStream.Position == dataLength))
                {
                    Array.Sort(memory);
                    LinkedFile.Write(memory);
                    memoryCounter = 0;
                }
            }

            inputStream.Close();

            LinkedFile.Save();
            LinkedFile.Merge(this.Output);

            this.MeasureTimeEnd(MethodBase.GetCurrentMethod().Name, "sorting the numbers");
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,HomeFileId,HomeFileName,RemoteFileName,RemoteBaseUri,AcceptFrom,SendTo")] LinkedFile linkedFile)
        {
            if (id != linkedFile.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (!linkedFile.RemoteBaseUri.EndsWith('/'))
                    {
                        linkedFile.RemoteBaseUri = linkedFile.RemoteBaseUri.TrimEnd(' ') + "/";
                    }

                    LinkProcessor lp = new LinkProcessor(_context);

                    if (await lp.Test(linkedFile.RemoteBaseUri))
                    {
                        _context.Update(linkedFile);
                        await _context.SaveChangesAsync();
                    }
                    else
                    {
                        return(RedirectToAction(nameof(Error)));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LinkedFileExists(linkedFile.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(linkedFile));
        }
Ejemplo n.º 12
0
            public static void Build(int fileCount, int minValue, int maxValue, string directory)
            {
                Path = directory;

                LinkedFile current = null;

                if (Root == null)
                {
                    CurrentIndex = 0;
                    CurrentRange = new NumberRange(minValue, maxValue);
                    Root         = new LinkedFile(CurrentIndex++, CurrentRange++);
                    current      = Root;
                }

                for (var i = 1; i < fileCount; i++)
                {
                    var linkedFile = new LinkedFile(CurrentIndex++, CurrentRange++);
                    current.Next = linkedFile;
                    current      = current.Next;
                }
            }
Ejemplo n.º 13
0
 public async Task Put(LinkedFile linkedFile)
 {
     _db.Entry(linkedFile).State = EntityState.Modified;
     await _db.SaveChangesAsync();
 }
Ejemplo n.º 14
0
 public async Task Post(LinkedFile linkedFile)
 {
     _db.LinkedFile.Add(linkedFile);
     await _db.SaveChangesAsync();
 }
Ejemplo n.º 15
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Include javascript only in live site or preview mode
            if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) || (CMSContext.ViewMode == ViewModeEnum.Preview))
            {
                // Render the inline script
                if (InlineScript.Trim() != string.Empty)
                {
                    string inlineScript = InlineScript;

                    // Check if script tags must be generated
                    if (GenerateScriptTags && (InlineScriptPageLocation.ToLower() != "submit"))
                    {
                        inlineScript = ScriptHelper.GetScript(InlineScript);
                    }
                    // Switch for script position on the page
                    switch (InlineScriptPageLocation.ToLower())
                    {
                    case "header":
                        Page.Header.Controls.Add(new LiteralControl(inlineScript));
                        break;

                    case "beginning":
                        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "inlinescript", inlineScript);
                        break;

                    case "inline":
                        ltlInlineScript.Text = inlineScript;
                        break;

                    case "startup":
                        ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "inlinescript", inlineScript);
                        break;

                    case "submit":
                        ScriptHelper.RegisterOnSubmitStatement(Page, typeof(string), ClientID + "inlinescript", inlineScript);
                        break;

                    default:
                        ltlInlineScript.Text = inlineScript;
                        break;
                    }
                }

                // Create linked js file
                if (LinkedFile.Trim() != string.Empty)
                {
                    string linkedFile = ScriptHelper.GetIncludeScript(ResolveUrl(LinkedFile));

                    // Switch for script position on the page
                    switch (LinkedFilePageLocation.ToLower())
                    {
                    case "header":
                        Page.Header.Controls.Add(new LiteralControl(linkedFile));
                        break;

                    case "beginning":
                        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "script", linkedFile);
                        break;

                    case "startup":
                        ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "script", linkedFile);
                        break;

                    default:
                        Page.Header.Controls.Add(new LiteralControl(linkedFile));
                        break;
                    }
                }
            }
        }
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Registers the linked files
    /// </summary>
    private void RegisterLinkedFiles()
    {
        // Create linked JS file
        if (LinkedFile.Trim() != string.Empty)
        {
            string linkedFile = String.Empty;

            // Register some script files manually, to prevent multiple registration
            switch (LinkedFile.Trim().ToLowerCSafe())
            {
            case "jquery":
                if (ScriptHelper.RequestScriptRegistration(ScriptHelper.JQUERY_KEY))
                {
                    linkedFile = ScriptHelper.JQUERY_FILENAME;
                }
                break;

            case "prototype":
                if (ScriptHelper.RequestScriptRegistration(ScriptHelper.PROTOTYPE_KEY))
                {
                    linkedFile = ScriptHelper.PROTOTYPE_FILENAME;
                }
                break;

            case "mootools":
                if (ScriptHelper.RequestScriptRegistration(ScriptHelper.MOOTOOLS_KEY))
                {
                    linkedFile = ScriptHelper.MOOTOOLS_FILENAME;
                }
                break;

            case "silverlight":
                if (ScriptHelper.RequestScriptRegistration(ScriptHelper.SILVERLIGHT_KEY))
                {
                    linkedFile = ScriptHelper.SILVERLIGHT_FILENAME;
                }
                break;

            default:
            {
                // File URL
                string file = LinkedFile;

                string key = ScriptHelper.SCRIPTFILE_PREFIX_KEY + file;
                if (ScriptHelper.RequestScriptRegistration(key))
                {
                    linkedFile = ScriptHelper.GetScriptUrl(file, false);
                    linkedFile = ResolveUrl(linkedFile);
                }
            }
            break;
            }

            if (!String.IsNullOrEmpty(linkedFile))
            {
                string script = ScriptHelper.GetIncludeScript(linkedFile);

                // Switch for script position on the page
                switch (LinkedFilePageLocation.ToLowerCSafe())
                {
                case "beginning":
                    ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), ClientID + "script", script);
                    break;

                case "startup":
                    ScriptHelper.RegisterStartupScript(Page, typeof(string), ClientID + "script", script);
                    break;

                case "header":
                default:
                    Page.Header.Controls.Add(new LiteralControl(script));
                    break;
                }
            }
        }
    }
Ejemplo n.º 17
0
 public FileAdder(ref LinkedFile linkedFile)
 {
     _linkedFile = linkedFile;
     InitializeComponent();
 }