private DataSourceHolder dataSourceHolder; // holds data sources /// <summary> /// Initializes a new instance of the class. /// </summary> public CoreLogic(CommConfig config, CommDirs appDirs, ILog log) { Config = config ?? throw new ArgumentNullException(nameof(config)); AppDirs = appDirs ?? throw new ArgumentNullException(nameof(appDirs)); Log = log ?? throw new ArgumentNullException(nameof(log)); BaseDataSet = null; SharedData = null; infoFileName = Path.Combine(appDirs.LogDir, CommUtils.InfoFileName); commLineLock = new object(); thread = null; terminated = false; utcStartDT = DateTime.MinValue; startDT = DateTime.MinValue; serviceStatus = ServiceStatus.Undefined; lastInfoLength = 0; maxLineTitleLength = -1; commLines = null; commLineMap = null; deviceMap = null; commandReader = null; driverHolder = null; dataSourceHolder = null; }
public void InitFunc() { try { CommConfig cfg = new CommConfig(); cfg.commType = CommType.RS232; cfg.PortName = comboBox1.SelectedItem.ToString(); cfg.BaudRate = 115200; cfg.DataBit = 8; cfg.parity = System.IO.Ports.Parity.None; cfg.stopbit = System.IO.Ports.StopBits.One; L2Handler = new L2Process(cfg); L2Handler.CallbackFunc = new L2CallbackDataReceived(DataRecvFunc); L2Handler.bIsNeedACK = 0; L2Handler.bIsEnableEncrypt = 0; L2Handler.u8NumResend = 2; L2Handler.L2Start(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); throw ex; } // Test(); }
public DependecyConfig(bool bGenerate = false) { Id = "IdDep"; Comm = new CommConfig(); SactaProtocol = new SactaProtocolConfig(bGenerate); Sectorization = new SectorizationDataConfig(bGenerate); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmGeneralOptions(ILog log, CommApp commApp) : this() { this.log = log ?? throw new ArgumentNullException(nameof(log)); this.commApp = commApp ?? throw new ArgumentNullException(nameof(commApp)); commConfig = commApp.AppConfig; changing = false; }
public static void InsertNewEntiy(CommConfig NewCommConfig) { using (DistributionContext context = new DistributionContext()) { NewCommConfig.c_id = Guid.NewGuid().ToString(); context.t_common_config.Add(NewCommConfig); context.SaveChanges(); } }
public static void UpdateEntity(CommConfig UpdateCommConfig) { using (DistributionContext context = new DistributionContext()) { CommConfig ag = context.t_common_config.Find(UpdateCommConfig.c_id); CommLogic.DeepClone <CommConfig>(ag, UpdateCommConfig); context.SaveChanges(); } }
public static void DeleteEntity(string CommConfigId) { using (DistributionContext context = new DistributionContext()) { CommConfig DelCommConfig = context.t_common_config.Find(CommConfigId); context.t_common_config.Remove(DelCommConfig); context.SaveChanges(); } }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmDataSources(IAdminContext adminContext, CommApp commApp) : this() { this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext)); this.commApp = commApp ?? throw new ArgumentNullException(nameof(commApp)); commConfig = commApp.AppConfig; changing = false; dataSourceClipboard = null; SetColumnNames(); }
/// <summary> /// Starts the service. /// </summary> public bool StartService() { #if DEBUG System.Diagnostics.Debugger.Launch(); #endif string exeDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); AppDirs.Init(exeDir); LogFile logFile = new LogFile(LogFormat.Full, Path.Combine(AppDirs.LogDir, CommUtils.LogFileName)) { Capacity = int.MaxValue }; log = logFile; log.WriteBreak(); if (!Locale.LoadCulture(Path.Combine(exeDir, "..", "Config", InstanceConfig.DefaultFileName), out string errMsg)) { log.WriteError(errMsg); } log.WriteAction(Locale.IsRussian ? "Коммуникатор {0} запущен" : "Communicator {0} started", CommUtils.AppVersion); if (AppDirs.CheckExistence(out errMsg)) { LocalizeApp(AppDirs.LangDir); string configFileName = Path.Combine(AppDirs.ConfigDir, CommConfig.DefaultFileName); CommConfig config = new CommConfig(); coreLogic = new CoreLogic(config, AppDirs, log); if (config.Load(configFileName, out errMsg) && coreLogic.StartProcessing()) { logFile.Capacity = config.GeneralOptions.MaxLogSize; return(true); } else if (!string.IsNullOrEmpty(errMsg)) { log.WriteError(errMsg); } } else { log.WriteError(errMsg); } log.WriteError(CommonPhrases.ExecutionImpossible); return(false); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public FrmSync(IAdminContext adminContext, ScadaProject project, CommApp commApp) : this() { this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext)); this.project = project ?? throw new ArgumentNullException(nameof(project)); this.commApp = commApp ?? throw new ArgumentNullException(nameof(commApp)); commConfig = commApp.AppConfig; lastErrorMessage = ""; SelectedLineNum = 0; AddedToComm = false; }
public void ProcessRequest(HttpContext context) { string result = "{{\"msg\":\"{0}\",\"result\":\"{1}\"}}"; CommConfig config = CommConfig.GetConfig(); string name = WebHelper.GetString("name"); AdminInfo admin = Admins.Instance.GetAdminByName(name); if (admin != null && admin.ID != WebHelper.GetInt("id")) { HttpContext.Current.Response.Write(string.Format(result, "用户名已使用", "error")); } else { HttpContext.Current.Response.Write(string.Format(result, "用户名通过验证", "success")); } WebHelper.SetNotCache(); }
public void ProcessRequest(HttpContext context) { string result = "{{\"msg\":\"{0}\",\"result\":\"{1}\",\"isdel\":\"{2}\",\"id\":\"{3}\"}}"; CommConfig config = CommConfig.GetConfig(); string phone = WebHelper.GetString("phone"); int corpid = WebHelper.GetInt("corpid"); CustomerInfo customer = Customers.Instance.GetCustomerByPhone(phone, corpid); if (customer != null) { HttpContext.Current.Response.Write(string.Format(result, "该客户电话已经存在", "error", customer.DelState, customer.ID)); } else { HttpContext.Current.Response.Write(string.Format(result, "该客户电话通过验证", "success", string.Empty, string.Empty)); } WebHelper.SetNotCache(); }
/// <summary> /// Permite enviar a la impresora los dostos del ticket, este método usa la /// libreria dll de zebra /// </summary> /// <param name="pTicket">Información que será impresa</param> /// <param name="pPuerto">Número de Puerto COM al que se enviará la impresión</param> public void EnviarDatosImpresora(CpclLabel pTicket, string pPuerto) { CommConfig cCommConfig = new CommConfig(); cCommConfig.CommunicationMode = 2; //Bluetooth cCommConfig.BtPort = pPuerto; Comm cComm = new Comm(cCommConfig); bool conectado = cComm.IsConnected; try { Printer impresora = new Printer(cCommConfig); impresora.Print(pTicket); cComm.Close(); } catch (Exception ex) { MessageBox.Show("Error al enviar datos a la mpresora: " + ex.Message); } }
/// <summary> /// Fills the tree view according to the Communicator configuration. /// </summary> public void FillTreeView(CommConfig commConfig, int selectedLineNum) { ArgumentNullException.ThrowIfNull(commConfig, nameof(commConfig)); try { treeView.BeginUpdate(); treeView.Nodes.Clear(); foreach (LineConfig lineConfig in commConfig.Lines) { TreeNode lineNode = new(CommUtils.GetLineTitle(lineConfig)) { Tag = new TreeNodeTag(lineConfig, CommNodeType.Line) }; foreach (DeviceConfig deviceConfig in lineConfig.DevicePolling) { lineNode.Nodes.Add(new TreeNode(CommUtils.GetDeviceTitle(deviceConfig)) { Tag = new TreeNodeTag(deviceConfig, CommNodeType.Device) }); } treeView.Nodes.Add(lineNode); if (lineConfig.CommLineNum == selectedLineNum) { lineNode.Checked = true; lineNode.Expand(); } } } finally { treeView.EndUpdate(); } }
/// <summary> /// Starts the service. /// </summary> public bool StartService() { #if DEBUG System.Diagnostics.Debugger.Launch(); #endif // load instance configuration AppDirs.Init(Assembly.GetExecutingAssembly()); InstanceConfig instanceConfig = new InstanceConfig(); Locale.SetCultureToEnglish(); if (instanceConfig.Load(InstanceConfig.GetConfigFileName(AppDirs.InstanceDir), out string errMsg)) { Locale.SetCulture(instanceConfig.Culture); AppDirs.UpdateLogDir(instanceConfig.LogDir); } else { Console.WriteLine(errMsg); Locale.SetCultureToDefault(); } // initialize log LogFile logFile = new LogFile(LogFormat.Full, Path.Combine(AppDirs.LogDir, CommUtils.LogFileName)) { Capacity = int.MaxValue }; log = logFile; log.WriteBreak(); // prepare to start service log.WriteAction(Locale.IsRussian ? "Коммуникатор {0} запущен" : "Communicator {0} started", EngineUtils.AppVersion); storageWrapper = new StorageWrapper(new StorageContext { App = ServiceApp.Comm, AppDirs = AppDirs, Log = log }, instanceConfig); CommConfig appConfig = new CommConfig(); if (AppDirs.CheckExistence(out errMsg) && LocalizeApp() && storageWrapper.InitStorage() && appConfig.Load(storageWrapper.Storage, CommConfig.DefaultFileName, out errMsg)) { // start service logFile.CapacityMB = appConfig.GeneralOptions.MaxLogSize; coreLogic = new CoreLogic(appConfig, AppDirs, storageWrapper.Storage, log); if (coreLogic.StartProcessing()) { return(true); } } else if (!string.IsNullOrEmpty(errMsg)) { log.WriteError(errMsg); } log.WriteError(CommonPhrases.ExecutionImpossible); return(false); }
/// <summary> /// Constructor /// </summary> /// <param name="baseAddress"></param> /// <param name="port"></param> public CoreBuilderHost(string baseAddress, string port) : base(Identity.ChildProcess) { this.baseStorageFolder = base.defaultConfigs[Identity.MotherProcess].BaseDirectory + "\\" + port; this.config = new CommConfig(Identity.ChildProcess, baseAddress, port, this.baseStorageFolder); }
/// <summary> /// Constructor. /// </summary> /// <param name="baseAddress"></param> /// <param name="port"></param> public WPFCommunicationBridge() : base(Identity.Client) { CommConfig config = new CommConfig(base.identity, "localhost", "8085", null); this.StartListener(config); }
/// <summary> /// Recreates the application configuration. /// </summary> protected override void RenewConfig() { AppConfig = new CommConfig(); }
/// <summary> /// Clears the application configuration. /// </summary> public override void ClearConfig() { base.ClearConfig(); Config = new CommConfig(); }