//Метод генериране на Визуалните Елементи public void generateVisualElements() { //Създава списък от Визуални елементи VisualElements = new List <SortingElement>(); //Обхожда елементите в Списък с Числа Елементи foreach (int element in IntegerElements) { SortingElement SE = new SortingElement(element); //Добавя в списъка с Визуални елементи от списъка от Числа Елементи VisualElements.Add(SE); } }
public bool appliedCompare(int difference_val_A_B) { int target = 0; if (difference_val_A_B > 0) { target = this.elementListA[0].partList[0]; this.elementListA[0].partList.RemoveAt(0); } else { target = this.elementListA[1].partList[0]; this.elementListA[1].partList.RemoveAt(0); } this.targetSortingElement.partList.Add(target); if (elementListA[0].partList.Count == 0 || elementListA[1].partList.Count == 0) { if (elementListA[0].partList.Count == 0) { this.targetSortingElement.partList.AddRange(this.elementListA[1].partList); } else if (elementListA[1].partList.Count == 0) { this.targetSortingElement.partList.AddRange(this.elementListA[0].partList); } this.elementListB.Add(targetSortingElement); this.targetSortingElement = new SortingElement(); this.elementListA.RemoveRange(0, 2); if (elementListA.Count == 0) { this.elementListA = this.elementListB; this.elementListB = new List <SortingElement>(); this.sortingComplete = this.nowSpliter >= length; this.nowSpliter = this.nowSpliter * 2; } else if (elementListA.Count == 1) { this.elementListB.AddRange(this.elementListA); this.elementListA.RemoveAt(0); this.elementListA = this.elementListB; this.elementListB = new List <SortingElement>(); this.sortingComplete = this.nowSpliter >= length; this.nowSpliter = this.nowSpliter * 2; } } return(this.sortingComplete); }
/// <summary> /// Handles the Sorting event of the MainGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewSortEventArgs"/> instance containing the event data.</param> void MainGrid_Sorting(object sender, GridViewSortEventArgs e) { #region Check for field being meta field bool _flag = false; foreach (MetaField field in CurrentView.AvailableFields) { if (field.Name == e.SortExpression) { _flag = true; break; } } if (!_flag) { return; } #endregion McMetaViewPreference mvPref = GetMetaViewPreference(); //fix bug when user try to sort column which doesn't support sorting at MetaData level if (!MetaDataWrapper.IsSortable(e.SortExpression, mvPref)) { return; } //fix issue with ajaxcontroltoolkit 3.5 Thread.Sleep(750); if (mvPref.Sorting == null || mvPref.Sorting.Count == 0) { SortingElement new_sort = new SortingElement(); mvPref.Sorting.Add(new_sort); } SortingElement sort = mvPref.Sorting[0]; if (sort.Source.Equals(e.SortExpression)) { if (sort.Type == SortingElementType.Asc) { sort.Type = SortingElementType.Desc; } else { sort.Type = SortingElementType.Asc; } } else { sort.Source = e.SortExpression; sort.Type = SortingElementType.Asc; } }
/// <summary> /// Gets the min start date. /// </summary> /// <param name="userId">The user id.</param> /// <returns></returns> public static DateTime GetTimeTrackingBlockMinStartDate(int userId) { TimeTrackingBlock[] userBlocks = TimeTrackingBlock.List( new FilterElementCollection(FilterElement.EqualElement("OwnerId", userId)), new SortingElementCollection(SortingElement.Ascending("StartDate")), 0, 1); if (userBlocks.Length > 0) { return(userBlocks[0].StartDate); } return(DateTime.Now.AddDays(-210)); }
/// <summary> /// Gens the source. /// </summary> /// <param name="text">The text.</param> /// <param name="totalCount">The total count.</param> /// <returns></returns> private DataTable genSource(string text, out int totalCount) { DataTable dt = new DataTable(); dt.Locale = CultureInfo.InvariantCulture; dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(int))); dt.Columns.Add(new DataColumn(TitleFieldName, typeof(string))); MetaClass mc = MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName); FilterElementCollection fec = new FilterElementCollection(); fec.Add(new FilterElement(mc.TitleFieldName, FilterElementType.Contains, text)); if (!String.IsNullOrEmpty(CardFilter)) { string[] mas = CardFilter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); if (mas.Length > 0) { OrBlockFilterElement fe = new OrBlockFilterElement(); foreach (string sCard in mas) { fe.ChildElements.Add(FilterElement.EqualElement("Card", sCard.Trim())); } fec.Add(fe); } } MetaObject[] list = MetaObject.List(mc, fec, new SortingElementCollection(SortingElement.Ascending(mc.TitleFieldName))); int count = 0; foreach (MetaObject bo in list) { DataRow row = dt.NewRow(); row["PrimaryKeyId"] = bo.PrimaryKeyId; row[TitleFieldName] = bo.Properties[mc.TitleFieldName].Value.ToString(); dt.Rows.Add(row); count++; if (count > 10) { break; } } totalCount = list.Length; return(dt); }
/// <summary> /// Invokes this instance. /// </summary> public override void Invoke() { // Remove Expired RemoveExpiredMessages(); //int maxDeliveryAttempts = 100; // TODO: Read From Config EntityObject[] elements = BusinessManager.List(OutgoingMessageQueueEntity.ClassName, OutgoingMessageUtil.CreateIbnClientMessageDeliveryProviderFilters(), new SortingElement[] { SortingElement.Ascending(OutgoingMessageQueueEntity.FieldCreated) }); foreach (OutgoingMessageQueueEntity element in elements) { try { // Load Ibn Message IbnClientMessageEntity message = (IbnClientMessageEntity)BusinessManager.Load(IbnClientMessageEntity.ClassName, element.IbnClientMessageId.Value); // Send int toOriginalId = DBUser.GetOriginalId(message.ToId); int fromOriginalId = DBUser.GetOriginalId(message.FromId); IMHelper.SendMessage(toOriginalId, fromOriginalId, message.HtmlBody); element.Error = string.Empty; element.DeliveryAttempts++; element.IsDelivered = true; } catch (Exception ex) { element.Error = ex.Message; element.DeliveryAttempts++; // TODO: Save Complete Error Stack || Complete Delivery Log } BusinessManager.Update(element); } // }
public MergeSorter(List <string> source) { this.source = source; this.length = source.Count; this.elementListA = new List <SortingElement>(); int counter = 0; foreach (string str in source) { elementListA.Add(new SortingElement(counter)); counter++; } this.elementListB = new List <SortingElement>(); this.targetSortingElement = new SortingElement(); this.nowSpliter = 1; if (nowSpliter >= length) { this.sortingComplete = true; } this.nowSpliter = this.nowSpliter * 2; int dSpliter = 2; while (dSpliter <= this.length) { int eleCount = this.length / dSpliter; timeMINCount += eleCount * dSpliter; timeMAXCount += eleCount * 2 * dSpliter; if (this.length % dSpliter > 0) { timeMINCount += 1; timeMAXCount += dSpliter; } dSpliter = dSpliter * 2; } }
public override void Invoke() { // TODO: Remove Expired RemoveExpiredMessages(); //int maxDeliveryAttempts = 100; // TODO: Read From Config int maxMessagesPerConnection = 10; // Prepare temporary collection List <MailMessage> outputMessages = new List <MailMessage>(); List <OutgoingMessageQueueEntity> queueEntity = new List <OutgoingMessageQueueEntity>(); // Load Outgoing Message Queue Entity EntityObject[] elements = BusinessManager.List(OutgoingMessageQueueEntity.ClassName, OutgoingMessageUtil.CreateEmailDeliveryProviderFilters(), new SortingElement[] { SortingElement.Ascending(OutgoingMessageQueueEntity.FieldSource), SortingElement.Ascending(OutgoingMessageQueueEntity.FieldCreated) }); // Run Message Delivery Process for (int elementIndex = 0; elementIndex < elements.Length; elementIndex++) { // Read Element From Outgoing Message Queue OutgoingMessageQueueEntity element = (OutgoingMessageQueueEntity)elements[elementIndex]; // Load Email Message EmailEntity emailEntity = (EmailEntity)BusinessManager.Load(EmailEntity.ClassName, element.EmailId.Value); // Create Output Mail Message MailMessage outputMessage = CopyEmailEntityToMailMessage(emailEntity); // Add Output message to Output queue outputMessages.Add(outputMessage); queueEntity.Add(element); string currentSource = element.Source; string nextElementSource = (elementIndex < (elements.Length - 1)) ? ((OutgoingMessageQueueEntity)elements[elementIndex + 1]).Source : string.Empty; if (outputMessages.Count < maxMessagesPerConnection && currentSource == nextElementSource) { continue; } // Send Output queue try { // OZ [2010-03-03]: Check that SmtpServer is configured. Write To Outgoing log if (SmtpBox.TotalCount() == 0) { throw new SmtpNotConfiguredException(); } // Initialize Smtp Client SmtpClient smtpClient = Mediachase.IBN.Business.EMail.SmtpClientUtility.CreateSmtpClient(element.Source); // Send smtpClient.Send(outputMessages.ToArray()); // Process result ProcessSendResult(outputMessages, queueEntity); } catch (Exception ex) { ProcessException(outputMessages, queueEntity, ex); } // Clear Output queue outputMessages.Clear(); queueEntity.Clear(); } // }
public void Insert(SortingElement referenceElement) { /* if reference element is above this element add position */ float belowFactor = (referenceElement.InsertedPosition < InsertedPosition) ? 1f : -1f; Vector2 insertPosition = referenceElement.rectTransform.anchoredPosition + (new Vector2(0f, rectTransform.sizeDelta.y + gap) * belowFactor); StartCoroutine (CoInsert (insertPosition)); }
/// <summary> /// Handles the Sorting event of the MainGrid control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewSortEventArgs"/> instance containing the event data.</param> void MainGrid_Sorting(object sender, GridViewSortEventArgs e) { #region Check for field being meta field bool _flag = false; foreach (MetaField field in CurrentView.AvailableFields) { if (field.Name == e.SortExpression) { _flag = true; break; } } if (!_flag) return; #endregion McMetaViewPreference mvPref = GetMetaViewPreference(); //fix bug when user try to sort column which doesn't support sorting at MetaData level if (!MetaDataWrapper.IsSortable(e.SortExpression, mvPref)) return; //fix issue with ajaxcontroltoolkit 3.5 Thread.Sleep(750); if (mvPref.Sorting == null || mvPref.Sorting.Count == 0) { SortingElement new_sort = new SortingElement(); mvPref.Sorting.Add(new_sort); } SortingElement sort = mvPref.Sorting[0]; if (sort.Source.Equals(e.SortExpression)) { if (sort.Type == SortingElementType.Asc) sort.Type = SortingElementType.Desc; else sort.Type = SortingElementType.Asc; } else { sort.Source = e.SortExpression; sort.Type = SortingElementType.Asc; } }
public CalendarEventListRequest(EntityObject target, SortingElement[] sorting) : base(CalendarEventListMethod.METHOD_NAME, target) { this.Sorting = sorting; }
public CalendarEventListRequest(string metaClassName,SortingElement[] sorting) : base(CalendarEventListMethod.METHOD_NAME, new EntityObject(metaClassName)) { this.Sorting = sorting; }
/// <summary> /// Функция за изпълняване на Стъпка /// </summary> private void executeStep() { CStep cstep = ctrl.Steps[Step - 1]; Step step = null; if (CurrentStep == "next") { step = cstep.NextStep; } else { step = cstep.PrevStep; } Highlight(step.Highlight); DescriptionBox.Text = "Стъпка " + Step + ":\n\n" + step.Message; //Foreach цикъл за Командите които се разделят с "|" foreach (string command in step.Command.Split('|')) { //След като обходи командите влиза в switch стейтмънта, спрямо различната команда влиза в различните кейсове switch (command) { //Кейс Join case "Attach": int limit; if (step.Delimiter == -1 || step.UsedelimForUpdateInit) { limit = step.AttachNames.Count; } else { limit = step.Delimiter; } for (int i = 0; i < limit; i++) { int index = ctrl.attachmentList.getIndexByName(step.AttachNames[i]); if (index == -1) { AttachmentElement EA_ = new AttachmentElement(step.AttachNames[i]); ctrl.addAE(EA_); if (step.AttachTo[i] == ctrl.List.IntegerElements.Count) { Point l = new Point(ctrl.List.VisualElements[step.AttachTo[i] - 1].Block.Location.X + 52, ctrl.List.VisualElements[step.AttachTo[i] - 1].Block.Location.Y); EA_.setLocation(l, step.Rows[i]); } else { EA_.setLocation(ctrl.List.VisualElements[step.AttachTo[i]].Block.Location, step.Rows[i]); } panelAnimation.Controls.Add(EA_.Attachment); } else { if (step.AttachTo[i] == ctrl.List.IntegerElements.Count) { Point l = new Point(ctrl.List.VisualElements[step.AttachTo[i] - 1].Block.Location.X + 52, ctrl.List.VisualElements[step.AttachTo[i] - 1].Block.Location.Y); ctrl.attachmentList[ctrl.attachmentList.getIndexByName(step.AttachNames[i])].setLocation(l, step.Rows[i]); } else { ctrl.attachmentList[ctrl.attachmentList.getIndexByName(step.AttachNames[i])].setLocation(ctrl.List.VisualElements[step.AttachTo[i]].Block.Location, step.Rows[i]); } } } break; //Премахва I-тата и Poz label case "Detach": if (step.Delimiter == -1 || step.UsedelimForUpdateInit) { limit = 0; } else { limit = step.Delimiter; } for (int i = limit; i < step.AttachNames.Count; i++) { int index = ctrl.attachmentList.getIndexByName(step.AttachNames[i]); if (index != -1) { panelAnimation.Controls.Remove(ctrl.attachmentList[index].Attachment); ctrl.attachmentList[index].Dispose(); ctrl.attachmentList.remove(index); } } break; //Инциализира променлива и стойност редовете, т.де инциализира стойностите на поле variableDataGridView case "Init": if (step.Delimiter == -1) { limit = step.VariableIndexes.Count(); } else { limit = step.Delimiter; } for (int i = 0; i < limit; i++) { variableDataGridView.Rows.Add(); variableDataGridView.Rows[step.VariableIndexes[i]].Cells[0].Value = step.VariableNames[i]; variableDataGridView.Rows[step.VariableIndexes[i]].Cells[1].Value = step.Values[i]; } break; //Трие определени редове от variableDataGridView case "!Init": if (step.Delimiter == -1) { limit = 0; } else { limit = step.Delimiter; } for (int i = limit; i < step.VariableIndexes.Count(); i++) { variableDataGridView.Rows.RemoveAt(step.VariableIndexes[i]); } break; //Обновява стойностите в dataGridview case "Update": if (step.Delimiter == -1) { limit = step.VariableIndexes.Count(); } else { limit = step.Delimiter; } if (step.UsedelimForUpdateInit) { for (int i = limit; i < step.VariableIndexes.Count(); i++) { variableDataGridView.Rows[step.VariableIndexes[i]].Cells[1].Value = step.Values[i]; } } else { for (int i = 0; i < limit; i++) { variableDataGridView.Rows[step.VariableIndexes[i]].Cells[1].Value = step.Values[i]; } } break; //Кейс за оцветяване на числата case "Highlight": for (int i = 0; i < ctrl.List.VisualElements.Count; i++) { if (step.HighlightenedBlockIndexes.Contains(i)) { //Eлемента който е селектиран остава червен ctrl.List.VisualElements[i].Block.BackColor = Color.Red; } else { //Елементите които не са селектирани остават оранжеви; ctrl.List.VisualElements[i].Block.BackColor = Color.Orange; } } break; //Размества двете стоийности които са избрани спрямо тяхната позиция case "Swap": SortingElement aux = ctrl.List.VisualElements[step.Swit.Item1]; ctrl.List.VisualElements[step.Swit.Item1] = ctrl.List.VisualElements[step.Swit.Item2]; ctrl.List.VisualElements[step.Swit.Item2] = aux; Point auxLoc = ctrl.List.VisualElements[step.Swit.Item1].Location; ctrl.List.VisualElements[step.Swit.Item1].Location = ctrl.List.VisualElements[step.Swit.Item2].Location; ctrl.List.VisualElements[step.Swit.Item2].Location = auxLoc; break; case "IHighlight": for (int i = 0; i < ctrl.List.IntegerElements.Count; i++) { if (step.HighlightenedLabelIndexes.Contains(i)) { //Оцветява на коя позиция мести число ctrl.attachmentList[i].Attachment.ForeColor = Color.Red; } else { //всички останали позиции са в черно ctrl.attachmentList[i].Attachment.ForeColor = Color.Black; } } break; //оцветява елемента позиция 'poz' в червено когато се използва case "AEHighlight": for (int i = 0; i < step.AttachNames.Count; i++) { int index = ctrl.attachmentList.getIndexByName(step.AttachNames[i]); if (index != -1) { ctrl.attachmentList[index].Attachment.ForeColor = Color.Red; } } break; //Оцветява отново елемента 'poz'в черно когато се премине на следващия елемент case "!AEHighlight": for (int i = 0; i < step.AttachNames.Count; i++) { int index = ctrl.attachmentList.getIndexByName(step.AttachNames[i]); if (index != -1) { ctrl.attachmentList[index].Attachment.ForeColor = Color.Black; } } break; //Кейс за пренаписване на стойностите на блокчетата от стойности, Разменя стойностите на swit item1 и swit item2 case "BlockOverwrite": ctrl.List.VisualElements[step.Swit.Item1].ChangeValue(step.Swit.Item2); break; case "THighlight": for (int i = 0; i < variableDataGridView.Rows.Count; i++) { if (step.HighlightedTableIndexes.Contains(i)) { //Вдига флаг selected на редовете variableDataGridView.Rows[i].Selected = true; } } break; //Изчиства DataGridView case "THClear": variableDataGridView.ClearSelection(); break; } } }