static void Main(string[] args) { var arrODS = FacadeOrder.GetAll().Where(p => p.OrderExecuteDate.Equals(new DateTime(2017, 11, 8))); int j = 1; Console.WriteLine("Total: " + arrODS.Count().ToString()); foreach (var i in arrODS) { try { Console.WriteLine(j.ToString() + " de " + arrODS.Count().ToString()); var dataODS = FacadeOrder.Get(i.PK_OrderID); var dataClient = FacadeClient.GetByID(i.FK_ClientID); var dataBaseInstalled = FacadeInstalledBase.GetByID(dataODS.FK_InstalledBaseID); var dataProduct = FacadeProduct.GetByID(dataBaseInstalled.FK_ProductID.Value); var dataHistory = FacadeMabe.HistoryODSByClient(dataClient.ClientID, dataBaseInstalled.InstalledBaseID); // insertar datos order history foreach (var item in dataHistory) { var dataDBHistory = FacadeHistory.GetByOrderID(dataODS.PK_OrderID); if (dataDBHistory.Where(p => p.OrderID == item.ID_Oper).Count() > 0) { // update var entity = dataDBHistory.Where(p => p.OrderID == item.ID_Oper).FirstOrDefault(); entity.CloseDate = ParseDate(item.Fecha_Cierre_Orden); entity.Failure1 = string.IsNullOrEmpty(item.Desc_ID_Falla1) ? "" : item.Desc_ID_Falla1; entity.Failure2 = string.IsNullOrEmpty(item.Desc_ID_Falla2) ? "" : item.Desc_ID_Falla2; entity.Failure3 = string.IsNullOrEmpty(item.Desc_ID_Falla3) ? "" : item.Desc_ID_Falla3; entity.FailureID1 = string.IsNullOrEmpty(item.ID_Falla1) ? "" : item.ID_Falla1; entity.FailureID2 = string.IsNullOrEmpty(item.ID_Falla2) ? "" : item.ID_Falla2; entity.FailureID3 = string.IsNullOrEmpty(item.ID_Falla3) ? "" : item.ID_Falla3; entity.FK_ClientID = dataODS.FK_ClientID; entity.FK_InstalledBaseID = dataODS.FK_InstalledBaseID; entity.FK_OrderID = dataODS.PK_OrderID; entity.Guaranty = string.IsNullOrEmpty(item.Tipo_Serv) ? "" : item.Tipo_Serv; entity.ItemStatus = string.IsNullOrEmpty(item.Estatus_Visita) ? "" : item.Estatus_Visita; entity.ModifyDate = DateTime.UtcNow; entity.OrderID = string.IsNullOrEmpty(item.ID_Oper) ? "" : item.ID_Oper; entity.OrderStatus = string.IsNullOrEmpty(item.Estatus_Oper) ? "" : item.Estatus_Oper; entity.ShopDate = new DateTime(1980, 1, 1); entity.Status = true; FacadeHistory.Update(entity); } else { // insert var entity = new EntityHistory(); entity.CloseDate = ParseDate(item.Fecha_Cierre_Orden); entity.CreateDate = DateTime.UtcNow; entity.Failure1 = string.IsNullOrEmpty(item.Desc_ID_Falla1) ? "" : item.Desc_ID_Falla1; entity.Failure2 = string.IsNullOrEmpty(item.Desc_ID_Falla2) ? "" : item.Desc_ID_Falla2; entity.Failure3 = string.IsNullOrEmpty(item.Desc_ID_Falla3) ? "" : item.Desc_ID_Falla3; entity.FailureID1 = string.IsNullOrEmpty(item.ID_Falla1) ? "" : item.ID_Falla1; entity.FailureID2 = string.IsNullOrEmpty(item.ID_Falla2) ? "" : item.ID_Falla2; entity.FailureID3 = string.IsNullOrEmpty(item.ID_Falla3) ? "" : item.ID_Falla3; entity.FK_ClientID = dataODS.FK_ClientID; entity.FK_InstalledBaseID = dataODS.FK_InstalledBaseID; entity.FK_OrderID = dataODS.PK_OrderID; entity.Guaranty = string.IsNullOrEmpty(item.Tipo_Serv) ? "" : item.Tipo_Serv; entity.ItemStatus = string.IsNullOrEmpty(item.Estatus_Visita) ? "" : item.Estatus_Visita; entity.ModifyDate = DateTime.UtcNow; entity.OrderID = string.IsNullOrEmpty(item.ID_Oper) ? "" : item.ID_Oper; entity.OrderStatus = string.IsNullOrEmpty(item.Estatus_Oper) ? "" : item.Estatus_Oper; entity.PK_HistoryID = 0; entity.ShopDate = new DateTime(1980, 1, 1); entity.Status = true; FacadeHistory.Insert(entity); } } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } j++; } //Inventory(); //RestImage(); //SendEmial(); //foreach (TimeZoneInfo z in TimeZoneInfo.GetSystemTimeZones()) // Console.WriteLine(z.Id); //Console.WriteLine(FacadeGoogle.GetLocalDateTime(19.3850, -99.1650, DateTime.UtcNow)); //string CLIENT_ID = "6538892993478012"; //string CLIENT_SECRET = "GGGzSZuzfdBDpua7g7wyZo9qiTrnTvcS"; //MP mp = new MP(CLIENT_ID, CLIENT_SECRET); //Hashtable data = mp.getPaymentInfo("9406314591T0170101000525SFODS"); // Sets the filters you want //Dictionary<String, String> filters = new Dictionary<String, String>(); //filters.Add("site_id", "MLM"); // Argentina: MLA; Brasil: MLB // Search payment data according to filters //Hashtable searchResult = mp.searchPayment(filters); // Show payment information //foreach (Hashtable payment in searchResult.SelectToken("response.results")) //{ // Console.WriteLine(String.Format("{0}", payment["collection"]["id"])); //} Console.WriteLine("Finish"); Console.ReadKey(); }
static void Main(string[] args) { DateTime fh = DateTime.Today.AddDays(-1); // considerar un dia atras para enviar ods resagadas si es manual se toma la fecha que se envia CultureInfo culture = new CultureInfo(ConfigurationManager.AppSettings["AppCulture"]); Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; int maxProcess = Convert.ToInt32(ConfigurationManager.AppSettings["MaxProcess"]); Console.WriteLine("Iniciando interface Serviplus " + DateTime.Now.ToString()); Console.WriteLine("Parametros "); foreach (var item in args) { Console.WriteLine(item); } string DownloadFolder = ""; List <string> arrFiles = new List <string>(); List <string> arrFilesOK = new List <string>(); if (args.Contains("-download")) { Console.WriteLine("Iniciando proceso de descarga " + DateTime.Now.ToString()); FacadeInterface.Download(args.Contains("-removeOrigin"), out arrFiles, out arrFilesOK, out DownloadFolder); Console.WriteLine(String.Format("Archivos descargados: {0}", arrFiles.Count())); Console.WriteLine(String.Format("Archivos descargados OK: {0}", arrFilesOK.Count())); Console.WriteLine("Completado proceso de descarga " + DateTime.Now.ToString()); } if (args.Contains("-path")) { foreach (var item in args) { if (item.Contains(@"\")) { DownloadFolder = item.Replace('"', ' ').Trim(); break; } } } if (args.Contains("-processOld")) { Console.WriteLine("Iniciando proceso de carga " + DateTime.Now.ToString()); FacadeInterface.Process(DownloadFolder); Console.WriteLine("Completado proceso de carga " + DateTime.Now.ToString()); } if (args.Contains("-process")) { Console.WriteLine("Iniciando proceso de carga " + DateTime.Now.ToString()); FacadeInterface.Process(); Console.WriteLine("Completado proceso de carga " + DateTime.Now.ToString()); } if (args.Contains("-import")) { Console.WriteLine("Iniciando proceso de importación de ODS " + DateTime.Now.ToString()); FacadeInterface.Import(DownloadFolder); Console.WriteLine("Completado proceso de importación de ODS " + DateTime.Now.ToString()); } if (args.Contains("-geo")) { Console.WriteLine("Iniciando proceso de geolocalización " + DateTime.Now.ToString()); FacadeInterface.Geolocation(); Console.WriteLine("Completado proceso de geolocalización " + DateTime.Now.ToString()); } if (args.Contains("-adds")) { Console.WriteLine("Iniciando proceso de ws SAP " + DateTime.Now.ToString()); FacadeInterface.GetWSAdds(); Console.WriteLine("Completado proceso de ws SAP " + DateTime.Now.ToString()); } if (args.Contains("-date")) { System.Text.RegularExpressions.Regex rgx = new System.Text.RegularExpressions.Regex(@"^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$"); foreach (var item in args) { if (rgx.IsMatch(item)) { fh = Convert.ToDateTime(item); break; } } } if (args.Contains("-sendCRM")) { FacadeMabe.SendCRM(fh, maxProcess, args.Contains("-reintent"), args.Contains("-extraKM")); } if (args.Contains("-debug")) { Console.WriteLine("Presione cualquier tecla para terminar. "); Console.ReadKey(); } }