Beispiel #1
0
        private bool CancelCheckout(Organization org, string fullName)
        {
            Log.LogDebug("CancelCheckout: org={0} {1}, fullName={2}", org.shortName, org.filespaceId, fullName);

            try
            {
                var ccParams = new CancelCheckoutParams
                {
                    filespaceid = org.filespaceId,
                    path        = fullName
                };

                var result = ExecuteRequest(Ticket, Method.GET, "/tcc/CancelCheckout", ccParams, typeof(CancelCheckoutResult));
                if (result is CancelCheckoutResult ccResult)
                {
                    if (ccResult.success)
                    {
                        return(true);
                    }
                    CheckForInvalidTicket(ccResult, "CancelCheckout");
                }
                else
                {
                    Log.LogError("Null result from CancelCheckout for org {0} file {1}", org.shortName, fullName);
                }
            }

            catch (Exception ex)
            {
                Log.LogError("Failed to cancel checkout TCC file for org {0} file {1}: {2}", org.shortName, fullName,
                             ex.Message);
            }
            return(false);
        }
Beispiel #2
0
        public bool CancelCheckout(Organization org, string fullName)
        {
            Log.DebugFormat("CancelCheckout: org={0} {1}, fullName={2}", org.shortName, org.filespaceId, fullName);

            try
            {
                CancelCheckoutParams ccParams = new CancelCheckoutParams
                {
                    filespaceid = org.filespaceId,
                    path        = fullName
                };
                var result = ExecuteRequest(Ticket, Method.GET, "/tcc/CancelCheckout", ccParams, typeof(CancelCheckoutResult));
                CancelCheckoutResult ccResult = result as CancelCheckoutResult;
                Log.Debug($"Result: {JsonConvert.SerializeObject(ccResult)}");
                if (ccResult != null && !ccResult.success &&
                    ccResult.errorid.Contains("WORKING_COPY_OF_CHECKED_OUT_FILE_IS_NOT_FOUND"))
                {
                    var editCopyName    = $"{fullName.Substring(0, fullName.Length - 4)}-EditCopy.tag";
                    var editCopyCreated = CopyFile(org, fullName, editCopyName);
                    if (editCopyCreated)
                    {
                        result   = ExecuteRequest(Ticket, Method.GET, "/tcc/CancelCheckout", ccParams, typeof(CancelCheckoutResult));
                        ccResult = result as CancelCheckoutResult;
                    }
                }
                if (ccResult != null)
                {
                    if (ccResult.success || ccResult.errorid.Contains("NOT_CHECKED_OUT"))
                    {
                        return(true);
                    }
                    CheckForInvalidTicket(ccResult, "CancelCheckout");
                }
                else
                {
                    Log.ErrorFormat("Null result from CancelCheckout for org {0} file {1}", org.shortName, fullName);
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("Failed to cancel checkout TCC file for org {0} file {1}: {2}", org.shortName, fullName,
                                ex.Message);
            }
            return(false);
        }