Exemple #1
0
        public ValidationMessage(string message)
        {
            ArgumentCheck.IsNotNull(message, "message");
            ArgumentCheck.IsNotEmpty(message, "message");

            Message = message;
        }
        public override void AddItem(Item item)
        {
            ArgumentCheck.IsNotNull(item);

            string message = string.Format("Unable to add {0} to WorkCentre.", item);

            throw new ArgumentException(message);
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CellReader"/> class.
        /// </summary>
        /// <param name="current">The current.</param>
        public CellReader(IXLCell current)
        {
            ArgumentCheck.IsNotNull(current);

            Address = current.Address.ToStringRelative(false);
            Row     = current.Address.RowNumber;
            Column  = current.Address.ColumnNumber;
            Value   = current.Value;
        }
        public override void AddItem(Item item)
        {
            ArgumentCheck.IsNotNull(item);

            Site site = item as Site;

            if (site == null)
            {
                string message = string.Format("Unable to add {0} to Enterprise.", item);
                throw new ArgumentException(message);
            }
            Site.Add(site);
        }
Exemple #5
0
        public override void AddItem(Item item)
        {
            ArgumentCheck.IsNotNull(item);

            Area area = item as Area;

            if (area == null)
            {
                string message = string.Format("Unable to add {0} to Site.", item);
                throw new ArgumentException(message);
            }
            Area.Add(area);
        }
Exemple #6
0
        /// <summary>
        ///     Adds the item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.InvalidOperationException">Only one Enterprise allowed.</exception>
        public override void AddItem(Item item)
        {
            ArgumentCheck.IsNotNull(item);

            Equipment equipment = item as Equipment;

            if (equipment == null)
            {
                string message = string.Format("Unable to add {0} to Project.", item);
                throw new ArgumentException(message);
            }
            Items.Add(equipment);
        }
        public Presenter(TView view, TModel model, IEventAggregator eventAggregator)
        {
            ArgumentCheck.IsNotNull(view);
            ArgumentCheck.IsNotNull(eventAggregator);
            ArgumentCheck.IsNotNull(model);

            View  = view;
            Model = model;

            View.SetEventPublisher(eventAggregator);
            eventAggregator.AddListener(this);
            EventAggregator = eventAggregator;
        }
        public bool Validate(IItem item)
        {
            ArgumentCheck.IsNotNull(item);
            List <ValidationMessage> messages = OnValidate(item);

            bool result = messages.Count == 0;

            foreach (ValidationMessage validationMessage in messages)
            {
                validationMessages.Add(validationMessage);
            }
            return(result);
        }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExcelSpreadsheet"/> class.
        /// </summary>
        /// <param name="filename">The filename.</param>
        private ExcelSpreadsheet(string filename)
        {
            ArgumentCheck.IsNotNull(filename);
            ArgumentCheck.IsNotEmpty(filename);

            FileInfo fileInfo = new FileInfo(filename);

            existingFile = fileInfo.Exists;

            this.filename = filename;
            workbook      = existingFile ? new XLWorkbook(filename) : new XLWorkbook();
            disposed      = false;
        }
        public WinFormsApplication(IMainPresenter mainPresenter, IoC ioc)
        {
            ArgumentCheck.IsNotNull(mainPresenter);
            ArgumentCheck.IsNotNull(ioc);

            ioc.EventAggregator.AddListener(this, true);

            Form mainForm = mainPresenter.MainView as Form;

            if (mainForm == null)
            {
                throw new InvalidOperationException("Presenter.View is not a Windows Form");
            }
            applicationContext = new ApplicationContext(mainForm);
            disposed           = false;
        }
        /// <summary>
        ///     Adds the item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="System.InvalidOperationException">Only one Enterprise allowed.</exception>
        public override void AddItem(Item item)
        {
            ArgumentCheck.IsNotNull(item);

            Enterprise enterprise = item as Enterprise;

            if (enterprise == null)
            {
                string message = string.Format("Unable to add {0} to Hierarchy.", item);
                throw new ArgumentException(message);
            }
            if (Enterprise != null)
            {
                throw new InvalidOperationException("Only one Enterprise allowed.");
            }
            Enterprise = enterprise;
        }
Exemple #12
0
        public User CreateUser(WorkContext workContext, User user)
        {
            ArgumentCheck.IsNotNull(workContext, nameof(workContext));
            ArgumentCheck.IsNotNullOrEmpty(workContext.LoginName, nameof(workContext.LoginName));
            ArgumentCheck.IsNotNull(user, nameof(user));
            ArgumentCheck.IsNotNullOrEmpty(user.RegisteredClientId, nameof(user.RegisteredClientId));
            ArgumentCheck.IsTrue(_dataService.GetRegisteredClient(user.RegisteredClientId) != null, $"referenced client id '{user.RegisteredClientId}' does not exist");
            ArgumentCheck.IsNotNullOrEmpty(user.LoginName, nameof(user.LoginName));
            ArgumentCheck.IsTrue(_dataService.GetUserByLoginName(user.RegisteredClientId, user.LoginName) == null, $"user with login name '{user.LoginName}' already exists for client '{user.RegisteredClientId}'");
            ArgumentCheck.IsNotNullOrEmpty(user.Password, nameof(user.Password));

            user.UserId       = Guid.NewGuid();
            user.CreationDate = DateTime.Now;
            user.CreationUser = workContext.LoginName;
            user.UpdateDate   = null;
            user.UpdateUser   = null;

            _dataService.CreateUser(user);

            return(user);
        }
Exemple #13
0
        public override void AddItem(Item item)
        {
            ArgumentCheck.IsNotNull(item);

            Area       area = item as Area;
            WorkCentre wc   = item as WorkCentre;

            if (area == null && wc == null)
            {
                string message = string.Format("Unable to add {0} to Area.", item);
                throw new ArgumentException(message);
            }
            if (area != null)
            {
                Area1.Add(area);
            }

            if (wc != null)
            {
                WorkCentre.Add(wc);
            }
        }
 public ItemCollection(Item parent)
 {
     ArgumentCheck.IsNotNull(parent);
     Parent = parent;
 }
 public void Add(ValidationMessage item)
 {
     ArgumentCheck.IsNotNull(item);
     messages.Add(item);
 }
Exemple #16
0
 public EditorPresenter(EditorMenuPresenter presenter, IEditorView view, EditorModel model, IEventAggregator eventAggregator)
     : base(view, model, eventAggregator)
 {
     ArgumentCheck.IsNotNull(presenter);
     eventAggregator.AddListener(this);
 }
Exemple #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WorksheetWriter"/> class.
 /// </summary>
 /// <param name="xlWorksheet">The xl worksheet.</param>
 public WorksheetWriter(IXLWorksheet xlWorksheet)
 {
     ArgumentCheck.IsNotNull(xlWorksheet);
     current = xlWorksheet.Cell(1, 1);
 }
        public MailServiceOperationResponse SendMail(MailServerConfiguration server, MailMessage message)
        {
            ArgumentCheck.IsNotNull(server, $"{nameof(server)} must not be null");
            ArgumentCheck.IsNotNullOrEmpty(server.Hostname, $"{nameof(server.Hostname)} must not be null or empty");
            ArgumentCheck.IsNotNullOrEmpty(server.From, $"{nameof(server.From)} must not be null or empty");

            ArgumentCheck.IsNotNull(message, $"{nameof(message)} must not be null");
            ArgumentCheck.IsNotNull(message.To, $"{nameof(message.To)} must not be null");
            ArgumentCheck.IsTrue(message.To.Count > 0, $"{nameof(message.To)} must contain at least 1 address");
            ArgumentCheck.IsFalse(message.To.Any(o => string.IsNullOrEmpty(o.Address)), $"{nameof(MailAddress.Address)} fields must not be null or empty");
            ArgumentCheck.IsNotNullOrEmpty(message.Body, $"{nameof(message.Body)}");
            ArgumentCheck.IsNotNullOrEmpty(message.Subject, $"{nameof(message.Subject)}");

            try
            {
                NetMail.MailMessage netMessage = new NetMail.MailMessage();

                // TO ##########################
                if (message.From == null)
                {
                    netMessage.From = new NetMail.MailAddress(message.From.Address);
                }
                else
                {
                    netMessage.From = new NetMail.MailAddress(server.From);
                }

                // TO ##########################
                foreach (var adr in message.To)
                {
                    if (string.IsNullOrEmpty(adr.Address))
                    {
                        continue;
                    }
                    NetMail.MailAddress address = new NetMail.MailAddress(adr.Address);
                    if (!string.IsNullOrEmpty(adr.DisplayName))
                    {
                        address = new NetMail.MailAddress(adr.Address, adr.DisplayName);
                    }
                    netMessage.To.Add(address);
                }

                // CC ##########################
                if (message.CC != null)
                {
                    foreach (var adr in message.CC)
                    {
                        if (string.IsNullOrEmpty(adr.Address))
                        {
                            continue;
                        }
                        NetMail.MailAddress address = new NetMail.MailAddress(adr.Address);
                        if (!string.IsNullOrEmpty(adr.DisplayName))
                        {
                            address = new NetMail.MailAddress(adr.Address, adr.DisplayName);
                        }
                        netMessage.CC.Add(address);
                    }
                }

                // BCC ##########################
                if (message.Bcc != null)
                {
                    foreach (var adr in message.Bcc)
                    {
                        if (string.IsNullOrEmpty(adr.Address))
                        {
                            continue;
                        }
                        NetMail.MailAddress address = new NetMail.MailAddress(adr.Address);
                        if (!string.IsNullOrEmpty(adr.DisplayName))
                        {
                            address = new NetMail.MailAddress(adr.Address, adr.DisplayName);
                        }
                        netMessage.Bcc.Add(address);
                    }
                }

                // ################################
                netMessage.Subject    = message.Subject;
                netMessage.Body       = message.Body;
                netMessage.IsBodyHtml = message.IsBodyHtml;

                // ################################
                using (NetMail.SmtpClient client = CreateClient(server))
                {
                    client.Send(netMessage);
                }
                _logger.Info($"Mail sent: '{message.Subject}' to '{string.Join(';', message.To.Select(o => o.Address).ToList())}'");
                return(MailServiceOperationResponse.CreateSuccess());
            }
            catch (Exception e)
            {
                _logger.Error(e);
                return(MailServiceOperationResponse.CreateInternalServerError(e));
            }
        }