Esempio n. 1
0
        public static HistoryModel GetHistoryFromModel <T>(T from, T to, string Autor) where T : Base
        {
            if (from == null)
            {
                from = (T)Activator.CreateInstance(to.GetType());
            }

            if (from.GetType() != to.GetType())
            {
                throw new ArgumentException();
            }

            string TableName = to.GetType().Name;
            string RecordID  = to.ID;

            PropertyInfo[] properties = to.GetType().GetProperties();

            HistoryRecord record = new HistoryRecord();

            record.Table    = TableName;
            record.RecordID = RecordID;
            record.Autor    = Autor;

            List <HistoryDetail> details = new List <HistoryDetail>();

            foreach (PropertyInfo info in properties)
            {
                HistoryFieldAttribute attr = info.GetCustomAttribute <HistoryFieldAttribute>();
                if (attr == null)
                {
                    continue;
                }

                var fromValue = info.GetValue(from);
                var toValue   = info.GetValue(to);

                if (fromValue != toValue)
                {
                    HistoryDetail detail = new HistoryDetail();
                    detail.Field         = info.Name;
                    detail.PrevValue     = fromValue == null ? "" : fromValue.ToString();
                    detail.NewValue      = toValue == null ? "" : toValue.ToString();
                    detail.HistoryRecord = record.ID;

                    details.Add(detail);
                }
            }

            HistoryModel returnData = new HistoryModel();

            returnData.Details = details;
            returnData.Records = new List <HistoryRecord> {
                record
            };

            return(returnData);
        }
Esempio n. 2
0
 void Awake()
 {
     _instance = this;
     hoverImage.SetActive(false);
     HistoryDetail_Hour   = transform.Find("HistoryDetail_Hour").gameObject;
     HistoryDetail_Minute = transform.Find("HistoryDetail_Minute").gameObject;
     hdbh = HistoryDetail_Hour.GetComponent <HistoryDetailByHour>();
     hdbm = HistoryDetail_Minute.GetComponent <HistoryDetailByMinute>();
 }
Esempio n. 3
0
        private void addHistory_Click(object sender, EventArgs e)
        {
            var now     = DateTime.Now.Date;
            var nextDay = now.AddDays(1);
            var topic   = (SelectionData)selectTopic.SelectedItem;

            using (var db = new DuoContext()) {
                History his;
                if (!db.Histories.Any(x => x.CreatedDate >= now && x.CreatedDate < nextDay))
                {
                    his = new History()
                    {
                        CreatedDate = now
                    };
                    db.Histories.Add(his);
                    db.SaveChanges();
                    var start = startDate.Value;
                    var end   = endDate.Value;
                    Reload(start, end);
                }
                else
                {
                    his = db.Histories.FirstOrDefault(x => x.CreatedDate >= now && x.CreatedDate < nextDay &&
                                                      !x.HistoryDetails.Any(y => y.TopicId == topic.Id));
                }
                if (his == null)
                {
                    MessageBox.Show("Chủ đề đã kiểm tra và thêm lịch sử", "Trùng lập dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                var hisDetail = new HistoryDetail()
                {
                    HistoryId = his.Id,
                    TopicId   = topic.Id,
                    DataTest  = new byte[0]
                };
                db.HistoryDetails.Add(hisDetail);
                db.SaveChanges();
                listTopic.DataSource = null;
                var hisDetails = db.HistoryDetails.AsNoTracking()
                                 .Where(x => x.MyHistory.Id == his.Id)
                                 .OrderBy(x => x.Id)
                                 .Select(x => new { Id = x.Id, Title = x.MyTopic.Title }).ToList();
                totalTopic.Text         = hisDetails.Count.ToString();
                listTopic.DataSource    = hisDetails;
                listTopic.DisplayMember = "Title";
                var topics = (List <SelectionData>)selectTopic.DataSource;
                var index  = topics.FindIndex(x => x.Id == topic.Id);
                topics.RemoveAt(index);
                selectTopic.DataSource    = null;
                selectTopic.DataSource    = topics;
                selectTopic.DisplayMember = "Name";
            }
            this.Refresh();
        }
Esempio n. 4
0
 void Awake()
 {
     hide.onClick.AddListener(() =>          //隐藏
     {
         gameObject.SetActive(false);
     });
     detail.onClick.AddListener(() =>         //进入详情
     {
         detailQuxian.SetActive(true);
         HistoryDetail hd = detailQuxian.GetComponent <HistoryDetail>();
         //hd.Init(TempDeviceName, TempTitle, TempTableName, TempIndex);
     });
 }
Esempio n. 5
0
    private void FillDataIntoForm(DataTable titleTable, DataTable valueTable, int index, GameObject item)
    {
        Button  detail = Utils.FindGameObject(item, "button_detail").GetComponent <Button>();
        DataRow titleRow = null, valueRow = null;
        string  text_title = "", text_value = "";

        if (titleTable.Rows.Count > 0)
        {
            titleRow   = titleTable.Rows[0];
            text_title = titleRow[index + 1].ToString();
        }
        if (valueTable.Rows.Count > 0)
        {
            valueRow       = valueTable.Rows[0];
            text_value     = valueRow[index + 2].ToString();
            detail.enabled = true;
            detail.onClick.RemoveAllListeners();
            detail.onClick.AddListener(() =>
            {
                //if (chart) chart.SetActive(true);
                //DeviceInfoChart dic = chart.GetComponent<DeviceInfoChart>();
                //dic.InitChart(deviceName.text, tableName_realTime, titleRow[index+1].ToString(), index);
                Dialog._instance.dialog_historyInfo.SetActive(true);
                HistoryDetail hd = Dialog._instance.dialog_historyInfo.GetComponent <HistoryDetail>();
                hd.Init(brand, deviceName.text, text_title, tableName_realtime, index);
            });
        }
        else
        {
            Utils.FindGameObject(item, "text_value").SetText("");
            detail.enabled = false;
        }
        Utils.FindGameObject(item, "text_title").SetText(text_title);
        if (text_value.IndexOf(".") > 0)
        {
            text_value = double.Parse(text_value).ToString("f4");
        }
        Utils.FindGameObject(item, "text_value").SetText(text_value);
    }
        public IHttpActionResult CheckAvailability(HistoryDetail userInfo)
        {

            if (ModelState.IsValid)
            {
                using (EmployeeEntities3 entity = new EmployeeEntities3())
                {

                    foreach (var book in entity.HistoryDetails)
                    {
                        if (userInfo.Resource_Id == book.Resource_Id)
                        {
                            if (userInfo.Start_Date > book.End_Date)
                            {
                                return Ok(true);
                            }
                            if (userInfo.Start_Date <= book.End_Date)
                            {
                                return Ok(false);
                            }
                        }
                        if (userInfo.Resource_Id != book.Resource_Id)
                        {
                            return Ok(true);
                        }
                    }

                    //var record=entity.HistoryDetails.Where(x => x.Resource_Id == (userInfo.Resource_Id) && x.Start_Date > (userInfo.End_Date));
                    //entity.HistoryDetails.Where(x => x.Resource_Id.Equals(userInfo.Resource_Id) && x.Start_Date > (userInfo.End_Date));
                    //var record = entity.HistoryDetails.Where(x => x.Start_Date>=(userInfo.Start_Date) && x.End_Date.Equals(userInfo.End_Date)).FirstOrDefault();
                    //if (record != null)
                    //{
                    //    return Ok(false);
                    //}

                }
            }
           return Ok(false);
        }