Esempio n. 1
0
        public void Execute()
        {
            Log.Info("-Export start =>");

            var    pms      = new PMSManager();
            string response = pms.Information(ApplicationStateEnum.sent);

            ParseRetrieve(response, id => pms.Information(ApplicationStateEnum.sent, id));

            int counterPkg  = 1;
            int maxPackages = int.Parse(ConfigurationManager.AppSettings["MaxExportPackage"]);

            foreach (InfoSignItem item in InfoSignExistsCollection)
            {
                ExportItem(pms, item);
                counterPkg++;
                if (counterPkg > maxPackages)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        private static void ExportItem(PMSManager pms, InfoSignItem item)
        {
            (string fileName, string result) = pms.Export(ApplicationStateEnum.sent, item.Id, item.UserReference);      // return Item1 => zip-file & Item2 => xml

            if (!string.IsNullOrWhiteSpace(fileName) && !string.IsNullOrWhiteSpace(result))
            {
                Log.Info($">User Reference [{item.UserReference}].");
                Log.Info($">Package Id=[{item.Id}].");

                (string errorId, string value) = GetResponseReturnValue(result);

                if (!string.IsNullOrWhiteSpace(errorId) && errorId.Equals("-1"))
                {
                    if (GetCaseIdByUserReference(item.UserReference) is int caseId && caseId > 0)
                    {
                        if (GetDocIdUnique() is int docId && docId > 0)
                        {
                            Log.Info($">Doc Id=[{docId}].");

                            if (GetPatCasePath(caseId) is string part2Path && !string.IsNullOrWhiteSpace(part2Path))
                            {
                                if (GetFirstPartPath() is string firstPath && !string.IsNullOrWhiteSpace(firstPath))
                                {
                                    var pathPatricia = Path.Combine(firstPath, part2Path);
                                    var login        = ConfigurationManager.AppSettings["Login"];
                                    var domain       = ConfigurationManager.AppSettings["Domain"];
                                    var password     = ConfigurationManager.AppSettings["Password"];
                                    var computerName = ConfigurationManager.AppSettings["ComputerName"];

                                    using (NetworkShareAccesser.Access(computerName, domain, login, password))
                                    {
                                        if (!Directory.Exists(pathPatricia))
                                        {
                                            Directory.CreateDirectory(pathPatricia);
                                        }
                                        File.Copy(fileName, Path.Combine(pathPatricia, Path.GetFileName(fileName)), true);
                                        Log.Info($">Package [{Path.GetFileName(fileName)}] copy from [{Path.GetDirectoryName(fileName)}] to [{pathPatricia}].");
                                    }

                                    ExportPatDocLog(Path.GetFileName(fileName), caseId, docId);                             // write to db
                                    var removeAfter = ConfigurationManager.AppSettings["RemoveAfterExport"];
                                    if (removeAfter.Equals("true", StringComparison.CurrentCultureIgnoreCase))
                                    {
                                        string remResult = pms.Remove(ApplicationStateEnum.sent, item.Id);
                                        if (!RemoveSuccessfull(remResult))
                                        {
                                            string str1 = $">User Reference [{item.UserReference}], Package Id={item.Id}. PMS-service remove crash.";
                                            Log.Info(str1);
                                        }
                                    }
                                    Log.Info(value + ".");
                                }
                            }
                        }
                    }
                    else
                    {
                        string str1 = $">User Reference [{item.UserReference}] not found in db.";
                        string str2 = $">Retrieve Package [{Path.GetFileName(fileName)}]";
                        Log.Info(str1);
                        Log.Info(str2);
                    }
                }
                else
                {
                    Log.Info($">PMS-service export crash [{value}].");
                }
            }