Exemplo n.º 1
0
        public App()
        {
            InitializeComponent();

            //For https connexion
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;

            //Read config file to load server URL
            ApplicationConstants.ReadConfigFile();

            //Load and send json which were not sended to server
            Task.Run(() =>
            {
                try
                {
                    EvaluationSender.LoadJsons();
                    EvaluationSender.SendJsonEvalToServer();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            });

            //Display the first Page of the app (MainPage => LoginPage)
            MainPage = new NavigationPage(new Onek.MainPage());
        }
        public void EndToEnd_BothViews_DataIsStoredRetrievedApprovedAndSaved()
        {
            const string firstName       = "John";
            const string lastName        = "Smith";
            const string gymMembershipId = "ABCD1234";
            var          member          = new Member {
                FirstName = firstName, LastName = lastName, GymMembershipId = gymMembershipId
            };

            var sutPage1  = new GatherMemberInfoPresenter(_tempDataRepository, _gatherMemberInfoView);
            var fakeView1 = (FakeGatherMemberInfoView)_gatherMemberInfoView;

            fakeView1.TriggerEvent_GatherMemberInfo(member);

            Assert.IsTrue(fakeView1.GoToNextViewMethodIsCalled);

            var sutPage2 = new RenewMembershipPresenter(_tempDataRepository, _nationalFitnessGateway,
                                                        _ccProcessingGateway, _memberRepository, _renewMembershipView);
            var fakeView2 = (FakeRenewMembershipView)_renewMembershipView;

            fakeView2.TriggerEvent_Initialize();
            Assert.AreEqual(member, _renewMembershipView.Member);

            fakeView2.TriggerEvent_RenewMembership();

            const bool isPaid = true;
            var        expectedFinalMessage = ApplicationConstants.FormatApprovalMessageForMember(member, isPaid);

            Assert.AreEqual(member, _renewMembershipView.Member);
            Assert.AreEqual(expectedFinalMessage, fakeView2.Message);
        }
        public void CompanyName()
        {
            var assembly = GetAssembly();
            var attribute = assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0] as AssemblyCompanyAttribute;

            var constants = new ApplicationConstants();
            Assert.AreEqual(attribute.Company, constants.CompanyName);
        }
        public void ApplicationVersion()
        {
            var assembly = GetAssembly();
            var version = assembly.GetName().Version;

            var constants = new ApplicationConstants();
            Assert.AreEqual(version, constants.ApplicationVersion);
        }
        public void ApplicationName()
        {
            var assembly = GetAssembly();
            var attribute = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false)[0] as AssemblyProductAttribute;

            var constants = new ApplicationConstants();
            Assert.AreEqual(attribute.Product, constants.ApplicationName);
        }
        public void ApplicationCompatibilityVersion()
        {
            var assembly = GetAssembly();
            var version = assembly.GetName().Version;

            var constants = new ApplicationConstants();
            Assert.AreEqual(new Version(version.Major, version.Minor), constants.ApplicationCompatibilityVersion);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FileConstants"/> class.
        /// </summary>
        /// <param name="constants">The object that stores constant values for the application.</param>
        public FileConstants(ApplicationConstants constants)
        {
            {
                Lokad.Enforce.Argument(() => constants);
            }

            m_Constants = constants;
        }
Exemplo n.º 8
0
        //[Authorize(Roles = "DataEntryOperator")]
        public async Task <IActionResult> ApproveRegistration(int id)
        {
            var ClientPersonal = await context.ClientPersonal.FirstOrDefaultAsync(x => x.Id == id);

            if (ClientPersonal == null)
            {
                return(BadRequest("Invalid Client Id"));
            }

            var user = new IdentityUser
            {
                UserName             = ApplicationConstants.USER_NAME_PREFIX + id,
                Email                = ClientPersonal.EmailAddress,
                PhoneNumber          = ClientPersonal.ContactNumber,
                PhoneNumberConfirmed = true,
                EmailConfirmed       = true
            };
            var password = ClientPersonal.CompanyName.ToLower() + "-" +
                           ApplicationConstants.PasswordString(ApplicationConstants.PASSWORD_STRING_LENGTH) + ClientPersonal.ShipmentsPerWeek;
            var result = await userManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                // Email client for successful registration with user id and password
                var message = new MimeMessage();
                message.From.Add(new MailboxAddress("Osama", "*****@*****.**"));
                message.To.Add(new MailboxAddress("Test", "*****@*****.**"));
                message.Subject = "Test email";
                message.Body    = new TextPart("plain")
                {
                    Text = "Username: hello , pwd : qwer@1234"
                };
                using (var client = new SmtpClient())
                {
                    client.Connect("smtp.gmail.com", 587, false);
                    client.Authenticate("*****@*****.**", "hotmail222");
                    client.Send(message);
                    client.Disconnect(true);
                }
                await userManager.AddToRoleAsync(user, "Client");

                ClientPersonal.UserId = user.Id;
                context.ClientPersonal.Update(ClientPersonal);
                await context.SaveChangesAsync();

                return(Ok());
            }
            else
            {
                StringBuilder errors = new StringBuilder();
                foreach (var error in result.Errors)
                {
                    errors.Append(error.Description);
                }
                throw new Exception(errors.ToString());
            }
        }
        public ApplicationConstants GetApplicationConstants()
        {
            ApplicationConstants applicationConstants = new ApplicationConstants
            {
                ProductCategories    = AdventureWorks.ProductCategories,
                ProductSubcategories = AdventureWorks.ProductSubcategories
            };

            return(applicationConstants);
        }
Exemplo n.º 10
0
        private void appFetcherButton_Click(object sender, EventArgs e)
        {
            if (!_applicationData.IsApiKeySet())
            {
                ApplicationConstants.MessageApiNotSet();
                return;
            }

            _formAppFetcher.Show();
        }
Exemplo n.º 11
0
 public static void Postfix(ApplicationConstants __instance)
 {
     RLog.M.TWL(0, "ApplicationConstants.FromJSON. PrewarmRequests:");
     try
     {
         List <PrewarmRequest> prewarmRequests = new List <PrewarmRequest>();
         prewarmRequests.AddRange(__instance.PrewarmRequests);
         HashSet <string> svgs = new HashSet <string>();
         foreach (AmmoCategoryValue ammoCat in AmmoCategoryEnumeration.AmmoCategoryList)
         {
             if (ammoCat.isBuildinIcon() == false)
             {
                 svgs.Add(ammoCat.Icon);
             }
         }
         foreach (WeaponCategoryValue weaponCat in WeaponCategoryEnumeration.WeaponCategoryList)
         {
             if (weaponCat.isBuildinIcon() == false)
             {
                 svgs.Add(weaponCat.Icon);
             }
         }
         FieldInfo[] fields = typeof(UILookAndColorConstants).GetFields();
         foreach (FieldInfo field in fields)
         {
             //RLog.M.WL(1, field.Name+":"+field.FieldType);
             if (field.FieldType != typeof(SVGAsset))
             {
                 continue;
             }
             string id = "UILookAndColorConstants." + field.Name;
             if (ModTek.isInSystemIcons(id))
             {
                 svgs.Add(id);
             }
         }
         foreach (string svg in svgs)
         {
             if (string.IsNullOrEmpty(svg) == false)
             {
                 prewarmRequests.Add(new PrewarmRequest(BattleTechResourceType.SVGAsset, svg));
             }
             ;
         }
         typeof(ApplicationConstants).GetProperty("PrewarmRequests", BindingFlags.Instance | BindingFlags.Public).GetSetMethod(true).Invoke(__instance, new object[] { prewarmRequests.ToArray() });
         foreach (PrewarmRequest preq in __instance.PrewarmRequests)
         {
             RLog.M.WL(1, preq.ResourceType + ":" + preq.ResourceID);
         }
     }
     catch (Exception e)
     {
         RLog.M.TWL(0, e.ToString(), true);
     }
 }
Exemplo n.º 12
0
        public void ProductSettingsPath()
        {
            var applicationConstants = new ApplicationConstants();
            var constants = new FileConstants(applicationConstants);

            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), applicationConstants.CompanyName);
            path = Path.Combine(path, applicationConstants.ApplicationName);
            path = Path.Combine(path, applicationConstants.ApplicationCompatibilityVersion.ToString(2));

            Assert.AreEqual(path, constants.ProductSettingsUserPath());
        }
Exemplo n.º 13
0
        public void LogPath()
        {
            var applicationConstants = new ApplicationConstants();
            var constants = new FileConstants(applicationConstants);

            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), applicationConstants.CompanyName);
            path = Path.Combine(path, applicationConstants.ApplicationName);
            path = Path.Combine(path, applicationConstants.ApplicationCompatibilityVersion.ToString(2));
            path = Path.Combine(path, "logs");

            Assert.AreEqual(path, constants.LogPath());
        }
Exemplo n.º 14
0
        /// <summary>
        /// Appends Serilog as the logging provider.
        /// </summary>
        /// <param name="builder">The web host builder to configure.</param>
        /// <returns>The web host builder.</returns>
        public static IWebHostBuilder AppendSerilog(this IWebHostBuilder builder)
        {
            Ensure.ArgumentNotNull(builder, nameof(builder));

            IApplicationConstants constants = new ApplicationConstants();

            return(builder.UseSerilog((hostingContext, loggerConfiguration) =>
            {
                IAppOptions appOptions = new AppOptions();
                hostingContext.Configuration.GetSection("AppOptions").Bind(appOptions);
                if (string.IsNullOrWhiteSpace(appOptions.WorkingDirectory))
                {
                    throw new UnexpectedNullException("Working directory is not defined.");
                }

                loggerConfiguration
                .SetMinimumLevel(hostingContext.Configuration)
                .Enrich.FromLogContext()
                .WriteTo.Console();

                if (bool.TryParse(hostingContext.Configuration["Logging:WriteToFile"], out bool writeToFile))
                {
                    if (writeToFile)
                    {
                        string path = Path.Combine(appOptions.WorkingDirectory, constants.LogFilePath);
                        if (!Uri.TryCreate(path, UriKind.RelativeOrAbsolute, out var logFilePath))
                        {
                            throw new Exception($"Invalid log file path '{constants.LogFilePath}'.");
                        }

                        var logFile = new FileInfo(Path.GetFullPath(path));
                        logFile.Directory?.Create();
                        loggerConfiguration
                        .WriteTo.File(
                            new RenderedCompactJsonFormatter(),
                            logFile.FullName,
                            fileSizeLimitBytes: 10_000_000,
                            rollOnFileSizeLimit: true,
                            retainedFileCountLimit: 2,
                            shared: true,
                            flushToDiskInterval: TimeSpan.FromSeconds(5));
                    }
                }
                if (bool.TryParse(hostingContext.Configuration["Logging:WriteToDb"], out bool writeToDb))
                {
                    if (writeToDb)
                    {
                        loggerConfiguration
                        .WriteToSqlite(appOptions, constants);
                    }
                }
            }));
        }
Exemplo n.º 15
0
        private async void LoadApp()
        {
            _appStoreInfo = await _applicationData.GetAppInfoAsync(_appId);

            if (_appStoreInfo == null)
            {
                ApplicationConstants.MessageAppNotAvailable();
                return;
            }

            LoadTextAppData();

            Show();
        }
Exemplo n.º 16
0
        private async void dataGridView1_DoubleClick(object sender, EventArgs e)
        {
            ulong friendsId = _currentPlayerProfile.Friends[dataGridView1.CurrentCell.RowIndex];
            ApplicationPlayerDetails friendDetails = new ApplicationPlayerDetails();

            if (!await _applicationData.GetUserByIdAsync(friendsId, friendDetails))
            {
                ApplicationConstants.MessageUserNotFound();
                return;
            }

            var friendsProfile = new FormProfileOverview(_applicationData, friendDetails);

            friendsProfile.Show();
        }
Exemplo n.º 17
0
        private void buttonProfile_Click(object sender, EventArgs e)
        {
            if (!_applicationData.IsUsernameSet())
            {
                ApplicationConstants.MessageUsernameNotSet();
                return;
            }

            // I'm sorry... I could not fix it in any better way
            if (!_applicationData.PlayerDetails.EverythingLoaded)
            {
                ApplicationConstants.MessageProfileNotYetLoaded();
                return;
            }
            var profileView = new FormProfileOverview(_applicationData);

            profileView.Show();
        }
Exemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    //*************************************************************************************
                    //Reset Filters and Page Number for catalogs grid if we are not coming from the add/edit window of the catalog
                    if (!string.IsNullOrEmpty(Page.Request.Headers["Referer"]))
                    {
                        SessionManager.RemoveValueFromSession(this.Page, SessionStrings.FILTER_EXPRESSION);
                        SessionManager.RemoveValueFromSession(this.Page, SessionStrings.FILTER_ITEM);
                        SessionManager.RemoveValueFromSession(this.Page, SessionStrings.PAGE_NUMBER_MAPPING);
                    }
                    //*************************************************************************************
                }

                Control c;
                if (HttpContext.Current.Request.QueryString.Keys.Count == 0)
                {
                    this.ShowError(new IndException(ApplicationMessages.EXCEPTION_COULD_NOT_GET_CATALOGUE_CODE_PARAMETER));
                    return;
                }
                //The code parameter is always the first parameter
                string codeParam     = HttpContext.Current.Request.QueryString.Keys[0];
                string catalogueCode = HttpContext.Current.Request.QueryString[codeParam];

                string ascxPath = ApplicationConstants.GetASCXPath(catalogueCode);

                c    = Page.LoadControl(ascxPath);
                c.ID = "parentGenericView";
                this.plhCatalogue.Controls.Add(c);
            }
            catch (IndException ex)
            {
                ShowError(ex);
                return;
            }
            catch (Exception ex)
            {
                ShowError(new IndException(ex));
                return;
            }
        }
Exemplo n.º 19
0
        protected override void OnInit(EventArgs e)
        {
            try
            {
                base.OnInit(e);
                if (HttpContext.Current.Request.QueryString.Keys.Count != 2)
                {
                    this.ShowError(new IndException(ApplicationMessages.EXCEPTION_COULD_NOT_GET_CATALOGUE_CODE_PARAMETER));
                    return;
                }
                //The code parameter is always the first parameter
                string codeParam     = HttpContext.Current.Request.QueryString.Keys[0];
                string catalogueCode = HttpContext.Current.Request.QueryString[codeParam];
                string idParameter   = HttpContext.Current.Request.QueryString.Keys[1];
                string catalogueKey  = HttpContext.Current.Request.QueryString[idParameter];

                SessionManager.SetSessionValue((IndBasePage)this.Page, SessionStrings.EDIT_PARAMETERS, null);

                if (!String.IsNullOrEmpty(catalogueKey))
                {
                    CreateEditParameters(catalogueKey);
                }

                Control editControl = null;

                string editControlName = SessionManager.GetSessionValueRedirect(this, SessionStrings.EDIT_CONTROL).ToString();

                string ascxPath = ApplicationConstants.GetASCXPath(catalogueCode, ApplicationConstants.EDIT_ASCX_INDEX);

                editControl = Page.LoadControl(ascxPath);
                plhEditControl.Controls.Add(editControl);
            }
            catch (IndException ex)
            {
                ShowError(ex);
                return;
            }
            catch (Exception ex)
            {
                ShowError(new IndException(ex));
                return;
            }
        }
        void _renewMembershipView_RenewMembership(object sender, EventArgs e)
        {
            var member = _tempDataRepository.GetMemberValues();
            var nationalFitnessResultsDto = _nationalFitnessGateway.VerifyMember(member);

            if (!nationalFitnessResultsDto.IsVerified)
            {
                _renewMembershipView.Message = ApplicationConstants.NATIONAL_FITNESS_MEMBERSHIP_NOT_VERIFIED;
                return;
            }

            var isPaid = _ccProcessingGateway.PayDuesByMembershipId(member.GymMembershipId);

            if (!isPaid)
            {
                _renewMembershipView.Message = ApplicationConstants.CC_CHARGES_NOT_APPROVED;
                return;
            }

            _memberRepository.SaveMember(member);
            _renewMembershipView.Message = ApplicationConstants.FormatApprovalMessageForMember(member, isPaid);
        }
        public void RenewMembershipEvent_MemberInput_InstructsToGoToNextView()
        {
            // define out expectations (of how the Presenter will coordinate the interfaces
            _renewMembershipView.Initialize += null;
            LastCall.IgnoreArguments();
            _renewMembershipView.RenewMembership += null;
            var renewMembershipEvent = LastCall.IgnoreArguments().GetEventRaiser();

            const string firstName       = "Sally";
            const string lastName        = "Wong";
            const string gymMembershipId = "AB1234";
            var          member          = new Member {
                FirstName = firstName, LastName = lastName, GymMembershipId = gymMembershipId
            };

            Expect.Call(_tempDataRepository.GetMemberValues()).Return(member);

            var nationalFitnessResultsDto = new NationalFitnessResultsDTO {
                IsVerified = true
            };

            Expect.Call(_nationalFitnessGateway.VerifyMember(member)).Return(nationalFitnessResultsDto);

            const bool isPaid = true;

            Expect.Call(_ccProcessingGateway.PayDuesByMembershipId(member.GymMembershipId)).Return(isPaid);

            _memberRepository.SaveMember(member);

            _renewMembershipView.Message = ApplicationConstants.FormatApprovalMessageForMember(member, isPaid);
            _mockRepository.ReplayAll();

            var sut = new RenewMembershipPresenter(_tempDataRepository, _nationalFitnessGateway,
                                                   _ccProcessingGateway, _memberRepository, _renewMembershipView);

            renewMembershipEvent.Raise(_renewMembershipView, EventArgs.Empty);

            _mockRepository.VerifyAll();
        }
Exemplo n.º 22
0
 /// <summary>
 /// Create new Cie94Comparison for specific application type.
 /// </summary>
 /// <param name="application"></param>
 public Cie94Comparison(Application application)
 {
     Constants = new ApplicationConstants(application);
 }
Exemplo n.º 23
0
 /// <summary>
 /// Create new Cie94Comparison. Defaults to GraphicArts application type.
 /// </summary>
 public Cie94Comparison()
 {
     Constants = new ApplicationConstants(Application.GraphicArts);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Create new Cie94Comparison. Defaults to GraphicArts application type.
 /// </summary>
 public Cie94Comparison()
 {
     Constants = new ApplicationConstants(Application.GraphicArts);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Create new Cie94Comparison for specific application type.
 /// </summary>
 /// <param name="application"></param>
 public Cie94Comparison(Application application)
 {
     Constants = new ApplicationConstants(application);
 }
Exemplo n.º 26
0
        private void trySettings()
        {
            if (!m_SettingsDone && m_SettingsAggregator != null)
            {
                m_SettingsDone = true;

                m_Logger.Log(@"settings applied to Shell Window", Category.Debug, Priority.Medium);



                bool clickOnce = ApplicationDeployment.IsNetworkDeployed;
                if (!clickOnce && Settings.Default.EnableVersionChecking)
                {
                    string thisVersion = ApplicationConstants.GetVersion();

                    string url       = "http://data.daisy.org/projects/tobi/install/net-4/Tobi_NET4.application";
                    var    webClient = new WebClientWithTimeout {
                        UseDefaultCredentials = true, Timeout = 5 * 1000
                    };                                                                                             // 5 seconds
                    StreamReader streamReader = null;
                    try
                    {
                        streamReader = new StreamReader(webClient.OpenRead(url), Encoding.UTF8);
                        string xmlStr = streamReader.ReadToEnd();
                        //m_Logger.Log(str, Category.Info, Priority.High);

                        if (!string.IsNullOrEmpty(xmlStr))
                        {
                            int i = xmlStr.IndexOf(" version=", 20);
                            if (i > 0)
                            {
                                int k = i + 10;
                                int j = xmlStr.IndexOf("\"", k);
                                if (j > 0 && j > i)
                                {
                                    string latestVersion = xmlStr.Substring(k, j - k);

                                    int lastestVersionNumber = parseVersionNumber(latestVersion);
                                    int thisVersionNumber    = parseVersionNumber(thisVersion);

                                    if (lastestVersionNumber > thisVersionNumber &&
                                        Settings.Default.UpdateRejected != latestVersion)
                                    {
                                        bool update = askUserAppUpdate(thisVersion, latestVersion);
                                        if (update)
                                        {
                                            ExecuteShellProcess("http://daisy.org/tobi");
                                        }
                                        else
                                        {
                                            Settings.Default.UpdateRejected = latestVersion;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        m_Logger.Log(@"Problem checking Tobi latest version? " + ex.Message, Category.Exception, Priority.High);
                        //ExceptionHandler.LogException(ex);
#if DEBUG
                        Debugger.Break();
#endif // DEBUG
                    }
                    finally
                    {
                        if (streamReader != null)
                        {
                            streamReader.Close();
                        }
                    }
                }
            }
        }