Esempio n. 1
0
        public ZeroResponse<string[]> GetExistingPacks(string ID)
        {
            ZeroResponse<string[]> ret = new ZeroResponse<string[]>
            {
                IsValid = true,
            };

            using (ZeroServerConfiguration Config = new ZeroServerConfiguration())
            {
                int TCode = 0;
                string msg = "";
                bool stat = Config.ValidateConnection(ID, out TCode, out msg);
                if (stat)
                {
                    ret.Result = Config.GetPackNamesToSend(TCode);
                }
                else
                {
                    if (TCode > 0)
                        Config.UpdateConnectionStatus(ID, ZeroServerConfiguration.ConnectionState.Error);
                }
                ret.Status = msg;
            }

            return ret;
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        public ZeroResponse<string> GetTerminals(string ID)
        {
            var ret = new ZeroResponse<string>();
            ret.IsValid = false;
            using (var hlp = new ServiceLogHelper(System.Reflection.MethodBase.GetCurrentMethod().Name, ID))
            {
                hlp.Handle(() =>
                    {
                        using (var Config = new ZeroServerConfiguration())
                        {
                            int tCode = -1;
                            if (Config.ValidateConnection(ID, out hlp.TerminalCode, out hlp.StatusMessage))
                            {
                                IEnumerable<Terminal> list = Config.GetTerminals(tCode);
                                ret.Result = ContextExtentions.GetEntitiesAsXMLObjectList(list);
                            }

                        }
                    });

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

            return ret;
        }
Esempio n. 4
0
        public ZeroResponse<string> GetTerminals(string ID)
        {
            ZeroResponse<string> ret = new ZeroResponse<string>();
            ret.IsValid = true;
            using (ZeroServerConfiguration Config = new ZeroServerConfiguration())
            {
                string msg;
                int tCode = -1;
                if (Config.ValidateConnection(ID, out tCode, out msg))
                {
                    IEnumerable<Terminal> list = Config.GetTerminals(tCode);
                    ret.Result = ZeroCommonClasses.Helpers.IEnumerableExtentions.GetEntitiesAsXMLObjectList<Terminal>(list);
                }

                ret.Status = msg;
            }
            return ret;
        }
Esempio n. 5
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;
        }
Esempio n. 6
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;
        }
Esempio n. 7
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;
        }
Esempio n. 8
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;
        }
Esempio n. 9
0
        public ZeroResponse<bool> MarkPackReceived(string ID, string packName)
        {
            ZeroResponse<bool> ret = new ZeroResponse<bool>();
            ret.IsValid = true;
            using (ZeroServerConfiguration Config = new ZeroServerConfiguration())
            {
                string msg;
                int tCode = -1;
                if (Config.ValidateConnection(ID, out tCode, out msg))
                {
                    Config.MarkPackReceived(tCode, packName);
                    ret.Result = true;
                }

                ret.Result = false;
                ret.Status = msg;
            }

            return ret;
        }
Esempio n. 10
0
        public ZeroResponse<bool> SendClientTerminals(string ID, string terminals)
        {
            ZeroResponse<bool> ret = new ZeroResponse<bool>();
            ret.IsValid = true;
            using (ZeroServerConfiguration Config = new ZeroServerConfiguration())
            {
                string msg;
                int tCode = -1;
                if (Config.ValidateConnection(ID, out tCode, out msg))
                {
                    ret.Result = true;
                    Config.MergeTerminal(tCode, IEnumerableExtentions.GetEntitiesFromXMLObjectList<Terminal>(terminals));
                }

                ret.Result = false;
                ret.Status = msg;
            }

            return ret;
        }
Esempio n. 11
0
        public ZeroResponse<bool> SendClientModules(string ID, string modules)
        {
            int TCode = 0;
            string msg = "";
            bool stat = true;
            using (ZeroServerConfiguration Config = new ZeroServerConfiguration())
            {
                stat = Config.ValidateConnection(ID, out TCode, out msg);
                if (stat)
                {
                    IEnumerable<Module> mods = IEnumerableExtentions.GetEntitiesFromXMLObjectList<Module>(modules);
                    Config.MergeModules(mods, TCode);
                }
            }
            ZeroResponse<bool> ret = new ZeroResponse<bool>
            {
                IsValid = stat,
                Result = stat,
                Status = (stat) ? "OK" : msg
            };

            return ret;
        }
Esempio n. 12
0
        public ZeroResponse<DateTime> SayBye(string ID)
        {
            ZeroResponse<DateTime> ret = new ZeroResponse<DateTime>();
            ret.IsValid = true;
            using (ZeroServerConfiguration Config = new ZeroServerConfiguration())
            {
                string msg;
                int tCode = -1;
                if (Config.ValidateConnection(ID, out tCode, out msg))
                {
                    Config.UpdateConnectionStatus(ID, ZeroServerConfiguration.ConnectionState.Ended);
                    ret.Result = DateTime.Now;
                }
                else
                {
                    if (tCode >= 0)
                        Config.UpdateConnectionStatus(ID, ZeroServerConfiguration.ConnectionState.Error);

                    ret.Result = DateTime.MinValue;
                    ret.Status = msg;
                }
            }

            return ret;
        }