Ejemplo n.º 1
0
 public static IRelayCommand ViewModelExecute(this IExecution sender, IBaseOperation execute, [CallerMemberName] string name = "", object precheck = null)
 {
     return(ViewModelExecute(sender, new BaseViewModelExecute(new List <IBaseOperation>()
     {
         execute
     }), null, name, precheck));
 }
Ejemplo n.º 2
0
 public static IRelayCommand ViewModelExecute(this IExecution sender, IBaseOperation execute, int timeout, [CallerMemberName] string name = "")
 {
     return(ViewModelExecute(sender, new BaseViewModelExecute(new List <IBaseOperation>()
     {
         execute
     }), timeout, name));
 }
Ejemplo n.º 3
0
 public static IRelayCommand ViewModelExecute(this IExecution sender, IBaseOperation execute, Func <object, bool> canExecute, [CallerMemberName] string name = "")
 {
     return(ViewModelExecute(sender, new BaseViewModelExecute(new List <IBaseOperation>()
     {
         execute
     }), canExecute, name));
 }
Ejemplo n.º 4
0
        private void OnOperationFinalized(IBaseOperation operation)
        {
            operationsInProgress.Remove(operation);

            if (operationsInProgress.Any())
            {
                return;
            }

            var errorMessage = LastErrorMessage;

            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                EditorApplication.update -= CheckInternetReachability;
                EditorApplication.update += CheckInternetReachability;

                errorMessage = "You seem to be offline.";
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                SetStatusMessage(StatusType.Error, errorMessage);
            }
            else
            {
                SetDefaultMessage(LastUpdateTime);
            }
        }
Ejemplo n.º 5
0
        public void Embed(Action <PackageInfo> onSuccess = null)
        {
            if (Current == null || PackageOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateEmbedOperation();

            packageOperationInstance       = operation;
            OnEmbedOperationFinalizedEvent = () =>
            {
                EmbedSignal.Operation           = null;
                operation.OnOperationFinalized -= OnEmbedOperationFinalizedEvent;
            };

            OnEmbedOperationSuccessEvent = info =>
            {
                onSuccess?.Invoke(info);
                operation.OnOperationSuccess -= OnEmbedOperationSuccessEvent;
            };

            operation.OnOperationSuccess   += OnEmbedOperationSuccessEvent;
            operation.OnOperationFinalized += OnEmbedOperationFinalizedEvent;
            EmbedSignal.SetOperation(operation);

            operation.EmbedPackageAsync(Current);
        }
Ejemplo n.º 6
0
 private void OnOperationFinalized(IBaseOperation operation)
 {
     operationsInProgress.Remove(operation);
     if (operationsInProgress.Any())
     {
         return;
     }
     UpdateStatusMessage();
 }
Ejemplo n.º 7
0
        internal static void AddFromId(string packageId)
        {
            if (AddRemoveOperationInProgress)
            {
                return;
            }
            var operation = OperationFactory.Instance.CreateAddOperation();

            addRemoveOperationInstance = operation;
            operation.AddPackageAsync(packageId);
        }
 private void UpdateLoading(IBaseOperation operation)
 {
     if (operation == null || operation.IsCompleted)
     {
         SetLoading(false);
     }
     else
     {
         operation.OnOperationFinalized += OnOperationFinalized;
         SetLoading(true);
     }
 }
Ejemplo n.º 9
0
        internal void OnListOrSearchOperation(IBaseOperation operation)
        {
            if (operation == null || operation.IsCompleted)
            {
                return;
            }
            operationsInProgress.Add(operation);
            operation.OnOperationFinalized += () => { OnOperationFinalized(operation); };
            operation.OnOperationError     += OnOperationError;

            SetStatusMessage(StatusType.Loading, "Loading packages...");
        }
Ejemplo n.º 10
0
        public override Task <TResult> HandleAsync(IBaseOperation operation,
                                                   IServiceProvider serviceProvider,
                                                   CancellationToken cancellationToken)
        {
            Task <TResult> HandleAsync() => serviceProvider.GetRequiredService <IOperationHandler <TOperation, TResult> >().HandleAsync((TOperation)operation, cancellationToken);

            var filters = serviceProvider.GetServices <IOperationFilter <TOperation, TResult> >();

            return(filters
                   .Reverse()
                   .Aggregate((OperationHandlerDelegate <TResult>)HandleAsync,
                              (next, filter) => () => filter.FilterAsync((TOperation)operation, cancellationToken, next))());
        }
Ejemplo n.º 11
0
        internal static void AddFromUrl(string url)
        {
            if (AddRemoveOperationInProgress)
            {
                return;
            }
            var operation = OperationFactory.Instance.CreateAddOperation();

            addRemoveOperationInstance = operation;
            // convert SCP-like syntax to SSH URL as currently UPM doesn't support it
            if (url.ToLower().StartsWith("git@"))
            {
                url = "ssh://" + url.Replace(':', '/');
            }
            operation.AddPackageAsync(url);
        }
Ejemplo n.º 12
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            _operation = PageInitialization.InitializeOperation("chrome");

            _operation.BrowseThisWebSite(ConfigurationManager.AppSettings["website"]);

            _operation.GoToDefaultTab();

            //LOL
            for (int i = 0; i < Int32.Parse(TextBoxClickCount.Text); i++)
            {
                _operation.ClickTheButton();
            }

            _operation.Quit();

            _process.EndSession("drivers".GetValue());
        }
Ejemplo n.º 13
0
        private IBaseOperation CreateOperation(Models.ISchedulablePlan plan, Options options)
        {
            IBaseOperation result = null;

            switch (options.PlanType)
            {
            case PlanTypeEnum.Backup:
                result = CreateBackupOperation(plan as Models.BackupPlan);
                //result = CreateBackupOperation(plan as Models.BackupPlan);
                break;

            case PlanTypeEnum.Restore:
                result = CreateRestoreOperation(plan as Models.RestorePlan);
                //result = CreateRestoreOperation(plan as Models.RestorePlan);
                break;
            }

            return(result);
        }
Ejemplo n.º 14
0
        private void Manp_Items_Shown(object sender, EventArgs e)
        {
            DataHolder     dataHolder    = new DataHolder();
            IBaseOperation loadOperation = dataHolder.LoadEnumData();

            if (!loadOperation.Successful)
            {
                OnLoadError(loadOperation.Fail);
                return;
            }
            lookUpItemType.Properties.DataSource      = dataHolder.ItemTypes;
            lookupPriceCalcType.Properties.DataSource = dataHolder.LineCalcTypes;

            if (Id == 0)
            {
                Item = new Item();
            }
            else
            {
                // GET DATA
                Operation <Item> op_item = OperationHandler.GetItemById(Id);
                if (!op_item.Successful)
                {
                    OnLoadError(op_item.Fail);
                    return;
                }
                Item = op_item.Value;
                lookUpItemType.Enabled = false;
            }
            bindTool.BindControl(txtGroup1, nameof(Item.Group1));
            bindTool.BindControl(txtGroup2, nameof(Item.Group2));
            bindTool.BindControl(txtGroup3, nameof(Item.Group3));
            bindTool.BindControl(txtGroup4, nameof(Item.Group4));
            bindTool.BindControl(txtItemCode, nameof(Item.ItemCode));
            bindTool.BindControl(txtItemName, nameof(Item.ItemName));
            bindTool.BindControl(lookUpItemType, nameof(Item.ItemTypeId));
            bindTool.BindControl(lookupPriceCalcType, nameof(Item.LineCalcTypeId));
            bindTool.BindControl(spLength, nameof(Item.Length));
            bindTool.BindControl(spWidth, nameof(Item.Width));
            bindTool.BindControl(chkIsLineService, nameof(Item.IsLineService));
            bindTool.DataObject = Item;
        }
Ejemplo n.º 15
0
        internal static void AddFromLocalDisk(string path)
        {
            if (AddRemoveOperationInProgress)
            {
                return;
            }

            var packageJson = PackageJsonHelper.Load(path);

            if (null == packageJson)
            {
                Debug.LogError(string.Format("Invalid package path: cannot find \"{0}\".", path));
                return;
            }

            var operation = OperationFactory.Instance.CreateAddOperation();

            addRemoveOperationInstance = operation;
            operation.AddPackageAsync(packageJson.PackageInfo);
        }
Ejemplo n.º 16
0
        public void Remove()
        {
            if (Current == null || AddRemoveOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateRemoveOperation();

            addRemoveOperationInstance      = operation;
            OnRemoveOperationFinalizedEvent = () =>
            {
                RemoveSignal.Operation          = null;
                operation.OnOperationFinalized -= OnRemoveOperationFinalizedEvent;
            };

            operation.OnOperationFinalized += OnRemoveOperationFinalizedEvent;
            RemoveSignal.SetOperation(operation);

            operation.RemovePackageAsync(Current);
        }
Ejemplo n.º 17
0
        internal void Add(PackageInfo packageInfo)
        {
            if (packageInfo == Current || AddRemoveOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateAddOperation();

            addRemoveOperationInstance   = operation;
            OnAddOperationFinalizedEvent = () =>
            {
                AddSignal.Operation             = null;
                operation.OnOperationFinalized -= OnAddOperationFinalizedEvent;
            };

            operation.OnOperationFinalized += OnAddOperationFinalizedEvent;

            AddSignal.SetOperation(operation);
            operation.AddPackageAsync(packageInfo);
        }
Ejemplo n.º 18
0
        public void Remove()
        {
            if (Current == null || PackageOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateRemoveOperation();

            packageOperationInstance        = operation;
            OnRemoveOperationFinalizedEvent = () =>
            {
                RemoveSignal.Operation          = null;
                operation.OnOperationFinalized -= OnRemoveOperationFinalizedEvent;
                PackageManagerWindow.FetchListOfflineCacheForAllWindows();
            };

            operation.OnOperationFinalized += OnRemoveOperationFinalizedEvent;
            RemoveSignal.SetOperation(operation);

            operation.RemovePackageAsync(Current);
        }
Ejemplo n.º 19
0
        internal void Add(PackageInfo packageInfo)
        {
            if (packageInfo == Current || PackageOperationInProgress)
            {
                return;
            }

            var operation = OperationFactory.Instance.CreateAddOperation();

            packageOperationInstance     = operation;
            OnAddOperationFinalizedEvent = () =>
            {
                AddSignal.Operation             = null;
                operation.OnOperationFinalized -= OnAddOperationFinalizedEvent;
                PackageManagerWindow.FetchListOfflineCacheForAllWindows();
            };

            operation.OnOperationFinalized += OnAddOperationFinalizedEvent;

            AddSignal.SetOperation(operation);
            operation.AddPackageAsync(packageInfo);
        }
Ejemplo n.º 20
0
 public abstract Task <TResult> HandleAsync(IBaseOperation operation,
                                            IServiceProvider serviceProvider,
                                            CancellationToken cancellationToken);
Ejemplo n.º 21
0
        private void Manp_CardTransaction_Shown(object sender, EventArgs e)
        {
            if (!IsEditMode)
            {
                foreach (Control c in grpCenter.Controls)
                {
                    c.Enabled = false;
                }
                btnOk.Enabled = false;
            }
            List <IBaseOperation> loadOperations = new List <IBaseOperation>();

            IBaseOperation baseOperation = dataHolder.LoadEnumData();

            loadOperations.Add(baseOperation);

            Operation <List <CardView> > op_CardMaster = OperationHandler.GetCardsByUserId(StaticData.CurrentUserId);

            loadOperations.Add(op_CardMaster);

            if (Id != 0)
            {
                Operation <CardFiche> op_ExistingCardFiche = OperationHandler.GetCardFicheById(Id);
                loadOperations.Add(op_ExistingCardFiche);
                cardFiche  = op_ExistingCardFiche.Value;
                creditLine = cardFiche.Lines.Where(x => x.SignType < 0).FirstOrDefault();
                debitLine  = cardFiche.Lines.Where(x => x.SignType > 0).FirstOrDefault();
            }
            else
            {
                cardFiche             = new CardFiche();
                cardFiche.CreatedDate = DateTime.Now;
                cardFiche.CreatedBy   = StaticData.CurrentUserId;
                cardFiche.StatusId    = 11;
            }

            foreach (IBaseOperation ibop in loadOperations)
            {
                if (!ibop.Successful)
                {
                    SetError(ibop.Fail);
                    return;
                }
            }

            Cards     = op_CardMaster.Value;
            CashTypes = dataHolder.CashTypes;
            lookUpCashType.Properties.DataSource         = CashTypes;
            searchLookUpSourceCard.Properties.DataSource = Cards;
            searchLookUpDestCard.Properties.DataSource   = Cards;


            ficheBindTool.BindControl(lookUpCashType, nameof(cardFiche.CashTypeId));
            ficheBindTool.BindControl(txtNote, nameof(cardFiche.Note));
            ficheBindTool.BindControl(txtFicheno, nameof(cardFiche.Ficheno));

            if (creditLine == null)
            {
                creditLine = new CardFicheLine();
            }
            creditLineBindTool.BindControl(searchLookUpSourceCard, nameof(creditLine.CardId));
            creditLineBindTool.BindControl(sourceCurrencyRate, nameof(creditLine.CurrencyRate));
            creditLineBindTool.BindControl(sourceAmount, nameof(creditLine.Total));

            if (debitLine == null)
            {
                debitLine = new CardFicheLine();
            }
            debitLineBindTool.BindControl(searchLookUpDestCard, nameof(debitLine.CardId));
            debitLineBindTool.BindControl(destCurrencyRate, nameof(debitLine.CurrencyRate));
            debitLineBindTool.BindControl(destAmount, nameof(debitLine.Total));

            ficheBindTool.DataObject      = cardFiche;
            creditLineBindTool.DataObject = creditLine;
            debitLineBindTool.DataObject  = debitLine;

            txtDate.Text = cardFiche.CreatedDate.ToString(StaticData.DateTimeFromatStr);

            ControlCurrencies();
            //if (injected)
            //{


            //    //CardView sourceCard = Cards.Where(x => x.Id == sourceCardId).FirstOrDefault();
            //    //lookUpCurrency.EditValue = sourceCard?.CurrencyId;
            //    //searchLookUpSourceCard.EditValue = sourceCard?.Id;
            //    //searchLookUpDestCard.EditValue = destCardId;
            //    //sourceAmount.EditValue = amount;
            //    //txtNote.Text = note;
            //    ////lookUpCurrency.ReadOnly = true;
            //    //cashTransaction.ConnectedFicheId = connectedInvoiceId;
            //}
        }
Ejemplo n.º 22
0
        private void Run()
        {
            // Load informed plan
            Models.ISchedulablePlan plan = LoadPlan(Options);
            if (plan == null)
            {
                logger.Fatal("The {0} plan with id {1} does not exist.",
                             Options.PlanType.ToString().ToLowerInvariant(), Options.PlanIdentifier);
                ExitShowingHelpText(1);
            }

            Model = plan;

            if (Options.Verbose)
            {
                logger.Info("Running {0} plan #{1}", Options.PlanType.ToString().ToLowerInvariant(), Options.PlanIdentifier);
            }

#if !DEBUG
            try
#endif
            {
                RunningOperation = CreateOperation(plan, Options);

                RunningOperation.Start();

                while (true)
                {
                    if (!IsReleaseVersion && System.Environment.UserInteractive)
                    {
                        if (ConsoleAppHelper.TerminationRequestedEvent.WaitOne(1))
                        {
                            if (RunningOperation != null && RunningOperation.IsRunning)
                            {
                                RunningOperation.Cancel();
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    if (RunningOperationEndedEvent.WaitOne(100))
                    {
                        break;
                    }

                    RunningOperation.DoEvents();
                }

                logger.Info("Operation finished.");

                Handler.Client.WaitUntilDone();

                RunningOperation.SendReport();
            }
#if !DEBUG
            catch (Exception ex)
            {
                string message = ex.Message;

                Handler.Send(Commands.ReportError(0, message));
                logger.Error(message);

                if (RunningOperation != null)
                {
                    BaseOperationReport report = RunningOperation.GetReport() as BaseOperationReport;
                    report.OperationStatus = OperationStatus.FAILED;
                    report.AddErrorMessage(message);
                    RunningOperation.SendReport();
                }

                Environment.Exit(1);
            }
#endif

#if DEBUG
            // Wait 10 seconds before exiting, only for debugging purposes.
            Thread.Sleep(10000);
#endif
        }
 private PageLoadErrorEventArgs OnPageLoadError(IBaseOperation op) {
   var handler = PageLoadError;
   var args = new PageLoadErrorEventArgs(op.Error);
   if (handler != null) {
     handler(this, args);
   }
   return args;
 }
Ejemplo n.º 24
0
 public void Init()
 {
     _operation = PageInitialization.InitializeOperation("chrome");
 }
Ejemplo n.º 25
0
        private void Manp_FichesNew_Shown(object sender, EventArgs e)
        {
            btnAddCashTran.Enabled          = btnDistributeExpences.Enabled =
                btnOk.Enabled               = searchLookUpCard.Enabled =
                    lookUpWarehouse.Enabled = IsEditMode;

            dataHolder = new DataHolder();
            IBaseOperation loadOper = dataHolder.LoadEnumData();

            if (!loadOper.Successful)
            {
                SetError(loadOper.Fail);
                return;
            }
            loadOper = dataHolder.LoadMasterData();
            if (!loadOper.Successful)
            {
                SetError(loadOper.Fail);
                return;
            }
            searchLookUpCard.Properties.DataSource = dataHolder.Cards;

            rpLookupItem.DataSource               = dataHolder.Items;
            rpLookupItem.DisplayMember            = "ItemName";
            rpLookupItem.ValueMember              = "Id";
            lookUpWarehouse.Properties.DataSource = dataHolder.Warehouses;

            foreach (ItemView item in dataHolder.Items.Where(x => x.IsLineService))
            {
                ToolStripMenuItem menuItem = new ToolStripMenuItem();
                menuItem.Tag    = item.Id;
                menuItem.Text   = item.ItemName;
                menuItem.Click += SrvBlukMenuItem_Click;
                tsBulkAddServices.DropDownItems.Add(menuItem);
            }



            if (isNew)
            {
                Fiche       = new FicheMasterView();
                Fiche.Lines = new List <FicheLineView>();
            }



            else
            {
                Operation <FicheMasterView> op_ExistingFiche = OperationHandler.GetFicheById(Id);
                if (!op_ExistingFiche.Successful)
                {
                    SetError(op_ExistingFiche.Fail);
                    return;
                }
                Fiche        = op_ExistingFiche.Value;
                txtDate.Text = Fiche.CreatedDate.ToString("dd.MM.yyyy");
                DocumentType = dataHolder.DocumentTypes.Where(x => x.Id == Fiche.DocTypeId).First();
                if (CreateInvoiceFromOrderFiche)
                {
                    Fiche.SourceDocument = Fiche.Ficheno;
                    Id = Fiche.Id = 0;
                    Fiche.DocTypeId = 2;
                    btnOk.Text      = "Fakturala";
                }
            }
            if (DocumentType.Id == 1 || DocumentType.Id == 2)
            {
                gvLines.Columns["LineExpense"].Visible = false;
                tabNavigationExpencesPage.PageVisible  = false;
            }
            else
            {
                gvLines.Columns["LineServicesTotal"].Visible = false;
                gvLines.Columns["IsCustomerItem"].Visible    = false;
                gvLines.Columns["IsSketched"].Visible        = false;
                gvLines.Columns["IsTemplated"].Visible       = false;
                gcServicesOfLine.Visible = false;
                gcLines.ContextMenuStrip = null;
                tabNavigationExpencesPage.PageVisible = true;
            }

            bindTool.BindControl(searchLookUpCard, nameof(Fiche.CardId));
            bindTool.BindControl(lookUpWarehouse, nameof(Fiche.SourceWarehouse));
            bindTool.BindControl(txtFicheno, nameof(Fiche.Ficheno));
            bindTool.BindControl(txtNote1, nameof(Fiche.Note1));
            bindTool.BindControl(txtNote2, nameof(Fiche.Note2));
            bindTool.BindControl(txtNote3, nameof(Fiche.Note3));
            bindTool.BindControl(txtNote4, nameof(Fiche.Note4));
            bindTool.BindControl(txtSourceDoc, nameof(Fiche.SourceDocument));
            bindTool.BindControl(spCurrencyRate, nameof(Fiche.CurrencyRate));
            bindTool.DataObject = Fiche;

            if (dataHolder.Warehouses.Count > 0)
            {
                lookUpWarehouse.EditValue = dataHolder.Warehouses.First().Number;
            }

            gcLines.DataSource = null;
            gcLines.DataSource = Fiche.Lines;
            // gcLines.DataSource = Fiche.FicheLines;
            //cmbItemType.SelectedIndex = 0;
            RefreshCashTrans();
        }
Ejemplo n.º 26
0
 public static IRelayCommand ViewModelExecute(this IExecution sender, IBaseOperation execute, [CallerMemberName] string name = "")
 {
     return ViewModelExecute(sender, new BaseViewModelExecute(new List<IBaseOperation>() { execute }), name);
 }