示例#1
0
		private void Update(Updater updater, IImportRecord record)
		{
			try
			{

				UpdateOption updateParameter = new UpdateOption();

				if (chkSkipAttachments.Checked)
				{
					updateParameter = updateParameter | UpdateOption.Attachments;
				}

				//if (chkUpdateChilds.Checked)
				//{
				//	updateParameter = updateParameter | UpdateOption.Children;
				//}

				updater.Update(record, Selection.SelectedItem, updateParameter);
				Refresh(Selection.SelectedItem, ToolbarArea.Both);
				
				ShowErrors(record);
			}
			catch (N2Exception ex)
			{
				cvUpdate.ErrorMessage = ex.Message;
				cvUpdate.IsValid = false;
				btnUpdateUploaded.Enabled = false;
			}
			finally
			{
				if (File.Exists(UploadedFilePath))
					File.Delete(UploadedFilePath);
			}
		}
 public void Handle(UpdateOption update)
 {
     if (string.Equals(update.Name, "enabled_proxy_id", StringComparison.OrdinalIgnoreCase))
     {
         BeginOnUIThread(() => Handle(CacheService.GetConnectionState(), CacheService.Options.EnabledProxyId));
     }
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Update"/> class.
 /// </summary>
 /// <param name="fullNameSpace">The full name space.</param>
 /// <param name="selector">The selector.</param>
 /// <param name="document">The document.</param>
 /// <param name="flags">The flags.</param>
 public Update(string fullNameSpace, IDBObject selector, IDBObject document, UpdateOption flags)
     : base(Operation.Update)
 {
     FullNameSpace = fullNameSpace;
     Selector = selector;
     Document = document;
     Flags = flags;
 }
示例#4
0
        public void UpdateBrokerAccount(
            IBroker broker,
            IBrokersCandlesService candleService,
            IMarketDetailsService marketsService,
            ITradeDetailsAutoCalculatorService tradeCalculateService,
            UpdateOption option = UpdateOption.OnlyIfNotRecentlyUpdated)
        {
            void UpdateProgressAction(string txt)
            {
            }

            UpdateBrokerAccount(broker, candleService, marketsService, tradeCalculateService, UpdateProgressAction, option);
        }
            public EntryWrapper(ContentEntry entry, bool isNew)
            {
                Entry        = entry;
                InstallEntry = true;
                IsNew        = isNew;

                if (isNew)
                {
                    return;
                }
                _updateOptionsList = entry.Type.GetUpdateOptions().ToArray();
                SelectedOption     = _updateOptionsList[0];
            }
示例#6
0
        public void UpdateBrokerAccount(
            IBroker broker,
            IBrokersCandlesService candleService,
            IMarketDetailsService marketsService,
            ITradeDetailsAutoCalculatorService tradeCalculateService,
            Action <string> updateProgressAction,
            UpdateOption option = UpdateOption.OnlyIfNotRecentlyUpdated)
        {
            if (option == UpdateOption.OnlyIfNotRecentlyUpdated && (AccountLastUpdated != null && (DateTime.UtcNow - AccountLastUpdated.Value).TotalHours < 24))
            {
                return;
            }

            Log.Debug($"Updating {broker.Name} account");

            foreach (var t in Trades)
            {
                tradeCalculateService.RemoveTrade(t);
            }

            try
            {
                broker.UpdateAccount(this, candleService, marketsService, updateProgressAction, out var addedOrUpdatedTrades);

                foreach (var trade in addedOrUpdatedTrades)
                {
                    RecalculateTrade(trade, candleService, marketsService, broker);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to update account", ex);
                MessageBox.Show($"Unable to update account - {ex.Message}", "Unable to update account", MessageBoxButtons.OK);
            }

            AccountLastUpdated = DateTime.UtcNow;

            Log.Debug($"Completed updating {broker.Name} trades");
            _brokerAccountUpdatedSubject.OnNext(new BrokerAccountUpdated(this));
        }
示例#7
0
文件: Updater.cs 项目: andy4711/n2cms
		public virtual void Update(IImportRecord record, ContentItem destination, UpdateOption options)
		{
			
			RemoveReferences(record.ReadItems, record.RootItem);

			AssociateLanguageKeys(record.ReadItems);

			UpdateContentItem(destination, record.RootItem);
			UpdateParts(destination, record.RootItem);
			

			if ((options & UpdateOption.Children) == UpdateOption.Children)
			{
				//Could be implemented for future use...
			}
		

			if ((options & UpdateOption.Attachments) == UpdateOption.Attachments)
			{
				foreach (Attachment a in record.Attachments)
				{
					try
					{
						a.Import(_fs);
					}
					catch (Exception ex)
					{
						logger.Warn(ex);
						record.FailedAttachments.Add(a);
					}
				}
			}

			destination.DontReOrderSave = true;
			_persister.SaveRecursive(destination);
			N2.Context.Current.Resolve<N2.Edit.Trash.ITrashHandler>().PurgeAll();
	
		}
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateMessage{T,U}"/> class.
 /// </summary>
 /// <param retval="connection">The connection.</param>
 /// <param retval="collection">The collection.</param>
 /// <param retval="options">The options.</param>
 /// <param retval="matchDocument">The match document.</param>
 /// <param retval="valueDocument">The value document.</param>
 internal UpdateMessage(IConnection connection, string collection, UpdateOption options, T matchDocument, U valueDocument) : base(connection, collection)
 {
     this._options       = options;
     this._matchDocument = matchDocument;
     this._valueDocument = valueDocument;
 }
 internal UpdateDiaglog(AppUpdateArgs appUpdateInfoArgs, UpdateOption updateOption)
 {
     InitializeComponent();
     _appUpdateInfoArgs = appUpdateInfoArgs;
     _updateOption      = updateOption;
 }
示例#10
0
        public void Handle(UpdateOption update)
        {
            switch (update.Name)
            {
            case "archive_and_mute_new_chats_from_unknown_users":
                _archiveAndMuteNewChatsFromUnknownUsers = GetValue <bool>(update.Value);
                break;

            case "storage_max_time_from_last_access":
                _storageMaxTimeFromLastAccess = GetValue <int>(update.Value);
                break;

            case "disable_pinned_message_notifications":
                _disablePinnedMessageNotifications = GetValue <bool>(update.Value);
                break;

            case "is_location_visible":
                _isLocationVisible = GetValue <bool>(update.Value);
                break;

            case "calls_enabled":
                _callsEnabled = GetValue <bool>(update.Value);
                break;

            case "disable_contact_registered_notifications":
                _disableContactRegisteredNotifications = GetValue <bool>(update.Value);
                break;

            case "disable_top_chats":
                _disableTopChats = GetValue <bool>(update.Value);
                break;

            case "ignore_background_updates":
                _ignoreBackgroundUpdates = GetValue <bool>(update.Value);
                break;

            case "ignore_inline_thumbnails":
                _ignoreInlineThumbnails = GetValue <bool>(update.Value);
                break;

            case "ignore_platform_restrictions":
                _ignorePlatformRestrictions = GetValue <bool>(update.Value);
                break;

            case "ignore_sensitive_content_restrictions":
                _ignoreSensitiveContentRestrictions = GetValue <bool>(update.Value);
                break;

            case "language_pack_database_path":
                _languagePackDatabasePath = GetValue <string>(update.Value);
                break;

            case "language_pack_id":
                _languagePackId = GetValue <string>(update.Value);
                break;

            case "localization_target":
                _localizationTarget = GetValue <string>(update.Value);
                break;

            case "notification_group_count_max":
                _notificationGroupCountMax = GetValue <int>(update.Value);
                break;

            case "notification_group_size_max":
                _notificationGroupSizeMax = GetValue <int>(update.Value);
                break;

            case "online":
                _online = GetValue <bool>(update.Value);
                break;

            case "prefer_ipv6":
                _preferIpv6 = GetValue <bool>(update.Value);
                break;

            case "use_pfs":
                _usePfs = GetValue <bool>(update.Value);
                break;

            case "use_quick_ack":
                _useQuickAck = GetValue <bool>(update.Value);
                break;

            case "use_storage_optimizer":
                _useStorageOptimizer = GetValue <bool>(update.Value);
                break;

            case "animated_emoji_sticker_set_name":
                _animatedEmojiStickerSetName = GetValue <string>(update.Value);
                break;

            case "animation_search_bot_username":
                _animationSearchBotUsername = GetValue <string>(update.Value);
                break;

            case "authorization_date":
                _authorizationDate = GetValue <int>(update.Value);
                break;

            case "basic_group_size_max":
                _basicGroupSizeMax = GetValue <int>(update.Value);
                break;

            case "call_connect_timeout_ms":
                _callConnectTimeoutMs = GetValue <int>(update.Value);
                break;

            case "call_packet_timeout_ms":
                _callPacketTimeoutMs = GetValue <int>(update.Value);
                break;

            case "can_ignore_sensitive_content_restrictions":
                _canIgnoreSensitiveContentRestrictions = GetValue <bool>(update.Value);
                break;

            case "enabled_proxy_id":
                _enabledProxyId = GetValue <int>(update.Value);
                break;

            case "expect_blocking":
                _expectBlocking = GetValue <bool>(update.Value);
                break;

            case "favorite_stickers_limit":
                _favoriteStickersLimit = GetValue <int>(update.Value);
                break;

            case "forwarded_message_count_max":
                _forwardedMessageCountMax = GetValue <int>(update.Value);
                break;

            case "message_caption_length_max":
                _messageCaptionLengthMax = GetValue <int>(update.Value);
                break;

            case "message_text_length_max":
                _messageTextLengthMax = GetValue <int>(update.Value);
                break;

            case "my_id":
                _myId = GetValue <int>(update.Value);
                break;

            case "pinned_archived_chat_count_max":
                _pinnedArchivedChatCountMax = GetValue <int>(update.Value);
                break;

            case "pinned_chat_count_max":
                _pinnedChatCountMax = GetValue <int>(update.Value);
                break;

            case "photo_search_bot_username":
                _photoSearchBotUsername = GetValue <string>(update.Value);
                break;

            case "suggested_language_pack_id":
                _suggestedLanguagePackId = GetValue <string>(update.Value);
                break;

            case "supergroup_size_max":
                _supergroupSizeMax = GetValue <int>(update.Value);
                break;

            case "t_me_url":
                _tMeUrl = GetValue <string>(update.Value);
                break;

            case "test_mode":
                _testMode = GetValue <bool>(update.Value);
                break;

            case "unix_time":
                _unixTime = GetValue <int>(update.Value);
                break;

            case "venue_search_bot_username":
                _venueSearchBotUsername = GetValue <string>(update.Value);
                break;

            case "version":
                _version = GetValue <string>(update.Value);
                break;

            default:
                _values[update.Name] = update.Value;
                break;
            }
        }
   public void WriteUpdate(
 string fullName,
 IDictionary<string, object> selector,
 IDictionary<string, object> doc,
 UpdateOption options = UpdateOption.None)
   {
       Write(new MessageHeader { Id = NextId(), Operation = Operation.Update });
         Write(0);
         Write(fullName);
         Write((int)options);
         Write(selector);
         Write(doc);
         var len = (int)BaseStream.Position;
         Seek(0, SeekOrigin.Begin);
         Write(len);
         WriteStreamTo(_output);
         Reset();
   }
示例#12
0
 private async void TSB_UpdateOption_Click(object sender, EventArgs e)
 {
     await UpdateOption?.Invoke();
 }
示例#13
0
        protected override int Execute()
        {
            base.Execute();

            var metaData = new GenymanMetadata();
            var version  = GetVersion();

            if (Input.Value.IsNullOrEmpty())
            {
                Description = $"{metaData.Description} (Version {version})";
                Name        = metaData.Identifier.ToLower();
                ShowHelp();
                return(-1);
            }

            var fileName = Input.ParsedValue;

            if (!File.Exists(fileName))
            {
                Log.Error($"Could not find input file {fileName}");
                return(-1);
            }

            var configurationContents = File.ReadAllText(fileName);
            GenymanConfiguration <TConfiguration> genyManConfiguration;

            try
            {
                //todo: based upon extension parse this
                genyManConfiguration = configurationContents.FromJsonString <TConfiguration>();
            }
            catch (Exception e)
            {
                Log.Debug(e.Message);
                Log.Error($"Could not parse {fileName} as a valid Genyman input file");
                return(-1);
            }

            var generator = new TGenerator
            {
                InputFileName         = fileName,
                ConfigurationMetadata = genyManConfiguration.Genyman,
                Configuration         = genyManConfiguration.Configuration,
                WorkingDirectory      = new FileInfo(fileName).DirectoryName,
                Metadata  = metaData,
                Overwrite = Overwrite.HasValue(),
                Update    = UpdateOption?.HasValue() ?? false
            };

            var sw = Stopwatch.StartNew();

            Log.Information($"Executing {generator.Metadata.PackageId} - Version {version}");
            generator.Execute();
            var elapsed = sw.ElapsedMilliseconds;

            Log.Information($"Finished {generator.Metadata.PackageId} ({elapsed}ms)");

            // telemetry
            if (metaData.PackageId.ToLower() != "genyman")
            {
                const string telemetryUrl = "https://cmgg8m1ib1.execute-api.us-east-2.amazonaws.com/genyman";
                telemetryUrl.PostJsonToUrl(new Telemetry()
                {
                    Name = metaData.PackageId, Version = metaData.Version, Duration = elapsed
                });
            }

            return(0);
        }
示例#14
0
 public virtual T GetOption <T>(UpdateOption <T> option) => throw new NotImplementedException();
示例#15
0
        /// <summary>
        /// データの更新(配信ステータスが「配信前」の時のみ)
        /// 実際の更新処理を行う
        /// </summary>
        /// <param name="inData">更新データ</param>
        /// <param name="isSame">更新要否の判定メソッド</param>
        /// <param name="updater">更新メソッド</param>
        /// <param name="option">更新処理オプション</param>
        /// <returns>更新されたDB内容</returns>
        private DtDeliveryFile Update(
            DtDeliveryFile inData,
            Func <DBAccessor.Models.DtDeliveryFile, DtDeliveryFile, bool> isSame,
            Func <DBAccessor.Models.RmsDbContext, DBAccessor.Models.DtDeliveryFile, DtDeliveryFile, DBAccessor.Models.DtDeliveryFile> updater,
            UpdateOption option)
        {
            // 複数回のSQL実行を競合なく実行・ロールバックさせるためにトランザクションを用いる
            using (DBAccessor.Models.RmsDbContext db = new DBAccessor.Models.RmsDbContext(_appSettings))
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        var entity = db.DtDeliveryFile
                                     .Include(x => x.DtDeliveryModel)
                                     .FirstOrDefault(x => x.Sid == inData.Sid);
                        if (entity == null)
                        {
                            return(null);
                        }

                        // isSame()の結果同一と判定されたら更新不要のため処理終了
                        if (isSame(entity, inData))
                        {
                            return(entity.ToModel());
                        }

                        if (option == UpdateOption.OnlyNotStart)
                        {
                            // 指定した配信ファイルSIDを持つ配信グループを検索し、そのすべての配信ステータスが未配信状態であるかチェックする
                            var isAllNotStarted = db.DtDeliveryGroup
                                                  .Where(x => x.DeliveryFileSid == inData.Sid)
                                                  .Include(x => x.DeliveryGroupStatusS)
                                                  .All(x => x.DeliveryGroupStatusS.Code.Equals(Utility.Const.DeliveryGroupStatus.NotStarted));
                            if (!isAllNotStarted)
                            {
                                throw new RmsCannotChangeDeliveredFileException(string.Format("配信前状態ではないDT_DELIVERY_FILEテーブルのレコードをUpdateしようとしました。(DT_DELIVERY_FILE.SID = {0})", inData.Sid));
                            }
                        }

                        // 情報の更新
                        entity = updater(db, entity, inData);

                        // コンテキスト管理のRowVersionを投入値に置き換えて、DBデータと比較させる(Attatch処理以外では必要)
                        db.Entry(entity).Property(e => e.RowVersion).OriginalValue = inData.RowVersion;

                        var p = db.DtDeliveryFile.Update(entity);

                        db.SaveChanges();

                        // トランザクション終了
                        tran.Commit();

                        return(p.Entity.ToModel());
                    }
                    catch (ValidationException e)
                    {
                        throw new RmsParameterException(e.ValidationResult.ErrorMessage, e);
                    }
                    catch (DbUpdateConcurrencyException e)
                    {
                        // RowVersion衝突が起きた
                        tran.Rollback();
                        throw new RmsConflictException("DT_DELIVERY_FILEテーブルのUpdateで競合が発生しました。", e);
                    }
                    catch
                    {
                        // SqlExceptionであれば再試行される
                        tran.Rollback();
                        throw;
                    }
                }
        }
示例#16
0
        protected override int Execute()
        {
            base.Execute();

            if (FromCli && !string.IsNullOrEmpty(PackageIdArgument.ParsedValue))
            {
                var packageId            = PackageIdArgument.ParsedValue;
                var resolvePackageResult = DotNetRunner.ResolvePackage(packageId, SourceOption.ParsedValue, UpdateOption.HasValue(), string.Empty);

                if (resolvePackageResult.success)
                {
                    var program = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                                                ? Path.Combine(DotNetRunner.CliFolderPathCalculator.ToolsShimPath, resolvePackageResult.packageId)
                                                : resolvePackageResult.packageId;

                    var run = ProcessRunner.Create(program)
                              .IsGenerator()
                              .WithArgument(Name);

                    foreach (var option in Options)
                    {
                        if (option.HasValue())
                        {
                            run.WithArgument("--" + option.LongName, option.Value());
                        }
                    }

                    run.Execute(false);
                    return(1);
                }

                Log.Error($"Could not execute {Name} command for this packageId.");
                return(-1);
            }

            return(0);
        }