public void Initialize(IEnumerable <IApplication> apps, IEnumerable <IGesture> gestures, bool showIgnore = false, bool selecteAll = false)
        {
            if (showIgnore)
            {
                AppTabControl.SelectedIndex = 1;
            }

            var newUserAppList = new List <AppListItem>();
            var newIgnoredApp  = new List <AppListItem>();

            foreach (var app in apps)
            {
                IgnoredApp ignoredApp = app as IgnoredApp;
                if (ignoredApp != null)
                {
                    newIgnoredApp.Add(new AppListItem(ignoredApp, null, selecteAll));
                }
                else
                {
                    var ali = new AppListItem(app, null, selecteAll);
                    ali.ActionItemList.ForEach(a => a.IsSelected = selecteAll);
                    newUserAppList.Add(ali);
                }
            }
            var color = (Color)Application.Current.Resources["HighlightColor"];

            GestureMap = gestures.ToDictionary(g => g.Name, g => new GestureItem()
            {
                Gesture      = g,
                GestureImage = GestureImage.CreateImage(g.PointPatterns, new Size(56, 56), color),
            });
            UserAppList    = newUserAppList;
            IgnoredAppList = newIgnoredApp;
        }
        public void Initialize(IEnumerable <IApplication> apps, IEnumerable <IGesture> gestures, bool showIgnore = false, bool selecteAll = false)
        {
            if (showIgnore)
            {
                AppTabControl.SelectedIndex = 1;
            }

            var newUserAppList = new List <AppListItem>();
            var newIgnoredApp  = new List <AppListItem>();

            foreach (var app in apps)
            {
                IgnoredApp ignoredApp = app as IgnoredApp;
                if (ignoredApp != null)
                {
                    newIgnoredApp.Add(new AppListItem(ignoredApp, null, selecteAll));
                }
                else
                {
                    var ali = new AppListItem(app, null, selecteAll);
                    ali.ActionItemList.ForEach(a => a.IsSelected = selecteAll);
                    newUserAppList.Add(ali);
                }
            }
            GestureMap     = gestures.ToDictionary(g => g.Name);
            UserAppList    = newUserAppList;
            IgnoredAppList = newIgnoredApp;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 啟用/停用 APP
        /// </summary>
        /// <returns></returns>
        public TResult <bool> EnableOrDisableApp(AppListItem appListItem)
        {
            //UI 畫面  是啟用 就是 反向
            string status = appListItem.Status ? AppStatus.Disable : AppStatus.Enable;

            if (status == AppStatus.Enable && !string.IsNullOrEmpty(appListItem.OSType))
            {
                //先檢查 有無其他版本啟用 不包含自己
                WisAppOs wisAppOs = _appListService.CheckAppOsStatus(appListItem.AppID, appListItem.OSType == "IOS" ? 1 : 2);

                if (wisAppOs != null && wisAppOs.AppOSID != Convert.ToInt32(appListItem.AppOSID))
                {
                    return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "已有其本版已啟用!"));
                }
            }

            bool updated = _appListService.EnableOrDisableApp(appListItem.AppOSID, status);

            if (updated)
            {
                return(TResult <bool> .OK(true, "OK"));
            }
            else
            {
                return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "updated fail!"));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 如果資料 只新增 AppList 需刪除 AppID 就可
        /// 如果資料 新增到 AppOS 需刪除 AppOSID
        /// </summary>
        /// <param name="appListItem"></param>
        /// <returns></returns>
        public TResult <bool> DeleteApp(AppListItem appListItem)
        {
            bool deleted = false;

            if (!string.IsNullOrEmpty(appListItem.AppOSID))
            {
                //有值 代表需刪除  AppOS 就可以
                deleted = _appListService.DeleteAppOs(appListItem.AppOSID);
            }
            else
            {
                //無值 代表 只新增 AppList 階段 需刪除 AppID 就可
                deleted = _appListService.DeleteApp(appListItem.AppID);
            }
            if (deleted)
            {
                return(TResult <bool> .OK(true, "OK"));
            }
            else
            {
                return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "delete fail!"));
            }
        }
Exemplo n.º 5
0
        private async void Grid_Tapped(object sender, TappedRoutedEventArgs e)
        {
            AppListItem item = (AppListItem)appListControl.SelectedItem;

            if (item != null)
            {
                if (item.PackageFullName.Contains("AppClock"))
                {
                    this.Frame.Navigate(typeof(AppClock));
                }
                else if (item.PackageFullName.Contains("ConnectMainPackage"))
                {
                    this.Frame.Navigate(typeof(ConnectMainPackage));
                }
                else if (item.PackageFullName.Contains("Shutdown"))
                {
                    this.Frame.Navigate(typeof(Shutdown));
                }
                else if (item.PackageFullName.Contains("Camera2"))
                {
                    StopGpio();
                    this.Frame.Navigate(typeof(Camera2));
                }
                else if (item.PackageFullName.Contains("AudioRecord"))
                {
                    this.Frame.Navigate(typeof(AudioRecord));
                }
                else if (item.PackageFullName.Contains("MediaPlayer"))
                {
                    this.Frame.Navigate(typeof(MediaPlayer));
                }
                else if (item.PackageFullName.Contains("Accelerometer"))
                {
                    this.Frame.Navigate(typeof(Accelerometer));
                }

                /*
                 * else if (item.PackageFullName.Contains("SensorCompass"))
                 * {
                 *  this.Frame.Navigate(typeof(SensorCompass));
                 * }
                 */
                else if (item.PackageFullName.Contains("SensorGyrometer"))
                {
                    this.Frame.Navigate(typeof(SensorGyrometer));
                }
                else if (item.PackageFullName.Contains("Vibrator"))
                {
                    this.Frame.Navigate(typeof(Vibrator));
                }
                else if (item.PackageFullName.Contains("NFCTest"))
                {
                    this.Frame.Navigate(typeof(NFCTest));
                }
                //linda 0511 add wificonnectFromFile
                else if (item.PackageFullName.Contains("WifiConnectFromFile"))
                {
                    this.Frame.Navigate(typeof(WifiConnectFromFile));
                }//linda 0511 add wificonnectFromFile
                else if (item.PackageFullName.Contains("Location2"))
                {
                    this.Frame.Navigate(typeof(Location2));
                }

                /*
                 * else if (item.PackageFullName.Contains("Map"))
                 * {
                 *  this.Frame.Navigate(typeof(Map));
                 * }
                 *
                 * else if (item.PackageFullName.Contains("autotest"))
                 * {
                 *  this.Frame.Navigate(typeof(autotest));
                 * }
                 */
                else if (item.PackageFullName.Contains("Setting"))
                {
                    this.Frame.Navigate(typeof(Setting));
                }
                else if (item.PackageFullName.Contains("DeviceContrl"))
                {
                    this.Frame.Navigate(typeof(DeviceContrl));
                }
                else if (item.PackageFullName.Contains("ShowMessage"))
                {
                    this.Frame.Navigate(typeof(ShowMessage));
                }
                else if (item.PackageFullName.Contains("About"))
                {
                    this.Frame.Navigate(typeof(about));
                }
                else if (item.PackageFullName.Contains("Flashlight"))
                {
                    //if(openStatus ==0)
                    //this.Frame.Navigate(typeof(FlashLight), flashPin112);
                    //else
                    this.Frame.Navigate(typeof(FlashLight), null);
                }
                else if (item.PackageFullName.Contains("AS7000HRM"))
                {
                    this.Frame.Navigate(typeof(AS7000HRM));
                }
                else
                {
                    await item.AppEntry.LaunchAsync();
                }
                //Unable to cast object of type 'Windows.ApplicationModel.Package' to type 'Windows.ApplicationModel.IPackageWithMetadata'.
            }
        }
Exemplo n.º 6
0
        public void SetUp()
        {
            #region Initial fake data of constructor

            _configContext = new ConfigContext
            {
                McpDb              = "Data Source=10.37.36.195;Initial Catalog=MCPDev;uid=gary;pwd=Unsoul418!;",
                UploadPath         = "C:/AppOs",
                ImageEndPoint      = "http://localhost:53322/app",
                IosDownloadAddress = "itms-services://?action=download-manifest&url="
            };

            _appList = new List <AppListItem>
            {
                new AppListItem {
                    AppID       = "4beedc78-0d31-496e-bb9c-81a79c9c6bc6",
                    AppOSID     = "22",
                    Status      = true,
                    CompanyApp  = true,
                    IsTop       = true,
                    AppName     = "Test AppName",
                    PackageName = "com.wistron.portalapp.dev",
                    Development = "MCP development",
                    CreateDT    = DateTime.Now,
                    OSType      = "IOS",
                    Version     = "1.0.0",
                    FileName    = "Portal 2.0_20201022(Dev 0.2.3).apk",
                    FilePath    = "ITSM/IOS/Install/23eb89786e364260ae789d0ec433d724.plist"
                }
            };

            _appListItem = new AppListItem
            {
                AppID       = "4beedc78-0d31-496e-bb9c-81a79c9c6bc6",
                AppOSID     = "22",
                Status      = false,
                CompanyApp  = true,
                IsTop       = true,
                AppName     = "Test AppName",
                PackageName = "com.wistron.portalapp.dev",
                Development = "MCP development",
                CreateDT    = DateTime.Now,
                OSType      = "IOS",
                Version     = "1.0.0",
                FileName    = "Portal 2.0_20201022(Dev 0.2.3).apk",
                FilePath    = "ITSM/IOS/Install/23eb89786e364260ae789d0ec433d724.plist"
            };

            _alreadyEnabled = new WisAppOs
            {
                AppID   = "4beedc78-0d31-496e-bb9c-81a79c9c6bc6",
                AppOSID = 22,
                OSType  = 1
            };

            //fake service
            _appListService    = Substitute.For <IAppListService>();
            _uploadFileService = Substitute.For <IUploadFileService>();
            _mapper            = Substitute.For <IMapper>();
            _authService       = Substitute.For <IAuthService>();

            #endregion

            _targetObj = new AppBiz(_configContext, _appListService, _uploadFileService, _mapper, _authService);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 因實體檔案 目前已 dev server C:/AppOs 路徑下為主 所以再本機 測試 會有無法刪除檔案情形
        /// </summary>
        /// <param name="appListItem"></param>
        /// <returns></returns>
        public TResult <bool> DeleteFile(AppListItem appListItem)
        {
            bool deleted = false;

            if (string.IsNullOrEmpty(appListItem.AppOSID))
            {
                return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "無法刪除實體檔案 因為 AppOsId 為空值"));
            }

            if (string.IsNullOrEmpty(appListItem.FilePath))
            {
                return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "無實體安裝檔案"));
            }

            //IOS 刪除檔案
            if (appListItem.OSType == "IOS")
            {
                //Plist 檔案
                string filePath = $"{_configContext.UploadPath}/{appListItem.FilePath}";
                //ipa 檔案
                string fileName = $"{_configContext.UploadPath}/{appListItem.FileName}";

                if (!File.Exists(filePath))
                {
                    return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, " 無實體安裝Plist路徑檔案"));
                }

                if (!File.Exists(fileName))
                {
                    return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, " 無實體安裝ipa路徑檔案"));
                }

                //刪除實體檔案
                File.Delete(filePath);
                File.Delete(fileName);
            }

            //Android 刪除檔案
            if (appListItem.OSType == "Android")
            {
                //apk 檔案 Android filePath  為 .apk 檔案路徑 fileName 為原.apk 黨案名稱
                string filePath = $"{_configContext.UploadPath}/{appListItem.FilePath}";

                if (!File.Exists(filePath))
                {
                    return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, " 無實體安裝apk路徑檔案"));
                }

                //刪除實體檔案
                File.Delete(filePath);
            }

            //DB 更新
            deleted = _appListService.DeleteAppFilePath(appListItem.AppOSID);

            if (deleted)
            {
                return(TResult <bool> .OK(true, "OK"));
            }
            else
            {
                return(TResult <bool> .Fail(false, FaultInfoRcConstants.ERR_CODE_FAIL, "再刪除資料庫 欄位 FilePath出現錯誤"));
            }
        }