示例#1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private void CheckBatch(Batch pBatch, ParallelLoopState pState, long pIndex)
        {
            string msg = "BatchId " + pBatch.Id;

            if (pBatch.ExportList.Count == 0)
            {
                ++vCheckCount;
                CommIo.Print(msg + "Empty.");
                return;
            }

            Data.Domain.Export e = pBatch.ExportList[0];
            //CommIo.Print(" - First Export Id="+e.Id+", ArtifactId="+e.Artifact.Id+
            //			", FabricId="+e.FabricId);

            var f = new FabricClient();

            f.AppDataProvSession.RefreshTokenIfNecessary();
            f.UseDataProviderPerson = true;

            if (!f.AppDataProvSession.IsAuthenticated)
            {
                throw new Exception("Could not authenticate.");
            }

            FabResponse <FabClass> fr =
                f.Services.Traversal.GetRootStep.ClassId(e.FabricId).Get();

            msg += " \t(" + (++vCheckCount) + " \tof " + vTotalCount + "): \t";

            if (fr == null)
            {
                lock ( vFailList ) {
                    vFailList.Add(pBatch);
                }

                CommIo.Print(msg + "Failed. FabResponse was null.");
                return;
            }

            FabClass c = fr.FirstDataItem();

            if (c == null)
            {
                lock ( vFailList ) {
                    vFailList.Add(pBatch);
                }

                CommIo.Print(msg + "Failed. FabClass was null.");
                return;
            }

            CommIo.Print(msg + "ArtifactId=" + c.ArtifactId + ".");
        }
示例#2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public override void Start()
        {
            try {
                CommIo.Print("Authenticating Fabric DataProvider...");
                var f = new FabricClient();
                f.AppDataProvSession.RefreshTokenIfNecessary();
                f.UseDataProviderPerson = true;

                if (!f.AppDataProvSession.IsAuthenticated)
                {
                    throw new Exception("DataProvider is not authenticated.");
                }

                CommIo.Print("DataProvider authenticated.");
            }
            catch (Exception e) {
                CommIo.Print("Authentication exception: " + e);
                return;
            }

            var sp = new SessionProvider();

            using (ISession sess = sp.OpenSession()) {
                if (vJobId == -1)
                {
                    Job j = sess.QueryOver <Job>()
                            .OrderBy(x => x.Id).Desc
                            .Take(1)
                            .SingleOrDefault();

                    vJobId = j.Id;
                }

                CommIo.Print("Loading Job " + vJobId);

                IList <Batch> batchList = sess.QueryOver <Batch>()
                                          .Where(x => x.Job.Id == vJobId)
                                          .List();

                var failList = new List <Batch>();
                int i        = 0;

                foreach (Batch b in batchList)
                {
                    CommIo.Print("Confirming Batch " + b.Id + " (" + (++i) + " of " + batchList.Count + ")");
                    Data.Domain.Export e = b.ExportList[0];
                    CommIo.Print(" - First Export Id=" + e.Id + ", ArtifactId=" + e.Artifact.Id +
                                 ", FabricId=" + e.FabricId);

                    var f = new FabricClient();
                    f.AppDataProvSession.RefreshTokenIfNecessary();
                    f.UseDataProviderPerson = true;

                    if (!f.AppDataProvSession.IsAuthenticated)
                    {
                        throw new Exception("Could not authenticate.");
                    }

                    FabResponse <FabClass> fr =
                        f.Services.Traversal.GetRootStep.ClassId(e.FabricId).Get();

                    if (fr == null)
                    {
                        failList.Add(b);
                        CommIo.Print(" - FabResponse was null.");
                        continue;
                    }

                    FabClass c = fr.FirstDataItem();

                    if (c == null)
                    {
                        failList.Add(b);
                        CommIo.Print(" - FabClass was null.");
                        continue;
                    }

                    CommIo.Print(" - Found class: " + c.ArtifactId);
                }

                CommIo.Print("");
                CommIo.Print("Failures: " + failList.Count);

                foreach (Batch b in failList)
                {
                    CommIo.Print(" - Batch " + b.Id);
                }
            }
        }