Exemplo n.º 1
0
        private void UserPreferences_Cliked(object sender, RoutedEventArgs e)
        {
            try
            {
                UserPreference userPreferences = GlobalResources.UserPreferences.CopyToObject(new UserPreference()).To <UserPreference>();

                userPreferences.PropertyChanged += this.UserPreference_Changed;

                if (ModelView.ShowDialog("User Preferences", userPreferences).IsFalse())
                {
                    // Do this to reset the Font values
                    userPreferences = GlobalResources.UserPreferences.CopyToObject(new UserPreference()).To <UserPreference>();

                    return;
                }

                UserPreferenceModel updatePreference = userPreferences.CopyToObject(new UserPreferenceModel()).To <UserPreferenceModel>();

                BiblesData.Database.InsertPreference(updatePreference);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Controller function to zip log file for the selected date passed as parameter
        /// </summary>
        /// <param name="logDate">Log Date</param>
        /// <returns>String (name of zip file)</returns>
        public JsonResult DownloadServerLog(DateTime?logDate)
        {
            Ctx ct = Session["ctx"] as Ctx;
            UserPreferenceModel model = new UserPreferenceModel();

            return(Json(model.DownloadServerLog(logDate), JsonRequestBehavior.AllowGet));
        }
        private IActionResult CreateUserPreference(UserPreferenceModel userPref)
        {
            // Setup
            Mock <IHttpContextAccessor> httpContextAccessorMock = CreateValidHttpContext(token, userId, hdid);

            Mock <IUserProfileService>          userProfileServiceMock = new Mock <IUserProfileService>();
            RequestResult <UserPreferenceModel> result = new RequestResult <UserPreferenceModel>()
            {
                ResourcePayload = userPref,
                ResultStatus    = ResultType.Success,
            };

            userProfileServiceMock.Setup(s => s.CreateUserPreference(userPref)).Returns(result);

            Mock <IUserEmailService> emailServiceMock = new Mock <IUserEmailService>();
            Mock <IUserSMSService>   smsServiceMock   = new Mock <IUserSMSService>();

            UserProfileController service = new UserProfileController(
                new Mock <ILogger <UserProfileController> >().Object,
                userProfileServiceMock.Object,
                httpContextAccessorMock.Object,
                emailServiceMock.Object,
                smsServiceMock.Object
                );

            return(service.CreateUserPreference(hdid, userPref));
        }
Exemplo n.º 4
0
        // Added by Bharat on 12 June 2017
        public JsonResult GetWindowID(string WindowName)
        {
            Ctx ct = Session["ctx"] as Ctx;
            UserPreferenceModel model = new UserPreferenceModel();

            return(Json(JsonConvert.SerializeObject(model.GetWindowID(WindowName)), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        private void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            try
            {
                UserPreferenceModel preference = GlobalResources.UserPreferences;

                this.SetFont(preference.Font);

                this.SetFontSize(preference.FontSize);

                string biblesKey = ((Reader.Reader) this.uxMainTab.Items[0]).SelectedVerseKey;

                if (!Formatters.IsBiblesKey(biblesKey))
                {
                    int biblesId = ((Reader.Reader) this.uxMainTab.Items[0]).Bible.BibleId;

                    biblesKey = Formatters.ChangeBible(biblesKey, biblesId);
                }

                preference.LastReadVerse = biblesKey;

                BiblesData.Database.InsertPreference(preference);
            }
            catch (Exception err)
            {
                // DO NOTHING
            }
        }
Exemplo n.º 6
0
        public int InsertPreference(UserPreferenceModel userPreference)
        {
            Task <UserPreferenceModel> existing = BiblesData.database.Table <UserPreferenceModel>().FirstOrDefaultAsync();

            if (existing.Result == null)
            {
                Task <int> newResult = BiblesData.database.InsertAsync(userPreference);

                int newResultValue = newResult.Result;

                return(userPreference.UserId);
            }

            existing.Result.DefaultBible = userPreference.DefaultBible;

            existing.Result.LanguageId = userPreference.LanguageId;

            existing.Result.SynchronizzeTabs = userPreference.SynchronizzeTabs;

            existing.Result.Font = userPreference.Font;

            existing.Result.FontSize = userPreference.FontSize;

            existing.Result.LastReadVerse = userPreference.LastReadVerse;

            BiblesData.database.UpdateAsync(existing.Result);

            return(existing.Result.UserId);
        }
Exemplo n.º 7
0
        public Task Set(UserPreferenceModel userPreference)
        {
            return
                (Task.Factory.StartNew(
                     () => {
                // Get old data
                var entity = this._Database.Table <UserPreference>().FirstOrDefaultAsync().Result;

                // Clear table
                if (entity == null)
                {
                    this._Database.InsertAsync(
                        this._Mapper.Map <UserPreferenceModel, UserPreference>(userPreference)
                        )
                    .Wait();
                }
                else
                {
                    entity.ExtUpdate(
                        this._Mapper.Map <UserPreferenceModel, UserPreference>(userPreference)
                        );

                    this._Database.UpdateAsync(entity)
                    .Wait();
                }
            }
                     ));
        }
Exemplo n.º 8
0
        public App()
        {
            UserPreferenceModel preference = GlobalResources.UserPreferences;

            if (preference != null && preference.LanguageId > 0)
            {
                this.LoadTranslationsDictionary(preference.LanguageId);
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// save prefrences into database
 /// </summary>
 /// <param name="pref"></param>
 /// <returns></returns>
 public JsonResult SavePrefrence(Dictionary <string, object> pref)
 {
     if (Session["Ctx"] != null)
     {
         var ctx = Session["ctx"] as Ctx;
         UserPreferenceModel obj = new UserPreferenceModel();
         obj.SavePrefrence(ctx, pref);
     }
     return(Json(new { result = "ok" }, JsonRequestBehavior.AllowGet));
 }
        public void ShouldUpdateUserPreferenceWithForbidResultError()
        {
            var userPref = new UserPreferenceModel()
            {
                HdId       = hdid + "dif.",
                Preference = "valid pref name",
                Value      = "Body value",
            };
            IActionResult actualResult = UpdateUserPreference(userPref);

            Assert.IsType <ForbidResult>(actualResult);
        }
        public void ShouldUpdateUserPreferenceWithEmtptyReferenceNameError()
        {
            var userPref = new UserPreferenceModel()
            {
                HdId       = hdid,
                Preference = null,
                Value      = "Body value",
            };
            IActionResult actualResult = UpdateUserPreference(userPref);

            Assert.IsType <BadRequestResult>(actualResult);
        }
Exemplo n.º 12
0
 /// <summary>
 /// save User settings into database
 /// </summary>
 /// <param name="pref"></param>
 /// <returns></returns>
 public JsonResult SaveUserSettings(int AD_User_ID, string currentPws, string newPws, bool chkEmail, bool chkNotice,
                                    bool chkSMS, bool chkFax, string emailUserName, string emailPws, int AD_Role_ID, int AD_Client_ID, int AD_Org_ID, int M_Warehouse_ID)
 {
     if (Session["Ctx"] != null)
     {
         var ctx = Session["ctx"] as Ctx;
         UserPreferenceModel obj = new UserPreferenceModel();
         var val = obj.SaveUserSettings(ctx, AD_User_ID, currentPws, newPws, chkEmail, chkNotice, chkSMS, chkFax, emailUserName, emailPws, AD_Role_ID, AD_Client_ID, AD_Org_ID, M_Warehouse_ID);
         return(Json(new { result = val }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { result = "ok" }, JsonRequestBehavior.AllowGet));
 }
Exemplo n.º 13
0
        public IActionResult CreateUserPreference(string hdid, [FromBody] UserPreferenceModel userPreferenceModel)
        {
            if (userPreferenceModel == null)
            {
                return(new BadRequestResult());
            }

            userPreferenceModel.HdId      = hdid;
            userPreferenceModel.CreatedBy = hdid;
            userPreferenceModel.UpdatedBy = hdid;
            RequestResult <UserPreferenceModel> result = this.userProfileService.CreateUserPreference(userPreferenceModel);

            return(new JsonResult(result));
        }
        ////
        //// GET: /VIS/UserPreference/
        //[HttpGet]
        //[AllowAnonymous]
        public ActionResult Index(string windowno, string adUserId)
        {
            ViewBag.WindowNumber = windowno;

            UserPreferenceModel obj = new UserPreferenceModel();

            if (Session["Ctx"] != null)
            {
                var ctx = Session["ctx"] as Ctx;
                obj          = obj.GetUserSettings(ctx, Convert.ToInt32(adUserId));
                ViewBag.lang = ctx.GetAD_Language();
            }

            return(PartialView(obj));
        }
Exemplo n.º 15
0
        public JsonResult GetSavedDetail(bool isTask)
        {
            string retJSON = "";
            Ctx    ctx     = null;

            if (Session["Ctx"] != null)
            {
                ctx = Session["ctx"] as Ctx;
            }

            UserPreferenceModel objUPModel = new UserPreferenceModel();

            retJSON = JsonConvert.SerializeObject(objUPModel.GetSavedDetail(ctx, isTask));
            return(Json(retJSON, JsonRequestBehavior.AllowGet));
        }
        public void ShouldUpdateUserPreference()
        {
            var userPref = new UserPreferenceModel()
            {
                HdId       = hdid,
                Preference = "actionedCovidModalAt",
                Value      = "Body value",
            };
            IActionResult actualResult = UpdateUserPreference(userPref);

            Assert.IsType <JsonResult>(actualResult);
            RequestResult <UserPreferenceModel> reqResult = ((JsonResult)actualResult).Value as RequestResult <UserPreferenceModel>;

            Assert.NotNull(reqResult);
            Assert.Equal(ResultType.Success, reqResult.ResultStatus);
        }
Exemplo n.º 17
0
        public IActionResult UpdateUserPreference(string hdid, [FromBody] UserPreferenceModel userPreferenceModel)
        {
            if (userPreferenceModel == null || string.IsNullOrEmpty(userPreferenceModel.Preference))
            {
                return(new BadRequestResult());
            }

            if (userPreferenceModel.HdId != hdid)
            {
                return(new ForbidResult());
            }

            userPreferenceModel.UpdatedBy = hdid;
            RequestResult <UserPreferenceModel> result = this.userProfileService.UpdateUserPreference(userPreferenceModel);

            return(new JsonResult(result));
        }
        private void InitialDataLoad_Completed(object sender, string message, bool completed, Exception error)
        {
            try
            {
                if (error != null)
                {
                    throw error;
                }

                if (completed)
                {
                    this.uxMessageLable.Content = string.Empty;

                    this.InitializeTabs();

                    this.LoadDynamicMenus();

                    UserPreferenceModel preference = GlobalResources.UserPreferences;

                    this.SetFont(preference.Font);

                    this.SetFontSize(preference.FontSize);

                    this.selectedItemKey = GlobalResources.UserPreferences.LastReadVerse;

                    int bibleId = !this.selectedItemKey.IsNullEmptyOrWhiteSpace() && Formatters.IsBiblesKey(this.selectedItemKey) ?
                                  Formatters.GetBibleFromKey(this.selectedItemKey)
                        :
                                  GlobalResources.UserPreferences.DefaultBible;

                    int verseNumber = Formatters.GetVerseFromKey(this.selectedItemKey);

                    ((Reader.Reader) this.uxMainTab.Items[0]).SetBible(bibleId);

                    this.uxIndexer.SetVerse(this.selectedItemKey);
                }
                else
                {
                    this.uxMessageLable.Content = message;
                }
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
Exemplo n.º 19
0
        ////
        //// GET: /VIS/UserPreference/
        //[HttpGet]
        //[AllowAnonymous]
        public ActionResult Index(string windowno, string adUserId)
        {
            ViewBag.WindowNumber = windowno;

            UserPreferenceModel obj = new UserPreferenceModel();

            if (Session["Ctx"] != null)
            {
                var ctx = Session["ctx"] as Ctx;
                obj             = obj.GetUserSettings(ctx, Convert.ToInt32(adUserId));
                ViewBag.lang    = ctx.GetAD_Language();
                ViewBag.IsAdmin = ctx.GetAD_Role_ID() == 0 && (ctx.GetAD_User_ID() == 100 || ctx.GetAD_User_ID() == 0) &&
                                  Util.GetValueOfInt(ctx.GetContext("#FRAMEWORK_VERSION")) > 1;
            }

            return(PartialView(obj));
        }
        private RequestResult <UserPreferenceModel> ExecuteUpdateUserPreference(Database.Constants.DBStatusCode dbResultStatus = Database.Constants.DBStatusCode.Updated)
        {
            UserPreferenceModel userPreferenceModel = new UserPreferenceModel
            {
                HdId       = hdid,
                Preference = "TutorialPopover",
                Value      = "mocked value",
            };
            DBResult <UserPreference> readResult = new DBResult <UserPreference>
            {
                Payload = userPreferenceModel.ToDbModel(),
                Status  = dbResultStatus
            };
            Mock <IUserPreferenceDelegate> preferenceDelegateMock = new Mock <IUserPreferenceDelegate>();

            preferenceDelegateMock.Setup(s => s.UpdateUserPreference(It.IsAny <UserPreference>(), It.IsAny <bool>())).Returns(readResult);

            Mock <IEmailQueueService>             emailer                 = new Mock <IEmailQueueService>();
            Mock <IUserProfileDelegate>           profileDelegateMock     = new Mock <IUserProfileDelegate>();
            Mock <IEmailDelegate>                 emailDelegateMock       = new Mock <IEmailDelegate>();
            Mock <IMessagingVerificationDelegate> emailInviteDelegateMock = new Mock <IMessagingVerificationDelegate>();
            Mock <IConfigurationService>          configServiceMock       = new Mock <IConfigurationService>();

            Mock <ILegalAgreementDelegate>        legalAgreementDelegateMock      = new Mock <ILegalAgreementDelegate>();
            Mock <ICryptoDelegate>                cryptoDelegateMock              = new Mock <ICryptoDelegate>();
            Mock <INotificationSettingsService>   notificationServiceMock         = new Mock <INotificationSettingsService>();
            Mock <IMessagingVerificationDelegate> messageVerificationDelegateMock = new Mock <IMessagingVerificationDelegate>();

            IUserProfileService service = new UserProfileService(
                new Mock <ILogger <UserProfileService> >().Object,
                new Mock <IPatientService>().Object,
                new Mock <IUserEmailService>().Object,
                new Mock <IUserSMSService>().Object,
                configServiceMock.Object,
                new Mock <IEmailQueueService>().Object,
                notificationServiceMock.Object,
                profileDelegateMock.Object,
                preferenceDelegateMock.Object,
                new Mock <ILegalAgreementDelegate>().Object,
                messageVerificationDelegateMock.Object,
                cryptoDelegateMock.Object,
                new Mock <IHttpContextAccessor>().Object);

            return(service.UpdateUserPreference(userPreferenceModel));
        }
Exemplo n.º 21
0
        /// <inheritdoc />
        public RequestResult <Dictionary <string, UserPreferenceModel> > GetUserPreferences(string hdid)
        {
            this.logger.LogTrace($"Getting user preference... {hdid}");
            DBResult <IEnumerable <UserPreference> > dbResult = this.userPreferenceDelegate.GetUserPreferences(hdid);
            RequestResult <Dictionary <string, UserPreferenceModel> > requestResult = new RequestResult <Dictionary <string, UserPreferenceModel> >()
            {
                ResourcePayload = UserPreferenceModel.CreateListFromDbModel(dbResult.Payload).ToDictionary(x => x.Preference, x => x),
                ResultStatus    = dbResult.Status == DBStatusCode.Read ? ResultType.Success : ResultType.Error,
                ResultError     = dbResult.Status == DBStatusCode.Read ? null : new RequestResultError()
                {
                    ResultMessage = dbResult.Message,
                    ErrorCode     = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database),
                },
            };

            this.logger.LogTrace($"Finished getting user preference. {JsonSerializer.Serialize(dbResult)}");
            return(requestResult);
        }
        public string GetUserPreference(string user)
        {
            UserPreferenceModel usrPreference = null;
            string connectionString = "type=embedded;storesdirectory=" + Constants.StoreLocation + ";storename=Users";
            var client = BrightstarService.GetClient(connectionString);

            using (var ctx = new MyEntityContext(connectionString))
            {
                var currentUser = ctx.Users.FirstOrDefault(x => x.Email == user);
                if (currentUser != null && currentUser.UserPreference != null)
                {
                    List<IInterest> listIInterests = currentUser.UserPreference.Interests.ToList<IInterest>();
                    List<Interest> listInterest = listIInterests.ConvertAll(obj => (Interest)obj);
                    listInterest.Sort(delegate(Interest interest1, Interest interest2) { return interest1.Name.CompareTo(interest2.Name); });
                    ICollection<Interest> interestsCollection = listInterest;

                    listIInterests = currentUser.UserPreference.Cuisine.ToList<IInterest>();
                    listInterest = listIInterests.ConvertAll(obj => (Interest)obj);
                    listInterest.Sort(delegate(Interest interest1, Interest interest2) { return interest1.Name.CompareTo(interest2.Name); });
                    ICollection<Interest> cuisineCollection = listInterest;

                    usrPreference = new UserPreferenceModel()
                    {
                        NeedWheelchair = currentUser.UserPreference.NeedWheelchair,
                        Cuisine = cuisineCollection,
                        Interests = interestsCollection,
                    };
                }
                var json = JsonConvert.SerializeObject(usrPreference,
                                    Formatting.None,
                                        new JsonSerializerSettings()
                                        {
                                            ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore
                                        });

                return json;
            }
        }
Exemplo n.º 23
0
        /// <inheritdoc />
        public RequestResult <UserPreferenceModel> CreateUserPreference(UserPreferenceModel userPreferenceModel)
        {
            this.logger.LogTrace($"Creating user preference... {userPreferenceModel.Preference}");

            UserPreference userPreference = userPreferenceModel.ToDbModel();

            DBResult <UserPreference> dbResult = this.userPreferenceDelegate.CreateUserPreference(userPreference);

            this.logger.LogDebug($"Finished creating user preference. {JsonSerializer.Serialize(dbResult)}");

            RequestResult <UserPreferenceModel> requestResult = new RequestResult <UserPreferenceModel>()
            {
                ResourcePayload = UserPreferenceModel.CreateFromDbModel(dbResult.Payload),
                ResultStatus    = dbResult.Status == DBStatusCode.Created ? ResultType.Success : ResultType.Error,
                ResultError     = dbResult.Status == DBStatusCode.Created ? null : new RequestResultError()
                {
                    ResultMessage = dbResult.Message,
                    ErrorCode     = ErrorTranslator.ServiceError(ErrorType.CommunicationInternal, ServiceType.Database),
                },
            };

            return(requestResult);
        }
        private Tuple <RequestResult <Dictionary <string, UserPreferenceModel> >, List <UserPreferenceModel> > ExecuteGetUserPreference(Database.Constants.DBStatusCode dbResultStatus = Database.Constants.DBStatusCode.Read)
        {
            UserProfile userProfile = new UserProfile
            {
                HdId = hdid,
                AcceptedTermsOfService = true,
            };

            DBResult <UserProfile> userProfileDBResult = new DBResult <UserProfile>
            {
                Payload = userProfile,
                Status  = dbResultStatus
            };

            UserProfileModel expected = UserProfileModel.CreateFromDbModel(userProfile);

            LegalAgreement termsOfService = new LegalAgreement()
            {
                Id            = Guid.NewGuid(),
                LegalText     = "",
                EffectiveDate = DateTime.Now
            };

            Mock <IEmailQueueService>   emailer             = new Mock <IEmailQueueService>();
            Mock <IUserProfileDelegate> profileDelegateMock = new Mock <IUserProfileDelegate>();

            profileDelegateMock.Setup(s => s.GetUserProfile(hdid)).Returns(userProfileDBResult);
            profileDelegateMock.Setup(s => s.Update(userProfile, true)).Returns(userProfileDBResult);

            UserPreferenceModel userPreferenceModel = new UserPreferenceModel
            {
                HdId       = hdid,
                Preference = "TutorialPopover",
                Value      = true.ToString(),
            };

            List <UserPreferenceModel> userPreferences = new List <UserPreferenceModel>();

            userPreferences.Add(userPreferenceModel);

            List <UserPreference> dbUserPreferences = new List <UserPreference>();

            dbUserPreferences.Add(userPreferenceModel.ToDbModel());

            DBResult <IEnumerable <UserPreference> > readResult = new DBResult <IEnumerable <UserPreference> >
            {
                Payload = dbUserPreferences,
                Status  = dbResultStatus
            };
            Mock <IUserPreferenceDelegate> preferenceDelegateMock = new Mock <IUserPreferenceDelegate>();

            preferenceDelegateMock.Setup(s => s.GetUserPreferences(hdid)).Returns(readResult);

            Mock <IEmailDelegate> emailDelegateMock = new Mock <IEmailDelegate>();
            Mock <IMessagingVerificationDelegate> emailInviteDelegateMock = new Mock <IMessagingVerificationDelegate>();

            emailInviteDelegateMock.Setup(s => s.GetLastByInviteKey(It.IsAny <Guid>())).Returns(new MessagingVerification());

            Mock <IConfigurationService> configServiceMock = new Mock <IConfigurationService>();

            configServiceMock.Setup(s => s.GetConfiguration()).Returns(new ExternalConfiguration());

            Mock <ILegalAgreementDelegate> legalAgreementDelegateMock = new Mock <ILegalAgreementDelegate>();

            legalAgreementDelegateMock
            .Setup(s => s.GetActiveByAgreementType(LegalAgreementType.TermsofService))
            .Returns(new DBResult <LegalAgreement>()
            {
                Payload = termsOfService
            });

            Mock <ICryptoDelegate> cryptoDelegateMock = new Mock <ICryptoDelegate>();
            Mock <INotificationSettingsService>   notificationServiceMock         = new Mock <INotificationSettingsService>();
            Mock <IMessagingVerificationDelegate> messageVerificationDelegateMock = new Mock <IMessagingVerificationDelegate>();

            IUserProfileService service = new UserProfileService(
                new Mock <ILogger <UserProfileService> >().Object,
                new Mock <IPatientService>().Object,
                new Mock <IUserEmailService>().Object,
                new Mock <IUserSMSService>().Object,
                configServiceMock.Object,
                new Mock <IEmailQueueService>().Object,
                notificationServiceMock.Object,
                profileDelegateMock.Object,
                preferenceDelegateMock.Object,
                new Mock <ILegalAgreementDelegate>().Object,
                messageVerificationDelegateMock.Object,
                cryptoDelegateMock.Object,
                new Mock <IHttpContextAccessor>().Object);

            RequestResult <Dictionary <string, UserPreferenceModel> > actualResult = service.GetUserPreferences(hdid);

            return(new Tuple <RequestResult <Dictionary <string, UserPreferenceModel> >, List <UserPreferenceModel> >(actualResult, userPreferences));
        }
Exemplo n.º 25
0
 public void UpdateUserPreference(UserPreferenceModel preference)
 {
     _cache.Set(preference.UserName, preference);
 }
 public Task Set(UserPreferenceModel userPreference)
 {
     return(this._Repository.Set(userPreference));
 }
Exemplo n.º 27
0
        public ActionResult UpdateUserPreference(UserPreferenceModel userPreference)
        {
            var response = _userService.Register(userPreference, typeof(UserPreferenceModel).Name) as UserModelResponse;

            return(Ok(APIResponse.CreateResponse(_jwtAuthentication.Value, _httpContextAccessor.HttpContext.Request, response)));
        }
Exemplo n.º 28
0
        public JsonResult GetDefaultLogin(int AD_User_ID)
        {
            UserPreferenceModel objUPModel = new UserPreferenceModel();

            return(Json(JsonConvert.SerializeObject(objUPModel.GetDefaultLogin(AD_User_ID)), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 29
0
        public JsonResult GetLoginData(string sql)
        {
            UserPreferenceModel objUPModel = new UserPreferenceModel();

            return(Json(JsonConvert.SerializeObject(objUPModel.GetLoginData(sql)), JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 30
0
        public JsonResult SaveGmailAccountSettings(string authCodes, bool isTask, bool isSyncInBackground, bool isRemoveLink, bool isContact)
        {
            string scope = string.Empty;

            if (isTask)
            {
                scope = "https://www.googleapis.com/auth/tasks";
            }
            else if (isContact)
            {
                scope = "https://www.googleapis.com/auth/contacts.readonly";
            }
            else
            {
                scope = "https://www.googleapis.com/auth/calendar";
            }
            string message = string.Empty;
            Ctx    ctx     = null;

            string retJSON = "";

            if (Session["Ctx"] != null)
            {
                ctx = Session["ctx"] as Ctx;
            }

            if (authCodes == "")
            {
                OAuth2Parameters parameters = new OAuth2Parameters()
                {
                    //Client
                    ClientId     = ClientCredentials.ClientID,
                    ClientSecret = ClientCredentials.ClientSecret,
                    RedirectUri  = "urn:ietf:wg:oauth:2.0:oob",
                    //Scope = "https://www.googleapis.com/auth/tasks",
                    Scope = scope,
                };

                //User clicks this auth url and will then be sent to your redirect url with a code parameter
                var authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
                retJSON = JsonConvert.SerializeObject(authorizationUrl);
                return(Json(retJSON, JsonRequestBehavior.AllowGet));
            }


            int AD_User_ID   = ctx.GetAD_User_ID();
            int AD_Client_ID = ctx.GetAD_Client_ID();
            int AD_Org_ID    = ctx.GetAD_Org_ID();

            if (isRemoveLink)
            {
                UserPreferenceModel objUPModel1 = new UserPreferenceModel();
                message = objUPModel1.Action(ctx, isSyncInBackground, isTask, authCodes, isRemoveLink);
                retJSON = JsonConvert.SerializeObject(message);
                return(Json(retJSON, JsonRequestBehavior.AllowGet));
            }
            GmailConfig objGmailConfig = new GmailConfig(AD_User_ID, AD_Client_ID, AD_Org_ID, authCodes, isTask, isContact);

            message = objGmailConfig.Start(ctx);
            if (message.Contains("error"))
            {
                return(Json("false", JsonRequestBehavior.AllowGet));
            }
            UserPreferenceModel objUPModel = new UserPreferenceModel();

            message = objUPModel.Action(ctx, isSyncInBackground, isTask, authCodes, isRemoveLink);
            retJSON = JsonConvert.SerializeObject(message);
            return(Json(retJSON, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 31
0
        public async void LoadEmbeddedBibles(Dispatcher dispatcher, FontFamily defaultFont)
        {
            Task <List <BibleModel> > loadedBiles = BiblesData.Database.GetBibles();

            await Task.Run(() =>
            {
                try
                {
                    #region LOAD BIBLES

                    if (loadedBiles.Result.Count == 0)
                    {
                        foreach (string bible in bibleNames)
                        {
                            dispatcher.Invoke(() =>
                            {
                                this.InitialDataLoadCompleted?.Invoke(this, $"Loading...{bible}", false, null);
                            });

                            BibleModel bibleModel = loadedBiles.Result.FirstOrDefault(l => l.BibleName == bible);

                            if (bibleModel == null)
                            {
                                bibleModel = new BibleModel
                                {
                                    BiblesId  = 0,
                                    BibleName = bible
                                };

                                BiblesData.Database.InsertBible(bibleModel);

                                BibleModel added = BiblesData.Database.GetBible(bible);

                                while (added == null)
                                {
                                    Sleep.ThreadWait(100);

                                    added = BiblesData.Database.GetBible(bible);
                                }

                                bibleModel.BiblesId = added.BiblesId;
                            }

                            this.LoadBibleVerses(dispatcher, bibleModel);

                            if (bible == this.systemDefaultbible)
                            {
                                UserPreferenceModel userPref = new UserPreferenceModel
                                {
                                    DefaultBible     = bibleModel.BiblesId,
                                    Font             = defaultFont.ParseToString(),
                                    FontSize         = 12,
                                    SynchronizzeTabs = false,
                                    LanguageId       = 0,
                                    LastReadVerse    = $"{bibleModel.BiblesId}||01O||1||1||"
                                };

                                BiblesData.Database.InsertPreference(userPref);
                            }
                        }
                    }

                    #endregion

                    this.LoadStrongsConcordance(dispatcher);
                }
                catch (Exception err)
                {
                    dispatcher.Invoke(() =>
                    {
                        this.InitialDataLoadCompleted?.Invoke(this, string.Empty, false, err);
                    });
                }

                dispatcher.Invoke(() =>
                {
                    this.InitialDataLoadCompleted?.Invoke(this, string.Empty, true, null);
                });
            });
        }