public List <Report> GetAllUserReportByUserIdToLeft(User _userObj)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             var allReports  = ReportDB.GetInstance().GetAllReportes();
             var userCompany = CompanyUserDB.GetInstance().GetCompanyUserById(_userObj.Id);
             if (userCompany.IsCompanyAdmin)
             {
                 return(allReports);
             }
             else
             {
                 var myCompanyId = context.CompanyUser.FirstOrDefault(x => x.UserId == _userObj.Id).CompanyId;
                 var myDevices   = allReports.Where(x => x.Id == myCompanyId).ToList();
                 return(myDevices);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#2
0
        /// <summary>
        /// Get latest data available on Database.
        /// </summary>
        /// <returns></returns>
        public static List <Region> FetchDatabase()
        {
            List <Region>      regions = new List <Region>();
            CoronaWatchContext context = new CoronaWatchContext();

            DateTime        currentDate    = System.DateTime.UtcNow.Date;
            DateTime        latestDateOnDB = Convert.ToDateTime(context.ReportDBs.Max(r => r.Date)).Date;
            List <RegionDB> regionDBs      = context.RegionDBs.ToList();
            List <ReportDB> reportDBs      = context.ReportDBs.ToList();

            foreach (RegionDB regionDB in regionDBs)
            {
                ReportDB  reportDB  = reportDBs.Where(r => r.ISOCode == regionDB.ISOCode).OrderByDescending(r => r.Date).Select(r => r).FirstOrDefault();
                Statistic statistic = new Statistic((int)reportDB.Confirmed, (int)reportDB.Recovered, (int)reportDB.Death)
                {
                    StatisticID = reportDB.ISOCode
                };
                Report report = new Report(Convert.ToDateTime(reportDB.Date).Date, statistic);
                Region region = new Region(regionDB.Name, Region.EnumLevel.Country, regionDB.Slug, regionDB.ISOCode)
                {
                    Report = report
                };
                regions.Add(region);
            }

            // Sort by Name, actually unneccesary. Can be delete to improve performance
            regions.Sort((x, y) => x.Name.CompareTo(y.Name));
            return(regions);
        }
示例#3
0
        private void BindUploadList()
        {
            ReportDB DB = new ReportDB();

            this.UploadList.DataSource = DB.GetUploadList();
            this.UploadList.DataBind();
        }
        public IActionResult GecmisKonumRaporu(int _deviceId, string _startDate, string _endDate)
        {
            try
            {
                _startDate += " 00:00:00";
                _endDate   += " 23:59:59";

                var result = ReportDB.GetInstance().GecmisKonumRaporu(_startDate, _endDate, new string[] { _deviceId.ToString() }).FirstOrDefault().Value;

                var dt = JsonConvert.DeserializeObject <DataTable>(JsonConvert.SerializeObject(result));
                dt.Columns.Remove("Grup");
                dt.Columns.Remove("Arac");
                dt.Columns.Remove("Enlem");
                dt.Columns.Remove("Boylam");

                foreach (DataRow dr in dt.Rows)
                {
                    dr["Tarih"] = Convert.ToDateTime(dr["Tarih"].ToString()).ToString("dd.MM.yyyy HH:mm");
                }

                dt = dt.DefaultView.ToTable(true);

                result = JsonConvert.DeserializeObject <List <GecmisKonumRaporuObjectRepo> >(JsonConvert.SerializeObject(dt));

                ViewBag.ReportStartDate = DateTime.ParseExact(_startDate, "yyyy-MM-dd HH:mm:ss", null).ToString("dd.MM.yyyy HH:mm");
                ViewBag.ReportEndDate   = DateTime.ParseExact(_endDate, "yyyy-MM-dd HH:mm:ss", null).ToString("dd.MM.yyyy HH:mm");
                ViewBag.PlateNumber     = DeviceDB.GetInstance().GetDeviceById(_deviceId).CarPlateNumber;

                return(PartialView("_GecmisKonumRaporuResult", result));
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportId"></param>
        /// <param name="deletedBy"></param>
        /// <returns></returns>
        public OperationDetails DeleteReport(int reportId, int deletedBy)
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            OperationDetails operationDetails = null;

            try
            {
                ReportModel reportModel = new ReportModel();
                reportModel.Id         = reportId;
                reportModel.ModifiedBy = deletedBy;

                using (ReportDB reportDB = new ReportDB())
                {
                    operationDetails = reportDB.DeleteReport(reportModel);
                }
                return(operationDetails);
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
示例#6
0
        public DataTable GetReportData(ConnectionModel connection, string storedProcedureName)
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            DataTable dataTable = null;

            try
            {
                string connectionString = string.Format("Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = {1}))"
                                                        + "(CONNECT_DATA =(SERVER = DEDICATED)(SID = {2})));User Id= {3};Password= {4};Persist Security Info=True;",
                                                        connection.IpAddress,
                                                        connection.PortNumber,
                                                        connection.SID,
                                                        connection.ConnectionUsername,
                                                        connection.ConnectionPassword);

                using (ReportDB reportDB = new ReportDB(connectionString))
                {
                    dataTable = reportDB.GetReportData(storedProcedureName);
                }
                return(dataTable);
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
        private bool Create_Son_Ha_Report(string tieuDe, string path, string fileName, string templateName)
        {
            var maCD = Convert.ToInt32(ConfigurationManager.AppSettings["MaCDChoReportTS"].ToString());
            var ns   = BLLAssignmentForLine.Instance.GetProductivitiesOfLines(DateTime.Now, AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(), null, getBTPInLineByType, maCD);

            return(ReportDB.ExportToExcel_ThienSon_Edit(tieuDe, path, templateName, fileName, ns.OrderBy(x => x.MaChuyen).ToList(), timesGetNSInDay));
        }
        private List <string> LoadDataNSChuyenExportToExcel(string tieuDe, string path, string fileName)
        {
            List <string> listFilePath = new List <string>();

            try
            {
                if (listChuyen != null && listChuyen.Count > 0)
                {
                    int appId = 1;
                    int.TryParse(ConfigurationManager.AppSettings["AppId"].ToString(), out appId);
                    var nx = BLLProductivity.GetProductivitiesInDay(AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(), appId);
                    dtDataNSChuyenExportExcel.Rows.Clear();
                    if (nx.Count > 0)
                    {
                        DataRow row;
                        foreach (var item in nx)
                        {
                            row = dtDataNSChuyenExportExcel.NewRow();
                            row.SetField(0, item.LineName);
                            row.SetField(1, item.LaborInLine);
                            row.SetField(2, item.CommoName);
                            row.SetField(3, item.ProductionPlans);
                            row.SetField(4, item.LK_TH);
                            row.SetField(5, item.LK_BTP);
                            row.SetField(6, item.NormsOfDay);
                            row.SetField(7, item.BTP_Day);
                            row.SetField(8, item.TH_Day);
                            row.SetField(9, item.ErrorsInDay);
                            row.SetField(10, item.TH_Percent);
                            row.SetField(11, item.ErrorPercent);
                            row.SetField(12, item.BTPInLine);
                            row.SetField(13, item.Funds);
                            row.SetField(14, item.ResearchPaced);
                            row.SetField(15, item.CurrentPacedProduction);
                            row.SetField(16, item.TC_Paced);
                            row.SetField(17, item.RevenuesInDay);
                            row.SetField(18, item.RevenuesInMonth);
                            row.SetField(19, item.TC_Day);
                            row.SetField(20, item.LK_TC);
                            dtDataNSChuyenExportExcel.Rows.Add(row);
                        }
                        var result = ReportDB.ExportToExcelByDataTable(tieuDe, path, fileName, dtDataNSChuyenExportExcel);
                        if (result)
                        {
                            listFilePath.Add(path + fileName);
                        }
                        else
                        {
                            MessageBox.Show("Lỗi: Tạo file excel năng suất chuyền không thành công.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message);
            }
            return(listFilePath);
        }
        private List <string> LoadDataNSCum(string tieuDe, string path, string fileName)
        {
            List <string> listFilePath = new List <string>();

            try
            {
                var listModelNangSuatCum = GetTTNangSuatCum();
                if (listModelNangSuatCum != null && listModelNangSuatCum.Count > 0)
                {
                    dtDataNSCumExportExcel.Rows.Clear();
                    foreach (var item in listModelNangSuatCum)
                    {
                        DataRow row = dtDataNSCumExportExcel.NewRow();
                        row.SetField(0, item.chuyen);
                        row.SetField(1, item.maHang);
                        row.SetField(2, item.sanLuongKeHoach);
                        if (item.listNangSuatCum != null && item.listNangSuatCum.Count > 0)
                        {
                            int i = 2;
                            foreach (var nscum in item.listNangSuatCum)
                            {
                                i++;
                                row.SetField(i, nscum.cum);
                                row.SetField(i + 1, nscum.sanLuong);
                                i++;
                            }
                        }
                        else
                        {
                            if (maxCountCum > 0)
                            {
                                for (int i = 0; i < maxCountCum; i++)
                                {
                                    row.SetField(2, "");
                                    row.SetField(2, "");
                                }
                            }
                        }
                        dtDataNSCumExportExcel.Rows.Add(row);
                    }
                    var result = ReportDB.ExportToExcelByDataTable(tieuDe, path, fileName, dtDataNSCumExportExcel);
                    if (result)
                    {
                        listFilePath.Add(path + fileName);
                    }
                    else
                    {
                        MessageBox.Show("Lỗi: Tạo file excel năng suất cụm không thành công.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message);
            }
            return(listFilePath);
        }
示例#10
0
        public static bool RemovePrivileges(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string username, string itemPath)
        {
            bool     objReturn = false;
            ReportDB objDB     = new ReportDB();

            objReturn = objDB.RemovePrivileges(CURRENT_USER, CURRENT_REGISTRY_ID, username, itemPath);
            objDB.Dispose();

            return(objReturn);
        }
示例#11
0
        public static bool AddItemReadOnly(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string username, string itemPath)
        {
            bool     objReturn = false;
            ReportDB objDB     = new ReportDB();

            objReturn = objDB.AddItemReadOnly(CURRENT_USER, CURRENT_REGISTRY_ID, username, itemPath);
            objDB.Dispose();

            return(objReturn);
        }
示例#12
0
        public static bool AddSystemUser(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string username)
        {
            bool     objReturn = false;
            ReportDB objDB     = new ReportDB();

            objReturn = objDB.AddSystemUser(CURRENT_USER, CURRENT_REGISTRY_ID, username);
            objDB.Dispose();

            return(objReturn);
        }
示例#13
0
        public static bool UpdateItemProperties(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string itemPath, string description)
        {
            bool     objReturn = false;
            ReportDB objDB     = new ReportDB();

            objReturn = objDB.UpdateItemProperties(CURRENT_USER, CURRENT_REGISTRY_ID, itemPath, description);
            objDB.Dispose();

            return(objReturn);
        }
示例#14
0
        public static void UpdateDatabase()
        {
            try
            {
                CoronaWatchContext context = new CoronaWatchContext();

                // Updating Region List, if exist
                InitializeDatabase();

                // Check if the current data for ReportDB is exist. Note that ReportDB is equivalent to Report.
                // Different Name used to avoid confusion and ambiguity
                var client = new RestClient(API + "summary")
                {
                    Timeout = -1
                };
                var           request  = new RestRequest(Method.GET);
                IRestResponse response = client.Execute(request);
                var           json     = SimpleJson.DeserializeObject(response.Content);
                JObject       obj      = JObject.Parse(json.ToString());
                JsonArray     array    = (JsonArray)SimpleJson.DeserializeObject(obj["Countries"].ToString());

                foreach (JsonObject jsonObject in array)
                {
                    //DateTime APIdate = Convert.ToDateTime(Regex.Match(jsonObject["Date"].ToString(), @"\d{4}-\d{2}-\d{2}").Value);
                    DateTime APIdate     = DateTime.Parse(jsonObject["Date"].ToString(), null, System.Globalization.DateTimeStyles.RoundtripKind);
                    string   CountryName = jsonObject["CountryCode"].ToString();
                    if (context.ReportDBs.Where(r => r.Date == APIdate && r.ISOCode == CountryName).FirstOrDefault() == null)
                    {
                        ReportDB reportDB = new ReportDB
                        {
                            ISOCode   = jsonObject["CountryCode"].ToString(),
                            Confirmed = Convert.ToInt32(jsonObject["TotalConfirmed"].ToString()),
                            Recovered = Convert.ToInt32(jsonObject["TotalRecovered"].ToString()),
                            Death     = Convert.ToInt32(jsonObject["TotalDeaths"].ToString())
                        };
                        reportDB.Active = reportDB.Confirmed - reportDB.Recovered - reportDB.Death;
                        reportDB.Date   = APIdate;
                        context.ReportDBs.Add(reportDB);
                        context.SaveChanges();
                    }
                }
                MessageBox.Show("Successfully Updated DB");
            }
            catch (Exception e)
            {
                if (e.Message == "Invalid JSON string")
                {
                    MessageBox.Show(e.Message + "\nPlease Check Your Connection", "Error", MessageBoxButton.OK);
                }
                else
                {
                    MessageBox.Show(e.Message, "Error");
                }
            }
        }
示例#15
0
        public static List <ReportItem> GetUserReports(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            List <ReportItem> objReturn = null;
            ReportDB          objDB     = new ReportDB();

            string folderName = "/Reports/" + CURRENT_USER.Replace("\\", "_");

            objReturn = objDB.GetReports(CURRENT_USER, CURRENT_REGISTRY_ID, folderName);

            return(objReturn);
        }
示例#16
0
        public static string CreateUserFolder(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID, string username)
        {
            string   objReturn = string.Empty;
            ReportDB objDB     = new ReportDB();

            string folderName = username.Replace("\\", "_");

            objReturn = objDB.CreateFolder(CURRENT_USER, CURRENT_REGISTRY_ID, folderName);
            objDB.Dispose();

            return(objReturn);
        }
 private void butCreateTemplateExcel_Click(object sender, EventArgs e)
 {
     try
     {
         List <ModelSheetExcel> listModelSheet = new List <ModelSheetExcel>();
         DataTable dtLines = chuyenDAO.GetDataTableLineByStrListId(AccountSuccess.strListChuyenId);
         if (dtLines != null)
         {
             listModelSheet.Add(new ModelSheetExcel()
             {
                 Title = "Danh Sách Chuyền", Data = dtLines
             });
         }
         DataTable dtSanPham = hangDAO.DSHangExportExcel(AccountSuccess.IdFloor);
         if (dtSanPham != null)
         {
             listModelSheet.Add(new ModelSheetExcel()
             {
                 Title = "Danh Sách Mặt Hàng", Data = dtSanPham
             });
         }
         DataTable dtPHC = new DataTable();
         dtPHC = new System.Data.DataTable("PHC");
         dtPHC.Columns.Add("TÊN CHUYỀN", typeof(System.String));
         dtPHC.Columns.Add("Mặt Hàng", typeof(System.String));
         dtPHC.Columns.Add("TG CHẾ TẠO", typeof(System.String));
         dtPHC.Columns.Add("SẢN LƯỢNG KH", typeof(System.String));
         dtPHC.Columns.Add("THÁNG", typeof(System.String));
         dtPHC.Columns.Add("NĂM", typeof(System.String));
         listModelSheet.Add(new ModelSheetExcel()
         {
             Title = "Phân Công Mặt Hàng Cho Chuyền", Data = dtPHC
         });
         SaveFileDialog saveFileDialog1 = new SaveFileDialog();
         saveFileDialog1.InitialDirectory = @"C:\";
         saveFileDialog1.Title            = "Save excel file";
         saveFileDialog1.FilterIndex      = 2;
         saveFileDialog1.RestoreDirectory = true;
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             var result = ReportDB.exportMulDataToExcel(saveFileDialog1.FileName, listModelSheet);
             if (result)
             {
                 MessageBox.Show("Tạo file excel nhập phân công chuyền thành công.");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi:" + ex.Message);
     }
 }
 public List <Report> GetAllUserReportByUserIdToRight(User _userObj)
 {
     try
     {
         using (var context = new VeraEntities())
         {
             var allReports    = ReportDB.GetInstance().GetAllReportes();
             var UserReport    = context.UserReport.Where(x => x.UserId == _userObj.Id).ToList();
             var UserReportIds = UserReport.Select(x => x.ReportId).ToList();
             var reports       = allReports.Where(x => UserReportIds.Contains(x.Id)).ToList();
             return(reports);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#19
0
        public static string CreateRegistryFolder(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            string   objReturn = string.Empty;
            ReportDB objDB     = new ReportDB();

            STD_REGISTRY registry = STD_REGISTRYManager.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, CURRENT_REGISTRY_ID);

            if (registry == null || string.IsNullOrEmpty(registry.CODE))
            {
                return(string.Empty);
            }

            string folderName = registry.CODE;

            objReturn = objDB.CreateFolder(CURRENT_USER, CURRENT_REGISTRY_ID, folderName);
            objDB.Dispose();

            return(objReturn);
        }
示例#20
0
        public static List <ReportItem> GetRegistryReports(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            List <ReportItem> objReturn = null;
            ReportDB          objDB     = new ReportDB();

            STD_REGISTRY registry = STD_REGISTRYManager.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, CURRENT_REGISTRY_ID);

            if (registry == null || string.IsNullOrEmpty(registry.CODE))
            {
                return(null);
            }

            string folderName = "/Reports/" + registry.CODE;

            objReturn = objDB.GetReports(CURRENT_USER, CURRENT_REGISTRY_ID, folderName);
            objDB.Dispose();

            return(objReturn);
        }
示例#21
0
        public static bool CreateDataSet(string CURRENT_USER, Int32 CURRENT_REGISTRY_ID)
        {
            bool     objReturn = false;
            ReportDB objDB     = new ReportDB();

            STD_REGISTRY registry = STD_REGISTRYManager.GetItem(CURRENT_USER, CURRENT_REGISTRY_ID, CURRENT_REGISTRY_ID);

            if (registry == null || string.IsNullOrEmpty(registry.CODE))
            {
                return(false);
            }

            string name   = registry.CODE;
            string parent = "/Reports/" + registry.CODE;

            objReturn = objDB.CreateDataSet(CURRENT_USER, CURRENT_REGISTRY_ID, name, parent);
            objDB.Dispose();

            return(objReturn);
        }
示例#22
0
    public IList<ReportDB> GetNewProducts()
    {
        IList<ReportDB> mySampleProducts = new List<ReportDB>(3);

        ReportDB myReport = new ReportDB();
        myReport.ProductName = "鸡蛋";
        myReport.ProductPrice = "$1.39";
        mySampleProducts.Add(myReport);

        myReport = new ReportDB();
        myReport.ProductName = "牛奶";
        myReport.ProductPrice = "$0.39";
        mySampleProducts.Add(myReport);

        myReport = new ReportDB();
        myReport.ProductName = "豆浆";
        myReport.ProductPrice = "$5.39";
        mySampleProducts.Add(myReport);

        return (mySampleProducts);
    }
        private bool Create_HoangGia_Report(string tieuDe, string path, string fileName, string templateName)
        {
            var latetestWork = BLLProductivity_.Instance.GetLatestWork();

            if (latetestWork != null)
            {
                var ns_Ngay = BLLAssignmentForLine.Instance.LayNSHoangGia_Ngay(
                    latetestWork.CreatedDate,
                    AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaCDCat"].ToString()),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaCDUi"].ToString()),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaCDDongThung"].ToString()));
                var ns_Thang = BLLAssignmentForLine.Instance.LayNSHoangGia_Thang(
                    latetestWork.CreatedDate,
                    AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaCDCat"].ToString()),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaCDUi"].ToString()),
                    Convert.ToInt32(ConfigurationManager.AppSettings["MaCDDongThung"].ToString()));
                return(ReportDB.ExportToExcel_HoangGia(tieuDe, path, templateName, fileName, ns_Ngay, ns_Thang, timesGetNSInDay, BLLDepartmentDailyLabour.Instance.GetsForReport(DateTime.Now.ToString("dd/MM/yyyy")), latetestWork.CreatedDate));
            }
            return(false);
        }
示例#24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportModel"></param>
        /// <returns></returns>
        public OperationDetails AddEditReport(ReportModel reportModel)
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            OperationDetails operationDetails = null;

            try
            {
                using (ReportDB reportDB = new ReportDB())
                {
                    operationDetails = reportDB.AddEditReport(reportModel);
                }
                return(operationDetails);
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
示例#25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportId"></param>
        /// <returns></returns>
        public ReportModel GetReportById(int reportId)
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            ReportModel reportModel = null;

            try
            {
                using (ReportDB reportDB = new ReportDB())
                {
                    reportModel = reportDB.GetReportById(reportId);
                }
                return(reportModel);
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
示例#26
0
        public List <ConnectionModel> GetConnectionsByProject(int projectId)
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            List <ConnectionModel> connectionList = null;

            try
            {
                using (ReportDB reportDB = new ReportDB())
                {
                    connectionList = reportDB.GetConnectionsByProject(projectId);
                }
                return(connectionList);
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
示例#27
0
        /// <summary>
        /// Get Report List
        /// </summary>
        /// <returns>Report List</returns>
        public List <ReportModel> GetReportList()
        {
            log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution start.");
            List <ReportModel> reportList = null;

            try
            {
                using (ReportDB reportDB = new ReportDB())
                {
                    reportList = reportDB.GetReportList();
                }
                return(reportList);
            }
            catch (Exception exception)
            {
                errorLog.Fatal("Exception " + exception.Message + "\n" + exception.StackTrace);
                throw;
            }
            finally
            {
                log.Debug(MethodHelper.GetCurrentMethodName() + " Method execution end.");
            }
        }
        private List <string> GetChart(string tieuDe, string path, string fileName, bool IsError, bool IsKCS, bool IsInHour, int getType)
        {
            var listFilePath = new List <string>();

            try
            {
                var lines  = BLLProductivity.GetProductiviesOfLinesInDay(AccountSuccess.strListChuyenId.Split(',').Select(x => int.Parse(x)).ToList(), DateTime.Now, IsInHour, getType);
                var result = ReportDB.DrawChartAndExport(lines, tieuDe, path, fileName, IsError, IsKCS);

                if (result)
                {
                    listFilePath.Add(path + fileName);
                }
                else
                {
                    MessageBox.Show("Lỗi: Tạo file excel không thành công.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message);
            }
            return(listFilePath);
        }
示例#29
0
        //    protected HtmlGenericControl PageTitle = new HtmlGenericControl();

        protected void Page_Init(object sender, EventArgs e)
        {
            string  customername = string.Empty;
            string  UserName     = string.Empty;
            string  AcctID       = string.Empty;
            Boolean showRpt      = true;

            if (Request.QueryString["ctl"] == null)
            {
                Response.Redirect("error.aspx");
            }
            else
            {
                string text = Request.QueryString["ctl"];

                //string[] ctls = new String[2];
                //  ctls = text.Split('*');

                string[] ctls = text.Split(new char[] { '-' }, 2);
                AcctID   = ctls[0];
                UserName = ctls[1];

                SqlDataReader drUser = UsersDB.ValidUser(UserName, AcctID);
                if (drUser.Read())
                {
                    acctName.Text = drUser["accountname"].ToString();
                    if (acctName.Text == string.Empty)
                    {
                        //                       Response.Redirect("error.aspx");
                        throw new Exception("account name issue");
                    }

                    custName.Text = drUser["customer"].ToString();
                    if (custName.Text == string.Empty)
                    {
                        //                       Response.Redirect("error.aspx");
                        throw new Exception("customer issue");
                    }
                    //                   UserName = drUser["UserName"].ToString();

                    customername = drUser["customername"].ToString();
                }
            }

            // Uri ReportServer;
            string ReportPath = string.Empty;

            if (Request.QueryString["rpt"] == null)
            {
                ReportViewer1.Visible = false;
                showRpt = false;
            }
            else
            {
                string rptid = Request.QueryString["rpt"];

                SqlDataReader drReport = ReportDB.ValidReport(rptid);
                if (drReport.Read())
                {
                    // ReportServer = drReport["ReportServer"];
                    ReportPath      = drReport["ReportPath"].ToString();
                    reportName.Text = drReport["ReportName"].ToString() + ' ' + customername;
                    Page.Title      = drReport["ReportName"].ToString();
                }
                else
                {
                    throw new Exception("report path issue");
//                    Response.Redirect("error.aspx");
                }
            }

            ReportViewer1.ServerReport.DisplayName = reportName.Text;


            ReportViewer1.ServerReport.ReportServerCredentials =
                new MyReportServerCredentials();

            if (showRpt)
            {
                SetReportParameters(ReportPath, UserName, AcctID);
            }
        }
 public static ReportDB WithReportDBLoadCounter(this ReportDB reportDB, Int32 reportDBLoadCounter)
 {
     reportDB.ReportDBLoadCounter = reportDBLoadCounter;
     return(reportDB);
 }
        private void butChooseFile_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter           = "file excel|*.xls;*.xlsx|all file|*.*";
                dlg.InitialDirectory = @"C:\";
                dlg.Multiselect      = false;
                dlg.RestoreDirectory = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    listChuyenPhamCong = new List <Chuyen_SanPham>();
                    listSanPham        = new List <SanPham>();
                    string[] tmp         = dlg.FileNames;
                    int      sttThucHien = 0;
                    foreach (string i in tmp)
                    {
                        txtFile.Text = dlg.FileName;
                        DateTime dateNow  = DateTime.Now;
                        int      intMorth = dateNow.Month;
                        int      intYear  = dateNow.Year;
                        Microsoft.Office.Interop.Excel.Application xlApp;
                        Microsoft.Office.Interop.Excel.Workbook    xlWorkBook;
                        Microsoft.Office.Interop.Excel.Worksheet   xlWorkSheet;
                        object misValue = System.Reflection.Missing.Value;

                        xlApp      = new Microsoft.Office.Interop.Excel.Application();
                        xlWorkBook = xlApp.Workbooks.Open(dlg.FileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

                        if (xlWorkBook.Worksheets != null)
                        {
                            int countSheet = xlWorkBook.Worksheets.Count;
                            for (int indexSheet = 1; indexSheet <= countSheet; indexSheet++)
                            {
                                xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(indexSheet);
                                int     indexRow    = 10;
                                int     intRowClear = 0;
                                dynamic dThangNam   = xlWorkSheet.get_Range("M4", "M4").Value2;
                                int     intThang    = 0;
                                int     intNam      = 0;
                                if (dThangNam != null)
                                {
                                    string strThangNam = dThangNam.ToString();
                                    strThangNam = strThangNam.Replace("THÁNG", "|");
                                    strThangNam = strThangNam.Replace("NĂM", "|");
                                    var arrThangNam = strThangNam.Split(new char[] { '|' });
                                    if (arrThangNam != null && arrThangNam.Length > 2)
                                    {
                                        int.TryParse(arrThangNam[1], out intThang);
                                        int.TryParse(arrThangNam[2], out intNam);
                                    }
                                }
                                if (intThang == intMorth && intNam == intYear)
                                {
                                    string tenChuyen = string.Empty;
                                    while (true)
                                    {
                                        dynamic dTenChuyen  = xlWorkSheet.get_Range("M" + indexRow, "M" + indexRow).Value2;
                                        dynamic dSanPham    = xlWorkSheet.get_Range("N" + indexRow, "N" + indexRow).Value2;
                                        dynamic dTGCheTaoSP = xlWorkSheet.get_Range("O" + indexRow, "O" + indexRow).Value2;
                                        dynamic dSanLuongKH = xlWorkSheet.get_Range("T" + indexRow, "T" + indexRow).Value2;
                                        dynamic dDonGiaCM   = xlWorkSheet.get_Range("S" + indexRow, "S" + indexRow).Value2;
                                        if (dSanPham != null && dDonGiaCM != null)
                                        {
                                            float fDonGiaCM = 0;
                                            float.TryParse(dDonGiaCM.ToString(), out fDonGiaCM);
                                            listSanPham.Add(new SanPham()
                                            {
                                                TenSanPham = dSanPham.ToString(),
                                                DonGia     = fDonGiaCM,
                                                DonGiaCM   = fDonGiaCM,
                                                Floor      = AccountSuccess.IdFloor
                                            });
                                        }
                                        if (dSanPham != null && dTGCheTaoSP != null && dSanLuongKH != null)
                                        {
                                            if (dTenChuyen != null)
                                            {
                                                tenChuyen = dTenChuyen.ToString();
                                            }
                                            int intSanLuongKH = 0;
                                            int.TryParse(dSanLuongKH.ToString(), out intSanLuongKH);
                                            float fTgCheTaoSP = 0;
                                            float.TryParse(dTGCheTaoSP.ToString(), out fTgCheTaoSP);
                                            sttThucHien++;
                                            listChuyenPhamCong.Add(new Chuyen_SanPham()
                                            {
                                                STTThucHien     = sttThucHien,
                                                TenChuyen       = tenChuyen.ToString(),
                                                TenSanPham      = dSanPham.ToString(),
                                                Thang           = intThang,
                                                Nam             = intNam,
                                                SanLuongKeHoach = intSanLuongKH,
                                                NangXuatSanXuat = fTgCheTaoSP
                                            });
                                        }
                                        else
                                        {
                                            intRowClear++;
                                            //MessageBox.Show("Lỗi: Thông tin phân công hàng cho chuyền, nhập liệu không đúng. Vui lòng kiểm tra lại, các thông tin không được để trống và các dòng dữ liệu cần liền nhau.");
                                        }
                                        if (intRowClear > 20)
                                        {
                                            break;
                                        }
                                        indexRow++;
                                    }
                                }
                            }
                            xlWorkBook.Close(true, misValue, misValue);
                            xlApp.Quit();
                            ReportDB.releaseObject(xlWorkBook);
                            ReportDB.releaseObject(xlApp);
                        }
                        break;
                    }
                    gridControl1.DataSource = listChuyenPhamCong;
                    if (listSanPham != null && listSanPham.Count > 0)
                    {
                        foreach (var p in listSanPham)
                        {
                            var productExist = sanPhamDAO.GetProductByName(AccountSuccess.IdFloor, p.TenSanPham);
                            if (productExist == null)
                            {
                                if (MessageBox.Show("Mặt Hàng: " + p.TenSanPham.Trim() + " chưa có trong hệ thống. Bạn có muốn thêm Mặt Hàng này không?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    sanPhamDAO.ThemOBJ(p);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi:" + ex.Message);
            }
        }
示例#32
0
    public IList<ReportDB> GetSampleProducts()
    {
        //IList<ReportDB> mySampleProducts = new List<ReportDB>(2);

        ReportDB myReport = new ReportDB();
        myReport.ProductName = "奶酪";
        myReport.ProductPrice = "$1.39";
        //mySampleProducts.Add(myReport);
        LReportDB.Add(myReport);
        //myReport.Distroy();

        myReport = new ReportDB();
        myReport.ProductName = "葡萄";
        myReport.ProductPrice = "$0.39";
        //mySampleProducts.Add(myReport);
        LReportDB.Add(myReport);

        //return (mySampleProducts);
        return (LReportDB);
    }