Example #1
0
        internal static ChangeLogEntity GetChangeLogEntity(ChangeLogModel changeModel)
        {
            var userId    = GetUserId();
            var userEmail = GetUserEmail();

            if (userId == DefaultUnknownUser)
            {
                //insightsTracker.TrackEvent(
                //    "UserIdNotFound",
                //    new Dictionary<string, string>
                //        {
                //            { nameof(ChangeLogEntity.UserId), "Unknown" },
                //            { nameof(ChangeLogEntity.UserEmail), userEmail },
                //            { nameof(ChangeLogEntity.Context), changeModel.Context },
                //            { nameof(ChangeLogEntity.TableName), changeModel.TableName },
                //            { nameof(ChangeLogEntity.Type), changeModel.Type }
                //        });
            }

            var changeLogEntity = new ChangeLogEntity
            {
                ChangeData       = changeModel.ChangeData,
                Context          = changeModel.Context,
                ItemId           = changeModel.ItemId,
                TableName        = changeModel.TableName,
                Type             = changeModel.Type,
                UserEmail        = userEmail,
                UserId           = userId,
                ChangedDataType  = changeModel.ChangedDataType,
                ItemPartitionKey = changeModel.ItemPartitionKey,
                ItemRowKey       = changeModel.ItemRowKey
            };

            return(changeLogEntity);
        }
Example #2
0
        protected void rdFryersGrid_OnItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "delete":
                HiddenField hdnDeepFryerId = e.Item.FindControl("hdnDeepFryerId") as HiddenField;

                if (hdnDeepFryerId != null)
                {
                    DeepFryerEntity deepFryer = new DeepFryerEntity(Convert.ToInt32(hdnDeepFryerId.Value));
                    deepFryer.IsActive = false;
                    deepFryer.Save();

                    ChangeLogEntity cle = new ChangeLogEntity();
                    cle.UserId       = sm.AuthenticatedUser.UserId;
                    cle.ChangeDate   = DateTime.Now;
                    cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.FryerRemoved;
                    DeepFryerChangeLogEntity dfcle = new DeepFryerChangeLogEntity();
                    dfcle.DeepFryerId = deepFryer.DeepFryerId;
                    dfcle.ChangeLog   = cle;
                    dfcle.Save(true);
                }
                break;

            default:
                break;
            }
        }
Example #3
0
 /// <summary> setups the sync logic for member _changeLog</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncChangeLog(IEntity2 relatedEntity)
 {
     if (_changeLog != relatedEntity)
     {
         DesetupSyncChangeLog(true, true);
         _changeLog = (ChangeLogEntity)relatedEntity;
         base.PerformSetupSyncRelatedEntity(_changeLog, new PropertyChangedEventHandler(OnChangeLogPropertyChanged), "ChangeLog", ServiceLocationAssetTypeChangeLogEntity.Relations.ChangeLogEntityUsingChangeLogId, true, new string[] {  });
     }
 }
Example #4
0
        public async Task GetChangeLogs()
        {
            var options = TestHelper.GetDbContext("GetChangeLogs");

            var now = DateTime.Now;

            //Given
            var cl1 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "1.0", ReleaseDate = now.AddMonths(-2), Published = true, Log = "Log 1"
            };
            var cl2 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "2.0", ReleaseDate = now.AddMonths(-1), Published = true, Log = "Log 2"
            };
            var cl3 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "3.0", ReleaseDate = now, Published = true, Log = "Log 3"
            };

            using (var context = new DataContext(options))
            {
                //Jumbled order
                context.ChangeLog.Add(cl1);
                context.ChangeLog.Add(cl3);
                context.ChangeLog.Add(cl2);

                context.SaveChanges();
            }

            using (var context = new DataContext(options))
            {
                var service = new ChangeLogService(context);

                //When
                var queryOptions = new ChangeLogQueryOptions("", "", 0, 0);
                var actual       = await service.GetChangeLogs(queryOptions);

                //Then
                Assert.Equal(3, actual.TotalItems);
                Assert.Equal(3, actual.Items.Count());

                var items = actual.Items.ToList();

                var actual1 = items[0];
                Assert.Equal(cl3.Id, actual1.Id);
                Assert.Equal(cl3.VersionNumber, actual1.VersionNumber);
                Assert.Equal(cl3.ReleaseDate, actual1.ReleaseDate);
                Assert.Equal(cl3.Published, actual1.Published);
                Assert.Equal(cl3.Log, actual1.Log);

                var actual2 = items[1];
                Assert.Equal(cl2.Id, actual2.Id);

                var actual3 = items[2];
                Assert.Equal(cl1.Id, actual3.Id);
            }
        }
Example #5
0
        /// <summary> Initializes the class members</summary>
        protected virtual void InitClassMembers()
        {
            _changeLog = null;
            _serviceLocationAssetType = null;

            PerformDependencyInjection();

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END

            OnInitClassMembersComplete();
        }
Example #6
0
        private async Task UpdateOverview(ChangeLogEntity changeLogEntity)
        {
            var changeLogOverviewEntity = await this.overviewTableHandler.GetItemAsync(StorageValues.TableOverviewPartitionKey, changeLogEntity.Context + "_" + changeLogEntity.TableName);

            if (changeLogOverviewEntity == null)
            {
                changeLogOverviewEntity = EntityFactory.CreateChangeLogTableOverviewEntity(changeLogEntity);
            }

            EntityFactory.AppendOverviewValues(changeLogEntity, changeLogOverviewEntity);

            await this.overviewTableHandler.InsertOrUpdateAsync(changeLogOverviewEntity);
        }
Example #7
0
        protected void btnSaveFryers_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem item in rdFryersGrid.Items)
            {
                TextBox     txtDeepFryerName          = item.FindControl("txtDeepFryerName") as TextBox;
                TextBox     txtDeepFryerDescription   = item.FindControl("txtDeepFryerDescription") as TextBox;
                TextBox     txtDeepFryerSizeInGallons = item.FindControl("txtDeepFryerSizeInGallons") as TextBox;
                HiddenField hdnDeepFryerId            = item.FindControl("hdnDeepFryerId") as HiddenField;
                HiddenField hdnOrigSize = item.FindControl("hdnOrigSize") as HiddenField;

                if (hdnDeepFryerId != null)
                {
                    DeepFryerEntity deepFryer = new DeepFryerEntity(Convert.ToInt32(hdnDeepFryerId.Value));
                    deepFryer.Name        = txtDeepFryerName.Text.Trim();
                    deepFryer.Description = txtDeepFryerDescription.Text.Trim();
                    if (deepFryer.SizeInGallons != null)
                    {
                        try
                        {
                            double orgSize = Convert.ToDouble(hdnOrigSize.Value);
                            double newSize = Convert.ToDouble(txtDeepFryerSizeInGallons.Text.Trim());

                            if (orgSize != newSize)
                            {
                                ChangeLogEntity cle = new ChangeLogEntity();
                                cle.UserId       = sm.AuthenticatedUser.UserId;
                                cle.ChangeDate   = DateTime.Now;
                                cle.ChangeTypeId = newSize > orgSize ? (int)ChangeTypeEntity.ChangeTypes.FryerSizeIncrease : (int)ChangeTypeEntity.ChangeTypes.FryerSizeDecrease;
                                DeepFryerChangeLogEntity dfcle = new DeepFryerChangeLogEntity();
                                dfcle.DeepFryerId = deepFryer.DeepFryerId;
                                dfcle.ChangeLog   = cle;
                                dfcle.Save(true);
                            }
                        }
                        catch { }
                    }


                    if (txtDeepFryerSizeInGallons.Text.Trim().Length > 0)
                    {
                        deepFryer.SizeInGallons = Convert.ToDouble(txtDeepFryerSizeInGallons.Text.Trim());
                    }



                    deepFryer.Save();
                }
            }

            Response.Redirect("~/EditAccount.aspx?acctId=" + _account.AccountId.ToString());
        }
        private ChangeLogEntity MapCompanyModelToEntity(ChangeLog model, ChangeLogEntity entity = null)
        {
            if (entity == null)
            {
                entity = new ChangeLogEntity();
            }

            entity.VersionNumber = model.VersionNumber;
            entity.ReleaseDate   = model.ReleaseDate.Value;
            entity.Published     = model.Published;
            entity.Log           = model.Log;

            return(entity);
        }
Example #9
0
        public async Task UpdateChangeLog()
        {
            var options = TestHelper.GetDbContext("UpdateChangeLog");

            //Given
            var cl1 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "1.0", ReleaseDate = DateTime.Now.AddMonths(-2), Published = false, Log = "Log 1"
            };
            var cl2 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "2.0", ReleaseDate = DateTime.Now.AddMonths(-1), Published = false, Log = "Log 2"
            };

            using (var context = new DataContext(options))
            {
                //Jumbled order
                context.ChangeLog.Add(cl1);
                context.ChangeLog.Add(cl2);

                context.SaveChanges();
            }

            var model = new ChangeLog()
            {
                Id            = cl2.Id,
                VersionNumber = "2.1",
                ReleaseDate   = DateTime.Now.AddMonths(-3),
                Log           = "Log 2 updated",
                Published     = true
            };

            using (var context = new DataContext(options))
            {
                var service = new ChangeLogService(context);

                //When
                var result = await service.UpdateChangeLog(model);

                //Then
                Assert.True(result.Success);

                var actual = await context.ChangeLog.FindAsync(model.Id);

                Assert.Equal(model.VersionNumber, actual.VersionNumber);
                Assert.Equal(model.ReleaseDate, actual.ReleaseDate);
                Assert.Equal(model.Published, actual.Published);
                Assert.Equal(model.Log, actual.Log);
            }
        }
Example #10
0
        protected void btnSaveAssetTypePrices_Click(object sender, EventArgs e)
        {
            foreach (GridDataItem assetCategoryItem in rdAssetTypeGrid.Items)
            {
                GridNestedViewItem detailView = (GridNestedViewItem)assetCategoryItem.ChildItem;

                if (detailView != null)
                {
                    GridTableView tableView = detailView.NestedTableViews.First();
                    foreach (GridDataItem assetTypeItem in tableView.Items)
                    {
                        Hashtable assetTypeValues = new Hashtable();
                        assetTypeItem.ExtractValues(assetTypeValues);
                        int serviceLocationAssetTypeId = Convert.ToInt32(assetTypeValues["ServiceLocationAssetTypeId"].ToString());
                        ServiceLocationAssetTypeEntity serviceLocationAssetType = new ServiceLocationAssetTypeEntity(serviceLocationAssetTypeId);

                        TextBox     txtPricePerUnit = assetTypeItem.FindControl("txtPricePerUnit") as TextBox;
                        HiddenField hdnOrigPrice    = assetTypeItem.FindControl("hdnOrigPrice") as HiddenField;

                        decimal price     = 0;
                        decimal origPrice = Convert.ToDecimal(hdnOrigPrice.Value.Trim().Replace("$", ""));

                        if (txtPricePerUnit.Text.Trim().Length > 0)
                        {
                            price = Convert.ToDecimal(txtPricePerUnit.Text.Trim().Replace("$", ""));
                        }

                        serviceLocationAssetType.PricePerUnit = price;
                        serviceLocationAssetType.Save();

                        if (price != origPrice)
                        {
                            ChangeLogEntity cle = new ChangeLogEntity();
                            cle.UserId       = sm.AuthenticatedUser.UserId;
                            cle.ChangeDate   = DateTime.Now;
                            cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.AssetTypePriceChange;
                            cle.Save();
                            ServiceLocationAssetTypeChangeLogEntity slatcle = new ServiceLocationAssetTypeChangeLogEntity();
                            slatcle.ServiceLocationAssetTypeId = serviceLocationAssetType.ServiceLocationAssetTypeId;
                            slatcle.ChangeLog = cle;
                            slatcle.Save();
                        }
                    }
                }
            }

            messages.AddSuccessDiv("Asset types successfully saved");
        }
Example #11
0
        protected void btnSaveDeepFryer_Click(object sender, EventArgs e)
        {
            if (txtDeepFryerName.Text.Trim().Length > 0)
            {
                _currentFryer = new DeepFryerEntity(Convert.ToInt32(hdnDeepFryerId.Value));
                double sizeInGallons = 0;

                if (txtSizeInGallons.Text.Trim().Length > 0)
                {
                    try
                    {
                        sizeInGallons = Convert.ToDouble(txtSizeInGallons.Text.Trim());
                    }
                    catch
                    {
                        //TODO
                    }
                }
                _currentFryer.Name              = txtDeepFryerName.Text.Trim();
                _currentFryer.Description       = txtDeepFryerDescription.Text.Trim().Length > 0 ? txtDeepFryerDescription.Text.Trim() : null;
                _currentFryer.ServiceLocationId = _serviceLocation.ServiceLocationId;
                if (sizeInGallons > 0)
                {
                    _currentFryer.SizeInGallons = sizeInGallons;
                }
                else
                {
                    _currentFryer.SizeInGallons = null;
                }
                _currentFryer.Save();

                ChangeLogEntity cle = new ChangeLogEntity();
                cle.UserId       = sm.AuthenticatedUser.UserId;
                cle.ChangeDate   = DateTime.Now;
                cle.ChangeTypeId = (int)ChangeTypeEntity.ChangeTypes.FryerAdded;
                DeepFryerChangeLogEntity dfcle = new DeepFryerChangeLogEntity();
                dfcle.DeepFryerId = _currentFryer.DeepFryerId;
                dfcle.ChangeLog   = cle;
                dfcle.Save(true);

                rdFryersGrid.Rebind();
                divAddNewFryer.Visible = false;
                btnAddNewFryer.Visible = true;
                //    Response.Redirect("~/EditServiceLocation.aspx?serviceLocationId=" + _currentFryer.ServiceLocationId.ToString() + "&tab=1");
            }
        }
Example #12
0
        internal static ChangeLogModel CreateChangeLogModel(ChangeLogEntity changeLogEntity)
        {
            var changeLogModel = new ChangeLogModel
            {
                UserId           = changeLogEntity.UserId,
                TableName        = changeLogEntity.TableName,
                Context          = changeLogEntity.Context,
                Type             = changeLogEntity.Type,
                ItemId           = changeLogEntity.ItemId,
                UserEmail        = changeLogEntity.UserEmail,
                ChangeData       = changeLogEntity.ChangeData,
                ChangedDataType  = changeLogEntity.ChangedDataType,
                LogDate          = changeLogEntity.Timestamp.DateTime,
                ItemPartitionKey = changeLogEntity.ItemPartitionKey,
                ItemRowKey       = changeLogEntity.ItemRowKey
            };

            return(changeLogModel);
        }
Example #13
0
        public async Task GetLatestChangeLog()
        {
            var options = TestHelper.GetDbContext("GetLatestChangeLog");

            var now = DateTime.Now;

            //Given
            var cl1 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "1.0", ReleaseDate = now.AddMonths(-2), Published = true, Log = "Log 1"
            };
            var cl2 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "2.0", ReleaseDate = now.AddMonths(-1), Published = true, Log = "Log 2"
            };
            var cl3 = new ChangeLogEntity {
                Id = Guid.NewGuid(), VersionNumber = "3.0", ReleaseDate = now, Published = false, Log = "Log 3"
            };

            using (var context = new DataContext(options))
            {
                //Jumbled order
                context.ChangeLog.Add(cl1);
                context.ChangeLog.Add(cl3);
                context.ChangeLog.Add(cl2);

                context.SaveChanges();
            }

            using (var context = new DataContext(options))
            {
                var service = new ChangeLogService(context);

                //When
                var actual = await service.GetLatestChangeLog();

                //Then
                Assert.Equal(cl2.Id, actual.Id);
                Assert.Equal(cl2.VersionNumber, actual.VersionNumber);
                Assert.Equal(cl2.ReleaseDate, actual.ReleaseDate);
                Assert.Equal(cl2.Published, actual.Published);
                Assert.Equal(cl2.Log, actual.Log);
            }
        }
Example #14
0
        internal static void AppendOverviewValues(ChangeLogEntity changeLogEntity, ChangeLogTableOverviewEntity changeLogOverviewEntity)
        {
            if (changeLogOverviewEntity.Users.Contains(changeLogEntity.UserId) == false)
            {
                changeLogOverviewEntity.Users += "," + changeLogEntity.UserId;
            }

            if (changeLogEntity.Type == ChangeTypeValues.Modify)
            {
                changeLogOverviewEntity.ModifyLogCount += 1;
            }
            if (changeLogEntity.Type == ChangeTypeValues.Create)
            {
                changeLogOverviewEntity.CreateLogCount += 1;
            }
            if (changeLogEntity.Type == ChangeTypeValues.Delete)
            {
                changeLogOverviewEntity.DeleteLogCount += 1;
            }
        }
Example #15
0
        protected ServiceLocationAssetTypeChangeLogEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            if (SerializationHelper.Optimization != SerializationOptimization.Fast)
            {
                _changeLog = (ChangeLogEntity)info.GetValue("_changeLog", typeof(ChangeLogEntity));
                if (_changeLog != null)
                {
                    _changeLog.AfterSave += new EventHandler(OnEntityAfterSave);
                }
                _serviceLocationAssetType = (ServiceLocationAssetTypeEntity)info.GetValue("_serviceLocationAssetType", typeof(ServiceLocationAssetTypeEntity));
                if (_serviceLocationAssetType != null)
                {
                    _serviceLocationAssetType.AfterSave += new EventHandler(OnEntityAfterSave);
                }

                base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
            }

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Example #16
0
 internal static string GetRowKey(ChangeLogEntity changeLogEntity)
 {
     return(changeLogEntity.Context + "_" + changeLogEntity.TableName);
 }
Example #17
0
 /// <summary> Removes the sync logic for member _changeLog</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncChangeLog(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity(_changeLog, new PropertyChangedEventHandler(OnChangeLogPropertyChanged), "ChangeLog", ServiceLocationAssetTypeChangeLogEntity.Relations.ChangeLogEntityUsingChangeLogId, true, signalRelatedEntity, "ServiceLocationAssetTypeChangeLog", resetFKFields, new int[] { (int)ServiceLocationAssetTypeChangeLogFieldIndex.ChangeLogId });
     _changeLog = null;
 }
Example #18
0
        internal static ChangeLogTableOverviewEntity CreateChangeLogTableOverviewEntity(ChangeLogEntity changeLogEntity)
        {
            var changeLogOverviewEntity = new ChangeLogTableOverviewEntity
            {
                PartitionKey = StorageValues.TableOverviewPartitionKey,
                RowKey       = GetRowKey(changeLogEntity),
                TableName    = changeLogEntity.TableName,
                Context      = changeLogEntity.Context,
                Users        = changeLogEntity.UserId
            };

            return(changeLogOverviewEntity);
        }