Пример #1
0
 public static bool SaveDB_NX9(Dictionary <Variable.UserData, List <Variable.OutInTime> > DicUser)
 {
     try
     {
         Sys_NX9License sysLicenseRecord = new Sys_NX9License();
         foreach (KeyValuePair <Variable.UserData, List <Variable.OutInTime> > kvp in DicUser)
         {
             foreach (Variable.OutInTime i in kvp.Value)
             {
                 sysLicenseRecord.department  = kvp.Key.Department;
                 sysLicenseRecord.userChinese = kvp.Key.ChineseName;
                 sysLicenseRecord.username    = kvp.Key.EnglishName;
                 sysLicenseRecord.login       = i.OutTime;
                 sysLicenseRecord.logout      = i.InTime;
                 sysLicenseRecord.workingtime = i.Duration;
                 sysLicenseRecord.totaltime   = i.TotalTime;
                 sysLicenseRecord.date        = DateTime.Today.ToLongDateString();
                 if (!SaveDB <Sys_NX9License>(sysLicenseRecord))
                 {
                     return(false);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         return(false);
     }
     return(true);
 }
Пример #2
0
        public static bool GetOverAllData_NX9(DateTime StartDate, int TotalDays, out Dictionary <string, List <OverAllValue> > DicOverAllData)
        {
            DicOverAllData = new Dictionary <string, List <OverAllValue> >();
            try
            {
                //先整理日期區間有哪些人使用
                List <UserData> ListUserName = new List <UserData>();
                if (!GetUserName_NX9(StartDate, TotalDays, out ListUserName))
                {
                    MessageBox.Show("取得【日期區間有哪些人使用】失敗");
                    return(false);
                }

                if (ListUserName.Count == 0)
                {
                    MessageBox.Show("此日期區間沒有任何資料");
                    return(false);
                }

                for (int i = 0; i < TotalDays; i++)
                {
                    foreach (UserData j in ListUserName)
                    {
                        IList <Sys_NX9License> ListData = new List <Sys_NX9License>();
                        using (ISession session = MyHibernateHelper.SessionFactory.OpenSession())
                        {
                            ListData = session.QueryOver <Sys_NX9License>().Where(x => x.username == j.EnglishName)
                                       .And(x => x.date == StartDate.AddDays(i).ToLongDateString()).List();
                            session.Close();
                        }

                        Sys_NX9License lastData = new Sys_NX9License();

                        List <OverAllValue> ListOverAllValue = new List <OverAllValue>();
                        status = DicOverAllData.TryGetValue(StartDate.AddDays(i).ToLongDateString(), out ListOverAllValue);
                        if (!status)
                        {
                            ListOverAllValue = new List <OverAllValue>();
                        }

                        OverAllValue sOverAllValue = new OverAllValue();
                        sOverAllValue.EnglishName = j.EnglishName;
                        sOverAllValue.Department  = j.Department;
                        sOverAllValue.ChineseName = j.ChineseName;
                        if (ListData.Count == 0)
                        {
                            //此人在這個日期沒有用UG
                            sOverAllValue.TotalTime = "";
                        }
                        else
                        {
                            //取最後一筆紀錄
                            lastData = ListData[ListData.Count - 1];
                            if (lastData.totaltime == "使用中或未關閉NX")
                            {
                                sOverAllValue.TotalTime = "1440分0秒";
                            }
                            else
                            {
                                sOverAllValue.TotalTime = lastData.totaltime;
                            }
                        }
                        ListOverAllValue.Add(sOverAllValue);
                        DicOverAllData[StartDate.AddDays(i).ToLongDateString()] = ListOverAllValue;
                    }
                }
            }
            catch (System.Exception ex)
            {
                return(false);
            }
            return(true);
        }