internal LibraryInfo Refresh(AssemblyResolver resolver, string assembly) { assembly = Path.GetFullPath(assembly); if (IsCurrent(assembly)) { return(Members [assembly]); } LibraryInfo info = Members [assembly]; if (info == null) { info = new LibraryInfo(); info.File = assembly; Members.Add(info); } info.Timestamp = File.GetLastWriteTime(assembly).ToUniversalTime(); info.Guid = Guid.NewGuid(); Save(); AssemblyDefinition adef = AssemblyFactory.GetAssembly(assembly); XmlDocument objects = GetObjectsDoc(resolver, adef, assembly); if (objects != null) { info.ObjectsDocument = objects; XmlDocument gui = GetGuiDoc(adef); if (gui != null) { info.GuiDocument = gui; } } return(info); }
//更新图书馆信息 public bool SetLibraryInfo(LibraryInfo l) { StringBuilder sql = new StringBuilder(); Dictionary <string, string> values = new Dictionary <string, string>(); sql.Append(@"UPDATE [dbo].[tb_library] SET [libraryName] = @libraryName ,[curator]=@curator ,[tel]=@tel ,[address]=@address ,[email]=@email ,[net] =@net ,[upbuildTime]=@upbuildTime ,[remark]=@remark"); values.Add("@libraryName", l.libraryName); values.Add("@curator", l.curator); values.Add("@tel", l.tel); values.Add("@address", l.address); values.Add("@email", l.email); values.Add("@net", l.net); values.Add("@upbuildTime", l.upbuildTime); values.Add("@remark", l.remark); return(BookInfoService.UpBookInfo(sql.ToString(), values)); }
public override async Task DownloadLibrary(LibraryInfo library, string savePath) { if (library.HasLibrary()) { var url = library.GetLibrary()?.Url; if (string.IsNullOrEmpty(url)) { url = $"{Server}{library.GetLibraryPath().Replace('\\', '/')}"; } url = _vanillaServer.Replace(url, Server); url = _forgeServeRegex.Replace(url, Server); Logger.Info(url); await Downloader.DownloadFileTaskAsync(url, savePath); } if (library.IsNative) { var url = library.GetNative().Url; if (string.IsNullOrEmpty(url)) { url = $"{Server}{library.GetNativePath().Replace('\\', '/')}"; } url = _vanillaServer.Replace(url, Server); url = _forgeServeRegex.Replace(url, Server); await Downloader.DownloadFileTaskAsync(url, savePath); } }
//图书馆信息操作 public LibraryInfo GetLibraryInfo() { LibraryInfo L = new LibraryInfo(); try { DataRow dr = DBHelper.GetDataRow(@"SELECT [libraryName] ,[curator] ,[tel] ,[address] ,[email] ,[net] ,[upbuildTime] ,[remark] FROM[dbo].[tb_library]"); L.libraryName = dr["libraryName"] == DBNull.Value ? string.Empty : dr["libraryName"].ToString().Trim(); L.curator = dr["curator"] == DBNull.Value ? string.Empty : dr["curator"].ToString().Trim(); L.tel = dr["tel"] == DBNull.Value ? string.Empty : dr["tel"].ToString().Trim(); L.address = dr["address"] == DBNull.Value ? string.Empty : dr["address"].ToString().Trim(); L.email = dr["email"] == DBNull.Value ? string.Empty : dr["email"].ToString().Trim(); L.net = dr["net"] == DBNull.Value ? string.Empty : dr["net"].ToString().Trim(); L.upbuildTime = dr["upbuildTime"] == DBNull.Value ? string.Empty : dr["upbuildTime"].ToString().Trim(); L.remark = dr["remark"] == DBNull.Value ? string.Empty : dr["remark"].ToString().Trim(); } catch (Exception) { } return(L); }
private void InitLibraryData(LibraryInfo li) { string localProductDirectoryRoot = GetBuildProperty("LocalProductDirectoryRoot"); string productPath = li.productDirectory + "\\v" + li.productVersion.Replace('.', '_') + "." + li.productPlatform; string buildPath = li.libraryPath; string updateDate = li.updateDate; if (buildPath.ToUpper().IndexOf(LBEnvironment.NetworkProductRootDir.ToUpper()) >= 0) { buildPath = Path.Combine(localProductDirectoryRoot, productPath + "\\NETWORK_" + li.branchOrTrunckName + "_BUILD"); //if a direct copy from the network, use the current database datetime //refresh the LibraryInfo file in ProductBuild.cs updateDate = DatabaseUtil.GetVMSServerTime().ToString(); } string stablePath = Path.Combine(LBEnvironment.NetworkProductRootDir, productPath + "\\" + "STABLE"); SetBuildProperty("ProductName", li.productName, false); SetBuildProperty("ProductVersion", li.productVersion, false); SetBuildProperty("ProductPlatform", li.productPlatform, false); SetBuildProperty("BranchOrTrunkName", li.branchOrTrunckName, false); SetBuildProperty("ProductDirectory", li.productDirectory, false); SetBuildProperty("LibraryDate", updateDate, false); SetBuildProperty("BuildPath", buildPath, true); SetBuildProperty("SourcePath", li.libraryPath, false); SetBuildProperty("PopulatePath", li.libraryPath, true); SetBuildProperty("StablePath", stablePath, false); string toRecipients = ProcessEmailRecipients(GetBuildProperty("EmailRecipients"), true); SetBuildProperty("EmailRecipients", toRecipients, true); }
public void Initialize(MgaProject p) { // Creating addon p.CreateAddOn(this, out addon); // Setting event mask (see ComponentConfig.eventMask) unchecked { addon.EventMask = (uint)ComponentConfig.eventMask; } this.project = p; if (metaPath == null) { metaPath = Path.Combine(META.VersionInfo.MetaPath, "meta"); } if (!Directory.Exists(metaPath)) { throw new ApplicationException(metaPath + " doesn't exist"); } //qudtTimer = new LibraryTimer("QudtTimer", new TimerLogicDelegate(QudtTimerHandler), project, control); //portLibTimer = new LibraryTimer("PortLibTimer", new TimerLogicDelegate(PortLibTimerHandler), project, control); QudtLibraryInfo = new LibraryInfo("CyPhyMLQudt", "UnitLibrary QUDT", new Action(QudtTimerHandler), project, control); PortLibraryInfo = new LibraryInfo("CyPhy_PortLib", "PortLibrary CyPhy_PortLib", new Action(PortLibTimerHandler), project, control); MaterialLibraryInfo = new LibraryInfo("CyPhy_MaterialLib", "MaterialLibrary CyPhy_MaterialLib", new Action(MaterialLibTimerHandler), project, control); CADResourceLibraryInfo = new LibraryInfo("CyPhy_CADResourceLib", "CADResourceLibrary", new Action(CADResourceLibTimerHandler), project, control); }
public override async Task DownloadLibrary(LibraryInfo library, string savePath) { var url = library.Url ?? Server + library.Path; url = _vanillaServer.Replace(url, Server); await Downloader.DownloadFileTaskAsync(url, savePath); }
public bool IsCurrent(string file) { file = Path.GetFullPath(file); LibraryInfo info = Members [file]; return(info != null && info.Timestamp == File.GetLastWriteTime(file).ToUniversalTime()); }
LibraryInfo Refresh(AssemblyResolver resolver, string assembly, string baseDirectory) { LibraryInfo info = GetInfo(resolver, assembly, baseDirectory); if (info == null || info.IsCurrent || !File.Exists(info.File)) { return(info); } info.Timestamp = File.GetLastWriteTime(info.File).ToUniversalTime(); info.Guid = Guid.NewGuid(); Save(); AssemblyDefinition adef = AssemblyDefinition.ReadAssembly(info.File); XmlDocument objects = GetObjectsDoc(resolver, adef, info.File, baseDirectory); if (objects != null) { info.ObjectsDocument = objects; XmlDocument gui = GetGuiDoc(adef); if (gui != null) { info.GuiDocument = gui; } } info.OnChanged(); return(info); }
public static bool IsLibraryAllowed(LibraryInfo lib) { if (lib.Rules == null) { return(true); } var allowed = false; foreach (var rule in lib.Rules) { var matchingOs = string.Equals(Platform.Name, rule.Os?.Name, StringComparison.Ordinal); var undefinedOs = string.IsNullOrEmpty(rule.Os?.Name); if (rule.Action == "allow" && (matchingOs || undefinedOs)) { allowed = true; } else if (rule.Action == "disallow" && matchingOs) { allowed = false; } } return(allowed); }
/// <summary> /// 更新图书馆信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool UpdataLibraryInfo(LibraryInfo model) { IWCFService.ISeatManageService seatService = WcfAccessProxy.ServiceProxy.CreateChannelSeatManageService(); bool error = false; try { return(seatService.UpdateLibrary(model)); } catch (Exception ex) { error = true; WriteLog.Write("更新图书馆失败:" + ex.Message); return(false); } finally { ICommunicationObject ICommObjectService = seatService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
internal Pkcs11LibraryInfo(string libraryPath, LibraryInfo libraryInfo) { LibraryPath = libraryPath; CryptokiVersion = libraryInfo.CryptokiVersion; ManufacturerId = libraryInfo.ManufacturerId; Flags = libraryInfo.Flags; LibraryDescription = libraryInfo.LibraryDescription; LibraryVersion = libraryInfo.LibraryVersion; }
public ITunesMediaLibrary(LibraryInfo info) { this._info = info; this._client = new Client(info.Location, 3689); this._client.Login(); _tempFilename = Path.GetTempFileName(); File.Delete(_tempFilename); // previous method actually creates the file }
private LibraryInfo DataRowToLibraryInfo(DataRow dr) { LibraryInfo library = new LibraryInfo(); library.No = dr["LibraryNo"].ToString(); library.Name = dr["LibraryName"].ToString(); library.School.No = dr["SchoolNo"].ToString(); library.AreaList = library.ToList(dr["AreaInfo"].ToString()); return(library); }
public void _01_BasicGetInfoTest() { using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.UseOsLocking)) { LibraryInfo libraryInfo = pkcs11.GetInfo(); // Do something interesting with library information Assert.IsFalse(String.IsNullOrEmpty(libraryInfo.ManufacturerId)); } }
/// <summary> /// 获取图书馆列表 /// </summary> /// <param name="Schoolno"></param> /// <param name="no"></param> /// <param name="name"></param> /// <returns></returns> public List <SeatManage.ClassModel.LibraryInfo> GetLibraryList(string Schoolno, string no, string name) { StringBuilder strWhere = new StringBuilder(); if (!string.IsNullOrEmpty(Schoolno)) { strWhere.Append(" SchoolNo='" + Schoolno + "'"); } if (!string.IsNullOrEmpty(no)) { if (string.IsNullOrEmpty(strWhere.ToString())) { strWhere.Append(" LibraryNo='" + no + "'"); } else { strWhere.Append(" and LibraryNo='" + no + "'"); } } if (!string.IsNullOrEmpty(name)) { if (string.IsNullOrEmpty(strWhere.ToString())) { strWhere.Append(" LibraryName='" + name + "'"); } else { strWhere.Append(" and LibraryName='" + name + "'"); } } try { DataSet ds = t_sm_library_dal.GetList(strWhere.ToString(), null); List <LibraryInfo> list = new List <LibraryInfo>(); if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { LibraryInfo lib = new LibraryInfo(); lib = DataRowToLibraryInfo(dr); List <School> scl = GetSchoolList(lib.School.No, null); if (scl.Count > 0) { lib.School = scl[0]; } list.Add(lib); } } return(list); } catch { throw; } }
public CompileTargets() { PocoLibrary = new LibraryInfo("Poco", "dotnet_poco", PocoDependencies); ClientLibrary = new LibraryInfo("Client", "dotnet_client", PocoDependencies); PortableLibrary = new LibraryInfo("Portable", "dotnet_portable", new string[0]); PhpSource = new LibraryInfo("Php", "php_client", new string[0], true, ".php"); WpfLibrary = new LibraryInfo("Wpf", "wpf", WpfDependencies); PostgresLibrary = new LibraryInfo("Postgres", "dotnet_server_postgres", RevenjDependencies); OracleLibrary = new LibraryInfo("Oracle", "dotnet_server_oracle", RevenjDependencies); Targets = new[] { PocoLibrary, ClientLibrary, PortableLibrary, PhpSource, WpfLibrary, PostgresLibrary, OracleLibrary }; }
public static void LoadInfoFromFile(this Library library, string fileName) { if (File.Exists(fileName)) { using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { LibraryInfo libraryInfo = LibraryInfo.LoadFromStream(stream); library.IsSuspect = libraryInfo.IsSuspect; library.SuspectReason = libraryInfo.SuspectReason; } } }
public void _01_BasicGetInfoTest() { Helpers.CheckPlatform(); using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.AppType)) { LibraryInfo libraryInfo = pkcs11.GetInfo(); // Do something interesting with library information Assert.IsFalse(String.IsNullOrEmpty(libraryInfo.ManufacturerId)); } }
public void _02_LibraryInfoMatches() { if (Platform.UnmanagedLongSize != 8 || Platform.StructPackingSize != 0) { Assert.Inconclusive("Test cannot be executed on this platform"); } using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.UseOsLocking)) { LibraryInfo libraryInfo = pkcs11.GetInfo(); // Empty URI Pkcs11Uri pkcs11uri = new Pkcs11Uri(@"pkcs11:"); Assert.IsTrue(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // Unknown path attribute in URI pkcs11uri = new Pkcs11Uri(@"pkcs11:vendor=foobar"); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // All attributes matching Pkcs11UriBuilder pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsTrue(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // LibraryManufacturer nonmatching pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = "foobar"; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // LibraryDescription nonmatching pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = "foobar"; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // LibraryVersion nonmatching pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = "0"; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); } }
public override async Task DownloadLibrary(LibraryInfo library, string savePath) { if (library.HasLibrary()) { var url = library.GetLibrary()?.Url ?? Server + library.GetLibraryPath(); await Downloader.DownloadFileTaskAsync(url, savePath); } if (library.IsNative) { var url = library.GetNative().Url ?? Server + library.GetNativePath(); await Downloader.DownloadFileTaskAsync(url, savePath); } }
public void _06_GetMatchingSlotList() { if (Platform.UnmanagedLongSize != 8 || Platform.StructPackingSize != 0) { Assert.Inconclusive("Test cannot be executed on this platform"); } using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.UseOsLocking)) { // Get all slots List <Slot> allSlots = pkcs11.GetSlotList(true); Assert.IsTrue(allSlots != null && allSlots.Count > 0); // Empty URI Pkcs11Uri pkcs11uri = new Pkcs11Uri(@"pkcs11:"); List <Slot> matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == allSlots.Count); // Unknown path attribute in URI pkcs11uri = new Pkcs11Uri(@"pkcs11:vendor=foobar"); matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == 0); // All attributes matching one slot LibraryInfo libraryInfo = pkcs11.GetInfo(); SlotInfo slotInfo = allSlots[0].GetSlotInfo(); TokenInfo tokenInfo = allSlots[0].GetTokenInfo(); Pkcs11UriBuilder pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11UriBuilder.SlotManufacturer = slotInfo.ManufacturerId; pkcs11UriBuilder.SlotDescription = slotInfo.SlotDescription; pkcs11UriBuilder.SlotId = slotInfo.SlotId; pkcs11UriBuilder.Token = tokenInfo.Label; pkcs11UriBuilder.Manufacturer = tokenInfo.ManufacturerId; pkcs11UriBuilder.Serial = tokenInfo.SerialNumber; pkcs11UriBuilder.Model = tokenInfo.Model; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == 1); // One attribute nonmatching pkcs11UriBuilder.Serial = "foobar"; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == 0); } }
public void CreateLibrary() { var info = new LibraryInfo { Location = "127.0.0.1", }; var library = new ITunesMediaLibrary(info); foreach (var song in library.GetSongs()) { Trace.WriteLine(string.Format("Song: {0} by {1}", song.Title, song.Artist), "ListSongs"); } }
public IMusicLibrary Create(LibraryInfo libraryInfo) { switch (libraryInfo.Type) { case LibraryType.GoogleMusic: return new GooglePlay.GoogleMusicMusicLibrary(libraryInfo.Username, libraryInfo.Password); case LibraryType.SharedFolder: return new Implementation.FileSystemMusicLibrary(libraryInfo.Location, _metadataService); default: throw new ArgumentOutOfRangeException("libraryInfo.Type", libraryInfo.Type, "Unknown type"); } }
public void _02_LibraryInfoMatches() { Helpers.CheckPlatform(); using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.AppType)) { LibraryInfo libraryInfo = pkcs11.GetInfo(); // Empty URI Pkcs11Uri pkcs11uri = new Pkcs11Uri(@"pkcs11:"); Assert.IsTrue(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // Unknown path attribute in URI pkcs11uri = new Pkcs11Uri(@"pkcs11:vendor=foobar"); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // All attributes matching Pkcs11UriBuilder pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsTrue(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // LibraryManufacturer nonmatching pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = "foobar"; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // LibraryDescription nonmatching pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = "foobar"; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); // LibraryVersion nonmatching pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = "0"; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); Assert.IsFalse(Pkcs11UriUtils.Matches(pkcs11uri, libraryInfo)); } }
void AddDependencies(XmlElement elem, AssemblyResolver resolver, string filename, AssemblyDefinition asm) { string dir = Path.GetDirectoryName(filename); foreach (AssemblyNameReference aref in asm.MainModule.AssemblyReferences) { LibraryInfo info = GetInfo(resolver, aref.FullName, dir); if (info != null && info.HasWidgets) { XmlElement edep = elem.OwnerDocument.CreateElement("dependency"); edep.InnerText = info.File; elem.AppendChild(edep); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LibraryInfo l = lm.GetLibraryInfo(); library_name.InnerText = l.libraryName; library_time.InnerText = l.upbuildTime; library_txt.InnerText = l.remark; library_address.InnerText = l.address; library_emil.InnerText = l.email; library_phone.InnerText = l.tel; library_website.InnerText = l.net; library_man.InnerText = l.curator; } }
public void LoadComplist() { string productName = GetBuildProperty("ProductName"); string productVersion = GetBuildProperty("ProductVersion"); string productPlatform = GetBuildProperty("ProductPlatform"); string productBranchOrTrunkName = GetBuildProperty("BranchOrTrunkName"); string productDirectory = GetBuildProperty("ProductDirectory"); string libraryPath = GetBuildProperty("BuildPath"); string updateDate = GetBuildProperty("LibraryDate"); LibraryInfo libraryInfo = new LibraryInfo(productName, productVersion, productPlatform, productBranchOrTrunkName, productDirectory, libraryPath, updateDate); Merge(GetComponentDataSet(libraryInfo), false, MissingSchemaAction.Ignore); ResolveExclusionLists(); AcceptChanges(); }
public void _01_BasicGetInfoTest() { if (Platform.UnmanagedLongSize != 4 || Platform.StructPackingSize != 0) { Assert.Inconclusive("Test cannot be executed on this platform"); } using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.AppType)) { LibraryInfo libraryInfo = pkcs11.GetInfo(); // Do something interesting with library information Assert.IsFalse(String.IsNullOrEmpty(libraryInfo.ManufacturerId)); } }
public void _06_GetMatchingSlotList() { Helpers.CheckPlatform(); using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.AppType)) { // Get all slots List <Slot> allSlots = pkcs11.GetSlotList(SlotsType.WithTokenPresent); Assert.IsTrue(allSlots != null && allSlots.Count > 0); // Empty URI Pkcs11Uri pkcs11uri = new Pkcs11Uri(@"pkcs11:"); List <Slot> matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == allSlots.Count); // Unknown path attribute in URI pkcs11uri = new Pkcs11Uri(@"pkcs11:vendor=foobar"); matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == 0); // All attributes matching one slot LibraryInfo libraryInfo = pkcs11.GetInfo(); SlotInfo slotInfo = allSlots[0].GetSlotInfo(); TokenInfo tokenInfo = allSlots[0].GetTokenInfo(); Pkcs11UriBuilder pkcs11UriBuilder = new Pkcs11UriBuilder(); pkcs11UriBuilder.LibraryManufacturer = libraryInfo.ManufacturerId; pkcs11UriBuilder.LibraryDescription = libraryInfo.LibraryDescription; pkcs11UriBuilder.LibraryVersion = libraryInfo.LibraryVersion; pkcs11UriBuilder.SlotManufacturer = slotInfo.ManufacturerId; pkcs11UriBuilder.SlotDescription = slotInfo.SlotDescription; pkcs11UriBuilder.SlotId = slotInfo.SlotId; pkcs11UriBuilder.Token = tokenInfo.Label; pkcs11UriBuilder.Manufacturer = tokenInfo.ManufacturerId; pkcs11UriBuilder.Serial = tokenInfo.SerialNumber; pkcs11UriBuilder.Model = tokenInfo.Model; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == 1); // One attribute nonmatching pkcs11UriBuilder.Serial = "foobar"; pkcs11uri = pkcs11UriBuilder.ToPkcs11Uri(); matchedSlots = Pkcs11UriUtils.GetMatchingSlotList(pkcs11uri, pkcs11, true); Assert.IsTrue(matchedSlots.Count == 0); } }
/// <summary> /// 删除图书馆信息,会连同下属阅览室以及座位信息一同删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool DeleteLibrary(LibraryInfo model) { IWCFService.ISeatManageService seatService = new WcfServiceForSeatManage.SeatManageDateService(); bool error = false; try { return(seatService.DeleteLibrary(model)); } catch (Exception ex) { error = true; WriteLog.Write("删除图书馆失败:" + ex.Message); return(false); } }
/// <summary> /// Creates new instance of Pkcs11X509StoreInfo class /// </summary> /// <param name="libraryPath">Name of or path to PKCS#11 library</param> /// <param name="libraryInfo">General information about PKCS#11 library (CK_INFO)</param> internal Pkcs11X509StoreInfo(string libraryPath, LibraryInfo libraryInfo) { if (string.IsNullOrEmpty(libraryPath)) { throw new ArgumentNullException(nameof(libraryPath)); } if (libraryInfo == null) { throw new ArgumentNullException(nameof(libraryInfo)); } _libraryPath = libraryPath; _manufacturer = libraryInfo.ManufacturerId; _description = libraryInfo.LibraryDescription; }
static private ProductBuildDataSet GetComponentDataSet(LibraryInfo libraryInfo) { ProductBuildDataSet componentDataSet = new ProductBuildDataSet(); SqlConnection vmsDatabase = null; SqlDataReader complistReader = null; try { vmsDatabase = new SqlConnection(DatabaseUtil.sqlConnectionString); vmsDatabase.Open(); SqlCommand complistCmd = new SqlCommand("GET_BUILD_COMPILATION_LIST", vmsDatabase); complistCmd.CommandType = CommandType.StoredProcedure; complistCmd.CommandTimeout = 180; complistCmd.Parameters.Add("@productName", SqlDbType.VarChar).Value = libraryInfo.productName; complistCmd.Parameters.Add("@productVer", SqlDbType.VarChar).Value = libraryInfo.productVersion; complistCmd.Parameters.Add("@platCode", SqlDbType.VarChar).Value = libraryInfo.productPlatform; complistCmd.Parameters.Add("@level", SqlDbType.VarChar).Value = libraryInfo.branchOrTrunckName; complistCmd.Parameters.Add("@date", SqlDbType.DateTime).Value = (libraryInfo.updateDate != null) ? (Object)libraryInfo.updateDate : DBNull.Value; complistCmd.Parameters.Add("RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue; complistReader = complistCmd.ExecuteReader(); while (complistReader.Read()) { string descriptorName = complistReader[1].ToString(); string targetName = complistReader[2].ToString(); int extensionPos = descriptorName.LastIndexOf(".") + 1; string descriptorExtension = (extensionPos > 0) ? descriptorName.Substring(extensionPos).ToLower() : ""; extensionPos = targetName.LastIndexOf(".") + 1; string targetExtension = (extensionPos > 0) ? targetName.Substring(extensionPos).ToLower() : ""; componentDataSet.Tables[on.Component].LoadDataRow(new object[] { complistReader[0], descriptorName, descriptorExtension, true }, true); componentDataSet.Tables[on.Target].LoadDataRow(new object[] { complistReader[0], targetName, targetExtension, true }, true); } } finally { if (vmsDatabase != null) { vmsDatabase.Close(); } if (complistReader != null) { complistReader.Close(); } } return(componentDataSet); }
public void _01_EjectTokenTest() { using (Pkcs11 pkcs11 = new Pkcs11(Settings.Pkcs11LibraryPath, Settings.UseOsLocking)) { LibraryInfo libraryInfo = pkcs11.GetInfo(); if (libraryInfo.LibraryDescription != "Mock module" && libraryInfo.ManufacturerId != "Pkcs11Interop Project") { Assert.Inconclusive("Test cannot be executed with this PKCS#11 library"); } // Find first slot with token present Slot slot = Helpers.GetUsableSlot(pkcs11); // Eject token via vendor specific function C_EjectToken slot.EjectToken(); } }
public void Add (LibraryInfo info) { libs [info.File] = info; }
LibraryInfo GetInfo (AssemblyResolver resolver, string assembly, string baseDirectory) { string file = assembly; if (File.Exists (assembly)) file = assembly; else { if (resolver == null) resolver = new AssemblyResolver (null); try { string path = resolver.Resolve (assembly, baseDirectory); if (path != null) file = path; else return null; } catch (Exception) { return null; } } file = Path.GetFullPath (file); LibraryInfo info = Members [file]; if (info == null) { info = new LibraryInfo (); info.File = file ?? assembly; Members.Add (info); } return info; }
private Either<Dictionary<string, string>> RunCompiler(string dslCompiler, LibraryInfo target, List<string> dsls) { var sb = new StringBuilder(); sb.Append("target=").Append(target.CompilerName); if (target.WithActiveRecord) sb.Append(" settings=active-record"); if (!target.WithHelperMethods) sb.Append(" settings=no-helpers"); if (target.WithManualJson) sb.Append(" settings=manual-json"); if (target.UseUtc) sb.Append(" settings=utc"); if (target.MinimalSerialization) sb.Append(" settings=minimal-serialization"); if (target.NoPrepareExecute) sb.Append(" settings=no-prepare-execute"); if (target.Legacy) sb.Append(" settings=legacy"); if (target.NoHelpers) sb.Append(" settings=no-helpers"); sb.Append(" format=xml"); var result = Compiler.CompileDsl(sb, dsls, null, cms => XElement.Load(cms)); if (result.Success) { var dict = (from x in result.Value.Elements() let elem = x.Elements() select new { key = elem.First().Value, value = elem.Last().Value }) .ToDictionary(it => it.key, it => it.value); return Either.Success(dict); } else return Either<Dictionary<string, string>>.Fail(result.Error); }
private void Compile(LibraryInfo info, Dictionary<string, string> files, bool filter) { if (!info.Compile) return; var references = info.References .Concat(Directory.GetFiles(info.DependenciesPath, "*.dll")) .Except(new[] { Path.Combine(info.DependenciesPath, info.Name + ".dll") }); var sources = files.Select(it => it.Value).ToArray(); var target = Path.Combine(info.TargetPath, info.Name + ".dll"); var assembly = Compiler.GenerateAssembly(target, sources, references); }
private void ReadInfo(LibraryInfo info, IPropertyBag pBag) { info.CompileOption = TryReadBool(info.Type + ".Compile", pBag); if (!info.SourceOnly) info.Name = TryReadString(info.Type + ".Name", pBag) ?? info.Name; info.Target = TryReadString(info.Type + ".Target", pBag) ?? info.Target; info.Dependencies = TryReadString(info.Type + ".Dependencies", pBag) ?? info.Dependencies; info.Namespace = TryReadString(info.Type + ".Namespace", pBag) ?? info.Namespace; info.WithActiveRecord = TryReadBool(info.Type + ".ActiveRecord", pBag, info.WithActiveRecord); info.WithHelperMethods = TryReadBool(info.Type + ".HelperMethods", pBag, info.WithHelperMethods); info.WithManualJson = TryReadBool(info.Type + ".WithManualJson", pBag, info.WithManualJson); info.UseUtc = TryReadBool(info.Type + ".UseUtc", pBag, info.UseUtc); info.Legacy = TryReadBool(info.Type + ".Legacy", pBag, info.Legacy); info.MinimalSerialization = TryReadBool(info.Type + ".MinimalSerialization", pBag, info.MinimalSerialization); info.NoPrepareExecute = TryReadBool(info.Type + ".NoPrepareExecute", pBag, info.NoPrepareExecute); }
private void WriteInfo(LibraryInfo info, IPropertyBag pBag) { var reference = new LibraryInfo(info.Type, null, null); object val; if (reference.CompileOption != info.CompileOption) { val = info.CompileOption.ToString(); pBag.Write(info.Type + ".Compile", ref val); } if (reference.Name != info.Name) { val = info.Name; pBag.Write(info.Type + ".Name", ref val); } if (reference.Target != info.Target) { val = info.Target; pBag.Write(info.Type + ".Target", ref val); } if (reference.Dependencies != info.Dependencies) { val = info.Dependencies; pBag.Write(info.Type + ".Dependencies", ref val); } if (reference.Namespace != info.Namespace) { val = info.Namespace; pBag.Write(info.Type + ".Namespace", ref val); } if (reference.WithActiveRecord != info.WithActiveRecord) { val = info.WithActiveRecord.ToString(); pBag.Write(info.Type + ".ActiveRecord", ref val); } if (reference.WithHelperMethods != info.WithHelperMethods) { val = info.WithHelperMethods.ToString(); pBag.Write(info.Type + ".HelperMethods", ref val); } if (reference.WithManualJson != info.WithManualJson) { val = info.WithManualJson.ToString(); pBag.Write(info.Type + ".WithManualJson", ref val); } if (reference.UseUtc != info.UseUtc) { val = info.UseUtc.ToString(); pBag.Write(info.Type + ".UseUtc", ref val); } if (reference.Legacy != info.Legacy) { val = info.Legacy.ToString(); pBag.Write(info.Type + ".Legacy", ref val); } if (reference.MinimalSerialization != info.MinimalSerialization) { val = info.MinimalSerialization.ToString(); pBag.Write(info.Type + ".MinimalSerialization", ref val); } if (reference.NoPrepareExecute != info.NoPrepareExecute) { val = info.NoPrepareExecute.ToString(); pBag.Write(info.Type + ".NoPrepareExecute", ref val); } }
private void AttachLibrary(LibraryInfo libraryInfo) { string mgaPath = metaPath + "\\" + libraryInfo.MgaName + ".mga"; if ((project.ProjectStatus & PROJECT_STATUS_OPEN) == PROJECT_STATUS_OPEN) { if (!File.Exists(mgaPath)) { GMEConsole.Error.WriteLine("Path '" + mgaPath + "' does not exist. Cannot attach " + libraryInfo.MgaName); return; } project.Notify(globalevent_enum.APPEVENT_LIB_ATTACH_BEGIN); try { project.BeginTransaction(project.ActiveTerritory); IMgaFolder oldLibFolder = project.RootFolder.ChildFolders.Cast<IMgaFolder>() .Where(x => string.IsNullOrWhiteSpace(x.LibraryName) == false && (x.Name.Contains(libraryInfo.DisplayName) || x.Name.Contains(libraryInfo.DisplayName))).FirstOrDefault(); bool needAttach; if (oldLibFolder == null) { needAttach = true; if (libraryPaths.Contains(Path.GetFullPath(project.ProjectConnStr.Substring("MGA=".Length)))) { // Don't attach libraries to themselves needAttach = false; } } else { DateTime oldModTime; long loldModTime; if (long.TryParse(oldLibFolder.RegistryValue["modtime"], out loldModTime)) { oldModTime = DateTime.FromFileTimeUtc(loldModTime); } else { oldModTime = DateTime.MinValue; } needAttach = File.GetLastWriteTimeUtc(mgaPath).CompareTo(oldModTime) > 0; if (!needAttach) { GMEConsole.Info.WriteLine("Library is up-to-date: embedded library modified " + oldModTime.ToString() + ", " + libraryInfo.MgaName + " modified " + File.GetLastWriteTimeUtc(mgaPath).ToString()); } } if (needAttach) { MgaProject proj = (MgaProject) Activator.CreateInstance(Type.GetTypeFromProgID("Mga.MgaProject")); int mgaVersion; string paradigmName; string paradigmVersion; object paradigmGuid; bool readOnly; proj.QueryProjectInfo("MGA=" + mgaPath, out mgaVersion, out paradigmName, out paradigmVersion, out paradigmGuid, out readOnly); Guid guidP1 = ConvertToGUID(paradigmGuid); Guid guidP2 = ConvertToGUID(project.RootMeta.GUID); bool guidsEqual = guidP1.Equals(guidP2); if (paradigmName != project.MetaName || !guidsEqual) { GMEConsole.Info.WriteLine("Skipping refresh of " + libraryInfo.DisplayName + " because it uses a different metamodel version than the current project."); throw new Exception(); } GMEConsole.Info.WriteLine("Attaching library " + mgaPath); RootFolder newLibFolder = Common.Classes.RootFolder.GetRootFolder(project).AttachLibrary("MGA=" + mgaPath); DateTime modtime = File.GetLastWriteTimeUtc(mgaPath); ((newLibFolder as ISIS.GME.Common.Classes.RootFolder).Impl as GME.MGA.IMgaFolder).RegistryValue["modtime"] = modtime.ToFileTimeUtc().ToString(); if (oldLibFolder != null) { ReferenceSwitcher.Switcher sw = new ReferenceSwitcher.Switcher(oldLibFolder, newLibFolder.Impl, null); sw.UpdateSublibrary(); oldLibFolder.DestroyObject(); } ((newLibFolder as ISIS.GME.Common.Classes.RootFolder).Impl as GME.MGA.IMgaFolder).LibraryName = libraryInfo.DisplayName; GMEConsole.Info.WriteLine((oldLibFolder == null ? "Attached " : "Refreshed ") + libraryInfo.MgaName + ".mga library."); } project.CommitTransaction(); } catch { project.AbortTransaction(); } finally { project.Notify(globalevent_enum.APPEVENT_LIB_ATTACH_END); } libraryInfo.attachedLibrary = true; } }
internal LibraryInfo Refresh(AssemblyResolver resolver, string assembly) { assembly = Path.GetFullPath (assembly); if (IsCurrent (assembly)) return Members [assembly]; LibraryInfo info = Members [assembly]; if (info == null) { info = new LibraryInfo (); info.File = assembly; Members.Add (info); } info.Timestamp = File.GetLastWriteTime (assembly).ToUniversalTime (); info.Guid = Guid.NewGuid (); Save (); AssemblyDefinition adef = AssemblyFactory.GetAssembly (assembly); XmlDocument objects = GetObjectsDoc (resolver, adef, assembly); if (objects != null) { info.ObjectsDocument = objects; XmlDocument gui = GetGuiDoc (adef); if (gui != null) info.GuiDocument = gui; } return info; }
private void CopySource(LibraryInfo info, Dictionary<string, string> files, bool filter) { if (!info.Compile) return; var sources = (from f in files let name = filter ? f.Key.Substring(1) : f.Key + info.Extension select new { Key = name, f.Value }) .ToDictionary(it => it.Key, it => it.Value); DumpToDisk(info.TargetPath, sources, 3); }
public void Reset(string compilerPath) { CompilerPath = compilerPath; oldPocoLibrary = PocoLibrary.Clone(); oldClientLibrary = ClientLibrary.Clone(); oldPortableLibrary = PortableLibrary.Clone(); oldPhpSource = PhpSource.Clone(); oldWpfLibrary = WpfLibrary.Clone(); oldPostgresLibrary = PostgresLibrary.Clone(); oldOracleLibrary = OracleLibrary.Clone(); }