Esempio n. 1
0
        public async Task BaZicCompile()
        {
            var inputCode =
                @"EXTERN FUNCTION Main(args[])
    VARIABLE var1 = 1
    VARIABLE Var1 = 2
    VARIABLE result = var1 + Var1
    System.Console.WriteLine(result.ToString())
    RETURN result
END FUNCTION";

            using (var interpreter = new BaZicInterpreter(inputCode, false))
            {
                var mscorlib      = AssemblyInfoHelper.GetAssemblyDetailsFromNameOrLocation(typeof(object).Assembly.FullName);
                var baZicCoreTest = AssemblyInfoHelper.GetAssemblyDetailsFromNameOrLocation(typeof(LogMock).Assembly.Location);
                interpreter.SetDependencies(mscorlib, baZicCoreTest);

                var tempFile = Path.Combine(Path.GetTempPath(), "BaZic_Bin", Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".exe");
                var errors   = await interpreter.Build(Core.Enums.BaZicCompilerOutputType.ConsoleApp, tempFile);

                Assert.IsNull(errors);
                Assert.IsTrue(File.Exists(tempFile));
                Assert.IsTrue(File.Exists(tempFile.Replace(".exe", ".pdb")));
                Assert.IsTrue(File.Exists(Path.Combine(Path.GetTempPath(), "BaZic_Bin", "BaZic.Core.Tests.dll")));

                File.Delete(tempFile);
                File.Delete(tempFile.Replace(".exe", ".pdb"));
                File.Delete(Path.Combine(Path.GetTempPath(), "BaZic_Bin", "BaZic.Core.Tests.dll"));
                Directory.Delete(Path.Combine(Path.GetTempPath(), @"BaZic_Bin"), true);
            }
        }
        private void ShowHeader()
        {
            System.Version version = AssemblyInfoHelper.GetVersion();
            lblVersion.Text = FI.Common.AppConfig.AppName + " " + version.Major + "." + version.Minor + "." + version.Build;

            lblHeader.Text = _message;
        }
Esempio n. 3
0
 /// <summary>
 /// Saves project
 /// </summary>
 public void Save()
 {
     ApplicationVersion = AssemblyInfoHelper.GetMainAssemblyVersion();
     Directory.CreateDirectory(ProjectDataFolderPath);
     Gallery.Save();
     File.WriteAllText(ProjectPath, SerializationHelper.SerializeToXml(this));
 }
Esempio n. 4
0
        public ActionResult About()
        {
            AssemblyInfoHelper assemblyInfoHelper = new AssemblyInfoHelper(this.GetType());

            assemblyInfoHelper.ReleaseNotes = IOHelper.GetFileContent(Server.MapPath("Release_Notes.txt"));
            return(View(assemblyInfoHelper));
        }
Esempio n. 5
0
        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <returns>true if the execution was successful; otherwise, false.</returns>
        public override bool Execute()
        {
            // This task is only required if MSBuild does not generate the assembly info data.
            if (GenerateAssemblyInfo)
            {
                return(true);
            }

            logger = new TaskLogger(Log);
            logger.Trace("NetRevisionTask: PatchAssemblyInfo");

            // Analyse working directory
            RevisionData data = Common.ProcessDirectory(ProjectDir, RequiredVcs, TagMatch, logger);

            if (!string.IsNullOrEmpty(RequiredVcs) && data.VcsProvider == null)
            {
                logger.Error($@"Required VCS ""{RequiredVcs}"" not present.");
                return(false);
            }
            if (string.IsNullOrEmpty(RevisionFormat))
            {
                RevisionFormat = Common.GetRevisionFormat(ProjectDir, logger, true);
            }
            if (string.IsNullOrEmpty(RevisionFormat))
            {
                RevisionFormat = data.GetDefaultRevisionFormat(logger);
            }

            var rf = new RevisionFormatter {
                RevisionData = data, RemoveTagV = RemoveTagV
            };

            try
            {
                var aih = new AssemblyInfoHelper(ProjectDir, true, logger);
                SourceAssemblyInfo  = aih.FileName;
                PatchedAssemblyInfo = aih.PatchFile(
                    IntermediateOutputPath,
                    rf,
                    RevisionFormat,
                    ResolveSimpleAttributes,
                    ResolveInformationalAttribute,
                    RevisionNumberOnly,
                    ResolveCopyright,
                    ShowRevision,
                    ProcessAnyProperty);
            }
            catch (FormatException ex)
            {
                logger.Error(ex.Message);
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        /// <summary>
        /// Set program required assemblies.
        /// </summary>
        /// <param name="assemblies">The fullname or path to assemblies</param>
        /// <returns>The current program</returns>
        public BaZicProgram WithAssemblies(params string[] assemblies)
        {
            var assembliesDetails = new List <AssemblyDetails>();

            foreach (var assembly in assemblies)
            {
                assembliesDetails.Add(AssemblyInfoHelper.GetAssemblyDetailsFromNameOrLocation(assembly));
            }

            Assemblies = assembliesDetails.AsReadOnly();
            return(this);
        }
        public MainForm()
        {
            InitializeComponent();
            // ReSharper disable once VirtualMemberCallInConstructor
            Text = $@"{AssemblyInfoHelper.GetTitle()} v{AssemblyInfoHelper.GetVersion()}";

            this.Subscribe <CantConnectToTheBarcodeReaderEvent>(e => {
                Invoke(new Action(() =>
                {
                    MessageBox.Show("Skaner Kodów Kreskowych nie został podłączony.\nSkanowanie kodów nie będzie możliwe.", "Uwaga", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }));
            });

            this.Subscribe <CantConnectToTheThermalPrinterEvent>(e => {
                Invoke(new Action(() =>
                {
                    MessageBox.Show("Drukarka termiczna nie została podłączona.\nDrukowanie faktur nie będzie możliwe.", "Uwaga", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }));
            });

            this.Subscribe <BarcodeWasScannedEvent>(e => {
                Invoke(new Action(() =>
                {
                    var activeChild = ActiveMdiChild;

                    if (activeChild != null)
                    {
                        try
                        {
                            var transactionForm = (TransactionForm)activeChild;
                            if (transactionForm.AddProductByBarcode(e.Barcode))
                            {
                                return;
                            }

                            this.Publish(new BarcodeErrorEncounteredEvent());

                            MessageBox.Show("Produktu o kodzie " + e.Barcode + " nie ma w bazie produktów!", "Błędny Kod", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Aby zeskanować kod kreskowy, aktywuj okno z tranzakcją", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Aby zeskanować kod kreskowy, aktywuj okno z tranzakcją", "Informacja", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }));
            });
        }
Esempio n. 8
0
        public AboutBox()
        {
            InitializeComponent();

            this.Text = String.Format("Informacje o {0} v{1}", AssemblyInfoHelper.GetTitle(), AssemblyInfoHelper.GetVersion());
            this.labelProductName.Text   = AssemblyInfoHelper.GetProduct();
            this.labelVersion.Text       = String.Format("Wersja {0}", AssemblyInfoHelper.GetVersion());
            this.labelCopyright.Text     = AssemblyInfoHelper.GetCopyright();
            this.labelCompanyName.Text   = AssemblyInfoHelper.GetCompany();
            this.textBoxDescription.Text = AssemblyInfoHelper.GetDescription();


            _gearImage = Image.FromFile(@"Images\gear.png");
        }
Esempio n. 9
0
        /// <summary>
        /// Load in the application domain all the required assemblies.
        /// </summary>
        private void LoadAssemblies()
        {
            var assemblies = Program.Assemblies.ToList();

            var assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location);

            var assembliesPath = new List <String>();

            assembliesPath.Add("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            assembliesPath.Add("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            assembliesPath.Add("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
            assembliesPath.Add("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            assembliesPath.Add("Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            assembliesPath.Add("PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
            assembliesPath.Add("PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
            assembliesPath.Add("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");

            foreach (var path in assembliesPath)
            {
                if (assemblies.All(a => string.CompareOrdinal(a.ToLocationOrFullName(), path) != 0))
                {
                    assemblies.Add(AssemblyInfoHelper.GetAssemblyDetailsFromNameOrLocation(path));
                }
            }

            AssemblyDetails details = null;

            try
            {
                for (int i = 0; i < assemblies.Count; i++)
                {
                    details = assemblies[i];
                    _assemblySandbox.LoadAssembly(details, false);
                    if (Verbose)
                    {
                        ChangeState(this, new BaZicInterpreterStateChangeEventArgs(L.BaZic.Runtime.BaZicInterpreter.FormattedAssemblyLoaded(details.ToLocationOrFullName())));
                    }
                }
            }
            catch (Exception exception)
            {
                CoreHelper.ReportException(exception);
                ChangeState(this, new LoadAssemblyException(L.BaZic.Runtime.BaZicInterpreter.FormattedAssemblyFailedLoad(details.ToLocationOrFullName()), details.ToLocationOrFullName(), exception));
            }
        }
Esempio n. 10
0
        private String getCaption(String appid)
        {
            String             caption = "StockMarket Demo V";
            AssemblyInfoHelper asm     = new AssemblyInfoHelper(this.GetType());
            string             ver     = asm.VersionInfo.Version;

            char[] separators = { '.' };
            int    mv         = Int32.Parse(ver.Split(separators)[2]);

            if (mv % 2 == 0)
            {
                caption += ver + " Release";
            }
            else
            {
                caption += ver + " Beta";
            }
            caption += " Author:wazhiyi Email:[email protected] 3Q:ShowApi ID: ";
            caption += appid;
            return(caption);
        }
Esempio n. 11
0
        /// <summary>
        /// Project creation
        /// </summary>
        /// <param name="projectPath">Project path</param>
        /// <param name="name">Name</param>
        /// <param name="projectTemplate">Project template</param>
        /// <returns></returns>
        public static Project Create(string projectPath, string name, ProjectTemplate projectTemplate)
        {
            Project project = new Project
            {
                ApplicationVersion = AssemblyInfoHelper.GetMainAssemblyVersion(),
                ProjectPath        = projectPath,
                Name = name,
                ProjectDataFolderPath = Path.Combine(Path.GetDirectoryName(projectPath), $@"{DataFolderPrefix}")
            };

            project.Gallery     = new Gallery(project.ProjectDataFolderPath);
            project.DataColumns = projectTemplate == null ?
                                  new List <DataColumn>()
                : SerializationHelper.DeserializeFromXml <List <DataColumn> >(projectTemplate.Data);
            project.Save();

            // Adding project to recent projects list
            new RecentProject(project.Name, project.ProjectPath).AddOrUpdate();

            // Deleting temporary files
            project.Gallery.DeleteTempFiles();

            return(project);
        }
Esempio n. 12
0
        private static void Main(string[] args)
        {
            string filename = "";
            if (args.Length == 0)
            {
                Stream myStream = null;
                OpenFileDialog openFileDialog1 = new OpenFileDialog
                {
                    Filter = "dll files (*.dll)|*.dll|All files (*.*)|*.*",
                    FilterIndex = 1,
                    RestoreDirectory = true,
                    Multiselect = false
                };
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                    filename = openFileDialog1.FileName;
                else
                    return;
            }
            else
                filename = Path.GetFullPath(args[0]);

            if (File.Exists(filename))
            {
                Package package = new Package();
                Assembly executingAssembly = Assembly.GetExecutingAssembly();

                using (Stream stream = executingAssembly
                    .GetManifestResourceStream(executingAssembly.GetName().Name + ".Package.nuspec"))
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        var xml = reader.ReadToEnd();
                        package = Package.Deserialize(xml);
                    }
                }

                Assembly assembly = Assembly.LoadFile(filename);
                AssemblyInfoHelper helper = new AssemblyInfoHelper(assembly);
                IDictionary<string, string> allAttributes = helper.GetAllAttributes();

                allAttributes.Add("version", helper.FileVersion);
                allAttributes.Add("id", helper.AssemblyName);
                allAttributes.Add("authors", helper.Company);
                allAttributes.Add("owners", helper.Company);

                PropertyInfo[] properties = typeof(PackageMetadata).GetProperties(
                    BindingFlags.Public |
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Instance);

                foreach (KeyValuePair<string, string> attribute in allAttributes)
                {
                    foreach (PropertyInfo propertyInfo in
                        properties.Where(propertyInfo => propertyInfo.Name.ToLower().Equals(attribute.Key.ToLower())).
                            Where(propertyInfo => propertyInfo.CanWrite))
                        propertyInfo.SetValue(package.Metadata, attribute.Value, null);
                }

                var version = helper.RuntimeVersion;
                package.Files.Add(new PackageFile
                    {
                        Src = helper.FilePath,
                        Target = "lib"
                    });

                var outFile = Path.GetFileName(filename.Replace(".dll", ".nuspec"));
                package.SaveToFile(outFile);
                Console.WriteLine("Done! " + outFile);
            }
            else
                Console.WriteLine("File does not exist!");
        }
        private void DisplayInfo()
        {
            AssemblyInfoHelper info= new AssemblyInfoHelper(this.GetType());

            lnkAbout.Text = string.Format("{0} v{1}  Release On {2}[{3}]",info.Title, info.AssemblyVersion, info.ReleaseDate, info.Copyright);
        }
Esempio n. 14
0
        private void ribbonButton1_Click(object sender, EventArgs e)
        {
            //Form a = new IView.UI.Forms.MainWindow();
            //a.ShowDialog();

            var url =  new AssemblyInfoHelper(this.GetType()).Company;
            Process.Start(url);

        }
Esempio n. 15
0
        public IEnumerable<PluginModel> GetPluginsInfo()
        {
            return this.ListeMenu.Select<IOgpMenu, PluginModel>(menu =>
            {
                var aih = new AssemblyInfoHelper(menu.GetType());
                PluginModel plugin = new PluginModel();
                plugin.Name = aih.Title;
                plugin.Description = aih.Description;
                plugin.Version = aih.AssemblyVersion;
                plugin.Location = aih.FilePath;

                return plugin;
            });
        }
Esempio n. 16
0
        private void upload()
        {
            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Title = "Choose the plugin to upload";
            dlg.FileName = "plugin" + PLUGIN_EXTENSION; // Default file name
            dlg.DefaultExt = PLUGIN_EXTENSION; // Default file extension
            dlg.Filter = PLUGIN_TYPE_DESCRIPTION; // Filter files by extension

            // Show open file dialog box
            Nullable<bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                // Open document
                string filepath = dlg.FileName;
                string dstFilepath  = Path.GetFullPath(filepath);

                // retrieve assembly info
                AssemblyInfoHelper asm = new AssemblyInfoHelper(dstFilepath);
                PluginModel pm = new PluginModel();
                pm.Name = asm.Title;
                pm.Version = asm.AssemblyVersion;
                pm.Description = asm.Description;
                pm.Actif = true;
                // retrieve dll file
                MemoryStream ms = new MemoryStream(File.ReadAllBytes(dstFilepath));

                // run in background
                var background = new BackgroundWorker();
                background.DoWork += (DoWorkEventHandler)((sender, e) =>
                {
                    Exception error = WcfHelper.Execute<IServicePlugin>(client =>
                    {
                        result = client.AddPlugin(pm, ms);
                    });

                    if (error != null)
                    {
                        throw new OgpPluginException("Erreur de upload", error);
                    }
                });

                background.RunWorkerCompleted += (RunWorkerCompletedEventHandler)((sender, e) =>
                {
                    new WPFMessageBoxService().ShowInformation("Plugin uploaded.");
                });
                background.RunWorkerAsync();
            }
        }
Esempio n. 17
0
       public static void CreatePDF(string directoryPath , string pdfFile, string name, ComicDownloaderSettings settings){

           try
           {
               Directory.CreateDirectory(Path.GetDirectoryName(pdfFile));
           }
           finally{}

            Document pdfDoc = new Document(PageSize.A4);
           AssemblyInfoHelper info = new AssemblyInfoHelper(typeof(PDFHelper));

           pdfDoc.AddAuthor(info.Company);
           pdfDoc.AddCreationDate();
           pdfDoc.AddTitle(name);
           

            float docw = pdfDoc.PageSize.Width;
            float doch = pdfDoc.PageSize.Width;
            
            PdfDate st = new PdfDate(DateTime.Today);
            Chapter chapter = new Chapter(new Paragraph(name), 1);

            try
            {
                var stream = File.Create(pdfFile);
                var writer = PdfWriter.GetInstance(pdfDoc, stream);

                pdfDoc.Open();

                if (settings.IncludePDFIntroPage && settings.PdfIntroPagePosition == PagePosition.FirstPage)
                    EmbedeIntroPage(pdfDoc, writer);

                DirectoryInfo di = new DirectoryInfo(directoryPath);
                var files = di.GetFiles();
                if (files != null)
                {
                    foreach (var fi in files)
                    {
                        Image img = Image.GetInstance(fi.FullName);
                        float h = img.Height;
                        float w = img.Width;

                        float hp = doch / h;
                        float wp = docw / w;

                        ///img.ScaleToFit(docw * 1.35f, doch * 1.35f);
                        // img.ScaleToFit(750, 550);
                        pdfDoc.NewPage();
                        //pdfDoc.Add(img);
                        PdfPTable nestedTable = new PdfPTable(1);
                        PdfPCell cell = new PdfPCell(img);
                        cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                        nestedTable.AddCell(cell);
                        //pdfDoc.Add(nestedTable);

                        Section section = chapter.AddSection(0f, new Paragraph("", new Font()
                        {
                            Color = BaseColor.WHITE
                        }));
                        //section.Add(nestedTable);
                        //pdfDoc.Add(section);
                        pdfDoc.Add(nestedTable);


                    }
                    if (settings.IncludePDFIntroPage && settings.PdfIntroPagePosition == PagePosition.LastPage)
                        EmbedeIntroPage(pdfDoc, writer);
                }
            }
            catch (Exception ex)
            {
                MyLogger.Log(ex);
            }
            finally
            {
                pdfDoc.Close();
            }

       
       }