Beispiel #1
0
        public static string GetRptToken(
            string idToken,
            string umaProtectionToken,
            string umaAuthorizationToken)
        {
            var factory = new SecurityProxyFactory();
            var proxy   = factory.GetProxy(new SecurityOptions
            {
                UmaConfigurationUrl    = "https://localhost:5445/.well-known/uma-configuration",
                OpenidConfigurationUrl = "https://localhost:5443/.well-known/openid-configuration",
                RootManageApiUrl       = "https://localhost:5444/api"
            });

            try
            {
                var result = proxy.GetRpt("resources/Apis/ClientApi/v1/ClientsController/Get", idToken, umaProtectionToken, umaAuthorizationToken, new List <string>
                {
                    "execute"
                }).Result;
                return(result);
            }
            catch (AggregateException ex)
            {
                return(null);
            }
        }
        public bool SendMail(decimal IdSender, decimal?IdReceiverTemp, decimal IdPack, string InSubject, string InDescription)
        {
            try
            {
                if (IdReceiverTemp == null)
                {
                    return(false);
                }
                var IdReceiver = (decimal)IdReceiverTemp;
                //if (IdPack == null)
                //{
                //    ItemsPublic.Exeptor("بسته ورودی نامشخص است");
                //}
                //if (IdReceiver == null)
                //{
                //    ItemsPublic.Exeptor("گیرنده پیام نامشخص است");
                //}
                //    IdPack = (decimal)IdPack;

                string   TicketID = UserContext.TicketID;
                PostItem mail     = new PostItem(true);
                // MessageBox.Show(mail.GetID().ToString());
                mail.Subject   = InSubject;// "درخواست مجوز عبور";
                mail.StateDate = DateTime.Now;

                mail.Description = string.IsNullOrEmpty(InDescription) ? _sss : InDescription + "\r\n\r\n" + _sss;
                //      return false;
                EOrgObject infoPack = new EOrgObject(true);
                infoPack.CreatorID                   = IdSender;       // UserContext.CurrentUser.ID;
                infoPack.ObjectTypeID                = _TypeGpBaridId; // عدد ثابت باید برای آبجکت های از نوع بسته های مجوز لحاظ شود
                infoPack.IsCreatedBySystem           = true;
                infoPack.SensitivityLevel            = (int)SensivityType.Normal;
                infoPack.ObjectID                    = IdPack;
                infoPack.OwnerID                     = IdSender; // UserContext.CurrentUser.ID;
                infoPack.AllowInheritablePermissions = true;
                IEOrgObjectFacade facade1 = SecurityProxyFactory.NewEOrgObjectFacade();
                if (!facade1.IsExistObject(TicketID, IdPack))
                {
                    mail.ReferenceId = facade1.Create(TicketID, infoPack);
                }
                else
                {
                    mail.ReferenceId = facade1.LoadObject(TicketID, IdPack).ObjectID;
                }

                InvolvedPersonList workFlowInvolvedPersonList = new InvolvedPersonList();
                InvolvedPerson     workFlowInvolvedPerson     = new InvolvedPerson(true);
                IParticipantFacade participantFacade          = DirectoryProxyFactory.NewParticipantFacade();
                Participant        defaultParticipant         = participantFacade.GetDefaultParticipant(TicketID, IdReceiver);
                workFlowInvolvedPerson.PersonID              = IdReceiver;
                workFlowInvolvedPerson.InvolvedTypeID        = (int)InvolvedType.MainReceiver;
                workFlowInvolvedPerson.InvolvedParticipantID = defaultParticipant.ID;
                workFlowInvolvedPerson.OrganizationID        = defaultParticipant.OrganizationUnitID;
                workFlowInvolvedPerson.DisplayString         = defaultParticipant.PersonName + "(" + defaultParticipant.DisplayString + ")";
                workFlowInvolvedPerson.PersonName            = defaultParticipant.PersonName;
                workFlowInvolvedPerson.PositionName          = defaultParticipant.PositionName;
                workFlowInvolvedPersonList.Add(workFlowInvolvedPerson);
                mail.InvolvedPersonList = workFlowInvolvedPersonList;

                IPostItemFacade facade   = WorkflowProxyFactory.NewPostItemFacade();
                decimal         idResult = facade.Send(TicketID, mail, IdSender, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            return(true);
        }