Exemplo n.º 1
0
        public void MapPackagesToLibraryInfo_Unique_Should_Return_One_Result()
        {
            AddUniquePackageOption();
            PackageList list = new PackageList();

            list.Add("log4net", new Package {
                Metadata = new Metadata {
                    Id      = "log4net",
                    License = new License {
                        Text = "MIT",
                        Type = "Open"
                    },
                    Version = "2.0.8",
                },
            });

            list.Add("log4net2", new Package {
                Metadata = new Metadata {
                    Id      = "log4net",
                    License = new License {
                        Text = "MIT",
                        Type = "Open"
                    },
                    Version = "2.0.8",
                }
            });

            var packages = new Dictionary <string, PackageList> ();

            packages.Add("packages", list);
            var info = _methods.MapPackagesToLibraryInfo(packages);

            info.Count.Should().Equals(1);
        }
Exemplo n.º 2
0
        public async Task MapPackagesToLibraryInfo_Proxy_Should_Return_License()
        {
            var methods = new Methods(
                new PackageOptions
            {
                ProjectDirectory = _projectPath,
                ProxyURL         = "http://localhost:8080",
                ProxySystemAuth  = true
            });


            PackageList list = new PackageList();

            list.Add("log4net", new Package
            {
                Metadata = new Metadata
                {
                    Id      = "log4net",
                    License = new License
                    {
                        Text = "MIT",
                        Type = "Open"
                    },
                    Version = "2.0.8",
                },
            });

            list.Add("Newtonsoft.Json", new Package
            {
                Metadata = new Metadata
                {
                    Id      = "Newtonsoft.Json",
                    License = new License
                    {
                        Text = "MIT",
                        Type = "Open"
                    },
                    Version = "6.0.9",
                }
            });

            var packages = new Dictionary <string, PackageList>();

            packages.Add("packages", list);
            var info = methods.MapPackagesToLibraryInfo(packages);

            info.Count.Should().Equals(2);
        }
Exemplo n.º 3
0
        private void AddInfo()
        {
            DBScanInfo db = new DBScanInfo();

            PackageList.Add(Package);
            Package = "";
            string AllPackage = "";

            foreach (string s in PackageList)
            {
                AllPackage += s;
            }
            db.InsertUploadInfo(this.Year.ToString(), this.Login, AllPackage, this.IDZ, PDF, PIN);
            try
            {
                db.InsertPackage(PackageList, this.PIN, this.Year);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            db.BuildAndInsertHyperLink(this.PIN, this.Year.ToString());

            fp.Close();
            this.Enabled = true;
            MessageBox.Show("Привязка успешно завершена!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Tries to create packages from the specified logfiles; walking dependencies if needed.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <param name="newPackages">The new packages.</param>
        /// <returns></returns>
        public static bool TryCreatePackages(PackageArgs args, out PackageList newPackages)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            PackageState state = new PackageState(args);

            state.LoadExternalOrigins();
            state.CreateBuildOrigins();
            state.AddRequirements();

            state.CalculateDependencies();

            newPackages = new PackageList();

            List <TBLogFile> filesToRun = new List <TBLogFile>(state.Logs);

            while (filesToRun.Count > 0)
            {
                int n = 0;
                for (int i = 0; i < filesToRun.Count; i++)
                {
                    TBLogFile file = filesToRun[i];
                    if (state.CanPackage(file))
                    {
                        filesToRun.RemoveAt(i--);

                        string   target     = QQnPath.Combine(args.OutputDir, file.Project.Name + ".tpZip");
                        FileInfo targetInfo = new FileInfo(target);

                        TPack pack;
                        if (targetInfo.Exists && targetInfo.LastWriteTime > file.GetLastWriteTime())
                        {
                            pack = TPack.OpenFrom(target, VerificationMode.None);
                            state.SetOriginPack(file, pack.Pack);
                        }
                        else
                        {
                            pack = TPack.Create(target, state.CreateDefinition(file));
                        }
                        newPackages.Add(target, pack);
                        n++;
                    }
                }

                if (n == 0)
                {
                    break; // Can't package anything
                }
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加发票信息
        /// </summary>
        /// <param name="one">发票信息实体</param>
        /// <returns></returns>
        private bool InsertOne(string pkgNo, InvoiceModel one = null)
        {
            if (!String.IsNullOrEmpty(pkgNo))
            {
                var pkg = PackageList.SingleOrDefault(f => f.PkgNumber == pkgNo);
                if (pkg == null)
                {
                    pkgIndex = 1;
                    PackageList.Add(new PackageModel {
                        PkgNumber = pkgNo, InvoiceList = new List <InvoiceModel>()
                    });
                    return(true);
                }
                else
                {
                    pkgIndex = pkg.InvoiceList.Count + 1;
                }

                return(true);
            }

            if (one == null)
            {
                return(true);
            }

            if (invoiceList.Count > 0)
            {
                var exist = invoiceList.Where(f => f.Number == one.Number);
                if (exist.Count() != 0)
                {
                    if (MessageBox.Show(string.Format("发票号码:{0} 已存在,是否重复添加?", one.Number), "扫描提示", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.No)
                    {
                        return(false);
                    }
                }
            }

            if (isAllowInsert)
            {
                //invoiceList.Where(f => f.PkgNumber == one.PkgNumber && f.PkgIndex >= one.PkgIndex).ToList();
                invoiceList.Insert(insertIndex, one);

                IsAllowInsert = false;
            }
            else
            {
                invoiceList.Add(one);
            }
            IsNeedSave = true;
            return(true);
        }
Exemplo n.º 6
0
        private async Task <PackageList> GetPackageFile(XmlDocument doc, string csProjPath)
        {
            var packageList = new PackageList();

            var packageName = GetPackageName(doc, "None", "Content");

            if (!string.IsNullOrWhiteSpace(packageName))
            {
                var path            = Path.Combine(csProjPath, packageName);
                var packageFileInfo = new FileInfo(path);

                var packageDocument = await _fileUtilities.ReadXmlDocument(packageFileInfo);

                var packageNodes = packageDocument.GetElementsByTagName("package");

                foreach (XmlNode packageNode in packageNodes)
                {
                    if (packageNode != null && packageNode.Attributes.Count > 0)
                    {
                        var package = new Package();

                        foreach (XmlAttribute attribute in packageNode.Attributes)
                        {
                            var attributeName = attribute.Name.ToLowerInvariant();

                            if (attributeName.CompareTo("id") == 0)
                            {
                                package.Id = attribute.Value;
                            }
                            else if (attributeName.CompareTo("version") == 0)
                            {
                                package.Version = attribute.Value;
                            }
                            else if (attributeName.CompareTo("targetframework") == 0)
                            {
                                package.TargetFramework = attribute.Value;
                            }
                        }

                        packageList.Add(package);
                    }
                }
            }

            return(packageList);
        }
Exemplo n.º 7
0
        protected PackageList ReadRepositoryDir(DirectoryInfo dir)
        {
            if (!dir.Exists)
            {
                throw new DirectoryNotFoundException("Repository directory does not exist.");
            }
            PackageList list = new PackageList();

            foreach (DirectoryInfo pdir in dir.EnumerateDirectories())
            {
                IPackage pkg = this.ReadPackageDir(pdir);
                if (pkg != null)
                {
                    list.Add(pkg);
                }
            }
            return(list);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Gets the list of all outdated packages
        /// </summary>
        /// <returns>List of outdated packages</returns>
        public PackageList GetOutdatedPackages()
        {
            var list = new PackageList();

            var output = runCommand("apm upgrade --list");

            output = escape(output); // Remove the ANSI escape codes
            // output = Regex.Replace(output, @"â”[ś”]──\s", "");

            var outdated = r_outDated.Matches(output);

            foreach (Match m in outdated)
            {
                list.Add(m.Groups[1].Value, m.Groups[2].Value, m.Groups[3].Value);
            }

            return(list);
        }
Exemplo n.º 9
0
            /// <summary>
            /// Parses the input list of packages
            /// The list must have this format (--bare):
            ///  - one package per line
            ///  - package name and its version is separated by @ symbol
            /// </summary>
            /// <param name="list">The list of packages (as string)</param>
            /// <returns>The newly formed package list containing packages from the input</returns>
            public static PackageList Parse(string list)
            {
                var ret = new PackageList();

                var lines = list.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);

                foreach (var line in lines)
                {
                    if (line.Contains("@"))
                    {
                        var split = line.Split('@');

                        ret.Add(split[0], split[1]);
                    }
                }

                return(ret);
            }
Exemplo n.º 10
0
 private IEnumerable <Package> GetActivePackages()
 {
     try {
         List <Package> PackageList = null;
         using (DbCommand dbcmdPackage = _Database.GetStoredProcCommand(PROC_PACKAGE_GETALL)) {
             using (IDataReader reader = _Database.ExecuteReader(dbcmdPackage)) {
                 if (PackageList == null)
                 {
                     PackageList = new List <Package>();
                 }
                 PackageList.Add(Mapper(reader));
             }
         }
         return(PackageList);
     }
     catch (Exception ex) {
         throw ex;
     }
 }
Exemplo n.º 11
0
    /// <summary>
    /// Using a url and basic file info will create a download package and add it to the downloder
    /// </summary>
    /// <param name="url"></param>
    /// <param name="fileLocalPath"></param>
    /// <returns></returns>
    internal Task <DownloadPackage> AddFile(string url, string fileLocalPath = null, bool requestRemoteSize = true)
    {
        DownloadPackage package;

        package = new DownloadPackage(this, url, fileLocalPath, requestRemoteSize);

        if (State == AgentState.Busy)
        {
            package.State = PackageState.OnQueue;
        }

        PackageList.Add(package);

        TotalDownloadFilesCount++;

        //ParentDownloder.CallDownloadFileAdded(package);
        System.Console.WriteLine("Devhus.Downloader file has been added: {0}", package.MyFile.FullName);

        return(Task.FromResult(package));
    }
Exemplo n.º 12
0
        private void BuildPackageList()
        {
            var packagesPath = Path.Combine(Path.GetDirectoryName(FullPath), "packages.config");

            if (!File.Exists(packagesPath))
            {
                return;
            }

            var packageFileList = File.ReadAllLines(packagesPath);

            foreach (var s in packageFileList)
            {
                if (!s.Contains(@"package id="))
                {
                    continue;
                }

                var col = Regex.Matches(s, "\"([^\"]*)\"");

                var version = new Version(0, 0, 0, 0);
                try
                {
                    var parsedVersion = col[1].Value.Trim('"').Split('-')[0];
                    version = new Version(parsedVersion);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }

                var mPackage = new ModelPackage
                {
                    Name            = col[0].Value.Trim('"'),
                    Version         = version,
                    TargetFramework = col[2].Value.Trim('"')
                };

                PackageList.Add(mPackage);
            }
        }
Exemplo n.º 13
0
        public void loadConfig()
        {
            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/channelList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/channelList/channel");

                ChannelList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    ChannelItem item = new ChannelItem();
                    item.ChannelName = xn.SelectSingleNode("channelName").InnerText;
                    item.ChannelId   = xn.SelectSingleNode("channelId").InnerText;
                    ChannelList.Add(item);
                }
            }

            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/packageList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/packageList/package");
                PackageList.Clear();
                foreach (XmlNode xn in xnList)
                {
                    PackageItem item = new PackageItem();
                    item.Title               = xn.SelectSingleNode("pkgTitle").InnerText;
                    item.PackageName         = xn.SelectSingleNode("pkgName").InnerText;
                    item.AppName             = xn.SelectSingleNode("AppName").InnerText;
                    item.ResourceDelete      = xn.SelectSingleNode("ResourceDelete").InnerText;
                    item.ResourceEncrypt     = xn.SelectSingleNode("ResourceEncrypt").InnerText;
                    item.ResourceNormal      = xn.SelectSingleNode("ResourceNormal").InnerText;
                    item.WinPhoneDescription = xn.SelectSingleNode("WinPhoneDescription").InnerText;
                    item.WinPhoneProductID   = xn.SelectSingleNode("WinPhoneProductID").InnerText;

                    XmlNodeList metaDataList = xn.SelectNodes("metaData/item");
                    foreach (XmlNode metaData in metaDataList)
                    {
                        string k = metaData.Attributes["name"].Value;
                        string v = metaData.Attributes["value"].Value;
                        item.MetaData.Add(k, v);
                    }

                    PackageList.Add(item);
                }
            }


            {
                XmlDocument xd = new XmlDocument();
                xd.Load(Path.Combine(Application.StartupPath, "config/enableList.xml"));

                XmlNodeList xnList = xd.SelectNodes("config/enableList/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "EnableMM":
                        EnableMM = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "EnableCopyFile":
                        EnableCopyFile = xn.Attributes["value"].Value.Equals("true");
                        break;

                    case "DeleteTemp":
                        DeleteTemp = xn.Attributes["value"].Value.Equals("true");
                        break;

                    default:
                        break;
                    }
                }

                xnList = xd.SelectNodes("config/encryptConfig/item");
                foreach (XmlNode xn in xnList)
                {
                    switch (xn.Attributes["name"].Value)
                    {
                    case "AllExts":
                    {
                        EncryptCfg.AllExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.AllExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartExts":
                    {
                        EncryptCfg.PartExts.Clear();
                        string   attrValue = xn.Attributes["value"].Value;
                        string[] strArr    = attrValue.Split(';');
                        foreach (string item in strArr)
                        {
                            EncryptCfg.PartExts.Add("." + item);
                        }
                    }
                    break;

                    case "PartLength":
                        EncryptCfg.PartLength = Convert.ToInt32(xn.Attributes["value"].Value);
                        break;

                    default:
                        break;
                    }
                }


                CopyFileList.Clear();
                xnList = xd.SelectNodes("config/copyFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    CopyFileList.Add(xn.Attributes["name"].Value);
                }

                ResourceFileList.Clear();
                xnList = xd.SelectNodes("config/resourceFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    ResourceFileList.Add(xn.Attributes["name"].Value);
                }

                WinPhoneFileList.Clear();
                xnList = xd.SelectNodes("config/winPhoneFileList/item");
                foreach (XmlNode xn in xnList)
                {
                    WinPhoneFileList.Add(xn.Attributes["name"].Value);
                }
            }
        }
Exemplo n.º 14
0
        private PackageList GetPackages()
        {
            BasicPackage p1 = new BasicPackage("package1")
            {
                Description = "mydescription_package1",
                IsMaster    = false,
                Url         = "http://myurl_package1.com"
            };

            p1.Versions.Add(new PackageVersion("1.1"));
            p1.Versions.Add(new PackageVersion("1.2"));

            BasicPackage p2 = new BasicPackage("package2")
            {
                Description = "mydescription_package2",
                IsMaster    = false,
                Url         = "http://myurl_package2.com"
            };

            p2.Versions.Add(new PackageVersion("2.1"));
            p2.Versions.Add(new PackageVersion("2.2"));
            p2.Dependencies.Add(new Dependency("package1")
            {
                Version = new PackageVersion("1.1")
            });
            p2.Features.Add(new Feature("feature1")
            {
                Description = "description_feature1",
                Url         = "http://myurl_feature1.com/feat",
                Enabled     = false
            });

            BasicPackage p3 = new BasicPackage("package3")
            {
                Description = "mydescription_package3",
                IsMaster    = false,
                Url         = "http://myurl_package3.com"
            };

            p3.Versions.Add(new PackageVersion("3.1"));
            p3.Versions.Add(new PackageVersion("3.2"));
            p3.Versions.Add(new PackageVersion("3.3"));
            p3.Dependencies.Add(new Dependency("package2.feature1")
            {
                Version = new PackageVersion("2.2")
            });
            p3.Dependencies.Add(new Dependency("package1")
            {
                Version = new PackageVersion("1.1")
            });
            p3.Dependencies.Add(new Dependency("package4.feature2")
            {
                Version = new PackageVersion("4.4")
            });
            p3.Features.Add(new Feature("feature1")
            {
                Description = "description_feature1",
                Url         = "http://myurl_feature1.com/feat",
                Enabled     = false
            });
            p3.Features.Add(new Feature("feature2")
            {
                Description = "description_feature2",
                Url         = "http://myurl_feature2.com/feat",
                Enabled     = false
            });

            BasicPackage p4 = new BasicPackage("package4")
            {
                Description = "mydescription_package4",
                IsMaster    = false,
                Url         = "http://myurl_package4.com"
            };

            p4.Versions.Add(new PackageVersion("4.1"));
            p4.Versions.Add(new PackageVersion("4.4"));
            p4.Dependencies.Add(new Dependency("package2.feature1")
            {
                Version = new PackageVersion("2.2")
            });
            p4.Dependencies.Add(new Dependency("package1")
            {
                Version = new PackageVersion("1.1")
            });
            p4.Features.Add(new Feature("feature1")
            {
                Description = "description_feature1",
                Url         = "http://myurl_feature1.com/feat",
                Enabled     = false
            });
            p4.Features.Add(new Feature("feature2")
            {
                Description = "description_feature2",
                Url         = "http://myurl_feature2.com/feat",
                Enabled     = false
            });

            PackageList packages = new PackageList();

            packages.Add(p1);
            packages.Add(p2);
            packages.Add(p3);
            packages.Add(p4);
            return(packages);
        }
Exemplo n.º 15
0
        private void CommonSetup()
        {
            try
            {
                _namespaceMgr = new XmlNamespaceManager(_testCaseDoc.NameTable);
                _namespaceMgr.AddNamespace("SsisUnit", "http://tempuri.org/SsisUnit.xsd");

                var xmlPackageReferences = _testCaseDoc.SelectNodes("SsisUnit:TestSuite/SsisUnit:PackageList/SsisUnit:Package", _namespaceMgr);

                if (xmlPackageReferences != null)
                {
                    foreach (XmlNode pkgRef in xmlPackageReferences)
                    {
                        if (pkgRef.Attributes == null)
                        {
                            continue;
                        }

                        PackageList.Add(pkgRef.Attributes["name"].Value, new PackageRef(pkgRef));
                    }
                }

                ConnectionList = _testCaseDoc.DocumentElement != null?LoadConnectionRefs(_testCaseDoc.DocumentElement["ConnectionList"]) : new Dictionary <string, ConnectionRef>();

                var xmlDatasets = _testCaseDoc.SelectNodes("SsisUnit:TestSuite/SsisUnit:DatasetList/SsisUnit:Dataset", _namespaceMgr);

                if (xmlDatasets != null)
                {
                    foreach (XmlNode xmlDataset in xmlDatasets)
                    {
                        if (xmlDataset.Attributes == null)
                        {
                            continue;
                        }

                        Datasets.Add(xmlDataset.Attributes["name"].Value, new Dataset(this, xmlDataset));
                    }
                }

                TestSuiteSetup    = _testCaseDoc.DocumentElement != null ? new CommandSet("Test Suite Setup", this, _testCaseDoc.DocumentElement["TestSuiteSetup"]) : new CommandSet(this);
                TestSuiteTeardown = _testCaseDoc.DocumentElement != null ? new CommandSet("Test Suite Teardown", this, _testCaseDoc.DocumentElement["TestSuiteTeardown"]) : new CommandSet(this);
                SetupCommands     = _testCaseDoc.DocumentElement != null ? new CommandSet("Unit Test Setup", this, _testCaseDoc.DocumentElement["Setup"]) : new CommandSet(this);
                TeardownCommands  = _testCaseDoc.DocumentElement != null ? new CommandSet("Unit Test Teardown", this, _testCaseDoc.DocumentElement["Teardown"]) : new CommandSet(this);

                var xmlTests = _testCaseDoc.SelectNodes("SsisUnit:TestSuite/SsisUnit:Tests/SsisUnit:Test", _namespaceMgr);

                if (xmlTests != null)
                {
                    foreach (XmlNode test in xmlTests)
                    {
                        if (test.Attributes == null)
                        {
                            continue;
                        }

                        Test newTest = new Test(this, test);

                        newTest.CommandCompleted += OnRaiseCommandCompleted;
                        newTest.CommandFailed    += OnRaiseCommandFailed;
                        newTest.CommandStarted   += OnRaiseCommandStarted;

                        Tests.Add(test.Attributes["name"].Value, newTest);
                    }
                }

                var xmlTestReferences = _testCaseDoc.SelectNodes("SsisUnit:TestSuite/SsisUnit:Tests/SsisUnit:TestRef", _namespaceMgr);

                if (xmlTestReferences != null)
                {
                    foreach (XmlNode testRef in xmlTestReferences)
                    {
                        if (testRef.Attributes == null)
                        {
                            continue;
                        }

                        TestRefs.Add(testRef.Attributes["path"].Value, new TestRef(this, testRef));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(string.Format("The unit test file is malformed or corrupt. Please verify that the file format conforms to the ssisUnit schema, provided in the SsisUnit.xsd file."), ex);
            }
        }