private object GetSpecificObject(TriggerJobViewModel triggerJob)
        {
            string userName = MiUtility.GetCurrentUserName();
            Dictionary <string, string> rDictionary = GetRemotePaths(triggerJob, userName);

            Dictionary <string, string> qDictionary = triggerJob.QueueItemForm.QueueItemControls.Where(q => q.Type != Models.QUEUE_ITEM_TYPE.DEFAULT).ToDictionary(q => q.Key, q => q.Value);

            qDictionary.Add("BatchID", this.BatchID);
            qDictionary.Add("TriggeredBy", userName.ToUpper());
            qDictionary.Add("TriggeredAt", _triggeredTime.ToString());

            Dictionary <string, object> queueDictionay = new Dictionary <string, object>();

            foreach (var key in qDictionary.Keys)
            {
                if (rDictionary.ContainsKey(key))
                {
                    queueDictionay.Add(key, rDictionary[key]);
                }
                else
                {
                    queueDictionay.Add(key, qDictionary[key]);
                }
            }

            var specificObject = MiUtility.GetDynamicObject(queueDictionay);

            return(specificObject);
        }
        private Dictionary <string, string> GetRemotePaths(TriggerJobViewModel triggerJob, string userName)
        {
            Dictionary <string, string> remotePaths = new Dictionary <string, string>();

            string sftpPath = MiUtility.GetConfigurationValue("SFTP_PATH");
            var    file_or_folder_Controls = triggerJob.QueueItemForm.QueueItemControls.Where(q => (q.Type == Models.QUEUE_ITEM_TYPE.BROWSE_FILE || q.Type == Models.QUEUE_ITEM_TYPE.BROWSE_FOLDER));

            foreach (var queueControl in file_or_folder_Controls)
            {
                string remoteDirectory = Path.Combine(sftpPath, string.Format("{0}\\{1}", userName.ToUpper(), this.BatchID));
                if (!Directory.Exists(remoteDirectory))
                {
                    Directory.CreateDirectory(remoteDirectory);
                }

                if (queueControl.Type == Models.QUEUE_ITEM_TYPE.BROWSE_FILE)
                {
                    string localFilePath  = queueControl.Value;
                    string fileName       = Path.GetFileName(localFilePath);
                    string remoteFilePath = Path.Combine(remoteDirectory, fileName);

                    File.Copy(localFilePath, remoteFilePath, true);

                    remotePaths.Add(queueControl.Key, remoteFilePath);
                }
                else if (queueControl.Type == Models.QUEUE_ITEM_TYPE.BROWSE_FOLDER)
                {
                    string localFolderPath  = queueControl.Value;
                    string folderName       = Path.GetDirectoryName(localFolderPath);
                    string remoteFolderPath = Path.Combine(remoteDirectory, folderName);

                    foreach (string dirPath in Directory.GetDirectories(localFolderPath, "*", SearchOption.AllDirectories))
                    {
                        Directory.CreateDirectory(dirPath.Replace(localFolderPath, remoteFolderPath));
                    }

                    foreach (string newPath in Directory.GetFiles(localFolderPath, "*.*", SearchOption.AllDirectories))
                    {
                        File.Copy(newPath, newPath.Replace(localFolderPath, remoteFolderPath), true);
                    }

                    remotePaths.Add(queueControl.Key, remoteFolderPath);
                }
            }

            return(remotePaths);
        }
        private void Initialize()
        {
            IsBusy = true;

            var releases = ApiHelper.Fetch_all_Processes();

            var robotInfos = MiUtility.GetRobotInfos();

            foreach (var robotInfo in robotInfos)
            {
                var release = releases.SingleOrDefault(r => r.Id == int.Parse(robotInfo.ProcessID));
                if (release != null)
                {
                    var process = new ProcessViewModel(robotInfo, release);
                    AddProcess(process);
                    Thread.Sleep(100);
                }
            }

            IsBusy = false;
        }