Esempio n. 1
0
        public string Import()
        {
            var pmsInput = new PmsInput {
                UserName = UserName, Password = Password, Mode = GetPmsMode()
            };

            PmsActionEnum action = PmsActionEnum.import;

            pmsInput.CreateActionByType(action);
            pmsInput.Action.ImportState      = ApplicationStateEnum.draft;
            pmsInput.Action.ApplicationState = ApplicationStateEnum.draft;

            Stream attachment = null;

            try
            {
                string request     = pmsInput.XmlString;
                string zipFullName = GetAttachmentZipFileFullName();
                if (string.IsNullOrEmpty(zipFullName))
                {
                    throw new Exception("Zip file not found.");
                }

                attachment = new FileStream(zipFullName, FileMode.Open, FileAccess.Read);
                string response = Proxy.Import(request, attachment);
                attachment.Close();

                return(response);
            }
            finally
            {
                attachment?.Close();
            }
        }
Esempio n. 2
0
        public string Information(ApplicationStateEnum state, int appId = 0)
        {
            var pmsInput = new PmsInput {
                UserName = UserName, Password = Password, Mode = GetPmsMode(), Language = LanguageTypeEnum.English
            };

            PmsActionEnum action = PmsActionEnum.information;

            pmsInput.CreateActionByType(action);
            pmsInput.Action.ApplicationState = state;
            if (appId > 0)
            {
                pmsInput.Action.ApplicationId = appId;
            }

            Stream responseAtt = null;
            string request     = pmsInput.XmlString;

            try
            {
                string result = Proxy.Information(request, out responseAtt);
                return(result);
            }
            finally
            {
                responseAtt?.Close();
            }
        }
Esempio n. 3
0
        public (string, string) Export(ApplicationStateEnum state, int appId)
        {
            var pmsInput = new PmsInput {
                UserName = UserName, Password = Password, Mode = GetPmsMode(), Language = LanguageTypeEnum.English
            };

            PmsActionEnum action = PmsActionEnum.export;

            pmsInput.CreateActionByType(action);
            pmsInput.Action.ApplicationId    = appId;
            pmsInput.Action.ApplicationState = state;

            Stream responseAtt = null;
            string request     = pmsInput.XmlString;

            try
            {
                string result     = Proxy.Export(request, out responseAtt);
                var    tempFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                tempFolder = Path.Combine(tempFolder, CommonConst.ApplicationName, "RetrievePackage");
                if (!Directory.Exists(tempFolder))
                {
                    Directory.CreateDirectory(tempFolder);
                }

                try
                {
                    var zipExists = Directory.GetFiles(tempFolder, "*.zip");
                    foreach (string zipFile in zipExists)
                    {
                        if (File.Exists(zipFile))
                        {
                            File.Delete(zipFile);
                        }
                    }
                }
                catch (IOException)
                {
                }

                var fileName = Utils.SaveAttachmentToWorkDir(responseAtt, tempFolder);
                return(fileName, result);
            }
            finally
            {
                responseAtt?.Close();
            }
        }
Esempio n. 4
0
        public string Remove(ApplicationStateEnum state, int appId)
        {
            var pmsInput = new PmsInput {
                UserName = UserName, Password = Password, Mode = GetPmsMode(), Language = LanguageTypeEnum.English
            };

            PmsActionEnum action = PmsActionEnum.remove;

            pmsInput.CreateActionByType(action);
            pmsInput.Action.ApplicationId    = appId;
            pmsInput.Action.ApplicationState = state;

            string request = pmsInput.XmlString;
            string result  = Proxy.Remove(request);

            return(result);
        }