Пример #1
0
        void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs args)
        {
            var request = args.Request;
            var item    = (RecipeDataItem)contentRegion.DataContext;

            ShareManager.ShareRecipe(request, item);
        }
        public override void Execute()
        {
            base.Execute();

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter      = "Sharing Definition File (*.sd)|*.sd";
            ofd.Multiselect = true;


            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    ShareManager shareManager = new ShareManager(Activator.RepositoryLocator);
                    shareManager.LocalReferenceGetter = LocalReferenceGetter;
                    foreach (var f in ofd.FileNames)
                    {
                        using (var stream = File.Open(f, FileMode.Open))
                            shareManager.ImportSharedObject(stream);
                    }
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show("Error importing file(s)", e);
                }
            }
        }
Пример #3
0
        public override void Execute()
        {
            base.Execute();

            if (_property == null)
            {
                return;
            }

            if (_getValueAtExecuteTime)
            {
                if (BasicActivator.SelectValueType(_property.Name, _property.PropertyType, _property.GetValue(_setOn), out object chosen))
                {
                    NewValue = chosen;
                }
                else
                {
                    Success = false;
                    return;
                }
            }

            ShareManager.SetValue(_property, NewValue, _setOn);
            ((DatabaseEntity)_setOn).SaveToDatabase();

            Success = true;
            Publish((DatabaseEntity)_setOn);
        }
Пример #4
0
        public DomainFacade(IStorageProvider storageProvider, string baseUri, ILanguageContainerService languageContainerService)
        {
            _storageProvider         = storageProvider;
            LanguageContainerService = languageContainerService;
            TryRestoreLanguageName();

            _grid             = new Grid();
            _toolManager      = new ToolManager();
            _historyManager   = new HistoryManager();
            _hintsProvider    = new HintsProvider();
            _storageManager   = new StorageManager(storageProvider);
            _shareManager     = new ShareManager(baseUri);
            _pasteManager     = new PasteManager();
            _solver           = new BruteForceSolver();
            _gridGenerator    = new PredefinedGridGenerator();
            _colorManager     = new ColorManager();
            _gameTimerManager = new GameTimerManager();

            _modalStateManager = new();
            _modalStateManager.OnModalStateChanged += HandleModalStateChanged;
            SetModalState(ModalState.Loading);

            Load();
            StartAutoSave(TimeSpan.FromSeconds(2));
        }
Пример #5
0
        void _onShare(Article article)
        {
            var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);

            ShareManager.showArticleShareView(
                true,
                isLoggedIn: this.widget.viewModel.isLoggedIn,
                () => {
                Clipboard.setData(new ClipboardData(text: linkUrl));
                CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
            },
                () => this.widget.actionModel.pushToLogin(),
                () => this.widget.actionModel.pushToBlock(obj: article.id),
                () => this.widget.actionModel.pushToReport(arg1: article.id, arg2: ReportType.article),
                type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url);
                this.widget.actionModel.shareToWechat(arg1: type, arg2: article.title,
                                                      arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl)
                .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
            }
                );
        }
Пример #6
0
        public ExecuteCommandExportObjectsToFile(IBasicActivateItems activator, IMapsDirectlyToDatabaseTable[] toExport, DirectoryInfo targetDirectoryInfo = null) : base(activator)
        {
            _toExport      = toExport;
            ShowInExplorer = true;

            _repositoryLocator = activator.RepositoryLocator;
            _toExport          = toExport;

            TargetDirectoryInfo = targetDirectoryInfo;

            _shareManager = new ShareManager(_repositoryLocator);

            if (toExport == null || !toExport.Any())
            {
                SetImpossible("No objects exist to be exported");
                return;
            }
            _gatherer = new Gatherer(_repositoryLocator);

            var incompatible = toExport.FirstOrDefault(o => !_gatherer.CanGatherDependencies(o));

            if (incompatible != null)
            {
                SetImpossible("Object " + incompatible.GetType() + " is not supported by Gatherer");
            }
        }
 public ForwardEngineerANOCatalogueEngine(IRDMPPlatformRepositoryServiceLocator repositoryLocator, ForwardEngineerANOCataloguePlanManager planManager)
 {
     _catalogueRepository = (CatalogueRepository)repositoryLocator.CatalogueRepository;
     _shareManager        = new ShareManager(repositoryLocator);
     _planManager         = planManager;
     _allColumnsInfos     = _catalogueRepository.GetAllObjects <ColumnInfo>();
 }
Пример #8
0
        public override void Execute()
        {
            base.Execute();

            var selected = BasicActivator.SelectFiles("Select ShareDefinitions to import", "Sharing Definition File", "*.sd");

            if (selected != null && selected.Any())
            {
                try
                {
                    ShareManager shareManager = new ShareManager(BasicActivator.RepositoryLocator);
                    shareManager.LocalReferenceGetter = LocalReferenceGetter;

                    foreach (var f in selected)
                    {
                        using (var stream = File.Open(f.FullName, FileMode.Open))
                            shareManager.ImportSharedObject(stream);
                    }
                }
                catch (Exception e)
                {
                    BasicActivator.ShowException("Error importing file(s)", e);
                }
            }
        }
Пример #9
0
        public ExitCodeType Fetch(IDataLoadJob job, GracefulCancellationToken cancellationToken)
        {
            int imported = 0;

            try
            {
                var shareManager = new ShareManager(job.RepositoryLocator);

                foreach (var shareDefinitionFile in job.LoadDirectory.ForLoading.EnumerateFiles("*.sd"))
                {
                    job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Found '" + shareDefinitionFile.Name + "'"));
                    using (var stream = File.Open(shareDefinitionFile.FullName, FileMode.Open))
                        shareManager.ImportSharedObject(stream);

                    imported++;
                    job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Imported '" + shareDefinitionFile.Name + "' Succesfully"));
                }
            }
            catch (SharingException ex)
            {
                job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Warning, "Error occured importing ShareDefinitions", ex));
            }

            job.OnNotify(this, new NotifyEventArgs(imported == 0 ? ProgressEventType.Warning : ProgressEventType.Information, "Imported " + imported + " ShareDefinition files"));

            return(ExitCodeType.Success);
        }
Пример #10
0
        internal ProcessTaskArgument(ShareManager shareManager, ShareDefinition shareDefinition)
        {
            shareManager.UpsertAndHydrate(this, shareDefinition);
            try
            {
                //if the import is into a repository other than the master original repository
                if (!shareManager.IsExportedObject(this.ProcessTask.LoadMetadata))
                {
                    //and we are a reference type e.g. to a ColumnInfo or something
                    var t = GetConcreteSystemType();

                    if (typeof(IMapsDirectlyToDatabaseTable).IsAssignableFrom(t) || typeof(IEnumerable <IMapsDirectlyToDatabaseTable>).IsAssignableFrom(t))
                    {
                        //then use the value Null because whatever ID is stored in us won't be pointing to the same object
                        //as when we were exported!
                        Value = null;
                        SaveToDatabase();
                    }
                }
            }
            catch (Exception e)
            {
                //couldn't work out the Type, maybe it is broken or something, or otherwise someone elses problem
                Console.WriteLine(e);
            }
        }
        Widget _buildUserCard(BuildContext context, int index)
        {
            var articleId   = this.widget.viewModel.likeArticleIds[index : index];
            var articleDict = this.widget.viewModel.articleDict;

            if (!articleDict.ContainsKey(key: articleId))
            {
                return(new Container());
            }

            var article  = articleDict[key : articleId];
            var linkUrl  = CStringUtils.JointProjectShareLink(projectId: article.id);
            var fullName = "";

            if (article.ownerType == OwnerType.user.ToString())
            {
                if (this.widget.viewModel.userDict.ContainsKey(key: article.userId))
                {
                    fullName = this.widget.viewModel.userDict[key : article.userId].fullName
                               ?? this.widget.viewModel.userDict[key : article.userId].name;
                }
            }

            if (article.ownerType == OwnerType.team.ToString())
            {
                if (this.widget.viewModel.teamDict.ContainsKey(key: article.teamId))
                {
                    fullName = this.widget.viewModel.teamDict[key : article.teamId].name;
                }
            }

            return(new ArticleCard(
                       article: article,
                       () => this.widget.actionModel.pushToArticleDetail(obj: article.id),
                       () => ShareManager.showArticleShareView(
                           false,
                           isLoggedIn: this.widget.viewModel.isLoggedIn,
                           () => {
                Clipboard.setData(new ClipboardData(text: linkUrl));
                CustomDialogUtils.showToast("复制链接成功", iconData: Icons.check_circle_outline);
            },
                           () => this.widget.actionModel.pushToLogin(),
                           () => this.widget.actionModel.pushToBlock(obj: article.id),
                           () => this.widget.actionModel.pushToReport(obj: article.id),
                           type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(imageUrl: article.thumbnail.url);
                this.widget.actionModel.shareToWechat(arg1: type, arg2: article.title,
                                                      arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl)
                .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
            }
                           ),
                       fullName: fullName,
                       new ObjectKey(value: article.id)
                       ));
        }
        Widget _buildArticleCard(BuildContext context, int index)
        {
            var article = this.viewModel.articleHistory[index : index];
            var linkUrl = CStringUtils.JointProjectShareLink(projectId: article.id);

            return(CustomDismissible.builder(
                       Key.key(value: article.id),
                       new ArticleCard(
                           article: article,
                           () => this.actionModel.pushToArticleDetail(obj: article.id),
                           () => ShareManager.showArticleShareView(
                               true,
                               isLoggedIn: this.viewModel.isLoggedIn,
                               () => {
                Clipboard.setData(new ClipboardData(text: linkUrl));
                CustomDialogUtils.showToast("复制链接成功", Icons.check_circle_outline);
            },
                               () => this.actionModel.pushToLogin(),
                               () => this.actionModel.pushToBlock(article.id),
                               () => this.actionModel.pushToReport(article.id, ReportType.article),
                               type => {
                CustomDialogUtils.showCustomDialog(
                    child: new CustomLoadingDialog()
                    );
                string imageUrl = CImageUtils.SizeTo200ImageUrl(article.thumbnail.url);
                this.actionModel.shareToWechat(arg1: type, arg2: article.title,
                                               arg3: article.subTitle, arg4: linkUrl, arg5: imageUrl)
                .Then(onResolved: CustomDialogUtils.hiddenCustomDialog)
                .Catch(_ => CustomDialogUtils.hiddenCustomDialog());
            }
                               ),
                           fullName: article.fullName,
                           index == 0,
                           new ObjectKey(value: article.id)
                           ),
                       new CustomDismissibleDrawerDelegate(),
                       secondaryActions: new List <Widget> {
                new GestureDetector(
                    onTap: () => this.actionModel.deleteArticleHistory(obj: article.id),
                    child: new Container(
                        color: CColors.Separator2,
                        width: 80,
                        alignment: Alignment.center,
                        child: new Container(
                            width: 44,
                            height: 44,
                            alignment: Alignment.center,
                            decoration: new BoxDecoration(
                                CColors.White,
                                borderRadius: BorderRadius.circular(22)
                                ),
                            child: new Icon(Icons.delete_outline, size: 28, color: CColors.Error)
                            )
                        )
                    )
            },
                       controller: this._controller
                       ));
        }
Пример #13
0
 public void Setup()
 {
     lobbies       = new Dictionary <string, Lobby>();
     lobbyManager  = new LobbyManager(lobbies);
     scoresManager = new ScoresManager();
     shareManager  = new ShareManager();
     legendManager = new LegendManager();
 }
Пример #14
0
 public RemotePushingService(IRDMPPlatformRepositoryServiceLocator repositoryLocator, IDataLoadEventListener listener)
 {
     _repositoryLocator = repositoryLocator;
     this.listener      = listener;
     remotes            = _repositoryLocator.CatalogueRepository.GetAllObjects <RemoteRDMP>();
     _gatherer          = new Gatherer(_repositoryLocator);
     _shareManager      = new ShareManager(_repositoryLocator);
 }
Пример #15
0
 private void Awake()
 {
     if (Instance != null)
     {
         return;
     }
     Instance = this;
 }
Пример #16
0
 public static ShareManager GetInstance()
 {
     if (instance == null)
     {
         instance = new ShareManager();
     }
     return(instance);
 }
Пример #17
0
        internal ExternalDatabaseServer(ShareManager shareManager, ShareDefinition shareDefinition)
        {
            var repo = shareManager.RepositoryLocator.CatalogueRepository;

            Repository = repo;
            _selfCertifyingDataAccessPoint = new SelfCertifyingDataAccessPoint(CatalogueRepository, DatabaseType.MicrosoftSQLServer /*will get changed by UpsertAndHydrate*/);

            shareManager.UpsertAndHydrate(this, shareDefinition);
        }
Пример #18
0
        public void TestPlugin_OrphanImport_Sharing()
        {
            //Setup the load module we want to test (with plugin parent)
            var fi = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah2." + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(fi.FullName, new byte[] { 0x1, 0x2 });

            var fi2 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah2." + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(fi2.FullName, new byte[] { 0x1, 0x2 });

            var fi3 = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "Blah3." + PackPluginRunner.PluginPackageSuffix));

            File.WriteAllBytes(fi3.FullName, new byte[] { 0x3, 0x4 });

            Core.Curation.Data.Plugin p = new Core.Curation.Data.Plugin(Repository, fi, new Version(1, 1, 1), new Version(1, 1, 1, 1));
            var lma  = new LoadModuleAssembly(Repository, fi2, p);
            var lma2 = new LoadModuleAssembly(Repository, fi3, p);

            //gather dependencies of the plugin (plugin[0] + lma[1])
            Gatherer     g    = new Gatherer(RepositoryLocator);
            ShareManager sm   = new ShareManager(RepositoryLocator);
            var          list = g.GatherDependencies(p).ToShareDefinitionWithChildren(sm);

            //Delete export definitions
            foreach (var e in Repository.GetAllObjects <ObjectExport>())
            {
                e.DeleteInDatabase();
            }

            //and delete pluing (CASCADE deletes lma too)
            p.DeleteInDatabase();

            //import them
            var created = sm.ImportSharedObject(list).ToArray();

            //There should be 3
            Assert.AreEqual(3, created.Count());

            Assert.AreEqual(3, Repository.GetAllObjects <ObjectImport>().Count());

            lma2 = (LoadModuleAssembly)created[2];

            //now delete lma2 only
            lma2.DeleteInDatabase();

            Assert.AreEqual(2, Repository.GetAllObjects <ObjectImport>().Count());

            //import them
            var created2 = sm.ImportSharedObject(list);

            //There should still be 3
            Assert.AreEqual(3, created2.Count());
        }
Пример #19
0
        public override void Execute()
        {
            base.Execute();

            if (_property == null)
            {
                return;
            }

            ShareManager.SetValue(_property, NewValue, null);
            Success = true;
        }
Пример #20
0
        public MainPage()
        {
            this.InitializeComponent();
            ExtendAcrylicIntoTitleBar();
            shareManager = new ShareManager();
            shareManager.ShareTargetChosen += ShareManager_ShareTargetChosen;

            Window.Current.SizeChanged += Current_SizeChanged;

            dt          = new DispatcherTimer();
            dt.Interval = new TimeSpan(0, 0, 4);
            dt.Tick    += (_, __) => Application.Current.Exit();
        }
Пример #21
0
        public void GetAllSharesTest()
        {
            // Arrange
            var shareRepositoryMock = Substitute.For <ISharesRepository>();

            var sut = new ShareManager(shareRepositoryMock);

            // Act
            sut.GetNumberOfShares();

            // Asserts
            shareRepositoryMock.Received(1).GetNumberOfShares();
        }
Пример #22
0
        /// <summary>
        /// This constructor is primarily intended for deserialization via <see cref="JsonConvertExtensions.DeserializeObject"/>.  You should
        /// instead use the overload.
        /// </summary>
        public ForwardEngineerANOCataloguePlanManager(IRDMPPlatformRepositoryServiceLocator repositoryLocator)
        {
            _shareManager = new ShareManager(repositoryLocator);

            DilutionOperations = new List <IDilutionOperation>();

            ObjectConstructor constructor = new ObjectConstructor();

            foreach (var operationType in repositoryLocator.CatalogueRepository.MEF.GetTypes <IDilutionOperation>())
            {
                DilutionOperations.Add((IDilutionOperation)constructor.Construct(operationType));
            }
        }
Пример #23
0
 public object Group(Group group, long userId, int type)
 {
     logger.Log(LogLevel.Debug, $"ShareController.Group({Json(group)}, {userId})");
     try
     {
         return(ShareManager.ShareGroup(group, userId, type));
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, $"ShareController.Group({Json(group)}, {userId}) - {ex}");
         //изменить http status code
         return(new Response(100, ex.Message));
     }
 }
Пример #24
0
 public object Group(long groupId, long userId, int type)
 {
     logger.Log(LogLevel.Debug, $"ShareController.Group({groupId}, {userId})");
     try
     {
         return(Json(ShareManager.ShareGroup(groupId, userId, type), JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         logger.Log(LogLevel.Error, $"ShareController.Group({groupId}, {userId}) - {ex}");
         //изменить http status code
         return(Json(new Response(100, ex.Message), JsonRequestBehavior.AllowGet));
     }
 }
Пример #25
0
        private LoadMetadata ShareToNewRepository(LoadMetadata lmd)
        {
            var gatherer = new Gatherer(RepositoryLocator);

            Assert.IsTrue(gatherer.CanGatherDependencies(lmd));
            var rootObj = gatherer.GatherDependencies(lmd);

            var sm = new ShareManager(RepositoryLocator, null);
            var shareDefinition = rootObj.ToShareDefinitionWithChildren(sm);

            var repo2 = new MemoryDataExportRepository();
            var sm2   = new ShareManager(new RepositoryProvider(repo2));

            return(sm2.ImportSharedObject(shareDefinition).OfType <LoadMetadata>().Single());
        }
Пример #26
0
        public void IsShareExistTest()
        {
            // Arrange
            var shareRepositoryMock = Substitute.For <ISharesRepository>();

            var sut = new ShareManager(shareRepositoryMock);

            int shareID = 135;

            // Act
            sut.IsShareExist(shareID);

            // Asserts
            shareRepositoryMock.Received(1).IsShareExist(Arg.Is <int>(shareID));
        }
Пример #27
0
        public Path(ShareManager shareManager, PathMode pathMode, MacroSync macro)
        {
            this.shareManager = shareManager;
            this.pathMode     = pathMode;
            this.macro        = macro;

            if (pathMode == PathMode.Advanced)
            {
                ZMO.Mine = true;
            }
            else
            {
                ZMO.Mine = false;
            }
        }
Пример #28
0
        public void IsShareExistShareTypeTest()
        {
            // Arrange
            var shareRepositoryMock = Substitute.For <ISharesRepository>();

            var sut = new ShareManager(shareRepositoryMock);

            string shareType = "Umbrella";

            // Act
            sut.IsShareExist(shareType);

            // Asserts
            shareRepositoryMock.Received(1).IsShareExist(Arg.Is <string>(shareType));
        }
Пример #29
0
 public DutyController(
     //IHostedService hostedService,
     IDiscordSender discordSender,
     DutyManager <ApplicationDbContext> dutyManager,
     PostManager <ApplicationDbContext> postManager,
     ShareManager <ApplicationDbContext> shareManager,
     SubjectManager <ApplicationDbContext> subjectManager,
     UserManager <Student> userManager)
 {
     _discordSender = discordSender;
     _dutyManager   = dutyManager;
     //_mailingCron = hostedService as MailingCron;
     _postManager    = postManager;
     _shareManager   = shareManager;
     _subjectManager = subjectManager;
     _userManager    = userManager;
 }
Пример #30
0
        private List <ShareDefinition> ToShareDefinitionWithChildren(ShareManager shareManager, List <ShareDefinition> branchParents)
        {
            var me = ToShareDefinition(shareManager, branchParents);

            var toReturn = new List <ShareDefinition>();
            var parents  = new List <ShareDefinition>(branchParents);

            parents.Add(me);
            toReturn.Add(me);

            foreach (GatheredObject child in Children)
            {
                toReturn.AddRange(child.ToShareDefinitionWithChildren(shareManager, parents));
            }

            return(toReturn);
        }
Пример #31
0
        static void Main(string[] args)
        {
            try {
                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.BufferHeight = 120;
                Console.BufferWidth = 190;
                Console.WindowHeight = 60;
                Console.WindowWidth = 180;
            } catch { }

            Console.Clear();

            Log.EntryAdded += new Log.EntryAddedHandler(Log_EntryAdded);

            _shareManager = new ShareManager();

            _shareManager.Start();

            ShareConfiguration dataShare = new FileSystemShareConfiguration() {
                Name = "Data",
                Path = "X:\\"
            };

            ShareConfiguration backupShare = new FileSystemShareConfiguration() {
                Name = "Time Capsule",
                Path = "X:\\Backups\\Time Capsule"
            };

            ServerConfiguration afpServer = new AppleFilingProtocolServerConfiguration() {
                Name = "Skynet",
                TimeMachineShares = { "Time Capsule" }
            };

            ServiceConfiguration service = new ServiceConfiguration() {
                Servers = { afpServer },
                Shares = { dataShare, backupShare }
            };

            _shareManager.Configuration = service;

            //IShareServer server = _shareManager.Servers[0];

            //server.AuthenticationProvider = new TestAuth();

            //AfpShareServer afpShareServer = (AfpShareServer)server;
            //afpShareServer.AuthenticationMethods.Clear();
            //afpShareServer.AuthenticationMethods.Add(new Afp.Protocol.Security.AfpCleartextUserAuthenticationMethod());

            for (; ; ) {
                string line = Console.ReadLine();
                if (line == "x") {
                    if (_shareManager.IsRunning) {
                        Console.WriteLine("Stopping...");
                        _shareManager.Stop();
                        Console.WriteLine("Stopped.");
                    } else {
                        Console.WriteLine("Starting...");
                        _shareManager.Start();
                    }
                } else {
                    break;
                }
            }

            _shareManager.Stop();
        }