Example #1
0
        protected virtual RecordList <TS> GetList <TS>(IQueryable <TS> query, int pageindex, int pagesize)
        {
            var records = new RecordList <TS> {
                PageIndex = pageindex, PageSize = pagesize, RecordCount = query.Count()
            };
            IList <TS> data;

            if (records.RecordCount == 0)
            {
                data = new TS[0];
            }
            else
            {
                do
                {
                    data = records.StartIndex > 0 ? query.Skip(records.StartIndex).Take(pagesize).ToList() : query.Take(pagesize).ToList();
                    if (data.Count == 0 && records.PageIndex > 1)
                    {
                        records.PageIndex--;
                    }
                } while (data.Count == 0 && records.PageIndex > 1);
            }
            records.Data = data;
            return(records);
        }
Example #2
0
        //添加新条目,如果没有相同网站和相同账号,添加之,并保存,并显示列表。
        public async void AddData()
        {
            if (string.IsNullOrEmpty(RecordItemToModify.WebSite))
            {
                RecordItemToModify.WebSite = "错误!网站名称不能为空";
                return;
            }
            int index = RecordList.FindIndex(r => r.WebSite == RecordItemToModify.WebSite && r.Account == RecordItemToModify.Account);

            if (index > -1)
            {
                RecordItemToModify.WebSite = "错误!已存在当前网站";
                RecordItemToModify.Account = "错误!已存在当前账户";
            }
            else
            {
                RecordItem r = new RecordItem();
                CopyRecordItem(RecordItemToModify, r);
                RecordList.Add(r);
                string titleStr = await BackupAsync(SaveType.LocalState);

                if (titleStr.StartsWith("-"))
                {
                    Title = titleStr.Substring(1);
                }
                else
                {
                    Title = "收藏列表";
                }
                IsUcItemDetailVisible = false;
                IsGrdPwdsListVisible  = true;
                IsBackVisible         = false;
                IsListVisible         = true;
            }
        }
        public static RecordList Postprocess(this DocumentDef doc)
        {
            var result = new RecordList(doc.Namespace);

            foreach (var rec in doc.Records)
            {
                var flags = new List <string>();
                var attrs = new Dictionary <string, string>();

                var inproc = ApplyAttibuteModifications(flags, attrs, doc.Defaults);

                var proto = doc.Prototypes.FirstOrDefault(x => x.Name == rec.PrototypeName);
                if (proto != null)
                {
                    inproc = ApplyAttibuteModifications(inproc.Item1, inproc.Item2, proto.Attributes);
                }

                inproc = ApplyAttibuteModifications(inproc.Item1, inproc.Item2, rec.Attributes);

                var fields = rec.Fields.Select(x => new Field(x.Name, x.Type)).ToArray();
                result.Records.Add(new Record(rec.Name, inproc.Item1.ToArray(), inproc.Item2, fields));
            }

            return(result);
        }
Example #4
0
        //删除条目,
        public async void DeleteData(RecordItem recordItem)
        {
            int index = RecordList.FindIndex(r => r.WebSite == recordItem.WebSite && r.Account == recordItem.Account);

            RecordList.RemoveAt(index);
            await BackupAsync(SaveType.LocalState);
        }
        /// <summary>
        /// This method searches for all the records that contain the string (searchString) and returns them as a RecordList object .
        /// /*This could easily be changed to it returns a List<Record> but I think returning a RecordList object is much helpful right now.*/
        /// USE THIS METHOD TO PRINT THE NEW RECORD LIST AFTER SEARCHING!!!
        /// </summary>
        /// <param name="searchString"></param>
        /// <returns></returns>
        public RecordList searchRecord(string searchString)
        {
            List <Record> searchedList = recordList.filterList(searchString);
            RecordList    cloneList    = new RecordList(searchedList);

            return(cloneList); //Needs some things updated in list and form first.
        }
Example #6
0
        public IPacket ReadPacket(IMinecraftDataReader reader)
        {
            Coordinates = Coordinates2D.FromReaderInt(reader);
            RecordList  = RecordList.FromReader(reader);

            return(this);
        }
Example #7
0
        //读出备份数据,同时将备份数据写入本地文件
        public async Task ReadBackupAsync(SaveType st)
        {
            IsProgressRingVisible = true;
            SettingResult         = "开始恢复...";
            string strRecover = await FileManager.RecoverAsync(st);

            if (strRecover.StartsWith("-"))
            {
                SettingResult         = strRecover.Substring(1);
                IsProgressRingVisible = false;
                return;
            }
            await FileManager.BackupAsync(strRecover, SaveType.LocalState);

            switch (strRecover.Substring(0, 3))
            {
            case "02|":
                RightPwdMd5 = strRecover.Substring(3, 32);
                break;

            default:
                RightPwdMd5 = strRecover.Substring(0, 32);
                break;
            }
            SettingResult = "恢复成功!";
            IsCheck       = false;
            RecordList.Clear();
            UserInputPwd          = "";
            IsLstMainSelected     = true;
            IsProgressRingVisible = false;
        }
Example #8
0
        //更改数据,找到与记忆条目相同的,更改之,然后返回去
        public async void ModifyData()
        {
            if ((RecordItemMemory.WebSite == RecordItemToModify.WebSite && RecordItemMemory.Account == RecordItemToModify.Account) ||
                (RecordList.FindIndex(r => r.WebSite == RecordItemToModify.WebSite && r.Account == RecordItemToModify.Account) < 0))
            {
                int index = RecordList.FindIndex(r => r.WebSite == RecordItemMemory.WebSite && r.Account == RecordItemMemory.Account);
                CopyRecordItem(RecordItemToModify, RecordList[index]);
                string str = await BackupAsync(SaveType.LocalState);

                if (str.StartsWith("-"))
                {
                    Title = str.Substring(1);
                }
                else
                {
                    Title = "收藏列表";
                }
                IsUcItemDetailVisible = false;
                IsGrdPwdsListVisible  = true;
                IsBackVisible         = false;
            }
            else
            {
                RecordItemToModify.WebSite = "错误!已有此网站与账号!";
            }
        }
Example #9
0
        private void CheckExpectedListItemsClassInSync()
        {
            int beExpectedListItemsClass    = m_browseViewer.BulkEditBar.ExpectedListItemsClassId;
            int clerkExpectedListItemsClass = Clerk.SortItemProvider.ListItemsClass;

            RecordList.CheckExpectedListItemsClassInSync(beExpectedListItemsClass, clerkExpectedListItemsClass);
        }
        /// <summary>
        /// Метод генерации записей в отдельном потоке
        /// </summary>
        public void StartGeneration()
        {
            if (generationProcess)
            {
                generationProcess = false;
            }
            else
            {
                buttonText        = "Остановить";
                status            = "Идет генерация записей";
                generationProcess = true;

                if (RecordList != null)
                {
                    RecordList.Clear();
                }

                cg.DoGenerationAsync(recordsCount);

                RecordList = cg.localRecordList;

                generationProcess = false;
                status            = "Ожидание начала работы";
                buttonText        = "Генерировать";
                count             = "Всего: " + RecordList.Count;
                GC.Collect();
            }
        }
Example #11
0
    public override void OpenRecord(BaseTask task)
    {
        task.RecordIndex = RecordList.Count;
        SpatialRecord prevRecord = (RecordList.Count == 0) ? null : RecordList[RecordList.Count - 1] as SpatialRecord;

        RecordList.Add(new SpatialRecord(prevRecord, task as SpatialTask));
    }
Example #12
0
        public SAV_Trainer7()
        {
            Loading = true;
            InitializeComponent();
            if (Main.unicode)
            {
                try { TB_OTName.Font = FontUtil.getPKXFont(11); }
                catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
            }

            WinFormsUtil.TranslateInterface(this, Main.curlanguage);
            B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";

            CB_Gender.Items.Clear();
            CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection

            getComboBoxes();
            getTextBoxes();

            CB_Stats.Items.Clear();
            for (int i = 0; i < 200; i++)
            {
                string name;
                if (!RecordList.TryGetValue(i, out name))
                {
                    name = i.ToString("D3");
                }

                CB_Stats.Items.Add(name);
            }
            CB_Stats.SelectedIndex   = RecordList.First().Key;
            CB_Fashion.SelectedIndex = 1;

            Loading = false;
        }
Example #13
0
        private void updateTip(int index, bool updateStats)
        {
            switch (index)
            {
            case 2:     // Storyline Completed Time
                int seconds = (int)(CAL_AdventureStartDate.Value - new DateTime(2000, 1, 1)).TotalSeconds;
                seconds -= seconds % 86400;
                seconds += (int)(CAL_AdventureStartTime.Value - new DateTime(2000, 1, 1)).TotalSeconds;
                Tip3.SetToolTip(NUD_Stat, dateval2str(SAV.getRecord(index), seconds));
                break;

            default:
                Tip3.RemoveAll();
                break;
            }
            if (!updateStats)
            {
                return;
            }

            string tip;

            if (RecordList.TryGetValue(index, out tip))
            {
                Tip3.SetToolTip(CB_Stats, tip);
            }
        }
Example #14
0
            static public void Choice(out bool cont)
            {
                cont = true;
                int choiceNumber = int.Parse(Console.ReadLine());

                switch (choiceNumber)
                {
                case 1:
                    RecordList.AddNewRecord();
                    break;

                case 2:
                    RecordList.ChangeRecord();
                    break;

                case 3:
                    RecordList.DeleteRecord();
                    break;

                case 4:
                    RecordList.ShowOneRecord();
                    break;

                case 5:
                    RecordList.ShowWholeDictionary();
                    break;

                case 6:
                    cont = false;
                    break;

                default:
                    break;
                }
            }
Example #15
0
        public override void PopulateRecordBar(RecordList recList)
        {
            CheckDisposed();

            // The ListBar has a problem in that when it is populated for the first time the horizonal
            // scroll scrolls over a little ways over hiding the left most + or -. I (Rand) sent some
            // time searching this out and found that it is a bug in the ListView control.  It is not
            // our bug.  The scrolling happens when EnsureVisible() is called on the listview.  I found
            // a way around it. By calling this method twice the bug goes away, it looks like the list
            // must be populated, cleared, then repopulated before the bug is bypassed. There are also
            // other things that have an effect on it, such as ClearListBar() must be before
            // BeginUpdate().  Also selection must be made before ExpandAll() or CollapseAll() is called.

            // JohnT: no, the problem is when we EnsureVisible of a node that is wider than the window.
            // EnsureVisble tries to show as much as possible of the label; since it won't fit, it scrolls
            // horizontally and hides the plus/minus.
            // To avoid this if it is desired to EnsureVisible, use the EnsureSelectedNodeVisible routine
            // (which temporarily makes the label short while calling EnsureVisible).
            // (I'm not sure why Rand's comment is in this exact location, so I'm not deleting it.)

            if (this.IsShowing)
            {
                m_fOutOfDate = false;
            }
            else
            {
                m_fOutOfDate = true;
                return;
            }

            XWindow window = (XWindow)m_mediator.PropertyTable.GetValue("window");

            window.TreeBarControl.IsFlatList = true;
            window.Cursor = Cursors.WaitCursor;
            ListView list = (ListView)window.ListStyleRecordList;

            list.BeginUpdate();
            window.ClearRecordBarList();                //don't want to directly clear the nodes, because that causes an event to be fired as every single note is removed!
            m_hvoToListViewItemTable.Clear();

            AddListViewItems(recList.SortedObjects, list);
            try
            {
                list.Font = new System.Drawing.Font(recList.FontName, recList.TypeSize);
            }
            catch (Exception error)
            {
                ErrorReporter.ReportException(error, null, false);
            }


            UpdateSelection(recList.CurrentObject);
            list.EndUpdate();

            if (list.SelectedItems.Count > 0)
            {
            }             //list.s .EnsureVisible();

            window.Cursor = Cursors.Default;
        }
Example #16
0
    public override void OpenRecord(BaseTask task)
    {
        task.RecordIndex = RecordList.Count;
        CollectRecord prevRecord = (RecordList.Count == 0) ? null : RecordList[RecordList.Count - 1] as CollectRecord;

        RecordList.Add(new CollectRecord(prevRecord, task as CollectTask));
    }
Example #17
0
        private void ReadCart()
        {
            int     ProductBuyCount   = 0;
            decimal ProductTotalPrice = 0M;

            this.cartList = CartBLL.ReadCartList(userID);
            string strProductID = string.Empty;

            foreach (CartInfo info in this.cartList)
            {
                if (strProductID == string.Empty)
                {
                    strProductID = info.ProductID.ToString();
                }
                else
                {
                    strProductID = strProductID + "," + info.ProductID.ToString();
                }
            }
            //List<MemberPriceInfo> memberPriceList = MemberPriceBLL.ReadMemberPriceByProductGrade(strProductID, base.GradeID);
            foreach (CartInfo info in this.cartList)
            {
                ProductInfo product = ProductBLL.ReadProduct(info.ProductID);
                info.ProductPrice  = product.MarketPrice;//MemberPriceBLL.ReadCurrentMemberPrice(memberPriceList, base.GradeID, TestCateModel);
                ProductBuyCount   += 1;
                ProductTotalPrice += info.ProductPrice;
            }
            RecordList.DataSource = cartList;
            RecordList.DataBind();
            Sessions.ProductBuyCount   = ProductBuyCount;
            Sessions.ProductTotalPrice = ProductTotalPrice;
        }
Example #18
0
    public void recordScore()
    {
        Record newRecord = new Record();

        newRecord.name   = nameInput.text;
        newRecord.score  = floor;
        newRecord.single = single;
        if (single)
        {
            singleRecords.Add(newRecord);
            //排序
            for (int i = 0; i < singleRecords.Count; i++)
            {
                for (int j = i; j < singleRecords.Count; j++)
                {
                    if (singleRecords[j].score > singleRecords[i].score)
                    {
                        Record tmp = singleRecords[j];
                        singleRecords[j] = singleRecords[i];
                        singleRecords[i] = tmp;
                    }
                }
            }
            if (singleRecords.Count > 10)
            {
                singleRecords.RemoveAt(10);
            }
        }
        else
        {
            mutiRecords.Add(newRecord);
            //排序
            for (int i = 0; i < mutiRecords.Count; i++)
            {
                for (int j = i; j < mutiRecords.Count; j++)
                {
                    if (mutiRecords[j].score > mutiRecords[i].score)
                    {
                        Record tmp = mutiRecords[j];
                        mutiRecords[j] = mutiRecords[i];
                        mutiRecords[i] = tmp;
                    }
                }
            }
            if (mutiRecords.Count > 10)
            {
                mutiRecords.RemoveAt(10);
            }
        }
        StreamWriter file   = new StreamWriter(Application.dataPath + "/Record.json", false);
        RecordList   tmpRec = new RecordList();

        tmpRec.records = new List <Record>();
        tmpRec.records.AddRange(singleRecords);
        tmpRec.records.AddRange(mutiRecords);
        file.WriteLine(JsonConvert.SerializeObject(tmpRec));
        file.Close();
        //跳記錄選單
        goRecordMenu();
    }
Example #19
0
        public async Task <RecordList> GetRecordsAsync()
        {
            HttpRequestMessage request      = new HttpRequestMessage(HttpMethod.Post, "/action/recordListGet");
            RecordList         responseBody = await SendRequest <RecordList>(request);

            return(responseBody);
        }
 /// <summary>
 /// RecordController constructor, generates a unique ID for the list. (Good for accounts later).
 /// </summary>
 public RecordController()
 {
     if (recInvoker == null)
     {
         recInvoker = new RecordInvoker();
     }
     recordList = new RecordList();
     generateUniqueID();
 }
Example #21
0
        public void PopulateRecordBarIfNeeded(RecordList list)
        {
            CheckDisposed();

            if (m_fOutOfDate)
            {
                PopulateRecordBar(list);
            }
        }
Example #22
0
        public void TestRecordList()
        {
            var head = MyLinkList.BuildListNodeFromArray(new[] { 1, 2, 3, 4, 5, 6, 7 });

            RecordList.Record(head);
            Assert.AreEqual(head.Next.Next.Val, 7);
            Assert.AreEqual(head.Next.Next.Next.Next.Val, 6);
            Assert.AreEqual(head.Next.Next.Next.Next.Next.Next.Val, 5);
            Assert.AreEqual(head.Next.Next.Next.Next.Next.Next.Next.Val, 4);
        }
Example #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CenterTitle.Text = "¶©µ¥ÏêÇé";
            userID           = base.UserID;
            int queryString = RequestHelper.GetQueryString <int>("ID");

            this.order            = OrderBLL.ReadOrder(queryString, userID);
            RecordList.DataSource = OrderDetailBLL.ReadOrderDetailByOrder(queryString);
            RecordList.DataBind();
        }
 public HabitMonthlyRecordTestData(DateTime dtBegin, List <UserHabitRecord> habitRecords, int firstMonthRecordCount, int secondMonthRecordCount) : this()
 {
     BeginDate = dtBegin;
     if (habitRecords.Count > 0)
     {
         RecordList.AddRange(habitRecords);
     }
     ExpectedFirstMonthRecordCount  = firstMonthRecordCount;
     ExpectedSecondMonthRecordCount = secondMonthRecordCount;
 }
 public HabitWeeklyRecordTestData(DateTime bgndate, List <UserHabitRecord> listRecord, int firstWeek, int secondWeek) : this()
 {
     BeginDate = bgndate;
     if (listRecord.Count > 0)
     {
         RecordList.AddRange(listRecord);
     }
     ExpectedFirstWeekCount  = firstWeek;
     ExpectedSecondWeekCount = secondWeek;
 }
Example #26
0
 private void Load()
 {
     try
     {
         RecordList = (FileHandler.FileExists(RecordListPathName) ? FileHandler.Deserialize <RecordList>(RecordListPathName) : new RecordList());
     }
     catch (Exception ex)
     {
         RaiseLogEntryEvent("Failed to load record list", ex);
     }
 }
Example #27
0
        private RecordList CreateRecordList()
        {
            RecordList obj = new RecordList();

            obj.CheckStatus = CheckStatus.Deleted;
            obj.Description = "Description";
            obj.Files       = 2;
            obj.Guid        = Guid.Parse("4f3283e6-9501-4a8e-b3bb-bc60d3ed3cea");
            obj.Name        = "AisleList";
            obj.Record      = "Record-AisleWF-{a36b49e1-27bb-4c37-8bc9-7f83f34a9984}.EasyBpart";
            return(obj);
        }
Example #28
0
        protected virtual RecordList <TS> GetList <TS>(IQueryable <TS> query, int?pageindex, int?pagesize)
        {
            if (pageindex.HasValue && pagesize.HasValue)
            {
                return(GetList(query, pageindex.Value, pagesize.Value));
            }

            var list = new RecordList <TS>(query.ToList());

            list.RecordCount = list.Count;
            return(list);
        }
        private void PublishSensor(RecordList recordList, Sensor sensor)
        {
            _logger.LogDebug("Handling sensor of type {sensorType}", sensor.TypeId);
            IList <Logrow>         sensorLogRows = recordList.Logrows.Where(r => r.Sid.Equals(sensor.SensorId)).ToArray();
            IList <IStateProvider> devices       = _conversionService.GetStateProviders(sensor, sensorLogRows);

            _logger.LogDebug("Received {countDevices} devices", devices.Count);
            foreach (var device in devices)
            {
                TryCall(device, PublishStateToMqtt);
            }
        }
Example #30
0
        public IActionResult ShoppingCart()
        {
            List <Record> records = new List <Record>()
            {
                new Record()
                {
                    Name = "Record 1", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 2", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 3", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 4", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 5", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 6", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 7", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 8", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 9", Price = 13.5M
                },
                new Record()
                {
                    Name = "Record 10", Price = 13.5M
                },
            };

            var viewModel = new RecordList()
            {
                Records = records
            };

            return(View());
        }
Example #31
0
        private List<RecordList> CreateEntityDefaultRecordLists(Entity entity)
        {
            List<RecordList> recordLists = new List<RecordList>();

            var create = new RecordList();
            create.Id = Guid.NewGuid();
            create.Name = "general";
            create.Label = "General";
            create.Default = true;
            create.System = true;
            create.Type = "general";
            create.Weight = 10;
            create.PageSize = 10;
            create.VisibleColumnsCount = 5;
            recordLists.Add(create);

            var lookup = new RecordList();
            lookup.Id = Guid.NewGuid();
            lookup.Name = "lookup";
            lookup.Label = "Lookup";
            lookup.Default = true;
            lookup.System = true;
            lookup.Type = "lookup";
            lookup.Weight = 10;
            lookup.PageSize = 10;
            lookup.VisibleColumnsCount = 5;
            recordLists.Add(lookup);

            return recordLists;
        }
Example #32
0
        private QueryObject CreateSearchQuery(string search, RecordList list, Entity entity)
        {
            if (string.IsNullOrWhiteSpace(search))
                return null;

            if (list == null)
                return null;

            search = search.Trim();

            var listFields = list.Columns.Where(c => c is RecordListFieldItem).Select(c => c as RecordListFieldItem).ToList();

            var firstSearchableField = listFields.FirstOrDefault(x => entity.Fields.Single(f => f.Id == x.FieldId).Searchable);
            if (firstSearchableField == null)
                throw new Exception("The list has no searchable fields.");

            var field = entity.Fields.SingleOrDefault(f => f.Id == firstSearchableField.FieldId);

            if (field is AutoNumberField || field is CurrencyField || field is NumberField || field is PercentField)
            {
                decimal value;
                if (!decimal.TryParse(search, out value))
                    throw new Exception("Invalid search value. It should be a number.");

                return EntityQuery.QueryEQ(field.Name, value);
            }
            else if (field is GuidField)
            {
                Guid value;
                if (!Guid.TryParse(search, out value))
                    throw new Exception("Invalid search value. It should be an unique identifier formated text.");

                return EntityQuery.QueryEQ(field.Name, value);
            }
            else if (field is DateTimeField || field is DateField)
            {
                DateTime value;
                if (!DateTime.TryParse(search, out value))
                    throw new Exception("Invalid search value. Cannot be recognized as date.");

                value = DateTime.SpecifyKind(value, DateTimeKind.Utc);
                return EntityQuery.QueryEQ(field.Name, value);
            }
            else if (field is MultiSelectField)
            {
                var option = (field as MultiSelectField).Options.FirstOrDefault(o => o.Value == search);
                if (option == null)
                    return EntityQuery.QueryEQ(field.Name, Guid.NewGuid().ToString()); //this will always be not found
                else
                    return EntityQuery.QueryEQ(field.Name, option.Key); //search in the keys
            }
            else
                return EntityQuery.QueryContains(field.Name, search);
        }
Example #33
0
        private RecordListResponse ReadRecordList(Entity entity, RecordList recordList)
        {
            RecordListResponse response = new RecordListResponse
            {
                Success = true,
                Message = "The list was successfully returned!",
            };

            try
            {
                response.Object = recordList;
            }
            catch (Exception e)
            {
                response.Timestamp = DateTime.UtcNow;
                response.Success = false;
            #if DEBUG
                response.Message = e.Message + e.StackTrace;
            #else
                response.Message = "An internal error occurred!";
            #endif
                return response;
            }

            response.Timestamp = DateTime.Now;

            return response;
        }
Example #34
0
        private List<RecordList> CreateEntityDefaultRecordLists(Entity entity)
        {
            List<RecordList> recordLists = new List<RecordList>();

            var create = new RecordList();
            create.Id = Guid.NewGuid();
            create.Name = "general";
            create.Label = "General";
            create.Title = "General";
            create.Default = true;
            create.System = false;
            create.Type = "general";
            create.IconName = "list";
            create.PageSize = 10;
            create.Weight = 10;
            create.VisibleColumnsCount = 5;
            create.ServiceCode = null;
            create.DynamicHtmlTemplate = null;
            create.DataSourceUrl = null;
            create.ActionItems = new List<ActionItem>();
            create.ActionItems.Add(GenerateListActionItem("wv_create_record"));
            create.ActionItems.Add(GenerateListActionItem("wv_import_records"));
            create.ActionItems.Add(GenerateListActionItem("wv_export_records"));
            create.ActionItems.Add(GenerateListActionItem("wv_record_details"));
            create.ActionItems.Add(GenerateListActionItem("wv_recursive_list_add_existing"));
            create.ActionItems.Add(GenerateListActionItem("wv_recursive_list_add_new"));
            create.ActionItems.Add(GenerateListActionItem("wv_recursive_list_view"));
            create.ActionItems.Add(GenerateListActionItem("wv_recursive_list_edit"));
            create.ActionItems.Add(GenerateListActionItem("wv_recursive_list_unrelate"));
            recordLists.Add(create);

            var lookup = new RecordList();
            lookup.Id = Guid.NewGuid();
            lookup.Name = "lookup";
            lookup.Label = "Lookup";
            lookup.Title = "Lookup";
            lookup.Default = true;
            lookup.System = false;
            lookup.Type = "lookup";
            lookup.IconName = "list";
            lookup.PageSize = 10;
            lookup.Weight = 10;
            lookup.VisibleColumnsCount = 5;
            lookup.ServiceCode = null;
            lookup.DynamicHtmlTemplate = null;
            lookup.DataSourceUrl = null;
            lookup.ActionItems = new List<ActionItem>();
            lookup.ActionItems.Add(GenerateListActionItem("wv_create_record"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_import_records"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_export_records"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_record_details"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_recursive_list_add_existing"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_recursive_list_add_new"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_recursive_list_view"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_recursive_list_edit"));
            lookup.ActionItems.Add(GenerateListActionItem("wv_recursive_list_unrelate"));
            recordLists.Add(lookup);

            return recordLists;
        }
        /// <summary>
        /// Gets a list of queue records.
        /// </summary>
        /// <param name="applicationName">The name of the application to get the queue list for.</param>
        /// <param name="search">The search query to filter the collection with.</param>
        /// <param name="limit">The paging limit to use.</param>
        /// <param name="offset">The paging offset to use.</param>
        /// <param name="transaction">The transaction to use, if applicable.</param>
        /// <returns>A collection of queue records.</returns>
        public RecordList<QueueListRecord> GetQueuedList(string applicationName, string search, int limit, int offset, IDbTransaction transaction)
        {
            StringBuilder cb = new StringBuilder(
            @"SELECT CAST(COUNT(q.[Id]) AS bigint)
            FROM [BlueCollarQueue] q
            LEFT OUTER JOIN [BlueCollarSchedule] s ON q.[ScheduleId] = s.[Id]
            WHERE
            q.[ApplicationName] = @ApplicationName");

            StringBuilder sb = new StringBuilder(
            @"SELECT *
            FROM
            (
            SELECT
            q.[Id],
            q.[QueueName],
            q.[JobName],
            q.[JobType],
            q.[QueuedOn],
            q.[TryNumber],
            s.[Name] AS [ScheduleName],
            ROW_NUMBER() OVER(ORDER BY q.[QueuedOn] ASC, q.[JobName] ASC) AS [RowNumber]
            FROM [BlueCollarQueue] q
            LEFT OUTER JOIN [BlueCollarSchedule] s ON q.[ScheduleId] = s.[Id]
            WHERE
            q.[ApplicationName] = @ApplicationName");

            if (!string.IsNullOrEmpty(search))
            {
                const string Search = @"
            AND
            (
            q.[QueueName] LIKE @Search
            OR q.[JobName] LIKE @Search
            OR q.[JobType] LIKE @Search
            OR s.[Name] LIKE @Search
            )";

                cb.Append(Search);
                sb.Append(Search);
            }

            cb.Append(";\n\n");

            sb.Append("\n");
            sb.Append(
            @") t
            WHERE t.[RowNumber] BETWEEN @Offset + 1 AND @Offset + @Limit;");

            sb.Append("\n");
            sb.Append(CountsSql);

            var p = new
            {
                ApplicationName = applicationName,
                Search = !string.IsNullOrEmpty(search) ? string.Concat("%", search, "%") : null,
                Limit = limit,
                Offset = offset
            };

            var list = new RecordList<QueueListRecord>();

            using (var multi = this.connection.QueryMultiple(cb.ToString() + sb.ToString(), p, transaction, null, null))
            {
                list.SetPaging(multi.Read<long>().First(), limit, offset);

                foreach (var record in multi.Read<QueueListRecord>())
                {
                    list.Records.Add(record);
                }

                list.Counts = CreateCounts(multi);
            }

            return list;
        }
        /// <summary>
        /// Gets a list of worker records.
        /// </summary>
        /// <param name="applicationName">The application name to get records for.</param>
        /// <param name="search">The search query to filter the collection with.</param>
        /// <param name="limit">The paging limit to use.</param>
        /// <param name="offset">The paging offset to use.</param>
        /// <param name="transaction">The transaction to use, if applicable.</param>
        /// <returns>A collection of worker records.</returns>
        public RecordList<WorkerRecord> GetWorkerList(string applicationName, string search, int limit, int offset, IDbTransaction transaction)
        {
            StringBuilder cb = new StringBuilder(
            @"SELECT CAST(COUNT([Id]) AS bigint)
            FROM [BlueCollarWorker]
            WHERE
            [ApplicationName] = @ApplicationName");

            StringBuilder sb = new StringBuilder(
            @"SELECT *
            FROM
            (
            SELECT
            *,
            ROW_NUMBER() OVER(ORDER BY [Name] ASC) AS [RowNumber]
            FROM [BlueCollarWorker]
            WHERE
            [ApplicationName] = @ApplicationName");

            if (!string.IsNullOrEmpty(search))
            {
                const string Search = @"
            AND
            (
            [Name] LIKE @Search
            OR [MachineName] LIKE @Search
            OR [MachineAddress] LIKE @Search
            OR [QueueNames] LIKE @Search
            OR [Status] LIKE @Search
            OR [Signal] LIKE @Search
            OR [Startup] LIKE @Search
            )";

                cb.Append(Search);
                sb.Append(Search);
            }

            cb.Append(";\n\n");

            sb.Append("\n");
            sb.Append(
            @") t
            WHERE t.[RowNumber] BETWEEN @Offset + 1 AND @Offset + @Limit;");

            sb.Append("\n");
            sb.Append(CountsSql);

            var p = new
            {
                ApplicationName = applicationName,
                Search = !string.IsNullOrEmpty(search) ? string.Concat("%", search, "%") : null,
                Limit = limit,
                Offset = offset
            };

            var list = new RecordList<WorkerRecord>();

            using (var multi = this.connection.QueryMultiple(cb.ToString() + sb.ToString(), p, transaction, null, null))
            {
                list.SetPaging(multi.Read<long>().First(), limit, offset);

                foreach (var record in multi.Read<WorkerRecord>())
                {
                    list.Records.Add(record);
                }

                list.Counts = CreateCounts(multi);
            }

            return list;
        }
Example #37
0
        public void SaveToDb(string name)
        {
            Console.WriteLine ("Saving to db");

            Map map = new Map () {
                Height = this.h,
                Width = this.w
            };

            GameState game = new GameState () {
                Name = name,
                Map = map,
            };

            string[] deleteTables = new string[] {
                "gamestate",
                "map",
                "hex",
                "hexresource",
                "map_cities",
                "map_rivers",
                "map_hexes",
                "hex_edges",
                "hex_effects",
                "kingdom"
            };

            foreach (string deleteTable in deleteTables)
                MySqlProvider.Provider.ExecuteNonQuery ("truncate " + deleteTable + ";");

            map.Game = game;
            map.Save ();
            game.Save ();

            RecordList<Hex> hexes = new RecordList<Hex> ();
            for (int x = 0; x < w; x++) {
                for (int y = 0; y < h; y++) {
                    Hex hex = new Hex ();
                    hex.EnsureId ();
                    hex.X = x;
                    hex.Y = y;
                    Color c = b.GetPixel (x, y);
                    if (c == blue)
                        hex.Terrain = TerrainType.Sea;
                    else if (c == white)
                        hex.Terrain = TerrainType.Mountains;
                    else if (c == darkGreen)
                        hex.Terrain = TerrainType.Forest;
                    else if (c == town)
                    {
                        hex.Terrain = TerrainType.Plains;
                    }
                    else
                        hex.Terrain = TerrainType.Plains;
                    hexes.Add (hex);
                    hexMap[x,y] = hex;
                }
            }

            //cities have to be done in a separate pass to account for growth.
            map.Hexes = hexes;
            map.EnsureMapIsBuilt (true);

            //check coastals
            foreach (Hex h in hexes)
                if (h.Terrain == TerrainType.Sea)
                    CheckCoastal (h);

            hexes.Save ();

            foreach (var kvp in riverPaths)
            {
                River r = new River();
                int z = 0;
                foreach(Point p in kvp.Value)
                {
                    r.Path.Add (new Triple<int> () {
                        X = p.X,
                        Y = p.Y,
                        Z = z++
                    });
                }
                r.Save ();
                r.Path.Save ();
                r.SaveRelations("Path");
                map.Rivers.Add (r);
            }

            map.SaveRelations ("Rivers");
            map.SaveRelations ("Hexes");
        }
Example #38
0
 protected IStorageRecordList CreateEmptyRecordListObject(RecordList list)
 {
     var storageService = service.StorageService;
     return storageService.GetObjectFactory().CreateEmptyRecordListObject();
 }
        /// <summary>
        /// Gets a list of schedule records.
        /// </summary>
        /// <param name="applicationName">The name of the application to get the schedule list for.</param>
        /// <param name="search">The search query to filter the collection with.</param>
        /// <param name="limit">The paging limit to use.</param>
        /// <param name="offset">The paging offset to use.</param>
        /// <param name="transaction">The transaction to use, if applicable.</param>
        /// <returns>A collection of schedules.</returns>
        public RecordList<ScheduleListRecord> GetScheduleList(string applicationName, string search, int limit, int offset, IDbTransaction transaction)
        {
            StringBuilder cb = new StringBuilder(
            @"SELECT CAST(COUNT(DISTINCT s.[Id]) AS bigint)
            FROM [BlueCollarSchedule] s
            LEFT OUTER JOIN [BlueCollarScheduledJob] j ON s.[Id] = j.[ScheduleId]
            WHERE
            s.[ApplicationName] = @ApplicationName");

            StringBuilder sb = new StringBuilder(
            @"SELECT DISTINCT s.*,
            (
            SELECT CAST(COUNT(sj.[Id]) AS bigint)
            FROM [BlueCollarScheduledJob] sj
            WHERE
            sj.[ScheduleId] = s.[Id]
            ) AS [JobCount]
            FROM [BlueCollarSchedule] s
            LEFT OUTER JOIN [BlueCollarScheduledJob] j ON s.[Id] = j.[ScheduleId]
            WHERE
            s.[ApplicationName] = @ApplicationName");

            if (!string.IsNullOrEmpty(search))
            {
                const string Search = @"
            AND
            (
            s.[QueueName] LIKE @Search
            OR s.[Name] LIKE @Search
            OR s.[RepeatType] LIKE @Search
            OR j.[JobType] LIKE @Search
            )";

                cb.Append(Search);
                sb.Append(Search);
            }

            cb.Append(";\n\n");

            sb.Append("\n");
            sb.Append(
            @"ORDER BY s.[Name] ASC
            LIMIT @Limit OFFSET @Offset;");

            sb.Append("\n");
            sb.Append(CountsSql);

            var p = new
            {
                ApplicationName = applicationName,
                Search = !string.IsNullOrEmpty(search) ? string.Concat("%", search, "%") : null,
                Limit = limit,
                Offset = offset
            };

            var list = new RecordList<ScheduleListRecord>();

            using (var multi = this.connection.QueryMultiple(cb.ToString() + sb.ToString(), p, transaction, null, null))
            {
                list.SetPaging(multi.Read<long>().First(), limit, offset);

                foreach (var record in multi.Read<ScheduleListRecord>())
                {
                    list.Records.Add(record);
                }

                list.Counts = CreateCounts(multi);
            }

            return list;
        }
        /// <summary>
        /// Gets a list of history records.
        /// </summary>
        /// <param name="applicationName">The name of the application to get the history list for.</param>
        /// <param name="search">The search query to filter the collection with.</param>
        /// <param name="limit">The paging limit to use.</param>
        /// <param name="offset">The paging offset to use.</param>
        /// <param name="transaction">The transaction to use, if applicable.</param>
        /// <returns>A list of history records.</returns>
        public RecordList<HistoryListRecord> GetHistoryList(string applicationName, string search, int limit, int offset, IDbTransaction transaction)
        {
            StringBuilder cb = new StringBuilder(
            @"SELECT CAST(COUNT(h.[Id]) AS bigint)
            FROM [BlueCollarHistory] h
            LEFT OUTER JOIN [BlueCollarSchedule] s ON h.[ScheduleId] = s.[Id]
            WHERE
            h.[ApplicationName] = @ApplicationName");

            StringBuilder sb = new StringBuilder(
            @"SELECT
            h.[Id],
            h.[QueueName],
            h.[JobName],
            h.[JobType],
            h.[QueuedOn],
            h.[TryNumber],
            h.[StartedOn],
            h.[Status],
            h.[FinishedOn],
            s.[Name] AS [ScheduleName]
            FROM [BlueCollarHistory] h
            LEFT OUTER JOIN [BlueCollarSchedule] s ON h.[ScheduleId] = s.[Id]
            WHERE
            h.[ApplicationName] = @ApplicationName");

            if (!string.IsNullOrEmpty(search))
            {
                const string Search = @"
            AND
            (
            h.[QueueName] LIKE @Search
            OR h.[JobName] LIKE @Search
            OR h.[JobType] LIKE @Search
            OR h.[Status] LIKE @Search
            OR s.[Name] LIKE @Search
            )";

                cb.Append(Search);
                sb.Append(Search);
            }

            cb.Append(";\n\n");

            sb.Append("\n");
            sb.Append(
            @"ORDER BY h.[QueuedOn] DESC, h.[JobName] ASC, h.[TryNumber] DESC
            LIMIT @Limit OFFSET @Offset;");

            sb.Append("\n");
            sb.Append(CountsSql);

            var p = new
            {
                ApplicationName = applicationName,
                Search = !string.IsNullOrEmpty(search) ? string.Concat("%", search, "%") : null,
                Limit = limit,
                Offset = offset
            };

            var list = new RecordList<HistoryListRecord>();

            using (var multi = this.connection.QueryMultiple(cb.ToString() + sb.ToString(), p, transaction, null, null))
            {
                list.SetPaging(multi.Read<long>().First(), limit, offset);

                foreach (var record in multi.Read<HistoryListRecord>())
                {
                    list.Records.Add(record);
                }

                list.Counts = CreateCounts(multi);
            }

            return list;
        }