Exemplo n.º 1
0
        public object[] PerformQuery(string QueryName, params object[] Parameters)
        {
            PackageViaWireless Package = new PackageViaWireless(0, true);

            Package.DefineQueryAndParams(QueryName, PackageConvertation.GetStrPatametersFromArray(Parameters));
            Package.ClientCode = User;
            ConnectionAgent.WaitingPackageID = Package.PackageID;
            ConnectionAgent.Executed         = false;
            MainForm.ShowQueryWait();
            if (ConnectionAgent.SendPackage(Package.GetPackage()))
            {
                while (!ConnectionAgent.RequestReady & ConnectionAgent.OnLine)
                {
                    Thread.Sleep(300);
                }

                MainForm.ShowQueryComplated();

                if (ConnectionAgent.Package == null || !ConnectionAgent.Executed)
                {
                    Process.ShowMessage("Пропала связь с сервером!");
                    return(null);
                }
                if (ConnectionAgent.Package.Parameters == "#ERROR:1C_AGENT_DISABLE#")
                {
                    ConnectionAgent.Package.Parameters = string.Empty;
                    ConnectionAgent.RequestReady       = false;
                    Process.ShowMessage("1С-агент неактивен. Обратитесь к оператору!");
                    return(null);
                }
                object[] result = PackageConvertation.GetPatametersFromStr(ConnectionAgent.Package.Parameters);

                ConnectionAgent.RequestReady = false;

                if (result.Length == 0)
                {
                    return(null);
                }
                if (result.GetType() == typeof(object[]) && result.Length == 1 && result[0] == null)
                {
                    return(null);
                }
                return(result);
            }
            return(null);
        }
Exemplo n.º 2
0
        public object[] PerformQuery(string QueryName, params object[] Parameters)
        {
            Current.LastQueryIsSuccessfull = false;
            if (!Current.OnLine && Current.MainForm.IsMainThread)
            {
                //"Нет подключения к серверу".Warning();
                return(null);
            }

            PackageViaWireless Package = new PackageViaWireless(0, true);

            Package.DefineQueryAndParams(QueryName, PackageConvertation.GetStrPatametersFromArray(Parameters));
            Package.ClientCode = User;
            ConnectionAgent.WaitingPackageID = Package.PackageID;
            ConnectionAgent.Executed         = false;
            MainForm.ShowQueryWait();
            if (ConnectionAgent.SendPackage(Package.GetPackage()))
            {
                var stopWatch = new Stopwatch();
                stopWatch.Start();
                while (!ConnectionAgent.RequestReady & ConnectionAgent.OnLine)
                {
                    Thread.Sleep(300);

                    const int MAX_WAIT_TIME_MILISEC = 5000;
                    if (stopWatch.ElapsedMilliseconds > MAX_WAIT_TIME_MILISEC)
                    {
                        RemoteCallDialog.WaitForServerResponse();
                        break;
                    }
                }

                if (!Current.ConnectionAgent.WifiEnabled)
                {
                    Thread.Sleep(1000);
                    Current.StartConnectionAgent();
                }

                MainForm.ShowQueryComplated();

                if (ConnectionAgent.Package == null || !ConnectionAgent.Executed)
                {
                    "Пропала связь с сервером!".ShowMessage();
                    return(null);
                }
                //if (ConnectionAgent.Package.Parameters == "#ERROR:1C_AGENT_DISABLE#")
                //    {
                //    ConnectionAgent.Package.Parameters = string.Empty;
                //    ConnectionAgent.RequestReady = false;
                //    "1С-агент неактивен. Обратитесь к оператору!".ShowMessage();
                //    return null;
                //    }
                object[] result = PackageConvertation.GetPatametersFromStr(ConnectionAgent.Package.Parameters);

                ConnectionAgent.RequestReady = false;

                if (result.Length == 0 ||
                    (result.GetType() == typeof(object[]) && result.Length == 1 && result[0] == null))
                {
                    return(null);
                }

                LastQueryIsSuccessfull = true;
                return(result);
            }
            return(null);
        }