Ejemplo n.º 1
0
        private void OnLoginEvent(LoginEventArgs arg)
        {
            if (arg != null)
            {
                switch (arg.ActionType)
                {
                case "Login":
                {
                    this.Name       = IdentityUtility.GetLoggedInName();
                    this.UserName   = IdentityUtility.GetLoggedInUserName();
                    this.Role       = IdentityUtility.GetLoggedInUserRole();
                    this.IsLoggedIn = Visibility.Visible;
                    break;
                }

                case "SignUp":
                {
                    break;
                }

                case "Logout":
                {
                    this.Name       = "Anonymous";
                    this.UserName   = "******";
                    this.Role       = "NIL";
                    this.IsLoggedIn = Visibility.Collapsed;
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <Participant> InferParticipantsFromWorkItems(IEnumerable <WorkItem> workItems,
                                                                        Func <WorkItem, bool> workItemPredicate, Func <Revision, bool> workItemRevisionPredicate)
        {
            List <Participant> participants = new List <Participant>();

            if (workItemPredicate != null)
            {
                workItems = workItems.Where(workItemPredicate);
            }

            foreach (WorkItem workItem in workItems)
            {
                foreach (Revision revision in workItem.Revisions)
                {
                    if (workItemRevisionPredicate != null)
                    {
                        if (!workItemRevisionPredicate(revision))
                        {
                            continue;
                        }
                    }

                    participants.Add(IdentityUtility.Create((string)revision.Fields["Changed by"].Value));
                }
            }

            return(participants.Distinct());
        }
Ejemplo n.º 3
0
        private async void ExecuteResetCommand(object parameter)
        {
            PasswordBox passwordBox       = parameter as PasswordBox;
            string      clearTextPassword = passwordBox.Password;

            if (IsSaveComplete == true)
            {
                IsSaveComplete = false;
                return;
            }

            if (SaveProgress != 0)
            {
                return;
            }

            var started = DateTime.Now;

            IsSaving = true;

            var userDetail = new UserDetail()
            {
                UserID   = IdentityUtility.GetLoggedInUserId(),
                Name     = this.Name,
                UserName = this.UserName,
                Password = clearTextPassword,
                GroupID  = 0
            };
            var errorInfo = this.dbContext.UpdateUser(userDetail, "RESET", this.UserName);

            if (errorInfo.Code == 0)
            {
            }
            else
            {
                await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Reset Password", errorInfo.Info);
            }

            new DispatcherTimer(
                TimeSpan.FromMilliseconds(50),
                DispatcherPriority.Normal,
                new EventHandler((o, e) =>
            {
                var totalDuration          = started.AddSeconds(3).Ticks - started.Ticks;
                var currentProgress        = DateTime.Now.Ticks - started.Ticks;
                var currentProgressPercent = 100.0 / totalDuration * currentProgress;

                SaveProgress = currentProgressPercent;

                if (SaveProgress >= 100)
                {
                    passwordBox.Password = string.Empty;
                    IsSaveComplete       = true;
                    IsSaving             = false;
                    SaveProgress         = 0;
                    ((DispatcherTimer)o).Stop();
                }
            }), Dispatcher.CurrentDispatcher);
        }
        private void InitializeUI()
        {
            bool isGroupManagementAccessible = IdentityUtility.IsFormAccessible(FormNames.GROUP_MANAGEMENT);
            bool isUserManagementAccessible  = IdentityUtility.IsFormAccessible(FormNames.USER_MANAGEMENT);

            this.CanGroupManagement = isGroupManagementAccessible ? Visibility.Visible : Visibility.Collapsed;
            this.CanUserManagement  = isUserManagementAccessible ? Visibility.Visible : Visibility.Collapsed;
        }
Ejemplo n.º 5
0
 public UserProfileFlyoutViewModel(UserManagementDb dbContext)
 {
     this.dbContext = dbContext;
     this.Name      = IdentityUtility.GetLoggedInName();
     this.UserName  = IdentityUtility.GetLoggedInUserName();
     this.Role      = IdentityUtility.GetLoggedInUserRole();
     InitializeCommands();
     SubscribeEvents();
 }
Ejemplo n.º 6
0
 public MessageHandle(string handleName,
                      string exception,
                      string consumeId)
 {
     Id         = IdentityUtility.NewGuidString();
     HandleName = handleName;
     Exception  = exception;
     ConsumeId  = consumeId;
 }
Ejemplo n.º 7
0
 public MessageConsumed(string topic,
                        string messageBody,
                        DateTime consumeTime)
 {
     Id          = IdentityUtility.NewGuidString();
     Topic       = topic;
     MessageBody = messageBody;
     ConsumeTime = consumeTime;
 }
Ejemplo n.º 8
0
        private void InitializeUI()
        {
            bool isNewProposalAccessible     = IdentityUtility.IsFormAccessible(FormNames.NEW_PROPOSAL);
            bool isAddQuotationAccessible    = IdentityUtility.IsFormAccessible(FormNames.ADD_QUOTATION);
            bool isSearchQuotationAccessible = IdentityUtility.IsFormAccessible(FormNames.SEARCH_QUOTATION);

            this.CanNewProposal     = isNewProposalAccessible ? Visibility.Visible : Visibility.Collapsed;
            this.CanAddQuotation    = isAddQuotationAccessible ? Visibility.Visible : Visibility.Collapsed;
            this.CanSearchQuotation = isSearchQuotationAccessible ? Visibility.Visible : Visibility.Collapsed;
        }
Ejemplo n.º 9
0
        private void ExecuteActivateLicenseCommand()
        {
            string errorMessage;
            var    userId = IdentityUtility.GetLoggedInUserId();

            StreamReader reader = new StreamReader(this._licenseFilePath);
            string       encryptedLicenseDetail = reader.ReadToEnd();

            reader.Close();

            var isUpdated = this.dbContext.UpdateLicense(userId, encryptedLicenseDetail, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                this.WarningMessage   = errorMessage;
                this.IsLicenseUpdated = false;
            }
            else
            {
                if (isUpdated)
                {
                    this.WarningMessage = string.Empty;

                    var licenseDetails = this.dbContext.GetLicenseDetails(out errorMessage);
                    if (licenseDetails != null && licenseDetails.ContainsKey("ExpiryDate"))
                    {
                        _expiryDate = licenseDetails["ExpiryDate"];
                        DateTime expiryDate; DateTime.TryParse(_expiryDate, out expiryDate);
                        if (_expiryDate != null && IsDateBeforeOrToday(expiryDate))
                        {
                            this.WarningMessage   = string.Format("Your License expires on {0}", expiryDate.ToShortDateString());
                            this.IsLicenseUpdated = true;
                        }
                        else
                        {
                            this.WarningMessage   = string.Format("Your License was expired on {0}", expiryDate.ToShortDateString());
                            this.IsLicenseUpdated = false;
                        }
                    }
                    else
                    {
                        this._expiryDate      = string.Empty;
                        this.WarningMessage   = "Please select a valid License file";
                        this.IsLicenseUpdated = false;
                    }
                }
                else
                {
                    this._expiryDate      = string.Empty;
                    this.WarningMessage   = "Please select a valid License file";
                    this.IsLicenseUpdated = false;
                }
            }
        }
Ejemplo n.º 10
0
 public MessagePublished(string producer,
                         string topic,
                         string messageBody,
                         DateTime publishTime,
                         string publishError)
 {
     Id           = IdentityUtility.NewGuidString();
     Producer     = producer;
     Topic        = topic;
     MessageBody  = messageBody;
     PublishTime  = publishTime;
     PublishError = publishError;
 }
Ejemplo n.º 11
0
 public PublishContext(string topic,
                       object message,
                       string producer)
 {
     Topic       = topic;
     Message     = message;
     PublishTime = DateTime.Now;
     Producer    = producer;
     if (Message is AggregateRootEvent @event)
     {
         Key = @event.Key;
     }
     else
     {
         Key = IdentityUtility.NewGuidString();
     }
 }
Ejemplo n.º 12
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime endDateTime, Func <Event, bool> predicate)
        {
            var dp = new YammerDataProvider();

            var retval = dp.PullData(startDateTime, endDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date      = p.CreatedAt,
                    EventType = "Yammer.SentMessages",
                    Text      = p.Body
                };
                e.Participants.Add(IdentityUtility.Create(p.Sender));
                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
Ejemplo n.º 13
0
        //业务方法
        public override void FromXmlData(XmlNode node)
        {
            if (Links == null)
            {
                Links = new ObservableCollection <LinkData>();
            }

            this.KeyIdentity = IdentityUtility.NewClientIdentity();
            this.DisplayName = base.GetAttribute("DisplayName", node);
            this.ModuleURL   = base.GetAttribute("DefaultContentSource", node);
            this.OrderBy     = 1;

            foreach (XmlNode item in node.ChildNodes)
            {
                LinkData temp = new LinkData();
                temp.FromXmlData(item);
                this.Links.Add(temp);
            }
        }
Ejemplo n.º 14
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var cdp = new ConnectDataProvider();

            var retval = cdp.PullData(startDateTime, stopDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date      = p.SubmittedUtcDate,
                    EventType = "Connect.Submission",
                    Text      = p.Title
                };

                e.Participants.Add(IdentityUtility.Create(Environment.UserName));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
Ejemplo n.º 15
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var source = new TeamFoundationServerChangesetDataProvider(TeamFoundationServer, Project);
            var data   = source.PullData(startDateTime, stopDateTime);

            var retval = data.Select(
                p =>
            {
                var e = new Event
                {
                    Text      = p.Comment,
                    Date      = p.CreationDate,
                    Duration  = TimeSpan.Zero,
                    Context   = p.ChangesetId,
                    EventType = "TeamFoundationServer.Changeset"
                };
                e.Participants.Add(IdentityUtility.Create(p.Committer));
                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
Ejemplo n.º 16
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var m = new ManicTimeDataProvider(m_settings[ManicTimeSettingConstants.ActivitiesDatabaseFile].Value);

            var retval = m.PullData(startDateTime, stopDateTime).Select(p =>
            {
                var e = new Event
                {
                    Date      = p.StartUtcTime,
                    Duration  = p.EndUtcTime - p.StartUtcTime,
                    EventType = "ManicTime.Activity",
                    Context   = p.DisplayName,
                    Text      = p.GroupDisplayName
                };

                // "Utilities" and other "helpers" should be injected via the plugin runtime
                e.Participants.Add(IdentityUtility.Create(Environment.UserName));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
Ejemplo n.º 17
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var kdp = new KudosDataProvider();

            var retval = kdp.PullData(startDateTime, stopDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date      = p.CreatedUtcTime,
                    EventType = "Kudos.Received",
                    Context   = p.SenderAlias,
                    Text      = p.Message
                };

                e.Participants.Add(IdentityUtility.Create(p.SenderAlias));
                e.Participants.Add(IdentityUtility.Create(Environment.UserName));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
Ejemplo n.º 18
0
        public IEnumerable <CodeFlowReview> PullData(DateTime startUtcTime, DateTime endUtcTime)
        {
            using (var codeFlowReviewClient = new ReviewDashboardServiceClient())
            {
                var alias = Environment.UserName.Split('\\').Last(); // REVIEW cheap inaccurate way to get user alias

                Console.WriteLine("Pulling reviews authored by " + alias);

                var result = codeFlowReviewClient.QueryReviewSummaries(new CodeReviewQuery
                {
                    CreatedBeforeDate = endUtcTime,
                    CreatedAfterDate  = startUtcTime,
                    Authors           = new[] { alias },
                    UserAgent         = "EECTES/WorkSummarizer 1.0"
                });

                if (result.Reviews == null)
                {
                    return(Enumerable.Empty <CodeFlowReview>());
                }

                return(result.Reviews
                       .Select(p =>
                {
                    return new CodeFlowReview
                    {
                        AuthorLogin = p.AuthorLogin,
                        PublishedUtcDate = p.CreatedOn.ToUniversalTime(),
                        ClosedUtcDate = p.CompletedOn.ToUniversalTime(),
                        Name = p.Name,
                        Reviewers = p.Reviewers.Select(s => IdentityUtility.Create(s.Name))
                    };
                })
                       .ToList());
            }
        }
Ejemplo n.º 19
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime,
                                                       Func <Event, bool> predicate)
        {
            var cfdp = new CodeFlowDataProvider();

            var retval = cfdp.PullData(startDateTime, stopDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date         = p.PublishedUtcDate,
                    Duration     = p.ClosedUtcDate - p.PublishedUtcDate,
                    Text         = p.Name,
                    Participants = p.Reviewers.ToGraph(),
                    EventType    = "CodeFlow.Author"
                };

                e.Participants.Add(IdentityUtility.Create(p.AuthorLogin));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
Ejemplo n.º 20
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime endDateTime, Func <Event, bool> predicate)
        {
            var source = new TeamFoundationServerWorkItemDataProvider(TeamFoundationServer, Project);
            var wis    = source.PullData(startDateTime, endDateTime);

            // Convert WI to Event
            var retval = new List <Event>();

            foreach (var wi in wis)
            {
                foreach (Revision r in wi.Revisions)
                {
                    var e = new Event();

                    e.Date      = (DateTime)r.Fields["Changed date"].Value;
                    e.Duration  = TimeSpan.Zero;
                    e.Text      = (string)r.Fields["History"].Value;
                    e.EventType = r.Index == 0 ? "TeamFoundationServer.WorkItem.Created" : "TeamFoundationServer.WorkItem.Revision";

                    if (r.Fields.Contains("State"))
                    {
                        var stateValue = r.Fields["State"].Value as string;
                        if (!string.IsNullOrWhiteSpace(stateValue))
                        {
                            if (
                                !string.Equals((string)r.Fields["State"].OriginalValue, (string)r.Fields["State"].Value,
                                               StringComparison.OrdinalIgnoreCase))
                            {
                                if (stateValue.Equals("Resolved", StringComparison.OrdinalIgnoreCase))
                                {
                                    e.EventType = "TeamFoundationServer.WorkItem.Resolved";
                                }
                                else if (stateValue.Equals("Closed", StringComparison.OrdinalIgnoreCase))
                                {
                                    e.EventType = "TeamFoundationServer.WorkItem.Closed";
                                }
                                else if (stateValue.Equals("Active", StringComparison.OrdinalIgnoreCase))
                                {
                                    e.EventType = "TeamFoundationServer.WorkItem.Activated";
                                }
                            }
                        }
                    }

                    e.Context = wi.Id;

                    if (e.Text.Contains(m_skipWorkItemWhenHistoryContainsText))
                    {
                        continue;
                    }

                    if (e.Date.Ticks > startDateTime.Ticks && e.Date.Ticks < endDateTime.Ticks)
                    {
                        var p = IdentityUtility.Create((string)r.Fields["Changed by"].Value);
                        e.Participants = new Graph <Participant> {
                            p
                        };

                        retval.Add(e);
                    }
                }
            }

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
        public dynamic Process(NancyModule nancyModule, AuthenticateCallbackData model)
        {
            ChatUser loggedInUser = null;

            if (nancyModule.Context.CurrentUser != null)
            {
                loggedInUser = _repository.GetUserById(nancyModule.Context.CurrentUser.UserName);
            }

            if (model.Exception == null)
            {
                UserInformation userInfo     = model.AuthenticatedClient.UserInformation;
                string          providerName = model.AuthenticatedClient.ProviderName;

                ChatUser user = _repository.GetUserByIdentity(providerName, userInfo.Id);

                // User with that identity doesn't exist, check if a user is logged in
                if (user == null)
                {
                    if (loggedInUser != null)
                    {
                        // Link to the logged in user
                        LinkIdentity(userInfo, providerName, loggedInUser);

                        // If a user is already logged in, then we know they could only have gotten here via the account page,
                        // so we will redirect them there
                        nancyModule.AddAlertMessage("success", String.Format("Successfully linked {0} account.", providerName));
                        return(nancyModule.Response.AsRedirect("~/account/#identityProviders"));
                    }
                    else
                    {
                        // Check the identity field to see if we need to migrate this user to the new
                        // non janrain identity model
                        string legacyIdentity = IdentityUtility.MakeLegacyIdentity(providerName, userInfo.Id);

                        if (legacyIdentity == null)
                        {
                            // No identity found so just add a new user
                            user = _membershipService.AddUser(userInfo.UserName, providerName, userInfo.Id, userInfo.Email);
                        }
                        else
                        {
                            // Try to get a legacy identity
                            user = _repository.GetUserByLegacyIdentity(legacyIdentity);

                            if (user == null)
                            {
                                // User doesn't exist
                                user = _membershipService.AddUser(userInfo.UserName, providerName, userInfo.Id, userInfo.Email);
                            }
                            else
                            {
                                // We found a legacy user via this id so convert them to the new format
                                LinkIdentity(userInfo, providerName, user);
                            }
                        }
                    }
                }
                else if (loggedInUser != null && user != loggedInUser)
                {
                    // You can't link an account that's already attached to another user
                    nancyModule.AddAlertMessage("error", String.Format("This {0} account has already been linked to another user.", providerName));

                    // If a user is logged in then we know they got here from the account page, and we should redirect them back there
                    return(nancyModule.Response.AsRedirect("~/account/#identityProviders"));
                }

                return(nancyModule.CompleteLogin(_authenticationTokenService, user));
            }

            nancyModule.AddAlertMessage("error", model.Exception.Message);

            // If a user is logged in, then they got here from the account page, send them back there
            if (loggedInUser != null)
            {
                return(nancyModule.Response.AsRedirect("~/account/#identityProviders"));
            }

            // At this point, send the user back to the root, everything else will work itself out
            return(nancyModule.Response.AsRedirect("~/"));
        }
Ejemplo n.º 22
0
        private ProcessingResult ProcessResult(
            KeyValuePair <ServiceRegistration, IEventQueryService> eventQueryServiceRegistration,
            Dispatcher uiDispatcher,
            DateTime selectedStartLocalTime,
            DateTime selectedEndLocalTime,
            int progressIncrement)
        {
            KeyValuePair <ServiceRegistration, IEventQueryService> registration1 = eventQueryServiceRegistration;
            var currentActivity = String.Format("Pulling data for {0} - {1}", registration1.Key.Family, registration1.Key.Name);

            try
            {
                uiDispatcher.Invoke(() => { ProgressStatus = String.Format("{0}...", currentActivity); });

                IEnumerable <Event> evts  = Enumerable.Empty <Event>();
                Action pullEventsDelegate =
                    () =>
                {
                    evts = registration1.Value.PullEvents(selectedStartLocalTime, (selectedEndLocalTime.AddDays(1).AddTicks(-1)),
                                                          Environment.UserName);
                };

                if (eventQueryServiceRegistration.Key.InvokeOnShellDispatcher)
                {
                    uiDispatcher.Invoke(pullEventsDelegate);
                }
                else
                {
                    pullEventsDelegate();
                }

                uiDispatcher.Invoke(() =>
                {
                    ProgressPercentage += progressIncrement;
                    ProgressStatus      = String.Format("Summarizing data for {0} - {1}...", registration1.Key.Family,
                                                        registration1.Key.Name);
                });

                var textProc   = new TextProcessor();
                var peopleProc = new PeopleProcessor();

                var sb = new StringBuilder();

                foreach (var evt in evts)
                {
                    sb.Append(evt.Text.Replace("\n", String.Empty).Replace("\r", String.Empty));
                }


                IDictionary <string, int> weightedPeople = peopleProc.GetTeam(evts);

                var customStopList = IdentityUtility.GetIdentityAttributes();

                var splitCustomStopList = new List <string>();

                foreach (var token in customStopList)
                {
                    splitCustomStopList.AddRange(token.Split(' '));
                }

                textProc.AddStopWords(splitCustomStopList);

                var nouns = textProc.GetNouns(sb.ToString());
                IDictionary <string, int> weightedTags       = textProc.GetNouns(sb.ToString());
                IEnumerable <string>      importantSentences = textProc.GetImportantEvents(evts.Select(x => x.Text), nouns);

                var result = new ProcessingResult
                {
                    EventSourceService = registration1.Key,
                    Events             = evts,
                    ImportantSentences = importantSentences,
                    WeightedPeople     = weightedPeople,
                    WeightedTags       = weightedTags
                };

                uiDispatcher.Invoke(() => { ProgressPercentage += progressIncrement; });
                return(result);
            }
            catch (AggregateException ex)
            {
                Trace.WriteLine("Aggregate inner exception: " + ex.InnerException);
                return(new ProcessingResult {
                    Exception = new ExceptionMessage(ex.InnerException, currentActivity)
                });
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                return(new ProcessingResult {
                    Exception = new ExceptionMessage(ex, currentActivity)
                });
            }
        }
        private async void OnGroupAccountEvent(GroupAccountEventArg arg)
        {
            if (arg != null && arg.Group != null)
            {
                string loggedInUserName = IdentityUtility.GetLoggedInUserName();
                switch (arg.ActionType)
                {
                case GroupAccountAction.GroupAdded:
                {
                    var groupDetail = new GroupDetail()
                    {
                        GroupID   = 0,
                        GroupName = arg.Group.Name
                    };

                    List <GroupFormRight> groupFormRights = new List <GroupFormRight>();
                    foreach (var form in arg.Group.Forms)
                    {
                        if (form.IsSelected)
                        {
                            GroupFormRight groupFormRight1 = new GroupFormRight()
                            {
                                FormID  = form.ID,
                                GroupID = form.Parent.GroupID,
                                Options = "ADD"
                            };

                            GroupFormRight groupFormRight2 = new GroupFormRight()
                            {
                                FormID  = form.ID,
                                GroupID = form.Parent.GroupID,
                                Options = "EDIT"
                            };

                            GroupFormRight groupFormRight3 = new GroupFormRight()
                            {
                                FormID  = form.ID,
                                GroupID = form.Parent.GroupID,
                                Options = "VIEW"
                            };

                            groupFormRights.Add(groupFormRight1);
                            groupFormRights.Add(groupFormRight2);
                            groupFormRights.Add(groupFormRight3);
                        }
                    }

                    var errorInfo = this.userManagementDb.UpdateGroup(groupDetail, "ADD", groupFormRights, loggedInUserName);
                    if (errorInfo.Code == 0)
                    {
                        this.Groups.Add(arg.Group);
                    }
                    else
                    {
                        await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("New Group", errorInfo.Info);
                    }
                    break;
                }

                case GroupAccountAction.GroupEdited:
                {
                    var groupDetail = new GroupDetail()
                    {
                        GroupID   = 0,
                        GroupName = arg.Group.Name
                    };

                    List <GroupFormRight> groupFormRights = new List <GroupFormRight>();
                    foreach (var form in arg.Group.Forms)
                    {
                        if (form.IsSelected)
                        {
                            GroupFormRight groupFormRight1 = new GroupFormRight()
                            {
                                FormID  = form.ID,
                                GroupID = form.Parent.GroupID,
                                Options = "ADD"
                            };

                            GroupFormRight groupFormRight2 = new GroupFormRight()
                            {
                                FormID  = form.ID,
                                GroupID = form.Parent.GroupID,
                                Options = "EDIT"
                            };

                            GroupFormRight groupFormRight3 = new GroupFormRight()
                            {
                                FormID  = form.ID,
                                GroupID = form.Parent.GroupID,
                                Options = "VIEW"
                            };

                            groupFormRights.Add(groupFormRight1);
                            groupFormRights.Add(groupFormRight2);
                            groupFormRights.Add(groupFormRight3);
                        }
                    }

                    var errorInfo = this.userManagementDb.UpdateGroup(groupDetail, "EDIT", groupFormRights, loggedInUserName);
                    if (errorInfo.Code == 0)
                    {
                    }
                    else
                    {
                        await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Edit Group", errorInfo.Info);
                    }
                    break;
                }

                case GroupAccountAction.GroupDeleted:
                {
                    var groupDetail = new GroupDetail()
                    {
                        GroupID   = 0,
                        GroupName = arg.Group.Name
                    };

                    List <GroupFormRight> groupFormRights = new List <GroupFormRight>();
                    foreach (var form in arg.Group.Forms)
                    {
                        GroupFormRight groupFormRight1 = new GroupFormRight()
                        {
                            FormID  = form.ID,
                            GroupID = form.Parent.GroupID,
                            Options = "ADD"
                        };

                        GroupFormRight groupFormRight2 = new GroupFormRight()
                        {
                            FormID  = form.ID,
                            GroupID = form.Parent.GroupID,
                            Options = "EDIT"
                        };

                        GroupFormRight groupFormRight3 = new GroupFormRight()
                        {
                            FormID  = form.ID,
                            GroupID = form.Parent.GroupID,
                            Options = "VIEW"
                        };

                        groupFormRights.Add(groupFormRight1);
                        groupFormRights.Add(groupFormRight2);
                        groupFormRights.Add(groupFormRight3);
                    }

                    var errorInfo = this.userManagementDb.UpdateGroup(groupDetail, "DELETE", groupFormRights, loggedInUserName);
                    if (errorInfo.Code == 0)
                    {
                        this.Groups.Remove(arg.Group);
                    }
                    else
                    {
                        await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Delete Group", errorInfo.Info);
                    }
                    break;
                }

                case GroupAccountAction.OperationFailed:
                {
                    await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Group Operation", "Unable to perform this operation");

                    break;
                }
                }
            }
        }
        private async void OnUserAccountEvent(UserAccountEventArg arg)
        {
            if (arg != null && arg.User != null)
            {
                string loggedInUserName = IdentityUtility.GetLoggedInUserName();
                switch (arg.ActionType)
                {
                case UserAccountAction.UserAdded:
                {
                    var userDetail = new UserDetail()
                    {
                        UserID   = 0,
                        Name     = arg.User.Name,
                        UserName = arg.User.Username,
                        Password = arg.User.Password,
                        GroupID  = arg.User.SelectedGroup.GroupID
                    };
                    var errorInfo = this.userManagementDb.UpdateUser(userDetail, "ADD", loggedInUserName);
                    if (errorInfo.Code == 0)
                    {
                        this.Users.Add(arg.User);
                    }
                    else
                    {
                        await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("New User", errorInfo.Info);
                    }
                    break;
                }

                case UserAccountAction.UserEdited:
                {
                    var userDetail = new UserDetail()
                    {
                        UserID   = arg.User.ID,
                        UserName = arg.User.Name,
                        //Password = arg.User.Password,
                        GroupID = arg.User.SelectedGroup.GroupID
                    };
                    var errorInfo = this.userManagementDb.UpdateUser(userDetail, "EDIT", loggedInUserName);
                    if (errorInfo.Code == 0)
                    {
                    }
                    else
                    {
                        await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Edit User", errorInfo.Info);
                    }
                    break;
                }

                case UserAccountAction.UserDeleted:
                {
                    var userDetail = new UserDetail()
                    {
                        UserID   = arg.User.ID,
                        Name     = arg.User.Name,
                        UserName = arg.User.Username,
                        Password = arg.User.Password,
                        GroupID  = arg.User.SelectedGroup.GroupID
                    };
                    var errorInfo = this.userManagementDb.UpdateUser(userDetail, "DELETE", loggedInUserName);
                    if (errorInfo.Code == 0)
                    {
                        this.Users.Remove(arg.User);
                    }
                    else
                    {
                        await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("Delete User", errorInfo.Info);
                    }
                    break;
                }

                case UserAccountAction.OperationFailed:
                {
                    await this.Container.Resolve <IMetroMessageDisplayService>(ServiceNames.MetroMessageDisplayService).ShowMessageAsnyc("User Operation", "Unable to perform this operation");

                    break;
                }
                }
            }
        }
Ejemplo n.º 25
0
 //业务方法
 public override void FromXmlData(XmlNode node)
 {
     this.KeyIdentity = IdentityUtility.NewClientIdentity();
     this.DisplayName = base.GetAttribute("DisplayName", node);
     this.LinkURL     = base.GetAttribute("Source", node);
 }