Exemplo n.º 1
0
        private void UpdateLedger()
        {
            FileInfo file           = new FileInfo(_localFullPath);
            var      settings       = SettingsLoader.LoadSettings();
            var      ledgerRowModel = new LedgerRowModel
            {
                UploadDateTime       = DateTime.Now,
                FileIdentifier       = FileIdGenerator.GetIdentifier(),
                FileName             = file.Name,
                LastDownloadDateTime = DateTime.MinValue,
                Username             = settings.FtpUsername
            };

            LedgerManager.GetManager().AddDatabaseToLedger(ledgerRowModel);
            LedgerManager.SaveLedger();
        }
Exemplo n.º 2
0
        private static string ExamineProjectItem(ProjectItem item, ProjectScanItem projectScan,
                                                 IVsHierarchy projectHierarchy)
        {
            var fileName = item.FileNames[1];

            if (Path.GetExtension(fileName) != ".cs")
            {
                return(null);
            }

            var code = item.FileCodeModel;

            if (code == null)
            {
                return(null);
            }

            var className     = string.Empty;
            var namespaceName = string.Empty;

            foreach (CodeElement codeElement in code.CodeElements)
            {
                if (string.IsNullOrEmpty(className))
                {
                    className = ExamineCodeElement(codeElement, vsCMElement.vsCMElementClass);
                }
                if (string.IsNullOrEmpty(namespaceName))
                {
                    namespaceName = ExamineCodeElement(codeElement, vsCMElement.vsCMElementNamespace);
                }

                if (!string.IsNullOrEmpty(className) && !string.IsNullOrEmpty(namespaceName))
                {
                    break;
                }
            }

            if (string.IsNullOrEmpty(className))
            {
                return(null);
            }
            uint itemId;

            if (projectHierarchy.ParseCanonicalName(item.FileNames[0], out itemId) == VSConstants.S_OK)
            {
                var buildPropertyStorage =
                    projectHierarchy as IVsBuildPropertyStorage;

                if (buildPropertyStorage == null)
                {
                    return(null);
                }
                string fileGuid;
                buildPropertyStorage.GetItemAttribute(itemId, PersistentFileGuidName, out fileGuid);
                if (string.IsNullOrEmpty(fileGuid))
                {
                    fileGuid = Guid.NewGuid().ToString();
                    buildPropertyStorage.SetItemAttribute(itemId, PersistentFileGuidName, fileGuid);
                    item.ContainingProject.Save();
                }

                if (string.IsNullOrEmpty(fileGuid))
                {
                    return(null);
                }

                var file = projectScan.Files.FirstOrDefault(x => x.ProjectFileId == fileGuid);

                var fileId = FileIdGenerator.Compute(namespaceName, className);

                if (file == null)
                {
                    projectScan.Files.Add(new FileScanItem {
                        ProjectFileId = fileGuid, OldId = fileId
                    });
                }
                else
                {
                    var newId = fileId;
                    if (file.OldId != newId)
                    {
                        file.NewId = newId;
                    }
                }

                return(fileGuid);
            }

            return(null);
        }