示例#1
0
        public static List <Task> GetXMLFromUTM()
        {
            List <Task> tasksList = new List <Task>();
            List <UTM>  utm       = WorkWithDB.GetActiveUTM();

            int TimeOut = Convert.ToInt32(ConfigurationManager.AppSettings.Get("HTTPTimeout")); //httpTimeout\

            if (TimeOut == 0)
            {
                TimeOut = 20000;
            }

            foreach (var u in utm)
            {
                tasksList.Add(AsyncGet(u, TimeOut));
            }
            return(tasksList);
        }
示例#2
0
        public static List <Task> SendXMLToUTM()
        {
            List <Task> tasksList = new List <Task>();
            List <UTM>  utmList   = WorkWithDB.GetActiveUTM();

            int TimeOut = Convert.ToInt32(ConfigurationManager.AppSettings.Get("HTTPTimeout")); // httpTimeout

            if (TimeOut == 0)
            {
                TimeOut = 20000;
            }

            foreach (var u in utmList)
            {
                List <UTM_Data> utmDataList = WorkWithDB.GetNewData(u.UTMId);

                tasksList.Add(AsyncSend(utmDataList, TimeOut));
            }
            return(tasksList);
        }
示例#3
0
        public static void DeleteAsiiuTicketFromUTM()
        {
            List <UTM> utmList = WorkWithDB.GetActiveUTM();

            try
            {
                foreach (var utm in utmList)
                {
                    if (utm.IsActive & UTMDeleteTicketPossibility(utm.UTMId))
                    {
                        string pathToOutFilesFromUTM = ConfigurationManager.AppSettings.Get("pathToTicket");

                        int timeOut = Convert.ToInt32(ConfigurationManager.AppSettings.Get("HTTPTimeout")); // httpTimeout
                        if (timeOut == 0)
                        {
                            timeOut = 20000;
                        }

                        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(utm.URL + pathToOutFilesFromUTM);
                        httpWebRequest.Method  = "GET";
                        httpWebRequest.Timeout = Convert.ToInt32(timeOut);

                        WorkWithXML     workWithXML       = new WorkWithXML();
                        List <UTM_Data> listTicketFromUtm = null; // all files on UTM

                        using (StreamReader streamReader = new StreamReader(httpWebRequest.GetResponse().GetResponseStream(), Encoding.UTF8))
                        {
                            string responseFromUTM = streamReader.ReadToEnd();                     // xml with list of all tickets on UTM
                            listTicketFromUtm = workWithXML.ParseResponseFromUTM(responseFromUTM); // get list all files on UTM
                        }

                        httpWebRequest = null;

                        foreach (var linkticket in listTicketFromUtm)
                        {
                            string Ticket = null;

                            HttpWebRequest httpWebRequestGetTicket = (HttpWebRequest)WebRequest.Create(linkticket.URL);
                            httpWebRequestGetTicket.Method  = "GET";
                            httpWebRequestGetTicket.Timeout = Convert.ToInt32(timeOut);

                            using (StreamReader streamReader = new StreamReader(httpWebRequestGetTicket.GetResponse().GetResponseStream(), Encoding.UTF8))
                            {
                                Ticket = streamReader.ReadToEnd();
                            }

                            httpWebRequestGetTicket = null;

                            linkticket.XMLContent = Ticket;
                            linkticket.UTMId      = utm.UTMId;

                            string docType = workWithXML.GetTicketDocType(linkticket.XMLContent);

                            if (!DocTypeDeletePossibility(docType))
                            {
                                DateTime TicketDate  = DateTime.Parse(WorkWithXML.GetDateFromXml(linkticket.XMLContent));
                                DateTime NowDateTime = DateTime.Now;
                                TimeSpan TicketOld   = NowDateTime.Subtract(TicketDate);

                                string ticketTimeSpan = ConfigurationManager.AppSettings.Get("ticketTimeSpan");

                                if (TicketOld > TimeSpan.Parse(ticketTimeSpan))
                                {
                                    HttpWebRequest  httpWebRequestDelete  = null;
                                    HttpWebResponse httpWebResponseDelete = null;

                                    try
                                    {
                                        httpWebRequestDelete        = (HttpWebRequest)WebRequest.Create(linkticket.URL);
                                        httpWebRequestDelete.Method = "DELETE";
                                        httpWebResponseDelete       = (HttpWebResponse)httpWebRequestDelete.GetResponse();
                                    }
                                    finally
                                    {
                                        httpWebRequestDelete  = null;
                                        httpWebResponseDelete = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log log = new Log(ex);
            }
        } // delete Asiiu's tickets from UTM