Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start Time: {0}", DateTime.Now);
            int sleepMiliseconds = 10000;

            HeaderInfo.Instance.UserID          = "SYSTEM";
            HeaderInfo.Instance.CurrentDateTime = DateTime.Now;

            var    arguments   = new Arguments(args);
            string processName = arguments ["processname"];

            if (string.IsNullOrEmpty(processName))
            {
                processName = "DEBUG";
            }

            Program program = new Program();

            ConnString.ConnectionString          = ConnString.ConnectionStringServer;
            ConnString.ConnectionStringFramework = ConnString.ConnectionStringServer;

            LogFile.WriteToTodaysLogFile("Document Generation Server started " + DateTime.Now);
            Console.WriteLine("Document Generation Server started " + DateTime.Now);

            int i = 0;

            while (i <= 3)
            {
                i++;

                Console.WriteLine("Running = " + DateTime.Now);
                Console.WriteLine("Process Name = " + processName);

                // Check if there is a request
                //
                program.activeList = BUSProcessRequest.ListActiveRequests();
                GenerateList(program, false, processName);

                //program.activeList = BUSProcessRequest.ListUnfinishedRequests();
                //GenerateList( program, true );
                Console.WriteLine("Iteration # " + i.ToString());

                Console.WriteLine("Sleeping for {0} miliseconds.", sleepMiliseconds);

                BUSFCMBackendStatus.ReportStatus(HeaderInfo.Instance, processName, "Sleeping...");

                Thread.Sleep(sleepMiliseconds);
            }
        }
Пример #2
0
        private static void GenerateList(Program program, bool isRestart, string processName)
        {
            #region startList
            if (program.activeList.Count > 0)
            {
                // If there is a request, process the request
                //

                foreach (var request in program.activeList)
                {
                    request.SetStatusToStarted();

                    program.processRequest = request;

                    // Update request to completed
                    //
                    if (request.Type == ProcessRequest.TypeValue.DOCUMENTGENERATION.ToString())
                    {
                        // Find Values
                        //
                        var    clientUID         = 0;
                        int    clientSetID       = 0;
                        var    overrideDocument  = "Yes";
                        int    clientDocumentUID = 0;
                        string filename          = " Full Set Generated";

                        foreach (var argument in request.argumentList)
                        {
                            if (argument.Code == ProcessRequestArguments.ProcessRequestCodeValues.CLIENTUID.ToString())
                            {
                                clientUID = Convert.ToInt32(argument.Value);
                            }
                            if (argument.Code == ProcessRequestArguments.ProcessRequestCodeValues.CLIENTSETID.ToString())
                            {
                                clientSetID = Convert.ToInt32(argument.Value);
                            }
                            if (argument.Code == ProcessRequestArguments.ProcessRequestCodeValues.OVERRIDE.ToString())
                            {
                                overrideDocument = argument.Value;
                            }
                            if (argument.Code == ProcessRequestArguments.ProcessRequestCodeValues.CLIENTDOCUID.ToString())
                            {
                                clientDocumentUID = Convert.ToInt32(argument.Value);
                                if (clientDocumentUID > 0)
                                {
                                    var clientDocument = BUSClientDocument.ClientDocumentReadS(clientDocumentUID);
                                    filename = " File: " + clientDocument.FileName;
                                }
                            }
                        }

                        var client = BUSClient.ClientRead(new ClientReadRequest()
                        {
                            clientUID = clientUID, headerInfo = HeaderInfo.Instance
                        });


                        // Send email to requester
                        //
                        string emailGraham = "*****@*****.**";
                        string emailDaniel = "*****@*****.**";

                        string emailSubject = "<> STARTED <> " + DateTime.Now + "<> generation requested by: " + request.RequestedByUser +
                                              " Client: " + clientUID + " " + client.client.Name +
                                              filename;

                        string emailBody = "Generation Started: " + DateTime.Now + " <> " + emailSubject + " -- ";

                        if (request.RequestedByUser.ToUpper() == "GC0001")
                        {
                            var resp1 = FCMEmail.SendEmailSimple(
                                iRecipient: emailGraham,
                                iSubject: emailSubject,
                                iBody: emailBody);
                        }

                        var resp2 = FCMEmail.SendEmailSimple(
                            iRecipient: emailDaniel,
                            iSubject: emailSubject,
                            iBody: emailBody);


                        // 30.03.2012
                        // Mudar para processamento paralelo e async
                        //

                        // Generate Document
                        //
                        BUSFCMBackendStatus.ReportStatus(HeaderInfo.Instance, processName, "Before document generation starts.");
                        if (clientDocumentUID > 0)
                        {
                            program.GenerateDocumentsForClient(clientUID, clientSetID, program, overrideDocument, clientDocumentUID, processName, request.RequestedByUser);
                        }
                        else
                        {
                            program.GenerateFullSetOfDocumentsForClient(clientUID, clientSetID, program, overrideDocument, isRestart, processName, request.RequestedByUser);
                        }
                        // Write output to database of logs and allow access online or
                        // Write to a file and allow access online...
                        // We can see the process of the request...

                        request.SetStatusToCompleted();
                        HeaderInfo.Instance.UserID          = request.RequestedByUser;
                        HeaderInfo.Instance.CurrentDateTime = DateTime.Now;



                        // Send email to requester
                        //

                        emailSubject = "<>  ENDED  <> " + DateTime.Now + "<> generation requested by: " + request.RequestedByUser +
                                       " Client: " + clientUID + " " + client.client.Name +
                                       filename;

                        emailBody = "Generation Ended: " + DateTime.Now + " <> " + emailSubject + " -- " + "File Generated.";

                        if (request.RequestedByUser.ToUpper() == "GC0001")
                        {
                            var resp3 = FCMEmail.SendEmailSimple(
                                iRecipient: emailGraham,
                                iSubject: emailSubject,
                                iBody: emailBody);
                        }

                        var resp4 = FCMEmail.SendEmailSimple(
                            iRecipient: emailDaniel,
                            iSubject: emailSubject,
                            iBody: emailBody);
                    }
                }
            }

            #endregion
        }
Пример #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Start Time: {0}", DateTime.Now);
            int sleepMiliseconds = 10000;

            HeaderInfo.Instance.UserID          = "SYSTEM";
            HeaderInfo.Instance.CurrentDateTime = DateTime.Now;

            var    arguments   = new Arguments(args);
            string processName = arguments["processname"];

            if (string.IsNullOrEmpty(processName))
            {
                processName = "DEBUG";
            }

            var resp2 = FCMEmail.SendEmailSimple(
                iRecipient: "*****@*****.**",
                iSubject: "test dan",
                iBody: "body");

            Program program = new Program();

            ConnString.ConnectionString          = ConnString.ConnectionStringServer;
            ConnString.ConnectionStringFramework = ConnString.ConnectionStringServer;

            LogFile.WriteToTodaysLogFile("Document Generation Server started " + DateTime.Now);
            Console.WriteLine("Document Generation Server started " + DateTime.Now);


            // ------------------------------------------------------------
            // (1) Get client details from the cloud
            // Call API from Construction Outcomes Web Site
            // Get the client details
            // Set up the client call, and add new client
            // ------------------------------------------------------------
            //
            //

            // TODO: Access data directly from the Con Outcomes DB ja' que nao consigo acessar/expor API diretament


            int i = 0;

            while (i <= 3)
            {
                i++;

                Console.WriteLine("Running = " + DateTime.Now);
                Console.WriteLine("Process Name = " + processName);

                // Check if there is a request
                //
                program.activeList = BUSProcessRequest.ListActiveRequests();
                GenerateList(program, false, processName);


                //program.activeList = BUSProcessRequest.ListUnfinishedRequests();
                //GenerateList( program, true );
                Console.WriteLine("Iteration # " + i.ToString());

                Console.WriteLine("Sleeping for {0} miliseconds.", sleepMiliseconds);

                BUSFCMBackendStatus.ReportStatus(HeaderInfo.Instance, processName, "Sleeping...");

                Thread.Sleep(sleepMiliseconds);
            }
        }