Example #1
0
 public MainViewModel(Community community, NavigationModel navigationModel, NewEntryModel newEntry, SynchronizationService synhronizationService)
 {
     _community = community;
     _navigationModel = navigationModel;
     _newEntry = newEntry;
     _synhronizationService = synhronizationService;
 }
 public ActivityViewModel(Community community, Individual individual, Quarter quarter, ActivitySelection activitySelection)
 {
     _community = community;
     _individual = individual;
     _quarter = quarter;
     _activitySelection = activitySelection;
 }
        public void Initialize()
        {
            var storage = IsolatedStorageStorageStrategy.Load();
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);
            var notification = new WindowsPhoneNotificationStrategy(http);
            communication.SetNotificationStrategy(notification);

            _community = new Community(storage);
            //_community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => _individual);

            _individual = _community.AddFact(new Individual(GetAnonymousUserId()));
            http.Individual = _individual;

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                Synchronize();
            };

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();
        }
        public void Initialize()
        {
            // TODO: Uncomment these lines to choose a database storage strategy.
            // string correspondenceConnectionString = ConfigurationManager.ConnectionStrings["Correspondence"].ConnectionString;
            // var storage = new SQLStorageStrategy(correspondenceConnectionString).UpgradeDatabase();

            string path = HostingEnvironment.MapPath("~/App_Data/Correspondence");
            var storage = new FileStreamStorageStrategy(path);
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => Domain);
            _community.ClientApp = false;

            LoadDomain();

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Resume in 5 minutes if there is an error.
            Timer synchronizeTimer = new Timer();
            synchronizeTimer.Elapsed += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = 5.0 * 60.0 * 1000.0;
            synchronizeTimer.Start();
        }
        public void Initialize()
        {
            POXConfigurationProvider configurationProvider = new POXConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new POXAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _navigationModel.CurrentUser)
                .Subscribe(() => _navigationModel.CurrentUser.SharedClouds)
                ;

            _navigationModel.CurrentUser = _community.AddFact(new Identity("mike2"));

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
        public void InitializeDesignMode()
        {
            _community = new Community(new MemoryStorageStrategy());
            _community.Register<CorrespondenceModel>();

            CreateIndidualDesignData();
        }
        public void Initialize()
        {
            string correspondenceDatabase = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "CorrespondenceApp", "Multinotes.Desktop", "Correspondence.sdf");
            var storage = new SSCEStorageStrategy(correspondenceDatabase);
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => Individual);
            _community.Subscribe(() => Individual.MessageBoards);

            CreateIndividual();

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
 public void RegisterAllFactTypes(Community community, IDictionary<Type, IFieldSerializer> fieldSerializerByType)
 {
     community.AddType(
         Individual._correspondenceFactType,
         new Individual.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { Individual._correspondenceFactType }));
 }
 public MainViewModel(Community community, Individual individual, Company company, ActivitySelection activitySelection)
 {
     _community = community;
     _individual = individual;
     _company = company;
     _activitySelection = activitySelection;
 }
Example #10
0
        private static void ServiceThreadProc()
        {
            // Load the correspondence database.
            string databaseFileName = Directory.ApplicationData / "FacetedWorlds" / "ReversiIdentificationService" / "Correspondence.sdf";

            Community community = new Community(new SSCEStorageStrategy(databaseFileName))
                .AddCommunicationStrategy(new WebServiceCommunicationStrategy())
                .Register<CorrespondenceModule>()
                .Subscribe(() => _service);

            _service = community.AddFact(new IdentityService());

            while (!_stop.WaitOne(TimeSpan.FromSeconds(15.0)))
            {
                try
                {
                    Synchronize(community);
                    if (RunService())
                        Synchronize(community);
                }
                catch (Exception ex)
                {
                    // Wait 1 minute between exceptions.
                    _stop.WaitOne(TimeSpan.FromMinutes(1.0));
                }
            }
        }
Example #11
0
        private void Application_Startup(
            object sender, StartupEventArgs e)
        {
            // Load the correspondence database.
            string databaseFileName = Directory.ApplicationData / "FacetedWorlds" / "Reversi" / "Correspondence.sdf";

            _community = new Community(new SSCEStorageStrategy(databaseFileName))
                .AddCommunicationStrategy(new WebServiceCommunicationStrategy())
                .Register<CorrespondenceModule>()
                .Subscribe(() => _machineViewModel.User)
                .Subscribe(() => _machineViewModel.User == null
                    ? Enumerable.Empty<Game>()
                    : _machineViewModel.User.ActivePlayers.Select(player => player.Game));

            // Recycle durations when the application is idle.
            DispatcherTimer timer = new DispatcherTimer(DispatcherPriority.ApplicationIdle);
            timer.Interval = TimeSpan.FromSeconds(1.0);
            timer.Tick += Timer_Tick;
            timer.Start();

            BeginDuration();

            // Display the main window.
            MainWindow = new View.MainWindow();
            MachineNavigationModel navigation = new MachineNavigationModel();
            _machineViewModel = new MachineViewModel(_community, navigation);
            MainWindow.DataContext = ForView.Wrap(_machineViewModel);
            MainWindow.Show();

            _synchronizationThread = new SynchronizationThread(_community);
            _community.FactAdded += () => _synchronizationThread.Wake();
            _synchronizationThread.Start();
        }
 public static void SetCookie(User user, Community community, int cookieExpireDate = 30)
 {
     HttpCookie myCookie = new HttpCookie(CookieName);
     myCookie["UserId"] = user.UserId.ToString();
     myCookie.Expires = DateTime.Now.AddDays(cookieExpireDate);
     HttpContext.Current.Response.Cookies.Add(myCookie);
 }
Example #13
0
 public OurMediaItem(Community.CsharpSqlite.SQLiteClient.SqliteConnection conn, int id)
 {
     // TODO: Complete member initialization
     this.conn = conn;
     this.id = id;
     checked_to_patron_id = -1;
 }
        public void Initialize()
        {
            var storage = IsolatedStorageStorageStrategy.Load();
            var http = new HTTPConfigurationProvider();
            var communication = new BinaryHTTPAsynchronousCommunicationStrategy(http);

            _community = new Community(storage);
            _community.AddAsynchronousCommunicationStrategy(communication);
            _community.Register<CorrespondenceModel>();
            _community.Subscribe(() => _individual);

            CreateIndividual();

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
        public MainViewModel(Community community, SynchronizationService synhronizationService, NewGameSelectionModel newGameSelection)
        {
            _community = community;
            _synhronizationService = synhronizationService;

            _newGame = new NewGameViewModel(synhronizationService.Domain, newGameSelection);
        }
Example #16
0
        public static Db.Community ToEntity(Community community)
        {
            if (community == null) return null;

            var members = community.Members != null
                ? community.Members.Select(UserMapper.ToEntity).ToList()
                : null;
            var posts = community.Posts != null
                ? community.Posts.Select(PostMapper.ToEntity).ToList()
                : null;
            var emblem = community.Emblem != null
                    ? (int?)community.Emblem.Id
                    : null;

            return new Db.Community
                {
                    Id = community.Id,
                    Name = community.Name,
                    Description = community.Description,
                    Members = members,
                    Posts = posts,
                    IsDeleted = community.IsDeleted,
                    LeaderUserId = community.Leader != null ? community.Leader.Id : 0,
                    Leader = null,
                    EmblemId = emblem,
                    IsPrivate = community.IsPrivate,
                    CreatedBy = community.CreatedBy,
                    CreatedDate = community.CreatedDate,
                    ModifiedBy = community.ModifiedBy,
                    ModifiedDate = community.ModifiedDate
                };
        }
        public void Initialize()
        {
            InitializeData();

            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _attendee.Conference)
                .Subscribe(() => _individual)
                .Subscribe(() => _attendee.ScheduledSessions)
                ;

            Individual identity = _community.AddFact(new Individual(GetAnonymousUserId()));
            _attendee = identity.GetAttendee(CommonSettings.ConferenceID);
            configurationProvider.Individual = identity;

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                Synchronize();
            };

            // Synchronize when the network becomes available.
            System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) =>
            {
                if (NetworkInterface.GetIsNetworkAvailable())
                    Synchronize();
            };

            // And synchronize on startup or resume.
            Synchronize();

            //DataLoader.Load(conference);
        }
        public void Initialize()
        {
            HTTPConfigurationProvider configurationProvider = new HTTPConfigurationProvider();
            _community = new Community(IsolatedStorageStorageStrategy.Load())
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(configurationProvider))
                .Register<CorrespondenceModel>();

            _domain = _community.AddFact(new Domain("Improving Enterprises"));
            _community.Subscribe(_domain);

            // Synchronize whenever the user has something to send.
            _community.FactAdded += delegate
            {
                _community.BeginSending();
            };

            // Periodically resume if there is an error.
            DispatcherTimer synchronizeTimer = new DispatcherTimer();
            synchronizeTimer.Tick += delegate
            {
                _community.BeginSending();
                _community.BeginReceiving();
            };
            synchronizeTimer.Interval = TimeSpan.FromSeconds(60.0);
            synchronizeTimer.Start();

            // And synchronize on startup.
            _community.BeginSending();
            _community.BeginReceiving();
        }
Example #19
0
        private static void WaitWhileSynchronizing(Community community)
        {
            while (community.Synchronizing)
                Thread.Sleep(1000);

            if (community.LastException != null)
                Console.WriteLine(community.LastException.Message);
        }
        public void Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<CorrespondenceModel>();

            _identity = _community.AddFact(new Identity("mike"));
            _viewModel = new HomeViewModel(_identity, new NavigationModel());
        }
Example #21
0
        public ForumSnapshot(Community community, string forum)
        {
            _forum = forum;

            _community = community;

            _storage = new List<ThreadInfo>();
        }
 public void RegisterAllFactTypes(Community community, IDictionary<Type, IFieldSerializer> fieldSerializerByType)
 {
     community.AddType(
         Individual._correspondenceFactType,
         new Individual.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { Individual._correspondenceFactType }));
     community.AddQuery(
         Individual._correspondenceFactType,
         Individual.GetQueryMessageBoards().QueryDefinition);
     community.AddQuery(
         Individual._correspondenceFactType,
         Individual.GetQueryShares().QueryDefinition);
     community.AddQuery(
         Individual._correspondenceFactType,
         Individual.GetQueryIsToastNotificationEnabled().QueryDefinition);
     community.AddType(
         Share._correspondenceFactType,
         new Share.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { Share._correspondenceFactType }));
     community.AddQuery(
         Share._correspondenceFactType,
         Share.GetQueryIsDeleted().QueryDefinition);
     community.AddUnpublisher(
         Share.GetRoleIndividual(),
         Condition.WhereIsEmpty(Share.GetQueryIsDeleted())
         );
     community.AddType(
         ShareDelete._correspondenceFactType,
         new ShareDelete.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { ShareDelete._correspondenceFactType }));
     community.AddType(
         MessageBoard._correspondenceFactType,
         new MessageBoard.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { MessageBoard._correspondenceFactType }));
     community.AddQuery(
         MessageBoard._correspondenceFactType,
         MessageBoard.GetQueryMessages().QueryDefinition);
     community.AddType(
         Domain._correspondenceFactType,
         new Domain.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { Domain._correspondenceFactType }));
     community.AddType(
         Message._correspondenceFactType,
         new Message.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { Message._correspondenceFactType }));
     community.AddType(
         EnableToastNotification._correspondenceFactType,
         new EnableToastNotification.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { EnableToastNotification._correspondenceFactType }));
     community.AddQuery(
         EnableToastNotification._correspondenceFactType,
         EnableToastNotification.GetQueryIsDisabled().QueryDefinition);
     community.AddType(
         DisableToastNotification._correspondenceFactType,
         new DisableToastNotification.CorrespondenceFactFactory(fieldSerializerByType),
         new FactMetadata(new List<CorrespondenceFactType> { DisableToastNotification._correspondenceFactType }));
 }
        public Community AllCommunity()
        {
            var community = new Community();
            community.Committers = _committerProvider.GetAllMembers();
            community.Contributors = _contributorProvider.GetAllContributors();
            community.Authors = _packageAuthorProvider.AllPackageAuthors();

            return community;
        }
 public SynchronizationThread(Community community)
 {
     _community = community;
     _thread = new Thread(SynchronizeProc);
     _thread.Name = "Correspondence synchronization thread";
     _stopping = new ManualResetEvent(false);
     _wake = new AutoResetEvent(false);
     _handles = new WaitHandle[] { _stopping, _wake };
 }
Example #25
0
        public Machine(string userName)
        {
            _community = new Community(new MemoryStorageStrategy())
                .AddAsynchronousCommunicationStrategy(new POXAsynchronousCommunicationStrategy(new POXConfigurationProvider()))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _user);

            _user = _community.AddFact(new User(userName));
        }
        public void Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<Model.CorrespondenceModel>();

            _identity = _community.AddFact(new Identity("mike"));
            Cloud cloud = _community.AddFact(new Cloud(_identity));
            _cloudViewModel = new CloudViewModel(cloud, new CloudNavigationModel(cloud));
        }
Example #27
0
        public void Add()
        {
            Community com = new Community();
            com.Lng = 112.546;
            com.Lat = 38.789;
            com.Name = "环球中心";

            long id = _areaContract.Add(com);
            Assert.AreNotEqual(0, id);
        }
Example #28
0
        public async Task Initialize()
        {
            _community = new Community(new MemoryStorageStrategy())
                .Register<CorrespondenceModel>();

            _company = await _community.AddFactAsync(new Company("improvingEnterprises"));
            _quarter = await _community.AddFactAsync(new Quarter(_company, new DateTime(2013, 1, 1)));
            _categoryGenerator = new CategoryGenerator(_community, _company, _quarter);
            await _categoryGenerator.GenerateAsync();
        }
        public void InitializeForDesignTime()
        {
            var storage = new MemoryStorageStrategy();

            _community = new Community(storage);
            _community.Register<CorrespondenceModel>();

            Individual individual = _community.AddFactAsync(new Individual("DesignTimeUser")).Result;
            var conference = _community.AddFactAsync(new Conference(CommonSettings.ConferenceID)).Result;
            _individual.Value = individual;
            _conference.Value = conference;
        }
Example #30
0
        static void Main(string[] args)
        {
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FacetedWorlds", "MyConSurveys");
            Community community = new Community(FileStreamStorageStrategy.Load(path))
                .AddAsynchronousCommunicationStrategy(new BinaryHTTPAsynchronousCommunicationStrategy(new HTTPConfigurationProvider()))
                .Register<CorrespondenceModel>()
                .Subscribe(() => _conference)
                .Subscribe(() => _conference.AllSessionSurveys);

            _conference = community.AddFact(new Conference(CommonSettings.ConferenceID));

            Console.WriteLine("Receiving facts.");
            community.BeginReceiving();
            WaitWhileSynchronizing(community);

            var completedSurveys =
                from survey in _conference.AllSessionSurveys
                from completed in survey.Completed
                select new
                {
                    SessionName = completed.SessionEvaluation.Schedule.SessionPlace.Session.Name,
                    SpeakerName = completed.SessionEvaluation.Schedule.SessionPlace.Session.Speaker.Name,
                    Ratings =
                        from ratingAnswer in completed.SessionEvaluation.RatingAnswers
                        select new
                        {
                            Question = ratingAnswer.Rating.Question.Text,
                            Answer = ratingAnswer.Value
                        },
                    Essays =
                        from essayAnswer in completed.SessionEvaluation.EssayAnswers
                        select new
                        {
                            Question = essayAnswer.Essay.Question.Text,
                            Answer = essayAnswer.Value
                        }
                };

            foreach (var completedSurvey in completedSurveys)
            {
                Console.WriteLine(completedSurvey.SessionName);
                Console.WriteLine(completedSurvey.SpeakerName);
                foreach (var rating in completedSurvey.Ratings)
                    Console.WriteLine(String.Format("{0}: {1}", rating.Question, rating.Answer));
                foreach (var essay in completedSurvey.Essays)
                    Console.WriteLine(String.Format("{0}: {1}", essay.Question, essay.Answer));
                Console.WriteLine();
            }

            Console.WriteLine("Finished.");
            Console.ReadKey();
        }
Example #31
0
        public void TypedList_Basics()
        {
            Community c = new Community();

            List <Person> people = new List <Person>
            {
                new Person(c)
                {
                    Name = "One"
                },
                new Person(c)
                {
                    Name = "Two"
                },
                new Person(c)
                {
                    Name = "Three"
                }
            };

            // Null by default
            Assert.Null(c.People);

            // Settable to Empty
            c.People = Array.Empty <Person>();

            TypedList <Person> list = (TypedList <Person>)c.People;

            Assert.Empty(list);

            list.Add(people[0]);
            Assert.Single(list);

            list.Add(people[1]);
            list.Add(people[2]);
            CollectionReadVerifier.VerifySame(people, list);

            // SetTo self works properly
            list.SetTo(list);
            CollectionReadVerifier.VerifySame(people, list);

            // SetTo null works
            list.SetTo(null);
            Assert.Empty(list);

            // SetTo other works
            list.SetTo(people);
            CollectionReadVerifier.VerifySame(people, list);

            // Test Equality members
            CollectionReadVerifier.VerifyEqualityMembers(list, list);

            // Test equality operators
#pragma warning disable CS1718 // Comparison made to same variable
            Assert.True(list == list);
            Assert.False(list != list);
#pragma warning restore CS1718 // Comparison made to same variable

            Assert.False(list == null);
            Assert.True(list != null);

            Assert.False(null == list);
            Assert.True(null != list);

            // SetTo empty works
            list.SetTo(new List <Person>());
            Assert.Empty(list);

            CollectionChangeVerifier.VerifyList(c.People, (i) => new Person(c)
            {
                Age = (byte)i
            });

            // Set null
            IList <Person> cachedPeople = c.People;
            c.People = null;
            Assert.Null(c.People);
            Assert.Equal(0, cachedPeople.Count);

            // SetTo TypedList from another DB/Table
            Community c2 = new Community();
            c2.People = new List <Person>();
            c2.People.Add(new Person(c2)
            {
                Name = "Other"
            });
            list.SetTo(c2.People);

            Assert.Equal("Other", list[0].Name);
        }
Example #32
0
 public override TemplateEmail GeneratePreview(Community community)
 {
     return(new CandidateLookingNotificationEmail(CreateMember(community)));
 }
Example #33
0
 public void AddSchedule(SessionPlace sessionPlace)
 {
     Community.AddFact(new Schedule(this, sessionPlace));
 }
Example #34
0
 public CommunityRecipe AddCommunityRecipe(Community community, Recipe recipe)
 {
     return(_unitOfWork.CommunityRecipe.AddFromEntities(community, recipe));
 }
Example #35
0
        public IActionResult Update(Community c)
        {
            int h = _bll.Update(c);

            return(Ok(new { data = h, sate = h > 0 ? true : false, msg = h > 0 ? "编辑成功" : "编辑失败" }));
        }
 public void Dispose()
 {
     Blog.ClearAll();
     Post.ClearAll();
     Community.ClearAll();
 }
Example #37
0
 public async Task <bool> IsUserSubscribed(ApplicationUser user, Community community)
 {
     return(await _context.UserCommunity.AnyAsync(x => x.Community == community && x.User == user));
 }
Example #38
0
    private void Start()
    {
        com = GetComponent <Community>();

        com.totalWealth = startWealth;

        for (int i = 0; i < cList.Count; i++)
        {
            CommunityCulture cc   = cList[i];
            Culture          cult = cc.cCult;

            cc.cPop      *= startPop;
            cc.cWealth   *= startWealth;
            cc.cMarriage *= startPop;

            if (com.residentCultures.Contains(cult) == false)
            {
                com.residentCultures.Add(cult);
            }

            float cPop = cList[i].cPop;

            for (int a = 0; a < cPop; a++)
            {
                GameObject citizen = Instantiate(prefab);
                citizen.transform.SetParent(civPool.transform);
                Citizen c = citizen.GetComponent <Citizen>();
                c.culture = cult;

                c.home = gameObject;
                com.citizens.Add(c);

                c.education = Random.Range(1, cc.education);
                cc.citList.Add(c);

                c.cultureDiscr   = cultureDiscr;
                c.religiousDiscr = religiousDiscr;

                c.religiousity = Random.Range(cc.faithMin, cc.faithMax);

                c.Basics();
                c.Randomizer();
            }

            float total         = 0;
            float partnerSearch = cc.cMarriage;

            for (int b = 0; b < cc.citList.Count; b++)
            {
                Citizen c = cc.citList[b];

                c.wealthPart = Random.Range(0, cc.cWKey);
                total       += c.wealthPart;

                c.age = Random.Range(18, cc.cAge);

                if (partnerSearch > 0)
                {
                    c.onSearch     = true;
                    partnerSearch -= 1;
                }
            }

            for (int b = 0; b < cc.citList.Count; b++)
            {
                Citizen c = cc.citList[b];

                c.wealthPart /= total;
                c.wealth     += c.wealthPart * cc.cWealth;
            }
        }

        for (int c = 0; c < com.citizens.Count; c++)
        {
            Citizen cit = com.citizens[c];

            if (cit.onSearch)
            {
                Debug.Log("Searching!");
                cit.SearchPartner();
            }

            cit.power = cit.wealthPart * com.citizens.Count;
        }
    }
        public void InitView(String editorConfigurationPath, System.Guid currentWorkingApplicationId)
        {
            NoticeboardMessage message = null;

            EditorConfiguration config = ServiceEditor.GetConfiguration(editorConfigurationPath);

            if (config != null)
            {
                ModuleEditorSettings mSettings = (config.ModuleSettings == null) ? null : config.ModuleSettings.Where(m => m.ModuleCode == ModuleNoticeboard.UniqueID).FirstOrDefault();
                if (mSettings == null && config.CssFiles.Any())
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && mSettings.CssFiles.Any() && mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, mSettings.CssFiles);
                }
                else if (mSettings != null && mSettings.CssFiles != null && !mSettings.OvverideCssFileSettings)
                {
                    View.PreloadCssFiles(config.DefaultCssFilesPath, config.CssFiles);
                }
            }

            long idMessage   = View.PreloadedIdMessage;
            int  IdCommunity = View.PreloadedIdCommunity;

            if (idMessage != 0)
            {
                message = Service.GetMessage(idMessage);
            }
            else
            {
                message = Service.GetLastMessage(IdCommunity);
                if (message != null)
                {
                    idMessage = message.Id;
                }
            }
            if (message != null && message.Community != null)
            {
                IdCommunity = message.Community.Id;
            }
            else if (message != null && message.isForPortal)
            {
                IdCommunity = 0;
            }
            else
            {
                IdCommunity = UserContext.WorkingCommunityID;
            }

            Community community = null;

            if (IdCommunity > 0)
            {
                community = CurrentManager.GetCommunity(IdCommunity);
            }
            if (community == null && IdCommunity > 0)
            {
                View.ContainerName = "";
            }
            else if (community != null)
            {
                View.ContainerName = community.Name;
            }
            else
            {
                View.ContainerName = View.PortalName;
            }

            Boolean anonymousViewAllowed = (View.PreloadWorkingApplicationId != Guid.Empty && View.PreloadWorkingApplicationId == currentWorkingApplicationId);

            if (message == null && idMessage > 0)
            {
                View.DisplayUnknownMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewUnknownMessage);
            }
            else if (message == null && idMessage == 0)
            {
                View.DisplayEmptyMessage();
                View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewEmptyMessage);
            }
            else if (UserContext.isAnonymous && !anonymousViewAllowed)
            {
                View.DisplaySessionTimeout();
            }
            else
            {
                View.IdCurrentMessage = idMessage;

                ModuleNoticeboard module = null;
                if (IdCommunity == 0 && message.isForPortal)
                {
                    module = ModuleNoticeboard.CreatePortalmodule((UserContext.isAnonymous) ? (int)UserTypeStandard.Guest : UserContext.UserTypeID);
                }
                else if (IdCommunity > 0)
                {
                    module = new ModuleNoticeboard(CurrentManager.GetModulePermission(UserContext.CurrentUserID, IdCommunity, ModuleID));
                }
                else
                {
                    module = new ModuleNoticeboard();
                }
                if (module.Administration || module.ViewCurrentMessage || module.ViewOldMessage || anonymousViewAllowed)
                {
                    View.DisplayMessage(message);
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.ViewMessage);
                }
                else
                {
                    View.DisplayNoPermission();
                    View.SendUserAction(IdCommunity, ModuleID, idMessage, ModuleNoticeboard.ActionType.NoPermission);
                }
            }
        }
Example #40
0
 public void Add(Community Community)
 {
     _context.Communities.Add(Community);
     _context.SaveChanges();
 }
        private async Task CreateCommunity()
        {
            ManagerUserInfo = await CreateTestUser();

            ActiveUserInfo = await CreateTestUser();

            InvitedUserInfo = await CreateTestUser();

            var communityId = Guid.NewGuid().ToString();
            var bar         = new Bar()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Default",
                CommunityId = communityId,
                IsShared    = true,
                CreatedAt   = DateTime.Now
            };
            await Database.Save(bar);

            bar = new Bar()
            {
                Id          = Guid.NewGuid().ToString(),
                Name        = "Bar 2",
                CommunityId = communityId,
                IsShared    = true,
                CreatedAt   = DateTime.Now,
                Items       = new BarItem[] {
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        IsPrimary     = true,
                        Configuration = new Dictionary <string, object>()
                        {
                            { "url", "https://google.com" },
                            { "label", "Google" }
                        }
                    },
                    new BarItem()
                    {
                        Kind          = BarItemKind.Link,
                        IsPrimary     = true,
                        Configuration = new Dictionary <string, object>()
                        {
                            { "url", "https://facebook.com" },
                            { "label", "Facebook" }
                        }
                    }
                }
            };
            await Database.Save(bar);

            Community = new Community()
            {
                Id           = communityId,
                Name         = "Test Community",
                DefaultBarId = bar.Id
            };
            await Database.Save(Community);

            Manager = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                UserId      = ManagerUserInfo.Id,
                State       = MemberState.Active,
                Role        = MemberRole.Manager
            };
            Manager.FirstName.PlainText = "Manager";
            Manager.LastName.PlainText  = "Tester";
            await Database.Save(Manager);

            ActiveMember = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                UserId      = ActiveUserInfo.Id,
                State       = MemberState.Active,
                Role        = MemberRole.Member
            };
            ActiveMember.FirstName.PlainText = "Active";
            ActiveMember.LastName.PlainText  = "Member";
            await Database.Save(ActiveMember);

            InvitedMember = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                State       = MemberState.Invited,
                Role        = MemberRole.Member
            };
            InvitedMember.FirstName.PlainText = "Invited";
            InvitedMember.LastName.PlainText  = "Person";
            await Database.Save(InvitedMember);

            UninvitedMember = new Member()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                State       = MemberState.Uninvited,
                Role        = MemberRole.Member
            };
            InvitedMember.FirstName.PlainText = "Uninvited";
            InvitedMember.LastName.PlainText  = "Person";
            await Database.Save(UninvitedMember);

            Invitation = new Invitation()
            {
                Id          = Guid.NewGuid().ToString(),
                CommunityId = Community.Id,
                MemberId    = InvitedMember.Id,
                CreatedAt   = DateTime.Now,
                ExpiresAt   = DateTime.Now.AddDays(14),
                SentAt      = DateTime.Now
            };
            Invitation.Email.PlainText = "*****@*****.**";
            await Database.Save(Invitation);
        }
Example #42
0
 public void Remove(Community Community)
 {
     _context.Communities.Remove(Community);
     _context.SaveChanges();
 }
Example #43
0
        public override TemplateEmail GeneratePreview(Community community)
        {
            var employer = CreateEmployer();

            return(new EmployerReportEmail(employer, CreateAdministrator(), new ResumeSearchActivityReport(), employer.Organisation, DateTime.Now.Date.AddDays(-31), DateTime.Now.Date.AddDays(-1)));
        }
Example #44
0
        public void Run()
        {
            var model = CommunityModel.GetInstance();

            // Create Communitties
            #region
            var announcements = new Community()
            {
                Id = 0, Name = "announcements"
            };
            var funny = new Community()
            {
                Id = 1, Name = "funny"
            };
            var askcommunity = new Community()
            {
                Id = 2, Name = "askcommunity"
            };
            var gaming = new Community()
            {
                Id = 3, Name = "gaming"
            };
            var aww = new Community()
            {
                Id = 4, Name = "aww"
            };
            var music = new Community()
            {
                Id = 5, Name = "music"
            };
            var science = new Community()
            {
                Id = 6, Name = "science"
            };
            var worldnews = new Community()
            {
                Id = 7, Name = "worldnews"
            };
            var todayilearned = new Community()
            {
                Id = 8, Name = "todayilearned"
            };
            var movies = new Community()
            {
                Id = 9, Name = "movies"
            };
            var tech = new Community()
            {
                Id = 10, Name = "tech"
            };
            var showerthoughts = new Community()
            {
                Id = 11, Name = "showerthoughts"
            };
            var jokes = new Community()
            {
                Id = 12, Name = "jokes"
            };
            var books = new Community()
            {
                Id = 13, Name = "books"
            };
            var mildlyinteresting = new Community()
            {
                Id = 14, Name = "mildlyinteresting"
            };
            var sports = new Community()
            {
                Id = 15, Name = "sports"
            };
            #endregion

            // Add Communities
            #region
            model.Communities.Insert(announcements);
            model.Communities.Insert(funny);
            model.Communities.Insert(askcommunity);
            model.Communities.Insert(gaming);
            model.Communities.Insert(aww);
            model.Communities.Insert(music);
            model.Communities.Insert(science);
            model.Communities.Insert(worldnews);
            model.Communities.Insert(todayilearned);
            model.Communities.Insert(movies);
            model.Communities.Insert(tech);
            model.Communities.Insert(showerthoughts);
            model.Communities.Insert(jokes);
            model.Communities.Insert(books);
            model.Communities.Insert(mildlyinteresting);
            model.Communities.Insert(sports);
            #endregion

            // Create Users
            #region
            var lepegen = new User()
            {
                Id = 0, Name = "lepegen", Password = "******"
            };
            var citylightsbird = new User()
            {
                Id = 1, Name = "citylightsbird", Password = "******"
            };
            var cucumberapple = new User()
            {
                Id = 2, Name = "cucumberapple", Password = "******"
            };
            var pathsofgloryfog = new User()
            {
                Id = 3, Name = "pathsofgloryfog", Password = "******"
            };
            var animaltracksnet = new User()
            {
                Id = 4, Name = "animaltracksnet", Password = "******"
            };
            var lastradawalker = new User()
            {
                Id = 5, Name = "lastradawalker", Password = "******"
            };
            var runningstardust = new User()
            {
                Id = 6, Name = "runningstardust", Password = "******"
            };
            var broccolipotato = new User()
            {
                Id = 7, Name = "broccolipotato", Password = "******"
            };
            var bridgebaseball = new User()
            {
                Id = 8, Name = "bridgebaseball", Password = "******"
            };
            var spiralshapefig = new User()
            {
                Id = 9, Name = "spiralshapefig", Password = "******"
            };
            var marsexpresscane = new User()
            {
                Id = 10, Name = "marsexpresscane", Password = "******"
            };
            var walruspandabird = new User()
            {
                Id = 11, Name = "walruspandabird", Password = "******"
            };
            var rearwindowowl = new User()
            {
                Id = 12, Name = "rearwindowowl", Password = "******"
            };
            var owlsilverberry = new User()
            {
                Id = 13, Name = "owlsilverberry", Password = "******"
            };
            var yogapianosalt = new User()
            {
                Id = 14, Name = "yogapianosalt", Password = "******"
            };
            #endregion

            // Add Communities to Users
            #region
            foreach (var item in new[] { askcommunity, funny, announcements, showerthoughts, tech, todayilearned })
            {
                lepegen.Communities.Insert(item);
            }
            foreach (var item in new[] { books, worldnews, todayilearned, gaming })
            {
                citylightsbird.Communities.Insert(item);
            }
            foreach (var item in new[] { tech, mildlyinteresting, announcements, worldnews, todayilearned })
            {
                cucumberapple.Communities.Insert(item);
            }
            foreach (var item in new[] { movies, showerthoughts, aww, science, music, sports, todayilearned, announcements, gaming, askcommunity, funny })
            {
                pathsofgloryfog.Communities.Insert(item);
            }
            foreach (var item in new[] { movies, announcements, books, askcommunity, science })
            {
                animaltracksnet.Communities.Insert(item);
            }
            foreach (var item in new[] { funny, music, askcommunity, announcements, sports, gaming, aww })
            {
                lastradawalker.Communities.Insert(item);
            }
            foreach (var item in new[] { books, science, worldnews, movies, music, askcommunity })
            {
                runningstardust.Communities.Insert(item);
            }
            foreach (var item in new[] { movies, sports, tech, gaming, showerthoughts })
            {
                broccolipotato.Communities.Insert(item);
            }
            foreach (var item in new[] { movies, books, aww, gaming, science, announcements, tech, askcommunity, jokes })
            {
                bridgebaseball.Communities.Insert(item);
            }
            foreach (var item in new[] { announcements, gaming, mildlyinteresting, sports, jokes, askcommunity, science, showerthoughts, music, aww, funny, worldnews, todayilearned, books, movies })
            {
                spiralshapefig.Communities.Insert(item);
            }
            foreach (var item in new[] { mildlyinteresting, gaming, tech, books, funny, jokes, movies, worldnews })
            {
                marsexpresscane.Communities.Insert(item);
            }
            foreach (var item in new[] { todayilearned, books, showerthoughts, jokes, music, gaming, sports, movies })
            {
                walruspandabird.Communities.Insert(item);
            }
            foreach (var item in new[] { todayilearned, science, tech, music, gaming, sports, movies, showerthoughts })
            {
                rearwindowowl.Communities.Insert(item);
            }
            foreach (var item in new[] { music, worldnews, announcements, funny, showerthoughts, books, askcommunity, todayilearned })
            {
                owlsilverberry.Communities.Insert(item);
            }
            foreach (var item in new[] { movies, funny, books, jokes, mildlyinteresting, music, todayilearned, aww, science, sports, worldnews, askcommunity, showerthoughts })
            {
                yogapianosalt.Communities.Insert(item);
            }
            #endregion

            // Add Users
            #region
            model.Users.AddVertex(lepegen);         // X
            model.Users.AddVertex(citylightsbird);  // X
            model.Users.AddVertex(cucumberapple);   // X
            model.Users.AddVertex(pathsofgloryfog); // X
            model.Users.AddVertex(animaltracksnet); // X
            model.Users.AddVertex(lastradawalker);  // X
            model.Users.AddVertex(runningstardust); // X
            model.Users.AddVertex(broccolipotato);  // X
            model.Users.AddVertex(bridgebaseball);  // X
            model.Users.AddVertex(spiralshapefig);  // X
            model.Users.AddVertex(marsexpresscane); // X
            model.Users.AddVertex(walruspandabird); // X
            model.Users.AddVertex(rearwindowowl);   // X
            model.Users.AddVertex(owlsilverberry);  // X
            model.Users.AddVertex(yogapianosalt);
            #endregion

            // Follow Other Users
            #region
            model.Users.AddEdge(lepegen, citylightsbird, 1);
            model.Users.AddEdge(lepegen, cucumberapple, 1);
            model.Users.AddEdge(lepegen, pathsofgloryfog, 1);
            model.Users.AddEdge(lepegen, animaltracksnet, 1);
            model.Users.AddEdge(lepegen, lastradawalker, 1);



            model.Users.AddEdge(citylightsbird, walruspandabird, 1);

            model.Users.AddEdge(cucumberapple, yogapianosalt, 1);

            model.Users.AddEdge(pathsofgloryfog, bridgebaseball, 1);
            model.Users.AddEdge(pathsofgloryfog, owlsilverberry, 1);
            model.Users.AddEdge(pathsofgloryfog, broccolipotato, 1);

            model.Users.AddEdge(animaltracksnet, spiralshapefig, 1);
            model.Users.AddEdge(animaltracksnet, owlsilverberry, 1);

            model.Users.AddEdge(bridgebaseball, broccolipotato, 1);
            model.Users.AddEdge(bridgebaseball, marsexpresscane, 1);

            model.Users.AddEdge(spiralshapefig, lepegen, 1);

            model.Users.AddEdge(marsexpresscane, lepegen, 1);
            model.Users.AddEdge(marsexpresscane, bridgebaseball, 1);
            model.Users.AddEdge(marsexpresscane, spiralshapefig, 1);
            model.Users.AddEdge(marsexpresscane, cucumberapple, 1);
            model.Users.AddEdge(marsexpresscane, pathsofgloryfog, 1);
            model.Users.AddEdge(marsexpresscane, citylightsbird, 1);
            model.Users.AddEdge(marsexpresscane, rearwindowowl, 1);

            model.Users.AddEdge(owlsilverberry, rearwindowowl, 1);
            model.Users.AddEdge(owlsilverberry, lastradawalker, 1);
            model.Users.AddEdge(owlsilverberry, lepegen, 1);

            model.Users.AddEdge(yogapianosalt, marsexpresscane, 1);
            #endregion

            // Add Posts to Users
            #region
            var post1 = new UserPost()
            {
                ID = 0, DatePosted = DateTime.Parse("9/11/2020"), Text = "Welcome to Community", Community = announcements, User = lepegen
            };
            lepegen.Posts.Push(post1); announcements.Posts.Push(post1);

            var post2 = new UserPost()
            {
                ID = 1, DatePosted = DateTime.Parse("9/12/2020"), Text = "E", Community = funny, User = citylightsbird
            };
            citylightsbird.Posts.Push(post2); funny.Posts.Push(post2);

            var post3 = new UserPost()
            {
                ID = 2, DatePosted = DateTime.Parse("9/13/2020"), Text = "What's", Community = askcommunity, User = cucumberapple
            };
            cucumberapple.Posts.Push(post3); askcommunity.Posts.Push(post3);

            var post4 = new UserPost()
            {
                ID = 3, DatePosted = DateTime.Parse("9/14/2020"), Text = "Xbox Series X Unboxing", Community = gaming, User = pathsofgloryfog
            };
            pathsofgloryfog.Posts.Push(post4); gaming.Posts.Push(post4);

            var post5 = new UserPost()
            {
                ID = 4, DatePosted = DateTime.Parse("9/15/2020"), Text = "It's my dog's 3rd birthday today :D", Community = aww, User = runningstardust
            };
            runningstardust.Posts.Push(post5); aww.Posts.Push(post5);

            var post6 = new UserPost()
            {
                ID = 5, DatePosted = DateTime.Parse("9/15/2020"), Text = "The Beatles - Here Comes the Sun", Community = music, User = lastradawalker
            };
            lastradawalker.Posts.Push(post6); music.Posts.Push(post6);

            var post7 = new UserPost()
            {
                ID = 6, DatePosted = DateTime.Parse("9/16/2020"), Text = "Water discoverd on the moon", Community = science, User = runningstardust
            };
            runningstardust.Posts.Push(post7); science.Posts.Push(post7);

            var post8 = new UserPost()
            {
                ID = 7, DatePosted = DateTime.Parse("9/17/2020"), Text = "Typhoon hit philippines devasted", Community = worldnews, User = broccolipotato
            };
            broccolipotato.Posts.Push(post8); worldnews.Posts.Push(post8);

            var post9 = new UserPost()
            {
                ID = 8, DatePosted = DateTime.Parse("9/18/2020"), Text = "TIL Socrates taught Plato, Plato taught Aristotle, and Aristotle taught Alexander the Great", Community = todayilearned, User = bridgebaseball
            };
            bridgebaseball.Posts.Push(post9); todayilearned.Posts.Push(post9);

            var post10 = new UserPost()
            {
                ID = 9, DatePosted = DateTime.Parse("9/19/2020"), Text = "Hot Fuzz(2007)", Community = movies, User = spiralshapefig
            };
            spiralshapefig.Posts.Push(post10); movies.Posts.Push(post10);

            var post11 = new UserPost()
            {
                ID = 10, DatePosted = DateTime.Parse("10/11/2020"), Text = "IPhone X Released", Community = tech, User = marsexpresscane
            };
            marsexpresscane.Posts.Push(post11); tech.Posts.Push(post11);

            var post12 = new UserPost()
            {
                ID = 11, DatePosted = DateTime.Parse("10/13/2020"), Text = "You have proberly seen more of the moons surface than you have earth's", Community = showerthoughts, User = walruspandabird
            };
            walruspandabird.Posts.Push(post12); showerthoughts.Posts.Push(post12);

            var post13 = new UserPost()
            {
                ID = 12, DatePosted = DateTime.Parse("10/15/2020"), Text = "I taught a wolf to meditate Now he’s aware wolf", Community = jokes, User = rearwindowowl
            };
            rearwindowowl.Posts.Push(post13); jokes.Posts.Push(post13);

            var post14 = new UserPost()
            {
                ID = 13, DatePosted = DateTime.Parse("10/16/2020"), Text = "1984 George Orwell", Community = books, User = owlsilverberry
            };
            owlsilverberry.Posts.Push(post14); books.Posts.Push(post14);

            var post15 = new UserPost()
            {
                ID = 14, DatePosted = DateTime.Parse("10/16/2020"), Text = "The A key on my keyboard is half A and half Q.", Community = mildlyinteresting, User = yogapianosalt
            };
            yogapianosalt.Posts.Push(post15); mildlyinteresting.Posts.Push(post15);

            var post16 = new UserPost()
            {
                ID = 15, DatePosted = DateTime.Parse("10/17/2020"), Text = "Barca - Alaves", Community = sports, User = lepegen
            };
            lepegen.Posts.Push(post16); sports.Posts.Push(post16);

            var post17 = new UserPost()
            {
                ID = 16, DatePosted = DateTime.Parse("10/17/2020"), Text = "v1.1 Now Up :D", Community = announcements, User = citylightsbird
            };
            citylightsbird.Posts.Push(post17); announcements.Posts.Push(post17);

            var post18 = new UserPost()
            {
                ID = 17, DatePosted = DateTime.Parse("10/18/2020"), Text = "I ran 3 miles yesterday Eventually I just said “here keep your purse”", Community = funny, User = cucumberapple
            };
            cucumberapple.Posts.Push(post18); funny.Posts.Push(post18);

            var post19 = new UserPost()
            {
                ID = 18, DatePosted = DateTime.Parse("10/18/2020"), Text = "How is everybody doing?", Community = askcommunity, User = animaltracksnet
            };
            animaltracksnet.Posts.Push(post19); askcommunity.Posts.Push(post19);

            var post20 = new UserPost()
            {
                ID = 19, DatePosted = DateTime.Parse("10/19/2020"), Text = "Watch Dogs: Legion now released", Community = gaming, User = rearwindowowl
            };
            rearwindowowl.Posts.Push(post20); gaming.Posts.Push(post20);
            #endregion
        }
Example #45
0
        public ActionResult OAdd(Community entity)
        {
            OperationResult or = CommunityService.Add(entity);

            return(this.JsonFormat(or));
        }
 public List <Community> GetCommunities()
 {
     return(Community.All().ToList());
 }
Example #47
0
 public void Leave()
 {
     Community.AddFactAsync(new ShareDelete(this));
 }
 private void OnFormClosed(object sender, FormClosedEventArgs e)
 {
     Community.Remove(Name);
 }
Example #49
0
        public IActionResult Insert(Community c)
        {
            int h = _bll.Insert(c);

            return(Ok(new { data = h, sate = h > 0 ? true : false, msg = h > 0 ? "添加成功" : "添加失败" }));
        }
Example #50
0
 public SessionEvaluationRating Rating(RatingQuestion question)
 {
     return(Community.AddFact(new SessionEvaluationRating(this, question)));
 }
 protected override Member CreateMember(int index, Community community)
 {
     return(null);
 }
 public EmployerCommunityEnquiryEmail(Community community, AffiliationEnquiry enquiry)
     : base(GetUnregisteredEmployer(enquiry.EmailAddress, enquiry.FirstName, enquiry.LastName))
 {
     _community = community;
     _enquiry   = enquiry;
 }
Example #53
0
 public MainViewModel(Community community, NavigationModel navigationModel, SynchronizationService synhronizationService)
 {
     _community             = community;
     _navigationModel       = navigationModel;
     _synhronizationService = synhronizationService;
 }
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, FlaggedRequest request)
        {
            if (thisObject == null)
            {
                thisObject = new EmailRequest();
            }

            ICommunityRepository communityRepository = DependencyResolver.Current.GetService(typeof(ICommunityRepository)) as ICommunityRepository;
            IContentRepository   contentRepository   = DependencyResolver.Current.GetService(typeof(IContentRepository)) as IContentRepository;

            IEnumerable <User> approvers = new List <User>();

            string entityName = string.Empty;

            if (request.EntityType == EntityType.Content)
            {
                Content content = contentRepository.GetItem(c => c.ContentID == request.ID);
                if (content != null)
                {
                    if (content.CommunityContents.Count > 0)
                    {
                        approvers = communityRepository.GetApprovers(Enumerable.ElementAt <CommunityContents>(content.CommunityContents, 0).CommunityID);
                    }

                    approvers.Concat(new[] { content.User });
                    entityName = content.Title;
                }
            }
            else
            {
                approvers = communityRepository.GetApprovers(request.ID);
                Community community = communityRepository.GetItem(c => c.CommunityID == request.ID);
                if (community != null)
                {
                    entityName = community.Name;
                }
            }

            foreach (User user in approvers)
            {
                if (user.IsSubscribed)
                {
                    thisObject.Recipients.Add(new MailAddress(user.Email.FixEmailAddress(), user.FirstName + " " + user.LastName));
                }
            }

            IUserRepository userRepository = DependencyResolver.Current.GetService(typeof(IUserRepository)) as IUserRepository;
            User            requestor      = userRepository.GetItem(u => u.UserID == request.UserID);

            thisObject.IsHtml = true;

            // Update the body and the subject.
            thisObject.Subject = string.Format(CultureInfo.CurrentUICulture, "The Layerscape {0} \"{1}\" has been flagged by a user", request.EntityType.ToString().ToLower(), entityName);

            var replacements = new Dictionary <string, string>
            {
                { "@@ApproverName@@", string.Empty },
                { "@@Type@@", HttpUtility.UrlDecode(request.EntityType.ToString().ToLower()) },
                { "@@Name@@", HttpUtility.UrlDecode(entityName) },
                { "@@Link@@", HttpUtility.UrlDecode(request.Link) },
                { "@@UserName@@", HttpUtility.UrlDecode(requestor.GetFullName()) },
                { "@@UserLink@@", HttpUtility.UrlDecode(request.UserLink) },
                { "@@FlaggedOn@@", HttpUtility.UrlDecode(request.FlaggedOn.ToString()) },
                { "@@FlaggedAs@@", HttpUtility.UrlDecode(request.FlaggedAs) },
                { "@@UserComments@@", HttpUtility.UrlDecode(request.UserComments) },
            };

            thisObject.MessageBody = FormatMailBodyUsingTemplate("flaggedrequest.html", replacements);

            return(thisObject);
        }
 private static string GetSubject(Community community)
 {
     return(string.Format(SubjectTemplate, community.Name));
 }
Example #56
0
    public static void Main()
    {
        using (var context = new CommunitiesContext())
        {
            // Show the EF model
            // Notice that in this case the join table is the CommunityPerson entity type defined above
            Console.WriteLine();
            Console.WriteLine("EF model is:");
            Console.WriteLine(context.Model.ToDebugString(MetadataDebugStringOptions.ShortDefault));
            Console.WriteLine();

            // Create a clean database each time
            // SQL is logged so you can see the join table is defined automatically
            context.Database.EnsureDeleted();
            context.Database.EnsureCreated();

            var arthur = new Person {
                Name = "Arthur"
            };
            var wendy = new Person {
                Name = "Wendy"
            };
            var julie = new Person {
                Name = "Julie"
            };
            var erik = new Person {
                Name = "Erik"
            };
            var jeremy = new Person {
                Name = "Jeremy"
            };

            var efCommunity = new Community {
                Name = "EF Community"
            };
            var dogPeople = new Community {
                Name = "Dog People"
            };
            var microsofties = new Community {
                Name = "Microsofties"
            };

            // Can add to collection on one side...
            efCommunity.Members.Add(arthur);
            efCommunity.Members.Add(julie);
            efCommunity.Members.Add(erik);
            efCommunity.Members.Add(jeremy);

            dogPeople.Members.Add(arthur);
            dogPeople.Members.Add(jeremy);
            dogPeople.Members.Add(julie);
            dogPeople.Members.Add(wendy);

            // Or the other...
            jeremy.Memberships.Add(microsofties);
            arthur.Memberships.Add(microsofties);

            context.AddRange(efCommunity, dogPeople, microsofties);

            // SQL generated here shows insertion into the join table
            context.SaveChanges();
        }

        using (var context = new CommunitiesContext())
        {
            // Use Include to pull in the many-to-many relationship
            var communities = context.Communities.Include(e => e.Members).ToList();

            // Show what we loaded - notice we still don't care about the join table in this code
            Console.WriteLine();
            Console.WriteLine();
            foreach (var community in communities)
            {
                Console.Write($"Community \"{community.Name}\" has members");

                foreach (var membershipData in community.MemberData)
                {
                    Console.Write($" '{membershipData.Person.Name}' (since {membershipData.MemberSince})");
                }

                Console.WriteLine();
            }

            // Show what the state manager is tracking
            // Notice that entities are being tracked for the join table
            Console.WriteLine();
            Console.WriteLine("DbContext is tracking:");
            Console.WriteLine(context.ChangeTracker.ToDebugString(ChangeTrackerDebugStringOptions.LongDefault, 2));
        }
    }
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, EntityAdminActionRequest request)
        {
            if (thisObject == null)
            {
                thisObject = new EmailRequest();
            }

            ICommunityRepository communityRepository = DependencyResolver.Current.GetService(typeof(ICommunityRepository)) as ICommunityRepository;
            IContentRepository   contentRepository   = DependencyResolver.Current.GetService(typeof(IContentRepository)) as IContentRepository;

            IEnumerable <User> approvers = new List <User>();

            string entityName = string.Empty;

            if (request.EntityType == EntityType.Content)
            {
                Content content = contentRepository.GetItem(c => c.ContentID == request.EntityID);
                if (content != null)
                {
                    if (content.CommunityContents.Count > 0)
                    {
                        approvers = communityRepository.GetApprovers(Enumerable.ElementAt <CommunityContents>(content.CommunityContents, 0).CommunityID);
                    }

                    approvers.Concat(new[] { content.User });
                    entityName = content.Title;
                }
            }
            else
            {
                approvers = communityRepository.GetApprovers(request.EntityID);
                Community community = communityRepository.GetItem(c => c.CommunityID == request.EntityID);
                if (community != null)
                {
                    entityName = community.Name;
                }
            }

            foreach (User user in approvers)
            {
                if (user.IsSubscribed)
                {
                    thisObject.Recipients.Add(new MailAddress(user.Email.FixEmailAddress(), user.FirstName + " " + user.LastName));
                }
            }

            thisObject.IsHtml = true;

            // Update the body and the subject.
            switch (request.Action)
            {
            case AdminActions.Delete:
                thisObject.Subject = string.Format(CultureInfo.CurrentUICulture, "The Layerscape {0} \"{1}\" has been deleted by the site admin", request.EntityType.ToString().ToLower(), entityName);
                break;

            case AdminActions.MarkAsPrivate:
                thisObject.Subject = string.Format(CultureInfo.CurrentUICulture, "The Layerscape {0} \"{1}\" has been marked as Private by the site admin", request.EntityType.ToString().ToLower(), entityName);
                break;
            }

            var replacements = new Dictionary <string, string>
            {
                { "@@UserName@@", string.Empty },
                { "@@EntityType@@", HttpUtility.UrlDecode(request.EntityType.ToString().ToLower()) },
                { "@@EntityName@@", HttpUtility.UrlDecode(entityName) },
                { "@@EntityLink@@", HttpUtility.UrlDecode(request.EntityLink) },
                { "@@ContactUsLink@@", string.Format(CultureInfo.CurrentUICulture, "mailto:{0}", Constants.MicrosoftEmail) }
            };

            thisObject.MessageBody = FormatMailBodyUsingTemplate(string.Format(CultureInfo.InvariantCulture, "entityadmin{0}request.html", request.Action.ToString().ToLower()), replacements);

            return(thisObject);
        }
Example #58
0
 public override TemplateEmail GeneratePreview(Community community)
 {
     return(null);
 }
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, EntityCommentRequest request)
        {
            if (thisObject == null)
            {
                thisObject = new EmailRequest();
            }

            ICommunityRepository communityRepository = DependencyResolver.Current.GetService(typeof(ICommunityRepository)) as ICommunityRepository;
            IContentRepository   contentRepository   = DependencyResolver.Current.GetService(typeof(IContentRepository)) as IContentRepository;

            IEnumerable <User> contributors = new List <User>();
            IEnumerable <User> commenters   = new List <User>();

            string entityName = string.Empty;

            if (request.EntityType == EntityType.Content)
            {
                Content content = contentRepository.GetItem(c => c.ContentID == request.ID);
                if (content != null)
                {
                    if (content.CommunityContents.Count > 0)
                    {
                        contributors = communityRepository.GetContributors(Enumerable.ElementAt <CommunityContents>(content.CommunityContents, 0).CommunityID);
                    }

                    contributors.Concat(new[] { content.User });
                    entityName = content.Title;
                }

                IContentCommentsRepository contentCommentsRepository = DependencyResolver.Current.GetService(typeof(IContentCommentsRepository)) as IContentCommentsRepository;
                commenters = contentCommentsRepository.GetCommenters(request.ID);
            }
            else
            {
                contributors = communityRepository.GetContributors(request.ID);
                Community community = communityRepository.GetItem(c => c.CommunityID == request.ID);
                if (community != null)
                {
                    entityName = community.Name;
                }

                ICommunityCommentRepository communityCommentRepository = DependencyResolver.Current.GetService(typeof(ICommunityCommentRepository)) as ICommunityCommentRepository;
                commenters = communityCommentRepository.GetCommenters(request.ID);
            }

            List <User> recipients = new List <User>();

            if (contributors != null && contributors.Count() > 0)
            {
                recipients.AddRange(contributors);
            }

            if (commenters != null && commenters.Count() > 0)
            {
                recipients.AddRange(commenters.Where(p => !contributors.Any(x => x.UserID.Equals(p.UserID))));
            }

            foreach (User user in recipients)
            {
                if (user.IsSubscribed && user.UserID != request.UserID)
                {
                    thisObject.Recipients.Add(new MailAddress(user.Email.FixEmailAddress(), user.FirstName + " " + user.LastName));
                }
            }

            IUserRepository userRepository = DependencyResolver.Current.GetService(typeof(IUserRepository)) as IUserRepository;
            User            requestor      = userRepository.GetItem(u => u.UserID == request.UserID);

            thisObject.IsHtml = true;

            // Update the body and the subject.
            thisObject.Subject = string.Format(CultureInfo.CurrentUICulture, "{0} has commented on the Layerscape {1} \"{2}\"", requestor.GetFullName(), request.EntityType.ToString().ToLower(), entityName);

            var replacements = new Dictionary <string, string>
            {
                { "@@RecipientName@@", string.Empty },
                { "@@Type@@", HttpUtility.UrlDecode(request.EntityType.ToString().ToLower()) },
                { "@@Name@@", HttpUtility.UrlDecode(entityName) },
                { "@@Link@@", HttpUtility.UrlDecode(request.Link) },
                { "@@UserName@@", HttpUtility.UrlDecode(requestor.GetFullName()) },
                { "@@UserLink@@", HttpUtility.UrlDecode(request.UserLink) },
                { "@@UserComments@@", HttpUtility.UrlDecode(request.UserComments) },
            };

            thisObject.MessageBody = FormatMailBodyUsingTemplate("entitycommentrequest.html", replacements);

            return(thisObject);
        }
Example #60
0
 public void GetIdFromLinkTestNullException()
 {
     //Throws NullReferenceException
     Client cl = new Community("net_takogo_pablica_i_ya_nadeyus_ne_budet_123");
 }