Exemple #1
0
        public static void PutOne <T>(this IDataClient @this, T item, bool excludeFromEviction = false)
        {
            var description = TypeDescriptionsCache.GetDescription(typeof(T));
            var schema      = description;

            @this.Put(schema.CollectionName, PackedObject.Pack(item, schema), excludeFromEviction);
        }
        public OrdersViewModel(Account account)
        {
            Account = account;

            _Orders = new List <Order>();

            _DataClient = DependencyService.Get <IDataClient>();

            OrderGroups = new ObservableCollection <Grouping <Order, string> >();

            MessagingCenter.Subscribe <Order>(this, MessagingServiceConstants.SAVE_ORDER, order =>
            {
                var index = _Orders.IndexOf(order);
                if (index >= 0)
                {
                    _Orders[index] = order;
                }
                else
                {
                    _Orders.Add(order);
                }

                GroupOrders();
            });
        }
Exemple #3
0
        public static IEnumerable <T> GetMany <T>(this IDataClient @this, Expression <Func <T, bool> > where)
        {
            var query = PredicateToQuery(where);


            return(@this.GetMany(query).Select(ri => ((JObject)ri.Item).ToObject <T>(SerializationHelper.Serializer)));
        }
Exemple #4
0
        internal override IDataClient TryExecute(IDataClient client)
        {
            if (!CanExecute)
            {
                return(client);
            }

            if (Params.Count != 1)
            {
                Logger.CommandLogger.WriteError("please specify a dump directory");
            }
            else
            {
                try
                {
                    client.Dump(Params[0]);
                    Logger.Write("Database successfully saved");
                }
                catch (Exception e)
                {
                    Logger.WriteEror("error saving database:" + e.Message);
                }
            }

            return(client);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApplicationBlock"/> class.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="title">The title.</param>
 /// <param name="icon">The icon.</param>
 public ApplicationBlock(IDataClient client, string title, Image icon)
 {
     _Client = client;
     this.OnHelpButtonClick = new MouseButtonEventHandler(this.ShowHelp);
     //_BlockMenu = new ApplicationBlockMenu(20, 20);
     //_BlockMenu.AddItem(IconLoader.GetImage(IconLoader.PinIconPath, 20, 20), null);
     //_BlockMenu.AddItem(IconLoader.GetImage(IconLoader.HelpIconPath, 20, 20), this.OnHelpButtonClick);
     //this.Children.Add(_BlockMenu);
     this.TitleLabel = new TextBlock()
     {
         Text = title,
         HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
         TextWrapping        = System.Windows.TextWrapping.WrapWithOverflow
     };
     DockPanel.SetDock(this.TitleLabel, Dock.Top);
     //icon.Stretch = System.Windows.Media.Stretch.None;
     //icon.VerticalAlignment = System.Windows.VerticalAlignment.Center;
     //icon.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
     TitleLabel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
     TitleLabel.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
     this.VerticalAlignment         = System.Windows.VerticalAlignment.Stretch;
     this.HorizontalAlignment       = System.Windows.HorizontalAlignment.Stretch;
     this.SetValue(HeightProperty, Double.NaN);
     this.SetValue(WidthProperty, Double.NaN);
     // this.Children.Add(icon);
     this.Children.Add(TitleLabel);
 }
Exemple #6
0
        internal static IEnumerable <PackedObject> LoadObjects(IDataClient @this, string jsonPath, [NotNull] string collectionName)
        {
            if (collectionName == null)
            {
                throw new ArgumentNullException(nameof(collectionName));
            }

            var json = File.ReadAllText(jsonPath);

            var array = JArray.Parse(json);

            var info = @this.GetClusterInformation();

            var schemaByName = info.Schema.ToDictionary(td => td.CollectionName.ToLower());

            if (!schemaByName.ContainsKey(collectionName.ToLower()))
            {
                throw new CacheException($"Collection {collectionName} not found");
            }

            CollectionSchema collectionSchema = schemaByName[collectionName];

            foreach (var item in array.Children <JObject>())
            {
                var cachedObject = PackedObject.PackJson(item.ToString(), collectionSchema);
                yield return(cachedObject);
            }
        }
        public ProjectsController()
        {
            _tokenContainer = new TokenContainer();
            var apiClient = new ApiClient(HttpClientInstance.Instance, _tokenContainer);

            _dataClient = new DataClient(apiClient);
        }
Exemple #8
0
        public static void PutMany <T>(this IDataClient @this, IEnumerable <T> items, bool excludeFromEviction = false)
        {
            var description = TypeDescriptionsCache.GetDescription(typeof(T));
            var schema      = description;

            @this.FeedMany(schema.CollectionName, items.Select(i => PackedObject.Pack(i, schema)), excludeFromEviction);
        }
        public CustomerDetailViewModel(Account account)
        {
            if (account == null)
            {
                Account = new Account();
                Account.Industry = Account.IndustryTypes[0];
                Account.OpportunityStage = Account.OpportunityStages[0];

                this.Title = "New Account";
            }
            else
            {
                Account = account;
                this.Title = "Account";
            }

            this.Icon = "account.png";

            _DataClient = DependencyService.Get<IDataClient>();
            _GeoCodingService = DependencyService.Get<IGeoCodingService>();

            MessagingCenter.Subscribe<Account>(this, MessagingServiceConstants.ACCOUNT, (Account) =>
                {
                    IsInitialized = false;
                });
        }
Exemple #10
0
        public AddInstrumentBinanceWindow(IDataClient client)
        {
            InitializeComponent();

            ViewModel   = new AddInstrumentBinanceViewModel(client, DialogCoordinator.Instance);
            DataContext = ViewModel;
        }
Exemple #11
0
 public QueryExecutor(IDataClient client, CollectionSchema collectionSchema, Guid sessionId, string collectionName)
 {
     _client           = client;
     _collectionSchema = collectionSchema;
     _sessionId        = sessionId;
     _collectionName   = collectionName;
 }
Exemple #12
0
        internal override IDataClient TryExecute(IDataClient client)
        {
            if (!CanExecute)
            {
                return(client);
            }


            try
            {
                Console.WriteLine("This will delete ALL your data. Are you sure (y/n) ?");
                var answer = Console.ReadLine()?.ToLower().StartsWith("y");
                if (answer.HasValue && answer.Value)
                {
                    client.DropDatabase();
                }
            }
            catch (Exception)
            {
                // ignored
            }


            return(client);
        }
        public OrderDetailViewModel(Account account, Order order = null)
        {
            Account = account;

            if (order == null)
            {
                Order = new Order() { AccountId = Account.Id };
            }
            else
            {
                Order = order;
            }

            this.Title = "Order Details";
            _DataClient = DependencyService.Get<IDataClient>();

            DependencyService.Get<ILocalize>();

            MessagingCenter.Subscribe<Product>(this, MessagingServiceConstants.UPDATE_ORDER_PRODUCT, async catalogProduct =>
                {
                    Order.Item = catalogProduct.Name;
                    Order.Price = catalogProduct.Price;
                    OrderItemImageUrl = null;
                    await ExecuteLoadOrderItemImageUrlCommand(); // this is to account for Android not calling OnAppearing() when the product selection modal disappears.
                    OnPropertyChanged("Order");
                }); 
        }
Exemple #14
0
        public LeadDetailViewModel(INavigation navigation, Account lead = null)
        {
            if (navigation == null)
            {
                throw new ArgumentNullException("navigation", "An instance of INavigation must be passed to the LeadDetailViewModel constructor.");
            }

            Navigation = navigation;

            if (lead == null)
            {
                Lead       = new Account();
                this.Title = TextResources.Leads_NewLead;
            }
            else
            {
                Lead       = lead;
                this.Title = lead.Company;
            }

            this.Icon = "contact.png";

            _DataClient = DependencyService.Get <IDataClient>();

            _GeoCodingService = DependencyService.Get <IGeoCodingService>();
        }
Exemple #15
0
        protected JobViewModelBase(T job, AbstractValidator <T> validator, IDataClient client, IDialogCoordinator dialogCoordinator, object dialogContext) : base(job, validator)
        {
            PreChangeName = job.Name;
            //Note the use of job vs Job below. The parameter has the type T which is necessary for the  client stuff to work
            Job = job;

            //Save job
            var saveCanExecute = this
                                 .WhenAnyValue(x => x.HasErrors)
                                 .Select(x => x == false);

            Save = ReactiveCommand.CreateFromTask(async _ =>
            {
                //First delete the existing job (if there is an existing job), with the old name
                string tmpName = Name;
                Name           = PreChangeName;
                await client.DeleteJob(job).ConfigureAwait(true); //failure is OK here, it might not exist on the server if it's newly added
                Name = tmpName;

                //then add it with the new values
                var result = await client.AddJob(job).ConfigureAwait(true);
                if (await result.DisplayErrors(dialogContext, dialogCoordinator).ConfigureAwait(true))
                {
                    return;
                }
                PreChangeName = Name;
            },
                                                  saveCanExecute);

            //this is here because we need to know the job type
            Delete = ReactiveCommand.CreateFromTask(async _ => (ApiResponse)await client.DeleteJob(job).ConfigureAwait(false));
        }
Exemple #16
0
        public AddInstrumentQuandlWindow(IDataClient client)
        {
            InitializeComponent();

            ViewModel   = new AddInstrumentQuandlViewModel(client, DialogCoordinator.Instance, Properties.Settings.Default.quandlAuthCode);
            DataContext = ViewModel;
        }
Exemple #17
0
        /// <summary>
        /// 回滚事务
        /// </summary>
        /// <param name="TransID">事务ID</param>
        public void RollbackTransaction(string TransID)
        {
            IDataClient idc = GetTransClient(TransID);

            idc.RollbackTransaction(TransID);
            RemoveClientTransaction(TransID);
        }
Exemple #18
0
        public IActionResult UpsertFlowchartRun([FromServices] IDataClient dataClient, string customerShortName, string projectShortName, Guid id)
        {
            var job = _jobProxy.GetJob(customerShortName, projectShortName, id);

            _workStatusProxy.Add(job, AnalyticsRunStatus.Running, Calculations.Percentage(0, 11, 14, _config.PreTAPercentageContribution), true, true);
            var projectConfig = _iam.GetProjectConfig(customerShortName, projectShortName);

            var stopWatch = Stopwatch.StartNew();

            job.flowchartRunRequest.ToList().ForEach(flowchartRunRequest => flowchartRunRequest.flowchartCatalogMetadata.ToList().ForEach(
                                                         catalog =>
            {
                var beginDate = DateTime.Parse(flowchartRunRequest.reportingYearBeginDate);
                var endDate   = DateTime.Parse(flowchartRunRequest.reportingYearEndDate);

                var parameters = new List <NpgsqlParameter>
                {
                    new NpgsqlParameter("result_schema_name", NpgsqlDbType.Varchar)
                    {
                        Value = projectConfig.GreenplumConfig.ResultSchema
                    },
                    new NpgsqlParameter("fc_catalog_id", DbType.Int64)
                    {
                        Value = catalog.flowchartCatalogID
                    },
                    new NpgsqlParameter("flowchartrunuuid", NpgsqlDbType.Varchar)
                    {
                        Value = flowchartRunRequest.flowchartRunUUID.ToString()
                    },
                    new NpgsqlParameter("fc_run_name", NpgsqlDbType.Varchar)
                    {
                        Value = flowchartRunRequest.name
                    },
                    new NpgsqlParameter("fc_run_date_time", NpgsqlDbType.Varchar)
                    {
                        Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                    },
                    new NpgsqlParameter("fc_begin_date", NpgsqlDbType.Varchar)
                    {
                        Value = beginDate.ToString("yyyy-MM-dd")
                    },
                    new NpgsqlParameter("fc_end_date", NpgsqlDbType.Varchar)
                    {
                        Value = endDate.ToString("yyyy-MM-dd")
                    },
                    new NpgsqlParameter("fc_catalog_name", NpgsqlDbType.Varchar)
                    {
                        Value = catalog.flowchartCatalogKey
                    }
                };

                var request            = new GreenplumStoredProcedureRequest(projectConfig.GreenplumConfig.RawConnectionString, "usp_insert_update_flowchartrun", parameters);
                catalog.flowchartRunID = dataClient.ExecuteScalar <long>(request);
            }));

            _jobProxy.UpdateJob(job);
            _taskLogging.LogOperation(customerShortName, projectShortName, "UpsertFlowchartRun", job, stopWatch.Elapsed);

            return(Ok());
        }
Exemple #19
0
        internal override IDataClient TryExecute(IDataClient client)
        {
            if (!CanExecute)
            {
                return(client);
            }

            if (Params.Count != 1)
            {
                Logger.CommandLogger.WriteError("please specify a directory containing database dump(s)");
            }
            else
            {
                try
                {
                    client.InitializeFromDump(Params[0]);
                    Logger.Write("Database successfully recreated");
                }
                catch (Exception e)
                {
                    Logger.WriteEror("error recreating database data:" + e.Message);
                }
            }

            return(client);
        }
Exemple #20
0
        public ActionResult RefreshMemberCombined([FromServices] IDataClient dataClient, string customerShortName, string projectShortName, Guid id)
        {
            var job = _jobProxy.GetJob(customerShortName, projectShortName, id);

            _workStatusProxy.Add(new WorkStatus(id, true, Calculations.Percentage(0, 5, 14, _config.PreTAPercentageContribution), AnalyticsRunStatus.Running));
            var projectConfig = _iam.GetProjectConfig(customerShortName, projectShortName);

            var parameters = new List <NpgsqlParameter>
            {
                new NpgsqlParameter("v_source_schema", NpgsqlDbType.Varchar)
                {
                    Value = projectConfig.GreenplumConfig.SourceSchema
                },
                new NpgsqlParameter("v_result_schema", NpgsqlDbType.Varchar)
                {
                    Value = projectConfig.GreenplumConfig.ResultSchema
                }
            };

            var stopWatch = Stopwatch.StartNew();

            var request = new GreenplumStoredProcedureRequest(projectConfig.GreenplumConfig.RawConnectionString, "usp_member_combined", parameters);

            dataClient.ExecuteScalar <object>(request);

            _taskLogging.LogOperation(customerShortName, projectShortName, "RefreshMemberCombined", job, stopWatch.Elapsed);
            return(Ok());
        }
Exemple #21
0
        public ActionResult ManageOutputCombined([FromServices] IDataClient dataClient, string customerShortName, string projectShortName, Guid id)
        {
            var job = _jobProxy.GetJob(customerShortName, projectShortName, id);

            _workStatusProxy.Add(job, AnalyticsRunStatus.Running, Calculations.Percentage(0, 12, 14, _config.PreTAPercentageContribution), true, true);

            var projectConfig = _iam.GetProjectConfig(customerShortName, projectShortName);
            var stopWatch     = Stopwatch.StartNew();

            job.flowchartRunRequest.ToList().ForEach(flowchartRunRequest =>
            {
                var parameters = new List <NpgsqlParameter>
                {
                    new NpgsqlParameter("v_result_schema", NpgsqlDbType.Varchar)
                    {
                        Value = projectConfig.GreenplumConfig.ResultSchema
                    },
                    new NpgsqlParameter("v_flowchart_run_uuid", NpgsqlDbType.Varchar)
                    {
                        Value = flowchartRunRequest.flowchartRunUUID.ToString()
                    }
                };

                var request = new GreenplumStoredProcedureRequest(projectConfig.GreenplumConfig.RawConnectionString, "usp_manage_combined_output_tables", parameters);
                dataClient.ExecuteScalar <object>(request);
            });

            _taskLogging.LogOperation(customerShortName, projectShortName, "ManageOutputCombined", job, stopWatch.Elapsed);
            return(Ok());
        }
Exemple #22
0
        public CustomerDetailViewModel(Account account)
        {
            if (account == null)
            {
                Account                  = new Account();
                Account.Industry         = Account.IndustryTypes[0];
                Account.OpportunityStage = Account.OpportunityStages[0];

                this.Title = "New Account";
            }
            else
            {
                Account    = account;
                this.Title = "Account";
            }

            this.Icon = "account.png";

            _DataClient       = DependencyService.Get <IDataClient>();
            _GeoCodingService = DependencyService.Get <IGeoCodingService>();

            MessagingCenter.Subscribe <Account>(this, MessagingServiceConstants.ACCOUNT, (Account) =>
            {
                IsInitialized = false;
            });
        }
Exemple #23
0
        public MainWindow(MainViewModel viewModel, IDataClient client)
        {
            _client = client;
            _client.HistoricalDataReceived += _client_HistoricalDataReceived;
            _client.Error += (s, e) => _clientLogger.Error(e.ErrorMessage);

            InitializeComponent();

            //load datagrid layout
            RestoreDatagridLayout();

            //build the instruments grid context menu
            BuildInstrumentsGridContextMenu();

            //build the tags menu
            using (var entityContext = new MyDBContext())
            {
                List <Tag> allTags = entityContext.Tags.ToList();
                BuildTagContextMenu(allTags);
            }

            //build session templates menu
            BuildSetSessionTemplateMenu();

            ViewModel   = viewModel;
            DataContext = ViewModel;

            ShowChangelog();
        }
Exemple #24
0
        public void Start(IDataClient client)
        {
            if (client.TableExists("users"))
            {
                client.RemoveTable("users");
            }

            client.AddTable("users",
                            AutoIncrement("id").AsPrimaryKey(),
                            String("username", 50).NotNull(),
                            String("password", 50).NotNull()
                            );
            client.AddUniqueKey("un_users", "users", "username");

            client.Insert
            .Into("users")
            .Columns("username", "password")
            .Values("foo", "bar");

            var users = client.Select
                        .AllColumns()
                        .From("users")
                        .Where(Filter.Eq("username", "foo"))
                        .SkipTake(0, 1)
                        .Map <User>();

            foreach (var user in users)
            {
                Console.WriteLine("User: " + user.Username);
            }
        }
Exemple #25
0
        /// <summary>
        /// 提交事务
        /// </summary>
        /// <param name="TransID">事务ID</param>
        public void CommitTransaction(string TransID)
        {
            IDataClient idc = GetTransClient(TransID);

            idc.CommitTransaction(TransID);
            RemoveClientTransaction(TransID);
        }
Exemple #26
0
        public IActionResult DeleteAnalyticsRunGreenplum([FromServices] IDataClient dataClient, string customerShortName, string projectShortName, Guid analyticsRunId)
        {
            var projectConfig = _iam.GetProjectConfig(customerShortName, projectShortName);
            var parameters    = new List <NpgsqlParameter>
            {
                new NpgsqlParameter("v_source_schema_name", NpgsqlDbType.Varchar)
                {
                    Value = projectConfig.GreenplumConfig.SourceSchema
                },
                new NpgsqlParameter("v_result_schema_name", NpgsqlDbType.Varchar)
                {
                    Value = projectConfig.GreenplumConfig.ResultSchema
                },
                new NpgsqlParameter("v_flowchart_run_uuid", NpgsqlDbType.Varchar)
                {
                    Value = analyticsRunId.ToString()
                }
            };

            var request = new GreenplumStoredProcedureRequest(projectConfig.GreenplumConfig.RawConnectionString, "usp_delete_flowchart_run", parameters);

            dataClient.ExecuteScalar <object>(request);

            _logging.Log("Deleted rates from greenplum", Orchestration.Shared.Domain.Log.LogLevels.Info, 50);
            return(Ok());
        }
        public LeadDetailViewModel(INavigation navigation, Account lead = null)
        {
            if (navigation == null)
            {
                throw new ArgumentNullException("navigation", "An instance of INavigation must be passed to the LeadDetailViewModel constructor.");
            }

            Navigation = navigation;

            if (lead == null)
            {
                Lead = new Account();
                this.Title = TextResources.Leads_NewLead;
            }
            else
            {
                Lead = lead;
                this.Title = lead.Company;
            }

            this.Icon = "contact.png";

            _DataClient = DependencyService.Get<IDataClient>();

            _GeoCodingService = DependencyService.Get<IGeoCodingService>();
        }
        /// <summary>
        /// Imports the provided shapefile into a sqlite database using the VirtualShape extension
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="client"></param>
        /// <param name="filename"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        public static bool ImportShapefile(DbConnection conn, IDataClient client, string filename, string tableName, int srid)
        {
            try
            {
                if (!File.Exists(filename))
                {
                    _log.ErrorFormat("ImportShapefile Failed!: File does not exist {0}", filename);
                    return(false);
                }

                if (DataClient.HasTable(conn, client, tableName))
                {
                    client.GetCommand(string.Format("DROP TABLE \"{0}\"", tableName)).ExecuteNonQuery();
                }

                //trim off the '.shp' from the end
                filename = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));
                string sql = string.Format("CREATE VIRTUAL TABLE " + tableName + " USING VirtualShape('{0}', CP1252, {1});", filename, srid);
                client.GetCommand(sql, conn).ExecuteNonQuery();

                _log.DebugFormat("Imported Shapefile {0} into table {1}",
                                 Path.GetFileNameWithoutExtension(filename),
                                 tableName);

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error("ImportShapefile failed: Error while loading shapefile ", ex);
            }
            return(false);
        }
Exemple #29
0
        public ContinuousFuturesBroker(IDataClient client, bool connectImmediately = true, IInstrumentSource instrumentRepo = null)
        {
            if (client == null)
            {
                throw new ArgumentNullException(nameof(client));
            }
            _client = client;

            _instrumentRepo = instrumentRepo ?? new InstrumentRepository(new MyDBContext());

            _client.HistoricalDataReceived += _client_HistoricalDataReceived;
            _client.Error += _client_Error;
            if (connectImmediately)
            {
                _client.Connect();
            }

            _data                    = new Dictionary <KeyValuePair <int, BarSize>, List <OHLCBar> >();
            _contracts               = new Dictionary <int, List <Instrument> >();
            _requestCounts           = new Dictionary <int, int>();
            _requests                = new Dictionary <int, HistoricalDataRequest>();
            _histReqIDMap            = new Dictionary <int, int>();
            _frontContractRequests   = new BlockingCollection <FrontContractRequest>();
            _requestTypes            = new Dictionary <int, bool>();
            _frontContractRequestMap = new Dictionary <int, FrontContractRequest>();
            _dataUsesPending         = new Dictionary <KeyValuePair <int, BarSize>, int>();

            _reconnectTimer          = new Timer(1000);
            _reconnectTimer.Elapsed += _reconnectTimer_Elapsed;
            _reconnectTimer.Start();

            Name = "ContinuousFutures";
        }
Exemple #30
0
 public VersionRepository(IDataClient dataClient, string migrationGroup = DEFAULT_MIGRATION_GROUP)
 {
     _dataClient           = dataClient;
     MigrationGroup        = migrationGroup ?? DEFAULT_MIGRATION_GROUP;
     _migrationGroupFilter = Filter.Eq("migrationgroup", MigrationGroup);
     EnsureSchemaVersionTable();
 }
        public SalesDashboardLeadsViewModel(Command pushTabbedLeadPageCommand, INavigation navigation = null)
            : base(navigation)
        {
            _PushTabbedLeadPageCommand = pushTabbedLeadPageCommand;

            _DataClient = DependencyService.Get <IDataClient>();

            Leads = new ObservableCollection <Account>();

            MessagingCenter.Subscribe <Account>(this, MessagingServiceConstants.SAVE_ACCOUNT, (account) =>
            {
                var index = Leads.IndexOf(account);
                if (index >= 0)
                {
                    Leads[index] = account;
                }
                else
                {
                    Leads.Add(account);
                }
                Leads = new ObservableCollection <Account>(Leads.OrderBy(l => l.Company));
            });

            IsInitialized = false;
        }
Exemple #32
0
        internal override IDataClient TryExecute(IDataClient client)
        {
            if (!CanExecute)
            {
                return(client);
            }

            if (Params.Count != 2)
            {
                Logger.CommandLogger.WriteError("please specify a json file to import and a collection name");
            }
            else
            {
                try
                {
                    client.Import(Params[0], Params[1]);
                    Logger.Write("Data successfully imported");
                }
                catch (Exception e)
                {
                    Logger.WriteEror("error importing  data:" + e.Message);
                }
            }

            return(client);
        }
        public SalesDashboardLeadsViewModel(Command pushTabbedLeadPageCommand, INavigation navigation = null)
            : base(navigation)
        {
            _PushTabbedLeadPageCommand = pushTabbedLeadPageCommand;

            _DataClient = DependencyService.Get<IDataClient>();

            Leads = new ObservableCollection<Account>();

            MessagingCenter.Subscribe<Account>(this, MessagingServiceConstants.SAVE_ACCOUNT, (account) =>
                {
                    var index = Leads.IndexOf(account);
                    if (index >= 0)
                    {
                        Leads[index] = account;
                    }
                    else
                    {
                        Leads.Add(account);
                    }
                    Leads = new ObservableCollection<Account>(Leads.OrderBy(l => l.Company));
                });

            IsInitialized = false;
        }
        public OrderDetailViewModel(Account account, Order order = null)
        {
            Account = account;

            if (order == null)
            {
                Order = new Order()
                {
                    AccountId = Account.Id
                };
            }
            else
            {
                Order = order;
            }

            this.Title  = "Order Details";
            _DataClient = DependencyService.Get <IDataClient>();

            DependencyService.Get <ILocalize>();

            MessagingCenter.Subscribe <Product>(this, MessagingServiceConstants.UPDATE_ORDER_PRODUCT, async catalogProduct =>
            {
                Order.Item        = catalogProduct.Name;
                Order.Price       = catalogProduct.Price;
                OrderItemImageUrl = null;
                await ExecuteLoadOrderItemImageUrlCommand();     // this is to account for Android not calling OnAppearing() when the product selection modal disappears.
                OnPropertyChanged("Order");
            });
        }
Exemple #35
0
        public OrdersViewModel(Account account)
        {
            Account = account;

            _Orders = new List<Order>();

            _DataClient = DependencyService.Get<IDataClient>();

            OrderGroups = new ObservableCollection<Grouping<Order, string>>();

            MessagingCenter.Subscribe<Order>(this, MessagingServiceConstants.SAVE_ORDER, order =>
                {
                    var index = _Orders.IndexOf(order);
                    if (index >= 0)
                    {
                        _Orders[index] = order;
                    }
                    else
                    {
                        _Orders.Add(order);
                    }

                    GroupOrders();
                });
        }
 public VersionRepository(IDataClient dataClient, bool createVersionTable = true)
 {
     _dataClient = dataClient;
     _migrationGroup = DEFAULT_MIGRATION_GROUP;
     if (createVersionTable) {
         CreateVersionTable();
     }
 }
 public Runner(IDataClient dataClient, Assembly targetAssembly, IVersionRepository versionRepository)
 {
     _dataClient = dataClient;
     _databaseKind = _dataClient.Database.Provider.DatabaseKind;
     _targetAssembly = targetAssembly ?? Assembly.GetCallingAssembly();
     VersionRepository = versionRepository;
     _migrationFactory = new MigrationFactory(_dataClient);
     _initialVersion = -1;
 }
        public CategoriesViewModel(Category category = null)
        {
            Category = category;

            SubCategories = new ObservableCollection<Category>();

            _DataClient = DependencyService.Get<IDataClient>();

        }
Exemple #39
0
        public ProductsViewModel(string categoryId = null)
        {
            _CategoryId = categoryId;

            _Products = new ObservableCollection<Product>();

            _DataClient = DependencyService.Get<IDataClient>();

        }
Exemple #40
0
		public MainViewModel (IDataClient dataClient, IAppConfig appConfig)
		{
			_dataClient = dataClient.ThrowIfNull ("dataClient");
			_appConfig = appConfig.ThrowIfNull ("appConfig");

			using (var scope = AppContainer.Container.BeginLifetimeScope ()) {
				_sessionsViewModel = AppContainer.Container.Resolve<SessionsViewModel> ();
				_speakersViewModel = AppContainer.Container.Resolve<SpeakersViewModel> ();
				_tracksVieModel = AppContainer.Container.Resolve<TracksViewModel> ();
			}
		}
        /// <summary>
        /// 
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="client"></param>
        /// <param name="filename"></param>
        /// <param name="tablename"></param>
        /// <returns></returns>
        public bool ImportDesiredVariables(DbConnection conn, IDataClient client, string filename, string tablename)
        {
            if ((string.IsNullOrEmpty(filename)) || (!File.Exists(filename)))
            {
                _log.DebugFormat("ImportDesiredVariables failed: provided filename was empty or did not exist \"{0}\" ", filename);
                return false;
            }

            try
            {

                //empty/create our temporary table
                DataTable dt = SetupTable(conn, client, tablename);

                //get a list of the columns they wanted
                dt = ReadVariablesFile(filename, dt);

                //check all our error scenarios
                TableChecker[] fnList = new TableChecker[] {
                    CheckForMaxColumns,
                    CheckForMinColumns,
                    CheckForDuplicates,
                    CheckForMOEDuplicates,
                    CheckForReserved
                };

                bool noErrors = true;
                foreach (var errCheckFn in fnList)
                {
                    string msg = errCheckFn(dt);
                    if (!string.IsNullOrEmpty(msg))
                    {
                        noErrors = false;
                        _log.Error(msg);
                    }
                }

                if (!noErrors)
                {
                    return false;
                }

                SaveTable(conn, client, dt);

                return true;
            }
            catch (Exception ex)
            {
                _log.Error("Variable Import Failed", ex);
                RemoveTemporaryTable(conn, client);
            }

            return false;
        }
        public ScriptCreatorRunner(IDataClient dataClient, Assembly targetAssembly)
        {
            _dialect = dataClient.Dialect;
            _scriptCreatorDatabase = new ScriptCreatorDatabase(_dialect, dataClient.Database);
            _scriptCreatorDataClient = new DataClient(_scriptCreatorDatabase, _dialect);
            _versionRepository = new ScriptCreatorVersionRepository(_scriptCreatorDataClient, false);
            _versionRepository.OnUpdateVersion += UpdateSchemaVersion;

            Runner.Log = new ScriptCreatorLogger(Runner.Log, this);
            _runner = new Runner(_scriptCreatorDataClient, targetAssembly, _versionRepository);
        }
        public static IDataService CreateDataServicePipeProxy(IDataClient dataReceiver, string hostname)
        {
            var factory =
                new DuplexChannelFactory<IDataService>(new InstanceContext(dataReceiver), CommunicationSettingsFactory.CreateDataServicePipeBinding(TimeSpan.MaxValue));

            var builder = new UriBuilder();
            builder.Scheme = Uri.UriSchemeNetPipe;
            builder.Host = hostname;
            builder.Path = "/IDataService";
            var address = new EndpointAddress(builder.Uri);
            return factory.CreateChannel(address);
        }
Exemple #44
0
        public CustomersViewModel(INavigation navigation = null) : base(navigation)
        {
            this.Title = "Accounts";
            this.Icon = "list.png";

            _DataClient = DependencyService.Get<IDataClient>();
            Accounts = new ObservableCollection<Account>();

            MessagingCenter.Subscribe<Account>(this, MessagingServiceConstants.ACCOUNT, (account) =>
                {
                    IsInitialized = false;
                });
        }
        public SalesDashboardChartViewModel(INavigation navigation = null)
            : base(navigation)
        {
            _DataClient = DependencyService.Get<IDataClient>();

            _ChartDataService = DependencyService.Get<IChartDataService>();

            Orders = new ObservableCollection<Order>();

            WeeklySalesChartDataPoints = new ObservableCollection<ChartDataPoint>();

            IsInitialized = false;
        }
        public DataService()
        {
            _client = OperationContext.Current.GetCallbackChannel<IDataClient>();

            MessageProperties properties = OperationContext.Current.IncomingMessageProperties;
            //获取消息发送的远程终结点IP和端口
            //RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
            //ip = string.Format("{0}:{1}", endpoint.Address, endpoint.Port);

            OperationContext.Current.Channel.Closed += new EventHandler(Channel_Closed);
            // OperationContext.Current.Channel.Faulted += Channel_Faulted;
            DataEngine.AddService(this);
        }
        public CustomerSalesViewModel(Account account, INavigation navigation = null)
            : base(navigation)
        {
            _Account = account;

            _DataClient = DependencyService.Get<IDataClient>();

            _ChartDataService = DependencyService.Get<IChartDataService>();

            Orders = new ObservableCollection<Order>();

            WeeklySalesChartDataPoints = new ObservableCollection<ChartDataPoint>();

            CategorySalesChartDataPoints = new ObservableCollection<ChartDataPoint>();

            IsInitialized = false;
        }
Exemple #48
0
        /// <summary>
        /// Uses a select statement and the ADO.NET CommandBuilder 
        /// to generate Insert,Update, and Delete statements, and load them onto an adapter
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="client"></param>
        /// <param name="sql"></param>
        /// <returns></returns>
        public static DbDataAdapter GetMagicAdapter(DbConnection conn, IDataClient client, string sql)
        {
            var cmd = client.GetCommand(sql, conn);
            var dba = client.GetDataAdapter(cmd);
            var builder = client.GetCommandBuilder(dba);

            dba.InsertCommand = builder.GetInsertCommand(true);
            dba.DeleteCommand = builder.GetDeleteCommand(true);
            dba.UpdateCommand = builder.GetUpdateCommand(true);

            if (dba.InsertCommand != null)
                dba.InsertCommand.CommandTimeout = client.QueryTimeout;

            if (dba.DeleteCommand != null)
                dba.DeleteCommand.CommandTimeout = client.QueryTimeout;

            if (dba.UpdateCommand != null)
                dba.UpdateCommand.CommandTimeout = client.QueryTimeout;

            return dba;
        }
Exemple #49
0
		public Count(IDataClient dataClient) : base(dataClient) { }
 public TaskController()
 {
     _mongoDatabase = RetreiveMongohqDb();
     _dataClient = new DataClient(_mongoDatabase);
 }
Exemple #51
0
 public FluentAdd(IDataClient dataClient)
 {
     _dataClient = dataClient;
 }
 public AddColumn(IDataClient dataClient, Column column)
     : base(dataClient)
 {
     _column = column;
 }
Exemple #53
0
 protected RemoveItemFromTable(IDataClient dataClient) : base(dataClient) {}
Exemple #54
0
 	public Select(IDataClient dataClient) : base(dataClient) { }
Exemple #55
0
 public RemoveTable(IDataClient dataClient) : base(dataClient) {}
Exemple #56
0
 public ModifyColumn(IDataClient dataClient, string columnName) 
     : base(dataClient) {
     _columnName = columnName;
 }
 public FluentRemove(IDataClient dataClient)
 {
     _dataClient = dataClient;
 }
 public FluentSelect(IDataClient client)
 {
     _select = new Select(client);
 }
 public Runner(IDataClient dataClient, Assembly targetAssembly)
     : this(dataClient, targetAssembly, new VersionRepository(dataClient))
 {
 }
 public FluentDelete(IDataClient client)
 {
     _delete = new Delete(client);
 }