Ejemplo n.º 1
0
        static void CheckMDS()
        {
            DefaultBinding_IContractManagement mdsContract = new DefaultBinding_IContractManagement();

            mdsContract.Url         = Properties.Settings.Default.ContractManagmentUrl;
            mdsContract.Credentials = new NetworkCredential(Properties.Settings.Default.User, Properties.Settings.Default.Password, Properties.Settings.Default.Domain);

            //Contract[] Contracts = mdsContract.ReadContractByAsset("Asset", AssetInfo.ProviderAssetId, AssetInfo.ProviderId);
            Contract[] Contracts = mdsContract.ReadContractByAsset("Asset", "WarnerBros", "HarryPotterChamberOfSecrets688");
            //Log(AssetInfo.ProviderAssetId + ": the number of contracts is " + Contracts.Length);
            Console.WriteLine("Contracts :" + Contracts.Length);
            foreach (Contract cont in Contracts)
            {
                Console.WriteLine(cont.Purchase.PurchaseType);

                if (cont.Purchase.PurchaseType == "External")
                {
                    //Log(AssetInfo.ProviderAssetId + ": the contact " + cont.ContractId + " is ok ");
                    Console.WriteLine("OK " + cont.ContractId);
                }
                else
                {
                    //Log(AssetInfo.ProviderAssetId + ": the contarc " + cont.ContractId + " we shoud delete ");
                    Console.WriteLine("delete " + cont.ContractId);
                    mdsContract.RemoveContract(cont.ContractProviderId, cont.ContractId);
                }
            }
        }
Ejemplo n.º 2
0
        static void CheckJobExecution(object JobID)
        {
            string ErrorJob = "";

            // Check running Job
            try
            {
                Guid JobGuid = Guid.Parse("00000000-0000-0000-0000-000000000000");
                if (Guid.TryParse(JobID.ToString(), out JobGuid))
                {
                    ErrorJob = JobGuid.ToString();

                    OssVodBranchWS VodBranch = new OssVodBranchWS();
                    VodBranch.Credentials = new NetworkCredential(Properties.Settings.Default.User, Properties.Settings.Default.Password, Properties.Settings.Default.Domain);
                    VodBranch.Url         = Properties.Settings.Default.VodBranch;

                    AssetInfo AssetInfo = new AssetInfo();

                    do
                    {
                        Thread.Sleep(180000);
                        AssetInfo = VodBranch.GetAssetInfoByJobId(JobGuid);
                        Console.WriteLine(AssetInfo.ProviderAssetId + ": Checking job " + JobGuid + ", status :" + AssetInfo.Status);
                        Log(AssetInfo.ProviderAssetId + ": Checking job " + JobGuid + " , status :" + AssetInfo.Status);
                    } while ((AssetInfo.Status == JobStatusCode.InProgress) || (AssetInfo.Status == JobStatusCode.Ready));
                    // Do something more
                    // Here we need check contract in MDS and remove it. if exist/
                    Thread.Sleep(180000);

                    DefaultBinding_IContractManagement mdsContract = new DefaultBinding_IContractManagement();
                    mdsContract.Url         = Properties.Settings.Default.ContractManagmentUrl;
                    mdsContract.Credentials = new NetworkCredential(Properties.Settings.Default.User, Properties.Settings.Default.Password, Properties.Settings.Default.Domain);

                    Contract[] Contracts = mdsContract.ReadContractByAsset("Asset", AssetInfo.ProviderId, AssetInfo.ProviderAssetId);
                    Log(AssetInfo.ProviderAssetId + ": the number of contracts is " + Contracts.Length);
                    foreach (Contract cont in Contracts)
                    {
                        if (cont.Purchase.PurchaseType == "External")
                        {
                            Log(AssetInfo.ProviderAssetId + ": the contract " + cont.ContractId + " is ok ");
                        }
                        else
                        {
                            Log(AssetInfo.ProviderAssetId + ": the contract " + cont.ContractId + " we shoud delete it");
                            mdsContract.RemoveContract(cont.ContractProviderId, cont.ContractId);
                            Log(AssetInfo.ProviderAssetId + ": the contract " + cont.ContractId + " was deleted ");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log("Error : " + ErrorJob + " " + e.Message);
                Console.WriteLine("Error :" + e.Message);
            }
        }