コード例 #1
0
    private t_Channel_Configurations GetChannelConfiguration()
    {
        t_Channel_Configurations channelConfiguration = new t_Channel_Configurations();

        channelConfiguration.ChannelId    = cboChannels.Text;
        channelConfiguration.ChannelName  = txtName.Text;
        channelConfiguration.Description  = txtDescription.Text;
        channelConfiguration.ForwardFlow  = rdoForward.Checked;
        channelConfiguration.LoggerId     = txtLoggerID.Text;
        channelConfiguration.Pressure1    = rdoPressure1.Checked;
        channelConfiguration.Pressure2    = rdoPressure2.Checked;
        channelConfiguration.ReverseFlow  = rdoReverse.Checked;
        channelConfiguration.Unit         = cboUnits.Text;
        channelConfiguration.ChannelOther = rdoChannelOther.Checked;
        if (rdoIsShowLable.Checked == true)
        {
            channelConfiguration.DisplayOnLabel = true;
        }
        if (rdonotShowLable.Checked == true)
        {
            channelConfiguration.DisplayOnLabel = false;
        }
        channelConfiguration.t_Logger_Configurations = GetLoggerConfiguration();
        return(channelConfiguration);
    }
コード例 #2
0
        public t_Channel_Configurations GetChannelConfigurationByType(string loggerId, string type)
        {
            t_Channel_Configurations config = new t_Channel_Configurations();

            switch (type)
            {
            case "f":
                config = context.t_Channel_Configurations.Where(c => c.ForwardFlow != null && c.ForwardFlow == true && c.LoggerId == loggerId).FirstOrDefault();
                break;

            case "r":
                config = context.t_Channel_Configurations.Where(c => c.ReverseFlow != null && c.ReverseFlow == true && c.LoggerId == loggerId).FirstOrDefault();
                break;

            case "p1":
                config = context.t_Channel_Configurations.Where(c => c.Pressure1 != null && c.Pressure1 == true && c.LoggerId == loggerId).FirstOrDefault();
                break;

            case "p2":
                config = context.t_Channel_Configurations.Where(c => c.Pressure2 != null && c.Pressure2 == true && c.LoggerId == loggerId).FirstOrDefault();
                break;

            default:
                break;
            }

            return(config);
        }
コード例 #3
0
 public void DeleteChannelConfiguration(t_Channel_Configurations channelConfiguration)
 {
     try
     {
         channelConfigurationRepository.DeleteChannelConfiguration(channelConfiguration);
     }
     catch (Exception ex)
     {
         //
         throw ex;
     }
 }
コード例 #4
0
 public void UpdateChannelConfiguration(t_Channel_Configurations channelConfiguration, t_Channel_Configurations origChannelConfiguration)
 {
     try
     {
         channelConfigurationRepository.UpdateChannelConfiguration(channelConfiguration, origChannelConfiguration);
     }
     catch (Exception ex)
     {
         //
         throw ex;
     }
 }
コード例 #5
0
 private void SetValues(t_Channel_Configurations channelConfiguration)
 {
     cboChannels.Text        = channelConfiguration.ChannelId;
     txtName.Text            = channelConfiguration.ChannelName;
     cboUnits.SelectedValue  = channelConfiguration.Unit;
     txtDescription.Text     = channelConfiguration.Description;
     rdoForward.Checked      = channelConfiguration.ForwardFlow ?? false;
     rdoPressure1.Checked    = channelConfiguration.Pressure1 ?? false;
     rdoPressure2.Checked    = channelConfiguration.Pressure2 ?? false;
     rdoReverse.Checked      = channelConfiguration.ReverseFlow ?? false;
     rdoChannelOther.Checked = channelConfiguration.ChannelOther ?? false;
     if (channelConfiguration.DisplayOnLabel == true)
     {
         rdoIsShowLable.Checked = true;
     }
     else
     {
         rdonotShowLable.Checked = true;
     }
 }
コード例 #6
0
        public void InsertChannelConfiguration(t_Channel_Configurations channelConfiguration)
        {
            try
            {
                var loggerConfiguration   = channelConfiguration.t_Logger_Configurations;
                var dbLoggerConfiguration = context.t_Logger_Configurations.SingleOrDefault(c => c.LoggerId == channelConfiguration.LoggerId);
                if (dbLoggerConfiguration != null)
                {
                    dbLoggerConfiguration.SiteId          = loggerConfiguration.SiteId;
                    dbLoggerConfiguration.StartHour       = loggerConfiguration.StartHour;
                    dbLoggerConfiguration.TelephoneNumber = loggerConfiguration.TelephoneNumber;

                    if (channelConfiguration.ForwardFlow == true)
                    {
                        dbLoggerConfiguration.ForwardFlow = 3;
                    }
                    if (channelConfiguration.Pressure1 == true)
                    {
                        dbLoggerConfiguration.Pressure1 = 1;
                    }
                    if (channelConfiguration.Pressure2 == true)
                    {
                        dbLoggerConfiguration.Pressure2 = 2;
                    }
                    if (channelConfiguration.ReverseFlow == true)
                    {
                        dbLoggerConfiguration.ReverseFlow = 4;
                    }

                    channelConfiguration.t_Logger_Configurations = null;
                }
                context.t_Channel_Configurations.Add(channelConfiguration);
                context.p_Create_Data_Table(channelConfiguration.ChannelId);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                //
                throw ex;
            }
        }
コード例 #7
0
        public void DeleteChannelConfiguration(t_Channel_Configurations channelConfiguration)
        {
            try
            {
                var loggerConfiguration = context.t_Logger_Configurations.SingleOrDefault(c => c.LoggerId == channelConfiguration.LoggerId);


                //Clear
                if (channelConfiguration.ForwardFlow == true)
                {
                    loggerConfiguration.ForwardFlow = null;
                }
                if (channelConfiguration.ReverseFlow == true)
                {
                    loggerConfiguration.ReverseFlow = null;
                }
                if (channelConfiguration.Pressure1 == true)
                {
                    loggerConfiguration.Pressure1 = null;
                }
                if (channelConfiguration.Pressure2 == true)
                {
                    loggerConfiguration.Pressure2 = null;
                }

                context.t_Channel_Configurations.Attach(channelConfiguration);
                context.t_Channel_Configurations.Remove(channelConfiguration);
                context.p_Drop_Data_Table(channelConfiguration.ChannelId);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                //
                throw ex;
            }
        }
コード例 #8
0
        public void UpdateChannelConfiguration(t_Channel_Configurations channelConfiguration, t_Channel_Configurations origChannelConfiguration)
        {
            try
            {
                context.t_Channel_Configurations.Attach(origChannelConfiguration);

                var dbLoggerConfiguration = origChannelConfiguration.t_Logger_Configurations;
                var loggerConfiguration   = channelConfiguration.t_Logger_Configurations;

                if (origChannelConfiguration.Pressure1 == true)
                {
                    dbLoggerConfiguration.Pressure1 = null;
                }
                if (origChannelConfiguration.Pressure2 == true)
                {
                    dbLoggerConfiguration.Pressure2 = null;
                }
                if (origChannelConfiguration.ForwardFlow == true)
                {
                    dbLoggerConfiguration.ForwardFlow = null;
                }
                if (origChannelConfiguration.ReverseFlow == true)
                {
                    dbLoggerConfiguration.ReverseFlow = null;
                }

                origChannelConfiguration.ChannelId      = channelConfiguration.ChannelId;
                origChannelConfiguration.ChannelName    = channelConfiguration.ChannelName;
                origChannelConfiguration.Description    = channelConfiguration.Description;
                origChannelConfiguration.ForwardFlow    = channelConfiguration.ForwardFlow;
                origChannelConfiguration.LoggerId       = channelConfiguration.LoggerId;
                origChannelConfiguration.Pressure1      = channelConfiguration.Pressure1;
                origChannelConfiguration.Pressure2      = channelConfiguration.Pressure2;
                origChannelConfiguration.ReverseFlow    = channelConfiguration.ReverseFlow;
                origChannelConfiguration.Unit           = channelConfiguration.Unit;
                origChannelConfiguration.DisplayOnLabel = channelConfiguration.DisplayOnLabel;
                origChannelConfiguration.ChannelOther   = channelConfiguration.ChannelOther;

                dbLoggerConfiguration.SiteId          = loggerConfiguration.SiteId;
                dbLoggerConfiguration.StartHour       = loggerConfiguration.StartHour;
                dbLoggerConfiguration.TelephoneNumber = loggerConfiguration.TelephoneNumber;



                //Add
                if (channelConfiguration.ForwardFlow == true)
                {
                    dbLoggerConfiguration.ForwardFlow = 3;
                }
                if (channelConfiguration.Pressure1 == true)
                {
                    dbLoggerConfiguration.Pressure1 = 1;
                }
                if (channelConfiguration.Pressure2 == true)
                {
                    dbLoggerConfiguration.Pressure2 = 2;
                }
                if (channelConfiguration.ReverseFlow == true)
                {
                    dbLoggerConfiguration.ReverseFlow = 4;
                }
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                //
                throw ex;
            }
        }