Пример #1
0
 /// <summary>
 /// Actualizes translation.
 /// </summary>
 public void ActualizeTranslation()
 {
     try {
         TranslationActualizer.ActualizeTranslation(TranslationActualizedOn);
         SysSettings.SetDefValue(UserConnection, TranslationActualizedOnSysSettingCode, DateTime.UtcNow);
     } catch (Exception ex) {
         MsgChannelUtilities.PostMessage(UserConnection, TranslationActualizedErrorMessageName, ex.Message);
         throw;
     }
 }
        private void UpdateExpenseReport(UserConnection userConnection, Guid Id)
        {
            Entity expenseReport = userConnection.EntitySchemaManager.GetInstanceByName("ExpenseReport").CreateEntity(userConnection);

            expenseReport.FetchFromDB(Id);
            Tuple <decimal, decimal> sum = CalculateSum(userConnection, Id);

            expenseReport.SetColumnValue("Total", sum.Item1);
            //expenseReport.SetColumnValue("TotalFC", sum.Item2);
            expenseReport.Save();
            MsgChannelUtilities.PostMessage(userConnection, GetType().Name, "UpdatedExpenseReport");
        }
Пример #3
0
        public override void OnSaving(object sender, EntityBeforeEventArgs e)
        {
            base.OnSaving(sender, e);
            Entity         entity         = (Entity)sender;
            UserConnection userConnection = entity.UserConnection;
            var            oldName        = entity.GetTypedColumnValue <string>("Name");



            if (oldName.Contains("Kirill"))
            {
                e.IsCanceled = true;
                MsgChannelUtilities.PostMessage(userConnection, this.GetType().FullName, "I am cancelling this, because ....");
            }

            entity.SetColumnValue("Name", $"{oldName} - test listener");
        }
        public override void OnSaved(object sender, EntityAfterEventArgs e)
        {
            base.OnSaved(sender, e);
            Entity entity = (Entity)sender;

            userConnection = entity.UserConnection;

            string[] ObservableColumns   = { "AmountHC", "AmountFC", "Currency" };
            bool     isChangeInteresting = false;

            foreach (EntityColumnValue mc in e.ModifiedColumnValues)
            {
                if (Array.IndexOf(ObservableColumns, mc.Column.Name) > -1)
                {
                    isChangeInteresting = true;
                }
            }

            if (!isChangeInteresting)
            {
                return;
            }


            Guid   currencyId   = entity.GetTypedColumnValue <Guid>("CurrencyId");
            string currencyName = GetCurrencyName(currencyId);

            IBank       bank       = BankFactory.GetBank(BankFactory.SupportedBanks.BOC);
            IBankResult bankResult = Task.Run(() => bank.GetRateAsync(currencyName, DateTime.Today)).Result;

            decimal rate = bankResult.ExchangeRate;

            decimal amountFC = entity.GetTypedColumnValue <decimal>("AmountFC");
            decimal amountHC = rate * amountFC;

            entity.SetColumnValue("AmountHC", amountHC);
            entity.Save();

            Guid expenseReportId = entity.GetTypedColumnValue <Guid>("ExpenseReportId");

            UpdateExpenseReport(entity.UserConnection, expenseReportId);

            MsgChannelUtilities.PostMessage(userConnection, GetType().Name, "UpdatedExpenseReportLine");
        }
Пример #5
0
        public override void OnSaving(object sender, EntityBeforeEventArgs e)
        {
            base.OnSaving(sender, e);
            Entity entity  = (Entity)sender;
            string oldName = entity.GetTypedOldColumnValue <string>("Name");
            string newName = entity.GetTypedColumnValue <string>("Name");

            entity.SetColumnValue("Name", $"Changing from {oldName } to {newName}");

            MsgChannelUtilities.PostMessage(entity.UserConnection, GetType().Name, "our first message");

            entity.Save();



            //UserConnection userConnection = entity.UserConnection;

            //string message = $"Changing name for {entity.GetTypedColumnValue<string>("Name")}";
            //_log.Info(message);
        }
        public override void OnSaving(object sender, EntityBeforeEventArgs e)
        {
            base.OnSaving(sender, e);
            Entity entity = (Entity)sender;

            UserConnection = entity.UserConnection;

            //Check if columns changed are the ones I care about
            if (!entity.IsChangeInteresting(InterestingColumns))
            {
                return;
            }

            //if (CountOverlappingActivitiesEsq(entity) != 0)
            if (CountOverlappingActivitiesSelect(entity) != 0)
            {
                e.IsCanceled = true;
                string message = entity.GetLocalizableString("OverlappingActivitiesFoundMessage", GetType().Name);
                MsgChannelUtilities.PostMessage(UserConnection, GetType().Name, message);
            }
        }
Пример #7
0
        public override void OnSaving(object sender, EntityBeforeEventArgs e)
        {
            var myClass = ClassFactory.Get <ICustomLogic>();
            var myInt   = myClass.SumNum(10, 20);


            base.OnSaving(sender, e);
            Entity entity = (Entity)sender;

            UserConnection = entity.UserConnection;

            //[Application address]/0/Nui/ViewModule.aspx#BaseSchemaModuleV2/FeaturesPage
            if (!UserConnection.GetIsFeatureEnabled(FeatureCode))
            {
                return;
            }

            if (!entity.IsChangeInteresting(InterestingColumns))
            {
                return;
            }

            if (CountOverlappingActivitiesSelect(entity) != 0)
            {
                e.IsCanceled = true;
                string message = entity.GetLocalizableString("OverlappingActivitiesFoundMessage", GetType().Name);
                _log.Info(message);
                MsgChannelUtilities.PostMessage(UserConnection, GetType().Name, message);
            }

            //if (CountOverlappingActivityEsq(entity) != 0)
            //{
            //    e.IsCanceled = true;
            //    string message = entity.GetLocalizableString("OverlappingActivitiesFoundMessage", GetType().Name);
            //    MsgChannelUtilities.PostMessage(UserConnection, GetType().Name, message);
            //}
        }
Пример #8
0
        private void CreateReminding(UserConnection userConnection, Guid forecastId)
        {
            var remindingUtilities = ClassFactory.Get <RemindingUtilities>();
            var sheetRepository    = ClassFactory.Get <IForecastSheetRepository>(
                new ConstructorArgument("userConnection", userConnection));
            var  sheet                 = sheetRepository.GetSheet(forecastId);
            Guid entitySchemaUId       = userConnection.EntitySchemaManager.GetItemByName("ForecastSheet").UId;
            var  _currentUserContactId = userConnection.CurrentUser.ContactId;
            var  config                = new RemindingConfig(entitySchemaUId)
            {
                AuthorId    = _currentUserContactId,
                ContactId   = _currentUserContactId,
                SubjectId   = forecastId,
                Description = GetLocalizableString(userConnection, "RemindingDescription"),
                PopupTitle  = string.Format(GetLocalizableString(userConnection, "RemindingPopupTitle"),
                                            sheet.Name)
            };
            var message = new {
                forecastId
            };

            MsgChannelUtilities.PostMessage(userConnection, "UpdateForecasts", JsonConvert.SerializeObject(message));
            remindingUtilities.CreateReminding(userConnection, config);
        }
Пример #9
0
 public void PostMessage(UserConnection userConnection, string senderName, string messageText)
 {
     MsgChannelUtilities.PostMessage(userConnection, senderName, messageText);
 }