Manivannan пре 1 недеља
родитељ
комит
dc247817bd

+ 45 - 0
.gitignore

@@ -0,0 +1,45 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+
+# compiled output
+/dist
+/dist-server
+/tmp
+/out-tsc
+
+# dependencies
+/node_modules
+/Elsevier_Scheduler/bin/*
+/Elsevier_Scheduler/obj/*
+
+# IDEs and editors
+/Elsevier_Scheduler/.csproj
+/.idea
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vs/*
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+# misc
+/.sass-cache
+/connect.lock
+/coverage
+/libpeerconnection.log
+npm-debug.log
+package-lock.json
+yarn-error.log
+testem.log
+/typings
+
+# System Files
+.DS_Store
+Thumbs.db

+ 22 - 0
Elsevier_Scheduler.sln

@@ -0,0 +1,22 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35527.113 d17.12
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsevier_Scheduler", "Elsevier_Scheduler\Elsevier_Scheduler.csproj", "{1EB05DC7-08E7-40BF-BE55-79E84AC6B9BE}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{1EB05DC7-08E7-40BF-BE55-79E84AC6B9BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1EB05DC7-08E7-40BF-BE55-79E84AC6B9BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1EB05DC7-08E7-40BF-BE55-79E84AC6B9BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1EB05DC7-08E7-40BF-BE55-79E84AC6B9BE}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 112 - 0
Elsevier_Scheduler/AppSetting.json

@@ -0,0 +1,112 @@
+{
+  "AppSettings": {
+    "Secret": "THIS IS USED TO SIGN AND VERIFY JWT TOKENS, REPLACE IT WITH YOUR OWN SECRET, IT CAN BE ANY STRING",
+    "emailhost": "smtp.zeptomail.in",
+    "emailusername": "lumina.tech2@luminad.com",
+    "emailpassword": "PHtE6r1YEem+2Wcv9xIJ4P/qF8+gM48s+u5gLFFCuY1KCfNQTk1X+oh5kmWzox4rXfRCEfHKyog84LqdsevWI23rNzpMCmqyqK3sx/VYSPOZsbq6x00Zt1UScE3VXYPsc9Ji1S3Wu9nbNA==",
+    "emailportid": "587",
+    "mail_subject": "Notification:File correction",
+    "mail_tomail": "arunkumar.sagar@luminad.com,harish.kumar@luminad.com",
+    "mail_ccmail": "manivannan.venkatesan@luminad.com,alisha.mohanty@luminad.com,bhupeshkumar.Baburam@luminad.com",
+    "mail_bccmail": "cse.arunkumar@gmail.com",
+    "other_tomail": "arunkumar.sagar@luminad.com",
+    "other_ccmail": "harish.kumar@luminad.com,manivannan.venkatesan@luminad.com",
+    "other_bccmail": "cse.arunkumar@gmail.com",
+    "kli_rootpath": "https://support.luminad.com/car/core",
+    "envirnmentname": "dev",
+    "sftpHostName": "sftp.luminadus.com",
+    "sftpusername": "teammurali",
+    "sftppassword": "d35E)x&e8-v+q7pK",
+    "sftpport": "2222",
+    "sftpppk": "D:\\LuminaDatamatics.ppk",
+    "conferencesftp": "/CAR/conference/Incoming/CHN/",
+    "conferencesftpwatcher": "/CAR/conference/Reviewed/CHN/",
+    "doiMatchMailTemplate": "47",
+    "support_mail": "car-support@luminad.com",
+    "issueNotiMailTemplate": "46",
+    "logfile_path": "/efs/cardev/stagecontroller"
+
+  },
+  "DBInfo": {
+    "ConnectionString": "User Id=postgres;Password=ssg@1234;Host=172.20.254.182;Database=laps_elsevier_car_dev;Pooling=False;"
+    //"ConnectionString": "User Id=postgres;Password=aWX^^#773s;Host=localhost;Port=5434;Database=laps_elsevier_car_dev;Pooling=False;"
+    //"ConnectionString": "User Id=els-dev;Password=ssg@1234;Host=172.18.254.229;Port=5432;Database=elsevier_car_stg;Pooling=False;"
+  },
+  "servive": {
+    "servicename": "CAR2 TPA SFTP File Watcher Dev",
+    "WatcherFolder": "/CAR/orders/CreateCLELE/",
+    //"BasePath": "\\\\172.18.254.160\\wiley_laps", //dev
+    //"BasePath": "\\\\172.18.254.225\\Live-Drive", //stg
+    "BasePath": "/efs",
+    //"ScrapperFolder": "scraper,opsbankII\\s200",
+    "ScrapperFolder": "conference",
+    "LOCAL_PATH": "D:\\CAR_WATCHER\\CAR_DEV\\WATCHER",
+    "ExecutorId": "183086",
+    "reSupplyMailTemplate": "48",
+    "envirnmentname": "Dev",
+    "IngoreFolders": "resupply, correction, unselected,scraper_Error",
+    "splitpath": "wiley_laps", //dev
+    "skipcontentproviderid": "20772" // s300 content provider skip
+  },
+
+  "hangfire": {
+    "cron": "*/5 * * * *"
+  },
+  "api": {
+    "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1",
+    "LAPS_rootpath": "https://support.luminad.com/car/core/"
+  },
+  "mail": {
+    "emailhost": "smtp.zeptomail.in",
+    "emailusername": "lumina.tech2@luminad.com",
+    "emailpassword": "PHtE6r1YEem+2Wcv9xIJ4P/qF8+gM48s+u5gLFFCuY1KCfNQTk1X+oh5kmWzox4rXfRCEfHKyog84LqdsevWI23rNzpMCmqyqK3sx/VYSPOZsbq6x00Zt1UScE3VXYPsc9Ji1S3Wu9nbNA==",
+    "emailportid": "587",
+    "mail_subject": "Notification: Job Creating Issue",
+    "mail_tomail": "harish.kumar@luminad.com,arunkumar.sagar@luminad.com,manivannan.venkatesan@luminad.com,alisha.mohanty@luminad.com",
+    "mail_ccmail": "arunkumar.sagar@luminad.com",
+    "mail_bccmail": "arunkumar.sagar@luminad.com"
+  },
+
+  "Content_Acquisition": "Content Acquisition", //-->Auto stage-->Batch type
+  "File_Corruption": "File Corruption", //-->Auto stage-->Batch type
+  "Acquisition_Error": "Acquisition Error", //--> Common tool -->Batch type
+  "Metadata_Verification": "Metadata Verification", //--> Common tool -->Lot type
+  "unselected": "unselected", //-->Auto stage-->Batch type
+  "Existing_TPA": "Existing TPA", //-->Auto stage-->Lot type
+  "New_TPA": "New TPA", //-->Auto stage-->Lot type
+  "Dispatched": "Dispatched", //-->Auto stage-->Batch type
+  "Upload_Error": "Upload Error", //-->Common tool -->Batch type
+  "End": "End", //-->Auto stage-->Batch type
+
+  //CAR-2 TPA: Creating TPA CARs without CAR Orders
+  "TPA_Upload_Error": "TPA Upload Error",
+  "TPA_Dispatched": "TPA Dispatched",
+  "Metadata_Retrival": "Metadata Retrival", //-->Auto stage-->Batch type
+  "Asset_Download": "Asset Download", //-->Auto stage-->Batch type --> stage Romoved 
+  "CAR_eligibility_check": "CAR eligibility check", //-->Auto stage-->Lot type
+  "Elsevier_API_error": "Elsevier API error", //-->Common tool -->Lot type
+  "Preprocessing": "Preprocessing", //-->Auto stage -->Lot type
+  "CR_Abstract_Generation": "CR Abstract Generation", //-->Auto stage-->Lot type
+  "PDF_Split": "PDF Split", //-->Common tool -->Lot type
+  "Style_Review": "Style Review", //-->Common tool -->Lot type
+  "Browsing": "Browsing", //-->Common tool -->Lot type
+  "Compare": "Compare", //-->Common tool -->Lot type
+  "QA": "QA", //-->Common tool -->Lot type
+  "QA1": "QA1", //-->Common tool -->Lot type --> not used
+  "XEP_CAR_generation": "XEP:CAR generation", //-->Auto stage-->Lot type
+  "Package_Generation": "Package Generation", //-->Auto stage-->Lot type	
+  "Package_Upload": "Package Upload", //-->Auto stage-->Lot type
+  "Discarded": "Discarded", //-->Auto stage-->Lot type
+  "CAR_Upload_Error": "CAR Upload Error",
+
+  //Conference workflow
+  "Create_Markup": "Create Markup", //-->Common tool -->Lot type
+  "Review_Markup": "Review Markup", //-->Common tool -->Lot type
+  "Content_list_creation": "Content list creation", //-->Auto stage-->Lot type
+  "Load_Content_List": "Load Content List", //-->Auto stage-->Lot type
+
+  "ServerOUTPATH": "OUT",
+  "ServerINPATH": "IN",
+  "fileuploadmethod": "1", //-1 file server -2 S3
+  "commontoolappUrl": "https://support.luminad.com/car/#/dashboard"
+}

+ 21 - 0
Elsevier_Scheduler/App_Data/AppContext.cs

@@ -0,0 +1,21 @@
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.App_Data
+{
+    public class AppContext
+    {
+        private static IHttpContextAccessor _httpContextAccessor;
+
+        public static void Configure(IHttpContextAccessor httpContextAccessor)
+        {
+            _httpContextAccessor = httpContextAccessor;
+
+        }
+
+        public static HttpContext Current => _httpContextAccessor.HttpContext;
+    }
+}

+ 520 - 0
Elsevier_Scheduler/App_Data/CommonClass.cs

@@ -0,0 +1,520 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Newtonsoft.Json;
+using System.Diagnostics;
+using System.IO;
+using Newtonsoft.Json.Linq;
+using System.Runtime.InteropServices;
+using Microsoft.Extensions.Configuration;
+using System.Net.Mail;
+using System.Net;
+using Elsevier_Scheduler.Models;
+using Elsevier_Scheduler.Configure;
+//using Ionic.Zip;
+
+namespace Elsevier_Scheduler.App_Data
+{
+    static class CommonClass
+    {
+        public static List<appdetails> CheckAppType(string tranid, string userid)
+        {
+            try
+            {
+                appdetails appdetails = new appdetails();
+                //appdetails obj = null;
+                List<appdetails> appdetails1 = new List<appdetails>();
+                insertcomments oInsertComments = new insertcomments();
+                oInsertComments.tranid = Convert.ToUInt32(tranid);
+                oInsertComments.userid = Convert.ToUInt32(userid);
+                oInsertComments.status = "R";
+                oInsertComments.p_option = "apptype";
+                var input = JsonConvert.SerializeObject(oInsertComments);
+                var appType = CommonRepository.ExecuteSP_ReturnList1("spusrlottransactionupdate", input);
+                if (appType != null)
+                {
+                    var i_appType = JsonConvert.DeserializeObject<object>(appType.ToString());
+                    JArray a_appType = JArray.Parse(i_appType.ToString());
+                    JObject obj_appType = JObject.Parse(a_appType[0].ToString());
+                    appdetails.jobworkflowid = obj_appType["jobworkflowid"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["jobworkflowid"].ToString());
+                    appdetails.lotid = obj_appType["lotid"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["lotid"].ToString());
+                    appdetails.jobid = obj_appType["jobid"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["jobid"].ToString());
+                    appdetails.merged_lot = obj_appType["merged_lot"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["merged_lot"].ToString());
+                    appdetails.batchid = obj_appType["batchid"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["batchid"].ToString());
+                    appdetails.nextstage = obj_appType["nextstage"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["nextstage"].ToString());
+                    appdetails.movebackstage = obj_appType["movebackstage"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["movebackstage"].ToString());
+                    appdetails.stagetype = obj_appType["stagetype"].ToString();
+                    appdetails.process_without_file = obj_appType["process_without_file"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["process_without_file"].ToString());
+                    appdetails.checkin_app = obj_appType["checkin_app"].ToString();
+                    appdetails.inprocessapp = obj_appType["inprocessapp"].ToString();
+                    appdetails.checkout_app = obj_appType["checkout_app"].ToString();
+                    appdetails.exe_path = obj_appType["exepath"].ToString();
+
+                    appdetails.checkin_appwather = obj_appType["checkin_appwather"].ToString();
+                    appdetails.inprocessappwatcher = obj_appType["inprocessappwatcher"].ToString();
+                    appdetails.checkout_appwatcher = obj_appType["checkout_appwatcher"].ToString();
+                    appdetails.ipaexepath = obj_appType["ipaexepath"].ToString();
+                    appdetails.coaexepath = obj_appType["coaexepath"].ToString();
+                    appdetails.is_checkin_exe = obj_appType["is_checkin_exe"].ToString();
+                    appdetails.ciaisservice = obj_appType["ciaisservice"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["ciaisservice"].ToString());
+                    appdetails.ipaisservice = obj_appType["ipaisservice"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["ipaisservice"].ToString());
+                    appdetails.coaisservice = obj_appType["coaisservice"].ToString() == "" ? 0 : Convert.ToInt32(obj_appType["coaisservice"].ToString());
+                }
+                appdetails1.Add(appdetails);
+                return appdetails1;
+
+            }
+            catch(Exception ex)
+            {
+                Console.WriteLine("RequestConsumer:LoadFunction:Error" + ex.Message.ToString());
+                var logdata = new
+                {
+                    errormessage = ex.Message,
+                    createdby = 0,
+                    controller = "Watcher:LoadFunction"
+                };
+                CommonClass.ErrorLog(ex);
+                //VendorMail.CallErrorMessage(tranid, "0", "0", "0", "LAPS WATCHER", ex.Message.ToString(), 0, "", ex);
+
+                CommonClass.WriteLog("", tranid, ex.ToString());
+                return null;
+            }
+        }
+        public static string CopyDirectory(string sourceDir, string destinationDirc)
+        {
+            string Name = "";
+            DirectoryInfo source = new DirectoryInfo(sourceDir);
+            DirectoryInfo destination = new DirectoryInfo(destinationDirc);
+            if (!destination.Exists)
+            {
+                destination.Create();
+            }
+            if (!source.Exists)
+            {
+                return "erorr";
+            }
+            FileInfo[] files = source.GetFiles();
+            foreach (FileInfo file in files)
+            {
+                if (file.Name.ToLower().Trim() != "thumbs.db")
+                {
+                    Name = file.Name;
+                    string Dest = System.IO.Path.Combine(destination.FullName, file.Name);
+                    if (System.IO.File.Exists(Dest))
+                    {
+                        System.IO.File.Delete(Dest);
+                    }
+                    if (!System.IO.File.Exists(Dest))
+                    {
+                        file.CopyTo(Dest, true);
+                    }
+                }
+            }
+            DirectoryInfo[] dirs = source.GetDirectories();
+            foreach (DirectoryInfo dir in dirs)
+            {
+                string destinationDir = System.IO.Path.Combine(destination.FullName, dir.Name);
+                string destinationDir1 = dir.FullName;
+                CopyDirectory(destinationDir1, destinationDir);
+            }
+            return Name;
+        }
+        public static string MoveDirectory(string sourceDir, string destinationDirc)
+        {
+            string Name = "";
+            DirectoryInfo source = new DirectoryInfo(sourceDir);
+            DirectoryInfo destination = new DirectoryInfo(destinationDirc);
+            if (!destination.Exists)
+            {
+                destination.Create();
+            }
+            if (!source.Exists)
+            {
+                return "erorr";
+            }
+            FileInfo[] files = source.GetFiles();
+            foreach (FileInfo file in files)
+            {
+                if (file.Name.ToLower().Trim() != "thumbs.db")
+                {
+                    Name = file.Name;
+                    string Dest = System.IO.Path.Combine(destination.FullName, file.Name);
+                    if (System.IO.File.Exists(Dest))
+                    {
+                        System.IO.File.Delete(Dest);
+                    }
+                    if (!System.IO.File.Exists(Dest))
+                    {
+                        file.MoveTo(Dest);
+                    }
+                }
+            }
+            DirectoryInfo[] dirs = source.GetDirectories();
+            foreach (DirectoryInfo dir in dirs)
+            {
+                string destinationDir = System.IO.Path.Combine(destination.FullName, dir.Name);
+                string destinationDir1 = dir.FullName;
+                CopyDirectory(destinationDir1, destinationDir);
+            }
+            return Name;
+        }
+        public static void ErrorLog(Exception ex)
+        {
+            try
+            {
+                //string filePath = @"C:\Error.txt";
+                //string a = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
+                //DriveInfo cDrive = new DriveInfo(System.Environment.CurrentDirectory);
+                //string b = cDrive.RootDirectory.ToString();
+                //string c = AppDomain.CurrentDomain.BaseDirectory;
+                string d = System.IO.Directory.GetCurrentDirectory();
+                //  File.WriteAllText(d, sb.ToString());
+                using (StreamWriter writer = new StreamWriter(d + "\\error.log.txt", true))
+                {
+                    StringBuilder sb = new StringBuilder();
+                    sb.AppendLine("------------------------Error Log start----------------------------");
+                    sb.AppendLine("Date:-" + DateTime.Now.ToString());
+                    sb.AppendLine("Application Name :" + ex.Source);
+                    sb.AppendLine("Error Message :" + ex.Message);
+                    sb.AppendLine("Method Name :" + ex.StackTrace);
+                    sb.AppendLine("------------------------Error Log End----------------------------");
+                    writer.WriteLine(sb.ToString());
+                    writer.Close();
+                    // tw.WriteLine("The next line!");
+                };
+            }
+            catch (Exception)
+            {
+
+            }
+            //System.IO.File.WriteAllText(d+"\\error.log.txt", sb.ToString());
+        }
+        public static void laps2Log(string func, string logtext)
+        {
+            try
+            {
+
+                //string d = System.IO.Directory.GetCurrentDirectory();
+                string d = System.IO.Directory.GetCurrentDirectory();
+                using (StreamWriter writer = new StreamWriter(d + "\\laps2log.log.txt", true))
+                {
+                    StringBuilder sb = new StringBuilder();
+                    sb.AppendLine("------------------------ Log start----------------------------");
+                    sb.AppendLine("Date:-" + DateTime.Now.ToString());
+                    sb.AppendLine("Application Name :" + func);
+                    sb.AppendLine("Error Message :" + logtext);
+                    sb.AppendLine("------------------------ Log End----------------------------");
+                    writer.WriteLine(sb.ToString());
+                    writer.Close();
+                    // tw.WriteLine("The next line!");
+                };
+            }
+            catch (Exception)
+            {
+
+            }
+            //System.IO.File.WriteAllText(d+"\\error.log.txt", sb.ToString());
+        }
+        public static void WriteLog(string fileName, string MSGID, string Log)
+        {
+            TextWriter tw = new StreamWriter(fileName, append: true);
+            tw.WriteLine("---------------------------------");
+            tw.WriteLine("Message ID : " + MSGID + " Date : " + DateTime.Now.ToString());
+            tw.WriteLine(Log.ToString());
+            tw.WriteLine("---------------------------------");
+            tw.Close();
+        }
+        public static string CreateBackupfolderOnly(string pathfold)
+        {
+            try
+            {
+                int i = 1;
+            rechck:;
+                string folderprefix = "\\V";
+                bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+                if (isWindows)
+                { folderprefix = "\\V"; }
+                else
+                {
+                    folderprefix = "/V";
+                }
+                Console.WriteLine("folderprefix=" + folderprefix);
+                Console.WriteLine("pathfold=" + pathfold);
+                if (Directory.Exists(Path.Join(pathfold, folderprefix + i.ToString("000"))))
+                {
+                    i++;
+                    goto rechck;
+                }
+                else
+                {
+                    Directory.CreateDirectory(Path.Join(pathfold, folderprefix + i.ToString("000")));
+                    Console.WriteLine("pathfold="+ Path.Join(pathfold, folderprefix + i.ToString("000")));
+                    return pathfold + folderprefix + i.ToString("000");
+                    //Directory.CreateDirectory(string.Join("", pathfold, "\\V", i.ToString("000")) + "\\OUT");
+
+                }
+               
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message.ToString());
+                //ErrorLogger.environment = enviroment; ErrorLogger.errorLog.WriteErrorLog(new ErrorTranslate { TranID = Convert.ToInt64(tranid), ErrorMessage = ex.Message.ToString() });
+                return pathfold;
+            }
+        }
+        public static string ErrorMsg = "", PrcOut = "";
+        public static string ExecComp(string AppName, string Params, string basedir = null)
+        {
+            //Console.WriteLine("LAPS App Watcher: ExecComp " + "ExecComp:AppName " + AppName + "Params: " + Params, "CommonClass ");
+           
+            try
+            {
+                Type callType = Type.GetType(AppName);
+                callType.GetMethod("call_laps_ioservice").Invoke(null, new[] { Params });
+                //typeof(laps_ioservice).GetMethod("call_laps_ioservice").Invoke(null, new[] { Params });
+
+            }
+            catch (Exception exp)
+            {
+                Console.WriteLine("LAPS App Watcher:ExecComp:Error, exception is" + exp.Message + "::" + exp.StackTrace);
+                CommonClass.ErrorLog(exp);
+                ErrorMsg = "Error while conversion, exception is: " + exp.Message + "::" + exp.StackTrace;
+            }
+            finally { /*if (compare != null) compare.Close();*/ }
+            return ErrorMsg;
+        }
+        public static string ExecCompwatcher(string AppName, string Params, string basedir = null)
+        {
+            Process compare = new Process();
+            try
+            {
+                //Console.WriteLine("LAPS App Watcher: ExecCompwatcher " + "ExecCompwatcher:AppName " + AppName + "Params: " + Params, "CommonClass ");
+                Type callType = Type.GetType(AppName);
+                callType.GetMethod("call_laps_ioservice").Invoke(null, new[] { Params });
+                //compare.StartInfo.FileName = AppName;
+                //compare.StartInfo.Arguments = Params;
+                //compare.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
+                //compare.StartInfo.WorkingDirectory = Path.GetDirectoryName(AppName);
+                //compare.Start();
+                //compare.WaitForExit();
+
+
+                //Process Prc = null;
+                //try
+                //{
+                //    Prc = new Process();
+                //    Prc.StartInfo.FileName = AppName;
+                //    Prc.StartInfo.Arguments = Params;
+                //    //////Prc.StartInfo.UserName = "ldl\\ssgchn";
+                //    //////var secure = new SecureString();
+                //    //////foreach (char c in "$sgs$426") { secure.AppendChar(c); }
+                //    //////Prc.StartInfo.Password = secure;
+                //    Prc.StartInfo.CreateNoWindow = true;
+                //    Prc.StartInfo.UseShellExecute = false;
+                //    Prc.Exited += Prc_Extd;
+                //    Prc.StartInfo.RedirectStandardError = true;
+                //    Prc.StartInfo.RedirectStandardOutput = true;
+                //    Prc.ErrorDataReceived += new DataReceivedEventHandler(Prc_ErDtRcvd);
+                //    Prc.OutputDataReceived += new DataReceivedEventHandler(Prc_OpDtRcvd);
+                //    Prc.Start();
+                //    Prc.BeginErrorReadLine();
+                //    Prc.BeginOutputReadLine();
+                //    Prc.WaitForExit();
+                if (ErrorMsg != "") return ErrorMsg;
+                Console.WriteLine(ErrorMsg);
+            }
+            catch (Exception exp) { ErrorMsg = "Error while conversion, exception is: " + exp.Message + "::" + exp.StackTrace; }
+            finally { if (compare != null) compare.Close(); }
+            return ErrorMsg;
+            //Console.WriteLine("LAPS App Watcher: ExecCompwatcher " + "ExecCompwatcher:AppName " + AppName + "Params: " + Params, "CommonClass ");
+
+            //try
+            //{
+            //    Type callType = Type.GetType(AppName);
+            //    callType.GetMethod("call_laps_ioservice").Invoke(null, new[] { Params });
+            //    //typeof(laps_ioservice).GetMethod("call_laps_ioservice").Invoke(null, new[] { Params });
+
+            //}
+            //catch (Exception exp)
+            //{
+            //    Console.WriteLine("LAPS App Watcher:ExecComp:Error, exception is" + exp.Message + "::" + exp.StackTrace);
+            //    CommonClass.ErrorLog(exp);
+            //    ErrorMsg = "Error while conversion, exception is: " + exp.Message + "::" + exp.StackTrace;
+            //}
+            //finally { /*if (compare != null) compare.Close();*/ }
+            //return ErrorMsg;
+        }
+        public static void WriteLog(string logtxt, string method)
+        {
+            try
+            {
+
+                string d = System.IO.Directory.GetCurrentDirectory();
+                using (StreamWriter writer = new StreamWriter(d + "\\laps2log.txt", true))
+                {
+                    StringBuilder sb = new StringBuilder();
+                    sb.AppendLine("------------------------ Log start----------------------------");
+                    sb.AppendLine("Date:-" + DateTime.Now.ToString());
+                    sb.AppendLine("Method Name :" + method);
+                    sb.AppendLine("Log Message :" + logtxt);
+
+                    sb.AppendLine("------------------------ Log End----------------------------");
+                    writer.WriteLine(sb.ToString());
+                    writer.Close();
+                    // tw.WriteLine("The next line!");
+                };
+            }
+            catch (Exception)
+            {
+
+            }
+            //System.IO.File.WriteAllText(d+"\\error.log.txt", sb.ToString());
+        }
+        public static void SendMail_authoring(string tomail, StringBuilder sbody, StringBuilder ssubject, string attachment = "")
+        {
+            try
+            {
+                SmtpClient smtpClient = new SmtpClient();
+                MailAddress fromAddress = null;
+                using (MailMessage message = new MailMessage())
+                {
+                    string b = WebUtility.HtmlDecode(sbody.ToString());
+                    message.Body = b;
+                    message.Subject = ssubject.ToString();
+                    message.To.Add(new MailAddress(tomail));
+                    fromAddress = new MailAddress(CustomConfiguration.AppSettings["AppSettings:emailusername"], "LAPS DEV");
+                    smtpClient.Host = CustomConfiguration.AppSettings["AppSettings:emailhost"];
+                    smtpClient.EnableSsl = true;
+                    smtpClient.Port = Convert.ToInt32(CustomConfiguration.AppSettings["AppSettings:emailportid"]);
+                    NetworkCredential myCredential = new NetworkCredential(CustomConfiguration.AppSettings["AppSettings:emailusername"],
+                    CustomConfiguration.AppSettings["AppSettings:emailpassword"]);
+                    smtpClient.Credentials = myCredential;
+                    message.From = fromAddress;
+                    MailMessage mail = new MailMessage();
+                    message.IsBodyHtml = true;
+
+
+                    string otherCCMail = CustomConfiguration.AppSettings["AppSettings:other_ccmail"].ToString();
+                    Console.WriteLine("...Calling SendEmail on" + DateTime.Now);
+                    var ccrecipient = otherCCMail.Split(';');
+                    foreach (var item in ccrecipient)
+                    {
+                        message.CC.Add(new MailAddress(item));
+                    }
+
+                    string otherBCCMail = CustomConfiguration.AppSettings["AppSettings:other_bccmail"].ToString();
+                    Console.WriteLine("...Calling SendEmail on" + DateTime.Now);
+                    var bccrecipient = otherBCCMail.Split(';');
+                    foreach (var item in bccrecipient)
+                    {
+                        message.Bcc.Add(new MailAddress(item));
+                    }
+
+
+                    foreach (string str in attachment.Split(';'))
+                    {
+                        if (str != "")
+                        {
+                            if (File.Exists(str))
+                            {
+                                message.Attachments.Add(new Attachment(str));
+                            }
+                        }
+                    }
+
+                    smtpClient.Send(message);
+                    Console.WriteLine("---------Adding send mail log starts----------");
+                    Console.WriteLine("Subject:" + message.Subject.ToString() + "From: " + message.From.Address);
+                    mailboxModel mailData = new mailboxModel();
+                    mailData.mailsubject = message.Subject.ToString();
+                    mailData.mailfrom = message.From.Address;
+                    mailData.mailto = tomail;
+                    mailData.mailbody = sbody.ToString();
+                    mailData.transactionid = 0;
+
+                    CommonRepository.PostMailboxData(mailData);
+                    Console.WriteLine("---------Adding send mail log ends----------");
+                }
+            }
+            catch (Exception exp)
+            {
+                Console.WriteLine("LAPS App Watcher:SendMail:Error, exception is" + exp.Message + "::" + exp.StackTrace);
+                CommonClass.ErrorLog(exp);
+            }
+        }
+        public static void SendMail(string tomail, StringBuilder sbody, StringBuilder ssubject,string attachment="")
+        {
+            try
+            {
+                SmtpClient smtpClient = new SmtpClient();
+                MailAddress fromAddress = null;
+                using (MailMessage message = new MailMessage())
+                {
+                    string b = WebUtility.HtmlDecode(sbody.ToString());
+                    message.Body = b;
+                    message.Subject = ssubject.ToString();
+                    message.To.Add(new MailAddress(tomail));
+                    fromAddress = new MailAddress(CustomConfiguration.AppSettings["AppSettings:emailusername"], "LAPS DEV");
+                    smtpClient.Host = CustomConfiguration.AppSettings["AppSettings:emailhost"];
+                    smtpClient.EnableSsl = true;
+                    smtpClient.Port = Convert.ToInt32(CustomConfiguration.AppSettings["AppSettings:emailportid"]);
+                    NetworkCredential myCredential = new NetworkCredential(CustomConfiguration.AppSettings["AppSettings:emailusername"],
+                    CustomConfiguration.AppSettings["AppSettings:emailpassword"]);
+                    smtpClient.Credentials = myCredential;
+                    message.From = fromAddress;
+                    MailMessage mail = new MailMessage();
+                    message.IsBodyHtml = true;
+
+
+                    foreach (string str in attachment.Split(';'))
+                    {
+                        if (str != "")
+                        {
+                            if (File.Exists(str))
+                            {
+                                message.Attachments.Add(new Attachment(str));
+                            }
+                        }
+                    }
+
+                    smtpClient.Send(message);
+                    Console.WriteLine("---------Adding send mail log starts----------");
+                    Console.WriteLine("Subject:"+ message.Subject.ToString()+ "From: "+ message.From.Address);
+                    mailboxModel mailData = new mailboxModel();
+                    mailData.mailsubject = message.Subject.ToString();
+                    mailData.mailfrom = message.From.Address;
+                    mailData.mailto = tomail;
+                    mailData.mailbody = sbody.ToString();
+                    mailData.transactionid = 0;
+                    
+                    CommonRepository.PostMailboxData(mailData);
+                    Console.WriteLine("---------Adding send mail log ends----------");
+                }
+            }
+            catch (Exception exp)
+            {
+                Console.WriteLine("LAPS App Watcher:SendMail:Error, exception is" + exp.Message + "::" + exp.StackTrace);
+                CommonClass.ErrorLog(exp);
+            }
+        }
+        public class insertcomments
+        {
+            public long transid { set; get; }
+            public string comment { set; get; }
+            public string doption { set; get; }
+            public string tostage { set; get; }
+            public long jobid { set; get; }
+            public long lotid { set; get; }
+            public string filename { set; get; }
+            public string lotstatus { set; get; }
+            public long userid { set; get; }
+            public string status { set; get; }
+            public string comments { set; get; }
+            public long jobworkflowid { set; get; }
+            public long tranid { set; get; }
+            public string transactionkey { set; get; }
+            public string p_option { set; get; }
+
+        }
+    }
+}

Разлика између датотеке није приказан због своје велике величине
+ 937 - 0
Elsevier_Scheduler/App_Data/CommonRepository.cs


+ 29 - 0
Elsevier_Scheduler/App_Data/ConnectionBase.cs

@@ -0,0 +1,29 @@
+using Elsevier_Scheduler.Configure;
+using Microsoft.Extensions.Configuration;
+using Npgsql;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.App_Data
+{
+    public class ConnectionBase
+    {
+        public static IDbConnection Connection
+        {
+            get
+            {
+                string constr = CustomConfiguration.AppSettings.GetValue<string>("DBInfo:ConnectionString").ToString();
+                return new NpgsqlConnection(constr);
+            }
+        }
+        public class ResultMaster
+        {
+            public int Result { get; set; }
+
+            public string Message { get; set; }
+        }
+    }
+}

+ 30 - 0
Elsevier_Scheduler/App_Data/CustomConfiguration.cs

@@ -0,0 +1,30 @@
+using System;
+using Microsoft.Extensions.Configuration;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+
+namespace Elsevier_Scheduler.Configure
+{
+    class CustomConfiguration
+    {
+        public static IConfiguration AppSettings { get; }
+        static CustomConfiguration()
+        {
+            try
+            {
+                var builder = new ConfigurationBuilder()
+                    .SetBasePath(Path.Combine(AppContext.BaseDirectory))
+                    .AddJsonFile("AppSetting.json", true, true);
+                AppSettings = new ConfigurationBuilder()
+                        .SetBasePath(Path.Combine(AppContext.BaseDirectory))
+                        .AddJsonFile("AppSetting.json")
+                        .Build();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message + " at " + ex.StackTrace);
+            }
+        }
+    }
+}

+ 69 - 0
Elsevier_Scheduler/App_Data/DBLibrary.cs

@@ -0,0 +1,69 @@
+using Elsevier_Scheduler.Configure;
+using Microsoft.Extensions.Configuration;
+using Npgsql;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+
+namespace Elsevier_Scheduler.App_Data
+{
+   public class DBLibrary
+    {
+        public static object insertdataScalar(string Qry, List<NpgsqlParameter> paramet = null)
+        {
+            NpgsqlConnection postgrescon = new NpgsqlConnection(CustomConfiguration.AppSettings.GetValue<string>("DBInfo:ConnectionString").ToString());
+            try
+            {
+                postgrescon.Open();
+                NpgsqlCommand cmd = new NpgsqlCommand(Qry, postgrescon);
+                if (paramet != null)
+                {
+                    foreach (NpgsqlParameter sqlpara in paramet)
+                        cmd.Parameters.Add(sqlpara);
+                    cmd.CommandType = CommandType.StoredProcedure;
+                }
+                else
+                {
+                    cmd.CommandType = CommandType.Text;
+                }
+                var obj = cmd.ExecuteScalar();
+                postgrescon.Close();
+                return obj;
+            }
+            catch (Exception ex)
+            {
+                postgrescon.Close();
+                return "";
+            }
+
+        }
+    }
+
+    public class modcommon
+    {
+
+        public static string ns(object val)
+        {
+            try
+            {
+                return val.ToString();
+            }
+            catch (Exception ex)
+            {
+                return string.Empty;
+            }
+        }
+        public static Int32 nz(object val)
+        {
+            try
+            {
+                return Int32.Parse(val.ToString());
+            }
+            catch (Exception ex)
+            {
+                return 0;
+            }
+        }
+    }
+}

+ 439 - 0
Elsevier_Scheduler/App_Data/apiparamModel.cs

@@ -0,0 +1,439 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    
+    public class CM
+    {
+        public List<Users> users { get; set; }
+        public string duedate { get; set; }
+    }
+
+    public class GE
+    {
+        public List<Users> users { get; set; }
+
+        public string duedate { get; set; }
+    }
+
+    public class Users
+    {
+        public string name { get; set; }
+
+        public string email { get; set; }
+    }
+
+    public class Documents
+    {
+        public string documentid { get; set; }
+        public string publication { get; set; }
+        public string publication_type { get; set; }
+        public string publicationid { get; set; }
+        public string chasing_unit { get; set; }
+        public string doctype { get; set; }
+        public string title { get; set; }
+        public bool query { get; set; }
+        public bool query_response { get; set; }
+        
+        public bool? prereview { get; set; }
+        public string schedule_change { get; set; }
+        public Allocation allocation { get; set; }
+
+    }
+
+    public class Authors
+    {
+        public List<Users> users { get; set; }
+        public string duedate { get; set; }
+    }
+    public class Freelancers
+    {
+        public List<Users> users { get; set; }
+        public string duedate { get; set; }
+    }
+    public class Arbitrators
+    {
+        public List<Users> users { get; set; }
+        public string duedate { get; set; }
+    }
+
+    public class cdbinputparamModel
+    {
+        public string tranid { get; set; }
+        public string userid { get; set; }
+        public string lotid { get; set; }
+    }
+    public class cdbparamModel
+    {
+        public string requestid { get; set; }
+        public string type { get; set; }
+        public List<Documents> documents { get; set; }
+    }
+    public class Editors
+    {
+        public CM CM { get; set; }
+        public GE GE { get; set; }
+    }
+    public class Allocation
+    {
+        public Authors authors { get; set; }
+        public Freelancers Freelancers { get; set; }
+        public Arbitrators Arbitrators { get; set; }
+        public Editors editors { get; set; }
+        public string actiondate { get; set; }
+        public string actionby { get; set; }
+    }
+
+    public class EMODProjectCreationModel
+    {
+
+        public string project_name { get; set; }
+        public string title { get; set; }
+        public string Project_type { get; set; }
+        public string Publisher_uuid { get; set; }
+        public string workflow { get; set; }
+        public string start_date { get; set; }
+        public string due_date { get; set; }
+        public string project_complexity { get; set; }
+        public string reference { get; set; }
+        public string reference_style { get; set; }
+
+
+    }
+    public class EMONDApiResponse
+    {
+        public string Error { get; set; }
+        public string Status { get; set; }
+        public string Message { get; set; }
+        public string Data { get; set; }
+        public string HTTP_Code { get; set; }
+    }
+    public class pubflowparamModel
+    {
+        public string PublicationType { get; set; } // Yes Type of the publication
+        public string PublicationID { get; set; } // Yes Unique identifier of the publication
+
+        public string type { get; set; } // Yes mode of request
+        public string batch { get; set; }
+        public string WorkflowName { get; set; }
+        public string CMNote { get; set; }
+        public string SupplementNumber { get; set; } // Yes Supplement number to update
+        public string ActivityName { get; set; } // Yes Activity name to update
+        public string ActivityComment { get; set; }
+        public string UploadFileURL { get; set; }
+        public string Notes { get; set; }
+        public string Emailid { get; set; }
+        public string UserID { get; set; } // Yes User ID of the person updating. (kli.projects @luminad.com)
+        public string API_KEY { get; set; } // Yes API Key shared - 56ce9aa5-5aa4-4912-8dc4-ce65ffc88402
+        public string tranid { get; set; }
+        public string lotid { get; set; }
+    }
+
+    public class pubflow
+    {
+        public string Error { get; set; }
+        public string Message { get; set; }
+        public string Issue_ID { get; set; }
+    }
+
+    public class ResponseMsg
+    {
+        public Success success { get; set; }
+        public Failure Failure { get; set; }
+        //public string status { get; set; }
+        //public string status_message { get; set; }
+    }
+    public class XEditProResponseMsg
+    {
+        public string status { get; set; }
+        public string status_message { get; set; }
+        public string message { get; set; }
+        public string data { get; set; }
+        //public byte[] file { get; set; }
+        //public FileContentResult file { get; set; }
+    }
+    public class statusResponse
+    {
+        public string returnCode { get; set; }
+        public string action { get; set; }
+        public string details { get; set; }
+        public string order_id { get; set; }
+    }
+    public class inputjson
+    {
+        public string inputpayload { get; set; }
+    }
+    public class Success
+    {
+        public List<documents> documentid { get; set; }
+        public string message { get; set; }
+    }
+    public class Failure
+    {
+        public List<documents> documentid { get; set; }
+        public string message { get; set; }
+    }
+    public class documents
+    {
+        public string documentid { get; set; }
+    }
+    public class bpparamModel
+    {
+        public string requestid { get; set; } 
+        public string documentid { get; set; }
+        public string documentpath { get; set; }
+        public string title { get; set; }
+        public string editorInfo { get; set; }
+        public string product { get; set; }
+        public string UserID { get; set; } // Yes User ID of the person updating. (kli.projects @luminad.com)
+        public string tranid { get; set; }
+        public string jobid { get; set; }
+
+    }
+
+    public class insertDocumentModel
+    {
+        public string orderid { get; set; }
+        public string rootpath { get; set; }
+        //public CpDetails cpdetails { get; set; }
+        public Dictionary<string, string> cpdetails { get; set; }
+        public List<string> sourcetype { get; set; }
+        public string systemid { get; set; }
+        public string jobid { get; set; }
+        public string lotid { get; set; }
+    }
+    public class CpDetails
+    {
+        public string CUP { get; set; }
+    }
+
+    public class BPResponseMsg
+    {
+        public string responsecode { get; set; }
+        public string responsestatus { get; set; }
+    }
+
+    public class bpURLUpdateModel
+    {
+        public string requestid { get; set; }
+        public string documentid { get; set; }
+        public string url { get; set; }
+        public string UserID { get; set; } // Yes User ID of the person updating. (kli.projects @luminad.com)
+    }
+    public class reqUpdateUrlModel
+    {
+        public string chapuuid { get; set; }  
+        public string editorurl { get; set; }
+        public bool IsSuccess { get; set; }
+    }
+    public class CarConversionStatusModel
+    {
+        public string chapter_uuid { get; set; }
+        public string type { get; set; }
+        public string discard_reason { get; set; }
+        public string package_location { get; set; }
+    }
+    public class bpErrorModel
+    {
+        public string requestid { get; set; }
+        public string documentid { get; set; }
+        public string status { get; set; }
+        public string message { get; set; }
+        public string userid { get; set; } // Yes User ID of the person updating. (kli.projects @luminad.com)
+    }
+    public class statusUpdateModel
+    {
+        public string projectid { get; set; }
+        public string chapterid { get; set; }
+        public string stageid { get; set; }
+        public string status { get; set; }
+        public string? status_message { get; set; }
+        public string user_email { get; set; }
+        public bool IsCorrection { get; set; }
+        //public string token { get; set; }
+    }
+    public class carStatusUpdateModel
+    {
+        public string orderid { get; set; }// tpa id  
+        public string userid { get; set; }
+        public string status { get; set; }
+        public string timestamp { get; set; }
+        public string comments { get; set; }
+        public string stageuuid { get; set; }// stage uuid 
+       
+    }
+    public class loginModel
+    {
+        public string username { get; set; }
+        public string password { get; set; }
+    }
+    public class loginResponse
+    {
+        public string returnCode { get; set; }
+        public string action { get; set; }
+        public string details { get; set; }
+        public string jwtToken { get; set; }
+        //public string loginOutputResponse { get; set; }
+    }
+    public class loginOutputResponse
+    {
+        public string userid { get; set; }
+        public string user_name { get; set; }
+        public string username { get; set; }
+        //public string cpdetails { get; set; }
+       
+        public List<Dictionary<string, string>> cpdetails { get; set; }
+        //public string stagedetails { get; set; }
+        public List<string> stagedetails { get; set; }
+        public string Issuer { get; set; }
+        public string name { get; set; }
+        public string email { get; set; }
+    }
+    public class downloadFiles
+    {
+        public string chapuuid { get; set; }
+        public string stageuuid { get; set; }
+        public string fileurl { get; set; }
+    }
+    public class url
+    {
+        public string fileurl { get; set; }
+    }
+    public class lots
+    {
+        //public string lotid { get; set; }
+        //public string sequence { get; set; }
+        public string file_uuid { get; set; }
+    }
+    public class stitched_pdf_model
+    {
+        public string chapter_data { get; set; }
+        public string output_type { get; set; }
+        public string pdf_type { get; set; }
+        public string project_uuid { get; set; }
+        public string book_title { get; set; }
+        public string Return_url { get; set; }
+       
+    }
+    //public class xmldata
+    //{
+    //    public long orderid { get; set; }
+    //    public string ordertype { get; set; }
+    //    public string excutorid { get; set; }
+    //    public long parcelid { get; set; }
+    //    public long contentproviderid { get; set; }
+    //    public string duedate { get; set; }
+    //    public string sourcetype { get; set; }
+    //    public string sourcexml { get; set; }
+    //    public string mailtemplate { get; set; }
+    //    public string executortype { get; set; }
+    //    //public List<string> files { get; set; }
+    //    //public List<string> instructions { get; set; }
+    //    public Int64 iwoid { get; set; }
+    //    //adding below properties for car2tpa
+    //    public string workflowtype { get; set; }
+    //    public List<string> articles { get; set; }
+    //    public string journalTitle_no { get; set; }
+    //    public string issuexml { get; set; }
+    //    public string folder { get; set; }
+    //    public string zipfolder { get; set; }
+    //    public Int64? batchid { get; set; }
+    //    public string journaltitle { set; get; }
+    //    public string publishername { set; get; }
+    //    public string volume { set; get; }
+    //    public string issue { set; get; }
+    //    public string issn { set; get; }
+    //}
+    public class xmldata
+    {
+        public long orderid { get; set; }
+        public string ordertype { get; set; }
+        public string excutorid { get; set; }
+        public long parcelid { get; set; }
+        public long contentproviderid { get; set; }
+        public string duedate { get; set; }
+        public string sourcetype { get; set; }
+        public string sourcexml { get; set; }
+        public string mailtemplate { get; set; }
+        public string executortype { get; set; }
+        //public List<string> files { get; set; }
+        //public List<string> instructions { get; set; }
+        public Int64 iwoid { get; set; }
+        //adding below properties for car2tpa
+
+        public string workflowtype { get; set; }
+        public List<string> articles { get; set; }
+        public string journalTitle_no { get; set; }
+        public string issuexml { get; set; }
+        public string folder { get; set; }
+        public string zipfolder { get; set; }
+        public Int64? batchid { get; set; }
+        public string journaltitle { set; get; }
+        public string publishername { set; get; }
+        public string volume { set; get; }
+        public string issue { set; get; }
+        public string issn { set; get; }
+        public string inputzipname { set; get; }
+        public int fileCount { set; get; }
+        public string jobid { get; set; }
+    }
+    public class mailTemplateFields
+    {
+        public int ArticleCount { get; set; }
+        public string JournalTitle { get; set; }
+        public List<string> Articles { get; set; }
+        public string workflowtype { get; set; }
+        public string remark { get; set; }
+
+        public string User_Name { get; set; }
+        public string file_name { get; set; }
+        public string FTP_path { get; set; }
+        public string FTP_server_address { get; set; }
+        public string Team_Information { get; set; }
+        public string Team_Name { get; set; }
+        public string cause { get; set; }
+
+    }
+    public class contentprovide
+    {
+        public string content_provider_id { get; set; }
+        public string contentprovider { get; set; }
+        public string sftp_host { get; set; }
+        public string sftp_port { get; set; }
+        public string sftp_user { get; set; }
+        public string sftp_password { get; set; }
+        public string sftp_root { get; set; }
+    }
+    public class jobrequestModel
+    {
+        public string cpid { get; set; }// lotid 
+        public string userid { get; set; }
+        public string stageid { get; set; }
+        public int no_of_orders { get; set; }
+
+    }
+    public class XEditResponseMsg
+    {
+        public string returnCode { get; set; }
+        public string action { get; set; }
+        public string details { get; set; }
+        public List<string> order_ids { get; set; } = new List<string>();
+        //public byte[] file { get; set; }
+        //public FileContentResult file { get; set; }
+    }
+    public class s3model
+    {
+        public string bucketname { get; set; }
+        public string key { get; set; }
+        public string filepath { get; set; }
+        public string contenttype { get; set; }
+        public string accesskey { get; set; }
+        public string secretkey { get; set; }
+        public string regionendpoint { get; set; }
+    }
+}

+ 30 - 0
Elsevier_Scheduler/Elsevier_Scheduler.csproj

@@ -0,0 +1,30 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+<ItemGroup>
+    <None Remove="AppSetting.json" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Content Include="AppSetting.json">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="Dapper" Version="2.1.66" />
+    <PackageReference Include="Microsoft.AspNetCore" Version="2.3.0" />
+    <PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.7" />
+    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.7" />
+    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
+    <PackageReference Include="Npgsql" Version="4.1.14" />
+    <PackageReference Include="Quartz" Version="3.15.0" />
+    <PackageReference Include="SSH.NET" Version="2024.2.0" />
+  </ItemGroup>
+
+</Project>

+ 73 - 0
Elsevier_Scheduler/Models/Configuration/lotModel.cs

@@ -0,0 +1,73 @@
+    using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models.Configuration
+{
+    public class lotmasterModel
+    {
+        public Int64 lotid { get; set; }
+        public Int32 jobid { get; set; }
+        public string title { get; set; }
+        public Int32? sequence { get; set; }
+        public string instructions { get; set; }
+        public string filename { get; set; }
+        public Int32? priority { get; set; }
+        public string foldername { get; set; }
+        public Int64? totalunits { get; set; }
+        public string lotstatus { get; set; }
+        public Int32? pickedby { get; set; }
+        public Int32? withvendor { get; set; }
+        public string lotkey { get; set; }
+        public Int32? createdby { get; set; }
+        public DateTime? createdon { get; set; }
+        public Int32? updatedby { get; set; }
+        public DateTime? updatedon { get; set; }
+        public string xmlsource { get; set; }
+        public Int64? tathours { get; set; }
+        public Int32? chaptertypeid { get; set; }
+        public Int32? active { get; set; }
+        public Int64? transactionid { get; set; }
+        public string option { get; set; }
+        public string serverpath { get; set; }
+        public string username { get; set; }
+        public string password { get; set; }
+        public string domain { get; set; }
+        
+    }
+    public class lotfilesModel
+    {
+        public Int64 lotfileid { get; set; }
+        public Int64? lotid { get; set; }
+        public string filename { get; set; }
+        public Int32? active { get; set; }
+    }
+    public class chaptertypemastersModel
+    {
+        public Int64 chaptertypeid { get; set; }
+        public string chaptertype { get; set; }
+        public int? chpsequence { get; set; }
+        public int? active { get; set; }
+        public int? createdby { get; set; }
+        public DateTime? createddate { get; set; }
+        public int? updatedby { get; set; }
+        public DateTime? updateddate { get; set; }
+    }
+    public class lotcomment
+    {
+        public long transid { set; get; }
+        public string comment { set; get; }
+        public string doption { set; get; }
+        public string tostage { set; get; }
+        public long jobid { set; get; }
+        public long lotid { set; get; }
+        public string filename { set; get; }
+        public string lotstatus { set; get; }
+        public long userid { set; get; }
+        public string status { set; get; }
+        public string comments { set; get; }
+        public long jobworkflowid { set; get; }
+        public long tranid { set; get; }
+    }
+}

+ 37 - 0
Elsevier_Scheduler/Models/Configuration/mailconfigModel.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models.Configuration
+{
+    public class mailconfigModel
+    {
+        public int mailconfigid { get; set; }
+        public int mailtemplateid { get; set; }
+        public int? mailgroupid { get; set; }
+        public int dbid { get; set; }
+        public string mailconfigname { get; set; }
+        public string subject { get; set; }
+        public string mailcontent { get; set; }
+        public string groupmapped { get; set; }
+        public string mailgroup { get; set; }
+        public string mailto { get; set; }
+        public string mailcc { get; set; }
+        public int active { get; set; }
+        public int createdby { get; set; }
+        public string createdon { get; set; }
+        public int? modifiedby { get; set; }
+        public string modifiedon { get; set; }
+        public int? eventid { get; set; }
+        public int? formconfigid { get; set; }
+        public int? requesttypeid { get; set; }
+        public string scheduletype { get; set; }
+        public string schedulespecifictime { get; set; }
+        public int? scheduleinterval { get; set; }
+        public string scheduledays { get; set; }
+        public int? scheduleweeks { get; set; }
+        public string externalto { get; set; }
+        public string externalcc { get; set; }
+    }
+}

+ 25 - 0
Elsevier_Scheduler/Models/appsettingsModel.cs

@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    public class Appsettings
+    {
+        public string Secret { get; set; }
+        public string ConnectionString { get; set; }
+        public string ConnectionStringSchedule { get; set; }
+        public string emailhost { get; set; }
+        public string emailusername { get; set; }
+        public string emailpassword { get; set; }
+        public int forgotpassword { get; set; }
+        public int accessapprove { get; set; }
+        public int accessreject { get; set; }
+        public int useradd { get; set; }
+        public int accessrequest { get; set; }
+        public string emailbodylinkforgotpassword { get; set; }
+        public string emailbodylinkname { get; set; }
+    }
+  
+}

+ 66 - 0
Elsevier_Scheduler/Models/lapswatchercommonModel.cs

@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    public class lapswatchercommonModel
+    {
+    }
+    public class jsonvalue
+    {
+        public string json { set; get; }
+    }
+    public class resultvalue
+    {
+        public string p_tranid { set; get; }
+    }
+    public class returnojb
+    {
+        public string path { set; get; }
+        public string tranid { set; get; }
+        public string basexmlupdate { set; get; }
+        public string emp_name { set; get; }
+        public string ErrorObject { set; get; }
+        public string isTrack { set; get; }
+        public bool isProcessSuccess { set; get; }
+        public string curntstage { set; get; }
+        public string stagelist { set; get; }
+        public string lotid { set; get; }
+        public string projid { set; get; }
+        public string jobid { set; get; }
+        public string moveback { set; get; }
+        public string lotkey { set; get; }
+        public string Xmldata { set; get; }
+        public string stageorder { set; get; }
+        public string parentedition { set; get; }
+
+    }
+    public class appdetails
+    {
+        public Int32? jobworkflowid { get; set; }
+        public Int32? lotid { get; set; }
+        public Int32? jobid { get; set; }
+        public Int32? merged_lot { get; set; }
+        public Int32? batchid { get; set; }
+        public Int32? nextstage { get; set; }
+        public Int32? movebackstage { get; set; }
+        public string stagetype { get; set; }
+        public Int32? process_without_file { get; set; }
+        public string checkin_app { get; set; }
+        public string inprocessapp { get; set; }
+        public string checkout_app { get; set; }
+        public string exe_path { get; set; }
+        public string checkin_appwather { get; set; }
+        public string inprocessappwatcher { get; set; }
+        public string checkout_appwatcher { get; set; }
+        public string ipaexepath { get; set; }
+        public string coaexepath { get; set; }
+        public string is_checkin_exe { get; set; }
+        public int ciaisservice { get; set; }
+        public int ipaisservice { get; set; }
+        public int coaisservice { get; set; }
+    }
+ 
+}

+ 32 - 0
Elsevier_Scheduler/Models/mailtemplateModel.cs

@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Elsevier_Scheduler.Models
+{
+    class mailtemplateModel
+    {
+        public int mailtemplateid { get; set; }
+        public string mailtemplatename { get; set; }
+        public string subject { get; set; }
+        public string body { get; set; }
+        public int active { get; set; }
+        public int createdby { get; set; }
+        public string createdon { get; set; }
+        public int? updatedby { get; set; }
+        public string updatedon { get; set; }
+    }
+    public class mailboxModel
+    {
+        public int mail_id { get; set; }
+        public int transactionid { get; set; }
+        public string mailto { get; set; }
+        public string mailcc { get; set; }
+        public string mailbcc { get; set; }
+        public string mailsubject { get; set; }
+        public string mailbody { get; set; }
+        public string mailfrom { get; set; }
+        public int readflag { get; set; }
+        public int active { get; set; }
+    }
+}

+ 19 - 0
Elsevier_Scheduler/Models/sentemailhistoryModel.cs

@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    public class sentemailhistoryModel
+    {
+        public long id { get; set; }
+        public string emailid { get; set; }
+        public string Msg { get; set; }
+        public string status { get; set; }
+
+        public string eventdetails { get; set; }
+        public Int32? sentby { get; set; }
+        public DateTime? senton { get; set; }
+    }
+}

+ 194 - 0
Elsevier_Scheduler/Models/servermasterModel.cs

@@ -0,0 +1,194 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    public class servermasterModel
+    {
+        public int serverid { get; set; }
+        public string servertype { get; set; }
+        public string servername { get; set; }
+        public string ipaddress { get; set; }
+        public string username { get; set; }
+        public string password { get; set; }
+        public string domain { get; set; }
+        public string root_path { get; set; }
+        public int createdby { get; set; }
+        public string createddate { get; set; }
+        public int? modifiedby { get; set; }
+        public string modifieddate { get; set; }
+        public int active { get; set; }
+
+        public string serverpath { get; set; }
+        public string ostype { get; set; }
+
+    }
+    public class lotmasterModel
+    {
+        public Int64 lotid { get; set; }
+        public Int32 jobid { get; set; }
+        public string title { get; set; }
+        public Int32? sequence { get; set; }
+        public string instructions { get; set; }
+        public string filename { get; set; }
+        public Int32? priority { get; set; }
+        public string foldername { get; set; }
+        public Int64? totalunits { get; set; }
+        public string lotstatus { get; set; }
+        public Int32? pickedby { get; set; }
+        public Int32? withvendor { get; set; }
+        public string lotkey { get; set; }
+        public Int32? createdby { get; set; }
+        public DateTime? createdon { get; set; }
+        public Int32? updatedby { get; set; }
+        public DateTime? updatedon { get; set; }
+        public string xmlsource { get; set; }
+        public Int64? tathours { get; set; }
+        public Int32? chaptertypeid { get; set; }
+        public Int32? active { get; set; }
+        public Int64? transactionid { get; set; }
+        public Int64 tranid { set; get; }
+        public string option { get; set; }
+        public string p_option { get; set; }
+        public string serverpath { get; set; }
+        public string username { get; set; }
+        public string password { get; set; }
+        public string domain { get; set; }
+        public string docid { get; set; }
+        public string templatelist { set; get; }
+        public Int64? productionworkflowid { get; set; }
+        public Int32? ismovetoproduction { get; set; }
+        public long? jobworkflowid { set; get; }
+        public string cmnote { get; set; }
+        public Int64? plotid { get; set; }
+        public Int64? lottype { get; set; }
+        public Int64? level { get; set; }
+        public Int32? isword { get; set; }
+        public string uuidkey { set; get; }
+        public Int32 chaptersubtype { set; get; }
+        public string editorurl { get; set; }
+        public Int64? iwoid { get; set; }
+        public Int64? cpid { get; set; }
+        public Int64? batchid { get; set; }
+        public string doi { get; set; }
+        public string type { get; set; }
+    }
+    public class jobModel
+    {
+        public long jobid { set; get; }
+        public long projectdefinitionid { set; get; }
+        public string jobno { set; get; }
+        public string title { set; get; }
+        public string isbn { set; get; }
+        public int totallots { set; get; }
+        public string startdate { set; get; }
+        public string enddate { set; get; }
+        public string jobstatus { set; get; }
+        public string filename { set; get; }
+        public int complexityid { set; get; }
+        public int isreadyforpurge { set; get; }
+        public int total_rec_count { set; get; }
+        public string jobkey { set; get; }
+        public int projectid { set; get; }
+        public string xmlsource { set; get; }
+        public int auto_lot_creation { set; get; }
+        public int ftpserver { set; get; }
+        public string jobmetadata { set; get; }
+        public bool isdaterequired { set; get; }
+        public string completeddate { set; get; }
+        public int createdby { set; get; }
+        public string createdon { set; get; }
+        public int updatedby { set; get; }
+        public string updatedon { set; get; }
+        public Int64? correctionrounds { set; get; }
+        public string revisedenddate { set; get; }
+        public string uuidkey { set; get; }
+        public Int64? ispdfreview { set; get; }
+        public Int64? isepubreview { set; get; }
+        public string issn { set; get; }
+        public string journaltitle { set; get; }
+        public string publishername { set; get; }
+        public string volume { set; get; }
+        public string issue { set; get; }
+    }
+    public class jobworkflow
+    {
+        public string stageid { set; get; }
+        public string jobworkflowid { set; get; }
+        public string stagename_alias { set; get; }
+    }
+    public class jobworkflowdefinitionModel
+    {
+        public long jobworkflowid { set; get; }
+        public long tatjobworkflowid { set; get; }
+        public Int32? jobid { set; get; }
+        public Int32? wfdid { set; get; }
+        public Int32? stage_type { set; get; }
+        public string stagename_alias { set; get; }
+        public Int32? parallelstage { set; get; }
+        public Int32? nextstage { set; get; }
+        public Int32? movebackstage { set; get; }
+        public Int32? resetstage { set; get; }
+        public Int32? process_without_file { set; get; }
+        public Int32? hidebypass { set; get; }
+        public Int32? hidereverse { set; get; }
+        public Int32? merged_lot { set; get; }
+        public Int32? unmerge_lot { set; get; }
+        public Int32? file_movement { set; get; }
+        public string allocation_mode { set; get; }
+        public Double? benchmark { set; get; }
+        public string folder_name { set; get; }
+        public Int32? show_file_browser { set; get; }
+        public Int32? unit { set; get; }
+        public Int32? checkin_app { set; get; }
+        public Int32? checkout_app { set; get; }
+        public Int32? file_server { get; set; }
+        public Int32 active { set; get; }
+        public Int32? createdby { set; get; }
+        public DateTime? createddate { set; get; }
+        public Int32? updatedby { set; get; }
+        public DateTime? updateddate { set; get; }
+        public Int32? allocationtype { set; get; }
+        public Int32? stageorder { set; get; }
+        public Int32? stageid { set; get; }
+        public Int32? signoffnotification { set; get; }
+        public Int32? mailtemplate { set; get; }
+        public Int32? inprocessapp { set; get; }
+        public string jobmetadata { set; get; }
+        public Int32? mailattachment { set; get; }
+        public Int32? checklistlog { set; get; }
+        public Int32? checklisttemplateid { set; get; }
+        public Int32? acknowledgement { set; get; }
+        public Int32? ackmailtemplate { set; get; }
+        public Int32? pmnotification { set; get; }
+        public Int32? pmmailtemplate { set; get; }
+        public Int64? tathours { set; get; }
+        public string tattype { set; get; }
+        public Int32? querycompilation { set; get; }
+        public Int32? querycomtemplateid { set; get; }
+        public Int32? querybatch { set; get; }
+        public Int32? backmatterstart { set; get; }
+        public Int32? frontmatterstart { set; get; }
+        public Int32? isfinalsubstage { set; get; }
+        public Int32? parentstagewfdid { set; get; }
+        public Int32? islotenable { set; get; }
+        public Int64? lotid { get; set; }
+        public string multiplemoveback { get; set; }
+        public Int32? issubworkflow { set; get; }
+        public Int32? subworkflowid { set; get; }
+        public Int32? issubworkflowstage { set; get; }
+        public Int32 ispp { set; get; }
+        public Int32? isinternalcorrection { set; get; }
+        public Int32 stageorder_with_crt { set; get; }
+        public string startdate { get; set; }
+        public string enddate { get; set; }
+        public Int32? earlierstart { set; get; }
+        public Int32? earlierfinish { set; get; }
+        public Int32? lateststart { set; get; }
+        public Int32? latestfinish { set; get; }
+        public Int32? totalfloat { set; get; }
+        public string freefloat { get; set; }
+    }
+}

+ 33 - 0
Elsevier_Scheduler/Models/userModel.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    public class userModel
+    {
+    }
+    public class useractivitylogModel
+    {
+        public int userlogid { get; set; }
+        public int userid { get; set; }
+        public string useraction { get; set; }
+        public string dateofaction { get; set; }
+        public string ipaddress { get; set; }
+        public string description { get; set; }
+    }
+    public class featureModel
+    {
+        public Int64 metadataid { get; set; }
+        public string mdata { get; set; }
+        public Int32 active { get; set; }
+        public Int32? createdby { get; set; }
+        public DateTime? createdon { get; set; }
+        public Int32? updatedby { get; set; }
+        public DateTime? updatedon { get; set; }
+        public string createdbyname { get; set; }
+        public string updatedbyname { get; set; }
+        public Int32? appurlid { get; set; }
+    }
+}

+ 107 - 0
Elsevier_Scheduler/Models/workareaModel.cs

@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Elsevier_Scheduler.Models
+{
+    public class workareaModel
+    {
+    }
+
+    public class FileDetails
+    {
+        public string FileName { get; set; }
+        public string FilePath { get; set; }
+        public long size { get; set; }
+        public DateTime lastModified { get; set; }
+    }
+    public class Fields
+    {
+        public long transid { set; get; }
+        public string fields { set; get; }
+        public string option { set; get; }
+        public string comment { set; get; }
+        public string cflag { set; get; }
+        public string userid { set; get; }
+        public long batchid { get; set; }
+
+        public string p_option { set; get; }
+    }
+  
+    public class lot_tran_info
+    {
+        public string p_tranid { set; get; }
+        public string p_userid { set; get; }
+        public string p_option { set; get; }
+        public string p_XmlName { set; get; }
+        public string p_holdreason { set; get; }
+        public string basexmlUpdate { set; get; }
+        public string stageorder { set; get; }
+    }
+
+    public class jobmetafields
+    {
+        public string name { get; set; }
+        public string type { get; set; }
+        public string label { get; set; }
+        public string workflowdid { get; set; }
+        public string value { get; set; }
+        public string status { get; set; }
+    }
+
+
+    public class insertcomments
+    {
+        public long transid { set; get; }
+        public string comment { set; get; }
+        public string doption { set; get; }
+        public string tostage { set; get; }
+        public long jobid { set; get; }
+        public long lotid { set; get; }
+        public string filename { set; get; }
+        public string lotstatus { set; get; }
+        public long userid { set; get; }
+        public string status { set; get; }
+        public string comments { set; get; }
+        public long jobworkflowid { set; get; }
+        public long tranid { set; get; }
+        public string transactionkey { set; get; }
+        public string p_option{set;get;}
+
+    }
+    public class lottraninfo
+    {
+        public string p_tranid { set; get; }
+        public string p_userid { set; get; }
+        public string p_option { set; get; }
+        public string p_XmlName { set; get; }
+        public string p_holdreason { set; get; }
+        public string basexmlUpdate { set; get; }
+        public string stageorder { set; get; }
+    }
+   
+
+    public class JobWorkflow_
+    {
+        public string jobworkflowid { set; get; }
+        public string jobid { set; get; }
+        public string lotid { set; get; }
+        public string batchid { set; get; }
+        public string lotstatus { set; get; }
+        public string p_option { set; get; }
+    }
+
+    public class StageData
+    {
+        public string CURRENT { set; get; }
+        public string NEXT { set; get; }
+        public string PARALLEL { set; get; }
+        public string MOVEBACKYES { set; get; }
+        public string MOVEBACKNO { set; get; }
+    }
+    public class transout
+    {
+        public string p_tranid { get; set; }
+    }
+}

+ 265 - 0
Elsevier_Scheduler/Program.cs

@@ -0,0 +1,265 @@
+using Dapper;
+using Elsevier_Scheduler.App_Data;
+using Elsevier_Scheduler.Configure;
+using Elsevier_Scheduler.Models;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using Quartz;
+using Quartz.Impl;
+using System;
+using System.Data;
+using System.Reflection.Metadata;
+using System.Runtime.InteropServices;
+using System.Threading.Tasks;
+using Renci.SshNet;
+using Microsoft.Extensions.Configuration;
+
+class Program
+{
+    static async Task Main(string[] args)
+    {
+        // 1️⃣ Create a scheduler
+        StdSchedulerFactory factory = new StdSchedulerFactory();
+        IScheduler scheduler = await factory.GetScheduler();
+
+        // 2️⃣ Start the scheduler
+        await scheduler.Start();
+
+        // 3️⃣ Define the job
+        IJobDetail job = JobBuilder.Create<MyJob1>()
+                                   .WithIdentity("job1", "group1")
+                                   .Build();
+
+        // 4️⃣ Define a trigger (every 10 seconds)
+        ITrigger trigger = TriggerBuilder.Create()
+                                         .WithIdentity("trigger1", "group1")
+                                         .StartNow()
+                                         .WithSimpleSchedule(x => x
+                                             .WithIntervalInSeconds(60)
+                                             .RepeatForever())
+                                         .Build();
+
+        //await scheduler.ScheduleJob(job, trigger);
+        await scheduler.ScheduleJob(job, new[] { trigger }, replace: true);
+        Console.WriteLine("Scheduler started. Press any key to exit...");
+        Console.ReadKey();
+        // 6️⃣ Shutdown when finished
+        await scheduler.Shutdown();
+    }
+}
+
+public class MyJob1 : IJob
+{
+    public Task Execute(IJobExecutionContext context)
+    {
+
+        string sftpHostName = CustomConfiguration.AppSettings.GetValue<string>("AppSettings:sftpHostName").ToString();
+        int sftpport = CustomConfiguration.AppSettings.GetValue<int>("AppSettings:sftpport");
+        string sftpusername = CustomConfiguration.AppSettings.GetValue<string>("AppSettings:sftpusername").ToString();
+        string sftppassword = CustomConfiguration.AppSettings.GetValue<string>("AppSettings:sftppassword").ToString();
+        string remotePath = CustomConfiguration.AppSettings.GetValue<string>("AppSettings:conferencesftpwatcher").ToString();
+        using (var sftp = new SftpClient(sftpHostName, Convert.ToInt32(sftpport), sftpusername, sftppassword))
+        {
+            try
+            {
+                sftp.Connect();
+                var files = sftp.ListDirectory(remotePath)
+                                .Where(f => !f.IsDirectory && !f.Name.StartsWith("."))
+                                .ToList();
+                foreach (var file in files)
+                {
+                    Console.WriteLine($"Checking {file.Name}...");
+
+                    // Step 1: check if file size is stable
+                    long size1 = file.Attributes.Size;
+                    Thread.Sleep(1000); // wait 5 sec
+                    var refreshed = sftp.GetAttributes(file.FullName);
+                    long size2 = refreshed.Size;
+                    if (size1 == size2) // stable size → ready for download
+                    {
+                        var inpujson = (dynamic)null; string input = String.Empty;
+                        var obj = new { filename = Path.GetFileName(file.FullName) };
+                        input = JsonConvert.SerializeObject(obj);
+                        // validation add
+                        var translist = CommonRepository.ExecuteSP_ReturnList2("public.splottransactionselect", input.ToString(), "con_detailgetbyfilename");
+                        if (translist != null)
+                        {
+                            var dt = JArray.Parse(translist.ToString());
+                            var objlotrans = JObject.Parse(dt[0].ToString());
+                            string tranid = objlotrans["transactionid"].ToString();
+                            string lotid = objlotrans["lotid"].ToString();
+                            string stage = objlotrans["stage"].ToString();
+                            string nextstage_serverpath = GetServerPath(tranid.ToString(), "serverinfo", true);
+                            if (!Directory.Exists(Path.Combine(nextstage_serverpath, "IN")))
+                            {
+                                Directory.CreateDirectory(Path.Combine(nextstage_serverpath, "IN"));
+                            }
+                            using (var fs = System.IO.File.Create(Path.Combine(nextstage_serverpath, "IN", Path.GetFileName(file.FullName))))
+                            {
+                                sftp.DownloadFile(file.FullName, fs);
+                            }
+                            string targetFolder = Path.Combine(remotePath, "processed");
+                            // ✅ Create folder if not exists
+                            if (!sftp.Exists(targetFolder))
+                            {
+                                sftp.CreateDirectory(targetFolder);
+                                Console.WriteLine($"Created folder: {targetFolder}");
+                            }
+                            string sourceFile = remotePath + "/" + Path.GetFileName(file.FullName);
+                            string destinationFile = targetFolder + "/" + Path.GetFileName(file.FullName);
+
+                            // ✅ Move file (rename in SFTP = move)
+                            if (sftp.Exists(destinationFile))
+                            {
+                                sftp.DeleteFile(destinationFile);
+                            }
+                            sftp.RenameFile(sourceFile, destinationFile);
+                            Console.WriteLine($"Moved {Path.GetFileName(file.FullName)} to {targetFolder}");
+
+                            var checkoutc = getCheckout(tranid, null, "R", "checkout_currentstage", "0", "", lotid.ToString());
+                        }
+                        else
+                        {
+                            string targetFolder = Path.Combine(remotePath, "notprocessed");
+                            // ✅ Create folder if not exists
+                            if (!sftp.Exists(targetFolder))
+                            {
+                                sftp.CreateDirectory(targetFolder);
+                                Console.WriteLine($"Created folder: {targetFolder}");
+                            }
+                            string sourceFile = remotePath + "/" + Path.GetFileName(file.FullName);
+                            string destinationFile = targetFolder + "/" + Path.GetFileName(file.FullName);
+
+                            // ✅ Move file (rename in SFTP = move)
+                            // If destination exists, delete it first
+                            if (sftp.Exists(destinationFile))
+                            {
+                                sftp.DeleteFile(destinationFile);
+                            }
+                            sftp.RenameFile(sourceFile, destinationFile);
+                            Console.WriteLine($"Moved {Path.GetFileName(file.FullName)} to {targetFolder}");
+                        }
+                    }
+                    else
+                    {
+                        Console.WriteLine($"Skipping {file.Name}, still uploading...");
+                    }
+                }
+                sftp.Disconnect();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("Error: " + ex.Message);
+            }
+        }
+
+        return Task.CompletedTask;
+    }
+    public static string GetServerPath(string transactionid, string mode, bool createdir = false)
+    {
+        string serverpath = string.Empty;
+        try
+        {
+            Console.WriteLine("GetServerPath:transactionid=" + transactionid + ", mode=" + mode);
+            using (IDbConnection dbConnection = ConnectionBase.Connection)
+            {
+                bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+                if (isWindows)
+                {
+                    dbConnection.Open();
+                    var param = new DynamicParameters();
+                    const string query = @"public.spusrserverpathinfo";
+                    param.Add("p_tranid", dbType: DbType.Int32, value: Convert.ToInt32(transactionid), direction: ParameterDirection.Input);
+                    param.Add("p_lotid", dbType: DbType.Int32, value: null, direction: ParameterDirection.Input);
+                    param.Add("p_option", dbType: DbType.String, value: mode, direction: ParameterDirection.Input);
+                    param.Add("p_ostype", dbType: DbType.String, value: "Windows", direction: ParameterDirection.Input);
+                    IEnumerable<servermasterModel> sm = dbConnection.Query<servermasterModel>(query, param, commandType: CommandType.StoredProcedure);
+                    if (createdir)
+                    {
+                        serverpath = FormatPath(sm.First().serverpath.ToString());
+                        Directory.CreateDirectory(Path.Combine(serverpath, "IN"));
+                        Directory.CreateDirectory(Path.Combine(serverpath, "OUT"));
+                    }
+                    else
+                    {
+                        serverpath = FormatPath(sm.First().serverpath.ToString());
+                    }
+                }
+                else
+                {
+                    dbConnection.Open();
+                    var param = new DynamicParameters();
+                    const string query = @"public.spusrserverpathinfo";
+                    param.Add("p_tranid", dbType: DbType.Int32, value: Convert.ToInt32(transactionid), direction: ParameterDirection.Input);
+                    param.Add("p_lotid", dbType: DbType.Int32, value: null, direction: ParameterDirection.Input);
+                    param.Add("p_option", dbType: DbType.String, value: mode, direction: ParameterDirection.Input);
+                    param.Add("p_ostype", dbType: DbType.String, value: "Linux", direction: ParameterDirection.Input);
+                    IEnumerable<servermasterModel> sm = dbConnection.Query<servermasterModel>(query, param, commandType: CommandType.StoredProcedure);
+                    if (createdir)
+                    {
+                        serverpath = sm.First().serverpath.ToString().Replace("\\", "/");
+                        Directory.CreateDirectory(Path.Combine(serverpath, "IN"));
+                        Directory.CreateDirectory(Path.Combine(serverpath, "OUT"));
+                    }
+                    else
+                    {
+                        serverpath = sm.First().serverpath.ToString().Replace("\\", "/");
+                    }
+                }
+            }
+        }
+        catch (Exception ex)
+        {
+            Console.WriteLine(ex.Message.ToString());
+            return serverpath;
+        }
+        return serverpath;
+    }
+    private static string FormatPath(string inputpath)
+    {
+        try
+        {
+            inputpath = inputpath.Replace("/", "\\");
+            inputpath = inputpath.Replace("\\\\", "");
+            inputpath = System.Text.RegularExpressions.Regex.Replace(inputpath, @"\\\\", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
+
+        }
+        catch (Exception ex)
+        {
+            Console.WriteLine(ex.Message.ToString());
+        }
+        return string.Concat("\\\\", inputpath);
+    }
+    public static List<jsonvalue> getCheckout(string trans_id, string p_userid, string status, string option, string jobworkflowid, string p_comments = "", string lotid = "0", string backto = "0")
+    {
+        if (lotid == "") { lotid = "0"; }
+        if (jobworkflowid == "") { jobworkflowid = "0"; }
+        var data = new { p_tranid = trans_id, p_userid = p_userid, p_status = status, p_option = option, n_jobworkflowid = jobworkflowid, p_comments = p_comments, n_lotid = lotid, p_backto = backto };
+        var jsonstr = JsonConvert.SerializeObject(data);
+        CommonRepository.WriteActionLog("Param:jsonstr" + jsonstr);
+        var res = CommonRepository.ExecuteSP_ReturnList1("spusrlottranupdatev2", jsonstr);
+
+        CommonRepository.WriteActionLog("RequestConsumer:getCheckout:p_status" + status);
+        CommonRepository.WriteActionLog("RequestConsumer:getCheckout:trans_id" + trans_id);
+        CommonRepository.WriteActionLog("RequestConsumer:getCheckout:option" + option);
+        CommonRepository.WriteActionLog("RequestConsumer:getCheckout:jobworkflowid" + jobworkflowid);
+        CommonRepository.WriteActionLog("RequestConsumer:getCheckout:lotid" + lotid);
+
+        System.Collections.Generic.List<jsonvalue> appdetails1 = new List<jsonvalue>();
+        jsonvalue dd = new jsonvalue();
+        dd.json = res.ToString();
+        appdetails1.Add(dd);
+
+        return appdetails1;
+    }
+
+}
+
+public class MyJob2 : IJob
+{
+    public Task Execute(IJobExecutionContext context)
+    {
+        Console.WriteLine($"[{DateTime.Now}] Job 2 executed!");
+        return Task.CompletedTask;
+    }
+}

+ 468 - 0
Elsevier_Scheduler/ServiceController/ServerInfo.cs

@@ -0,0 +1,468 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Npgsql;
+using NpgsqlTypes;
+using System.Data;
+using System.Security.Principal;
+using System.Runtime.InteropServices;
+using System.Configuration;
+using System.Xml;
+using Microsoft.Extensions.Configuration;
+using Newtonsoft.Json;
+using Dapper;
+using System.Net.Mail;
+using System.Net;
+using Elsevier_Scheduler.App_Data;
+using Elsevier_Scheduler.Models;
+using Elsevier_Scheduler.Configure;
+
+namespace Elsevier_Scheduler
+{
+    public class ServerInfo
+    {
+        private string connstring = string.Empty;
+        private NpgsqlConnection conn = new NpgsqlConnection();
+        protected string query { get; set; }
+        public ServerInfo()
+        {
+            this.connstring = GetConfigValue();
+            //this.connstring = String.Format("Server={0}; User Id={1}; Database={2}; Port={3}; Password={4}; SSL Mode=Prefer; Trust Server Certificate=true", "172.16.1.99", "postgres", "livewms", "5432", "ssg@1234");
+            this.conn = new NpgsqlConnection(connstring);
+        }
+        public static string connStrings { get; set; }
+        public static string username { get; set; }
+        public static string password { get; set; }
+        public static string domain { get; set; }
+        public static string ipaddress { get; set; }
+        private string GetConfigValue()
+        {
+            string convalue = string.Empty;
+            try
+            {
+                // convalue = System.Configuration.ConfigurationSettings.AppSettings["postprovide"].ToString();
+                convalue = CustomConfiguration.AppSettings.GetValue<string>("");
+
+                // convalue = Program.Enviroinment;
+                /*var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
+                var location = executingAssembly.Location;
+                string configfile = System.Text.RegularExpressions.Regex.Replace(location, ".([a-z]+)$", ".config", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
+                XmlDocument doc = new XmlDocument();
+                doc.Load(configfile);
+                XmlNode addnode = doc.SelectSingleNode("//appSettings/add");
+                convalue = addnode.Attributes["value"].Value;
+                doc = null;*/
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message.ToString());
+            }
+            return convalue;
+        }
+        /// To insert the newly added role information
+        public int addlog(object data, string mastername)
+        {
+            using (IDbConnection dbConnection = ConnectionBase.Connection)
+            {
+                dbConnection.Open();
+                string input = JsonConvert.SerializeObject(data);
+                int result = 0;
+                string query = @"public.sp" + mastername;
+                var param = new DynamicParameters();
+                param.Add("inputjsonstr", dbType: DbType.String, value: input, direction: ParameterDirection.Input);
+                param.Add("mode_p", dbType: DbType.String, value: "insert", direction: ParameterDirection.Input);
+                result = dbConnection.Query<int>(query, param, commandType: CommandType.StoredProcedure).First();
+                return result;
+            }
+        }
+        public DataTable GetDataTable(string funname, List<NpgsqlParameter> paramet)
+        {
+            NpgsqlConnection postgrescon = new NpgsqlConnection(CustomConfiguration.AppSettings["DBInfo:ConnectionString"]);
+            DataTable dtable = new DataTable();
+            try
+            {
+                NpgsqlCommand cmd = new NpgsqlCommand(funname, postgrescon);
+                if (paramet != null)
+                {
+                    foreach (NpgsqlParameter sqlpara in paramet)
+                        cmd.Parameters.Add(sqlpara);
+                    cmd.CommandType = CommandType.StoredProcedure;
+                }
+                else
+                {
+                    cmd.CommandType = CommandType.Text;
+                }
+                NpgsqlDataAdapter adp = new NpgsqlDataAdapter(cmd);
+                adp.Fill(dtable);
+                postgrescon.Close();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("ServerInfo:GetDataTable:funname" + funname);
+                Console.WriteLine(ex.StackTrace);
+                postgrescon.Close();
+            }
+            return dtable;
+        }
+        private List<NpgsqlParameter> GetNpgsqlParameter(string transid, int lotid, string process)
+        {
+            List<NpgsqlParameter> parametr = new List<NpgsqlParameter>();
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_tranid", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer, Value = transid });
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_lotid", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer, Value = lotid });
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_option", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar, Value = process });
+            return parametr;
+        }
+        private List<NpgsqlParameter> GetNpgsqlParameter(int transid, int lotid, string process, string ostype)
+        {
+            List<NpgsqlParameter> parametr = new List<NpgsqlParameter>();
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_tranid", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer, Value = transid });
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_lotid", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Integer, Value = lotid });
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_option", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar, Value = process });
+            parametr.Add(new NpgsqlParameter { ParameterName = "p_ostype", NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar, Value = ostype });
+            return parametr;
+        }
+        private string GetPath(string sqlquery)
+        {
+            string serverpath = string.Empty;
+
+            try
+            {
+                DataSet ds = GetDataSet(sqlquery);
+                if (ds.Tables.Count > 0)
+                {
+                    return FormatPath(ds.Tables[0].Rows[0]["serverpath"].ToString());
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message.ToString());
+            }
+            return serverpath;
+        }
+        public DataSet GetDataSet(string query)
+        {
+            DataSet ds = new DataSet();
+
+            try
+            {
+                NpgsqlCommand cmd = conn.CreateCommand();
+                NpgsqlDataAdapter da = new NpgsqlDataAdapter();
+                cmd.CommandText = query;
+                da.SelectCommand = cmd;
+                conn.Open();
+                da.Fill(ds);
+                conn.Close();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message.ToString());
+            }
+            return ds;
+        }
+        public string GetServerPath(string transactionid, string mode, bool createdir = false)
+        {
+            string serverpath = string.Empty;
+            try
+            {
+                Console.WriteLine("GetServerPath:transactionid=" + transactionid + ", mode=" + mode);
+                using (IDbConnection dbConnection = ConnectionBase.Connection)
+                {
+                    bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+                    if (isWindows)
+                    {
+                        dbConnection.Open();
+                        var param = new DynamicParameters();
+                        const string query = @"public.spusrserverpathinfo";
+                        param.Add("p_tranid", dbType: DbType.Int32, value: Convert.ToInt32(transactionid), direction: ParameterDirection.Input);
+                        param.Add("p_lotid", dbType: DbType.Int32, value: null, direction: ParameterDirection.Input);
+                        param.Add("p_option", dbType: DbType.String, value: mode, direction: ParameterDirection.Input);
+                        param.Add("p_ostype", dbType: DbType.String, value: "Windows", direction: ParameterDirection.Input);
+                        IEnumerable<servermasterModel> sm = dbConnection.Query<servermasterModel>(query, param, commandType: CommandType.StoredProcedure);
+                        if (createdir)
+                        {
+                            serverpath = FormatPath(sm.First().serverpath.ToString());
+                            Directory.CreateDirectory(Path.Combine(serverpath, "IN"));
+                            Directory.CreateDirectory(Path.Combine(serverpath, "OUT"));
+                        }
+                        else
+                        {
+                            serverpath = FormatPath(sm.First().serverpath.ToString());
+                        }
+                    }
+                    else
+                    {
+                        dbConnection.Open();
+                        var param = new DynamicParameters();
+                        const string query = @"public.spusrserverpathinfo";
+                        param.Add("p_tranid", dbType: DbType.Int32, value: Convert.ToInt32(transactionid), direction: ParameterDirection.Input);
+                        param.Add("p_lotid", dbType: DbType.Int32, value: null, direction: ParameterDirection.Input);
+                        param.Add("p_option", dbType: DbType.String, value: mode, direction: ParameterDirection.Input);
+                        param.Add("p_ostype", dbType: DbType.String, value: "Linux", direction: ParameterDirection.Input);
+                        IEnumerable<servermasterModel> sm = dbConnection.Query<servermasterModel>(query, param, commandType: CommandType.StoredProcedure);
+                        if (createdir)
+                        {
+                            serverpath = sm.First().serverpath.ToString().Replace("\\","/");
+                            Directory.CreateDirectory(Path.Combine(serverpath, "IN"));
+                            Directory.CreateDirectory(Path.Combine(serverpath, "OUT"));
+                        }
+                        else
+                        {
+                            serverpath = sm.First().serverpath.ToString().Replace("\\", "/");
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message.ToString());
+                return serverpath;
+            }
+            return serverpath;
+        }
+        public string GrantFolderPermissions(string transactionid, string lotid = null)
+        {
+            string ostype = "Windows";
+            bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
+            if (isWindows)
+            {
+                ostype = "Windows";
+            }
+            else
+            {
+                ostype = "Linux";
+            }
+            if (string.IsNullOrEmpty(transactionid))
+            {
+                username = CustomConfiguration.AppSettings["username"];
+                password = CustomConfiguration.AppSettings["password"];
+                domain = CustomConfiguration.AppSettings["domain"];
+                return string.Concat(domain, ",", username, ",", password);
+            }
+            else
+            {
+                DataTable ds = null;
+                if (!string.IsNullOrEmpty(transactionid))
+                    ds = GetDataTable("spusrserverpathinfo", GetNpgsqlParameter(Convert.ToInt32(transactionid), 0, "logininfo", ostype));
+                else if (!string.IsNullOrEmpty(lotid))
+                    ds = GetDataTable("spusrserverpathinfo", GetNpgsqlParameter(0, Convert.ToInt32(lotid), "loginlotinfo", ostype));
+                if (ds.Rows.Count > 0)
+                {
+                    return string.Concat(ds.Rows[0]["domain"].ToString(), ",", ds.Rows[0]["username"].ToString(), ",", ds.Rows[0]["password"].ToString());
+                }
+                else
+                {
+                    username = CustomConfiguration.AppSettings["username"];
+                    password = CustomConfiguration.AppSettings["password"];
+                    domain = CustomConfiguration.AppSettings["domain"];
+                    return string.Concat(domain, ",", username, ",", password);
+                }
+            }
+        }
+        private static string FormatPath(string inputpath)
+        {
+            try
+            {
+                inputpath = inputpath.Replace("/", "\\");
+                inputpath = inputpath.Replace("\\\\", "");
+                inputpath = System.Text.RegularExpressions.Regex.Replace(inputpath, @"\\\\", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
+
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message.ToString());
+            }
+            return string.Concat("\\\\", inputpath);
+        }
+        public void SendEmail(string htmlString, string subj)
+        {
+            try
+            {
+                var tempstring = "<p> Hi Team, <br> <br> . " +
+                            "<br> </p> <br>";
+                htmlString = "<table style='border: 1px solid black;'>" + tempstring + "</table> <br><p>For any queries or support, reach out to <a href='lumina.tech2@luminad.com'>lumina.tech2@luminad.com</a>.<br><br>Regards,<br><br>LAPS Team </p>";
+                string sub1 = CustomConfiguration.AppSettings["AppSettings:mail_subject"].ToString();
+                string emailhost = CustomConfiguration.AppSettings["AppSettings:emailhost"].ToString();
+                string emailusername = CustomConfiguration.AppSettings["AppSettings:emailusername"].ToString();
+                string emailpassword = CustomConfiguration.AppSettings["AppSettings:emailpassword"].ToString();
+                string ToMailid = CustomConfiguration.AppSettings["AppSettings:mail_tomail"].ToString();
+                string CCMail = CustomConfiguration.AppSettings["AppSettings:mail_ccmail"].ToString();
+                string BCCMail = CustomConfiguration.AppSettings["AppSettings:mail_bccmail"].ToString();
+                Console.WriteLine("...Calling SendEmail on" + DateTime.Now);
+                var torecipient = ToMailid.Split(';');
+                MailMessage message = new MailMessage();
+                SmtpClient smtp = new SmtpClient();
+                message.From = new MailAddress(emailusername);
+                foreach (var item in torecipient)
+                {
+                    message.To.Add(new MailAddress(item));
+                }
+                var CCMailrecipient = CCMail.Split(';');
+                foreach (var item in CCMailrecipient)
+                {
+                    message.CC.Add(new MailAddress(item));
+                }
+                var BCCMailrecipient = BCCMail.Split(';');
+                foreach (var item in BCCMailrecipient)
+                {
+                    message.Bcc.Add(new MailAddress(item));
+                }
+                message.Subject = subj;
+                message.IsBodyHtml = true; //to make message body as html  
+                message.Body = htmlString;
+                smtp.Port = 587;
+                smtp.Host = emailhost; //for gmail host  
+                smtp.EnableSsl = true;
+                smtp.UseDefaultCredentials = false;
+                smtp.Credentials = new NetworkCredential(emailusername, emailpassword);
+                smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
+                smtp.Send(message);
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(".........Catch Exception on downloadin file....[" + ex.Message.ToString() + "].....");
+                ////string sQry = "insertmail_error";
+                ////List<NpgsqlParameter> paramet = new List<NpgsqlParameter>();
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.Int64, ParameterName = "p_tranid", Value = 0 });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_subject", Value = Convert.ToString("") });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_frommail", Value = "" });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_to", Value = String.Join(";", "") });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_body", Value = Convert.ToString("") });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_error_message", Value = Convert.ToString(ex.Message) });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_application", Value = Convert.ToString("UrsaApi") });
+                ////paramet.Add(new NpgsqlParameter() { DbType = DbType.String, ParameterName = "p_methodname", Value = Convert.ToString("SFTP") });
+                ////modcommon.nz(DBLibrary.insertdataScalar(sQry, paramet));
+            }
+
+        }
+        public class GrantFolderPermission : IDisposable
+        {
+            ServerInfo info = new ServerInfo();
+            private bool id;
+            Impartunate impartunate = null;
+
+            public GrantFolderPermission(string transactionid)
+            {
+
+                var data = new
+                {
+                    transactionid = transactionid,
+                    lotid = 0,
+                    option = "logininfo"
+                };
+
+                string inputstr = JsonConvert.SerializeObject(data);
+                var ds = CommonRepository.getfilesavelocation("spusrserverpathinfo", inputstr);
+                // var ds = CommonRepository.ExecuteSP_ReturnListForLot("spusrserverpathinfo", inputstr, "logininfo");
+
+                // DataSet ds = info.GetDataTable("usr_server_path_info", info.GetNpgsqlParameter(transactionid, 0, "logininfo"));
+
+                /*string query = @"select  lt.transactionid, sm.ipaddress, sm.username, sm.password, sm.domain  from lot_transaction as lt 
+                                Left join lot_master lm on lt.lotid=lm.lotid 
+                                left join job_master jm on lm.jobid = jm.jobid
+                                left join project_definition pd on jm.projectdefinitionid = pd.projectdefinitionid
+                                left join server_master sm on pd.fileserver = sm.serverid where lt.transactionid = '" + transid + "'";*/
+
+                //using (DataSet ds = info.GetDataSet(query))
+                //{
+                if (ds != null)
+                {
+                    string username = ds.username;
+                    string password = ds.password;
+                    string domain = ds.domain;
+                    impartunate = new Impartunate(username, password, domain);
+                    impartunate.AllowAccesstoServer();
+                }
+                //}
+            }
+
+            public void Dispose()
+            {
+                if (id == true)
+                    return;
+                impartunate.RemoveServerAccess();
+                impartunate = null;
+                id = true;
+                GC.SuppressFinalize(this);
+            }
+        }
+        class Impartunate
+        {
+            #region Impersonating User
+
+            #region Impersonation
+            static IntPtr tokenHandle;
+            // static WindowsImpersonationContext impersonatedUser;
+            private string impersUsername { get; set; }
+            private string impersPwd { get; set; }
+            private string impersDomain { get; set; }
+            static WindowsIdentity newId;
+            #endregion
+
+            public Impartunate(string username, string password, string domain)
+            {
+                impersUsername = username;
+                impersPwd = password;
+                impersDomain = domain;
+            }
+
+
+            //   public static WindowsImpersonationContext oImpersonatedUser;
+            [DllImport("advapi32.dll", SetLastError = true)]
+            private static extern bool LogonUser(string sUsername, string sDomain, string sPassword, int iLogonType, int iLogonProvider, ref IntPtr oToken);
+
+            [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+            private static extern bool CloseHandle(IntPtr oHandle);
+
+            public bool AllowAccesstoServer()
+            {
+                try
+                {
+                    tokenHandle = IntPtr.Zero;
+                    bool Result = LogonUser(impersUsername, impersDomain, impersPwd, 2, 0, ref tokenHandle);
+                    if (Result)
+                    {
+                        newId = new WindowsIdentity(tokenHandle);
+                        //  impersonatedUser = newId.Impersonate();
+                        return true;
+                    }
+                    else
+                    {
+                        return false;
+                    }
+                }
+                catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); return false; }
+            }
+
+            public void RemoveServerAccess()
+            {
+                try
+                {
+                    //if (impersonatedUser != null)
+                    //{
+                    //    impersonatedUser.Undo();
+                    //}
+                    if (tokenHandle != IntPtr.Zero)
+                    {
+                        CloseHandle(tokenHandle);
+                    }
+                }
+                catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); }
+            }
+
+            private void ImpersonateUser()
+            {
+                //System.IO.FileInfo localFileLastModified;
+                //System.IO.FileInfo serverFileLastModified;
+                if (AllowAccesstoServer())
+                {
+                    RemoveServerAccess();
+                }
+            }
+
+            #endregion
+        }
+    }
+}

Неке датотеке нису приказане због велике количине промена