示例#1
0
        public Mesh GetMesh(TimeValue t)
        {
            if (_Object.CanConvertToType(ClassID.TriObject._IClass_ID) == 0)
            {
                return(null);
            }

            ITriObject tri = _Object.ConvertToType(t, ClassID.TriObject._IClass_ID) as ITriObject;

            if (tri == null)
            {
                return(null);
            }

            Mesh r = new Mesh(tri.Mesh);

            if (tri.Handle != _Object.Handle)
            {
                RefResult rr = tri.MaybeAutoDelete();
                if (rr == RefResult.Fail)
                {
                    throw new Exception("Failed to autodelete the tri-object");
                }
            }

            return(r);
        }
示例#2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the Scripture reference for this footnote.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void UpdateFootnoteRef()
        {
            IScrBook owningBook = OwnerOfClass <IScrBook>();

            if (owningBook == null)
            {
                throw new InvalidOperationException("Can not calculate footnote reference until footnote is inserted");
            }

            if (ParaContainingOrcRA == null)
            {
                return;                 // Would be better to throw an exception, but will happen in tests
            }
            BCVRef startRef = new BCVRef(owningBook.CanonicalNum, 0, 0);
            BCVRef endRef   = new BCVRef(owningBook.CanonicalNum, 0, 0);

            IScrSection owningSection = ParaContainingOrcRA.OwnerOfClass <IScrSection>();

            if (owningSection != null && BCVRef.GetChapterFromBcv(owningSection.VerseRefStart) ==
                BCVRef.GetChapterFromBcv(owningSection.VerseRefEnd))
            {
                // Section only contains one chapter, so we know which chapter to use
                startRef.Chapter = endRef.Chapter = BCVRef.GetChapterFromBcv(owningSection.VerseRefStart);
            }

            IStText owningText = (IStText)ParaContainingOrcRA.Owner;

            for (int iPara = owningText.ParagraphsOS.IndexOf(ParaContainingOrcRA); iPara >= 0; iPara--)
            {
                IScrTxtPara para   = (IScrTxtPara)owningText[iPara];
                RefResult   result = GetReference(owningBook, para, startRef, endRef);

                if (result == RefResult.ScannedAllFootnotes)
                {
                    return;                     // no need to finish since full scan updated my reference
                }
                if (result == RefResult.Found)
                {
                    break;
                }
            }

            if (owningSection != null)
            {
                if (startRef.Verse == 0)
                {
                    startRef.Verse = endRef.Verse = new BCVRef(owningSection.VerseRefStart).Verse;
                }

                if (startRef.Chapter == 0)
                {
                    startRef.Chapter = endRef.Chapter = new BCVRef(owningSection.VerseRefStart).Chapter;
                }
            }

            FootnoteRefInfo = new RefRange(startRef, endRef);
        }
示例#3
0
        public static int DoLogin(ref LoginAttempt loginAttempt, KoloAndroidEntities db, out string error)
        {
            error = "";
            var refResult = new RefResult()
            {
                ResultCode = "FAIL"
            };
            var loginTime  = DateTime.Now;
            var idCustomer = loginAttempt.IdCustomer;
            var customer   = db.Customers
                             .Include("MobileDevices").Include("Person").Include("Registration")
                             .FirstOrDefault(c => c.IdCustomer == idCustomer);

            if (customer != null)
            {
                var customerLogin = db.CustomerLogins.FirstOrDefault(c => c.IdCustomer == customer.IdCustomer);
                loginAttempt.LoginTime = loginTime;
                if (customerLogin != null)
                {
                    var mobile = db.MobileDevices.FirstOrDefault(md => md.IdMobileDevice == customer.IdCustomer);
                    if (MobileDeviceHelper.SameMobileIds(mobile, loginAttempt) == true)
                    {
                        if (PasswordHasher.VerifyPassword(loginAttempt, customerLogin))
                        {
                            loginAttempt.ResultCode = "SUCCESS";
                            loginAttempt.IdCustomer = customer.IdCustomer;
                            db.LoginAttempts.Add(loginAttempt);
                            try
                            {
                                db.SaveChanges();
                                refResult.ResultCode = "SUCCESS";
                                return(loginAttempt.IdLoginAttempt);
                            }
                            catch (Exception ex)
                            {
                                error = ExceptionHelper.GetExceptionMessage(ex);
                            }
                        }
                    }
                }
            }
            using (KoloAndroidEntities dbFail = new KoloAndroidEntities())
            {
                LoginAttempt la = new LoginAttempt()
                {
                    ResultCode = "FAIL",
                };
                dbFail.LoginAttempts.Add(la);
                dbFail.SaveChanges();
            }
            return(loginAttempt.IdLoginAttempt);
        }