/// <summary>
        ///     This method updates the specified entity excluding the user object.
        /// </summary>
        /// <param name="entity">The entity parameter represents the updated project object.</param>
        public override void Update(Project entity)
        {
            entity = UpdateUpdatedField(entity);

            DbSet.Attach(entity);
            if (entity.User != null)
            {
                DbContext.Entry(entity.User)
                .Property(x => x.Email)
                .IsModified = false;

                DbContext.Entry(entity.User)
                .State = EntityState.Unchanged;
            }

            if (entity.ProjectIcon == null)
            {
                DbContext.Entry(entity)
                .Entity.ProjectIconId = null;
            }

            DbSet.Update(entity);
            SetLikes(entity);
            ESProjectDTO projectToSync = ProjectConverter.ProjectToESProjectDTO(entity);

            taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(projectToSync), Subject.ELASTIC_CREATE_OR_UPDATE);
        }
Esempio n. 2
0
        public void ValidatesFileIsWritable()
        {
            var progress = new Progress <string>(x => { });

            File.SetAttributes("TestFiles\\OtherTestProjects\\readonly.testcsproj", FileAttributes.ReadOnly);
            Assert.IsFalse(ProjectConverter.Validate(new FileInfo("TestFiles\\OtherTestProjects\\readonly.testcsproj"), progress));
        }
Esempio n. 3
0
        public virtual bool TryGetConstValueWithCast(CppTypeName cast, out object value)
        {
            if (!TryGetConstValue(out value))
            {
                return(false);
            }
            var type = ProjectConverter.GetConstValueType(value);

            if (type == cast)
            {
                return(true);
            }
            if (P.IsArithmeticType(type) && P.IsArithmeticType(cast))
            {
                var NumberConverter = new Dictionary <CppTypeName, Func <object, object> > {
                    { ProjectConverter.CppTypeName_Byte, x => Convert.ToByte(x) },
                    { ProjectConverter.CppTypeName_Short, x => Convert.ToInt16(x) },
                    { ProjectConverter.CppTypeName_Int, x => Convert.ToInt32(x) },
                    { ProjectConverter.CppTypeName_Long, x => Convert.ToInt64(x) },
                    { ProjectConverter.CppTypeName_Float, x => Convert.ToSingle(x) },
                    { ProjectConverter.CppTypeName_Double, x => Convert.ToDouble(x) },
                };
                if (NumberConverter.TryGetValue(cast, out var converter))
                {
                    value = converter(value);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 4
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Projects.Clear();

                var client   = new WebClient();
                var response = await client.GetProjects();

                IsVisibleProjects = response.Response.Items.Count > 0;

                foreach (var item in response.Response.Items)
                {
                    Projects.Add(ProjectConverter.Convert(item));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine("Please specify a project file.");
                return;
            }


#if DEBUG
            var progress = new Progress <string>(x => Debug.WriteLine(x));
#else
            var progress = new Progress <string>(System.Console.WriteLine);
#endif

            var convertedProjects = ProjectConverter.Convert(args[0], progress)
                                    .Where(x => x != null)
                                    .ToList();

            if (!args.Contains("--dry-run"))
            {
                var doBackup = !args.Contains("--no-backup");

                var writer = new Writing.ProjectWriter(x => x.Delete(), _ => { });
                foreach (var project in convertedProjects)
                {
                    writer.Write(project, doBackup, progress);
                }
            }
        }
        public ProjectCoverterTest()
        {
            proConv    = new ProjectConverter();
            projectBOs = new List <ProjectBO>();
            projectBOs.Add(new ProjectBO()
            {
                Id           = 20,
                ProjectName  = "ImportantProject",
                CreatorName  = "Bobby",
                CustomerName = "Billy"
            });

            projectBOs.Add(new ProjectBO()
            {
                ProjectName = "Project Without other info"
            });

            projectBOs.Add(new ProjectBO());

            projects = new List <Project>();
            projects.Add(new Project()
            {
                Id           = 20,
                ProjectName  = "ImportantProject",
                CreatorName  = "Bobby",
                CustomerName = "Billy"
            });

            projects.Add(new Project()
            {
                ProjectName = "Project Without other info"
            });

            projects.Add(new Project());
        }
Esempio n. 7
0
 public override CppTypeName GetResultType()
 {
     if (!TryGetConstValue(out var v))
     {
         throw new Exception();
     }
     return(ProjectConverter.GetConstValueType(v));
 }
        /// <summary>
        /// This method removes the project from the database and ES Index.
        /// </summary>
        /// <param name="entity">The entity parameter represents a project to be removed.</param>
        public override void Remove(Project entity)
        {
            base.Remove(entity);
            SetLikes(entity);
            ESProjectDTO projectToSync = ProjectConverter.ProjectToESProjectDTO(entity);

            taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(projectToSync), Subject.ELASTIC_DELETE);
        }
Esempio n. 9
0
 public ContractGridService(IUnitOfWork uow)
 {
     _uow = uow;
     _contractConverter   = new ContractConverter();
     _projectConverter    = new ProjectConverter();
     _companyConverter    = new CompanyConverter();
     _supervisorConverter = new SupervisorConverter();
 }
        public MainWindowViewModel(IOpenFileDialog openFileDialog)
        {
            var fileConverter    = new FileConverter();
            var projectConverter = new ProjectConverter();

            Settings = new SettingsViewModel();
            File     = new ConvertFileViewModel(fileConverter, Settings);
            Project  = new ConvertProjectViewModel(fileConverter, projectConverter, openFileDialog, File, Settings, this);
        }
 public PackingListService(IDALFacade facade)
 {
     _facade = facade;
     _convPL = new PackingListConverter();
     _conv   = new ProjectConverter();
     _convCL = new ColliListConverter();
     _convPI = new PackItemConverter();
     _convI  = new ItemConverter();
 }
        /// <summary>
        /// This method adds the given project to the database and ES Index.
        /// </summary>
        /// <param name="entity">The entity parameter represents a project to be added.</param>
        public override void Add(Project entity)
        {
            base.Add(entity);
            base.Save();
            Console.WriteLine("Add method id: " + entity.Id);
            SetLikes(entity);
            ESProjectDTO projectToSync = ProjectConverter.ProjectToESProjectDTO(entity);

            taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(projectToSync), Subject.ELASTIC_CREATE_OR_UPDATE);
        }
Esempio n. 13
0
        public ActionResult Summary(Guid projectId)
        {
            var project = _projectRepository.GetProject(projectId);

            ProjectViewModel model = new ProjectConverter().ConvertToView(project);

            model.CurrentUser = User.Identity.Name;

            return(View(model));
        }
        /// <summary>
        ///     This method redacts user email from the Project if isPublic setting is set to false.
        /// This method asynchronously removes the project from the database and ES Index coupled to the given id.
        /// </summary>
        /// <param name="id">The project parameter represents unique identifier.</param>
        /// <returns>
        /// The task wherein the removal of the project from the database is executed.
        /// </returns>
        public override Task RemoveAsync(int id)
        {
            Project entity = DbSet.Find(id);

            SetLikes(entity);
            ESProjectDTO projectToSync = ProjectConverter.ProjectToESProjectDTO(entity);

            taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(projectToSync), Subject.ELASTIC_DELETE);
            return(base.RemoveAsync(id));
        }
        public void MigrateDatabase(List <Project> projectsToExport)
        {
            // Converts the Projects to Elastic format.
            List <ESProjectDTO> projectsToExportDTOs = ProjectConverter.ProjectsToProjectESDTOs(projectsToExport);

            foreach (ESProjectDTO project in projectsToExportDTOs)
            {
                // Registers an Elastic formatted project at the message broker to be inserted into Elastic DB.
                taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(project), Subject.ELASTIC_CREATE_OR_UPDATE);
            }
        }
        public async Task SyncProjectToES(Project project)
        {
            Project projectToSync = await FindAsync(project.Id);

            if (projectToSync == null)
            {
                throw new NotFoundException("Project to sync was not found");
            }
            ESProjectDTO eSProjectDTO = ProjectConverter.ProjectToESProjectDTO(projectToSync);

            taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(eSProjectDTO), Subject.ELASTIC_CREATE_OR_UPDATE);
        }
Esempio n. 17
0
        private void btnImportEagle_Click(object sender, EventArgs e)
        {
            //
            // GenTestData.GenerateData();

            //
            AppSettings.SourceFilename = textBoxSource.Text;
            AppSettings.DestFolder     = textBoxDest.Text;
            SaveAppSettings();

            if (Directory.Exists(AppSettings.DestFolder))
            {
                bool is_empty = false;

                string[] Files = Directory.GetFiles(AppSettings.DestFolder);

                if (Files.Length == 0)
                {
                    string[] folders = Directory.GetDirectories(AppSettings.DestFolder);
                    if (folders.Length == 0)
                    {
                        is_empty = true;
                    }
                }

                if (!is_empty)
                {
                    DialogResult res = MessageBox.Show("Warning - Destination folder is not empty, files will be overwritten!" + Environment.NewLine + Environment.NewLine +
                                                       "Continue ?",
                                                       "Overwrite check",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation
                                                       );

                    if (res != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }
            else
            {
                AppSettingsBase.CreateDirectory(AppSettings.DestFolder);
            }

            ProjectConverter converter = new ProjectConverter();
            //if (converter.CheckValid(textBoxSource.Text))
            {
                converter.OnTrace += Trace;
                converter.ConvertProject(textBoxSource.Text, textBoxDest.Text);
            }
        }
Esempio n. 18
0
        public virtual bool TryGetConstValueWithCast(CppTypeName cast, out object value)
        {
            if (!TryGetConstValue(out value))
            {
                return(false);
            }
            var type = ProjectConverter.GetConstValueType(value);

            if (type == cast)
            {
                return(true); //FIXME 类型自动转换
            }
            return(false);
        }
Esempio n. 19
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine($"Please specify a project file.");
                return;
            }

            var writer = new Project2015To2017.Writing.ProjectWriter();

            foreach (var definition in ProjectConverter.Convert(args[0], new Progress <string>(System.Console.WriteLine)))
            {
                writer.Write(definition);
            }
        }
Esempio n. 20
0
        private static bool ConvertToKicad()
        {
            AppSettings.SourceFilename = SourceFilename;
            AppSettings.DestFolder     = DestFolder;

            if (Directory.Exists(AppSettings.DestFolder))
            {
                if (!overwrite)
                {
                    bool is_empty = false;

                    string[] Files = Directory.GetFiles(AppSettings.DestFolder);

                    if (Files.Length == 0)
                    {
                        string[] folders = Directory.GetDirectories(AppSettings.DestFolder);
                        if (folders.Length == 0)
                        {
                            is_empty = true;
                        }
                    }

                    if (!is_empty)
                    {
                        Trace("error: Destination folder is not empty, specify -overwrite option");
                        Usage();
                        return(false);
                    }
                }
            }
            else
            {
                AppSettingsBase.CreateDirectory(AppSettings.DestFolder);
            }

            ProjectConverter converter = new ProjectConverter();

            //if (converter.CheckValid(textBoxSource.Text))
            {
                converter.OnTrace += Trace;
                converter.ConvertProject(SourceFilename, DestFolder);
            }

            return(true);
        }
        public override void AddRange(IEnumerable <Project> entities)
        {
            List <Project> entityList = entities.ToList();

            for (int i = 0; i < entityList.Count; i++)
            {
                entityList[i] = UpdateCreatedField(entityList[i]);
                entityList[i] = UpdateUpdatedField(entityList[i]);
            }
            DbSet.AddRange(entityList);
            entityList.ForEach(x =>
            {
                SetLikes(x);
                ESProjectDTO projectToSync = ProjectConverter.ProjectToESProjectDTO(x);
                taskPublisher.RegisterTask(Newtonsoft.Json.JsonConvert.SerializeObject(projectToSync),
                                           Subject.ELASTIC_CREATE_OR_UPDATE);
            });
        }
Esempio n. 22
0
        public IReadOnlyCollection <Project> ParseProjects(
            IEnumerable <string> items,
            ITransformationSet transformationSet,
            ConversionOptions conversionOptions)
        {
            var convertedProjects = new List <Project>();

            foreach (var file in items)
            {
                var projects = new ProjectConverter(genericLogger, transformationSet, conversionOptions)
                               .Convert(file)
                               .Where(x => x != null)
                               .ToList();
                convertedProjects.AddRange(projects);
            }

            return(convertedProjects);
        }
Esempio n. 23
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length != 3)
                {
                    Console.WriteLine(
                        "usage: ConvertTheFuck [input file] [option] [output file]\n\toption:\t-h export cpp song header file\n\t\t-b export binary song file\n");
                }
                else
                {
                    var logger  = new ConsoleLogger();
                    var song    = new ProjectConverter().Convert(args[0], logger);
                    var option  = args[1];
                    var outFile = args[2];

                    Console.WriteLine("Devices: {0}", song.Devices.Count);
                    Console.WriteLine("Tracks: {0}", song.Tracks.Count);
                    Console.WriteLine("Tempo: {0}", song.Tempo);
                    Console.WriteLine("Length: {0}", song.Length);

                    switch (option)
                    {
                    case "-h":
                        Console.WriteLine("Writing header file: {0}", outFile);
                        File.WriteAllText(outFile, new Serializer().Serialize(song));
                        break;

                    case "-b":
                        Console.WriteLine("Writing binary file: {0}", outFile);
                        File.WriteAllBytes(outFile, new Serializer().SerializeBinary(song));
                        break;

                    default:
                        Console.WriteLine(string.Format("ERROR: unknown option {0}", args[1]));
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e.Message);
            }
        }
Esempio n. 24
0
        public virtual void before_each()
        {
            autoSubstitute = new AutoSubstitute();

            projectWrapperFactory = autoSubstitute.Resolve <IProjectWrapperFactory>();

            fileService = autoSubstitute.Resolve <IFileService>();

            IProjectWrapper notAProject = null;

            projectWrapperFactory.Create(Arg.Any <IVsHierarchy>()).Returns(notAProject);

            fileService.Exists(Arg.Any <string>()).Returns(false);

            converter = autoSubstitute.Resolve <ProjectConverter>();

            someProjectInfo  = new ProjectInfo();
            someHierarchy    = autoSubstitute.Resolve <IVsHierarchy>();
            someDummyProject = autoSubstitute.Resolve <IProjectWrapper>();
        }
Esempio n. 25
0
        public void Money_Budget_Type_Should_Be_Mapped_From_Xml()
        {
            string input = @"<?xml version=""1.0"" encoding=""UTF-8""?>
                        <project>
                           <id type=""integer"">123</id>
                           <name>Website Konzeption</name>
                           <note></note>
                           <budget type=""integer"">0</budget>
                           <budget-type>cents</budget-type>
                           <archived type=""boolean"">false</archived>
                           <customer-id type=""integer"">2</customer-id>
                           <customer-name>LilaLaune GmbH</customer-name>
                           <updated-at type=""datetime"">2007-12-13T12:12:00+01:00</updated-at>
                           <created-at type=""datetime"">2007-12-13T12:12:00+01:00</created-at>
                        </project>
                        ";

            ProjectConverter projectConverter = new ProjectConverter();
            Project project = projectConverter.Convert(input);

            Assert.That(project.BudgetType, Is.EqualTo(BudgetType.cents));
        }
Esempio n. 26
0
        public JsonResult GetCompleteProjects()
        {
            var model = new ProjectViewModel();

            var projects = new List <ProjectViewModel>();

            var tempProjects = _projectRepository.GetProjects().Where(x => x.IsComplete).ToList();

            if (tempProjects != null && tempProjects.Count > 0)
            {
                foreach (var tempProject in tempProjects)
                {
                    ProjectViewModel convertedModel = new ProjectConverter().ConvertToListView(tempProject);

                    projects.Add(convertedModel);
                }
            }

            model.Projects = projects.OrderByDescending(x => x.CreatedDate).ThenBy(y => y.ProjectName).ToList();

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Esempio n. 27
0
        public ActionResult Index()
        {
            var model = new ProjectViewModel();

            var projects = new List <ProjectViewModel>();

            var tempProjects = _projectRepository.GetProjects().Where(x => x.IsOpen).ToList();

            if (tempProjects != null && tempProjects.Count > 0)
            {
                foreach (var tempProject in tempProjects)
                {
                    ProjectViewModel convertedModel = new ProjectConverter().ConvertToListView(tempProject);

                    projects.Add(convertedModel);
                }

                model.Projects = projects;
            }

            return(View(model));
        }
Esempio n. 28
0
        public ConvertProjectViewModel(FileConverter fileConverter, ProjectConverter projectConverter, IOpenFileDialog openFileDialog, ConvertFileViewModel convertFileVm, SettingsViewModel settings, MainWindowViewModel mainWindow)
        {
            _convertFileVm    = convertFileVm;
            _fileConverter    = fileConverter;
            _projectConverter = projectConverter;
            _settings         = settings;
            _mainWindow       = mainWindow;

            CopyToBak = true;

            LoadCsproj = ReactiveCommand.CreateFromObservable(() => openFileDialog.BrowseFile());
            LoadCsproj.SelectMany(projectFile => LoadProjectFile(projectFile).ToObservable())
            .Subscribe();

            PreviewPage = ReactiveCommand.Create((PageViewModel page) => {
                var originalFileName = File.Exists(page.FilePath)
                                       ? page.FilePath
                                       : File.Exists(page.FilePath + ".bak")
                                         ? page.FilePath + ".bak"
                                         : null;

                if (originalFileName != null)
                {
                    convertFileVm.Xaml = File.ReadAllText(originalFileName);
                }
                else
                {
                    convertFileVm.Xaml = "File doesn't exist on disk anymore";
                }

                UpdatePageFilenames();

                convertFileVm.Ammy = page.Ammy;

                _mainWindow.IsConvertFileSelected = true;
            });

            Convert = ReactiveCommand.Create(ConvertProject);
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine("Please specify a project file.");
                return;
            }

            var writer = new Writing.ProjectWriter();

            var progress = new Progress <string>(System.Console.WriteLine);

            var convertedProjects = ProjectConverter.Convert(args[0], progress)
                                    .Where(x => x != null)
                                    .ToList();

            if (!args.Contains("--dry-run"))
            {
                foreach (var project in convertedProjects)
                {
                    writer.Write(project, progress);
                }
            }
        }
Esempio n. 30
0
        public void ProjectShouldBeConvertedToXml()
        {
            Project project = new Project
            {
                Archived = false,
                Budget = 1000,
                Customer = new Customer
                {
                    Name = "test"
                },
                Id = 2,
                Name = "Test project"
            };

            string xml = new ProjectConverter().Convert(project);

            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xml);

            string value = xmlDocument.SelectSingleNode("/project/name").InnerText;

            Assert.That(value, Is.EqualTo(project.Name.ToString(CultureInfo.InvariantCulture)));
        }
Esempio n. 31
0
        public bool Run(string testFileName, string refFileName, bool interactive)
        {
            var testFileInfo = new FileInfo(testFileName);
            var refFileInfo = new FileInfo(refFileName);

            Console.Write(testFileInfo.Name + ": ");
            var originalColor = Console.ForegroundColor;

            var logger = new NullLogger();

            var testSong = new ProjectConverter().Convert(testFileName, logger);

            bool success = false;

            if (refFileInfo.Exists)
            {
                var refSong = JsonConvert.DeserializeObject<Song>(File.ReadAllText(refFileName));
                var diff = new Diff(testSong, refSong);
                if (diff.IsEmpty)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("PASSED");
                    success = true;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("MISMATCH");
                    Console.ForegroundColor = originalColor;
                    Console.WriteLine("Converted song does not match stored ref.");
                    Console.WriteLine("Diff (test, ref):");
                    Console.ForegroundColor = ConsoleColor.White;
                    diff.Print();
                    Console.ForegroundColor = originalColor;
                    if (interactive)
                    {
                        Response response;
                        do
                        {
                            response = YesNoPrompt("Update ref?");
                        } while (response == Response.Invalid);
                        if (response == Response.Yes)
                        {
                            writeRef(refFileName, testSong);
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.Write("UPDATED REF");
                            success = true;
                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Write("FAILED");
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("FAILED");
                    }
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("NO REF FOUND");
                Console.ForegroundColor = originalColor;
                if (interactive)
                {
                    Response response;
                    do
                    {
                        response = YesNoPrompt("Create ref?");
                    } while (response == Response.Invalid);
                    if (response == Response.Yes)
                    {
                        writeRef(refFileName, testSong);
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.Write("CREATED REF");
                        success = true;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Write("FAILED");
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("FAILED");
                }
            }

            Console.ForegroundColor = originalColor;
            Console.WriteLine();

            return success;
        }
Esempio n. 32
0
        public void Money_Budget_Type_Should_Be_Written_To_Xml()
        {
            Project project = new Project();
           // project.Name = "test";
            project.BudgetType = BudgetType.cents;

            ProjectConverter projectConverter = new ProjectConverter();
            string xml = projectConverter.Convert(project);

            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(xml);

            XmlNode value = xmlDocument.SelectSingleNode("/project/budget-type");

            Assert.That(value.InnerText, Is.EqualTo("cents"));
        }
Esempio n. 33
0
 public ProjectService(IDALFacade facade)
 {
     _facade = facade;
     _conv   = new ProjectConverter();
     _convPL = new PackingListConverter();
 }