public ConfigurationServiceResponse UpdateRecords(ServiceUpdateRecordRequest request)
        {
            HierarchicalRecords records;
            var response = new ConfigurationServiceResponse();

            records = new HierarchicalRecords(UserConnection, request.SchemaName, request.ParentColumnName);
            foreach (Guid item in request.ChildrenIds)
            {
                try {
                    bool hasParentResult = records.HasParentInBranch(item, request.ParentId);
                    if (hasParentResult)
                    {
                        records.RemoveParent(request.ParentId);
                        records.ChangeParent(item, request.ParentId);
                    }
                    else
                    {
                        records.ChangeParent(item, request.ParentId);
                    }
                } catch (LoopInHierarchyException ex) {
                    response = new ConfigurationServiceResponse(ex);
                }
            }
            return(response);
        }
        public ConfigurationServiceResponse LaunchCampaign(Guid campaignId)
        {
            UserConnection userConnection         = UserConnection;
            ConfigurationServiceResponse response = ValidateBulkEmails(campaignId, userConnection);

            if (!response.Success)
            {
                return(response);
            }
            CreateActualizeStepsCamapignJob(campaignId);
            UpdateCampaignStatus(campaignId, userConnection, "StartDate", CampaignConsts.RunCampaignStatusId);
            CultureInfo culture = Thread.CurrentThread.CurrentCulture;

            Task.Factory.StartNew(() => {
                try {
                    Thread.CurrentThread.CurrentCulture = culture;
                    UpdateUnconditionedRoutes(campaignId);
                    var campaignStepsHandler =
                        ClassFactory.Get <CampaignStepsHandler>(new ConstructorArgument("userConnection", userConnection));
                    campaignStepsHandler.SetCurrentStepCamapignAudience(campaignId);
                    ActivateReferencedCampaignEmails(campaignId, userConnection);
                    campaignStepsHandler.ActualizeStepsByCampaign(campaignId, true);
                } catch (Exception e) {
                    CampaignUtilities.Log.ErrorFormat("[CampaignService.LaunchCampaign].", e);
                }
            });
            return(response);
        }
        public ConfigurationServiceResponse Save(DCTemplateContract template)
        {
            var response = new ConfigurationServiceResponse();

            try {
                var templateRepository    = new DCTemplateRepository <DCTemplateModel>(UserConnection);
                var repositoryReadOptions = new DCRepositoryReadOptions <DCTemplateModel, DCReplicaModel> {
                    TemplateReadOptions = DCTemplateReadOption.ExcludeAttributes
                                          | DCTemplateReadOption.ExcludeReplicaHtmlContent
                };
                var existedTemplate = templateRepository.ReadByRecordId(template.RecordId, repositoryReadOptions);
                if (existedTemplate != null)
                {
                    template.Id = existedTemplate.Id;
                }
                else if (template.Id.Equals(Guid.Empty))
                {
                    template.Id = Guid.NewGuid();
                }
                templateRepository.Save((DCTemplateModel)template);
            } catch (Exception e) {
                response.Exception = e;
            }
            return(response);
        }
        public ConfigurationServiceResponse DeleteForecastEntityRow(Guid recordId, Guid forecastId)
        {
            RowRepository.UserConnection = UserConnection;
            var response = new ConfigurationServiceResponse();
            var sheet    = SheetRepository.GetSheet(forecastId);
            var config   = new FilterConfig()
            {
                RecordIds = new List <Guid>()
                {
                    recordId
                }
            };

            try {
                var rowIds = RowRepository.Get(sheet, config);
                if (rowIds.Any())
                {
                    var records = new[] { recordId };
                    GroupCellsProvider.RecalculateGroupCells(sheet, new RecalculateGroupCellsParameters {
                        RecordIds       = records,
                        ExcludedRecords = records
                    });
                    var item = rowIds.First();
                    response.Success = RowRepository.Remove(item);
                }
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Beispiel #5
0
        public ConfigurationServiceResponse EditMessage(Guid messageId, EsnWriteMessageDTO message)
        {
            var result = new ConfigurationServiceResponse();

            try {
                EsnCenter.EditMessage(messageId, message);
            } catch (Exception e) {
                result = new ConfigurationServiceResponse(e);
            }
            return(result);
        }
Beispiel #6
0
        public ConfigurationServiceResponse EditComment(Guid commentId, EsnWriteMessageDTO comment)
        {
            var result = new ConfigurationServiceResponse();

            try {
                EsnCenter.EditComment(commentId, comment);
            } catch (Exception e) {
                result = new ConfigurationServiceResponse(e);
            }
            return(result);
        }
Beispiel #7
0
        public ConfigurationServiceResponse DeleteComment(Guid schemaUId, Guid entityId, Guid commentId)
        {
            var result = new ConfigurationServiceResponse();

            try {
                EsnCenter.DeleteComment(schemaUId, entityId, commentId);
            } catch (Exception e) {
                result = new ConfigurationServiceResponse(e);
            }
            return(result);
        }
        public ConfigurationServiceResponse ValidateOrderProductQuantity(Guid orderProductId, decimal newQuantity)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PassportHelper.ValidateOrderProductQuantity(orderProductId, newQuantity);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse ChangeTemplate(Guid orderId, Guid templateId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PassportHelper.ChangeTemplate(orderId, templateId);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse ClearSupplyPaymentProducts(Guid supplyPaymentElementId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PassportHelper.ClearSupplyPaymentProducts(supplyPaymentElementId);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse UpdateSupplyPaymentProducts(UpdateSupplyPaymentProductsRequest updateRequest)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PassportHelper.UpdateSupplyPaymentProducts(updateRequest.SupplyPaymentElementId, updateRequest.ProductsInfo);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse TurnDefPassportTemplateOff(Guid orderId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PassportHelper.TurnDefPassportTemplateOff(orderId);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Beispiel #13
0
        public ConfigurationServiceResponse UnLikeMessage(Guid messageId)
        {
            var result = new ConfigurationServiceResponse();

            try {
                EsnCenter.UnLikeMessage(GetCurrentUserId, messageId);
            } catch (Exception e) {
                result = new ConfigurationServiceResponse(e);
            }
            return(result);
        }
Beispiel #14
0
        public ConfigurationServiceResponse CheckIsFileValid(Guid importSessionId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PersistentFileImporter.CheckIsFileValid(importSessionId);
            } catch (Exception ex) {
                response.Exception = ex;
                response.Success   = false;
            }
            return(response);
        }
Beispiel #15
0
        public ConfigurationServiceResponse DeleteFile(Guid importSessionId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PersistentFileImporter.DeleteFile(importSessionId);
            } catch (ItemNotFoundException ex) {
                response.Exception = ex;
                response.Success   = false;
            }
            return(response);
        }
        public ConfigurationServiceResponse ValidateSupplyPaymentAmountPlan(Guid orderId, Guid currentElementId, decimal newAmountPlanValue)
        {
            var response = new ConfigurationServiceResponse();

            try {
                PassportHelper.ValidateSupplyPaymentAmountPlan(orderId, currentElementId, newAmountPlanValue);
            }
            catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Beispiel #17
0
        public ConfigurationServiceResponse ReopenCase(string recordId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                var caseId = Guid.Parse(recordId);
                ReopenCase(caseId);
            } catch (Exception e) {
                response.Exception = e;
            }
            return(response);
        }
        public ConfigurationServiceResponse Delete(Guid templateId)
        {
            var response = new ConfigurationServiceResponse();

            try {
                var templateRepository = new DCTemplateRepository <DCTemplateModel>(UserConnection);
                response.Success = templateRepository.Delete(templateId);
            } catch (Exception e) {
                response.Exception = e;
            }
            return(response);
        }
        public ConfigurationServiceResponse SaveGroupCell(SaveGroupCellParams parameters)
        {
            var response = new ConfigurationServiceResponse();

            var sheet = SheetRepository.GetSheet(parameters.ForecastId);

            try {
                GroupCellsProvider.SaveGroupCell(sheet, parameters);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse ApplyOptionalFuncRolesForUsers(UserInRolePair[] usersInRoles)
        {
            var response = new ConfigurationServiceResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                sspUserManagementHelper.ApplyOptionalFuncRolesForUsers(usersInRoles.ToList());
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse ChangeUserActivationStatus(Guid userId, bool isActive)
        {
            var response = new ConfigurationServiceResponse();

            try {
                UserConnection.DBSecurityEngine.CheckCanManageSspUsers();
                var sspUserManagementHelper = new SspUserManagementServiceHelper(UserConnection);
                sspUserManagementHelper.ChangeUserActivationStatus(userId, isActive);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Beispiel #22
0
        public ConfigurationServiceResponse RecalculateFact(Guid forecastId, string[] periods)
        {
            var response = new ConfigurationServiceResponse();

            try {
                IEnumerable <Guid> periodIds = periods.Select(p => new Guid(p));
                RecalculateFact(forecastId, periodIds.ToList());
            }
            catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse RecalculateGroupCells(Guid forecastId, Guid[] recordIds)
        {
            var response = new ConfigurationServiceResponse();
            var sheet    = SheetRepository.GetSheet(forecastId);

            try {
                GroupCellsProvider.RecalculateGroupCells(sheet, new RecalculateGroupCellsParameters {
                    RecordIds = recordIds
                });
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Beispiel #24
0
        public ConfigurationServiceResponse SaveCell(Guid forecastId, Guid recordId, Guid periodId, Guid columnId,
                                                     string value)
        {
            var response = new ConfigurationServiceResponse();
            var sheet    = SheetRepository.GetSheet(forecastId);

            try {
                CellRepository.SaveCell(sheet, new Cell {
                    EntityId = recordId,
                    PeriodId = periodId,
                    ColumnId = columnId,
                    Value    = Convert.ToDecimal(value, CultureInfo.InvariantCulture)
                });
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse UpdateColumns(Guid forecastId,
                                                          ICollection <ForecastColumnsResponse.Column> forecastColumns)
        {
            var response = new ConfigurationServiceResponse();

            try {
                IEnumerable <ForecastColumn> columns = forecastColumns.Select((fc, index) => new ForecastColumn {
                    Name     = fc.Name,
                    Code     = fc.Code,
                    TypeId   = fc.TypeId,
                    Position = index
                });
                ColumnRepository.UpdateColumns(columns);
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
Beispiel #26
0
        public ConfigurationServiceResponse SaveFile(Stream fileContent)
        {
            IFileUploadInfo fileUploadInfo = GetFileUploadInfo(fileContent);
            decimal         maxFileSize    = GetMaxFileSizeFromSysSettings();
            var             uploadSettings = new FileUploadConfig(fileUploadInfo)
            {
                SetCustomColumnsFromConfig = false,
                MaxFileSize = maxFileSize
            };
            var response = new ConfigurationServiceResponse();

            try {
                FileUploader.UploadFile(uploadSettings);
            } catch (MaxFileSizeExceededException ex) {
                response.Exception = ex;
                response.Success   = false;
            }
            return(response);
        }
Beispiel #27
0
        public ConfigurationServiceResponse GetIsValidColumn(Guid columnTypeId, string settings)
        {
            var response = new ConfigurationServiceResponse();

            if (columnTypeId.Equals(ForecastConsts.FormulaColumnTypeId))
            {
                var formulaItems = FormulaUtilities.DeserializeFormula(new ForecastColumn {
                    Settings = settings
                });
                var isValid = FormulaUtilities.Validate(formulaItems);
                response.Success = isValid;
                if (!isValid)
                {
                    var message = UserConnection.GetLocalizableString("ForecastResources", "FormulaNotValidMessage");
                    response.ErrorInfo = new ErrorInfo {
                        Message = message
                    };
                }
            }
            return(response);
        }
Beispiel #28
0
        public ConfigurationServiceResponse DeleteCells(Guid forecastId, Guid columnId, Guid[] periods)
        {
            periods = periods ?? new Guid[0];
            var periodCollection = periods.Select(id => new Period {
                Id = id
            });
            var response = new ConfigurationServiceResponse();

            try {
                var sheet = SheetRepository.GetSheet(forecastId);
                CellRepository.DeleteCells(sheet, periodCollection, new[] {
                    new ForecastColumn()
                    {
                        Id = columnId
                    }
                });
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }
        public ConfigurationServiceResponse GetIsValidColumn(Guid columnTypeId, string settings, FormulaSettingType type = FormulaSettingType.Default)
        {
            var response = new ConfigurationServiceResponse();

            if (columnTypeId.Equals(ForecastConsts.FormulaColumnTypeId))
            {
                var forecastColumn = new ForecastColumn {
                    Settings = settings
                };
                var formulaSetting = forecastColumn.GetColumnSettings <FormulaSetting>();
                var isValid        = IsFormulaInColumnValid(formulaSetting, type);
                response.Success = isValid;
                if (!isValid)
                {
                    var message = UserConnection.GetLocalizableString(LczResourcesSchemaName, "FormulaNotValidMessage");
                    response.ErrorInfo = new ErrorInfo {
                        Message = message
                    };
                }
            }
            return(response);
        }
Beispiel #30
0
        public ConfigurationServiceResponse RecalculateFact(Guid forecastId, string[] periods)
        {
            var response = new ConfigurationServiceResponse();

            try {
                var userAdminUnitCollection = UserConnection.DBSecurityEngine.GetUserAdminUnitCollection();
                if (userAdminUnitCollection.Any(id =>
                                                id.Equals(ForecastConsts.FinanceRoleId) ||
                                                id.Equals(BaseConsts.SystemAdministratorsSysAdminUnitId)))
                {
                    IEnumerable <Guid> periodIds = periods.Select(p => new Guid(p)).Take(MaxPeriodsCount);
                    RecalculateColumns(forecastId, periodIds.ToList());
                }
                else
                {
                    throw new SecurityException(new LocalizableString("Terrasoft.Core",
                                                                      "ProcessSchemaManager.Exception.NoRightForModify"));
                }
            } catch (Exception ex) {
                response.Exception = ex;
            }
            return(response);
        }