Ejemplo n.º 1
0
        public JsonResult DeleteDeviceSetup(DeviceSetup deviceSetup)
        {
            var          isSuccess = true;
            var          message   = string.Empty;
            const string url       = "/DeviceSetup/Index";

            permission = (RoleSubModuleItem)cacheProvider.Get(cacheKey) ?? roleSubModuleItemService.GetRoleSubModuleItemBySubModuleIdandRole(url,
                                                                                                                                             Helpers.UserSession.GetUserFromSession().RoleId);

            if (permission.DeleteOperation == true)
            {
                isSuccess = this.deviceSetupService.DeleteDeviceSetup(deviceSetup.Id);
                if (isSuccess)
                {
                    message = Resources.ResourceDeviceSetup.MsgDeviceSetupDeleteSuccessful;
                }
                else
                {
                    message = Resources.ResourceDeviceSetup.MsgDeviceSetupDeleteFailed;
                }
            }
            else
            {
                message = Resources.ResourceCommon.MsgNoPermissionToDelete;
            }
            return(Json(new
            {
                isSuccess = isSuccess,
                message = message
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 处理机器开机
        /// </summary>
        /// <param name="deviceId">设备Id</param>
        /// <param name="deviceOwn">设备所有人</param>
        /// <param name="deviceSetup">设备信息</param>
        private async Task ProcessDeviceSetup(string deviceId, string deviceOwn, DeviceSetup deviceSetup)
        {
            var device = new Entity.Device
            {
                #region
                ComPortNum = deviceSetup.ComPortNum,
                DeviceName = deviceId,
                DeviceType = deviceSetup.DevType,
                InDate     = DateTime.Now,
                DeviceId   = deviceId,
                IsGetway   = deviceSetup.IsGateway,
                IsOnline   = true,
                Gps        = deviceSetup.GPS,
                UserOwn    = deviceOwn,
                Version    = deviceSetup.Version
                             #endregion
            };

            if (await this.deviceService.GetDevice(deviceId) == null)
            {
                await this.deviceService.Insert(device);
            }
            else
            {
                device.IsOnline = true;
                await this.deviceService.Update(device);
            }
        }
        private void ConntectToService()
        {
            MainViewModel.Conntected = true;
            DeviceEssentials.device  = device;
            DeviceSetup.ConnectToDevice();

            nav.GoBack();
            nav.GoBack();
        }
Ejemplo n.º 4
0
        public async void GetDeviceList()
        {
            try
            {
                var device = await DeviceSetup.FindDevice((e) =>
                {
                    Scanning = e;
                });

                deviceList.Add(device);
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
        public void PollDevice(int deviceId)
        {
            //Execute this in Background, because it will take a while and the core might be blocked
            BackgroundJob.Enqueue(() => ExecutePollAction(deviceId));

            //if polling is not done by the device, to it using this website //todo: check if this is initiated, seems to be improper to be done in this method
            DeviceSetup deviceSetup = _deviceSetupRepository.GetSingle(deviceId);

            if (deviceSetup != null && !deviceSetup.PollingEnabled)
            {
                var minutes = deviceSetup.PostBackIntervalMinutes;
                RecurringJob.AddOrUpdate(_recurringDevicePollingTaskName, () => ExecutePollAction(deviceId),
                                         "*/" + minutes + " * * * *");
            }
        }
Ejemplo n.º 6
0
        public bool UpdateDeviceSetup(DeviceSetup deviceSetup)
        {
            bool isSuccess = true;

            try
            {
                deviceSetupRepository.Update(deviceSetup);
                this.SaveRecord();
                ServiceUtil <DeviceSetup> .WriteActionLog(deviceSetup.Id, ENUMOperation.UPDATE, deviceSetup);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in updating DeviceSetup", ex);
            }
            return(isSuccess);
        }
        public DeviceSetup Update(DeviceSetup deviceSetup)
        {
            DeviceConfiguration existingConfiguration = GetSingle(deviceSetup.Id);

            if (existingConfiguration != null)
            {
                _dbContext.Update(existingConfiguration);

                existingConfiguration.PollingEnabled          = deviceSetup.PollingEnabled;
                existingConfiguration.PostBackIntervalMinutes = deviceSetup.PostBackIntervalMinutes;
                existingConfiguration.PostBackUrl             = deviceSetup.PostBackUrl;
                existingConfiguration.PostBackPort            = deviceSetup.PostBackPort;

                _dbContext.SaveChanges();
            }

            return(existingConfiguration);
        }
Ejemplo n.º 8
0
        private DeviceSetupModel PrepareDeviceSetupModel(DeviceSetup deviceSetup)
        {
            DeviceSetupModel deviceSetupTemp = new DeviceSetupModel();

            deviceSetupTemp.Id        = deviceSetup.Id;
            deviceSetupTemp.Name      = deviceSetup.Name;
            deviceSetupTemp.Code      = deviceSetup.Code;
            deviceSetupTemp.Gate      = deviceSetup.Gate;
            deviceSetupTemp.IPAddress = deviceSetup.IPAddress;
            deviceSetupTemp.Location  = deviceSetup.Location;
            deviceSetupTemp.Port      = deviceSetup.Port;
            deviceSetupTemp.TypeId    = deviceSetup.TypeId;
            if (deviceSetupTemp.TypeId > 0)
            {
                deviceSetupTemp.DeviceTypeName = deviceSetup.DeviceType.Name;
            }
            deviceSetupTemp.SchoolId = deviceSetup.SchoolId;
            if (deviceSetupTemp.SchoolId > 0)
            {
                deviceSetupTemp.SchoolName = deviceSetup.School.Name;
                deviceSetupTemp.UpazilaId  = deviceSetup.School.UpazilaId;
                if (deviceSetupTemp.UpazilaId > 0)
                {
                    //deviceSetupTemp.UpazilaName = deviceSetup.School.Upazila.Name;
                    deviceSetupTemp.DistrictId = deviceSetup.School.Upazila.DistrictId;
                    if (deviceSetupTemp.DistrictId > 0)
                    {
                        //deviceSetupTemp.DistrictName = deviceSetup.School.Upazila.District.Name;
                        deviceSetupTemp.DivisionId = deviceSetup.School.Upazila.District.DivisionId;
                        if (deviceSetupTemp.DivisionId > 0)
                        {
                            //deviceSetupTemp.DivisionName = deviceSetup.School.Upazila.District.Division.Name;
                            deviceSetupTemp.GeoName = deviceSetup.School.Upazila.District.Division.Name + " - " + deviceSetup.School.Upazila.District.Name + " - " + deviceSetup.School.Upazila.Name;
                        }
                    }
                }
            }
            if (deviceSetup.IsActive != null)
            {
                deviceSetupTemp.IsActive = deviceSetup.IsActive.Value;
            }
            return(deviceSetupTemp);
        }
        public IActionResult UpdateDeviceSetup(int id, [FromBody] FoodItemDto dto)
        {
            DeviceSetup deviceSetupToCheck = _deviceSetupRepository.GetSingle(id);

            if (deviceSetupToCheck == null)
            {
                return(NotFound());
            }
            if (id != dto.Id)
            {
                return(BadRequest("ids do not match"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var updatedItem = _deviceSetupRepository.Update(AutoMapper.Mapper.Map <DeviceSetup>(dto));

            return(Ok(AutoMapper.Mapper.Map <DeviceSetupDto>(updatedItem)));
        }
Ejemplo n.º 10
0
        async public void Activate(NavigationEventArgs e)
        {
            SelectedDevice = e.Parameter as SsdpRootDevice;

            HttpClient client         = new HttpClient();
            string     deviceSetupXml = await client.GetStringAsync(SelectedDevice.Location);

            XmlSerializer serializer  = new XmlSerializer(typeof(DeviceSetup));
            DeviceSetup   deviceSetup = (DeviceSetup)serializer.Deserialize(new StringReader(deviceSetupXml));

            wifiSetupService = null;
            foreach (Service service in deviceSetup.Device.ServiceList.Service)
            {
                if (service.ServiceId == "urn:Belkin:serviceId:WiFiSetup1")
                {
                    wifiSetupService = service;
                    break;
                }
            }

            GetApList();
        }
Ejemplo n.º 11
0
        private void UpdateModel()
        {
            if (Model != null)
            {
                var oldModel = Model;
                Model = null;
                oldModel.Dispose();
            }



            try
            {
                Model = new DownloadManager(DeviceSetup.GetModel());
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Error connecting to device : {ex.GetType().Name} - {ex.Message}");
            }

            UpdateFromDomain();
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            var openGUI = false;

            version = new Version();
            // Review & parse command line arguments

            if (args != null && args.Length > 0)
            {
                #region Parse Arguments
                foreach (string arg in args)
                {
                    // First of all.
                    // We check if bot have called clicking in a pokesnimer URI: pokesniper2://PokemonName/latitude,longitude
                    if (args[0].Contains("pokesniper2") || args[0].Contains("msniper"))
                    {
                        // If yes, We create a temporary file to share with main process, and close.
                        SniperPanel.SharePokesniperURI(args[0]);
                        return;
                    }

                    #region Argument -nogui
                    if (arg.Contains("-nogui"))
                    {
                        Logger.ColoredConsoleWrite(ConsoleColor.Red, "You added -nogui!");

                        #region Read bot settings
                        if (File.Exists(Program.accountProfiles))
                        {
                            string  JSONstring      = File.ReadAllText(accountProfiles);
                            var     Profiles        = Newtonsoft.Json.JsonConvert.DeserializeObject <Collection <Profile> >(JSONstring);
                            Profile selectedProfile = null;
                            foreach (Profile _profile in Profiles)
                            {
                                if (_profile.IsDefault)
                                {
                                    selectedProfile = _profile;
                                    break;
                                }
                            }
                            if (selectedProfile != null)
                            {
                                GlobalVars.ProfileName = selectedProfile.ProfileName;
                                var filenameProf = Path.Combine(path, $"{selectedProfile.ProfileName}.json");
                                selectedProfile.Settings = ProfileSettings.LoadFromFile(filenameProf);
                                selectedProfile.Settings.SaveToGlobals();
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Red, "Default Profile not found! You didn't setup the bot correctly by running it with -nogui.");
                                Environment.Exit(-1);
                            }
                        }
                        else
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Red, "You have not setup the bot yet. Run it without -nogui to Configure.");
                            Environment.Exit(-1);
                        }

                        if (GlobalVars.UsePwdEncryption)
                        {
                            GlobalVars.Password = Encryption.Decrypt(GlobalVars.Password);
                        }
                        #endregion
                    }
                    #endregion

                    #region Argument Coordinates
                    if (arg.Contains(","))
                    {
                        if (File.Exists(LastCoordsTXTFileName))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(LastCoordsTXTFileName);
                        }

                        string[] crdParts = arg.Split(',');
                        GlobalVars.latitude  = double.Parse(crdParts[0].Replace(',', '.'), ConfigWindow.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        GlobalVars.longitude = double.Parse(crdParts[1].Replace(',', '.'), ConfigWindow.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Logger.ColoredConsoleWrite(ConsoleColor.Yellow, $"Found coordinates in command line. Starting at: {GlobalVars.latitude},{GlobalVars.longitude},{GlobalVars.altitude}");
                    }
                    #endregion

                    #region Argument -bypassversioncheck
                    GlobalVars.BypassCheckCompatibilityVersion |= arg.ToLower().Contains("-bypassversioncheck");
                    #endregion

                    #region Argument -help
                    if (arg.ToLower().Contains("-help"))
                    {
                        //Show Help
                        System.Console.WriteLine($"Pokemon BOT C# v{Resources.BotVersion.ToString()} help" + Environment.NewLine);
                        System.Console.WriteLine("Use:");
                        System.Console.WriteLine("  -nogui <lat>,<long>         Console mode only, starting on the indicated Latitude & Longitude");
                        System.Console.WriteLine("  -bypassversioncheck         Do NOT check BOT & API compatibility (be careful with that option!)");
                        System.Console.WriteLine("  -help                       This help" + Environment.NewLine);
                        Environment.Exit(0);
                    }
                    #endregion
                }
            }
            else
            {
                openGUI = true;
            }
            #endregion

            // Checking if current BOT API implementation supports NIANTIC current API (unless there's an override command line switch)
            if (!GlobalVars.BypassCheckCompatibilityVersion)
            {
                var currentAPIVersion = new CurrentAPIVersion();
                Logger.ColoredConsoleWrite(ConsoleColor.DarkMagenta, $"Bot Current version: {Resources.BotVersion}");
                Logger.ColoredConsoleWrite(ConsoleColor.DarkMagenta, $"Bot Supported API version: {Resources.BotApiSupportedVersion}");
                Logger.ColoredConsoleWrite(ConsoleColor.DarkMagenta, $"Current API version: {currentAPIVersion.GetNianticAPIVersion()}");

                bool CurrentVersionsOK = currentAPIVersion.CheckAPIVersionCompatibility(GlobalVars.BotApiSupportedVersion);
                if (!CurrentVersionsOK)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Atention, current API version is new and still not supported by Bot.");
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Bot will now exit to keep your account safe.");
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"---------- PRESS ANY KEY TO CLOSE ----------");

                    Console.ReadKey();
                    Environment.Exit(-1);
                }
            }

            // Check if Bot is deactivated at server level
            StringUtils.CheckKillSwitch();

            // Check if a new version of BOT is available
            CheckVersion();

            if (openGUI)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ConfigWindow());

                Task.Run(() =>
                {
                    new Panels.SplashScreen().ShowDialog();
                });
                openGUI = GlobalVars.EnablePokeList;
                if (GlobalVars.EnableConsoleInTab)
                {
                    Logger.type = 1;
                }
                // To open tabbed GUI to test programing

                /*
                 * TabbedSystem.skipReadyToUse = true;
                 * Application.Run( new TabbedSystem());
                 * Environment.Exit(0);
                 */
            }

            SleepHelper.PreventSleep();
            CreateLogDirectories();

            GlobalVars.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task.Run(() =>
            {
                do
                {
                    try
                    {
                        DeviceSetup.SelectDevice(GlobalVars.DeviceTradeName, GlobalVars.DeviceID, deviceData);
                        new Logic.Logic(new Settings(), GlobalVars.infoObservable).Execute();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error($"Unhandled exception: {ex}");
                    }
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(20000);
                }while (Logic.Logic.restartLogic);
            });

            if (openGUI)
            {
                if (GlobalVars.simulatedPGO)
                {
                    Application.Run(new GameAspectSimulator());
                }
                else
                {
                    if (GlobalVars.EnableConsoleInTab)
                    {
                        FreeConsole();
                    }
                    Application.Run(new TabbedSystem());
                }
            }
            else
            {
                System.Console.ReadLine();
            }
            SleepHelper.AllowSleep();
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            var     openGUI = true;
            Version version = new Version();

            // Review & parse command line arguments

            if (args != null && args.Length > 0)
            {
                #region Parse Arguments
                foreach (string arg in args)
                {
                    #region Argument -nogui
                    if (arg.Contains("-nogui"))
                    {
                        openGUI = false;
                        Profile selectedProfile = new Profile();
                        Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Argument: -nogui");
                        if (!arg.Contains(":")) // Load Default Profile
                        {
                            #region Read bot settings
                            if (File.Exists(GlobalVars.FileForProfiles))
                            {
                                var Profiles = Newtonsoft.Json.JsonConvert.DeserializeObject <Collection <Profile> >(File.ReadAllText(GlobalVars.FileForProfiles));
                                foreach (Profile _profile in Profiles)
                                {
                                    if (_profile.IsDefault)
                                    {
                                        selectedProfile = _profile;
                                        break;
                                    }
                                }
                                if (selectedProfile != null)
                                {
                                    GlobalVars.ProfileName   = selectedProfile.ProfileName;
                                    selectedProfile.Settings = ProfileSettings.LoadFromFile(Path.Combine(GlobalVars.PathToConfigs, $"{selectedProfile.ProfileName}.json"));
                                    selectedProfile.Settings.SaveToGlobals();
                                }
                                else
                                {
                                    Logger.ColoredConsoleWrite(ConsoleColor.Red, "Default Profile not found! You didn't setup the bot correctly by running it with -nogui.");
                                    Environment.Exit(-1);
                                }
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Red, "You have not setup the bot yet. Run it without -nogui to Configure.");
                                Environment.Exit(-1);
                            }
                        }
                        else // Load selected profile
                        {
                            var givenProfile = arg.Split(':');
                            if (File.Exists(Path.Combine(GlobalVars.PathToConfigs, givenProfile[1] + ".json")))
                            {
                                selectedProfile.ProfileName = givenProfile[1];
                                GlobalVars.ProfileName      = selectedProfile.ProfileName;
                                selectedProfile.Settings    = ProfileSettings.LoadFromFile(Path.Combine(GlobalVars.PathToConfigs, givenProfile[1] + ".json"));
                                selectedProfile.Settings.SaveToGlobals();
                            }
                            else
                            {
                                Logger.ColoredConsoleWrite(ConsoleColor.Red, "Profile not found! You didn't setup the bot correctly by running it with -nogui.");
                                Environment.Exit(-1);
                            }
                        }

                        Logger.ColoredConsoleWrite(ConsoleColor.Cyan, "Argument: profile. Using " + GlobalVars.ProfileName + ". Check logs in this profile log folder.");
                        CheckLogDirectories(Path.Combine(GlobalVars.PathToLogs, GlobalVars.ProfileName));

                        if (GlobalVars.UsePwdEncryption)
                        {
                            GlobalVars.Password = Encryption.Decrypt(GlobalVars.Password);
                        }
                        #endregion
                    }
                    #endregion

                    #region Argument Coordinates
                    if (arg.Contains(","))
                    {
                        if (File.Exists(GlobalVars.FileForCoordinates))
                        {
                            Logger.ColoredConsoleWrite(ConsoleColor.Yellow, "Last coords file exists, trying to delete it");
                            File.Delete(GlobalVars.FileForCoordinates);
                        }

                        string[] crdParts = arg.Split(',');
                        GlobalVars.latitude  = double.Parse(crdParts[0].Replace(',', '.'), ConfigWindow.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        GlobalVars.longitude = double.Parse(crdParts[1].Replace(',', '.'), ConfigWindow.cords, System.Globalization.NumberFormatInfo.InvariantInfo);
                        Logger.ColoredConsoleWrite(ConsoleColor.Cyan, $"Argument: coordinates. Starting at: {GlobalVars.latitude},{GlobalVars.longitude},{GlobalVars.altitude}");
                        //we assume -nogui
                        openGUI = false;
                    }
                    #endregion

                    #region Argument -bypassversioncheck
                    GlobalVars.BypassCheckCompatibilityVersion |= arg.ToLower().Contains("-bypassversioncheck");
                    #endregion

                    #region Argument -bypasskillswitch
                    GlobalVars.BypassKillSwitch |= arg.ToLower().Contains("-bypasskillswitch");
                    #endregion

                    #region Argument -help
                    if (arg.ToLower().Contains("-help"))
                    {
                        //Show Help
                        System.Console.WriteLine($"Pokemon BOT C# v{Resources.BotVersion.ToString()} help" + Environment.NewLine);
                        System.Console.WriteLine("Use:");
                        System.Console.WriteLine("  -nogui<:profile_name> <lat>,<long>         Console mode only, starting on the indicated Profile , Latitude & Longitude ");
                        System.Console.WriteLine("  -bypassversioncheck         Do NOT check BOT & API compatibility (be careful with that option!)");
                        System.Console.WriteLine("  -bypasskillswitch           Do NOT check the forced bot stop (this assures a more than probable ban of your account)");
                        System.Console.WriteLine("  -help                       This help" + Environment.NewLine);
                        Environment.Exit(0);
                    }
                    #endregion
                }
            }
            #endregion

            // Checking if current BOT API implementation supports NIANTIC current API (unless there's an override command line switch)
            var currentAPIVersion = new CurrentAPIVersion();
            Logger.ColoredConsoleWrite(ConsoleColor.DarkCyan, "_____________________________________________________________");
            Logger.ColoredConsoleWrite(ConsoleColor.White, "Attention: NO BOT IS SAFE - YOUR ACCOUNT MIGHT BE BANNED !!!");
            Logger.ColoredConsoleWrite(ConsoleColor.Gray, "----- You have been warned => Your decision, your risk -----");
            Logger.ColoredConsoleWrite(ConsoleColor.DarkCyan, "_____________________________________________________________");
            Logger.ColoredConsoleWrite(ConsoleColor.Gray, $"             Supported API version: {Resources.BotApiSupportedVersion}");
            Logger.ColoredConsoleWrite(ConsoleColor.Gray, $"              Current API version: {currentAPIVersion.GetNianticAPIVersion()}");
            Logger.ColoredConsoleWrite(ConsoleColor.DarkCyan, $"_____________________________________________________v{Resources.BotVersion}");

            Resources.SetApiVars(currentAPIVersion.GetNianticAPIVersion());
            // Check if a new version of BOT is available
            CheckForNewBotVersion();

            if (!GlobalVars.BypassCheckCompatibilityVersion)
            {
                bool CurrentVersionsOK = currentAPIVersion.CheckAPIVersionCompatibility(GlobalVars.BotApiSupportedVersion);
                if (!CurrentVersionsOK)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Atention, current API version is new and still not supported by Bot.");
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"Bot will now exit to keep your account safe.");
                    Logger.ColoredConsoleWrite(ConsoleColor.Red, $"---------- PRESS ANY KEY TO CLOSE ----------");

                    Console.ReadKey();
                    Environment.Exit(-1);
                }
            }

            // Check if Bot is deactivated at server level
            if (!GlobalVars.BypassKillSwitch)
            {
                StringUtils.CheckKillSwitch();
            }

            if (openGUI)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ConfigWindow());

                Task.Run(() =>
                {
                    new Panels.SplashScreen().ShowDialog();
                });
                openGUI = GlobalVars.EnablePokeList;
                if (GlobalVars.EnableConsoleInTab)
                {
                    Logger.type = 1;
                }
                // To open tabbed GUI to test programing

                /*
                 * TabbedSystem.skipReadyToUse = true;
                 * Application.Run( new TabbedSystem());
                 * Environment.Exit(0);
                 */
            }

            SleepHelper.PreventSleep();

            // Ensure all log paths exists
            CheckLogDirectories(Path.Combine(GlobalVars.PathToLogs, GlobalVars.ProfileName));

            GlobalVars.infoObservable.HandleNewHuntStats += SaveHuntStats;

            Task MainTask;

            MainTask = Task.Run(() =>
            {
                do
                {
                    try
                    {
                        DeviceSetup.SelectDevice(GlobalVars.DeviceTradeName, GlobalVars.DeviceID, GlobalVars.FileForDeviceData);
                        new Logic.Logic(new Settings(), GlobalVars.infoObservable).Execute();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error($"Unhandled exception: {ex}");
                    }
                    Logger.Error("Restarting in 20 Seconds.");
                    Thread.Sleep(20000);
                }while (Logic.Logic.restartLogic);
            });

            if (openGUI)
            {
                if (GlobalVars.simulatedPGO)
                {
                    Application.Run(new GameAspectSimulator());
                }
                else
                {
                    if (GlobalVars.EnableConsoleInTab)
                    {
                        FreeConsole();
                    }
                    Application.Run(new TabbedSystem());
                }
            }

            MainTask.Wait();

            SleepHelper.AllowSleep();
        }
Ejemplo n.º 14
0
        public JsonResult CreateDeviceSetup(DeviceSetup deviceSetup)
        {
            const string url = "/DeviceSetup/Index";

            permission = (RoleSubModuleItem)cacheProvider.Get(cacheKey);
            if (permission == null)
            {
                permission = roleSubModuleItemService.GetRoleSubModuleItemBySubModuleIdandRole(url, Helpers.UserSession.GetUserFromSession().RoleId);
            }

            var isSuccess = false;
            var message   = string.Empty;
            var isNew     = deviceSetup.Id == 0 ? true : false;

            if (isNew)
            {
                if (permission.CreateOperation == true)
                {
                    if (!CheckIsExist(deviceSetup))
                    {
                        if (this.deviceSetupService.CreateDeviceSetup(deviceSetup))
                        {
                            isSuccess = true;
                            message   = Resources.ResourceDeviceSetup.MsgDeviceSetupSaveSuccessful;
                        }
                        else
                        {
                            message = Resources.ResourceDeviceSetup.MsgDeviceSetupSaveFailed;
                        }
                    }
                    else
                    {
                        isSuccess = false;
                        message   = Resources.ResourceDeviceSetup.MsgDuplicateDeviceSetup;
                    }
                }
                else
                {
                    message = Resources.ResourceCommon.MsgNoPermissionToCreate;
                }
            }
            else
            {
                if (permission.UpdateOperation == true)
                {
                    if (this.deviceSetupService.UpdateDeviceSetup(deviceSetup))
                    {
                        isSuccess = true;
                        message   = Resources.ResourceDeviceSetup.MsgDeviceSetupUpdateSuccessful;
                    }
                    else
                    {
                        message = Resources.ResourceDeviceSetup.MsgDeviceSetupUpdateFailed;
                    }
                }
                else
                {
                    message = Resources.ResourceCommon.MsgNoPermissionToUpdate;
                }
            }

            return(Json(new
            {
                isSuccess = isSuccess,
                message = message,
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 15
0
 private bool CheckIsExist(DeviceSetup deviceSetup)
 {
     return(this.deviceSetupService.CheckIsExist(deviceSetup));
 }
Ejemplo n.º 16
0
 public bool CheckIsExist(DeviceSetup deviceSetup)
 {
     return(deviceSetupRepository.Get(chk => chk.Name == deviceSetup.Name) == null ? false : true);
 }