Example #1
0
        /// <summary>
        /// Search users - Find users by keyword.
        /// 
        /// /legacy/user/search/:keyword
        /// </summary>
        /// <param name="keyword">Keyword search parameters</param>
        /// <param name="startPage">Optional Page number to fetch</param>
        /// <param name="sort">Optional Sort field. One of followers, joined, 
        /// or repositories. If not provided, results are sorted by best 
        /// match.</param>
        /// <param name="order">Optional Sort order if sort param is provided. One of asc or desc.</param>
        /// <returns></returns>
        async public Task<User.UserSearchResults> Users(string keyword,
            int? startPage = null,
            UserSorts? sort = null,
            SortOrders? order = null)
        {
            var request = CreateRequest("/legacy/user/search/" + Uri.EscapeDataString(keyword));

            var response = await Complete<User.UserSearchResults>(request);

            return response.Result;
        }
Example #2
0
        public DEMSurveysGroup(TreeNodeCollection parentNodes, IContainer container)
            : base(parentNodes, "DEM Surveys", "DEM Survey", "DEM Surveys", ProjectManager.Project.SurveysFolder, container, ProjectManager.Project.DEMSurveys.Count > 0)
        {
            ToolStripMenuItem tsmiSort = new ToolStripMenuItem("Sort DEM Surveys");

            tsmiSort.DropDownItems.Add(new ToolStripMenuItem("Sort Alphabetical Ascending", Properties.Resources.alphabetical, OnSort));
            tsmiSort.DropDownItems.Add(new ToolStripMenuItem("Sort Alphabetical Descending", Properties.Resources.alpha_descending, OnSort));
            tsmiSort.DropDownItems.Add(new ToolStripMenuItem("Sort Chronological Ascending", Properties.Resources.chrono_ascending, OnSort));
            tsmiSort.DropDownItems.Add(new ToolStripMenuItem("Sort Chronological Descending", Properties.Resources.chrono_descending, OnSort));
            ContextMenuStrip.Items.Insert(ContextMenuStrip.Items.Count - 2, tsmiSort);

            // Default is ascending alphabetical
            SortOrder = SortOrders.AlphaAsc;

            LoadChildNodes();
        }
        /// <summary>
        /// Encodes a number between 0-63 into a char.
        /// </summary>
        /// <param name="number">input number</param>
        /// <param name="order">determines type of order (ordinal or lexicographic). Default uses ordinal which is used by Azure</param>
        /// <returns>a char representing the order-preserving encoding of input number</returns>
        public static char Encode(byte number, SortOrders order = SortOrders.Ordinal)
        {
            // Error check
            if (number > 63)
            {
                throw new ArgumentException(string.Format("The number {0} cannot be represented in 6 bits only. ", number));
            }

            char[] charsInOrder = CharsInOrdinalOrder;

            if (order == SortOrders.Lexicographic)
            {
                charsInOrder = CharsInLexicographicOrder;
            }

            return(charsInOrder[number]);
        }
Example #4
0
        /// <summary>
        /// Search repositories - Find repositories by keyword. Note, this 
        /// legacy method does not follow the v3 pagination pattern. This 
        /// method returns up to 100 results per page and pages can be fetched 
        /// using the startPage parameter.
        /// 
        /// /legacy/repos/search/:keyword
        /// </summary>
        /// <param name="keyword">Search term</param>
        /// <param name="language">Optional Filter results by language 
        /// (https://github.com/languages)</param>
        /// <param name="startPage">Optional Page number to fetch</param>
        /// <param name="sort">Optional Sort field. One of stars, forks, or 
        /// updated. If not provided, results are sorted by best match.</param>
        /// <param name="order">Optional Sort order if sort param is provided. 
        /// One of asc or desc.</param>
        /// <returns>A Repository.RepositorySearchResults with the matching Repositories.</returns>
        async public Task<Repository.RepositorySearchResults> Repositories(string keyword,
            string language = null,
            int startPage = 0,
            RepositorySorts? sort = null,
            SortOrders? order = null)
        {
            var request = CreateRequest("/legacy/repos/search/" + Uri.EscapeDataString(keyword),
                new Dictionary<string, string>
                    {
                        {"language", language},
                        {"start_page", startPage.ToString(CultureInfo.InvariantCulture)},
                        {"sort", sort.ToParameterValue()},
                        {"order", order.ToParameterValue()}
                    });

            var response = await Complete<Repository.RepositorySearchResults>(request);

            return response.Result;
        }
        /// <summary>
        /// Decodes a char into a six-bit byte (i.e., the byte is between 0 and 63)
        /// </summary>
        /// <param name="encodedChar">the input char</param>
        /// <param name="order">determines type of order (ordinal or lexicographic). Default uses ordinal which is used by Azure</param>
        /// <returns>a byte represending the order-preserving decoding of input char</returns>
        public static byte Decode(char encodedChar, SortOrders order = SortOrders.Ordinal)
        {
            char[] charsInOrder = CharsInOrdinalOrder;

            if (order == SortOrders.Lexicographic)
            {
                charsInOrder = CharsInLexicographicOrder;
            }

            // Find index of current character in the order array
            int index = Array.IndexOf(charsInOrder, encodedChar);

            if (index < 0)
            {
                throw new ArgumentException(string.Format("The encoding \'{0}\' contains invalid bytes. Can't decode.", encodedChar));
            }

            return((byte)index);
        }
        /// <summary>
        /// Encodes a ulong into a fixed-size char array of length 11.
        /// </summary>
        /// <param name="number">input number</param>
        /// <param name="order">determines type of order (ordinal or lexicographic). Default uses ordinal which is used by Azure</param>
        /// <returns>an array of 11 chars representing the order-preserving encoding of input number</returns>
        public static char[] Encode(ulong number, SortOrders order = SortOrders.Ordinal)
        {
            char[] result       = new char[11];
            char[] charsInOrder = CharsInOrdinalOrder;

            if (order == SortOrders.Lexicographic)
            {
                charsInOrder = CharsInLexicographicOrder;
            }

            // Go from LSB to MSB six-bits at a time
            for (int i = 10; i >= 0; i -= 1)
            {
                result[i] = Encode((byte)(number % 64), order);
                number  >>= 6;
            }

            return(result);
        }
Example #7
0
        private void UpdateFromString(string str)
        {
            // force lowercase
            str = str.ToLower();
            Match match = ParametersRegex.Match(str);

            if (match.Success)
            {
                string strCapValue  = match.Groups[1].Value;
                string strField     = match.Groups[2].Value;
                string strSortOrder = match.Groups[3].Value;

                this.CapValue    = Int32.Parse(strCapValue);
                this.FilterField = CapFilterFieldsMap[strField];
                this.SortOrder   = SortOrdersMap[strSortOrder];
            }
            else
            {
                throw new ArgumentException("Input string is invalid.");
            }
        }
Example #8
0
        public void TestSearchSingleOrderField(string fieldName, string condition)
        {
            Dictionary <string, Type> sortOrders = new Dictionary <string, Type>();
            string idField = "Id";

            Dictionary <string, object> urlParameters = new Dictionary <string, object>()
            {
                { PhaseApiFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { PhaseApiFields.Resource, (int)defaultResource },
            };

            //List of sort order class { <field, sortType, Type>, <field, sortType, Type>,... }
            //This is single order
            List <SortOrders> sortOrderFieldList = new List <SortOrders>()
            {
                { new SortOrders(fieldName, condition, SearchTestData.phaseFieldList[fieldName]) }
            };

            SortOrders parameterSortOrder = PhaseHelper.GetParameterSortOrders(sortOrderFieldList, idField, condition);

            urlParameters[PhaseApiFields.Order] = parameterSortOrder.Condition;
            urlParameters[PhaseApiFields.Field] = parameterSortOrder.Field;
            sortOrders = parameterSortOrder.SortOrderTypes;

            //Sort
            if (condition == DateTimeValidator.OrderEmpty)
            {
                ReadOrderFailed(defaultResource, urlParameters);
            }
            else
            {
                List <XmlResource> result      = ReadPhaseResource(urlParameters);
                List <XmlResource> sortedItems = ResourceHelper.SortList(result, sortOrders);
                Assert.IsTrue(ResourceHelper.CompareList(result, sortedItems, idField), Enums.Message.SORT_INCORRECT);
            }
        }
        protected void FillSearchCriterias()
        {
            StartTime     = EndTime = null;
            SortAscending = false;
            SearchStatus  = string.Empty;
            SortOrders.Clear();
            Payments.Clear();

            foreach (PaymentCriteria test in Enum.GetValues(typeof(PaymentCriteria)))
            {
                var item = new CheckListItem <PaymentCriteria>(EnumLocalizer.Default.Translate(test), test);
                Payments.Add(item);
            }

            foreach (ProductsSortOrder test in Enum.GetValues(typeof(ProductsSortOrder)))
            {
                var item = new CheckListItem <ProductsSortOrder>(EnumLocalizer.Default.Translate(test), test);
                SortOrders.Add(item);
            }


            SelectedPayment   = PaymentCriteria.Any;
            SelectedSortOrder = ProductsSortOrder.ByDate;
        }
Example #10
0
 public void SortByDateCreated()
 {
     Tasks     = Tasks.OrderBy(x => x.DateCreated).ToList();
     SortOrder = SortOrders.DateCreated;
 }
Example #11
0
 public static string SortOrdersToString(SortOrders sort)
 {
   return sort == SortOrders.Ascending ? "asc" : "desc";
 }
Example #12
0
 public void SortByPriority()
 {
     Tasks     = Tasks.OrderByDescending(x => x.Priority).ToList();
     SortOrder = SortOrders.Priority;
 }
Example #13
0
 public void SortByDueDate()
 {
     Tasks     = Tasks.OrderBy(x => x.DueDate).ToList();
     SortOrder = SortOrders.DueDate;
 }
Example #14
0
 public void SortByAlphabetical()
 {
     Tasks     = Tasks.OrderBy(x => x.Message).ToList();
     SortOrder = SortOrders.Alphabetical;
 }
        private static void CreateStrategies()
        {
            //sort orderr groups
            var useSortOrderGroups = new UseSortOrderGroups[] { UseSortOrderGroups.Use, UseSortOrderGroups.DoNotUse };

            //sort orders
            var sortOrders = new SortOrders[] { SortOrders.HighestRateFirst, SortOrders.LowestBalanceFirst };

            //extra per month calc methods
            var extraPerMonthCalcMethods = new ExtraPerMonthCalcMethods[] { ExtraPerMonthCalcMethods.Contant, ExtraPerMonthCalcMethods.MinPaymentPlusExtra };

            //months/years of delay
            var       maxTerm   = Loans.Select(l => l.TermInMonths).Max(); //max of the base strat loan terms
            const int monthStep = 12;
            var       m         = 0;

            IList <int> monthsDelay = new List <int>();

            do
            {
                monthsDelay.Add(m * monthStep);
                m++;
            } while (m * monthStep < maxTerm);

            //extra payment amounts per month
            const int amountStep     = 100;
            const int numAmountSteps = 20;

            IList <int> extraAmounts = new List <int>();

            for (int a = 1; a <= numAmountSteps; a++)
            {
                extraAmounts.Add(a * amountStep);
            }

            //create the "special" base strategy
            int id = 1;

            Strategies = new List <Strategy>
            {
                new Strategy()
                {
                    StrategyId              = id,
                    ExtraPerMonth           = 0,
                    SortOrder               = SortOrders.NotApplicable,
                    StrategyName            = "Base",
                    MonthsDelay             = 0,
                    ExtraPerMonthCalcMethod = ExtraPerMonthCalcMethods.NotApplicable,
                    UseSortOrderGroup       = UseSortOrderGroups.NotApplicable,
                }
            };

            //create the rest of the strategies
            foreach (UseSortOrderGroups useSortOrderGroup in useSortOrderGroups)
            {
                foreach (ExtraPerMonthCalcMethods extraPerMonthCalcMethod in extraPerMonthCalcMethods)
                {
                    foreach (SortOrders sortOrder in sortOrders)
                    {
                        foreach (var extraAmount in extraAmounts)
                        {
                            foreach (var monthDelay in monthsDelay)
                            {
                                id++;
                                Strategies.Add(new Strategy
                                {
                                    StrategyId              = id,
                                    ExtraPerMonth           = extraAmount,
                                    SortOrder               = sortOrder,
                                    StrategyName            = $"{useSortOrderGroup} {extraPerMonthCalcMethod} {sortOrder} {extraAmount} {monthDelay}",
                                    MonthsDelay             = monthDelay,
                                    ExtraPerMonthCalcMethod = extraPerMonthCalcMethod,
                                    UseSortOrderGroup       = useSortOrderGroup,
                                });
                            }
                        }
                    }
                }
            }
        }
Example #16
0
        protected sealed override string OnParseSelect()
        {
            var builder = new StringBuilder("Select ");

            if (Top != null)
            {
                builder.AppendFormat("Top {0} ", Top.Value);
            }
            if (Columns.Count == 0)
            {
                builder.AppendLine("*");
            }
            else
            {
                using (var e = Columns.GetEnumerator())
                {
                    e.MoveNext();
                    var visitor = new MsSqlExpressionVisitor();
                    e.Current.Accept(visitor);
                    builder.AppendFormat("{0}", visitor.Complier()).AppendLine();
                    while (e.MoveNext())
                    {
                        visitor.Reset();
                        e.Current.Accept(visitor);

                        builder.AppendFormat(", {0}", visitor.Complier()).AppendLine();
                    }
                }
            }
            builder.AppendFormat("From {0}", MsSqlHelper.FormatSymbolName(Name));
            if (Condition != null)
            {
                builder.AppendLine();
                builder.Append("Where ");

                var visitor = new MsSqlExpressionVisitor();
                var expre   = MsSqlExpressionVisitor.LogicExpression(Condition);
                expre.Accept(visitor);
                builder.Append(visitor.Complier());
            }
            if (Groups != null)
            {
                builder.AppendLine();
                builder.AppendFormat("Group By {0}", string.Join(", ", Groups.Select(p => string.Format("[{0}]", p.Name))));
            }
            if (SortOrders != null)
            {
                using (var e = SortOrders.GetEnumerator())
                {
                    if (e.MoveNext())
                    {
                        builder.AppendLine();
                        builder.AppendFormat("Order By [{0}] {1}", e.Current.Member.Name, e.Current.Ascending ? "Asc" : "Desc");
                        while (e.MoveNext())
                        {
                            builder.Append(", ");
                            builder.AppendFormat("[{0}] {1}", e.Current.Member.Name, e.Current.Ascending ? "Asc" : "Desc");
                        }
                    }
                }
            }
            if (RowOffset != null)
            {
                //offset 5*2 rows fetch next 5 rows only
                builder.AppendLine();
                builder.Append("Offset ").Append(RowOffset.Offset).Append(" Rows Fetch Next ").Append(RowOffset.Count).Append(" Rows Only");
            }
            return(builder.ToString());
        }
Example #17
0
 public ImageSearchQuery Sort(string sortOrder)
 {
     SortOrders.Add(sortOrder);
     return(this);
 }
Example #18
0
 /// <summary>
 ///     从服务器读取XML或JSON数据时初始的排序类型
 /// </summary>
 /// <param name="sortOrderType">排序类型</param>
 /// <returns></returns>
 public GridGenerator <T> SortOrder(SortOrders sortOrderType = SortOrders.Desc)
 {
     GridConfiguration.Sortorder = sortOrderType.ToString().ToLower();
     return(this);
 }
Example #19
0
 // constructor
 public ObjectSortField(string sortExpression, SortOrders sortOrder)
 {
     this.sortExpression = sortExpression;
     this.sortOrder      = sortOrder;
 }
Example #20
0
        /// <summary>
        /// 生成报表数据
        /// </summary>
        /// <returns></returns>
        private DataTable CreateData(string strFacilityIDs, DateTime dFrom, DateTime dTo, string code, string pattern, bool showByPlan, SortOrders sortOrder)
        {
            #region get data

            Filter filter1 = new Filter();
            filter1.Add("StartTime", dTo.Date.AddDays(1), RELEATTION_TYPE.LESSEQUAL, LOGIC_TYPE.AND);
            filter1.Add("EndTime", dFrom.Date, RELEATTION_TYPE.GREATEREQUAL, LOGIC_TYPE.AND);

            //拿取指定的生产线
            //string strFacilityIDs = this.GetFacilityID();
            List <Facility> lstFacility = AMO.BLL.Facility.GetList(strFacilityIDs);

            //ProductionEvent
            Filter filter = new Filter();
            filter.Add("FacilityID", strFacilityIDs, RELEATTION_TYPE.IN, LOGIC_TYPE.AND);
            filter.Add(filter1, LOGIC_TYPE.AND);


            List <ProductionEvent> lstProductionEvent = ProductionEvent.GetList(filter);
            DicProdEvent = lstProductionEvent.ToDictionary(x => x.ID);

            ////拿取指定时间段内指定生产线的生产计划
            string ProductionEventIDSql = DBHelper.GetDistinctSql("ProductionEvent", "ID", filter);

            //ProductionEventDetail
            filter = new Filter();
            filter.Add("ProductionEventID", ProductionEventIDSql, RELEATTION_TYPE.IN, LOGIC_TYPE.AND);
            List <ProductionEventDetail> lstProductionEventDetail = ProductionEventDetail.GetList(filter);
            DicProdEventDetails = new Dictionary <int, List <ProductionEventDetail> >();
            var gsPED = lstProductionEventDetail.GroupBy(x => x.ProductionEventID);
            foreach (var g in gsPED)
            {
                DicProdEventDetails.Add(g.Key, g.ToList());
            }

            //PO
            string distPOIDSql = DBHelper.GetDistinctSql("ProductionEventDetail", "POID", filter);

            //增加生产单&&款号过滤
            if (!string.IsNullOrEmpty(code))
            {
                if (code.Length >= AMOData.Settings.SysSetting.PoCodeLength)
                {
                    distPOIDSql += string.Format(@" and code = '{0}' ", code);
                }
                else
                {
                    distPOIDSql += string.Format(@" and code like '%{0}%' ", code);
                }
            }
            if (!string.IsNullOrEmpty(pattern))
            {
                if (pattern.Length >= AMOData.Settings.SysSetting.PatternLength)
                {
                    distPOIDSql += string.Format(@" and PATTERN ='{0}' ", pattern);
                }
                else
                {
                    distPOIDSql += string.Format(@" and PATTERN like '%{0}%' ", pattern);
                }
            }

            filter = new Filter();

            filter.Add("ID", distPOIDSql, RELEATTION_TYPE.IN, LOGIC_TYPE.AND);

            DicPO = PO.GetDictionary(filter);

            //ProductionSchedule
            Filter filterProcess = new Filter();
            filterProcess.Add("IsPrimary", 1, RELEATTION_TYPE.EQUAL, LOGIC_TYPE.AND);
            string distProcessSQL = DBHelper.GetDistinctSql("Process", "ID", filterProcess);

            Filter filterPS = new Filter();
            filterPS.Add("ProductionDate", dFrom.Date, RELEATTION_TYPE.GREATEREQUAL, LOGIC_TYPE.AND);
            filterPS.Add("ProductionDate", dTo.Date, RELEATTION_TYPE.LESSEQUAL, LOGIC_TYPE.AND);
            filterPS.Add("ProcessID", distProcessSQL, RELEATTION_TYPE.IN, LOGIC_TYPE.AND);
            List <AMOData.ProductionSchedule> lstProdSchedule = ProductionSchedule.GetList(filterPS);
            //var qPS = from g in lstProdSchedule
            //          group g by g.POID;

            //生产线的动态人数
            Filter dyFilter = new Filter();
            dyFilter.Add("FacilityID", strFacilityIDs, RELEATTION_TYPE.IN, LOGIC_TYPE.AND);
            var lstDyWrorkers = FacilityWorkerNumber.GetList(dyFilter);
            if (lstDyWrorkers.Count > 0)
            {
                lstDyWrorkers = lstDyWrorkers.OrderByDescending(x => x.BeginDate).ToList();//开始日期大到小排序
            }
            DicFacilityWorkerNumber = new Dictionary <int, List <FacilityWorkerNumber> >();
            var gs = lstDyWrorkers.GroupBy(x => x.FacilityID).ToList();
            foreach (var g in gs)
            {
                DicFacilityWorkerNumber[g.Key] = g.ToList();
            }
            //
            #endregion

            #region create data structure

            lstActualAmount.Clear();

            List <DailyProdAmount> lstPlanAmount = new List <DailyProdAmount>();

            List <LineRate> lstLineRate = new List <LineRate>();

            //结果表
            DataTable dtResult = new DataTable();
            dtResult.Columns.Add("SpecLineID", typeof(int));//生产线ID
            foreach (ReportSetting rptSet in LstReportSetting)
            {
                //switch (rptSet.DataType.ToLower())
                //{
                //    case "int":
                //        dtResult.Columns.Add(rptSet.HeaderText, typeof(int));
                //        break;
                //    case "datetime":
                //        dtResult.Columns.Add(rptSet.HeaderText, typeof(DateTime));
                //        break;
                //    case "string":
                //    default:
                dtResult.Columns.Add(rptSet.HeaderText);
                //        break;
                //}
            }

            dtResult.Columns.Add("SpecCol", typeof(string));//特殊列

            DateTime dayDate = dFrom.Date;
            while (dayDate <= dTo.Date)
            {
                DataColumn dc = new DataColumn(dayDate.ToString("MM-dd"), typeof(string));
                dc.DefaultValue = 0;
                dtResult.Columns.Add(dc);
                dayDate = dayDate.AddDays(1);
            }

            DataColumn dcRowSum = new DataColumn("RowSum", typeof(string));
            dcRowSum.DefaultValue = 0;
            dtResult.Columns.Add(dcRowSum);//行 sum 列

            DataColumn dcRowSpan = new DataColumn("RowSpan", typeof(int));
            dcRowSpan.DefaultValue = 1;
            dtResult.Columns.Add(dcRowSpan);

            #endregion

            #region put data to lstPlanAmount

            Simulation oSimulation = new Simulation(true);
            oSimulation.LoadSettings();
            oSimulation.LoadFacility(true);
            oSimulation.LoadCalendar(false, true);
            oSimulation.LoadLnCurveData();
            //外发不排产需过滤外发线
            if (!AMOData.Settings.ImpSetting.IsOutsourcedScheduling)
            {
                lstFacility = lstFacility.Where(m => m.IsSubCon == false).ToList();
            }
            //join lstProductionEvent & lstFacility
            var query = (from xEvent in lstProductionEvent
                         join xFacility in lstFacility
                         on xEvent.FacilityID equals xFacility.ID
                         orderby xFacility.Name, xEvent.StartTime
                         select new { xEvent, xFacility }).ToList(); //

            foreach (var obj in query)                               //遍历每条生产线上每个计划
            {
                VirtualProdEvent vProdEvent = new VirtualProdEvent(obj.xEvent, oSimulation.DateNow);
                List <int>       lstPOIDs   = null;
                if (DicProdEventDetails.ContainsKey(obj.xEvent.ID))
                {
                    List <ProductionEventDetail> queryDetail = DicProdEventDetails[obj.xEvent.ID];
                    foreach (ProductionEventDetail detail in queryDetail)
                    {
                        VirtualProdEventDetail vDetail = new VirtualProdEventDetail(detail, string.Empty, string.Empty, string.Empty);
                        vProdEvent.AddDetail(vDetail);
                    }
                    lstPOIDs = queryDetail.Select(x => x.POID).Distinct().ToList();
                }

                if (lstPOIDs == null)
                {
                    lstPOIDs = new List <int>();
                }

                //学习曲线
                LnCurveApply oLnCurveApply = oSimulation.LearningCurve.GetInLncApply(vProdEvent);
                if (oLnCurveApply != null)
                {
                    vProdEvent.LncApplyID    = oLnCurveApply.ID;
                    vProdEvent.LncTemplateID = oLnCurveApply.LnCurveTemplateID;
                }

                foreach (int pid in lstPOIDs)
                {
                    if (DicPO.ContainsKey(pid))
                    {
                        // double poqty = vProdEvent.AllDetails.Where(p => p.POID == pid).Sum(p => p.PlanAmount);//PO排单总数
                        //
                        Dictionary <DateTime, int> dicAmount = vProdEvent.CalculateCanFinishedQty(oSimulation, true, -1, pid);//计算某个计划每天应该完成的数量
                        dayDate = dFrom.Date;
                        while (dayDate <= dTo.Date)
                        {
                            int amount = 0;
                            if (dicAmount.ContainsKey(dayDate.Date))
                            {
                                amount = dicAmount[dayDate.Date];
                            }

                            DailyProdAmount pAmount = new DailyProdAmount();
                            pAmount.LineID      = obj.xFacility.ID;
                            pAmount.ProdEventID = obj.xEvent.ID;
                            pAmount.POID        = pid;    //po.ID;
                            pAmount.ProdDate    = dayDate;
                            pAmount.Amount      = amount; // (poqty == vpqty ? amount : (int)Math.Round(amount * poqty / vpqty, 0));//考虑合单情况
                            lstPlanAmount.Add(pAmount);

                            dayDate = dayDate.AddDays(1);
                        }
                    }
                }
            }

            #endregion

            #region put data to lstActualAmount

            //join lstProdSchedule ,lstProductionEvent, lstFacility
            var query2 = (from xPS in lstProdSchedule
                          join xProdEv in lstProductionEvent on xPS.ProductionEventID equals xProdEv.ID
                          join xFacility in lstFacility on xProdEv.FacilityID equals xFacility.ID
                          orderby xFacility.ID
                          select new { xPS, xFacility }).ToList(); //

            foreach (var obj in query2)                            //遍历每条生产线上每个计划 实际产量
            {
                DailyProdAmount aAmount = new DailyProdAmount();
                aAmount.LineID      = obj.xFacility.ID;
                aAmount.ProdEventID = obj.xPS.ProductionEventID;
                aAmount.POID        = obj.xPS.POID;
                aAmount.ProdDate    = obj.xPS.ProductionDate;
                if (obj.xPS.Amount == 0)
                {
                    aAmount.HasZeroAmount = true;
                }
                if (!DicPO.Keys.Contains(aAmount.POID))
                {
                    continue;
                }
                aAmount.PoCode = DicPO[aAmount.POID].Code;
                aAmount.Amount = Convert.ToInt32(obj.xPS.Amount);//Ben 等于0时表示有进度,但数量为0

                lstActualAmount.Add(aAmount);
            }
            #endregion

            #region put data to lstLineRate
            var        lineIDs            = lstPlanAmount.Select(p => p.LineID).Distinct();
            List <int> prodtingFaciltyids = DicProdEvent.Values.Select(x => x.FacilityID).Distinct().ToList();
            foreach (int lineid in lineIDs)
            {
                if (!prodtingFaciltyids.Contains(lineid))
                {
                    continue;
                }
                int pAmount = lstPlanAmount.Where(p => p.LineID == lineid).ToList().Sum(p => p.Amount);
                if (pAmount > 0)
                {
                    int      aAmount = lstActualAmount.Where(p => p.LineID == lineid).ToList().Sum(p => p.Amount);
                    LineRate lr      = new LineRate();
                    lr.LineID       = lineid;
                    lr.CompleteRate = Math.Round(((double)aAmount / pAmount), 3);
                    Facility facility = lstFacility.First(m => m.ID == lineid);
                    lr.FacilityName = facility.Name;
                    lr.GroupName    = facility.GroupName;
                    lstLineRate.Add(lr);
                }
            }
            if (sortOrder == SortOrders.ByRanking)
            {
                lstLineRate = lstLineRate.OrderByDescending(p => p.CompleteRate).ToList();
            }
            else
            {//生产线,排序顺序同排产器
                lstLineRate = lstLineRate.OrderBy(p => p.GroupName).ThenBy(m => m.FacilityName).ToList();
            }

            #endregion

            #region put data to dtResult

            DataRow drTempTotalPlan = dtResult.NewRow();          //最后一行(总计行)
            DataRow drTempTotalActual = dtResult.NewRow();
            int     tempRowTotalPlan = 0, tempRowTotalActual = 0; //总计列累计
            int     mc = 0;                                       //名次

            #region insert 数据行&小计行
            foreach (LineRate lr in lstLineRate)//按完成率倒序
            {
                Facility oFacility = lstFacility.Find(f => f.ID == lr.LineID);
                if (oFacility == null)
                {
                    continue;
                }
                int lineid = lr.LineID;

                #region insert 生产线分组行
                DataRow drLine = dtResult.NewRow();
                drLine["SpecLineID"] = -1;

                string strSpecialCol = string.Empty;
                string leader        = string.Empty;
                if (string.IsNullOrEmpty(oFacility.Leader) == false)
                {
                    leader = string.Format(",{0}", oFacility.Leader);
                }
                //if (sortOrder == SortOrders.ByRanking)
                //{

                //    strSpecialCol = string.Format("{0} {1} ( {2}: {3} )", oFacility.Name, leader, CText.TextOrderName, ++mc);
                //}
                //else
                //{
                strSpecialCol = string.Format("{0} {1} ", oFacility.Name, leader);
                //}
                //增加code&pattern过滤条件的显示
                if (!string.IsNullOrEmpty(code.Trim()))
                {
                    strSpecialCol += " , " + code;
                }
                if (!string.IsNullOrEmpty(pattern.Trim()))
                {
                    strSpecialCol += " , " + pattern;
                }

                drLine["SpecCol"] = strSpecialCol;
                dtResult.Rows.Add(drLine);//insert facility summary row
                #endregion

                #region insert 数据行

                //生产线最后一行(小计行)
                DataRow drTempPlanSum = dtResult.NewRow();
                DataRow drTempActualSum = dtResult.NewRow();
                int     tempRowSumPlan = 0, tempRowSumActual = 0;//小计列累计

                var linePlanIDs = lstPlanAmount.Where(p => p.LineID == lineid).ToList().Select(p => p.ProdEventID).Distinct();
                foreach (int peid in linePlanIDs)//循环产线上的每一个计划
                {
                    if (!showByPlan)
                    {
                        SetContentRow(dtResult, peid, lineid, lstPlanAmount, oFacility, dFrom, dTo,
                                      ref tempRowSumPlan, ref tempRowSumActual, ref tempRowTotalPlan, ref tempRowTotalActual,
                                      drTempPlanSum, drTempActualSum, drTempTotalPlan, drTempTotalActual);
                    }
                    else
                    {
                        SetContentRow22(dtResult, peid, lineid, lstPlanAmount, oFacility, dFrom, dTo,
                                        ref tempRowSumPlan, ref tempRowSumActual, ref tempRowTotalPlan, ref tempRowTotalActual,
                                        drTempPlanSum, drTempActualSum, drTempTotalPlan, drTempTotalActual);
                    }
                }//end foreach plans

                #endregion

                #region insert 小计行
                DataRow drLineTotal = dtResult.NewRow();
                drLineTotal["SpecLineID"] = -2;
                drLineTotal["SpecCol"]    = "目标达成(小计)";// "目标达成(小计)";

                dayDate = dFrom.Date;
                while (dayDate <= dTo.Date)
                {
                    string colName       = dayDate.ToString("MM-dd");
                    int    planAmountSum = Convert.ToInt32(drTempPlanSum[colName]);
                    if (planAmountSum == 0)
                    {
                        drLineTotal[colName] = "";
                    }
                    else
                    {
                        drLineTotal[colName] = (Convert.ToDouble(drTempActualSum[colName]) / planAmountSum).ToString("p1");
                    }
                    dayDate = dayDate.AddDays(1);
                }

                if (tempRowSumPlan == 0)
                {
                    drLineTotal["RowSum"] = "";
                }
                else
                {
                    drLineTotal["RowSum"] = (Convert.ToDouble(tempRowSumActual) / tempRowSumPlan).ToString("p1");
                }

                drTempActualSum = null;
                drTempPlanSum   = null;
                dtResult.Rows.Add(drLineTotal);//insert 小计行
                #endregion
            }
            #endregion

            #region insert 总计行
            if (dtResult.Rows.Count > 0)
            {
                DataRow drAllTotal = dtResult.NewRow();
                drAllTotal["SpecLineID"] = -3;
                drAllTotal["SpecCol"]    = "目标达成(总计)";// "目标达成(总计)";

                dayDate = dFrom.Date;
                while (dayDate <= dTo.Date)
                {
                    string colName         = dayDate.ToString("MM-dd");
                    int    planAmountTotal = Convert.ToInt32(drTempTotalPlan[colName]);
                    if (planAmountTotal == 0)
                    {
                        drAllTotal[colName] = "";
                    }
                    else
                    {
                        drAllTotal[colName] = (Convert.ToDouble(drTempTotalActual[colName]) / planAmountTotal).ToString("p1");
                    }
                    dayDate = dayDate.AddDays(1);
                }

                if (tempRowTotalPlan == 0)
                {
                    drAllTotal["RowSum"] = "";
                }
                else
                {
                    drAllTotal["RowSum"] = (Convert.ToDouble(tempRowTotalActual) / tempRowTotalPlan).ToString("p1");
                }

                drTempTotalActual = null;
                drTempTotalPlan   = null;
                dtResult.Rows.Add(drAllTotal);//insert 总计行

                #region 汇总所有数量

                DataRow drSumPlan = dtResult.NewRow();
                drSumPlan["SpecLineID"] = -1;
                drSumPlan["SpecCol"]    = "汇总计划产量 : " + tempRowTotalPlan; //汇总计划产量
                dtResult.Rows.Add(drSumPlan);                             //insert 汇总计划数量

                DataRow drSumActual = dtResult.NewRow();
                drSumActual["SpecLineID"] = -1;
                drSumActual["SpecCol"]    = "汇总实际产量 : " + tempRowTotalActual; //汇总实际产量
                dtResult.Rows.Add(drSumActual);                               //insert 汇总实际产量
                #endregion
            }
            #endregion

            #endregion

            return(dtResult);
        }
Example #21
0
        protected void FillSearchCriterias()
        {
            SortAscending = false;
            Countries.Clear();
            Groups.Clear();
            Genders.Clear();
            CalendarPrivacy.Clear();
            MeasurementPrivacy.Clear();
            Photos.Clear();
            Plans.Clear();
            SearchStatus = string.Empty;
            SortOrders.Clear();

            foreach (var test in Country.Countries)
            {
                CheckListItem <Country> item = new CheckListItem <Country>(test.DisplayName, test);
                Countries.Add(item);
            }

            foreach (UserSearchGroup test in Enum.GetValues(typeof(UserSearchGroup)))
            {
                var item = new CheckListItem <UserSearchGroup>(EnumLocalizer.Default.Translate(test), test);
                Groups.Add(item);
            }

            foreach (Gender test in Enum.GetValues(typeof(Gender)))
            {
                var item = new CheckListItem <Gender>(EnumLocalizer.Default.Translate(test), test);
                Genders.Add(item);
            }

            foreach (PrivacyCriteria test in Enum.GetValues(typeof(PrivacyCriteria)))
            {
                var item = new CheckListItem <PrivacyCriteria>(EnumLocalizer.Default.Translate(test), test);
                CalendarPrivacy.Add(item);
            }
            foreach (PrivacyCriteria test in Enum.GetValues(typeof(PrivacyCriteria)))
            {
                var item = new CheckListItem <PrivacyCriteria>(EnumLocalizer.Default.Translate(test), test);
                MeasurementPrivacy.Add(item);
            }

            foreach (UsersSortOrder test in Enum.GetValues(typeof(UsersSortOrder)))
            {
                var item = new CheckListItem <UsersSortOrder>(EnumLocalizer.Default.Translate(test), test);
                SortOrders.Add(item);
            }

            foreach (PictureCriteria test in Enum.GetValues(typeof(PictureCriteria)))
            {
                var item = new CheckListItem <PictureCriteria>(EnumLocalizer.Default.Translate(test), test);
                Photos.Add(item);
            }
            foreach (UserPlanCriteria test in Enum.GetValues(typeof(UserPlanCriteria)))
            {
                var item = new CheckListItem <UserPlanCriteria>(EnumLocalizer.Default.Translate(test), test);
                Plans.Add(item);
            }


            SelectedCalendarPrivacy    = PrivacyCriteria.All;
            SelectedMeasurementPrivacy = PrivacyCriteria.All;
            SelectedPhoto     = PictureCriteria.All;
            SelectedPlan      = UserPlanCriteria.All;
            SelectedSortOrder = UsersSortOrder.ByLastLoginDate;
        }
Example #22
0
        public static IQueryable <T> InvokeOrderBy <T>(this IQueryable <T> source, string propertyName, SortOrders order)
        {
            var piParametr = Expression.Parameter(typeof(T), "r");
            var property   = Expression.Property(piParametr, propertyName);
            var lambdaExpr = Expression.Lambda(property, piParametr);

            return((IQueryable <T>)Expression.Call(
                       typeof(Queryable),
                       order == SortOrders.ASC ? "OrderBy" : "OrderByDescending",
                       new Type[] { typeof(T), property.Type },
                       source.Expression,
                       lambdaExpr)
                   .Method.Invoke(null, new object[] { source, lambdaExpr }));
        }
Example #23
0
 public static string SortOrdersToString(SortOrders sort)
 {
     return(sort == SortOrders.Ascending ? "asc" : "desc");
 }
Example #24
0
        private static void SaveDealings(BridgeBelotEntities dbContext, List <List <Card> > cards, SortOrders sortOrder, int sequenceNo, int?shuffledSequenceNo)
        {
            var dbDealing = dbContext.DbDealings.Add(new DbDealing {
                SortOrder = (int)sortOrder, TimeStamp = DateTime.UtcNow
            });

            foreach (var playerDeck in cards)
            {
                foreach (var card in playerDeck)
                {
                    dbContext.DbCards.Add(new DbCard
                    {
                        DealingId          = dbDealing.Id,
                        Suit               = (int)card.Suit,
                        Side               = (int)card.Side,
                        Stage              = (int)card.Stage,
                        BeloteCard         = (int)card.BelotCard,
                        SequenceNo         = sequenceNo,
                        ShuffledSequenceNo = shuffledSequenceNo
                    });
                }
            }

            dbContext.SaveChanges();
        }
Example #25
0
        public static bool TryGet(this IEnumerable <KeyValuePair <string, string> > queryCollection, string name, out SortOrders order)
        {
            string orderStr;

            order = SortOrders.ASC;
            if (!queryCollection.TryGet(name, out orderStr))
            {
                return(false);
            }

            SortOrders result;

            if (Enum.TryParse(orderStr.ToUpperInvariant(), out result))
            {
                order = result;
                return(true);
            }

            return(false);
        }
Example #26
0
 /// <summary>
 /// Reorders the list according to the next item in the <see cref="TaskList"/>.<see cref="SortOrders"/>
 /// </summary>
 public void DoNextSortOrder()
 {
     SortOrder = SortOrder.NextItem();
     Sort();
 }