Exemple #1
0
        public Save(VideoInfo video)
        {
            var store = new Store.Store().GetData();

            Filename   = GetFilename(video);
            FilePath   = GetFilePath(video);
            FolderPath = GetFolderPath();
        }
Exemple #2
0
        public MainWindowViewModel(Store.Store <Domain.State, Domain.Actions> store)
        {
            _store = store;

            AddTodoCommand        = new DelegateCommand(AddTodo, AddTodoCanExecute);
            ToggleCompleteCommand = new DelegateCommand <Domain.Todo>(ToggleComplete);
            ToggleFilterCommand   = new DelegateCommand <string>(ToggleFilter);

            _store.StateUpdated += UpdateUI;
        }
Exemple #3
0
        /// <summary>
        /// ファイルの存在を確認
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool Exists(string id)
        {
            var    data    = new Store.Store().GetData();
            string dirPath = data.GetVideoFilePath();

            if (!Directory.Exists(dirPath))
            {
                return(false);
            }

            return(Directory.GetFiles(dirPath, $"[{id}]*").Length > 0);
        }
Exemple #4
0
        /// <summary>
        /// ファイル名を取得する
        /// </summary>
        private string GetFilename(VideoInfo video)
        {
            var    store  = new Store.Store().GetData();
            string format = store.GetVideoFileFormat();

            return(this.RemoveInvalidChar(
                       format.Replace("<id>", video.Id)
                       .Replace("<title>", video.Title)
                       .Replace("<user>", video.User)
                       + ".xml"
                       ));
        }
        public override UserAccount Execute()
        {
            Interaction.Write("\nSelect where do you want to go?\n");
            Interaction.Write(_placeBehaviour.PrintPlaces());
            var index = Interaction.ReadNumber();

            if (index <= 0 || index > _placeBehaviour.places.Count)
            {
                interaction.Write("Your number is innocent.Enter another number!");
                return(Execute());
            }

            var result = _placeBehaviour.Execute(_placeBehaviour.GetPlaceType(index - 1));

            if (!result.Accepted)
            {
                Interaction.Write("Oves Du :D\n");
                return(Execute());
            }


            if ((Places)(index - 1) == Places.Home || (Places)(index - 1) == Places.Back)
            {
                Interaction.Write($"{result.Item}\n");
                return(Execute());
            }

            if ((Places)(index - 1) == Places.Shop)
            {
                var store            = new Store.Store(interaction);
                var suggestBehaviour = new SuggestBehaviourInteraction(userAccount, store, interaction);
                suggestBehaviour.Execute();
                Interaction.Write($"{result.Item}\n");

                return(Execute());
            }

            interaction.Write("Enter (b-back) if you want to go back: ");
            string str = interaction.Read();

            str = str.ToLower();

            if (str.Equals("b") || str.Equals("back"))
            {
                interaction.Write("Now you are at home!");
                return(Execute());
            }

            interaction.Write($"{result.Item}");
            return(Execute());
            //return result.Item;
        }
Exemple #6
0
        public static IEffectMethodWrapper FromObject(Store.Store store, Effect effect)
        {
            var effectType = effect.GetType();
            var effectTypeGenericArguments = effectType.BaseType.GenericTypeArguments;
            var typeOfInputAction          = effectTypeGenericArguments[0].FullName;

            var invokeMethod    = effectType.GetMethod(Effect.InvokeMethodName);
            var actionArg       = invokeMethod.GetParameters()[0];
            var actionParameter = Expression.Parameter(actionArg.ParameterType, actionArg.Name);

            var methodExpr = Expression.Lambda(
                Expression.Call(Expression.Constant(effect, effectType), invokeMethod, actionParameter),
                actionParameter
                );

            if (effectTypeGenericArguments.Length == 1)
            {
                return((IEffectMethodWrapper)typeof(EffectMethodWrapper <>)
                       .MakeGenericType(new Type[]
                {
                    actionArg.ParameterType
                })
                       .GetConstructors()[0]
                       .Invoke(new object[]
                {
                    typeOfInputAction,
                    methodExpr.Compile()
                }));
            }
            else if (effectTypeGenericArguments.Length == 2)
            {
                return((IEffectMethodWrapper)typeof(EffectMethodWrapper <,>)
                       .MakeGenericType(new Type[]
                {
                    actionArg.ParameterType,
                    invokeMethod.ReturnType.GenericTypeArguments[0]
                })
                       .GetConstructors()[0]
                       .Invoke(new object[]
                {
                    typeOfInputAction,
                    methodExpr.Compile(),
                    store
                }));
            }
            else
            {
                throw new InvalidOperationException();
            }
        }
Exemple #7
0
        public static async Task <List <string> > GetIDLists()
        {
            var storeData = new Store.Store().GetData();
            var ids       = new List <string>();

            //チャンネルが指定されているかどうか
            if (!storeData.DoDownloadChannel())
            {
                ids.Add(storeData.GetNicoID());
            }
            else
            {
                var channnelClient = new WWW.Channel();
                ids.AddRange(await channnelClient.GetIdList(storeData.GetChannnelName()));
            }
            return(ids);
        }
        public BankingPageProps MapState(State state, Store.Store store)
        {
            var accountTypeSumProps =
                state.Accounts
                .GroupBy(x => x.AccountType)
                .OrderByDescending(x => x.Sum(y => y.Balance))
                .Select(
                    x => new TotalProps(
                        x.Key.ToString(),
                        x.Sum(y => y.Balance).ToString("c"),
                        GetTextColor(x.Sum(y => y.Balance))))
                .ToImmutableArray();

            var accountsProps = state.Accounts.Select(
                x => new AccountProps(
                    x.Name,
                    x.Balance.ToString("c"),
                    GetTextColor(x.Balance),
                    () => store.Dispatch(new DepositAction(x.Name)),
                    () => store.Dispatch(new WithdrawAction(x.Name))
                    )).OrderBy(x => x.Name)
                                .ToImmutableArray();

            var grandTotal = state.Accounts.Sum(x => x.Balance);

            return(new BankingPageProps(
                       accountsProps,
                       accountTypeSumProps
                       ));

            Colour GetTextColor(int balance)
            {
                if (balance < 0)
                {
                    return(new Colour(200, 50, 50));
                }

                return(new Colour(100, 100, 100));
            }
        }
        public static void Main(string[] args)
        {
            ///*
            banco = new Store.Store();
            JavaScriptSerializer ser = new JavaScriptSerializer();

            OEE.OEE foo = ser.Deserialize <OEE.OEE>(banco.Fabrica);

            oee         = new OEE.OEE(foo.quantidade, foo.Linhas, foo.DXM_Endress, foo.emulador, foo.tickLog, foo.zerou_turno);
            oee.timeOut = foo.timeOut;
            if (oee.DXM_Tcp)
            {
                dxm = new ModbusClient(oee.DXM_Endress, 502);
            }
            else
            {
                dxm = new ModbusClient(oee.DXM_Endress);
            }

            ThreadStart start = new ThreadStart(leituraDXM);
            Thread      acao  = new Thread(start);
            ThreadStart log   = new ThreadStart(DXMLog);
            Thread      acao2 = new Thread(log);
            ThreadStart log2  = new ThreadStart(poolRegistro);
            Thread      acao3 = new Thread(log2);

            acao3.Start();
            acao.Start();
            acao2.Start();

            //*/

            var pathToExec = Process.GetCurrentProcess().MainModule.FileName;

            _pathContentRoot = Path.GetDirectoryName(pathToExec);

            //CreateWebHostBuilder(args).Build().RunAsCustomService();
            CreateWebHostBuilder(args).Build().Run();
        }
Exemple #10
0
        /// <summary>
        /// NG処理
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public bool JudgeAll(NicoComment::JsonComment comment)
        {
            var data = new Store.Store().GetData();

            if (IsTimeNg(comment, data.GetNgTime()))
            {
                return(true);
            }
            if (IsCommandNg(comment, data.GetNgCommand()))
            {
                return(true);
            }
            if (IsUserNg(comment, data.GetNgUser()))
            {
                return(true);
            }
            if (IsWordNg(comment, data.GetNgWord()))
            {
                return(true);
            }
            return(false);
        }
        private static IStore CreateStore()
        {
            IStore store = new Store.Store(
                // Loads up the instance of the Store with the last known State.
                // In this example a new state is always being created, but that's
                // the place where you should load your current State from disk
                // or whatever you prefer for persisting data.
                InitialState.Create(),

                // Register all Reducers that should be applied to dispatched
                // actions.
                RootReducer.Create()
                );

            store.Subscribe(SubscriptionType <AppState> .NewStateSubscription(state =>
            {
                // The State was updated. That's the moment where you
                // should persist the current state.
            }));

            return(store);
        }
        public BankingPageProps MapState(State state, Store.Store store)
        {
            var accountsProps = state.Accounts.Select(
                x => new AccountProps(
                    name: x.Name,
                    balance: x.Balance.ToString("c"),
                    textColor: GetTextColor(balance: x.Balance),
                    didDeposit: () => store.Dispatch(new DepositAction(title: x.Name)),
                    didWithdraw: () => store.Dispatch(new WithdrawAction(title: x.Name))
                    )).OrderBy(x => x.Name)
                                .ToImmutableArray();

            var totalsProps =
                state.Accounts
                .GroupBy(x => x.AccountType)
                .OrderByDescending(x => x.Sum(selector: y => y.Balance))
                .Select(
                    x => new TotalProps(
                        text: x.Key.ToString(),
                        sum: x.Sum(selector: y => y.Balance).ToString("c"),
                        textColor: GetTextColor(balance: x.Sum(selector: y => y.Balance))))
                .ToImmutableArray();

            return(new BankingPageProps(
                       accounts: accountsProps,
                       totals: totalsProps
                       ));

            Color GetTextColor(int balance)
            {
                if (balance < 0)
                {
                    return(Color.OrangeRed);
                }

                return(Color.DimGray);
            }
        }
Exemple #13
0
        public async Task <NicoEnums::GenelicErrorCode> DownloadComment(string id)
        {
            var  logger     = NicoLogger.GetLogger();
            var  storeData  = new Store.Store().GetData();
            bool fileExists = Utils.IO.Exists(id);

            if (fileExists)
            {
                if (storeData.DoSkipOverWrite())
                {
                    logger.Warn($"id:{id}は既に保存のため、スキップします");
                    return(NicoEnums.GenelicErrorCode.SKIP);
                }
                else if (!storeData.DoOverWrite())
                {
                    while (true)
                    {
                        logger.Warn($"id:{id}は既に保存済です。上書きしますか?(Y/N)");
                        string continueOrNot = Console.ReadLine();
                        if (Regex.IsMatch(continueOrNot, "[yY]"))
                        {
                            break;
                        }
                        else if (Regex.IsMatch(continueOrNot, "[nN]"))
                        {
                            logger.Log("処理をスキップします。");
                            return(NicoEnums::GenelicErrorCode.OK);
                        }
                        else
                        {
                            logger.Error("YまたはNで答えて下さい。");
                            continue;
                        }
                    }
                }
            }

            VideoInfo video;
            List <ComApi.CommentBody.Json.JsonComment> comment;

            using (var context = new NicoContext())
            {
                if (!await context.GetContent(id, "コメントのダウンロード"))
                {
                    logger.Error("セッションの確立に失敗しました。");
                    return(NicoEnums::GenelicErrorCode.ERROR);
                }

                //nullチェック
                if (context.ApiData == null)
                {
                    logger.Error("APIデータの取得に失敗しました。");
                    return(NicoEnums.GenelicErrorCode.ERROR);
                }

                //動画情報
                video = context.GetVideoInfo();

                //投稿日時を指定
                storeData.SetPostDate(video.PostedDateTime);

                var comCliet = new CommentClient(context);
                try
                {
                    comment = await comCliet.GetComment(context.ApiData, context, storeData.DoDownloadCommentLog());
                }
                catch (Exception e)
                {
                    logger.Error(e.Message);
                    return(NicoEnums.GenelicErrorCode.ERROR);
                }
            }


            //保存
            var  save     = new Nicome.IO.Save(video);
            bool ioResult = save.TryWriteComment(comment);

            if (!ioResult)
            {
                return(NicoEnums::GenelicErrorCode.ERROR);
            }

            logger.Log("コメントの保存が完了しました。");

            return(NicoEnums.GenelicErrorCode.OK);
        }
Exemple #14
0
        public virtual void Deliver(Employee deliverEmployee, string deliverNote)
        {
            // چک شود که فاکتور برگشت از فروش نباشد
            if (Sale.IsRollbackSale)
            {
                _bussinessRules.Add(SaleBusinessRules.ThisIsRollbackCannotDeliver);
                return;
            }

            // چک شود که آیتم قبلا تحویل نشده باشد
            if (DeliverEmployee != null)
            {
                _bussinessRules.Add(SaleBusinessRules.AlreadyDeliverd);
                return;
            }

            // چک شود که فاکتور تأیید شده باشد
            if (!Sale.Closed)
            {
                _bussinessRules.Add(SaleBusinessRules.SaleIsNotClosedCantDeliver);
                return;
            }

            // چک شود حساب مشتری به اندازه کافی بستانکار باشد
            // ??

            // پیدا کردن انبارهای فرعی کارمند تحویل
            IEnumerable <Store.Store> stores = deliverEmployee.Stores;

            bool atLeastOneStoreContainsThisProduct = false;

            // مشخص کردن اولین انباری که کالای مورد نظر در آن وجود دارد
            foreach (Store.Store store in stores)
            {
                // اگر انبار حاوی کالای مورد نظر باشد
                if (store.Products.Contains(ProductPrice.Product))
                {
                    atLeastOneStoreContainsThisProduct = true;

                    // اگر تعداد کالا در انبار کافی باشد
                    if (store.StoreProducts.First(w => w.Product == ProductPrice.Product).UnitsInStock >= Units)
                    {
                        // تحویل
                        SetDeliver(deliverEmployee, deliverNote);

                        // ذخیره کردن انباری که کالا را تحویل داده در دیتابیس
                        DeliverStore = store;

                        // کسر از انبار
                        store.StoreProducts.First(w => w.Product == ProductPrice.Product).UnitsInStock -= Units;
                        return;
                    }
                }
            }

            // اگر کامپایلر به اینجا رسید یعنی انبارها حاوی کالای مورد نظر نبوده یا موجودی کافی نبوده و تحویل انجام نشده
            if (!atLeastOneStoreContainsThisProduct)
            {
                //  هیچ یک از انبارها حاوی کالای مورد نظر نبوده
                _bussinessRules.Add(SaleBusinessRules.StoresNotContainThisProduct);
            }
            else
            {
                //  حداقل یکی از انبارها حاوی کالای مورد نظر بوده ولی موجودی کافی نیست
                _bussinessRules.Add(SaleBusinessRules.UnitsInStockNotEnough);
            }
        }
Exemple #15
0
 public SuggestBehaviourInteraction(UserAccount userAccount, Store.Store store, IInteraction interaction) : base(interaction)
 {
     _userAccount = userAccount;
     _store       = store;
 }
Exemple #16
0
 public Shop()
 {
     var store = new Store.Store(interaction);
 }
Exemple #17
0
        /// <summary>
        /// 最大コメント数に達しているかどうか
        /// </summary>
        /// <returns></returns>
        public bool IsMax(int i)
        {
            var store = new Store.Store().GetData();

            return(store.IsMaxCommentSet() && this.Count > this.GetMaxComments() + 1000 * i);
        }
Exemple #18
0
        /// <summary>
        /// 最大コメント数を取得
        /// </summary>
        /// <returns></returns>
        private uint GetMaxComments()
        {
            var store = new Store.Store().GetData();

            return(store.IsMaxCommentSet() ? store.GetMaxComment() : 0);
        }
Exemple #19
0
        /// <summary>
        /// フォルダーのパスを取得
        /// </summary>
        /// <param name="video"></param>
        /// <returns></returns>
        private string GetFolderPath()
        {
            var store = new Store.Store().GetData();

            return(store.GetVideoFilePath());
        }