コード例 #1
0
        public static IEnumerable <UserReg> GetOld(User User)
        {
            var filter = new QQuery(string.Empty, UserReg.DBTable);

            filter.BuildPropertyParam(nameof(UserReg.UserId), CompareType.Equal, User.PrimaryId);
            filter.BuildPropertyParam(nameof(UserReg.RegType), CompareType.Equal, UserRegType.Password);
            filter.Orders.Add(new QOrder {
                Column = UserReg.DBTable.ParseProperty(nameof(UserReg.Id)), Direction = ListSortDirection.Descending
            });
            return(UserReg.DBTable.Load(filter, DBLoadParam.Load | DBLoadParam.Synchronize));
        }
コード例 #2
0
ファイル: Account.cs プロジェクト: alexandrvslv/datawf
        public Balance GetBalance(object typeid)
        {
            var filter = new QQuery("", Balance.DBTable);

            filter.BuildPropertyParam(nameof(Balance.AccountId), CompareType.Equal, PrimaryId);
            filter.BuildPropertyParam(nameof(Balance.TypeId), CompareType.Equal, typeid);
            var balances = Balance.DBTable.Load(filter, DBLoadParam.Load | DBLoadParam.Synchronize).ToList();

            balances.Sort(new DBComparer <Balance, DateTime?>(Balance.BalanceDateKey, ListSortDirection.Descending));
            return(balances.FirstOrDefault());
        }
コード例 #3
0
        public static void SynchMessage()
        {
            if (MessageAddress.DBTable == null)
            {
                return;
            }
            var query = new QQuery(string.Empty, MessageAddress.DBTable);

            query.BuildPropertyParam(nameof(MessageAddress.UserId), CompareType.Equal, GuiEnvironment.User?.Id);
            query.BuildPropertyParam(nameof(MessageAddress.DateRead), CompareType.Is, DBNull.Value);
            MessageAddress.DBTable.Load(query, DBLoadParam.Synchronize, null).LastOrDefault();
        }
コード例 #4
0
        public static async Task <User> GetUser(string login, string passoword)
        {
            var query = new QQuery(string.Empty, User.DBTable);

            query.BuildPropertyParam(nameof(Login), CompareType.Equal, login);
            query.BuildPropertyParam(nameof(Password), CompareType.Equal, passoword);
            var user = User.DBTable.Select(query).FirstOrDefault();

            if (user != null)
            {
                await UserReg.LogUser(user, UserRegType.Authorization, "GetUser");
            }

            return(user);
        }
コード例 #5
0
ファイル: Document.cs プロジェクト: alexandrvslv/datawf
        public static void LoadDocuments(User user)
        {
            var qWork = new QQuery(string.Empty, DocumentWork.DBTable);

            qWork.Columns.Add(new QColumn(nameof(DocumentWork.Document)));
            qWork.BuildPropertyParam(nameof(DocumentWork.IsComplete), CompareType.Equal, false);
            qWork.BuildPropertyParam(nameof(DocumentWork.UserId), CompareType.Equal, user);

            var qDocs = new QQuery(string.Empty, Document.DBTable);

            qDocs.BuildPropertyParam(nameof(Document.Id), CompareType.In, qWork);

            Document.DBTable.Load(qDocs, DBLoadParam.Synchronize);
            DocumentWork.DBTable.Load(qWork, DBLoadParam.Synchronize);
        }
コード例 #6
0
        public async Task <object> Execute(ExecuteArgs parameters)
        {
            var filter = new QQuery(string.Empty, DocumentWork.DBTable);

            filter.BuildPropertyParam(nameof(DocumentWork.IsComplete), CompareType.Equal, false);
            filter.BuildPropertyParam(nameof(DocumentWork.IsSystem), CompareType.Equal, true);
            //string filter = string.Format("{0}!='{1}' and {2} in (select {3} from {4} where {5} = '{6}')",
            foreach (DocumentWork work in DocumentWork.DBTable.Load(filter, DBLoadParam.Load | DBLoadParam.Synchronize, parameters.Transaction))
            {
                if (work.Stage == null || work.Document == null)
                {
                    continue;
                }
                work.Document.ExecuteProceduresByWork(work, StageParamProcudureType.Manual, parameters.Transaction);
                await work.Document.Save(parameters.Transaction);
            }
            return(null);
        }
コード例 #7
0
ファイル: Instance.cs プロジェクト: alexandrvslv/datawf
        public static async Task <Instance> GetByNetId(IPEndPoint endPoint, bool create, IUserIdentity user = null)
        {
            var query = new QQuery(DBTable);

            query.BuildPropertyParam(nameof(Host), CompareType.Equal, endPoint.Address.ToString());
            query.BuildPropertyParam(nameof(Port), CompareType.Equal, endPoint.Port);
            query.BuildPropertyParam(nameof(Action), CompareType.Equal, false);
            var instance = DBTable.Load(query).LastOrDefault();

            if (instance == null && create)
            {
                instance = new Instance
                {
                    EndPoint  = endPoint,
                    Active    = true,
                    IsCurrent = true
                };
                await instance.Save(user);
            }
            return(instance);
        }
コード例 #8
0
ファイル: PersoneIndentify.cs プロジェクト: radtek/datawf
        public PersoneIdentify FindByCustomer(object customer)
        {
            if (customer == null)
            {
                return(null);
            }
            var filter = new QQuery("", PersoneIdentify.DBTable);

            filter.BuildPropertyParam(nameof(PersoneIdentify.PersoneId), CompareType.Equal, customer);
            var list = ((IEnumerable <PersoneIdentify>)table.LoadItems(filter, DBLoadParam.Load)).ToList();

            if (list.Count > 1)
            {
                list.Sort(new DBComparer <PersoneIdentify, int?>(Table.PrimaryKey, ListSortDirection.Descending));
            }
            return(list.Count == 0 ? null : list[0] as PersoneIdentify);
        }
コード例 #9
0
        public DocumentWorker()
        {
            toolRefresh = new ToolItem(ToolLoadOnClick)
            {
                Name = "Load", GlyphColor = Colors.DarkBlue, Glyph = GlyphType.Download
            };
            toolPreview.InsertAfter(new[] { toolRefresh });

            //mtimer.Elapsed += (object sender, System.Timers.ElapsedEventArgs asg) => { CheckNewDocument(null); mtimer.Stop(); };

            qWork = new QQuery(string.Empty, DocumentWork.DBTable);
            qWork.BuildPropertyParam(nameof(DocumentWork.IsComplete), CompareType.Equal, false);
            qWork.BuildPropertyParam(nameof(DocumentWork.UserId), CompareType.Equal, GuiEnvironment.User.Id);

            var qDocWorks = new QQuery(string.Empty, DocumentWork.DBTable);

            qDocWorks.Columns.Add(new QColumn(DocumentWork.DBTable.ParseProperty(nameof(DocumentWork.DocumentId))));
            qDocWorks.BuildPropertyParam(nameof(DocumentWork.IsComplete), CompareType.Equal, false);
            qDocWorks.BuildPropertyParam(nameof(DocumentWork.UserId), CompareType.Equal, GuiEnvironment.User.Id);

            qDocs = new QQuery(string.Empty, Document.DBTable);
            qDocs.BuildPropertyParam(nameof(Document.Id), CompareType.In, qDocWorks);

            works = new DocumentWorkList(qWork.ToWhere(), DBViewKeys.Empty);
            works.CollectionChanged += WorksListChanged;

            AllowPreview     = true;
            Filter.IsCurrent = true;
            Name             = "Documents";
            Worker           = this;

            //Task.Run(() =>
            //{
            //    try
            //    {
            //        var items = qWork.Select().Cast<DocumentWork>().ToList();
            //        items.Sort((x, y) =>
            //        {
            //            var result = x.Document.Template.Name.CompareTo(y.Document.Template.Name);
            //            return result == 0 ? x.Stage.Name.CompareTo(y.Stage.Name) : result;
            //        });
            //        foreach (var item in items)
            //        {
            //            works.Add(item);
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        Helper.OnException(ex);
            //    }
            //});

            Task.Run(() =>
            {
                while (true)
                {
                    var task = new TaskExecutor
                    {
                        Name   = "Load Documents",
                        Action = () =>
                        {
                            try
                            {
                                Document.DBTable.Load(qDocs, DBLoadParam.Referencing, null).LastOrDefault();
                                //DocumentWork.DBTable.Load(qWork, DBLoadParam.Synchronize, works).LastOrDefault();
                                Helper.LogWorkingSet("Documents");
                            }
                            catch (Exception ex)
                            {
                                Helper.OnException(ex);
                            }
                            return(null);
                        }
                    };
                    GuiService.Main.AddTask(this, task);
                    load.Reset();
                    load.WaitOne(200000);
                }
            });
        }