Exemple #1
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            MyOrg.Name = input_OrgName.Text;
            if (!MyOrg.Create())
            {
                MessageBox.Show("Could not create your new organisation");
            }

            OrgMember TempMember = MyOrg.NewOrgMember(Data.ActiveUser);

            if (TempMember.Create())
            {
                Data.OrgMembers.Add(TempMember);
                MessageBox.Show("Organisation created successfully!");
                this.Close();
            }
            else
            {
                if (MyOrg.Delete())
                {
                    MessageBox.Show("You could not be added as a member to your organisation. " +
                                    "Your organisation has been deleted.");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Your organisation was created but you could not be added as a  member. " +
                                    "Changes could not be reverted.");
                    this.Close();
                }
            }
        }
        public async Task <OrganisationDto> Handle(CreateOrganisationCommand request, CancellationToken cancellationToken)
        {
            //do validation
            if (string.IsNullOrWhiteSpace(request.Name))
            {
                throw new ThisAppException(StatusCodes.Status417ExpectationFailed, Messages.Err417MissingObjectData("Organisation Name"));
            }
            if (string.IsNullOrWhiteSpace(request.MasterEmail))
            {
                throw new ThisAppException(StatusCodes.Status417ExpectationFailed, Messages.Err417MissingObjectData("Master Email Address"));
            }
            //TODO: Validate that email address is valid with RegEx compare

            var newOrg = await Organisation.Create(_executor, request.Name, request.MasterEmail);

            return(_mapper.Map <OrganisationDto>(newOrg));
        }
Exemple #3
0
        /// <summary>
        /// The message handler logic for organisation messages
        /// </summary>
        /// <param name="topicparts">topic parts</param>
        /// <param name="wrapper">wrapper object</param>
        /// <returns>resulting object or null</returns>
        public static ReturnMessageWrapper HandleMessage(string[] topicparts, Common.DTO.MessageWrapper wrapper)
        {
            CallContext cc = new CallContext(
                wrapper.OrgContext,
                new Common.DTO.Token()
            {
                Tokenid = wrapper.UserContextToken, Scope = GlobalValues.Scope
            },
                wrapper.IssuedDate);
            var operation = topicparts[1];

            Monosoft.Auth.DTO.Organisation organisation = new Auth.DTO.Organisation();

            if (cc.IsKeyAccountManager)
            {
                if (wrapper.MessageData != null)
                {
                    Auth.DTO.Organisation result = null;
                    switch (operation)
                    {
                    case "create":     // TESTET OK: 30-09-2018
                        organisation = Common.DTO.MessageWrapperHelper <Monosoft.Auth.DTO.Organisation> .GetData(wrapper);

                        result = Organisation.ConvertToDTO(cc.Scope, Organisation.Create(organisation, cc.Scope));
                        Common.MessageQueue.EventClient.Instance.RaiseEvent(GlobalValues.RouteOrganisationCreated, new Common.DTO.EventDTO(result, wrapper.Clientid, wrapper.Messageid));
                        return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
                        {
                            new LocalizedString()
                            {
                                Lang = "en", Text = "OK"
                            }
                        }, result));

                    case "update":     // TESTET OK: 30-09-2018
                        organisation = Common.DTO.MessageWrapperHelper <Monosoft.Auth.DTO.Organisation> .GetData(wrapper);

                        result = Organisation.ConvertToDTO(cc.Scope, Organisation.Update(organisation, cc.Scope));
                        Common.MessageQueue.EventClient.Instance.RaiseEvent(GlobalValues.RouteOrganisationUpdated, new Common.DTO.EventDTO(result, wrapper.Clientid, wrapper.Messageid));
                        return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
                        {
                            new LocalizedString()
                            {
                                Lang = "en", Text = "OK"
                            }
                        }, result));

                    case "delete":     // TESTET OK: 30-09-2018
                        var deleteid = Common.DTO.MessageWrapperHelper <Monosoft.Common.DTO.GuidIdDTO> .GetData(wrapper);

                        Common.DTO.Success isDeleted = new Common.DTO.Success();
                        isDeleted.Succeeded = Organisation.Delete(deleteid.Id);
                        Common.MessageQueue.EventClient.Instance.RaiseEvent(GlobalValues.RouteOrganisationDeleted, new Common.DTO.EventDTO(isDeleted, wrapper.Clientid, wrapper.Messageid));
                        return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
                        {
                            new LocalizedString()
                            {
                                Lang = "en", Text = "OK"
                            }
                        }, isDeleted));

                    default:     /*log error event*/
                        // Common.MessageQueue.Diagnostics.Instance.LogEvent("Unknow topic for Organisation.", operation + " is unknown", Common.DTO.Severity.Information, wrapper.OrgContext);
                        break;
                    }
                }
            }

            if (wrapper.MessageData != null)
            { // operations without any security conserns
                switch (operation)
                {
                case "create":
                case "update":
                case "delete":
                    Common.MessageQueue.Diagnostics.Instance.LogEvent("Missing credentials.", "Missing credentials for " + operation + " is unknown", Common.DTO.Severity.Information, wrapper.OrgContext);
                    return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
                    {
                        new LocalizedString()
                        {
                            Lang = "en", Text = "missing credentials"
                        }
                    }, null));

                case "getbyids":
                    var getbyid = Common.DTO.MessageWrapperHelper <Monosoft.Common.DTO.GuidIdsDTO> .GetData(wrapper);

                    var orgsList = Organisation.GetByIds(getbyid.Ids).Select(p => Organisation.ConvertToDTOWoDetails(cc.Scope, p)).ToList();
                    var results  = Organisation.ConvertToDTO(cc.Scope, orgsList);
                    Common.MessageQueue.EventClient.Instance.RaiseEvent(GlobalValues.RouteOrganisationRead, new Common.DTO.EventDTO(results, wrapper.Clientid, wrapper.Messageid));
                    return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
                    {
                        new LocalizedString()
                        {
                            Lang = "en", Text = "OK"
                        }
                    }, results));

                default:     /*log error event*/
                    Common.MessageQueue.Diagnostics.Instance.LogEvent("Unknow topic for Organisation.", operation + " is unknown", Common.DTO.Severity.Information, wrapper.OrgContext);
                    return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
                    {
                        new LocalizedString()
                        {
                            Lang = "en", Text = operation + " is unknown"
                        }
                    }, null));
                }
            }

            Common.MessageQueue.Diagnostics.Instance.LogEvent("Missing MessageData.", "MessageData is null", Common.DTO.Severity.Information, wrapper.OrgContext);
            return(ReturnMessageWrapper.CreateResult(true, wrapper, new System.Collections.Generic.List <LocalizedString>()
            {
                new LocalizedString()
                {
                    Lang = "en", Text = "MessageData is null"
                }
            }, null));
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Organisation NewOrg = new Organisation();

            NewOrg.Name = "Stress Test Org";

            if (NewOrg.Create())
            {
                Console.WriteLine("Created organisation");
            }
            else
            {
                Console.WriteLine("Failed to create organisation: " + NewOrg.ErrMsg);
                Console.ReadLine();
            }

            User Me = new User(new Guid("78d3c158-01a9-49ff-82c8-d823ba27d214"));

            if (Me.Get())
            {
                Console.WriteLine("Got your user");
            }
            else
            {
                Console.WriteLine("Failed to get your user");
                Console.ReadLine();
            }

            Data.ActiveUser = Me;

            OrgMember MeMember = NewOrg.NewOrgMember(Me);

            if (!MeMember.Create())
            {
                Console.Write("Failed to make org member");
                Console.ReadLine();
            }

            Product MyProduct = NewOrg.NewProduct();

            MyProduct.Name = "Stress Test Product";

            if (MyProduct.Create())
            {
                Console.WriteLine("Created your product");
            }
            else
            {
                Console.WriteLine("Failed to create your product");
                Console.ReadLine();
            }

            for (int i = 0; i < 1000; i++)
            {
                Bug TempBug = MyProduct.NewBug();
                TempBug.Title       = "Auto Generated Bug #" + i;
                TempBug.Description = "Lorem ipsum dolor sit amet, prima pertinacia no has. " +
                                      "Ad sea velit audiam phaedrum. Te efficiendi omittantur consequuntur cum, " +
                                      "usu timeam imperdiet liberavisse cu. Cu idque oporteat scribentur vel, " +
                                      "bonorum probatus cu vim, quando liberavisse ut duo. Audiam ornatus sententiae " +
                                      "eos te.His id nobis veniam, eos eu eripuit sapientem argumentum, nec no erant " +
                                      "legimus postulant. Wisi admodum deseruisse eu vim.Ridens timeam mea ad. Cu sit " +
                                      "populo oblique, ut fugit dicunt indoctum usu.";

                TempBug.Severity = 1;

                if (TempBug.Create())
                {
                    Console.Write("\rBug {0}/1000 created", i + 1);
                }
                else
                {
                    Console.Write("Failed while creating bug: " + TempBug.ErrMsg);
                }
            }
            Console.WriteLine();
            Console.WriteLine("Done");
            Console.ReadLine();
        }