Esempio n. 1
0
        private void AddToQueue(FileSystemEventArgs e, ExtentionType extentionType)
        {
            bool seenBefore = HashCheck.DoCheck(e.FullPath);

            if (!seenBefore)
            {
                //Create Media Item for Queue
                MediaFile mediaFile = new MediaFile
                {
                    DtDateTimeStamp   = DateTime.Now,
                    ConversionType    = extentionType,
                    StrName           = e.Name,
                    StrOriginFilePath = e.FullPath,
                    StrOutputFilePath = GetCustomFolder(e, ChkCustomOutput.Checked),
                    Hash     = HashCheck.GetHash(e),
                    Progress = 10
                };

                _conversionQueue.Enqueue(mediaFile);

                dgvQueue.BeginInvoke((Action)(() =>
                {
                    if (dgvQueue.Rows.Count < 0)
                    {
                        SetupGrid();
                    }
                    dgvQueue.DataSource = _conversionQueue.ToList();
                }));
            }
        }
Esempio n. 2
0
    protected void SetExtension(ExtentionType aextensionType)
    {
        extentionType = aextensionType;

        if ((extentionType & ExtentionType.RetryAfterNetworkError) == ExtentionType.RetryAfterNetworkError)
        {
            currentRetryAttempts = 0;
        }
    }
Esempio n. 3
0
    public override void invokeCallback(WWW www)
    {
        apiCallCount--;

        if (callback != null)
        {
            int    responcecode = 0;
            string error        = null;

            if (isRequestCanceled)            //cancel
            {
                if ((extentionType & ExtentionType.AutoCancelIfRequired) == ExtentionType.AutoCancelIfRequired)
                {
                    error        = "RestApiExtention:AutoCancel";
                    responcecode = (int)ErrorCodes.AutoCanceled;
                    callback(null, error, error, responcecode, customData);
                    callback          = null;
                    customData        = null;
                    isRequestCanceled = false;
                    return;
                }
                else if ((extentionType & ExtentionType.CancelAndRestartIfRequired) == ExtentionType.CancelAndRestartIfRequired)
                {
                    //Ignore the cancel request
                    Debug.Log("Suspended");
                    isRequestCanceled = false;
                    return;
                }
                else
                {
                    error        = "RestApiExtention:Canceled";
                    responcecode = (int)ErrorCodes.Canceled;
                    callback(null, error, error, responcecode, customData);
                    callback          = null;
                    customData        = null;
                    isRequestCanceled = false;
                    return;
                }
            }
            else
            {
                error = www.error;              //Actual server error
                //GameStateManager.Instance.checkNetworkConnection = true;
            }


            string      resultText;
            IDictionary resultDict;

            if (error != null)           //Network related error
            {
                Debug.LogError("***Network error!!  Call Admin Guy!! ==>" + error + "***APICALL** " + www.url);
                resultDict = null;
                resultText = error;
                ExtentionType temp = extentionType;

                if ((temp & ExtentionType.RetryAfterNetworkError) == ExtentionType.RetryAfterNetworkError && currentRetryAttempts < retryAttempts)
                {
                    currentRetryAttempts++;
                    RestApiHelper.GetInstance().StartHandleWWWAfterDelay(retryDely, www, this);
                    return;
                }
                else
                {
                    Debug.LogError("***Network error!!  Call Admin Guy!! ==>" + error + "***APICALL** " + www.url);
                    responcecode = (int)ErrorCodes.ExeededRetries;
                }

                //GameStateManager.Instance.checkNetworkConnection = true;
            }
            else
            {
                //Handling API related error in advancd
                Debug.Log("***APICALL**  TimeStamp:" + System.DateTime.Now.ToLongTimeString() + " " + www.url + "\n=>" + www.text);
                resultDict = (IDictionary)Json.Deserialize(www.text);
                resultText = www.text;
                if (resultDict != null)
                {
                    responcecode = int.Parse(string.Format("{0}", resultDict["responseCode"]));
                }

                else
                {
                    Debug.LogError("***Server error!! Call server ppl !! ==>" + www.text + "***APICALL** " + www.url);
                }
                //GameStateManager.Instance.checkNetworkConnection = true;
            }

            callback(resultDict, resultText, error, responcecode, customData);
            callback   = null;
            customData = null;
        }
    }
Esempio n. 4
0
 public RestApiExtention(string inurl, RestApiHelper.CallBack inCallback, ExtentionType anExtentionType) : this(inurl, inCallback)
 {
     SetExtension(anExtentionType);
 }
Esempio n. 5
0
        /// <summary>
        /// Processes changes to watch folder
        /// </summary>
        /// <param name="e"></param>
        private void ChangeDetected(FileSystemEventArgs e)
        {
            if (RbtnMKVtoMP4.Checked)
            {
                _outputExtension = ExtentionType.Mp4;
            }

            if (e.ChangeType == WatcherChangeTypes.Created || e.ChangeType == WatcherChangeTypes.Changed)
            {
                AddToQueue(e, _outputExtension);

                //If file is folder
                if (Directory.Exists(e.FullPath))
                {
                    //Get files from folder
                    foreach (string file in Directory.GetFiles(e.FullPath))
                    {
                        _outputFile = GetCustomFolder(e, ChkCustomOutput.Checked);

                        if (file.EndsWith(".mkv")) //if file is a .mkv
                        {
                            bool seenBefore = HashCheck.DoCheck(file);

                            if (!seenBefore)
                            {
                                //If convert to MKV option checked
                                if (RbtnMKVtoMP4.Checked)
                                {
                                    ConvertToMp4(file, _outputFile);
                                }
                            }
                        }
                        else
                        {
                            //Recursively look into other folders and repeat
                            var eventArgs = new FileSystemEventArgs(
                                WatcherChangeTypes.Created,
                                Path.GetDirectoryName(file),
                                Path.GetFileName(file));
                            ChangeDetected(eventArgs);
                        }
                    }
                }

                else
                {
                    //single file (not in folder)
                    if (e.ChangeType == WatcherChangeTypes.Created || e.ChangeType == WatcherChangeTypes.Changed)
                    {
                        bool seenBefore = HashCheck.DoCheck(e.FullPath);

                        if (!seenBefore)
                        {
                            _outputFile = GetCustomFolder(e, ChkCustomOutput.Checked);

                            //If convert to MKV option checked
                            if (RbtnMKVtoMP4.Checked)
                            {
                                ConvertToMp4(e.FullPath, _outputFile);
                                LogFile(e);
                            }
                        }
                    }
                }
            }
        }