protected void cboSites_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        var site = _siteBL.GetSite(cboSites.SelectedValue);

        txtLocation.Text = site.Location;
        SetEmpty();
    }
    protected void cboSites_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        var site = _siteBL.GetSite(cboSites.SelectedValue);

        //cboConsumers.SelectedValue = site.ConsumerId;
        SetEmpty();
    }
Пример #3
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        List <t_LanguageTranslate> list          = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("/Supervisor/Site/Config.aspx")).ToList();
        var lb_installation_point_update_confirm = list.Where(x => x.ControlId.Contains("lb_installation_point_update_confirm")).FirstOrDefault();

        ntf.VisibleOnPageLoad = true;
        bool invalid = IsInvalidInput();

        if (invalid)
        {
            return;
        }
        var dbSite = _siteBL.GetSite(cboSites.Text);
        var site   = GetSite();
        var loggerConfiguration   = GetLoggerConfiguration();
        var dbLoggerConfiguration = _loggerConfigurationBL.GetLoggerConfiguration(txtLoggerID.Text);

        if (dbSite == null)
        {
            if (dbLoggerConfiguration == null)
            {
                _loggerConfigurationBL.InsertLoggerConfiguration(loggerConfiguration);
                //site.t_Logger_Configurations = loggerConfiguration;
            }
            else
            {
                loggerConfiguration.ForwardFlow = dbLoggerConfiguration.ForwardFlow;
                loggerConfiguration.Pressure1   = dbLoggerConfiguration.Pressure1;
                loggerConfiguration.Pressure2   = dbLoggerConfiguration.Pressure2;
                loggerConfiguration.ReverseFlow = dbLoggerConfiguration.ReverseFlow;
                _loggerConfigurationBL.UpdateLoggerConfiguration(loggerConfiguration, dbLoggerConfiguration);
            }
            _siteBL.InsertSite(site);
            ReBind();

            //ntf.Text = "Đã thêm mới điểm lắp đặt.";
            ntf.Text = lb_installation_point_update_confirm.Contents;
        }
        else
        {
            if (dbLoggerConfiguration == null)
            {
                _loggerConfigurationBL.InsertLoggerConfiguration(loggerConfiguration);
            }
            else
            {
                loggerConfiguration.ForwardFlow = dbLoggerConfiguration.ForwardFlow;
                loggerConfiguration.Pressure1   = dbLoggerConfiguration.Pressure1;
                loggerConfiguration.Pressure2   = dbLoggerConfiguration.Pressure2;
                loggerConfiguration.ReverseFlow = dbLoggerConfiguration.ReverseFlow;
                _loggerConfigurationBL.UpdateLoggerConfiguration(loggerConfiguration, dbLoggerConfiguration);
            }
            _siteBL.UpdateSite(site, dbSite);
            ntf.Text = "Data saved.";
        }
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Pi-solution developer - multi languages
        if (!IsPostBack)
        {
            language = (Session["myapplication.language"] == null) ? "vi" : Session["myapplication.language"].ToString();

            List <t_LanguageTranslate> listLanguage = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("/Supervisor/Logger/DetailTable.aspx")).ToList();

            //Parse content to form
            var var1 = listLanguage.Where(x => x.ControlId.Contains("lbFrom")).FirstOrDefault();
            lbFrom.Text = (var1 == null) ? "" : var1.Contents;
            var var2 = listLanguage.Where(x => x.ControlId.Contains("lbTo")).FirstOrDefault();
            lbTo.Text = (var2 == null) ? "" : var2.Contents;

            var var3 = listLanguage.Where(x => x.ControlId.Contains("btnView")).FirstOrDefault();
            btnView.Text = (var3 == null) ? "" : var3.Contents;
            var var4 = listLanguage.Where(x => x.ControlId.Contains("btnExport")).FirstOrDefault();
            btnExport.Text = (var4 == null) ? "" : var4.Contents;

            // Title
            var var5 = listLanguage.Where(x => x.ControlId.Contains("lbTitleContent")).FirstOrDefault();
            tileContent = (var5 == null) ? "" : var5.Contents;

            // Change header of rad grid
            var var15 = listLanguage.Where(x => x.ControlId.Contains("grv_TimeStamp")).FirstOrDefault();
            grv.MasterTableView.GetColumn("column3").HeaderText = (var15 == null) ? "" : var15.Contents;
            var var16 = listLanguage.Where(x => x.ControlId.Contains("grv_FlowRate")).FirstOrDefault();
            grv.MasterTableView.GetColumn("column").HeaderText = (var16 == null) ? "" : var16.Contents;
            var var17 = listLanguage.Where(x => x.ControlId.Contains("grv_ForwardIndex")).FirstOrDefault();
            grv.MasterTableView.GetColumn("column2").HeaderText = (var17 == null) ? "" : var17.Contents;
            var var18 = listLanguage.Where(x => x.ControlId.Contains("grv_ReverseIndex")).FirstOrDefault();
            grv.MasterTableView.GetColumn("column4").HeaderText = (var18 == null) ? "" : var18.Contents;
            var var19 = listLanguage.Where(x => x.ControlId.Contains("grv_NetIndex")).FirstOrDefault();
            grv.MasterTableView.GetColumn("column5").HeaderText = (var19 == null) ? "" : var19.Contents;
            var var20 = listLanguage.Where(x => x.ControlId.Contains("grv_Pressure")).FirstOrDefault();
            grv.MasterTableView.GetColumn("column1").HeaderText = (var20 == null) ? "" : var20.Contents;
        }

        CultureInfo culture = new CultureInfo("en-GB");
        string      siteID  = Request.QueryString["si"];
        double      oADate  = double.Parse(Request.QueryString["dt"]);
        DateTime    date    = DateTime.FromOADate(oADate);
        t_Sites     site    = _siteBL.GetSite(siteID);
        var         list    = _loggerDataHelper.GetComplexLoggerData(site.SiteId, date, date);

        lblTitle.Text  = tileContent + " " + site.SiteAliasName + " (" + site.Location + ") " + date.ToString("dd-MM-yyyy");
        grv.DataSource = list;
        grv.DataBind();
        grv.ExportSettings.FileName = site.SiteAliasName + "_" + date.ToString("yyyy_MM_dd");
        ntf.VisibleOnPageLoad       = false;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CultureInfo culture = new CultureInfo("en-GB");
        string      siteID  = Request.QueryString["si"];
        double      oADate  = double.Parse(Request.QueryString["dt"]);
        DateTime    date    = DateTime.FromOADate(oADate);
        t_Sites     site    = _siteBL.GetSite(siteID);
        var         list    = _loggerDataHelper.GetComplexLoggerData(site.SiteId, date, date);

        lblTitle.Text  = "Chi tiết dữ liệu logger điểm " + site.SiteAliasName + " (" + site.Location + ") " + date.ToString("dd-MM-yyyy");
        grv.DataSource = list;
        grv.DataBind();
        grv.ExportSettings.FileName = site.SiteAliasName + "_" + date.ToString("yyyy_MM_dd");
        ntf.VisibleOnPageLoad       = false;
    }
Пример #6
0
    public IList <ComplexDataViewModel> GetData()
    {
        if (dtmStart.SelectedDate != null && dtmEnd.SelectedDate != null)
        {
            DateTime         startDate    = (DateTime)dtmStart.SelectedDate;
            DateTime         endDate      = (DateTime)dtmEnd.SelectedDate;
            List <string>    loggerIds    = new List <string>();
            DropDownListItem selectedItem = DropDownSite.SelectedItem;
            loggerIds.Add(_siteBL.GetSite(selectedItem.Value).LoggerId);
            var listDailyComplexData = _complexDataHelper.GetDailyComplexData_Multiple(loggerIds, startDate, endDate);

            //var tempMaxFlow = listDailyComplexData.Max(d => d.MaxFlowRate);
            //var maxFlow = listDailyComplexData.Where(d => d.MaxFlowRate == tempMaxFlow).ToList();

            //var tempMinFlow = listDailyComplexData.Min(d => d.MinFlowRate);
            //var minFlow = listDailyComplexData.Where(d => d.MinFlowRate == tempMinFlow).ToList();

            //var tempMaxPress = listDailyComplexData.Max(d => d.MaxPressure);
            //var maxPress = listDailyComplexData.Where(d => d.MaxPressure == tempMaxPress).ToList();

            //var tempMinPress = listDailyComplexData.Min(d => d.MinPressure);
            //var minPress = listDailyComplexData.Where(d => d.MinPressure == tempMinPress).ToList();

            return(listDailyComplexData);
        }
        else
        {
            return(null);
        }
    }
    public mySite GetSite(string siteID)
    {
        SiteBL _siteBL = new SiteBL();
        mySite ms      = new mySite();
        var    s       = _siteBL.GetSite(siteID);

        ms.SiteID = s.SiteAliasName;
        return(ms);
    }
Пример #8
0
    private void SetControlValues(t_Transmitter_Histories transmitterHistory)
    {
        var site = _siteBL.GetSite(transmitterHistory.SiteID);

        cboSiteID.Text = site.SiteAliasName;

        dtmChange.SelectedDate      = transmitterHistory.DateChanged;
        cboOldSerials.SelectedValue = transmitterHistory.OldTransmitterSerial;
        cboNewSerials.SelectedValue = transmitterHistory.NewTransmitterSerial;
        nmrOldIndex.Value           = transmitterHistory.Index;
        txtDescription.Text         = transmitterHistory.Description;
    }
Пример #9
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        string siteID = Request.QueryString["si"];
        var    site   = _siteBL.GetSite(siteID);

        System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en-GB");
        DateTime startDate = DateTime.Parse(Request.QueryString["st"], culture);
        DateTime endDate   = DateTime.Parse(Request.QueryString["en"], culture);

        string filePath = Server.MapPath("~/App_Data/Temp/" + site.SiteId.Replace(' ', '_') + "_from_" + startDate.ToString("yyyy_MM") + "_to_" + endDate.ToString("yyyy_MM") + ".xls");

        if (File.Exists(filePath))
        {
            File.Delete(filePath);
        }
        CreateFile(filePath, siteID, startDate, endDate);
        string subject       = "<" + ConfigurationManager.AppSettings["sCompany"].ToString() + "> Sản lượng " + site.SiteAliasName + "(" + site.Location + ") từ " + startDate.ToString("MM/yyyy") + " đến " + endDate.ToString("MM/yyyy");
        string body          = "FYI,";
        string adminEmail    = ConfigurationManager.AppSettings["mail"].ToString();
        string adminPassword = ConfigurationManager.AppSettings["mailPassword"].ToString();

        SendMail(subject, body, filePath, adminEmail, adminPassword);
    }
    public IList <ComplexDataViewModel> GetData()
    {
        if (myStart.SelectedDate != null && myEnd.SelectedDate != null)
        {
            DateTime startDate = (DateTime)myStart.SelectedDate;
            DateTime endDate   = (DateTime)myEnd.SelectedDate;
            startDate = DateTime.Parse(startDate.ToString("yyyy-MM"));
            endDate   = DateTime.Parse(endDate.ToString("yyyy-MM"));

            List <string> loggerIds = new List <string>();
            foreach (RadListBoxItem item in listBoxSelectedSites.Items)
            {
                loggerIds.Add(_siteBL.GetSite(item.Value).LoggerId);
            }
            var listMonthlyComplexData = _complexDataHelper.GetMonthlyComplexData_Multiple(loggerIds, startDate, endDate);
            return(listMonthlyComplexData);
        }
        else
        {
            return(null);
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        List <t_LanguageTranslate> list = languageBL.FindAll(x => x.Language == language && x.Noted.Contains("/Supervisor/Admin/CreateUser.aspx")).ToList();
        var lb_user_update_confirm      = list.Where(x => x.ControlId.Contains("lb_user_update_confirm")).FirstOrDefault();


        ntf.VisibleOnPageLoad = true;
        bool invalid = IsInvalidInput();

        if (invalid)
        {
            return;
        }
        var user   = GetUser();
        var dbUser = _userBL.GetUser(user.Username);

        if (dbUser == null)
        {
            user.Salt     = _stringUTL.CreateSalt(8);
            user.Password = _stringUTL.HashMD5(_stringUTL.HashMD5(user.Password) + user.Salt);

            _userBL.InsertUser(user);
            ntf.Text = "Đã thêm mới người dùng.";
        }
        else
        {
            if (!string.Equals(user.Password, "********"))
            {
                user.Salt     = _stringUTL.CreateSalt(8);
                user.Password = _stringUTL.HashMD5(_stringUTL.HashMD5(user.Password) + user.Salt);
                string staff = user.StaffId + ";";
                foreach (RadListBoxItem item in listBoxSelectedSites.Items)
                {
                    //loggerIds.Add(_siteBL.GetSite(item.Value).LoggerId);
                    string logger = _siteBL.GetSite(item.Value).LoggerId;
                    //update t_site set staffid =staff where loggerid = logger

                    using (SqlConnection connection = new SqlConnection(connectionString))
                    {
                        string     cmdText = "UPDATE [t_Sites] SET [Staffs]=CONCAT('" + staff + "',[Staffs]) WHERE [LoggerId] = '" + logger + "'";
                        SqlCommand cmd     = new SqlCommand(cmdText, connection);
                        connection.Open();
                        cmd.ExecuteReader();

                        // SqlDataReader rd = cmd.ExecuteReader();
                        // rd.Read();
                        connection.Close();
                    }//end using
                }
            }
            else
            {
                user.Salt     = dbUser.Salt;
                user.Password = dbUser.Password;
                string staff = user.StaffId + ";";
                foreach (RadListBoxItem item in listBoxSelectedSites.Items)
                {
                    //loggerIds.Add(_siteBL.GetSite(item.Value).LoggerId);
                    string logger = _siteBL.GetSite(item.Value).LoggerId;
                    //update t_site set staffid =staff where loggerid = logger

                    using (SqlConnection connection = new SqlConnection(connectionString))
                    {
                        string cmdText = "UPDATE [dbo].[t_Sites] SET [Staffs]=CONCAT('" + staff + "',[Staffs]) WHERE [LoggerId] = '" + logger + "'";
                        //string cmdText = "UPDATE [dbo].[t_Sites] SET [Staffs]=  [Staffs] + '" + staff + "'  WHERE [LoggerId] = '" + logger + "'";

                        SqlCommand cmd = new SqlCommand(cmdText, connection);
                        connection.Open();
                        cmd.ExecuteReader();

                        // SqlDataReader rd = cmd.ExecuteReader();
                        // rd.Read();
                        connection.Close();
                    }//end using
                }
            }
            _userBL.UpdateUser(user, dbUser);
            //ntf.Text = "Đã cập nhật thông tin người dùng.";
            ntf.Text = lb_user_update_confirm.Contents;
        }
    }
    public List <ReportDataViewModel> GetMonthyReportData(string siteID, DateTime startDate, DateTime endDate)
    {
        List <ReportDataViewModel> listReportDataViewModel = new List <ReportDataViewModel>();
        var site = _siteBL.GetSite(siteID);
        var loggerConfiguration = site.t_Logger_Configurations;

        DateTime start;
        double   startDay  = Convert.ToDouble(site.StartDay);
        double   startHour = Convert.ToDouble(loggerConfiguration.StartHour);

        string channelForward = "";
        string channelReverse = "";

        if (loggerConfiguration.ForwardFlow != null)
        {
            channelForward = _channelConfigurationBL.GetChannelConfigurationByType(loggerConfiguration.LoggerId, "f").ChannelId;
            //string channelForward = loggerConfiguration.LoggerId + "_" + string.Format("{0:00}", loggerConfiguration.ForwardFlow);
        }
        if (loggerConfiguration.ReverseFlow != null)
        {
            channelReverse = _channelConfigurationBL.GetChannelConfigurationByType(loggerConfiguration.LoggerId, "r").ChannelId;
            //string channelReverse = loggerConfiguration.LoggerId + "_" + string.Format("{0:00}", loggerConfiguration.ReverseFlow);
        }

        var listMonthlyComplexDataViewModel = _complexDataHelper.GetMonthlyComplexData(loggerConfiguration.LoggerId, startDate, endDate);

        int interval = 0;//sec

        if (listMonthlyComplexDataViewModel.Count != 0)
        {
            interval = listMonthlyComplexDataViewModel[0].TimeStamp.Second;
        }

        startDate = startDate.AddDays(startDay - 1).AddHours(startHour);
        int totalMonth = (endDate.Year - startDate.Year) * 12 + (endDate.Month - startDate.Month) + 1;

        for (int i = 0; i < totalMonth; i++)
        {
            start = startDate.AddMonths(i);
            ReportDataViewModel data = new ReportDataViewModel();
            data.StartDate     = start;
            data.EndDate       = start.AddMonths(1);
            data.SiteID        = site.SiteId;
            data.SiteAliasName = site.SiteAliasName;
            data.Location      = site.Location;

            var startRecord = _rawIndexBL.GetRawIndex(site.SiteId, data.StartDate);

            if (startRecord != null)
            {
                data.StartIndex = startRecord.Index;
            }

            var endRecord = _rawIndexBL.GetRawIndex(siteID, data.EndDate);

            if (endRecord != null)
            {
                data.EndIndex = endRecord.Index;
            }
            if (startRecord != null && endRecord != null)
            {
                data.Output = data.EndIndex - data.StartIndex;
            }
            listReportDataViewModel.Add(data);
        }
        double startForwardIndex = 0;
        double startReveseIndex  = 0;
        double endForwardIndex   = 0;
        double endReveseIndex    = 0;

        t_Logger_Data startLoggerForwardIndex = null;
        t_Logger_Data startLoggerReveseIndex  = null;
        t_Logger_Data endLoggerForwardIndex   = null;
        t_Logger_Data endLoggerReveseIndex    = null;

        for (int i = 0; i < listReportDataViewModel.Count; i++)
        {
            if (listReportDataViewModel[i].Output == null)
            {
                var complexData = listMonthlyComplexDataViewModel.Where(d => d.SiteID == listReportDataViewModel[i].SiteID && d.TimeStamp == listReportDataViewModel[i].StartDate.AddHours(1)).SingleOrDefault();
                if (complexData == null)//Inventia
                {
                    complexData = listMonthlyComplexDataViewModel.Where(d => d.SiteID == listReportDataViewModel[i].SiteID && d.TimeStamp == listReportDataViewModel[i].StartDate.AddHours(1).AddSeconds(1)).SingleOrDefault();
                }
                if (complexData != null)
                {
                    listReportDataViewModel[i].Output = complexData.Output;
                    if (loggerConfiguration.ForwardFlow != null)
                    {
                        startLoggerForwardIndex = _loggerDataBL.GetLoggerIndex(channelForward, listReportDataViewModel[i].StartDate);
                        if (startLoggerForwardIndex == null)
                        {
                            startLoggerForwardIndex = _loggerDataBL.GetLoggerIndex(channelForward, listReportDataViewModel[i].StartDate.AddSeconds(1));
                        }
                        endLoggerForwardIndex = _loggerDataBL.GetLoggerIndex(channelForward, listReportDataViewModel[i].EndDate);
                        if (endLoggerForwardIndex == null)
                        {
                            endLoggerForwardIndex = _loggerDataBL.GetLoggerIndex(channelForward, listReportDataViewModel[i].EndDate.AddSeconds(1));
                        }
                    }
                    if (loggerConfiguration.ReverseFlow != null)
                    {
                        startLoggerReveseIndex = _loggerDataBL.GetLoggerIndex(channelReverse, listReportDataViewModel[i].StartDate);
                        if (startLoggerReveseIndex == null)
                        {
                            startLoggerReveseIndex = _loggerDataBL.GetLoggerIndex(channelReverse, listReportDataViewModel[i].StartDate.AddSeconds(1));
                        }
                        endLoggerReveseIndex = _loggerDataBL.GetLoggerIndex(channelReverse, listReportDataViewModel[i].EndDate);
                        if (endLoggerReveseIndex == null)
                        {
                            endLoggerReveseIndex = _loggerDataBL.GetLoggerIndex(channelReverse, listReportDataViewModel[i].EndDate.AddSeconds(1));
                        }
                    }

                    startForwardIndex = 0;
                    startReveseIndex  = 0;
                    endForwardIndex   = 0;
                    endReveseIndex    = 0;

                    if (startLoggerForwardIndex != null)
                    {
                        startForwardIndex = startLoggerForwardIndex.Value ?? 0;
                    }
                    if (startLoggerReveseIndex != null)
                    {
                        startReveseIndex = startLoggerReveseIndex.Value ?? 0;
                    }
                    if (endLoggerForwardIndex != null)
                    {
                        endForwardIndex = endLoggerForwardIndex.Value ?? 0;
                    }
                    if (endLoggerReveseIndex != null)
                    {
                        endReveseIndex = endLoggerReveseIndex.Value ?? 0;
                    }
                    listReportDataViewModel[i].StartIndex = startForwardIndex - startReveseIndex;
                    listReportDataViewModel[i].EndIndex   = endForwardIndex - endReveseIndex;
                }
            }
        }
        return(listReportDataViewModel);
    }