public UcDesktopBtn(AppItem item,string ico_path) { InitializeComponent(); IconPath = ico_path; AppItem = item; AppItem.ToLower(); this.label1.Text = AppItem.Name; bool bFlag = false; try { this.button1.Image = Image.FromFile(IconPath + AppItem.Icon); bFlag = true; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } if (!bFlag) { if (AppItem.AppType.EndsWith("exe")) { this.button1.Image = global::DoctorGuid.Properties.Resources.exe; } } }
private void btnAdd_Click(object sender, EventArgs e) { AppItem appItem = new AppItem(); FormShortCutEdit dlg = new FormShortCutEdit(appItem); dlg.Text = "添加快捷方式"; if (DialogResult.OK == dlg.ShowDialog()) { mAppItems.Add(new AppItemObject(dlg.GetAppItem(), "", false)); RefreshListView(); } }
// create an appliance item attaching option lists public AppItem createApp(string name, int roomid) { AppItem a = new AppItem(); if (name != "" && name != null && roomid > -1) { a.name = name; a.RoomItem_Id = roomid; db.AppItems.AddObject(a); db.SaveChanges(); return a; } else return null; }
public async Task <IActionResult> OnGetAsync() { var author = await _db.Authors.GetItem(a => a.AppUserName == User.Identity.Name); IsAdmin = author.IsAdmin; Notifications = await _ns.GetNotifications(author.Id); if (!author.IsAdmin) { return(RedirectToPage("../Shared/_Error", new { code = 403 })); } AppItem = _app.Value; return(Page()); }
// create an appliance item attaching option lists public AppItem createApp(string name, int roomid) { AppItem a = new AppItem(); if (name != "" && name != null && roomid > -1) { a.name = name; a.RoomItem_Id = roomid; db.AppItems.AddObject(a); db.SaveChanges(); return(a); } else { return(null); } }
public async Task NavigateBack(AppItem item) { if (item.IsFolder) { int index = breadcrumbList.IndexOf(item); if (index > -1) { for (; index < breadcrumbList.Count;) { breadcrumbList.RemoveAt(index); } } await GetDataFromServer(item); } StateHasChanged(); }
public void LoadApplications(String working_dir_p) { app_settings_manager_l = new AppSettingsManager(working_dir_p, ApplicatoinItems); app_settings_manager_l.LoadAppItems(); for (int count = 0; count < app_settings_manager_l.AppItems.Count; count++) { AppItem temp_app_item = app_settings_manager_l.AppItems[count]; AddApplicationItemToList(temp_app_item); } foreach (AppListBoxItem app_list_box_item in ApplicatoinItems) { LaunchApplication(app_list_box_item.AppPath, app_list_box_item.AppItemData.AppArgs); } }
private void AddToCartMethod(AppItem Item) { var cart = DataBase.GetAllStream <CartItem>("Cart"); CartItem cartItem = new CartItem(Item, new List <AppItem>(), 1); var ie = cart.GetEnumerator(); while (ie.MoveNext()) { if (ie.Current.Item != null && ie.Current.Item.uid == Item.uid) { ie.Current.Count++; DataBase.UpdateItem <CartItem>("Cart", null, ie.Current); return; } } DataBase.WriteItem <CartItem>("Cart", cartItem); }
private bool checkEntry(AppItem item) { if (item is MemorizeAppItem) { MemorizeAppItem memorizeAppItem = item as MemorizeAppItem; if (memorizeAppItem.MemorizeEntry == null) { try { memorizeAppItem.MemorizeEntry = MemorizeEntry.Load(memorizeAppItem.AppEntryFile); } catch (Exception ex) { Debug.Assert(false, ex.Message); } finally { } return(memorizeAppItem.MemorizeEntry != null); } } else if (item is AssessmentAppItem) { return(true); } else { if (item.Entry == null) { try { Assembly gadgetAssembly = Assembly.LoadFile(item.AppEntryFile); item.Entry = gadgetAssembly.CreateInstance(item.FullName) as IGadgetEntry; } catch (Exception ex) { Debug.Assert(false, ex.Message); } return(item.Entry != null); } } return(true); }
public Task removeAppAsync(AppItem appItem) { return(Task.Run(() => { string appPath = appItem.getAppPath(); //删除文件夹 DirectoryInfo appPathInfo = new DirectoryInfo(appPath); if (appPathInfo.Exists) { appPathInfo.Delete(true); } if (appItem.type == AppType.PHP) { //用户Path环境变量中删除 this.removeUserPath(appPath); } })); }
private void appListBox_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { ListBox listBox = sender as ListBox; if (listBox == null) { return; } Point clickPoint = e.GetPosition(listBox); HitTestResult result = VisualTreeHelper.HitTest(listBox, clickPoint); ListBoxItem listBoxItem = GC_UIHelper.FindParent <ListBoxItem>(result.VisualHit); if (listBoxItem == null) { return; } if (listBoxItem.Content is AddAppItem) { this.managementBtn_Click(sender, new RoutedEventArgs()); } else if (listBoxItem.Content is AppItem) { AppItem item = listBoxItem.Content as AppItem; MainWindow mainWnd = App.Current.MainWindow as MainWindow; mainWnd.LoadGadget(item); listBox.SelectedIndex = -1; Thread.Sleep(System.Windows.Forms.SystemInformation.DoubleClickTime); } else if (listBoxItem.Content is TypeItem) { //TypeItem typeItem = listBoxItem.Content as TypeItem; //this.appListStackPanel.Visibility = System.Windows.Visibility.Visible; //this.appListBox.Visibility = System.Windows.Visibility.Hidden; //if (!string.IsNullOrEmpty(typeItem.Thumbnail)) // this.typeThumbnailImage.Source = new BitmapImage(new Uri(typeItem.Thumbnail)); //this.appListBox_All.ItemsSource = DataMgr.Instance[typeItem.Type]; } }
private void addCommand(AppItem app) { AppItem defaultApp; if (commandDic.TryGetValue(app.name, out defaultApp)) { DialogResult dialogResult = MessageBox.Show(string.Format("\"{0}\"已存在,是否替换", app.name), "提示", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { defaultApp.data = app.data; defaultApp.appType = app.appType; saveData(); } return; } commandDic.Add(app.name, app); listboxCommands.Items.Add(app.name); saveData(); }
// Decode URL static string DecodeURL(AppItem item, string URL) { // Get Encoding Type Encoding e = EncodingType[item.decode.ToUpper()]; // "+" Decode if (!item.decodePlus) { string oldPathAndQuery = new Uri(URL).PathAndQuery; string newPathAndQuery = oldPathAndQuery.Replace("+", "%2B"); URL = URL.Replace(oldPathAndQuery, newPathAndQuery); } // Decode if (e != null) { URL = HttpUtility.UrlDecode(URL, e); } return(URL); }
internal void LoadGadget(AppItem item) { #if _LAUNCH_APP_ AppMgr.Instance.Start(item); DataMgr.Instance.MruItems.Add(item); #else this.containerPanel.Content = ControlMgr.Instance.GadgetContainerUserControl; ControlMgr.Instance.GadgetContainerUserControl.LoadGadget(item); DataMgr.Instance.MruItems.Add(item); #endif var newAppQuery = from app in AppInstallMgr.Instance.AppInstallItems where app.State == InstallState.Done && item.Id == app.AppItem.UniqueId select app; if (newAppQuery.Count() > 0) { AppInstallMgr.Instance.Remove(newAppQuery.First()); } }
public JsonResult PageList(AppItem item, int page = 1, int rows = 10) { var query = db.AppItems.AsQueryable(); if (!string.IsNullOrWhiteSpace(item.CN_CODE)) { query = query.Where(obj => obj.CN_CODE.Contains(item.CN_CODE)); } if (!string.IsNullOrWhiteSpace(item.CN_ITEM_CODE)) { query = query.Where(obj => obj.CN_ITEM_CODE.Contains(item.CN_ITEM_CODE)); } if (!string.IsNullOrWhiteSpace(item.CN_NAME)) { query = query.Where(obj => obj.CN_NAME.Contains(item.CN_NAME)); } var list = query.OrderByDescending(obj => obj.CN_CODE).Skip((page - 1) * rows).Take(rows).ToList(); var count = query.Count(); return(Json(ResultInfo.Success(new { rows = list, total = count }))); }
private void addButton_Click(object sender, RoutedEventArgs e) { GadgetItemOnline item = this.DataContext as GadgetItemOnline; this.appItem = DataMgr.Instance.getAppItemById(item.UniqueId); var query = from temp in AppInstallMgr.Instance.AppInstallItems where temp.AppItem.UniqueId == item.UniqueId select temp; if (appItem != null) { MainWindow mainWnd = App.Current.MainWindow as MainWindow; mainWnd.Activate(); mainWnd.LoadGadget(this.appItem); foreach (Window wnd in App.Current.Windows) { if (wnd is AppStoreWindow) { wnd.Close(); } } } else { if (query.Count() > 0) { this.addButton.Content = "正在安装"; } //else if (item.Price > 0) //{ //} else { AppInstallMgr.Instance.Start(this.DataContext as GadgetItemOnline); this.addButton.Content = "正在安装"; } } }
private void GetAppFiles() { _appFiles = new List <AppItem>(); List <string> fileNames = new List <string>(); try { fileNames = Directory.GetFiles(_defaultDirectory, "*.APP").ToList(); } #pragma warning disable CS0168 // Variable is declared but never used catch (Exception e) #pragma warning restore CS0168 // Variable is declared but never used { fileNames = null; } foreach (string filename in fileNames) { AppItem a = new AppItem(filename); _appFiles.Add(a); } }
private void installNginx(AppItem appItem) { string appPath = appItem.getAppPath(); DirectoryInfo appPathInfo = new DirectoryInfo(appPath); //从目录中移动到当前目录 DirectoryInfo[] subDirs = appPathInfo.GetDirectories(); this.copyFiles(subDirs[0], appPathInfo); //删除目录 subDirs[0].Delete(true); //复制默认配置文件 DirectoryInfo defaultConfigPath = new DirectoryInfo(DirectoryHelper.getNginxDefaultConfigPath()); this.copyFiles(defaultConfigPath, new DirectoryInfo(appPath + @"\conf")); //修改默认网站路径 string defaultWebsitePath = DirectoryHelper.getDefaultWebsitePath(); string configPath = appPath + @"\conf\vhost\localhost.conf"; UTF8Encoding encoding = new UTF8Encoding(); string fileContent = File.ReadAllText(configPath, encoding); fileContent = fileContent.Replace("{{path}}", defaultWebsitePath.Replace("\\", "/")); File.WriteAllText(configPath, fileContent, encoding); }
public void Verify_WithHash_VerifiesCorrectly() { using var testFolder = new TemporaryFolderAllocation(); const string expectedMessage = "Oh noes!"; var gameItem = new AppItem(); var relativePath = Path.GetRandomFileName(); var randomPath = Path.Combine(testFolder.FolderPath, relativePath); // Write random file. var seed = DateTime.UtcNow.Ticks % int.MaxValue; var bytes = new byte[1024]; new Random((int)seed).NextBytes(bytes); File.WriteAllBytes(randomPath, bytes); // Add random file. var warningItem = new WarningItem() { ErrorMessage = expectedMessage, }; warningItem.Items.Add(new VerifyItem() { FilePath = relativePath, Hash = Hashing.ToString(xxHash64.ComputeHash(bytes)) }); gameItem.Warnings.Add(warningItem); // Act var hasError = gameItem.TryGetError(testFolder.FolderPath, out var warnings); // Assert Assert.True(hasError); Assert.Single(warnings); Assert.Equal(expectedMessage, warnings[0].ErrorMessage); }
private void continueInstall(AppItem appItem) { //创建目录 string appPath = appItem.getAppPath(); DirectoryInfo appPathInfo = new DirectoryInfo(appPath); if (!appPathInfo.Exists) { appPathInfo.Create(); } //解压 string zipPath = appItem.getAppZipPath(); System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, appPath); //执行后续步骤 if (appItem.type == AppType.PHP) { this.installPhp(appItem); } else if (appItem.type == AppType.NGINX) { this.installNginx(appItem); } }
public FormShortCutEdit(AppItem _appItem) { InitializeComponent(); appItem = _appItem; this.textBoxName.Text = appItem.Name; this.textBoxFileName.Text = appItem.FileName; if (appItem.AppType.ToLower().Equals("exe")) { this.radioButtonExe.Checked = true; } else { this.radioButtonExplorer.Checked = true; } this.textBoxProcessName.Text = appItem.ProcessName; this.textBoxUrl.Text = appItem.Url; this.textBoxIcon.Text = appItem.Icon; }
private void MenuItem_Click(object sender, RoutedEventArgs e) { if (this.appListBox_All.SelectedIndex < 0) { return; } AppItem item = this.appListBox_All.SelectedItem as AppItem; if (item == null) { return; } MessageWindow messageWnd = new MessageWindow(); messageWnd.ShowMessage(string.Format("您确定要卸载{0}吗?", item.Title), MessageBoxButton.OKCancel, new MessageWindowCallback((ok) => { if (ok) { DataMgr.Instance.uninstallApp(item); } })); }
public ProductViewModel() { product = new AppItem(); toppings = new ObservableCollection <AppItem>(); selectedToppings = new ObservableCollection <AppItem>(); width = App.screenWidth / 4; height = App.screenHeight; amount = 1; AddToCart = new Command(() => { List <AppItem> toppings = new List <AppItem>(); foreach (var topping in selectedToppings) { toppings.Add(topping); } CartItem item = new CartItem(this.product, this.selectedToppings, amount); item.Toppings = new List <AppItem>(); foreach (var topping in this.selectedToppings) { item.Toppings.Add(topping); } var cart = DataBase.GetAllStream <CartItem>("Cart"); var ie = cart.GetEnumerator(); while (ie.MoveNext()) { if (ie.Current.Item.uid == this.product.uid && ie.Current.Toppings == toppings) { ie.Current.Count++; DataBase.UpdateItem <CartItem>("Cart", null, ie.Current); return; } } DataBase.WriteItem <CartItem>("Cart", item); }); LoadProductCommand = new Command((index) => { if (index == null) { return; } product = DataBase.GetProduct <AppItem>("Items", index as string); if (product.toppings.Count > 1) { LoadToppingsComand.Execute(product.toppings); } }); LoadToppingsComand = new Command((indecies) => { toppings.Clear(); foreach (var index in indecies as List <string> ) { var topping = DataBase.GetProduct <AppItem>("Items", index as string); if (topping != null) { toppings.Add(topping); } } }); AddToppingCommand = new Command((item) => { (item as AppItem).Amount = 1; selectedToppings.Add(item as AppItem); }); RemoveToppingCommand = new Command((item) => { selectedToppings.Remove(item as AppItem); }); IncreaseTopping = new Command(() => { Console.WriteLine("1"); }); }
private void Install(AppInstallItem item) { FileStream fs = null; try { this.UpdateState(InstallState.Installing, item); this.UpdateProgress(0, item); fs = File.OpenRead(item.LocakPackFile); // Check File Header string fileHeader = this.ReadString(fs); this.VerifyFileHeader(fileHeader); // Check AppTitle and AppId string appId = this.ReadString(fs); string appTitle = this.ReadString(fs); if (appTitle != item.AppItem.Title || appId != item.AppItem.Id) { // throw new NotSupportedException(); } string appFolder = this.GetAppFolder(fileHeader, appId); // Description string description = this.ReadString(fs); // Logos string thumbnail = this.ExtractLogo(fs, appId); // Entry File; string appEntryFile = this.ReadString(fs); string fullName = this.ReadString(fs); int type = BitConverter.ToInt32(this.ReadBytes(fs), 0); int subType = BitConverter.ToInt32(this.ReadBytes(fs), 0); AppItem appItem = this.CreateAppItem(fileHeader, type, subType); appItem.Id = appId; appItem.Title = appTitle; appItem.Description = description; appItem.Thumbnail = thumbnail; appItem.AppEntryFile = appEntryFile; appItem.FullName = fullName; appItem.Type = type; appItem.SubType = subType; appItem.CreateDate = DateTime.Parse(this.ReadString(fs)); appItem.CreatorName = this.ReadString(fs); appItem.CreatorLogo = this.ReadString(fs); appItem.CreatorWebSite = this.ReadString(fs); appItem.AddedTime = DateTime.Now.ToUniversalTime(); // Get File Count string countString = this.ReadString(fs); int count = Convert.ToInt32(countString); for (int i = 0; i < count; i++) { // Get FileName and Data string fileName = this.ReadString(fs); byte[] fileData = this.ReadBytes(fs); if (string.IsNullOrEmpty(fileName)) { continue; } appItem.RelatedFiles.Add(fileName); // Create File Path string filePath = appFolder + Path.GetDirectoryName(fileName); if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } // Create File Name filePath = Path.Combine(filePath, Path.GetFileName(fileName)); if (File.Exists(filePath)) { } try { if (fileData.Length > 0) { File.WriteAllBytes(filePath, fileData); } } catch { } if (item.State == InstallState.UserCancelling) { this.UpdateState(InstallState.UserCancelled, item); break; } this.UpdateProgress((int)((i + 1 * 100) / count), item); } if (appItem is MemorizeAppItem) { MemorizeAppItem memorizeAppItem = appItem as MemorizeAppItem; try { memorizeAppItem.MemorizeEntry = MemorizeEntry.Load(System.IO.Path.Combine(appFolder, System.IO.Path.GetFileName(appItem.AppEntryFile))); if (memorizeAppItem.MemorizeEntry.SubType == 0) { memorizeAppItem.SubType = 10299; } else { memorizeAppItem.SubType = memorizeAppItem.MemorizeEntry.SubType; } memorizeAppItem.Type = 102; } catch (Exception e) { this.UpdateState(InstallState.InstallFail, item); this.InvokeInstallCompletedEvent(item, e); return; } } else if (appItem is AssessmentAppItem) { AssessmentAppItem assessmentAppItem = appItem as AssessmentAppItem; try { string folder = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (UIHelper.Is64BitOS()) { SevenZipExtractor.SetLibraryPath(System.IO.Path.Combine(folder, "ThirdParty\\7z\\7z64.dll")); } else { SevenZipExtractor.SetLibraryPath(System.IO.Path.Combine(folder, "ThirdParty\\7z\\7z.dll")); } string archiveFile = Path.Combine(folder, @"data\assessment\" + assessmentAppItem.Id + @"\" + assessmentAppItem.Id + ".zip"); assessmentAppItem.AppEntryFile = Path.Combine(folder, @"data\assessment\" + assessmentAppItem.Id + @"\" + assessmentAppItem.Id + ".sla"); using (SevenZipExtractor extractor = new SevenZipExtractor(archiveFile, "$L&%$D123@3$5^7*")) { string targetFolder = Path.Combine(folder, @"data\assessment\" + assessmentAppItem.Id); for (int i = 0; i < extractor.FilesCount; i++) { string fileName = extractor.ArchiveFileNames[i]; if (!extractor.ArchiveFileNames[i].StartsWith("\\")) { fileName = "\\" + extractor.ArchiveFileNames[i]; } string targetFile = targetFolder + fileName; FileStream targetFs = File.Open(targetFile, FileMode.OpenOrCreate, FileAccess.ReadWrite); extractor.ExtractFile(i, targetFs); targetFs.Close(); } } File.Delete(archiveFile); } catch (Exception ex) { Debug.Assert(false, ex.Message); this.UpdateState(InstallState.InstallFail, item); this.InvokeInstallCompletedEvent(item, ex); return; } } if (DataMgr.Instance.getAppItemById(appItem.Id) == null) { DataMgr.Instance.insertAppItem(0, appItem); } this.UpdateProgress(100, item); this.UpdateState(InstallState.Done, item); this.InvokeInstallCompletedEvent(item, null); // this.Remove(item); DataMgr.Instance.AppService.IncreaseDownloadCount(appItem.Id, LoginInfo.GetMD5Hash("#$32*d_&")); } catch (Exception ex) { ProcessWriteFileEx(ex, item); this.InvokeInstallCompletedEvent(item, ex); } finally { if (fs != null) { fs.Close(); } try { File.Delete(item.LocakPackFile); } catch { } } }
private void button1_Click(object sender, EventArgs e) { try { if (AppItem.AppType.EndsWith("exe")) { Process.Start(AppItem.FileName, AppItem.Url); } else { //火狐单独处理 if (!AppItem.FileName.Contains("firefox.exe")) { Process.Start(AppItem.FileName, AppItem.Url); return; } if (myThread != null && myThread.IsAlive) { myThread.Abort(); } myThread = new Thread(_parStart); AppItem obj = new AppItem(); obj.ProcessName = AppItem.ProcessName; obj.FileName = AppItem.FileName; obj.Url = AppItem.Url; myThread.Start(obj); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
internal void ShowAppItem(GadgetItemOnline item) { this.DataContext = item; this.createTimeTextBlock.Text = item.CreateDate.ToLocalTime().ToString(); this.priceTextBlock.Text = string.Format("{0}元", item.Price.ToString()) + "(推广期,免费使用)"; this.ShowCategory(item); this.appItem = DataMgr.Instance.getAppItemById(item.UniqueId); var query = from temp in AppInstallMgr.Instance.AppInstallItems where temp.AppItem.UniqueId == item.UniqueId select temp; if (appItem != null) { this.addButton.Content = "打开"; } else { if (query.Count() > 0) { this.addButton.Content = "正在安装"; } //else if (item.Price > 0) //{ //} else { this.addButton.Content = "添加"; } } this.snapshotListBox.ItemsSource = null; this.authorTextBlock.Text = string.Empty; UserPaidInfo userPaidInfo = null; if (item.SnapshotList.Count == 0) { this.IsEnabled = false; BackgroundWorker worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.WorkerReportsProgress = true; worker.DoWork += ((s, e) => { string strRet = DataMgr.Instance.AppService.GetAppAttachInfo(Convert.ToInt32(item.Id), item.CreatorId, LoginInfo.GetMD5Hash("4%!@s*&d")); if (!string.IsNullOrEmpty(strRet)) { string[] strRets = strRet.Split(new string[] { "||" }, StringSplitOptions.None); item.Creator = strRets[0]; if (strRets.Length > 1) { item.SnapshotList.Add(new AppImage(strRets[1])); if (strRets.Length > 2) { item.SnapshotList.Add(new AppImage(strRets[2])); } if (strRets.Length > 3) { item.SnapshotList.Add(new AppImage(strRets[3])); } if (strRets.Length > 4) { item.SnapshotList.Add(new AppImage(strRets[4])); } if (strRets.Length > 5) { item.SnapshotList.Add(new AppImage(strRets[5])); } } } //try //{ // userPaidInfo = DataMgr.Instance.AppService.GetUserPaidInfo(item.UniqueId, // DataMgr.Instance.LoginInfo.LoginId, // DataMgr.Instance.LoginInfo.Password, // LoginInfo.GetMD5Hash("##32*d_&")); //} //catch (Exception ex) //{ // Debug.Assert(false, ex.Message); //} }); worker.RunWorkerCompleted += ((s, e) => { this.snapshotListBox.ItemsSource = item.SnapshotList; this.authorTextBlock.Text = item.Creator; this.IsEnabled = true; if (item.Price > 0 && userPaidInfo != null) { // Temp no need paid if (userPaidInfo == null || userPaidInfo.Paid) { this.addButton.Content = "添加"; } else { this.addButton.Content = "购买"; Style style = App.Current.TryFindResource("ButtonStyle_IconBtn_Single") as Style; if (style != null) { this.addButton.Style = style; } } } }); worker.RunWorkerAsync(); } else { this.snapshotListBox.ItemsSource = item.SnapshotList; this.authorTextBlock.Text = item.Creator; } }
private void AddEventSources(AppItem app) { // add function sources for (var sourceIndex = 0; sourceIndex < app.Sources.Count; ++sourceIndex) { var source = app.Sources[sourceIndex]; var sourceSuffix = (sourceIndex + 1).ToString(); switch (source) { case ScheduleSource scheduleSource: { // NOTE (2019-01-30, bjorg): we need the source suffix to support multiple sources // per app; however, we cannot exceed 64 characters in length for the ID. var id = app.LogicalId; if (id.Length > 61) { id += id.Substring(0, 61) + "-" + sourceSuffix; } else { id += "-" + sourceSuffix; } var schedule = _builder.AddResource( parent: app, name: $"Source{sourceSuffix}ScheduleEvent", description: null, scope: null, resource: new Humidifier.Events.Rule { ScheduleExpression = scheduleSource.Expression, Targets = new[] { new Humidifier.Events.RuleTypes.Target { Id = id, Arn = FnGetAtt($"{app.FullName}::EventBus", "Outputs.EventTopicArn"), InputTransformer = new Humidifier.Events.RuleTypes.InputTransformer { InputPathsMap = new Dictionary <string, object> { ["id"] = "$.id", ["time"] = "$.time" }, InputTemplate = @"{ ""Id"": <id>, ""Time"": <time>, ""Name"": """ + scheduleSource.Name + @""" }" } } }.ToList() }, resourceExportAttribute: null, dependsOn: null, condition: null, pragmas: null, deletionPolicy: null ); } break; case CloudWatchEventSource cloudWatchRuleSource: { // NOTE (2019-01-30, bjorg): we need the source suffix to support multiple sources // per function; however, we cannot exceed 64 characters in length for the ID. var id = app.LogicalId; if (id.Length > 61) { id += id.Substring(0, 61) + "-" + sourceSuffix; } else { id += "-" + sourceSuffix; } var rule = _builder.AddResource( parent: app, name: $"Source{sourceSuffix}Event", description: null, scope: null, resource: new Humidifier.Events.Rule { EventPattern = cloudWatchRuleSource.Pattern, EventBusName = cloudWatchRuleSource.EventBus, Targets = new[] { new Humidifier.Events.RuleTypes.Target { Id = id, Arn = FnGetAtt($"{app.FullName}::EventBus", "Outputs.EventTopicArn") } }.ToList() }, resourceExportAttribute: null, dependsOn: null, condition: null, pragmas: null, deletionPolicy: null ); } break; default: throw new ApplicationException($"unrecognized app source type '{source?.GetType()}' for source #{sourceSuffix}"); } } }
public CategoriesViewModel(HttpClient client) { CatList = new ObservableCollection <Category>(); Products = new ObservableCollection <AppItem>(); SubCats = new ObservableCollection <Subcategory>(); items = new List <AppItem>(); data = new List <Category>(); MainProduct = new AppItem(); GetCartCountCommand = new Command(async() => { var cart = await DataBase.GetAllStreamAsync <Models.CartItem>("Cart"); var Count = 0; foreach (var item in cart) { Count += item.Count; } this.CartCount = Count; }); LoadSubcat = new Command(async(subcat) => { var items = DataBase.GetByQueryEnumerable <AppItem>("Items", Query.Where("category", x => x.AsArray.Contains((int)subcat))); if (Products == null) { Products = new ObservableCollection <AppItem>(); } Products.Clear(); if (items != null) { while (items.MoveNext()) { await Task.Delay(TimeSpan.FromMilliseconds(200)); Products.Add(items.Current); } } }); LoadCategoriesCommand = new Command(async() => { if (DataBase.GetRecordCount <CategorySimplified>("Categories") == 0) { data = await RequestHelper.GetData <List <Category> >(client, "data/app_categs_full20.php?version="); } CatList.Clear(); var categories = new List <CategorySimplified>(); if (data.Count > 0) { foreach (var category in data) { categories.Add(new CategorySimplified(category)); } DataBase.WriteAll <CategorySimplified>("Categories", categories); foreach (Category category in data) { category.image = "https://www.tokyo-city.ru" + category.image; CatList.Add(category); } CurrentCategory = CatList[0].id; LoadItemsCommand.Execute(null); } else { var categs = await DataBase.GetAllStreamAsync <CategorySimplified>("Categories"); var ie = categs.GetEnumerator(); while (ie.MoveNext()) { CatList.Add(new Category(ie.Current)); } } }); LoadItemsCommand = new Command(async() => { await Task.Run(() => LoadItemsMethod(client)); }); LoadCategoryItemsCommand = new Command(async() => { int count = DataBase.GetRecordCount <AppItem>("Items"); var query = Query.Where("category", category => category.AsArray.Contains(CurrentCategory)); var itemsFound = DataBase.GetByQueryEnumerable <AppItem>("Items", query); SubCats.Clear(); if (CatList[CategoryIndex].subcategories?.Count > 0) { foreach (var subcat in CatList[CategoryIndex].subcategories) { SubCats.Add(subcat); } } Products.Clear(); List <AppItem> tempList = new List <AppItem>(); while (itemsFound.MoveNext()) { await Task.Delay(TimeSpan.FromMilliseconds(200)); Products.Add(itemsFound.Current); } itemsFound.Dispose(); }); LoadFirstItemCommand = new Command(() => { MainProduct = DataBase.GetOneOfCategory <AppItem>("Items", CurrentCategory); }); }
public void ShowModal(AppItem item) { ModalRef.ShowModal(item); }
/// <summary> /// 超链接处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void vcHyperlinkColumn_Click(object sender, RoutedEventArgs e) { AppItem appItem = ((TextBlock)sender).DataContext as AppItem; Process.Start(appItem.downloadUrl); }
/// <summary> /// 安装composer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void installComposer(object sender, RoutedEventArgs e) { Button btn = sender as Button; AppItem appItem = this.phpSelector.SelectedItem as AppItem; MainWindow mainWin = this.Owner as MainWindow; string boxTitle = "安装composer"; if (appItem == null) { mainWin.showErrorMessage("需要先安装php", boxTitle); } else { ComposerInstall installService = new ComposerInstall(this); string appPath = appItem.getAppPath(); List <string> toRemoveDirs = null; //等待状态 btn.IsEnabled = false; this.phpSelector.IsEnabled = false; this.composerProgressBar.IsIndeterminate = true; this.composerProgressBar.Visibility = Visibility.Visible; try { //从path环境变量中,获取已经安装了composer的目录 List <string> installedDirs = await installService.getInstalledDirsAsync(); if (installedDirs.Contains(appPath)) { installedDirs.Remove(appPath); } if (installedDirs.Count > 0) { string tipMessage = "检测到以下目录已经安装了composer,继续安装composer可能无法生效,是否删除下方目录中安装的composer?\r\n"; if (MessageBoxResult.Yes == MessageBox.Show(tipMessage + String.Join(" , ", installedDirs), boxTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Question)) { toRemoveDirs = installedDirs; } } //执行安装操作 await installService.installAsync(appPath, toRemoveDirs); //状态还原 btn.IsEnabled = true; this.phpSelector.IsEnabled = true; this.composerProgressBar.IsIndeterminate = true; this.composerProgressBar.Visibility = Visibility.Hidden; //composer -V string composerInfo = await installService.getComposerInfoAsync(appPath); mainWin.showErrorMessage("--composer版本信息如下--\r\n" + composerInfo, boxTitle + "成功", MessageBoxImage.Information); } catch (Exception e1) { //状态还原 btn.IsEnabled = true; this.phpSelector.IsEnabled = true; this.composerProgressBar.IsIndeterminate = true; this.composerProgressBar.Visibility = Visibility.Hidden; // mainWin.showErrorMessage(e1.Message, boxTitle + "失败"); } } }
private void loadGadgetWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; int index = 0; AppDomain exeDomain = AppDomain.CurrentDomain; Assembly assembly = Assembly.GetExecutingAssembly(); string exeAssembly = assembly.FullName; DirectoryInfo di = new DirectoryInfo(System.IO.Path.GetDirectoryName(assembly.Location)); DirectoryInfo memorizeDataDi = new DirectoryInfo(DataMgr.Instance.MemorizeDataPath); DirectoryInfo assessmentDataDi = new DirectoryInfo(DataMgr.Instance.AssessmentDataPath); try { DataMgr.Instance.preLoadApps(); } catch { } try { AppInstallMgr.Instance.Dispatcher = this.Dispatcher; AppInstallMgr.Instance.Init(); } catch { } var newAppQuery = from item in AppInstallMgr.Instance.AppInstallItems where item.State == InstallState.Done select item; #if _LAUNCH_APP_ #region Remote Loader FileInfo[] appFiles = di.GetFiles("*.dll"); this.totalDllCount = appFiles.Length; this.currentDllIndex = 0; foreach (FileInfo fi in appFiles) { this.currentDllIndex++; LocalLoader localLoader = null; try { localLoader = new LocalLoader(System.IO.Path.GetDirectoryName(assembly.Location)); localLoader.LoadAssembly(fi.FullName); foreach (string entryName in localLoader.GetSubclasses(typeof(MarshalByRefObject).FullName)) { MarshalByRefObject entryObject = localLoader.CreateInstance(entryName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.CreateInstance, new object[] { }); if (entryObject is IGadgetEntry) { IGadgetEntry entry = entryObject as IGadgetEntry; if (DataMgr.Instance.GadgetItems.IsAppExist(entry.Id)) { worker.ReportProgress(index++, entry.Title); Thread.Sleep(1); break; } string name = string.Empty; string website = string.Empty; string logo = string.Empty; if (entry is IAuthorInfo) { IAuthorInfo authorInfo = entry as IAuthorInfo; name = authorInfo.Name; website = authorInfo.WebSite; logo = authorInfo.Logo; } string thumbnail = System.IO.Path.GetDirectoryName(assembly.Location); thumbnail = System.IO.Path.Combine(thumbnail, @"AppLogos\"); thumbnail += entry.Id; thumbnail += System.IO.Path.GetExtension(entry.Thumbnail); if (!File.Exists(thumbnail)) { ExtractLogo(entry.Thumbnail, entry.Id, assembly.Location); } AppItem item = (AppItem)exeDomain.CreateInstanceAndUnwrap( exeAssembly, typeof(AppItem).FullName, true, BindingFlags.Default, null, new object[] { entry.Id, entry.Title, entry.Description, entry.CreateDate, thumbnail, entry.Tag, entry.SubTag, entryName, name, website, logo }, null, null ); item.AppEntryFile = fi.FullName; // GadgetItem item = new GadgetItem(); DataMgr.Instance.GadgetItems.Add(item); worker.ReportProgress(index++, entry.Title); Thread.Sleep(1); break; } } } catch (Exception ex) { } finally { if (localLoader != null) { localLoader.Unload(); localLoader = null; } } } this.currentDllIndex = this.totalDllCount; #endregion #else ////////////////////////////////////////////////////////// FileInfo[] appFiles = di.GetFiles("*.dll"); FileInfo[] memorizeDataFiles = memorizeDataDi.GetFiles("*.mre", SearchOption.AllDirectories); FileInfo[] assessmentAppFiles = assessmentDataDi.GetFiles("*.sla", SearchOption.AllDirectories); this.totalDllCount = appFiles.Length + memorizeDataFiles.Length + assessmentAppFiles.Length; this.currentDllIndex = 0; foreach (FileInfo fi in appFiles) { try { this.currentDllIndex++; Assembly gadgetAssembly = Assembly.LoadFrom(fi.FullName); bool found = false; // Assembly gadgetAssembly = Assembly.LoadFile(fi.FullName); Module[] modules = gadgetAssembly.GetModules(); foreach (Module module in modules) { Type[] types = module.GetTypes(); foreach (Type type in types) { if (type.IsClass && !type.IsAbstract) { Type entryInterface = type.GetInterface("IGadgetEntry"); if (entryInterface != null) { IGadgetEntry entry = gadgetAssembly.CreateInstance(type.FullName) as IGadgetEntry; if (DataMgr.Instance.getAppItemById(entry.Id) != null) { worker.ReportProgress(index++, entry.Title); Thread.Sleep(1); found = true; break; } string name = string.Empty; string website = string.Empty; string logo = string.Empty; if (entry is IAuthorInfo) { IAuthorInfo authorInfo = entry as IAuthorInfo; name = authorInfo.Name; website = authorInfo.WebSite; logo = authorInfo.Logo; } string thumbnail = entry.Thumbnail; string thumbnailFile = System.IO.Path.GetDirectoryName(assembly.Location); thumbnailFile = System.IO.Path.Combine(thumbnail, @"AppLogos\"); thumbnailFile += entry.Id; thumbnailFile += System.IO.Path.GetExtension(entry.Thumbnail); if (File.Exists(thumbnailFile)) { try { File.Delete(thumbnailFile); } catch { } } // if (entry.Tag == 200 && // entry.SubTag == 202) // thumbnail = @"pack://application:,,,/Resources/Images/GradeMath.png"; AppItem item = null; if (entry.Tag == 200 && entry.SubTag == 207) { item = new MathFastAppItem(entry.Id, entry.Title, entry.Description, entry.CreateDate, thumbnail, entry.Tag, entry.SubTag, type.FullName, name, website, logo); } else { item = new DllAppItem(entry.Id, entry.Title, entry.Description, entry.CreateDate, thumbnail, entry.Tag, entry.SubTag, type.FullName, name, website, logo); } var matchAppId = from app in newAppQuery where app.AppItem.UniqueId == entry.Id select app.AppItem.Id; if (matchAppId.Count() > 0) { item.IsNew = true; } item.Entry = entry; item.AppEntryFile = fi.FullName; // GadgetItem item = new GadgetItem(); DataMgr.Instance.addAppItem(item); worker.ReportProgress(index++, entry.Title); Thread.Sleep(1); found = true; break; } // end if } // end if } // end foreach if (found) { break; } } } catch { } } foreach (FileInfo fi in memorizeDataFiles) { try { MemorizeEntry entry = MemorizeEntry.Load(fi.FullName); MemorizeAppItem item = new MemorizeAppItem(); item.Id = entry.Id; item.Title = entry.Title; item.Description = entry.Description; item.Thumbnail = entry.Thumbnail; item.CreateDate = entry.CreateDate; item.CreatorName = entry.Creator; item.CreatorLogo = entry.CreatorLogo; item.CreatorWebSite = entry.CreatorWebsite; item.MemorizeEntry = entry; if (entry.SubType == 0) { item.SubType = 10299; } else { item.SubType = entry.SubType; } item.Type = 102; item.AppEntryFile = fi.FullName; DataMgr.Instance.addAppItem(item); worker.ReportProgress(index++, entry.Title); Thread.Sleep(1); } catch (Exception ex) { Debug.Assert(false, ex.Message); } } foreach (FileInfo fi in assessmentAppFiles) { try { AssessmentApp app = SerializerHelper <AssessmentApp> .XmlDeserialize(fi.FullName); AssessmentAppItem item = new AssessmentAppItem(); item.Id = app.Id; item.Title = app.Name; item.Description = app.Description; item.Thumbnail = app.Thumbnail; item.Type = 200; // app.Type; item.SubType = 201; // app.SubType; item.CreateDate = app.CreateDate.ToLocalTime(); item.AppEntryFile = fi.FullName; item.CreatorName = app.Creator; item.CreatorWebSite = app.CreatorWebsite; item.CreatorLogo = app.CreatorLogo; DataMgr.Instance.addAppItem(item); worker.ReportProgress(index++, item.Title); Thread.Sleep(1); } catch (Exception ex) { Debug.Assert(false, ex.Message); } } this.currentDllIndex = this.totalDllCount; #endif try { DataMgr.Instance.MruItems.Load(); } catch { } }
public static string getAppPath(this AppItem appItem) { return(getAppPath(appItem.type, appItem.version)); }
public void Add(AppItem item) { _appMap[item.AppKey] = item; }