예제 #1
0
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var request = filterContext.HttpContext.Request;

            int count     = int.Parse(request.Form.Get("countDays"));
            var model     = (WeatherModel)((PartialViewResult)filterContext.Result).Model;
            var forecasts = new List <Forecast>();

            var log = new HistoryQuery()
            {
                Ip   = request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? request.UserHostAddress,
                City = model.City.Name,
                Date = DateTime.Now
            };

            UnitOfWork.HistoryRepository.Create(log);

            for (int i = 0; i < count; i++)
            {
                var forecast = new Forecast()
                {
                    Temperature        = model.List[i].Temp.Day,
                    Pressure           = model.List[i].Pressure,
                    Humidity           = model.List[i].Humidity,
                    Clouds             = model.List[i].Clouds,
                    SpeedWind          = model.List[i].Speed,
                    DescriptionWeather = model.List[i].Weather.FirstOrDefault().Description,
                    HistoryQueryId     = log.Id
                };
                UnitOfWork.ForecastRepository.Create(forecast);
            }
            UnitOfWork.Save();

            base.OnActionExecuted(filterContext);
        }
예제 #2
0
        public static bool _isMatch(History obj, HistoryQuery query)
        {
            if (!string.IsNullOrEmpty(query.IdEqual) && !string.Equals(obj.Id, query.IdEqual))
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(query.IdNotEqual) && string.Equals(obj.Id, query.IdNotEqual))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(query.UserIdEqual) && !string.Equals(obj.UserId, query.UserIdEqual))
            {
                return(false);
            }
            if (!string.IsNullOrEmpty(query.ContentLike) && !obj.Content.Contains(query.ContentLike))
            {
                return(false);
            }

            if ((null != query.MinCreationDate) && (obj.CreationDate < query.MinCreationDate))
            {
                return(false);
            }
            if ((null != query.MaxCreationDate) && (obj.CreationDate > query.MaxCreationDate))
            {
                return(false);
            }

            return(true);
        }
        public ActionResult HistorySearch(int pageSize, int pageIndex)
        {
            HistoryQuery            query       = HistoryQueryUtility.GetHistoryQuery(base.Request);
            int                     recordCount = 0;
            IList <VwWafer_History> list        = historyService.HistoryList(query, pageSize, pageIndex, out recordCount);

            if (list != null && list.Count > 0)
            {
                foreach (VwWafer_History history in list)
                {
                    if (history.IsVendor)
                    {
                        history.DisposeText = "Confirmed";
                    }
                    else
                    {
                        history.DisposeText = WaferHelper.WaferSelectionDes(history.Dispose);
                    }
                }
            }
            var json = JsonConvert.SerializeObject(new
            {
                currentPage = pageIndex,
                totalPages  = PagerUtility.GetPageCount(recordCount, pageSize),
                rows        = list,
            });

            base.Response.Write(json);
            return(null);
        }
예제 #4
0
        private async Task GetHistoryDataFromServerAndSave(int key, TimePeriod period, HistoryData loaded)
        {
            var query = new HistoryQuery
            {
                Begining  = period.Begining,
                End       = period.End,
                Parameter = new List <int> {
                    key
                },
            };

            var result = await server.Value.GetHistoricalData(query);

            lock (locker)
            {
                loaded.UpdateParameters(result.Parameters);
            }

            foreach (var v in result.Parameters)
            {
                foreach (var k in v.Value)
                {
                    history.Value.Values.Add(k);
                }
            }
        }
        public ActionResult ExportHistory()
        {
            string                  xlsName     = string.Format("History_{0}", DateTime.Now.ToString("yyyyMMdd_hhmmss"));
            HistoryQuery            query       = HistoryQueryUtility.GetHistoryQuery(base.Request);
            int                     recordCount = 0;
            IList <VwWafer_History> list        = historyService.HistoryList(query, 0xf423f, 0, out recordCount);

            if (list != null && list.Count > 0)
            {
                foreach (VwWafer_History history in list)
                {
                    if (history.IsVendor)
                    {
                        history.DisposeText = "Confirmed";
                    }
                    else
                    {
                        history.DisposeText = WaferHelper.WaferSelectionDes(history.Dispose);
                    }
                }
            }
            string        nextUrl     = Exporthelper.GetExport <VwWafer_History>("Historys", list, "/Export/Excels/History/", "/Content/Exports/ExportHistory.xml", xlsName, 0, 0);
            ResponseTypes redirect    = ResponseTypes.Redirect;
            TipTypes      information = TipTypes.Information;

            base.Response.Write(new HandlerResponse("0", "导出Excel文件", redirect.ToString(), information.ToString(), nextUrl, "", "").GenerateJsonResponse());
            return(null);
        }
예제 #6
0
        /// <summary>
        /// 显示导入的历史记录
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public HistoryImport GetResultImportList(HistoryQuery query)
        {
            var action = 0;

            if (query.ObjectId != null)
            {
                action = 1;
            }
            var dataResult = _import.GetResultImportList(query, action);

            try
            {
                dataResult.PageInfo.CuttrentPage = query.PaddingInfo.Page;
                dataResult.PageInfo.Pages        = dataResult.PageInfo.Total % query.PaddingInfo.PageSize == 0
                    ? dataResult.PageInfo.Total / query.PaddingInfo.PageSize
                    : dataResult.PageInfo.Total / query.PaddingInfo.PageSize + 1;
                dataResult.Success  = true;
                dataResult.ErrorMsg = string.Empty;
            }
            catch (Exception e)
            {
                dataResult.Success  = false;
                dataResult.ErrorMsg = e.Message;
            }
            return(dataResult);
        }
예제 #7
0
        public async Task <HistoryResponse> GetHistoricalData(HistoryQuery history)
        {
            NotifyFunctionCalled();

            await Task.Delay(100);

            var result = new HistoryResponse();

            DateTimeOffset localTime = DateTime.UtcNow;

            result.Parameters = new Dictionary <int, List <ValueInTime> >
            {
                { 34, new List <ValueInTime> {
                      new ValueInTime {
                          Time = localTime.ToUnixTimeSeconds() - 120, Value = 10
                      },
                      new ValueInTime {
                          Time = localTime.ToUnixTimeSeconds(), Value = 12
                      },
                  } },
                { 35, new List <ValueInTime> {
                      new ValueInTime {
                          Time = localTime.ToUnixTimeSeconds() - 60, Value = 14
                      },
                      new ValueInTime {
                          Time = localTime.ToUnixTimeSeconds(), Value = 20
                      },
                  } }
            };

            return(result);
        }
예제 #8
0
 private static dynamic _orderByKey(History obj, HistoryQuery query)
 {
     if (string.IsNullOrEmpty(query.OrderByKey))
     {
         return(obj.Id);
     }
     return(obj.GetType().GetProperty(query.OrderByKey).GetValue(obj));
 }
예제 #9
0
        public static int CountHistoryByQuery(HistoryQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new HistoryRepository(context);

                int count = repository.GetPageCount(item => _isMatch(item, query));
                return(count);
            }
        }
예제 #10
0
        public static History GetHistoryById(string id4query)
        {
            HistoryQuery query = new HistoryQuery()
            {
                IdEqual = id4query
            };
            History historyInDb = GetHistoryListByQuery(query).FirstOrDefault();

            return(historyInDb);
        }
예제 #11
0
        public static List <History> GetHistoryListByQuery(HistoryQuery query)
        {
            using (var context = new XiaoluEntities())
            {
                var repository = new HistoryRepository(context);

                List <History> historys = repository.GetPageList(item => _isMatch(item, query), item => _orderByKey(item, query), query.OrderByValue, query.Offset, query.Limit);
                return(historys);
            }
        }
예제 #12
0
        public IList <VwWafer_History> HistoryList(HistoryQuery query, int pageSize, int pageIndex, out int recordCount)
        {
            Conditions      condition       = GetConditions(query);
            OrderExpression orderExpression = null;

            if (!StringHelper.isEmptyString(query.OrderBy))
            {
                orderExpression = new OrderExpression(query.OrderBy, query.OrderDesc);
            }
            return(this.dbGateway.getRecords(pageIndex, pageSize, condition, orderExpression, null, Connector.AND, out recordCount));
        }
예제 #13
0
        public Task <HistoryCollection> PageHistory(HistoryQuery query)
        {
            var fileInfo = this.fileInfoProvider.GetFileInfo(query.FilePath, pathBase);

            var repoQuery = repo.Commits.QueryBy(fileInfo.DerivedFileName);
            var total     = repoQuery.Count();

            var items = repoQuery
                        .Skip(query.SkipTo(total)).Take(query.Limit)
                        .Select(i => new History(i.Commit));

            return(Task.FromResult(new HistoryCollection(query, total, items)));
        }
예제 #14
0
        public async Task <ActionResult <HistoryQueryResult> > GetAll([FromQuery] HistoryQuery query)
        {
            //https://stackoverflow.com/questions/748062/return-multiple-values-to-a-method-caller/36436255#36436255
            (List <ExchangeEntry> entries, int count) = await repository.GetEntriesAsync(query);

            var result = new HistoryQueryResult()
            {
                Entries = entries,
                Count   = count
            };

            return(Ok(result));
        }
예제 #15
0
        private Conditions GetConditions(HistoryQuery query)
        {
            Conditions condition = new Conditions();

            if (!StringHelper.isNullOrEmpty(query.ProductName))
            {
                condition.ConditionExpressions.Add(new Condition("ProductName", Operator.Like, query.ProductName));
            }
            if (!StringHelper.isNullOrEmpty(query.WaferCode))
            {
                condition.ConditionExpressions.Add(new Condition("WaferCode", Operator.Like, query.WaferCode));
            }
            if (!StringHelper.isNullOrEmpty(query.LotId))
            {
                condition.ConditionExpressions.Add(new Condition("LotId", Operator.Like, query.LotId));
            }
            if (!StringHelper.isNullOrEmpty(query.WaferID))
            {
                condition.ConditionExpressions.Add(new Condition("WaferID", Operator.Like, query.WaferID));
            }
            if (query.Dispose > 0)
            {
                if (query.Dispose == 111)
                {
                    condition.ConditionExpressions.Add(new Condition("IsVendor", Operator.EqualTo, true));
                }
                else
                {
                    condition.ConditionExpressions.Add(new Condition("Dispose", Operator.EqualTo, query.Dispose));
                }
            }
            if (!StringHelper.isNullOrEmpty(query.UserID))
            {
                condition.ConditionExpressions.Add(new Condition("UserID", Operator.Like, query.UserID));
            }
            if (!StringHelper.isNullOrEmpty(query.Comment))
            {
                condition.ConditionExpressions.Add(new Condition("Comment", Operator.Like, query.Comment));
            }
            if (!StringHelper.isNullOrEmpty(query.CreateTime))
            {
                string[] dateArray = query.CreateTime.Split('-');
                condition.ConditionExpressions.Add(new Condition("CreateTime", Operator.Between, dateArray[0], dateArray[1] + " 23:59:59"));
            }
            condition.Connector = Connector.AND;
            return(condition);
        }
예제 #16
0
        public HistoryImport GetResultImportList(HistoryQuery import, int action)
        {
            var result = new HistoryImport {
                HistoryItem = new List <ResultImport>(), PageInfo = new PageInfo()
            };
            var cmd      = new DataCommand("SearchImportData", new SqlCustomDbCommand());
            var whereStr = new StringBuilder();

            if (import.DeviceId == null || import.DeviceId == 0)
            {
                if (!string.IsNullOrEmpty(import.ObjectId.ToString()))
                {
                    whereStr.Append(string.Format(" and import.ObjectID={0}", import.ObjectId));
                }
            }
            else
            {
                whereStr.Append(string.Format(" and import.ObjectID={0}", import.DeviceId));
            }
            if (!string.IsNullOrEmpty(import.Starttime.ToString()))
            {
                whereStr.Append(string.Format(" and import.Starttime>='{0}'", import.Starttime));
            }
            if (!string.IsNullOrEmpty(import.Endtime.ToString()))
            {
                whereStr.Append(string.Format(" and import.Starttime<='{0}'", import.Endtime));
            }
            if (!string.IsNullOrEmpty(import.ItemCode))
            {
                whereStr.Append(string.Format(" and import.ItemCode='{0}'", import.ItemCode));
            }
            if (!string.IsNullOrEmpty(import.DateUnit.ToString(CultureInfo.InvariantCulture)))
            {
                whereStr.Append(string.Format(" and import.MonthType={0}", import.DateUnit));
            }
            cmd.SetParameterValue("@action", action);
            cmd.ReplaceParameterValue("#whereStr#", whereStr.ToString());
            cmd.ReplaceParameterValue("#pagesize#", import.PaddingInfo.PageSize.ToString(CultureInfo.InvariantCulture));
            cmd.ReplaceParameterValue("#pagenums#", ((import.PaddingInfo.Page - 1) * import.PaddingInfo.PageSize).ToString(CultureInfo.InvariantCulture));
            result.HistoryItem = cmd.ExecuteEntityList <ResultImport>();
            foreach (var item in result.HistoryItem)
            {
                item.ObjectName = GetObjectName(item.IsArea, item.ObjectId);
            }
            result.PageInfo.Total = (int)cmd.GetParameterValue("@Count");
            return(result);
        }
예제 #17
0
        public static HistoryQuery GetHistoryQuery(HttpRequestBase req)
        {
            HistoryQuery query = new HistoryQuery {
                ProductName = req.QueryString["ProductName"],
                WaferCode   = req.QueryString["WaferCode"],
                LotId       = req.QueryString["LotId"],
                WaferID     = req.QueryString["WaferID"],
                Dispose     = StringHelper.isNullOrEmpty(req.QueryString["Dispose"])?0:int.Parse(req.QueryString["Dispose"]),
                UserID      = req.QueryString["UserID"],
                Comment     = req.QueryString["Comment"],
                CreateTime  = req.QueryString["CreateTime"],
                OrderBy     = req.QueryString["OrderBy"],
                OrderDesc   = StringHelper.isNullOrEmpty(req.QueryString["OrderDesc"]) ? false : Convert.ToBoolean(req.QueryString["OrderDesc"]),
            };

            return(query);
        }
예제 #18
0
 public Task <HistoryResponse> GetHistoricalData(HistoryQuery history)
 {
     return(SendJsonQuery <HistoryResponse, HistoryQuery>(history, historySite));
 }
예제 #19
0
        private void btnGetHistory_Click(object sender, System.EventArgs e)
        {
            try
            {
                // Clear old results
                this.lstHistory.Items.Clear();

                // Get selected data source and tag
                object     oIdx = this.cboDatasources.SelectedItem.ToString();
                DataSource ds   = m_dss.Item(oIdx);
                if (ds == null)
                {
                    return;
                }
                if (ds.Tags.Count == 0)
                {
                    return;
                }

                oIdx = 1;
                Tag t = ds.Tags.Item(oIdx);
                if (t == null)
                {
                    return;
                }

                // Get history query object
                HistoryQuery q = t.History.Query;
                if (q == null)
                {
                    return;
                }

                // Get selected request type
                apdHistoryTypeEnum type = apdHistoryTypeEnum.apdActual;
                if (cboTypes.SelectedIndex > 0)
                {
                    type = apdHistoryTypeEnum.apdBestFit;
                }

                // Set history query properties
                q.Type      = type;
                q.BeginTime = this.dtBegin.Value;
                q.EndTime   = this.dtEnd.Value;
                q.MaxPoints = System.Convert.ToInt32(this.txtMaxPoints.Text);
                q.Stepped   = this.chkStepped.Checked;

                // Read history, async = false
                t.History.Read(false);

                // Output query status text
                this.lblQueryStatus.Text = t.History.QueryStatus.StatusText;

                // Do we have samples?
                if (t.History.Samples.Count > 0)
                {
                    object oSample;
                    // Populate list box with raw samples data
                    for (int i = 1; i <= t.History.Samples.Count; i++)
                    {
                        // Output Time - Value pair
                        oSample  = System.Convert.ToString(t.History.Samples.Item(i).Time);
                        oSample += " - ";
                        oSample += System.Convert.ToString(t.History.Samples.Item(i).Value);
                        lstHistory.Items.Add(oSample);
                    }
                    // Show samples data table (formatted with level and status)
                    t.History.Samples.ShowDataTable(t.Name);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Get History Error");
            }
        }
예제 #20
0
 public HistoryList()
 {
     hq = new HistoryQuery();
 }
예제 #21
0
 public IList <VwWafer_History> HistoryList(HistoryQuery query, int pageSize, int pageIndex, out int recordCount)
 {
     return(this.way.HistoryList(query, pageSize, pageIndex, out recordCount));
 }
예제 #22
0
 public Task <HistoryCollection> Get([FromQuery] HistoryQuery query)
 {
     return(historyRepo.PageHistory(query));
 }
예제 #23
0
        public async Task <(List <ExchangeEntry> entries, int count)> GetEntriesAsync(HistoryQuery query)
        {
            if (query.FromCurrencyCodes == null)
            {
                query.FromCurrencyCodes = new List <string>();
            }
            if (query.ToCurrencyCodes == null)
            {
                query.ToCurrencyCodes = new List <string>();
            }
            if (query.EndDate == DateTime.MinValue || query.EndDate < query.StartDate)
            {
                query.EndDate = DateTime.MaxValue;
            }

            var entries = context.ExchangeEntries.Where(
                entry =>
                query.FromCurrencyCodes.Contains(entry.FromCurrencyCode)
                &&
                query.ToCurrencyCodes.Contains(entry.ToCurrencyCode)
                &&
                entry.Date >= query.StartDate
                &&
                entry.Date <= query.EndDate
                );

            var orderedEntries = query.OrderColumnName switch
            {
                "FromCurrencyCode" => entries.OrderBy(c => c.FromCurrencyCode),
                "FromAmount" => entries.OrderBy(c => c.FromAmount),
                "ToCurrencyCode" => entries.OrderBy(c => c.ToCurrencyCode),
                "ToAmount" => entries.OrderBy(c => c.ToAmount),
                "Date" => entries.OrderBy(c => c.Date),
                _ => entries
            };

            if (query.IsDescending)
            {
                orderedEntries = orderedEntries.Reverse();
            }
            var selectedEntries = await orderedEntries.Skip((query.PageNumber - 1) *query.PageSize).Take(query.PageSize).ToListAsync();

            return(entries : selectedEntries, count : entries.Count());
        }
예제 #24
0
 public Task <HistoryCollection> Get(String filePath, [FromQuery] HistoryQuery query)
 {
     query.FilePath = filePath;
     return(Get(query));
 }