Ejemplo n.º 1
0
        private void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            List <string> existingIds = new List <string>();

            foreach (ItemObject existingItem in this.ItemList)
            {
                existingIds.Add(existingItem.ItemId);
            }
            foreach (ItemObject item in (ObservableCollection <ItemObject>)e.Result)
            {
                if (!existingIds.Contains(item.ItemId))
                {
                    this.ItemList.Add(item);
                    existingIds.Add(item.ItemId);
                }
            }
            this.ButtonVisibility = "True";
            this.ProgressText     = "Item Load Complete";
            if (this.ItemIdAbsentList.Count > 0)
            {
                AlertView window = new AlertView()
                {
                    DataContext = new AlertViewModel(this.ItemIdAbsentList, "Alert", "The following items were not found in the database.")
                };
                window.ShowDialog();
            }
        }
Ejemplo n.º 2
0
 public void nextOrCreateCommand()
 {
     AlertViewViewModel.Button button = new AlertViewViewModel.Button {
         name = "Okay"
     };
     if (string.IsNullOrWhiteSpace(_project_model_i.ProjectName) || string.IsNullOrWhiteSpace(_project_model_i.ProjectLocation) || _project_model_i.ProjectModel == null || _project_model_i.ProjectDate == DateTime.MinValue)
     {
         AlertView alertView = new AlertView("Not enough informations", "The informations you have provided to create a new project is not sufficient. Please fill essential fields.", AlertViewType.WARNING, button);
         alertView.ShowDialog();
     }
     else
     {
         DateTime current_date_time = DateTime.Now;
         _project_model_i.ProjectCreationDate = current_date_time;
         if (_project_model_i.ProjectModel.client_id.value == _project_model_i.ClientModels[0].id.value)
         {
             try {
                 this.nextButtonClicked();
             }
             catch (AlreadyExistsError) {
                 AlertView alertView = new AlertView("Project already exist", "The project you are trying to create is already exist, try a different project name.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (DirectoryNotFoundException) {
                 AlertView alertView = new AlertView("Invalid path", "The path you are trying to create the project is invalid, insert a correct path or explore a path.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (Exception err) {
                 Core.Reference.logger.logError(err);
                 AlertView alertView = new AlertView("Unknown error", "Unknown error has occured while creating a project. Please try again.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
         }
         else
         {
             try {
                 ProjectModelI.ProjectModelApi.model.client_id.value = ProjectModelI.SelectedClient.id.value;
                 CoreApp.getSingleton().createNewProject(ProjectModelI.ProjectModelApi, FolderBrowseCommand.FolderPath);
                 CoreApp.getSingleton().setDefaultProjectPath(FolderBrowseCommand.FolderPath);
                 NewProject.ProjectManager.closeWindow();
             }
             catch (AlreadyExistsError) {
                 AlertView alertView = new AlertView("Project already exist", "The project you are trying to create is already exist, try a different project name.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (DirectoryNotFoundException) {
                 AlertView alertView = new AlertView("Invalid path", "The path you are trying to create the project is invalid, insert a correct path or explore a path.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
             catch (Exception err) {
                 Core.Reference.logger.logError(err);
                 AlertView alertView = new AlertView("Unknown error", "Unknown error has occured while creating a project. Please try again.", AlertViewType.ERROR, button);
                 alertView.ShowDialog();
             }
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Checks that collumn headers are correct and alerts user if any are misspelled
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private void CheckColumnHeaders(string fileName)
        {
            List <string> wrongHeaders = ItemService.ValidateHeaderCollumns(fileName);

            if (wrongHeaders.Count > 0)
            {
                AlertView window = new AlertView
                {
                    DataContext = new AlertViewModel(wrongHeaders, "Alert", "The following columns did not match any existing values. Please adjust the header or remove this column before loading.")
                };
                window.ShowDialog();
            }
        }
Ejemplo n.º 4
0
 private void LoadItemWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     foreach (ItemObject item in (ObservableCollection <ItemObject>)e.Result)
     {
         this.ItemList.Add(item);
     }
     if (this.AbsentIds.Count > 0)
     {
         AlertView window = new AlertView
         {
             DataContext = new AlertViewModel(this.AbsentIds, "Alert", "The following item ids are either duplicates in the load sheet \r\n or they have not been previously saved to the database.")
         };
         window.ShowDialog();
     }
     this.ProgressCheck    = "Item Load Complete";
     this.ButtonVisibility = "True";
 }
Ejemplo n.º 5
0
        public void createNewProjectWithClient()
        {
            _client_model_i.api.model.id.value = DateTime.Now.Ticks; // TODO: consider change the pk
            _client_model_i.api.update();
            NewProjectViewModel new_project_view_model = NewClient.ProjectManager.NewProject.NewProjectViewModel;

            new_project_view_model.ProjectModelI.SelectedClient = _client_model_i.ClientModel;

            AlertViewViewModel.Button button = new AlertViewViewModel.Button {
                name = "Okay"
            };
            try {
                CoreApp.getSingleton().createNewProject(new_project_view_model.ProjectModelI.ProjectModelApi, new_project_view_model.FolderBrowseCommand.FolderPath);
                CoreApp.getSingleton().setDefaultProjectPath(new_project_view_model.FolderBrowseCommand.FolderPath);
                NewClient.ProjectManager.closeWindow();
            }
            catch (Exception err) {
                Core.Reference.logger.logError(err);
                AlertView alertView = new AlertView("Unknown error", "Unknown error has occured while creating a project. Please try again.", AlertViewType.ERROR, button);
                alertView.ShowDialog();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Copies the images for the given request into a folder on the users desktop
        /// </summary>
        public void PullImages()
        {
            ObservableCollection <ItemObject> items = new ObservableCollection <ItemObject>();

            foreach (Request r in this.SelectedRequestlingList)
            {
                items.Add(new ItemObject(1)
                {
                    ItemId       = r.ItemId,
                    ItemCategory = r.ItemCategory
                });
            }
            List <string> missingImages = ItemService.PullImages(items);

            if (missingImages.Count > 0)
            {
                AlertView window = new AlertView
                {
                    DataContext = new AlertViewModel(missingImages, "Alert", "The following images were not found in the captures folder or were too large.")
                };
                window.ShowDialog();
            }
        }
        private void SetTradingModeSell()
        {
            Dictionary<string, List<string>> selectedStrategyAndSymbol = new Dictionary<string, List<string>>();
            GetSelectedStrategyAndSymbol(selectedStrategyAndSymbol, ProcessType.SELL);
            if (selectedStrategyAndSymbol.Count == 0)
            {
                return;
            }
            string messageTextLine2 = CreateMessageText(selectedStrategyAndSymbol);

            AlertView view = new AlertView(AlertType.SELL, string.Empty, messageTextLine2, false);
            bool? status = view.ShowDialog();
            if (AlertView.AlertReturnType == AlertActionReturnType.YES)
            {
                string tradingMode = "Sell";
                SetOrderTradingMode(selectedStrategyAndSymbol, tradingMode);

                App.AppManager.Sell(selectedStrategyAndSymbol, false);
            }
            else
            {
                ClearSelectedStrategyAndSymbol();
            }
        }
        private void mnuStop_Click(object sender, RoutedEventArgs e)
        {
            Dictionary<string, List<string>> selectedStrategyAndSymbol = new Dictionary<string, List<string>>();

            GetSelectedStrategyAndSymbol(selectedStrategyAndSymbol, ProcessType.STOP);

            string messageTextLine2 = CreateMessageText(selectedStrategyAndSymbol);

            AlertView view = new AlertView(AlertType.STOP, string.Empty, messageTextLine2, false);
            bool? status = view.ShowDialog();
            if (status == true && AlertView.AlertReturnType == AlertActionReturnType.YES)
            {
                App.AppManager.Stop(selectedStrategyAndSymbol, false);
            }
            else
            {
                ClearSelectedStrategyAndSymbol();
            }
        }
Ejemplo n.º 9
0
        private void startStopRowButton_Click(object sender, RoutedEventArgs e)
        {
            App.AppManager.DataMgr.ClearProcessSelectionIndication();
            AlertType alertType = AlertType.START;
            if (dgAggregate.SelectedItem != null)
            {
                if (dgAggregate.SelectedItem is SummaryOrder)
                {
                    SummaryOrder order = dgAggregate.SelectedItem as SummaryOrder;
                    string key = order.StrategyId;
                    string strategy = order.StrategyName;

                    Dictionary<string, List<string>> selectedStrategyAndSymbol = new Dictionary<string, List<string>>();

                    bool? status = true;
                    AlertView.AlertReturnType = AlertActionReturnType.YES;
                    if (order.Status.Equals("Running"))
                    {
                        alertType = AlertType.STOP;

                        GetSelectedStrategyAndSymbol(key, selectedStrategyAndSymbol, alertType);

                        string messageTextLine3 = CreateMessageText(selectedStrategyAndSymbol);
                        string messageTextLine2 = string.Format("{0}", App.AppManager.DataMgr.StrategyList.Where(s => s.StrategyId == key).Select(s => s.StrategyName).FirstOrDefault());

                        AlertView view = new AlertView(alertType, messageTextLine2, messageTextLine3, true);
                        status = view.ShowDialog();
                    }
                    else
                    {
                        GetSelectedStrategyAndSymbol(key, selectedStrategyAndSymbol, alertType);
                    }

                    if (status == true && AlertView.AlertReturnType == AlertActionReturnType.YES)
                    {
                        if (alertType == AlertType.START)
                        {
                            App.AppManager.Start(selectedStrategyAndSymbol, true);
                            order.Status = App.AppManager.StgEngine.StrategyEngineStatus;
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(AlertView.AlertReturnSymbols))
                            {
                                if (AlertView.AlertReturnSymbols.Equals("ALL"))
                                {
                                    App.AppManager.Stop(selectedStrategyAndSymbol, true);
                                    order.Status = App.AppManager.StgEngine.StrategyEngineStatus;
                                }
                                else
                                {
                                    selectedStrategyAndSymbol = new Dictionary<string, List<string>>();
                                    selectedStrategyAndSymbol[key] = EZXWPFLibrary.Utils.StringUtils.StringTextToList(AlertView.AlertReturnSymbols, ',');
                                    App.AppManager.Stop(selectedStrategyAndSymbol, false);
                                    order.Status = App.AppManager.StgEngine.StrategyEngineStatus;
                                }
                            }
                            else
                            {
                                MessageBox.Show("No symbol is selected");
                            }
                        }
                    }
                    else
                    {
                        ClearSelectedStrategyAndSymbol(key);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private void lockUnLockRowButton_Click(object sender, RoutedEventArgs e)
        {
            App.AppManager.DataMgr.ClearProcessSelectionIndication();
            AlertType alertType = AlertType.LOCK;
            if (dgAggregate.SelectedItem != null)
            {
                if (dgAggregate.SelectedItem is SummaryOrder)
                {
                    SummaryOrder order = dgAggregate.SelectedItem as SummaryOrder;
                    string key = order.StrategyId;

                    if (order.Status.Equals("Lock"))
                    {
                        alertType = AlertType.UNLOCK;
                    }
                    Dictionary<string, List<string>> selectedStrategyAndSymbol = new Dictionary<string, List<string>>();

                    GetSelectedStrategyAndSymbol(key, selectedStrategyAndSymbol, alertType);
                    string messageTextLine3 = CreateMessageText(selectedStrategyAndSymbol);

                    string messageTextLine2 = string.Format("{0}", App.AppManager.DataMgr.StrategyList.Where(s => s.StrategyId == key).Select(s => s.StrategyName).FirstOrDefault());

                    AlertView view = new AlertView(alertType, messageTextLine2, messageTextLine3, true);
                    bool? status = view.ShowDialog();
                    if (status == true && AlertView.AlertReturnType == AlertActionReturnType.YES)
                    {
                        if (alertType == AlertType.LOCK)
                        {
                            App.AppManager.Lock(selectedStrategyAndSymbol, true);
                        }
                        else
                        {
                            App.AppManager.Unlock(selectedStrategyAndSymbol, true);
                        }
                    }
                    else
                    {
                        ClearSelectedStrategyAndSymbol(key);
                    }
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     Add item id input to the list of items to update.
        /// </summary>
        public void FindItemById()
        {
            if (!(string.IsNullOrEmpty(this.ItemIdSearchInput)))
            {
                if (this.ItemIdSearchInput.Length > 1)
                {
                    try
                    {
                        List <SearchItem> searchItems = ItemService.RetrieveFindItemSearchResults(this.ItemIdSearchInput, this.DisabledCheck);
                        if (searchItems.Count() == 0)
                        {
                            List <string> missingItems = new List <string>();
                            foreach (SearchItem searchItem in searchItems)
                            {
                                missingItems.Add(searchItem.ItemId);
                            }
                            AlertView window = new AlertView()
                            {
                                DataContext = new AlertViewModel(missingItems, "Alert", "No results were found for the following items. Or they were duplicates")
                            };
                            window.ShowDialog();
                        }
                        else if (searchItems.Count > 1)
                        {
                            FindItemResultListView window = new FindItemResultListView()
                            {
                                DataContext = new FindItemResultListViewModel(searchItems)
                            };
                            List <string> itemIds = new List <string>();
                            if (window.ShowDialog() == true)
                            {
                                ObservableCollection <SearchItem> ReturnedItems = (window.DataContext as FindItemResultListViewModel).ReturnSelectedItems();
                                // Items already in item list
                                foreach (SearchItem returnedItem in ReturnedItems)
                                {
                                    bool exists = false;
                                    // Items selected from search

                                    foreach (ItemObject CurrentItem in this.ItemList)
                                    {
                                        if (returnedItem.ItemId == CurrentItem.ItemId)
                                        {
                                            exists = true;
                                            break;
                                        }
                                    }
                                    if (!exists)
                                    {
                                        itemIds.Add(returnedItem.ItemId);
                                        this.ItemList.Add(ItemService.RetrieveItem(returnedItem.ItemId, this.ItemList.Count + 1));
                                    }
                                }
                                this.ItemLoadCount                     = this.SearchItemIds.Count;
                                this.ButtonVisibility                  = "False";
                                this.BackgroundWorkerState             = "SearchList";
                                BackgroundWorker.DoWork               += BackgroundWorker_DoWork;
                                BackgroundWorker.ProgressChanged      += BackgroundWorker_ProgressChanged;
                                BackgroundWorker.RunWorkerCompleted   += BackgroundWorker_RunWorkerCompleted;
                                BackgroundWorker.WorkerReportsProgress = true;
                                BackgroundWorker.RunWorkerAsync();
                                // this.SearchItemList = ReturnedItems;
                            }
                        }
                        else if (searchItems.Count == 1)
                        {
                            ObservableCollection <SearchItem> ReturnedItems = new ObservableCollection <SearchItem>()
                            {
                                searchItems[0]
                            };

                            foreach (SearchItem returnedItem in ReturnedItems)
                            {
                                bool exists = false;
                                foreach (ItemObject CurrentItem in this.ItemList)
                                {
                                    if (returnedItem.ItemId == CurrentItem.ItemId)
                                    {
                                        exists = true;
                                        break;
                                    }
                                }
                                if (!exists)
                                {
                                    this.ItemList.Add(ItemService.RetrieveItem(returnedItem.ItemId, this.ItemList.Count + 1));
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.LogError("Odin was unable to retireve the items.", ex.ToString());
                    }
                }
            }
        }
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            if (fltdgStrategyStatus.SelectedItems == null || fltdgStrategyStatus.SelectedItems.Count == 0)
            {
                return;
            }

            Dictionary<string, List<string>> selectedStrategyAndSymbol = new Dictionary<string, List<string>>();

            GetSelectedStrategyAndSymbol(selectedStrategyAndSymbol, ProcessType.START);

            string messageTextLine2 = CreateMessageText(selectedStrategyAndSymbol);

            AlertView view = new AlertView(AlertType.START, string.Empty, messageTextLine2, false);
            bool? status = view.ShowDialog();
            if (status == true && AlertView.AlertReturnType == AlertActionReturnType.YES)
            {
                App.AppManager.Start(selectedStrategyAndSymbol, false);
            }
            else
            {
                ClearSelectedStrategyAndSymbol();
            }
        }