public void NextJob(NbtAuth auth, PrinterSetupData aprinter)
        {
            NbtPublicClient NbtClient = _getClient(auth);

            NextJobEventArgs e = new NextJobEventArgs();

            e.printer.PrinterKey  = aprinter.PrinterKey;
            e.printer.PrinterName = aprinter.PrinterName;
            e.printer.LPCname     = aprinter.LPCname;
            e.auth.AccessId       = auth.AccessId;
            e.auth.UserId         = auth.UserId;
            e.auth.Password       = auth.Password;
            e.auth.baseURL        = auth.baseURL;
            e.auth.useSSL         = auth.useSSL;

            CswNbtLabelJobRequest labelReq = new CswNbtLabelJobRequest();

            labelReq.PrinterKey = e.printer.PrinterKey;

            CswNbtLabelJobResponse Ret;

            using (OperationContextScope Scope = new OperationContextScope(NbtClient.InnerChannel))
            {
                WebOperationContext.Current.OutgoingRequest.Headers.Add("X-NBT-SessionId", auth.sessionId);
                Ret = NbtClient.LpcGetNextJob(labelReq);
            }

            if (Ret.Authentication.AuthenticationStatus == "NonExistentSession")
            {
                //the old session has timed out, and we need to authenticate again
                CswNbtWebServiceSessionCswNbtAuthReturn authAttempt = _Authenticate(auth, e, NbtClient);
                if (authAttempt.Authentication.AuthenticationStatus == "Authenticated")
                {
                    NextJob(auth, aprinter);
                }
            }
            else if (Ret.Authentication.AuthenticationStatus == "Authenticated")
            {
                if (Ret.Status.Success)
                {
                    e.Succeeded      = true;
                    e.Job            = Ret;
                    aprinter.LPCname = Ret.PrinterName;
                }
                else
                {
                    e.Message = "Error calling NextLabelJob web service. ";
                    if (Ret.Status.Errors.Length > 0)
                    {
                        e.Message += Ret.Status.Errors[0].Message;
                    }
                }


                if (OnNextJob != null)
                {
                    OnNextJob(e);
                }
            }
        }//NextJob()
Example #2
0
        public CswNbtLabelJobResponse LpcGetNextJob(CswNbtLabelJobRequest Request)
        {
            //delegate has to be static because you can't create an instance yet: you don't have resources until the delegate is actually called
            CswNbtLabelJobResponse Ret = new CswNbtLabelJobResponse();
            var SvcDriver = new CswWebSvcDriver <CswNbtLabelJobResponse, CswNbtLabelJobRequest>(
                CswWebSvcResourceInitializer: new CswWebSvcResourceInitializerNbt(_Context, null),
                ReturnObj: Ret,
                WebSvcMethodPtr: CswNbtWebServicePrintLabels.nextLabelJob,
                ParamObj: Request
                );

            SvcDriver.run();
            return(Ret);
        }