Пример #1
0
        public ZeroResponse<Dictionary<int, int>> GetExistingPacks(string ID)
        {
            var ret = new ZeroResponse<Dictionary<int, int>>();
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                ret.Result = Config.GetPacksToSend(hlp.TerminalCode);
                            }
                            else
                            {
                                if (hlp.TerminalCode >= 0)
                                    Config.UpdateConnectionStatus(ID, ZeroServerConfiguration.ConnectionState.Error);
                            }
                        }
                    });

                ret.IsValid = hlp.IsValid;
                ret.Message = hlp.StatusMessage;
            }

            return ret;
        }
Пример #2
0
        public ZeroResponse<string> GetServerProperties(string ID)
        {
            var ret = new ZeroResponse<string>();
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                IEnumerable<TerminalProperty> list = Config.GetTerminalProperties(hlp.TerminalCode);
                                ret.Result = ContextExtentions.GetEntitiesAsXMLObjectList(list);
                            }
                        }
                    });

                ret.IsValid = hlp.IsValid;
                ret.Message = hlp.StatusMessage;
            }
            return ret;
        }
Пример #3
0
        public ZeroResponse<bool> SendClientTerminals(string ID, string terminals)
        {
            var ret = new ZeroResponse<bool>();

            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID, terminals))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                ret.Result = true;
                                Config.MergeTerminal(hlp.TerminalCode, ContextExtentions.GetEntitiesFromXMLObjectList<Terminal>(terminals));
                            }
                        }
                    });

                ret.IsValid = hlp.IsValid;
                ret.Message = hlp.StatusMessage;
            }

            return ret;
        }
Пример #4
0
        public ZeroResponse<bool> SendClientModules(string ID, string modules)
        {
            var ret = new ZeroResponse<bool>();
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID, modules))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                IEnumerable<Module> mods = ContextExtentions.GetEntitiesFromXMLObjectList<Module>(modules);
                                Config.MergeModules(mods, hlp.TerminalCode);
                                ret.Result = true;
                            }
                        }

                    });

                ret.IsValid = hlp.IsValid;
                ret.Message = hlp.StatusMessage;
            };

            return ret;
        }
Пример #5
0
        public ZeroResponse<string> SayHello(string name, int terminal)
        {
            var ret = new ZeroResponse<string>();
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, "", name, terminal))
            {
                hlp.TerminalCode = terminal;
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateTerminal(terminal, name, out hlp.StatusMessage))
                            {
                                string ip = GetWCFMethodCallerIp();
                                ret.Result = Config.CreateConnection(terminal, ip);
                                Trace.WriteLine(string.Format("Iniciando Conexión con terminal {0} - ID {1} - ConnID {2} - IP: {3}", name, terminal, ret.Result, ip));
                            }
                        }
                    });

                ret.IsValid = hlp.IsValid;
                ret.Message = hlp.StatusMessage;
            }

            return ret;
        }
Пример #6
0
        public ZeroResponse<DateTime> SayBye(string ID)
        {
            var ret = new ZeroResponse<DateTime>();
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                Config.UpdateConnectionStatus(ID, ZeroServerConfiguration.ConnectionState.Ended);
                                ret.Result = DateTime.Now;
                                Trace.WriteLine(string.Format("Finalizando Conexión con terminal ID {0} - ConnID {1}", hlp.TerminalCode, ID));
                            }
                            else
                            {
                                if (hlp.TerminalCode >= 0)
                                    Config.UpdateConnectionStatus(ID, ZeroServerConfiguration.ConnectionState.Error);

                                ret.Result = DateTime.MinValue;
                            }
                        }
                    });

                ret.Message = hlp.StatusMessage;
                ret.IsValid = hlp.IsValid;
            }

            return ret;
        }
Пример #7
0
        public ZeroResponse<bool> MarkPackReceived(string ID, int packCode)
        {
            var ret = new ZeroResponse<bool>();
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID, packCode))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                Config.MarkPackReceived(hlp.TerminalCode, packCode);
                                ret.Result = true;
                            }
                            else
                            {
                                ret.Result = false;
                            }
                        }
                    });

                ret.Message = hlp.StatusMessage;
                ret.IsValid = hlp.IsValid;

            }

            return ret;
        }