Пример #1
0
        //Please write your properties and functions here. This part will not be replaced.

        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            //return base.onBeforeInsert(entitySet, parameters);
            try
            {
                if (FWUtils.WebUIUtils.IsLocalHost() == false)
                {
                    System.Text.StringBuilder body = new System.Text.StringBuilder();

                    string msg = FWUtils.EntityUtils.GetObjectFieldValueString(entitySet, vAppExceptionLog.ColumnNames.Message);

                    body.Append("StackTrace: ").Append(FWUtils.EntityUtils.GetObjectFieldValueString(entitySet, vAppExceptionLog.ColumnNames.StackTrace)).Append("\n");
                    //body.Append("Url: ").Append(FWUtils.EntityUtils.GetObjectFieldValueString(entitySet, vAppExceptionLog.ColumnNames.Url)).Append("\n");
                    //body.Append("UserID: ").Append(FWUtils.EntityUtils.GetObjectFieldValueString(entitySet, vAppExceptionLog.ColumnNames.UserID)).Append("\n");
                    //body.Append("DateTime: ").Append(DateTime.UtcNow).Append("\n");

                    body.Append("Complete Exception Info:").AppendLine();
                    body.AppendLine(FWUtils.EntityUtils.JsonSerializeObject(entitySet, false, null, true));

                    NotificationSystem.NotificationSenderAgent
                    .emailNotificationSender.SendEmailMessage("\"Xecare exception\" <*****@*****.**>", "*****@*****.**", "New Exception - " + msg, body.ToString(), false);
                }
            }
            catch (Exception)
            {
                // preventing recursive logging
                //FWUtils.ExpLogUtils.ExceptionLogger.LogError(ex, null);
            }
            return(true);
        }
Пример #2
0
        protected QueryableDataSourceEditData BuildInsertObject(IDictionary values, IDictionary <string, Exception> validationErrors)
        {
            QueryableDataSourceEditData editData = new QueryableDataSourceEditData();
            Type        dataObjectType           = EntityType;
            IDictionary caseInsensitiveNewValues = new OrderedDictionary(StringComparer.OrdinalIgnoreCase);

            if (!DataSourceHelper.MergeDictionaries(dataObjectType,
                                                    InsertParameters,
                                                    InsertParameters.GetValues(_context, _owner),
                                                    caseInsensitiveNewValues,
                                                    validationErrors))
            {
                return(editData);
            }

            if (!DataSourceHelper.MergeDictionaries(dataObjectType,
                                                    InsertParameters,
                                                    values,
                                                    caseInsensitiveNewValues, validationErrors))
            {
                return(editData);
            }

            editData.NewDataObject = DataSourceHelper.BuildDataObject(dataObjectType, caseInsensitiveNewValues, validationErrors);
            return(editData);
        }
Пример #3
0
        //Please write your properties and functions here. This part will not be replaced.


        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            Visit           visit = (Visit)entitySet;
            var             doctorScheduleService = DoctorScheduleEN.GetService("");
            vDoctorSchedule doctorScheduleV       = doctorScheduleService.GetByIDV(visit.DoctorScheduleID, new GetByIDParameters());

            ((VisitBR)BusinessLogicObject).CheckInsert(visit, doctorScheduleV);

            visit.VisitStatusID  = (int)EntityEnums.VisitStatusEnum.Scheduled;
            visit.DoctorReport   = null;
            visit.ChiefComplaint = null;
            visit.Description    = null;

            // updating doctor schedule number of registered patients
            DoctorSchedule doctorSchedule = doctorScheduleService.GetByIDT(visit.DoctorScheduleID, new GetByIDParameters());

            doctorSchedule.NumberOfRegisteredPatients++;

            parameters.DetailEntityObjects.Add(new DetailObjectInfo()
            {
                EntityName = vDoctorSchedule.EntityName,
                FnName     = RuleFunctionSEnum.Update,
                EntitySet  = doctorSchedule
            });

            return(true);
        }
Пример #4
0
        //Please write your properties and functions here. This part will not be replaced.

        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            //IUserService userService = (IUserService)EntityFactory.GetEntityServiceByName(User.EntityName, "");
            //User user = (User)userService.GetByID(((Person)entitySet).PersonID, new GetByIDParameters() { SourceType = GetSourceTypeEnum.Table });
            //user.UserApprovalStatusID = (int)EntityEnums.UserApprovalStatusEnum.WaitingForApproval;
            //parameters.DetailEntityObjects.Add(new DetailObjectInfo() { EntityName = User.EntityName, FnName = RuleFunctionSEnum.Update, EntitySet = user, AdditionalDataKey="" });
            return(true);
        }
 public async Task <ActionResult> Insert(int id, [FromBody] InsertParameters parameters)
 {
     return(await _telemetryCollector.WithStopwatch <ActionResult>(async() =>
     {
         if (await _service.Insert(id, parameters.Substring, parameters.Index))
         {
             return Ok();
         }
         return BadRequest();
     }));
 }
        protected override void onAfterInsert(object entitySet, InsertParameters parameters)
        {
            //to avoid db dependancy we send push right after the item inserted
            // TODO: re-write the code with database dependency
            // TODO: Cache all templates to avoid database request for each template

            var notification = (MobilePushNotification)entitySet;
            var template     = MobilePushTemplateEN.GetService("").GetByIDV(notification.MobilePushTemplateID, new GetByIDParameters());

            SendToSignalRClient(entitySet, notification, template);
            SendToMobilePushServers(notification, template);
        }
Пример #7
0
        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            VitalValue obj = (VitalValue)entitySet;

            if (this.AdditionalDataKey == VitalValueEN.AdditionalData_MyVital)
            {
                obj.PersonID = FWUtils.SecurityUtils.GetCurrentUserIDLong();
            }

            obj.RecordDateTime = DateTime.UtcNow;

            return(true);
        }
Пример #8
0
        /// <summary>
        /// Inserts the specified parameters.
        /// </summary>
        /// <param name="entitySet">The entity set.</param>
        /// <param name="parameters">The parameters.</param>
        /// <exception cref="BRException"></exception>
        public void Insert(object entitySet, InsertParameters parameters)
        {
            Check.Require(_IsInitialized, "The class is not initialized yet.");

            BusinessRuleErrorList errors = new BusinessRuleErrorList();

            CheckRules(entitySet, RuleFunctionSEnum.Insert, errors);

            CheckDetailEntityRules(parameters.DetailEntityObjects, errors);

            if (errors.Count > 0)
            {
                throw new BRException(errors);
            }

            this.DataAccessObject.Insert(entitySet, parameters);
        }
        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            TimeSeries_SmallInt_Seconds obj = (TimeSeries_SmallInt_Seconds)entitySet;

            if (this.AdditionalDataKey == VitalValueEN.AdditionalData_MyVital)
            {
                obj.UserID = FWUtils.SecurityUtils.GetCurrentUserIDLong();
            }

            // if only raw data was provided then compress it before insertion
            if (obj.RawString != null)
            {
                obj.TSValueBinary = CompressionUtils.SerializeAndCompress(obj.RawString);
            }

            obj.TSDateOffset = DateTimeEpoch.GetUtcNowEpoch();
            return(true);
        }
Пример #10
0
        /// <summary>
        /// Inserts the specified parameters.
        /// </summary>
        /// <param name="entitySet">The entity set.</param>
        /// <param name="parameters">The parameters.</param>
        public void Insert(object entitySet, InsertParameters parameters = null)
        {
            Check.Require(_IsInitialized, "The class is not initialized yet.");
            if (parameters == null)
            {
                parameters = new InsertParameters();
            }

            if (onBeforeInsert(entitySet, parameters))
            {
                foreach (EntitySecurityBase checker in this.SecurityCheckers)
                {
                    checker.Insert(entitySet, parameters);
                }

                BusinessLogicObject.Insert(entitySet, parameters);
                onAfterInsert(entitySet, parameters);
            }
        }
Пример #11
0
        protected override bool onBeforeInsert(object entitySet, InsertParameters parameters)
        {
            TimeSeriesStrip obj = (TimeSeriesStrip)entitySet;

            Guid stripId = Guid.NewGuid();

            if (obj.TimeSeriesStripID == Guid.Empty)
            {
                obj.TimeSeriesStripID = stripId;
            }

            obj.StartDateOffset = DateTimeEpoch.GetUtcNowEpoch();
            obj.EndDateOffset   = obj.StartDateOffset;

            if (this.AdditionalDataKey == VitalValueEN.AdditionalData_MyVital)
            {
                obj.UserID = FWUtils.SecurityUtils.GetCurrentUserIDLong();
            }

            return(true);
        }
Пример #12
0
 /// <summary>
 /// Inserts the specified entity set.
 /// </summary>
 /// <param name="entitySet">The entity set.</param>
 /// <param name="parameters">The parameters.</param>
 public void Insert(object entitySet, InsertParameters parameters)
 {
     SetEntityObjectAutomaticValueForInsert(entitySet);
     if (parameters.DetailEntityObjects == null ||
         parameters.DetailEntityObjects.Count == 0)
     {
         NHibernateSession.Save(entitySet);
         if (this.AutoSave)
         {
             SaveChanges();
         }
     }
     else
     {
         using (var tx = NHibernateSession.BeginTransaction())
         {
             NHibernateSession.Save(entitySet);
             AutoSetDetailFK((EntityObjectBase)entitySet, parameters.DetailEntityObjects);
             SaveDetailEntities(parameters.DetailEntityObjects);
             tx.Commit();
         }
         //SaveChanges(); no save is required.
     }
 }
Пример #13
0
 protected virtual void onAfterInsert(object entitySet, InsertParameters parameters)
 {
 }
Пример #14
0
 protected virtual bool onBeforeInsert(object entitySet, InsertParameters parameters)
 {
     return(true);
 }
Пример #15
0
 public abstract void Insert(object entitySet, InsertParameters parameters);
        //Please write your properties and functions here. This part will not be replaced.

        protected override void onAfterInsert(object entitySet, InsertParameters parameters)
        {
            var foodGroupId = (long)FWUtils.EntityUtils.GetObjectFieldValue(entitySet, vFoodGroupItem.ColumnNames.FoodGroupID);

            FoodGroupEN.GetService().UpdateDailyActivityByGroupID(foodGroupId);
        }
Пример #17
0
 /// <summary>
 /// Inserts the specified entity set.
 /// </summary>
 /// <param name="entitySet">The entity set.</param>
 /// <param name="parameters">The parameters.</param>
 public void InsertT(T entitySet, InsertParameters parameters = null)
 {
     Insert(entitySet, parameters);
 }
        public override void Insert(object entitySet, InsertParameters parameters)
        {
            string resourceCode = this.Entity.SecurityResourceCode + strDelimiter + SecurityFunctionSEnum.Insert;

            FWUtils.SecurityUtils.HasAccess(resourceCode, throwIfNoAccess: true);
        }
Пример #19
0
        //Please write your properties and functions here. This part will not be replaced.

        // Doctor selected a visit record, then CreatePaymentForVisit
        // Patient gets a notification to pay the amount
        // Patient selected payment method like Paypal (it uses UpdatePayPalKey to get Key from the bank)
        // Patient pays the money for the payment and
        //

        /// <summary>
        /// Precondition:
        /// Have Visit record in database with PaymentStatusID = NotStarted
        /// Steps:
        /// 1- Select a visit record (visitID) and enter amount and description required
        /// 2- CreatePaymentForVisit (PaymentStatusID = PendingWithoutPayKey)
        /// 3- UpdatePayPalKey (payment records in database PaymentStatusID = PendingWithPayKey)
        /// 4- PaymentReceived (PaymentStatusID = Done)
        /// </summary>
        public Payment CreatePaymentForVisit(PaymentCreatePaymentForVisitSP p)
        {
            PaymentBR biz = (PaymentBR)this.BusinessLogicObject;

            IVisitService visitService   = (IVisitService)EntityFactory.GetEntityServiceByName(vVisit.EntityName, "");
            vVisit        visit          = (vVisit)visitService.GetByID(p.VisitID, new GetByIDParameters(GetSourceTypeEnum.View));
            Visit         visitForUpdate = (Visit)visitService.GetByID(p.VisitID, new GetByIDParameters());

            biz.CreatePaymentForVisit(visit);


            Payment paymentForDoctor = new Payment();

            paymentForDoctor.SenderUserID           = visit.PatientUserID;
            paymentForDoctor.ReceiverUserID         = visit.DoctorID;
            paymentForDoctor.AppEntityID            = (int)EntityEnums.PaymentEntityEnum.Visit;
            paymentForDoctor.PaymentStatusID        = (int)EntityEnums.PaymentStatusEnum.PendingWithoutPayKey;
            paymentForDoctor.AppEntityRecordIDValue = visit.VisitID;
            paymentForDoctor.CreatedDateTime        = DateTime.UtcNow;
            paymentForDoctor.CompletedDateTime      = null;
            paymentForDoctor.PayKey = "";
            paymentForDoctor.Amount = p.Amount;
            paymentForDoctor.ServiceChargeAmount = p.ServiceChargeAmount;
            paymentForDoctor.PaymentMethodID     = (int)EntityEnums.PaymentMethodEnum.Undefined;
            paymentForDoctor.Description         = null;

            InsertParameters insertParameters = new InsertParameters();

            //visitForUpdate.PaymentStatusID = (int)EntityEnums.PaymentStatusEnum.PendingWithoutPayKey;
            DetailObjectInfo visitDetail = new DetailObjectInfo()
            {
                EntitySet              = visitForUpdate,
                EntityName             = vVisit.EntityName,
                AdditionalDataKey      = "",
                FnName                 = RuleFunctionSEnum.Update,
                FKColumnNameForAutoSet = ""
            };

            insertParameters.DetailEntityObjects.Add(visitDetail);


            // At this time, we just have one record for each visit.
            // We don't keep data for each receiver. So, it simplifies the problem.
            // ServiceChargeAmount is to show how much the user paid to us

            //Payment paymentForProvider = new Payment();
            //paymentForProvider.SenderUserID = visit.PatientUserID;
            //paymentForProvider.ReceiverUserID = visit.DoctorUserID;
            //paymentForProvider.PaymentEntityID = (int)EntityEnums.PaymentEntityEnum.Visit;
            //paymentForProvider.RelatedEntityRecordID = visit.VisitID;
            //paymentForProvider.CreatedDateTime = DateTime.UtcNow;
            //paymentForProvider.CompletedDateTime = null;
            //paymentForProvider.PayKey = "";
            //paymentForProvider.Amount = amount;
            //paymentForProvider.Description = null;

            //DetailObjectInfo companyPayment = new DetailObjectInfo() {
            //    EntitySet = paymentForProvider,
            //    EntityName = Payment.EntityName,
            //    AdditionalDataKey = this.AdditionalDataKey,
            //    FnName = RuleFunctionSEnum.Insert,
            //    FKColumnNameForAutoSet = "" };

            //insertParameters.DetailEntityObjects.Add(companyPayment);


            Insert(paymentForDoctor, insertParameters);
            return(paymentForDoctor);
        }