示例#1
0
        /// <summary>
        /// This method saves all the Excel embedded binary objects from the <paramref name="inputFile"/> to the
        /// <see cref="outputFolder"/>
        /// </summary>
        /// <param name="inputFile">The binary Excel file</param>
        /// <param name="outputFolder">The output folder</param>
        /// <returns></returns>
        /// <exception cref="OEFileIsPasswordProtected">Raised when the <paramref name="inputFile"/> is password protected</exception>
        /// <exception cref="OEFileIsCorrupt">Raised when the file is corrupt</exception>
        public static List <string> SaveToFolder(string inputFile, string outputFolder)
        {
            var fileName = Path.GetFileName(inputFile);

            using (var compoundFile = new CompoundFile(inputFile))
            {
                if (IsPasswordProtected(compoundFile, fileName))
                {
                    throw new OEFileIsPasswordProtected("The file '" + fileName + "' is password protected");
                }

                var             result  = new List <string>();
                Action <CFItem> entries = storage =>
                {
                    var childStorage = storage as CFStorage;
                    if (childStorage == null || !childStorage.Name.StartsWith("MBD"))
                    {
                        return;
                    }
                    var extractedFileName = Extraction.SaveFromStorageNode(childStorage, outputFolder);
                    if (extractedFileName != null)
                    {
                        result.Add(extractedFileName);
                    }
                };

                compoundFile.RootStorage.VisitEntries(entries, false);
                return(result);
            }
        }
        private void loadExtractions(int index)
        {
            InitializeViewExtraction();
            Extraction ext = null;

            try
            {
                ext = extractions.Where(e => e.metadata.folder == folderExtractionTab).ToList().OrderBy(e => e.metadata.name)?.ToArray()[index] ?? null;
            }
            catch
            {
            }

            dgvExtraction.DataSource = tabTable.ExtractionToTable(ext);

            if (ext != null)
            {
                btnDeleteExtraction.Visible = true;
                txtDate.Text    = ext.metadata.createDate.ToString("dddd, dd MMMM yyyy HH:mm:ss");
                txtColumns.Text = ext.Columns.Count.ToString();
                txtName.Text    = ext.metadata.name;
                List <Folders> FOLDS = Folders.GetFolders();
                Folders        fold  = Folders.GetFolders()?.Where(f => f.ID == ext.metadata.folder).FirstOrDefault();
                txtFolder.Text    = Folders.GetFolders()?.Where(f => f.ID == ext.metadata.folder).FirstOrDefault()?.NAME ?? "-1";
                txtRegisters.Text = String.Format("{0:n0}", ext.metadata.registers);
            }

            selectdExtraction = ext;
        }
示例#3
0
        public Extraction ExtractFrom(
            Context context)
        {
            Extraction current = null;

            foreach (var extractor in _extractors)
            {
                var contentToExtractFrom = current == null
                    ? context
                    : new Context(
                    context.Input,
                    current.Value,
                    current.Path);

                current = extractor.ExtractFrom(
                    contentToExtractFrom);

                if (!current.IsSuccess)
                {
                    return(current);
                }
            }

            return(current);
        }
示例#4
0
        public void TestDoesntExist()
        {
            using var tmpdir = new TemporaryDirectory();
            string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs");

            string programText = @"
/// <code doctest=""true"">
///    var x = 1;
/// </code>
";

            var doctestsAndErrors = Extraction.Extract(
                CSharpSyntaxTree.ParseText(
                    programText));

            Assert.AreEqual(0, doctestsAndErrors.Errors.Count);
            var doctests = doctestsAndErrors.Doctests;

            // Test pre-condition
            Assert.IsFalse(File.Exists(outputPath));

            var got = Process.Check(doctests, "SomeProgram.cs", outputPath);

            Assert.IsInstanceOf <Report.DoesntExist>(got);
        }
示例#5
0
        private void btnAcept_Click(object sender, EventArgs e)
        {
            if (cmbFolder.SelectedItem == null || cmbFileType.SelectedItem == null || String.IsNullOrEmpty(txtDelimiter.Text))
            {
                MessageBox.Show("Folder, fileType and delimiter must be filled.");
            }
            else
            {
                List <Extraction>   extractions = new List <OBJECTS.Extraction>();
                Extraction.fileType fileType;
                Cursor.Current = Cursors.WaitCursor;
                foreach (string item in chlbFileName.CheckedItems)
                {
                    switch (cmbFileType.SelectedItem?.ToString() ?? null)
                    {
                    case "CSV":
                        fileType = Extraction.fileType.CSV;
                        break;

                    case "JSON":
                        fileType = Extraction.fileType.JSON;
                        break;

                    default:
                        fileType = Extraction.fileType.CSV;
                        break;
                    }
                    ComboBoxItem folder = (ComboBoxItem)cmbFolder.SelectedItem;

                    extractions.Add(Extraction.extraction(item.ToString(), path, txtDelimiter.Text, chbFirstLineHeader.Checked, Parser.toInt(folder.Value), fileType));
                    Cursor.Current = Cursors.Default;
                    this.Close();
                }
            }
        }
示例#6
0
        static void Testing()
        {
            XmlLayer rootLayer = XmlLoader.Load(FILE_TEST);

            XmlLayer newLayer = rootLayer.GoTo("Child", "InnerChild");
            XmlLayer layer    = XmlLayer.CreateRootLayer(FILE_TEST);

            XmlLayer serverConfigRootLayer = XmlLayer.CreateRootLayer(FILE_SERVER_CONFIG);
            XmlLayer consoleFilterLayer    = serverConfigRootLayer.GoTo("Logging", "Console", "Filters");
            XmlLayer jsonFilterLayer       = serverConfigRootLayer.GoTo("Logging", "Json", "Filters");

            Extraction consoleExtraction = Extraction.OnMany((() => new List <string>()),
                                                             (list, data) => list.Add($"From: {data[0].Source}. {data[0].Data}"),
                                                             (list =>
            {
                foreach (string filter in list)
                {
                    Console.WriteLine(filter);
                }
            }))
                                           .OnOne(data => Console.WriteLine($"One Filter was found, {data[0].Source}. {data[0].Data}"))
                                           .OnNone((() => Console.WriteLine("No filters detected.")));

            consoleFilterLayer.ExtractIntoFromElements(consoleExtraction);

            ExtractionRaw raw = ExtractionRaw.OnOne(data => Console.WriteLine($"From {data[0].Source}. {data[0].Data}"))
                                .OnNone(() => Console.WriteLine("No raw data found."));

            serverConfigRootLayer.ExtractIntoFromRaw(raw, "General.Port");

            layer.Dispose();

            layer = XmlLoader.Load(FILE_TEST);
            layer = layer.CreateRootLayer();
        }
示例#7
0
        /// <summary>
        /// This method saves all the Excel embedded binary objects from the <paramref name="inputFile"/> to the
        /// <see cref="outputFolder"/>
        /// </summary>
        /// <param name="inputFile">The binary Excel file</param>
        /// <param name="outputFolder">The output folder</param>
        /// <returns></returns>
        /// <exception cref="OEFileIsPasswordProtected">Raised when the <paramref name="inputFile"/> is password protected</exception>
        /// <exception cref="OEFileIsCorrupt">Raised when the file is corrupt</exception>
        public static List <string> SaveToFolder(string inputFile, string outputFolder)
        {
            using (var compoundFile = new CompoundFile(inputFile))
            {
                var result = new List <string>();

                void Entries(CFItem storage)
                {
                    var childStorage = storage as CFStorage;

                    if (childStorage == null || !childStorage.Name.StartsWith("MBD"))
                    {
                        return;
                    }
                    var extractedFileName = Extraction.SaveFromStorageNode(childStorage, outputFolder);

                    if (extractedFileName != null)
                    {
                        result.Add(extractedFileName);
                    }
                }

                compoundFile.RootStorage.VisitEntries(Entries, false);
                return(result);
            }
        }
示例#8
0
        public void CalculateTest()
        {
            Extraction calculator = new Extraction();

            Assert.AreEqual(0, calculator.calculate(0));
            Assert.AreEqual(1, calculator.calculate(1));
            Assert.AreEqual(5, calculator.calculate(25));
        }
示例#9
0
        static void Main(string[] args)
        {
            try
            {
                string plantel = Inscriptions.Properties.Settings.Default.plantel;
                string conn    = Inscriptions.Properties.Settings.Default.FbConnectionstring;
                string path    = Inscriptions.Properties.Settings.Default.outputpath;
                string type    = Inscriptions.Properties.Settings.Default.usertype;
                string track   = Inscriptions.Properties.Settings.Default.TrackingConnection;

                Extraction ex = new Extraction(type, track);

                Console.WriteLine("Presione Enter para iniciar la extracción de " + type);
                Console.WriteLine("Plantel: " + plantel);
                Console.ReadLine();

                //all the magic is inside!
                string file = string.Empty;
                switch (type)
                {
                case "usuarios":
                    file = ex.getUsers(plantel, conn).toCSV(path);
                    break;

                case "profesores":
                    file = ex.getTeachers(plantel, conn).toCSV(path);
                    break;

                default:
                    throw new Exception("No existe el tipo: " + type.ToString());
                }

                Console.WriteLine(string.Format("Hay {0} errores. Presione Enter para continuar.", ex.Errors.Count));
                Console.ReadLine();

                if (ex.Errors.Count > 0)
                {
                    string filepath = string.Format("{0}error_{1}.log", path, DateTime.Now.ToString("MM-dd-yyyy-hhmmss"));
                    using (System.IO.StreamWriter filelog = new System.IO.StreamWriter(filepath))
                    {
                        filelog.WriteLine(string.Format("Error.log para el archivo {0}:", file));

                        foreach (string error in ex.Errors)
                        {
                            filelog.WriteLine(error);
                            Console.WriteLine(error);
                        }
                    }

                    Console.ReadLine();
                }
            }
            catch (Exception oe)
            {
                Console.WriteLine(oe.Message.ToString());
                Console.ReadLine();
            }
        }
示例#10
0
 public void UpdateInformation(Extraction extraction)
 {
     textBox1.Text = extraction.Resource.Name;
     textBox2.Text = extraction.VolumeReserve;
     textBox3.Text = extraction.VolumeSale;
     textBox4.Text = extraction.VolumeExport;
     textBox5.Text = extraction.VolumeUndistributed;
     textBox6.Text = extraction.Resource.Description;
 }
示例#11
0
        public HttpResponseMessage UpdateExtraction(HttpRequestMessage request, [FromBody] Extraction extractionModel)
        {
            return(GetHttpResponse(request, () =>
            {
                var extraction = _ExtractionProcessService.UpdateExtraction(extractionModel);

                return request.CreateResponse <Extraction>(HttpStatusCode.OK, extraction);
            }));
        }
示例#12
0
        private void RunProcedure(Extraction extraction, ExtractionJob job, ExtractionTrigger extractionTrigger)
        {
            var actionName = extraction.PackageName;
            var parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter()
            {
                ParameterName = "StartDate", Value = job.StartDate.GetOracleDate()
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "EndDate", Value = job.EndDate.GetOracleDate()
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "FYYear", Value = string.Format("FY{0}", job.EndDate.Year.ToString())
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "Year", Value = string.Format("{0}", job.EndDate.Year.ToString())
            });
            parameters.Add(new SqlParameter()
            {
                ParameterName = "Period", Value = string.Format("M{0}", job.EndDate.Month.ToString().PadLeft(2, '0'))
            });

            Log.WriteErrorLog(string.Format("Starting store procedure execution for {0}-{1}.", _serviceName, extraction.Title));

            //Update tigger to Running
            extractionTrigger.Status = PackageStatus.Running;
            extractionTrigger.Remark = "Store procedure currently running...";
            _dataManager.UpdateExtractionTrigger(_connectionString, extractionTrigger);

            var result = string.Empty;

            SqlDataManager.RunProcedureWithMessage(_connectionString, actionName, parameters.ToArray());

            if (result.Contains("Success"))
            {
                Log.WriteErrorLog(string.Format("Store procedure execution for {0}-{1} successfull.", _serviceName, extraction.Title));

                //Update tigger to Done
                extractionTrigger.Status = PackageStatus.Done;
                extractionTrigger.Remark = result;
                _dataManager.UpdateExtractionTrigger(_connectionString, extractionTrigger);
            }
            else
            {
                Log.WriteErrorLog(string.Format("Store procedure execution for {0}-{1} failed.{2}", _serviceName, extraction.Title, result));

                //Update tigger to Fail
                extractionTrigger.Status = PackageStatus.Fail;
                extractionTrigger.Remark = string.Format("Package {0}-{1} failed. {2}", _serviceName, extraction.Title, result);
                _dataManager.UpdateExtractionTrigger(_connectionString, extractionTrigger);
            }
        }
示例#13
0
        private void RunPackage(Extraction extraction, ExtractionJob job, ExtractionTrigger extractionTrigger)
        {
            var packagePath = extraction.PackagePath + extraction.PackageName + ".dtsx";

            dts.Package package = _app.LoadPackage(packagePath, null);

            Log.WriteErrorLog(string.Format("Starting package execution for {0}-{1}.", _serviceName, extraction.Title));

            //Update tigger to Running
            extractionTrigger.Status = PackageStatus.Running;
            extractionTrigger.Remark = "Package currently running...";
            _dataManager.UpdateExtractionTrigger(_connectionString, extractionTrigger);
            //DD-mon-YYYY
            extraction.ScriptText = extraction.ScriptText.Replace("@StartDate", job.StartDate.GetOracleDate());
            extraction.ScriptText = extraction.ScriptText.Replace("@EndDate", job.EndDate.GetOracleDate());
            extraction.ScriptText = extraction.ScriptText.Replace("@FYYear", string.Format("FY{0}", job.EndDate.Year.ToString()));
            extraction.ScriptText = extraction.ScriptText.Replace("@Year", string.Format("{0}", job.EndDate.Year.ToString()));
            extraction.ScriptText = extraction.ScriptText.Replace("@Period", string.Format("M{0}", job.EndDate.Month.ToString().PadLeft(2, '0')));

            package.Variables["StorProc"].Value = extraction.ScriptText;//"Script", true, "", extraction.ScriptText);

            var result = package.Execute();

            if (result == dts.DTSExecResult.Success)
            {
                int ssisDuration = 0;
                //int.TryParse(Math.Round((package.ExecutionDuration / 1000.00), 2).ToString(), out ssisDuration);

                ssisDuration = (package.ExecutionDuration / 1000);

                Log.WriteErrorLog(string.Format("Package execution for {0}-{1} successfull.", _serviceName, extraction.Title));

                //Update tigger to Done

                extractionTrigger.Status = PackageStatus.Done;
                //extractionTrigger.Remark = string.Format("{0}{1}lines extracted ({2})", string.Format("Package {0}-{1} successfully executed: ", _serviceName, extraction.Title), package.Variables["RecCount"].Value.ToString(), DateTimeExtensions.GetRealTime(ssisDuration));
                extractionTrigger.Remark = string.Format("{0}{1}lines extracted ({2})", string.Format("Package {0}-{1} successfully executed: ", _serviceName, extraction.Title), package.Variables["RecCount"].Value.ToString(), HHMMSS(ssisDuration));
                _dataManager.UpdateExtractionTrigger(_connectionString, extractionTrigger);
                //_Exp = _ProcessName & ": " & _ssisCount & " lines extracted (" & HHMMSS(_ssisDuration) & ")"
            }
            else
            {
                string errorMessage = string.Empty;
                foreach (var error in package.Errors)
                {
                    errorMessage += error.Description;
                }

                Log.WriteErrorLog(string.Format("Package execution for {0}-{1} failed.{2}", _serviceName, extraction.Title, errorMessage));

                //Update tigger to Fail
                extractionTrigger.Status = PackageStatus.Fail;
                extractionTrigger.Remark = string.Format("Package {0}-{1} failed.", _serviceName, extraction.Title) + "\n" + errorMessage;
                _dataManager.UpdateExtractionTrigger(_connectionString, extractionTrigger);
            }
        }
示例#14
0
 // basic object initialization
 private static Extraction Get(Extraction extraction, string session)
 {
     extraction.OrbitSession = new OrbitSession
     {
         MachineIp   = Utilities.GetLocalEndpoint(),
         MachineName = Environment.MachineName,
         SessionsId  = session
     };
     return(extraction);
 }
示例#15
0
        protected World()
        {
            XmlLayer   root = XmlLayer.CreateRootLayer(PlaceHolderFileSystem.ConfigFilePath);
            Extraction extractionWorldSize = Extraction.OnMany(WorldSizeRoute)
                                             .OnNone(() => { Height = 100; Width = 100; });

            root.ExtractIntoFromElements(extractionWorldSize, "World");
            root.Dispose();

            PopulateWorld();
        }
示例#16
0
        /// <summary>
        /// This method saves all the Word embedded binary objects from the <paramref name="inputFile"/> to the
        /// <see cref="outputFolder"/>
        /// </summary>
        /// <param name="inputFile">The binary Word file</param>
        /// <param name="outputFolder">The output folder</param>
        /// <returns></returns>
        /// <exception cref="OEFileIsPasswordProtected">Raised when the <see cref="inputFile"/> is password protected</exception>
        public static List <string> SaveToFolder(string inputFile, string outputFolder)
        {
            using (var compoundFile = new CompoundFile(inputFile))
            {
                if (IsPasswordProtected(compoundFile))
                {
                    throw new OEFileIsPasswordProtected("The file '" + Path.GetFileName(inputFile) +
                                                        "' is password protected");
                }

                var result = new List <string>();

                if (!compoundFile.RootStorage.ExistsStorage("ObjectPool"))
                {
                    return(result);
                }
                var objectPoolStorage = compoundFile.RootStorage.GetStorage("ObjectPool") as CFStorage;
                if (objectPoolStorage == null)
                {
                    return(result);
                }

                // Multiple objects are stored as children of the storage object
                foreach (var child in objectPoolStorage.Children)
                {
                    var childStorage = child as CFStorage;
                    if (childStorage == null)
                    {
                        continue;
                    }

                    // Get the objInfo stream to check if this is a linked file... if so then ignore it
                    var objInfo       = childStorage.GetStream("\x0003ObjInfo");
                    var objInfoStream = new ObjInfoStream(objInfo);

                    // We don't want to export linked objects and objects that are not shown as an icon...
                    // because these objects are already visible on the Word document
                    if (objInfoStream.Link || !objInfoStream.Icon)
                    {
                        continue;
                    }

                    var extractedFileName = Extraction.SaveFromStorageNode(childStorage, outputFolder);
                    if (!string.IsNullOrEmpty(extractedFileName))
                    {
                        result.Add(extractedFileName);
                    }
                }

                return(result);
            }
        }
示例#17
0
        public void Test(string text, string[] expectedNamespaces)
        {
            var tree = CSharpSyntaxTree.ParseText(text);
            var doctestsAndErrors = Extraction.Extract(tree);

            Assert.That(doctestsAndErrors.Errors, Is.EquivalentTo(new List <Extraction.Error>()));

            var doctests = doctestsAndErrors.Doctests;

            var gotNamespaces = doctests.Select((doctest) => doctest.Namespace).ToList();

            Assert.That(gotNamespaces, Is.EquivalentTo(expectedNamespaces));
        }
示例#18
0
        public HttpResponseMessage GetExtraction(HttpRequestMessage request, int extractionId)
        {
            return(GetHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                Extraction extraction = _ExtractionProcessService.GetExtraction(extractionId);

                // notice no need to create a seperate model object since Extraction entity will do just fine
                response = request.CreateResponse <Extraction>(HttpStatusCode.OK, extraction);

                return response;
            }));
        }
示例#19
0
        public async Task Extract_InvalidOutputDirectory_True()
        {
            IMediaInfo info = await MediaInfo.Get(Resources.MKV_Encoded_MultipleTracks);

            var audioTrack = info.AudioTracks.First();

            Action act = () => Extraction.New()
                         .AddTrack(audioTrack)
                         .SetOutputDirectory(@"F:\fakeDirectory\adawdj1o2312")
                         .Start()
                         .ConfigureAwait(false);

            Assert.Throws <InvalidInputException>(act);
        }
示例#20
0
        public Extraction getExtraction(int index, int folder, List <Extraction> extractions)
        {
            Extraction extraction = null;

            try
            {
                extraction = extractions.Where(ext => ext.metadata.folder == folder).
                             ToList().OrderBy(ext => ext.metadata.name)?.ToArray()[index] ?? null;
            }
            catch
            {
            }
            return(extraction);
        }
示例#21
0
        public async Task Extract_UnknownExtension_True()
        {
            IMediaInfo info = await MediaInfo.Get(Resources.MKV_Encoded_MultipleTracks);

            var audioTrack = info.AudioTracks.First();

            audioTrack.CodecId = "fakeCodec";

            Action act = () => Extraction.New()
                         .AddTrack(audioTrack)
                         .Start()
                         .ConfigureAwait(false);

            Assert.Throws <UnkownExtentionException>(act);
        }
示例#22
0
        public async Task Extract_InvalidInputDifferentSources_True()
        {
            IMediaInfo info = await MediaInfo.Get(Resources.MKV_Encoded_MultipleTracks);

            IMediaInfo info_2 = await MediaInfo.Get(Resources.MKV_Raw_MultipleTracks);


            Action act = () => Extraction.New()
                         .AddTrack(info.VideoTracks.First())
                         .AddTrack(info_2.VideoTracks.First())
                         .Start()
                         .ConfigureAwait(false);

            Assert.Throws <InvalidInputException>(act);
        }
示例#23
0
        public override Status Convert(string outDirectory)
        {
            Status = Status.Working;

            var extracted = Extraction.Expand(Location, "*.cab", _tempLocation);

            if (extracted)
            {
                if (MoveFromTemp(outDirectory, "*Windows*.cab"))
                {
                    return(Status.Success);
                }
            }
            return(Status.Failed);
        }
示例#24
0
        public frmTable(string selectedFolder, List <Extraction> extractions, Extraction selectedExtraction)
        {
            this.extractions        = extractions;
            this.selectedExtraction = selectedExtraction;
            InitializeComponent();
            txtFolder.Text    = selectedFolder;
            txtFolder.Enabled = false;

            List <ComboBoxItem> comboBoxItems = new List <ComboBoxItem>();

            extractions.ForEach(extraction => comboBoxItems.Add(new ComboBoxItem(extraction.metadata.name, extraction._id)));

            cmbExtraction.Items.AddRange(comboBoxItems.ToArray());

            cmbExtraction.SelectedItem = comboBoxItems.Where(combo => (ObjectId)combo.Value == selectedExtraction._id).FirstOrDefault();
        }
示例#25
0
        public void TestOkNoDoctest()
        {
            using var tmpdir = new TemporaryDirectory();
            string outputPath = Path.Join(tmpdir.Path, "Output.cs");

            var doctestsAndErrors = Extraction.Extract(
                CSharpSyntaxTree.ParseText(
                    "No doctest at all"));

            Assert.AreEqual(0, doctestsAndErrors.Errors.Count);
            var doctests = doctestsAndErrors.Doctests;

            Process.Report got = Process.Check(doctests, outputPath);

            Assert.AreEqual(Process.Report.Ok, got);
        }
示例#26
0
        public void TestOkNoDoctest()
        {
            using var tmpdir = new TemporaryDirectory();
            string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs");

            var doctestsAndErrors = Extraction.Extract(
                CSharpSyntaxTree.ParseText(
                    "No doctest at all"));

            Assert.AreEqual(0, doctestsAndErrors.Errors.Count);
            var doctests = doctestsAndErrors.Doctests;

            var got = Process.Check(doctests, "SomeProgram.cs", outputPath);

            Assert.IsInstanceOf <Report.Ok>(got);
        }
示例#27
0
        public void TestNoDoctest()
        {
            using var tmpdir = new TemporaryDirectory();
            string outputPath = Path.Join(tmpdir.Path, "DocTestSomeProgram.cs");

            var doctestsAndErrors = Extraction.Extract(
                CSharpSyntaxTree.ParseText(
                    "No doctest at all"));

            Assert.AreEqual(0, doctestsAndErrors.Errors.Count);
            var doctests = doctestsAndErrors.Doctests;

            bool got = Process.Generate(doctests, "SomeProgram.cs", outputPath);

            Assert.IsFalse(got);
            Assert.IsFalse(File.Exists(outputPath));
        }
示例#28
0
        /// <summary>
        ///     Get package name and version.
        /// </summary>
        private void GetDetails()
        {
            Extraction.Expand(Location, "update.mum", _tempLocation);

            if (Directory.Exists(_tempLocation))
            {
                var msuInfo =
                    Directory.GetFiles(_tempLocation, "update.mum", SearchOption.TopDirectoryOnly).FirstOrDefault();

                if (msuInfo != null)
                {
                    var doc = new XmlDocument();
                    doc.Load(msuInfo);

                    var p = (XmlElement)doc.LastChild;
                    _packageDescription = p.Attributes["description"].InnerText;
                    _support            = p.Attributes["supportInformation"].InnerText;
                    if (p.HasAttribute("creationTimeStamp"))
                    {
                        _createdDate = DateTime.Parse(p.Attributes["creationTimeStamp"].InnerText);
                    }
                    else
                    {
                        _createdDate = FileHandling.GetModifiedDate(msuInfo);
                    }


                    var p2 = (XmlElement)p.ChildNodes[0];
                    _packageName = p2.Attributes["name"].InnerText;

                    _packageVersion = p2.Attributes["version"].InnerText;

                    var applies = _packageVersion.Split('.')[0] + "." + _packageVersion.Split('.')[1];
                    _appliesTo = applies;

                    _language = p2.Attributes["language"].InnerText;

                    var arc = p2.Attributes["processorArchitecture"].InnerText;
                    if (arc.EqualsIgnoreCase("amd64"))
                    {
                        _architecture = Architecture.X64;
                    }
                }
                FileHandling.DeleteDirectory(_tempLocation);
            }
        }
示例#29
0
    public void Extract(SelectionObjectData item)
    {
        ItemBase         i   = Extraction.Extract(item.item).GetComponent <ItemBase>();
        ItemsDescription des = i.itemProperties.itemDescription;

        des.GetItemType();

        //The extraction will take default information from the prefab object.
        //must check if the item type is already present.
        int phVal = des.pHValue;

        AddItem(i); //invenetory will take care of everything checking for ph if present.


        //IF the item type is already present, it's pH value in the description data must be checked.
        //If the pH is same, the extra volume must be added to the existing item slot
    }
示例#30
0
        public async Task <IActionResult> Post(VideoDataModel response)
        {
            // rujtja json
            //ProcessedDataModel pdm = new ProcessedDataModel(response.Title,response.Description,response.VideoPath.FileName);
            var currentFile = System.IO.File.ReadAllText("./Data/information.json");
            var resultList  = JsonConvert.DeserializeObject <List <ProcessedDataModel> >(currentFile);

            int id;

            if (resultList.Count != 0)
            {
                id = Convert.ToInt32(resultList[resultList.Count - 1].id) + 1;
            }
            else
            {
                id = 1;
            }

            var filePath = String.Format("./wwwroot/videos/{0}.mp4", id);

            using (var stream = System.IO.File.Create(filePath))
            {
                await response.VideoPath.CopyToAsync(stream);
            }

            string dir       = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location).Split("bin")[0];
            string videoPath = string.Format("{0}wwwroot\\videos\\{1}.mp4", dir, id.ToString());

            IMediaInfo mediaInfo = await FFmpeg.GetMediaInfo(videoPath);

            int videoDuration = (int)Math.Floor(mediaInfo.Duration.TotalSeconds);

            ProcessedDataModel pdm = new ProcessedDataModel(id, response.Title, response.Description, response.Category, filePath, videoDuration);

            resultList.Add(pdm);
            var convertedJson = JsonConvert.SerializeObject(resultList, Formatting.Indented);

            System.IO.File.WriteAllText("./Data/information.json", convertedJson);

            // rujta e file
            //System.IO.File.Copy(response.VideoPath, "./wwwroot/videos/" + resultList.Count + ".mp4",true);
            Extraction.extractThumbnailAsync(id);
            Extraction.extractFrames(id);

            return(RedirectToAction(nameof(AdminPage), response));
        }