public List<ACM.Model.Campaign> CampaignInfo(ACM.Model.Campaign request) { List<ACM.Model.Campaign> response = new List<ACM.Model.Campaign>(); try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { ctx.Configuration.ProxyCreationEnabled = false; if (request != null && request.RequestorId != null && request.RequestorId != 0) { response = (from campaign in ctx.Campaigns where campaign.RequestorId == request.RequestorId select campaign).ToList(); } else response = (from campaign in ctx.Campaigns select campaign).ToList(); ctx.Configuration.ProxyCreationEnabled = true; } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "CampaignInfo"); throw; } return response; }
public ACM.Model.DeploymentPeriod DeploymentPeriodAdd(ACM.Model.DeploymentPeriod request) { ACM.Model.DeploymentPeriod response = new ACM.Model.DeploymentPeriod(); try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { request.CreatedDate = DateTime.Now; ctx.DeploymentPeriods.Add(request); ctx.SaveChanges(); ctx.Configuration.ProxyCreationEnabled = false; // IQueryable<ACM.Model.Campaign> response1 = ctx.Campaigns.Last(); response = (from deploymentperiod in ctx.DeploymentPeriods orderby deploymentperiod.DeploymentPeriodId descending select deploymentperiod).First(); ctx.Configuration.ProxyCreationEnabled = true; } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "DeploymentPeriodAdd"); throw; } return response; }
public ACM.Model.Campaign CampaignAdd(ACM.Model.Campaign request) { ACM.Model.Campaign response = new ACM.Model.Campaign(); try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { request.CreatedDate = DateTime.Now; ctx.Campaigns.Add(request); ctx.SaveChanges(); ctx.Configuration.ProxyCreationEnabled = false; response = (from campaign in ctx.Campaigns where campaign.CampaignGuid == request.CampaignGuid orderby campaign.CampaignId descending select campaign).First(); ctx.Configuration.ProxyCreationEnabled = true; } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "CampaignAdd"); throw; } return response; }
static void Main(string[] args) { Console.Write("Enter a positive integer: "); int n = Console.ReadLine().ToInteger(); List <string> points = new List <string>(); for (int r = 0; r <= n; r++) { for (int c = 0; c <= n; c++) { if (r == c && c == 0) { continue; } int gcf = ACM.GreatestCommonDivisor(r, c); string point = (r / gcf) + "," + (c / gcf); // Reduce every point by it's greatest common divisor (since that point was seen first) if (!points.Contains(point)) { points.Add(point); } } } Console.WriteLine("Points of L({0}) visible from the origin: {1}", n, points.Count); }
// 设置点击状态 public void SetInteractable(bool b, bool isCacheAC = true, bool effect = true) { if (!IsShow) { return; } if (isCacheAC) { if (Data.OnEnter != null) { ACAll = ACM.GetAll(); } } if (IsInteractable == b) { return; } IsInteractable = b; OnInteractable(b); if (effect) { foreach (var item in EffectTrans) { item.OnInteractable(b); } } }
public List<ACM.Model.DeploymentPeriod> DeploymentPeriodInformation(ACM.Model.DeploymentPeriod request) { List<ACM.Model.DeploymentPeriod> response = new List<ACM.Model.DeploymentPeriod>(); try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { ctx.Configuration.ProxyCreationEnabled = false; if (request != null) { response = (from deploymentperiod in ctx.DeploymentPeriods select deploymentperiod).ToList(); } ctx.Configuration.ProxyCreationEnabled = true; } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "DeploymentPeriodInformation"); throw; } return response; }
static void Main(string[] args) { Console.Write("Numerator and Denominator: "); List <int> fraction = Console.ReadLine().ToIntegerList(); int gcd = ACM.GreatestCommonDivisor(fraction[0], fraction[1]); fraction[0] /= gcd; fraction[1] /= gcd; for (int k = 2; k < 1000; k++) { for (int n = k; n < 1000; n++) { int num = k * k - k; int denom = n * n - n; gcd = ACM.GreatestCommonDivisor(num, denom); num /= gcd; denom /= gcd; if (num == fraction[0] && denom == fraction[1]) { Console.WriteLine("{0} black and {1} white", k, n - k); break; } } } }
static void Main(string[] args) { List <int> primes = ACM.GeneratePrimes(80000); List <BigInteger> powers = new List <BigInteger>(); Dictionary <string, string> powerNames = new Dictionary <string, string>(); // This problem is the WORST.. too much stuff going on // Let's just brute force generate a ton of things // and hope for the best foreach (int p in primes) { for (int i = 1; i < 64; i++) { BigInteger result = BigInteger.Pow(p, i); powers.Add(result); powerNames.Add(result.ToString(), p + "^" + i); } } powers.Sort(); Console.Write("Enter a positive integer: "); int n = Console.ReadLine().ToInteger(); string ending = "."; string pname = powerNames[powers[n - 1] + ""]; if (!pname.EndsWith("^1")) { ending = " = " + pname + "."; } Console.WriteLine("The " + nth(n) + " prime power is " + powers[n - 1] + ending); }
public string AdAdRestrictionFlagAdd(ACM.Model.Ad ad, List<int> flags, bool applyAll = false) { List<ACM.Model.AdRestrictionAd> requestRestrictionAds = new List<AdRestrictionAd>(); ACM.Model.AdRestrictionAd requestRestrictionAd = new AdRestrictionAd(); return adDAO.AdAdRestrictionFlagAdd(ad.AdId, ad.CampaignId, flags, applyAll); }
public List<ACM.Model.Ad> AdInfo(ACM.Model.Ad request) { try { return adDAO.AdInfo(request); } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "AdInfo"); throw; } }
static void Main(string[] args) { Console.Write("Enter a positive integer: "); int n = Console.ReadLine().ToInteger(); primes = ACM.GeneratePrimes(n); int cost = CalculateCost(n); Console.WriteLine("Cost: {0}", cost); }
public ACM.Model.DeploymentPeriod DeploymentPeriodInquiry(ACM.Model.DeploymentPeriod request) { try { return deploymentPeriodDAO.DeploymentPeriodInquiry(request); } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "DeploymentPeriodInquiry"); throw; } }
public string DeploymenPeriodModification(ACM.Model.DeploymentPeriod request) { string camMod; try { return deploymentPeriodDAO.DeploymentModification(request); } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } }
static void Main(string[] args) { Console.Write("Input: "); int n = Console.ReadLine().ToInteger(); primes = ACM.GeneratePrimes(n); long sum = 0; for (int i = 2; i <= n; i++) { int gpf = g(i); sum += gpf; } Console.WriteLine("s({0}) = {1}", n, sum); }
public void ACM_ReadPdfFile(string fileName) { string Linea; string Observaciones; ACM oACM = null; try { if (!File.Exists(fileName)) { return; } listACM = new List <ACM>(); StreamReader fileReader = new StreamReader(fileName); fileReader.ReadLine(); while ((Linea = fileReader.ReadLine()) != null) { string[] Columnas = Linea.Split(new char[] { '|' }); long BilleteACM = 0; if (long.TryParse(Columnas[3], out BilleteACM)) { Observaciones = Linea; while (Observaciones.IndexOf("||") > -1) { Observaciones = Observaciones.Replace("||", "|"); } if (Observaciones.Substring(Observaciones.Length - 1) == "|") { Observaciones = Observaciones.Substring(0, Observaciones.Length - 1); } oACM = new ACM { Billete = BilleteACM, Observaciones = Observaciones }; listACM.Add(oACM); } } fileReader.Close(); } catch (Exception Exception1) { MessageBox.Show("Error: " + Exception1.Message + "\nfileName: " + fileName, "Error"); } }
public string DeploymentModification(ACM.Model.DeploymentPeriod request) { try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { request.ModifiedDate = DateTime.Now; ctx.Entry(request).State = EntityState.Modified; ctx.SaveChanges(); } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "DeploymentModification"); throw; } return "Successfully updated"; }
public string CampaignDel(ACM.Model.Campaign request) { try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { ACM.Model.Campaign campaign = ctx.Campaigns.Find(request.CampaignId); ctx.Campaigns.Remove(request); ctx.SaveChanges(); } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "CampaignDel"); throw; } return "Successfully deleted"; }
static void Main(string[] args) { Console.Write("Enter k and n: "); List <int> nums = Console.ReadLine().ToIntegerList(); int count = 0; ACM.GeneratePrimes(nums[1]); // We need to generate a massive list of primes first for (int i = 2; i <= nums[1]; i++) { if (i.GetPrimeFactors().Max() <= nums[0]) // Uses ACMHelper GetPrimeFactors integer extension method { count++; } } Console.WriteLine("{0}", count + 1); // Literally because we also include 1 as a k-smooth number }
public ActionResult CampaignFollowUp(ACM.Model.CampaignFollowUp cmpFollowUp) { ACM.Model.CampaignFollowUp CampFollowUp = new ACM.Model.CampaignFollowUp(); if (cmpFollowUp != null && cmpFollowUp.CampaignId == 0) cmpFollowUp.CampaignId = Convert.ToInt32(Session["CampaignId"]); else CampFollowUp.CampaignId = Convert.ToInt32(cmpFollowUp.CampaignId); var campaignFollowUp = campaignServiceClient.CampaignFollowUpInq(CampFollowUp); if (campaignFollowUp == null) { campaignFollowUp = new Model.CampaignFollowUp(); campaignFollowUp.CampaignId = CampFollowUp.CampaignId; } var FollowUpList = campaignServiceClient.GetMasterDropDownDataforMasterTables("FollowUpId", "FollowUpDescription", "FollowUp"); ViewBag.FollowUpList = new SelectList(FollowUpList, "id", "name"); return PartialView(campaignFollowUp); }
public override bool Equals(object other) { if (!(other is ACM)) { return(false); } ACM o = (ACM)other; if (!this.timeout.Equals(o.timeout)) { return(false); } if (!this.close.Equals(o.close)) { return(false); } if (!this.heartbeat.Equals(o.heartbeat)) { return(false); } return(true); }
public ACM.Model.Ad AdAdd(ACM.Model.Ad request) { ACM.Model.Ad response = new ACM.Model.Ad(); try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { ctx.Ads.Add(request); ctx.SaveChanges(); response = (from ad in ctx.Ads where ad.AdGuid == request.AdGuid orderby ad.AdId descending select ad).First(); } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "AdAdd"); throw; } return response; }
public string CampaignMod(ACM.Model.Campaign request) { string camMod; using (TransactionScope tran = new TransactionScope()) { try { var checkthecampaigntype = campaignDAO.CampaignInq(request); if (checkthecampaigntype.CampaignTypeId != request.CampaignTypeId) DeleteByCampaignType(request); camMod = campaignDAO.CampaignMod(request); tran.Complete(); } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "CampaignMod-BO"); throw new Exception(ex.Message.ToString()); } } return camMod; }
public ActionResult CampaignInfoSection(ACM.Model.Campaign cmp) { ViewBag.disablecontrols = false; ACM.Model.Campaign campaign = new ACM.Model.Campaign(); campaign.CampaignId = Convert.ToInt32(cmp.CampaignId); var campaignInq = campaignServiceClient.CampaignInq(campaign); var campaigntypelist = campaignServiceClient.GetMasterDropDownDataforMasterTables("CampaignTypeId", "CampaignTypeName", "CampaignType"); ViewBag.campaigntypelist = new SelectList(campaigntypelist, "ID", "Name"); var loblist = campaignServiceClient.GetMasterDropDownDataforMasterTables("LOBId", "LOBName", "LOB"); ViewBag.loblist = new SelectList(loblist, "ID", "Name"); var primarypmlist = campaignServiceClient.GetMasterDropDownDataforMasterTables("UserID", "FirstName+ ' ' +LastName", "Users"); ViewBag.primarypmlist = new SelectList(primarypmlist, "ID", "Name"); var secondarypmlist = campaignServiceClient.GetMasterDropDownDataforMasterTables("UserID", "FirstName+ ' ' +LastName", "Users"); ViewBag.secondarypmlist = new SelectList(secondarypmlist, "ID", "Name"); var promobuttontypelist = campaignServiceClient.GetMasterDropDownDataforMasterTables("PromoButtonTypeId", "PromoButtonName", "PromoButton"); ViewBag.promobuttontypelist = new SelectList(promobuttontypelist, "ID", "Name"); var productplacementlist = campaignServiceClient.GetMasterDropDownDataforMasterTables("ProductPlacementId", "Description", "ProductPlacement"); ViewBag.productplacementlist = new SelectList(productplacementlist, "ID", "Name"); var supercategory = campaignServiceClient.GetMasterDropDownDataforMasterTables("SuperCategoryID", "SuperCategoryName", "SuperCategory"); ViewBag.supercategory = new SelectList(supercategory, "ID", "Name"); var campaignType = campaignServiceClient.GetMasterDropDownDataforMasterTables("SuperCategoryID", "SuperCategoryName", "SuperCategory"); ViewBag.supercategory = new SelectList(campaignType, "ID", "Name"); var campaignTableStatuslist = campaignServiceClient.GetMasterDropDownDataforMasterTables("CampaignTableStatusId", "CampaignTableStatusDescription", "CampaignTableStatus"); ViewBag.campaignTableStatuslist = new SelectList(campaignTableStatuslist, "ID", "Name"); var category = campaignServiceClient.GetMasterDropDownDataforMasterTables("CategoryID", "CategoryName", "Category"); ViewBag.category = new SelectList(category, "ID", "Name"); if (campaignInq != null) { if (campaignInq.CategoryId != null) { ViewBag.categoryName = category.Find(x => x.ID == campaignInq.CategoryId).Name; } } var subcategory = campaignServiceClient.GetMasterDropDownDataforMasterTables("SubCategoryID", "SubCategoryName", "SubCategory"); ViewBag.subcategory = new SelectList(subcategory, "ID", "Name"); if (campaignInq != null) { if (campaignInq.SubCategoryId != null) { ViewBag.subCategoryName = subcategory.Find(x => x.ID == campaignInq.SubCategoryId).Name; } } var campaignTableStatusList = campaignServiceClient.GetMasterDropDownDataforMasterTables("CampaignTableStatusId", "CampaignTableStatusDescription", "CampaignTableStatus"); ViewBag.campaignTableStatusList = new SelectList(campaignTableStatusList, "ID", "Name"); var requestorlist = campaignServiceClient.GetMasterDropDownDataforMasterTables("UserID", "FirstName+ ' ' +LastName", "Users"); ViewBag.requestorlist = new SelectList(requestorlist, "ID", "Name"); var eventTrigger = campaignServiceClient.GetMasterDropDownDataforMasterTables("EventTriggerId", "EventTriggerName", "EventTrigger"); ViewBag.eventTrigger = new SelectList(eventTrigger, "ID", "Name"); // var campaign = cmpbo.GetCampaign(100); if (campaignInq == null) { campaignInq = new Model.Campaign(); CampaignTableStatu campaignTableStatu = new CampaignTableStatu(); campaignInq.CampaignTableStatu = campaignTableStatu; } if (campaignInq.CampaignTypeId != null) { var campaignTypeValue = campaigntypelist.Find(x => x.ID == campaignInq.CampaignTypeId); ViewBag.campaignTypeName = campaignTypeValue.Name; ViewBag.campaignTypeId = campaignInq.CampaignTypeId; } return PartialView(campaignInq); }
public ACM.Model.Ad AdAdd(ACM.Model.Ad request) { return adBO.AdAdd(request); }
static void Main(string[] args) { // Generate list of primes less than or equal to 5000 List <int> primes = ACM.GeneratePrimes(5000); List <int> primesFaster = ACM.GeneratePrimesParallel(5000); List <int> factors = ACM.GetPrimeFactors(38); // [2, 19] int fact = 88; List <int> factors2 = fact.GetPrimeFactors(); // [2, 2, 2, 11] int gpf = 4997.GreatestPrimeFactor(); // 263 // Parse input strings List <int> nums = "1 2 3 4 5 6 7 8 9 10".ToIntegerList(); List <string> strings = "apple banana carrot".ToStringList(); int num = "1".ToInteger(); long num2 = "2".ToLong(); double val = "6.5".ToDouble(); // Reverse a string String s = "taco"; s = s.Reverse(); // "ocat" // Turn an int into a different arbitrary base (binary = 2, octal = 8, hex = 16) string output = 42.ToBase(2); // 101010 string roman = 57.ToRoman(); // LVII string everything = ACM.ConvertBase("101010", 2, 10); // 42 string everything2 = "101010".ConvertBase(2, 10); // 42 // one hundred and twenty-three million four hundred and fifty-six thousand seven hundred and eighty-nine string numberwords = 123456789.ToWords(); int solution = "2 + (3 * 4)".Evaluate(); // 14 string longest = "apple car banana grapefruit".ToStringList().OrderByDescending(sp => sp.Length).First(); string a = "the cat in the hat", b = "I left the cat in the garage"; string common = ACM.LongestCommonSubstring(a, b); // "the cat in the " // Generates all possible substrings of a string List <string> allSubstrings = "i love cats".FindAllSubstrings().ToList(); string prefix = "the cat in the hat:the cat loves me:the cat eats mice".ToStringList(":").ShortestCommonPrefix(); // "the cat" // Greatest common divisor (biggest number that divides 12 and 8) int gcd = ACM.GreatestCommonDivisor(12, 8); // 4 // Least common multiple (first number that is a multiple of a and b) int lcm = ACM.LeastCommonMultiple(2, 7); // 14 // Check if two lists contain indentical elements (order matters) List <int> aq = 123456789.ToIntegerList(); // [1,2,3,4,5,6,7,8,9] List <int> bq = 123456789.ToIntegerList(); // [1,2,3,4,5,6,7,8,9] List <int> cq = 987654321.ToIntegerList(); // [9,8,7,6,5,4,3,2,1] bool equals = aq.SequenceEqual(bq); // true because both lists have same numbers in same sequence bool equals2 = aq.SequenceEqual(cq); // false, same numbers but different order bool equals3 = aq.All(k => cq.Contains(k)) && aq.Count == cq.Count; List <int> digits = 12345.ToIntegerList(); int least = digits.Min(); // Rotate a list List <int> rotateLeft = nums.Rotate(2); List <int> rotateRight = nums.Rotate(-2); // Generate permutations of a list List <int> plist = 1234.ToIntegerList(); var permutations = plist.Permute().ToList(); foreach (var permutation in permutations) { List <int> perm = permutation.ToList(); } List <int> blist = 12344321.ToIntegerList(); bool increasing = blist.IsIncreasing(0, 3); int revint = 12345.Reverse(); bool res = 123457789.ToIntegerList().IsIncreasing(); }
public List<ACM.Model.Campaign> CampaignInfo(ACM.Model.Campaign request) { return campaignDAO.CampaignInfo(request); }
public string AdMod(ACM.Model.Ad request) { return adDAO.AdMod(request); }
public ACM.Model.Ad AdInq(ACM.Model.Ad request) { return adDAO.AdInq(request); }
public virtual bool IsCanPayLoan(LoanData data) { ACM.Reset(SelfBaseUnit); ACM.Add(new ExCondition(IsGoldEnough(data), "AC_金币不够", data.Gold)); return(ACM.IsTrue()); }
public virtual bool IsCanPayLoan() { ACM.Reset(SelfBaseUnit); ACM.Add(new ExCondition(IsHaveLoan(), "AC_没有债务")); return(ACM.IsTrue()); }
public string UpdateAdRestriction(ACM.Model.Ad request) { return adDAO.UpdateAdRestriction(request); }
public List<AdOutStandingTask> GetOutstandingTask(ACM.Model.Ad request) { return adDAO.GetOutstandingTask(request); }
public string AdDel(ACM.Model.Ad request) { return adBO.AdDel(request); }
public JsonResult SaveCampaign(ACM.Model.Campaign NewCampaign, ACM.Model.CampaignTargetFileProvider[] NewCampaignTFPList, ACM.Model.CampaignLocation[] NewCampaignLocationList) { //list local variables CampaignRequestBO CampRequestBO = new CampaignRequestBO(); CampRequestBO.SaveCampaign(NewCampaign, NewCampaignTFPList, NewCampaignLocationList); var SaveResult = new { result = "Changes Saved!" }; return Json(SaveResult, JsonRequestBehavior.AllowGet); }
public string CampaignDel(ACM.Model.Campaign request) { return campaignDAO.CampaignDel(request); }
public ACM.Model.AdDeploymentPeriod AdStatusInquiry(ACM.Model.AdDeploymentPeriod request, int deploymentPeriodId) { return adDAO.AdStatusInquiry(request, deploymentPeriodId); }
public ACM.Model.Campaign CampaignInq(ACM.Model.Campaign request) { return campaignDAO.CampaignInq(request); }
public string AdStatusModify(ACM.Model.AdDeploymentPeriod request) { return adDAO.AdStatusModify(request); }
public ACM.Model.Campaign CampaignInq(ACM.Model.Campaign request) { ACM.Model.Campaign response = new ACM.Model.Campaign(); try { using (ACM_Redesign2014Context ctx = new ACM_Redesign2014Context()) { ctx.Configuration.LazyLoadingEnabled = true; ctx.Configuration.ProxyCreationEnabled = false; if (request != null) { response = ctx.Campaigns.Find(request.CampaignId); ctx.Campaigns.Include("CampaignTableStatu").ToList(); } } } catch (Exception ex) { Error.WriteException(TraceEventType.Error, ex.Message.ToString(), "CampaignInq"); throw; } return response; }
public virtual bool IsCanAddLoan() { ACM.Reset(SelfBaseUnit); ACM.Add(new ExCondition(!IsInMaxLoan(), "AC_超出贷款上限", UIUtil.FractionCol(CurLoan, MaxLoan))); return(ACM.IsTrue()); }
public JsonResult SaveCampaignTargetFileProvider(ACM.Model.CampaignTargetFileProvider CmpTargetFileProvider) { CampaignTargetFileProvider campaignTargetFileProvider = new CampaignTargetFileProvider(); CmpTargetFileProvider.CampaignId = Convert.ToInt32(Session["CampaignId"]); campaignTargetFileProvider = campaignServiceClient.CampaigTargetFileInq(CmpTargetFileProvider); string loginId = Utility.LoginId(User.Identity.Name); ACM.BO.Admin.UsersBO usersBO = new ACM.BO.Admin.UsersBO(); var userDetail = usersBO.GetUserDetail(loginId); CmpTargetFileProvider.ModifiedBy = userDetail.UserId; CmpTargetFileProvider.ModifiedDate = DateTime.Now; CmpTargetFileProvider.CreatedDate = DateTime.Now; if (campaignTargetFileProvider == null) { // CmpTargetFileProvider.CampaignId = Convert.ToInt32(Session["CampaignId"]); CmpTargetFileProvider.CreatedBy = userDetail.UserId; CmpTargetFileProvider.CreatedDate = DateTime.Now; campaignServiceClient.CampaigTargetFileAdd(CmpTargetFileProvider); return Json(CmpTargetFileProvider); } else { campaignServiceClient.CampaigTargetFileMod(CmpTargetFileProvider); return Json(CmpTargetFileProvider); } }
public void TryAddMarkExCondition() { ACM.Add(new ExCondition(!IsIn(), Util.GetStr("AC_无法操作的标记") + "\n" + GetListStr()).NoTrans()); }
public void BSP_ReadPdfFile(string fileName) { int page = 0, index = 0; string currentText = ""; BSP_Ticket oBSP_Ticket = null; BSP_Ticket_Detalle oBSP_Ticket_Detalle = null; Companias companias = new Companias(); List <Compania> lstCompanias = companias.GetAll(); Compania oCompaniaActual = null; string strFinCompania = ""; List <Compania> lstNuevasCompanias = new List <Compania>(); Conceptos conceptos = new Conceptos(); List <Concepto> lstConceptos = conceptos.GetAll(); Concepto oConceptoActual = null; string strFinConcepto = ""; BSP_Rg Tipo = BSP_Rg.Ambas; int CompaniaID = 0; string Linea = ""; try { if (File.Exists(fileName)) { semanaToImport.TicketsBSP = new List <BSP_Ticket>(); PdfReader pdfReader = new PdfReader(fileName); for (page = pageStart; page <= pdfReader.NumberOfPages; page++) { currentText = ""; currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, new SimpleTextExtractionStrategy()); currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); string[] arrLineas = currentText.Split(new char[] { '\n' }); if (BSPActions.EsAnalisisDeVenta(ref arrLineas)) { string strTipo = arrLineas[3].Substring(21, 30).Trim(); Tipo = BSP_Rg.Ambas; if (strTipo == "DOMESTICO") { Tipo = BSP_Rg.Doméstico; } else if (strTipo == "INTERNACIONAL") { Tipo = BSP_Rg.Internacional; } if (Tipo != BSP_Rg.Ambas) //Si no estoy en el resumen final { for (index = 10; index < arrLineas.Length; index++) //10: Salteo cabecera { Linea = arrLineas[index]; if (Linea.Trim() != "") { if (oCompaniaActual == null && index == 10 && Linea.Length >= 3 && int.TryParse(Linea.Substring(0, 3), out CompaniaID)) //Si no estoy dentro de una compañía aerea... { oCompaniaActual = lstCompanias.Find(x => x.ID == CompaniaID); if (oCompaniaActual == null) { oCompaniaActual = new Compania() { ID = CompaniaID, Nombre = Linea.Substring(4).Trim() }; companias.Insertar(oCompaniaActual); lstCompanias.Add(oCompaniaActual); lstNuevasCompanias.Add(oCompaniaActual); } strFinCompania = "TOT " + Linea.Substring(4).Trim(); } else if (Linea.Length >= strFinCompania.Length && Linea.Substring(0, strFinCompania.Length) == strFinCompania) //Si estoy en el cierre de la compañía aerea... { oCompaniaActual = null; } else if (oConceptoActual == null) //Si estoy en la compañía aerea y no estoy dentro de un concepto... { oConceptoActual = lstConceptos.Find(x => x.Nombre.Length <= Linea.Length && x.Nombre.ToUpper() == Linea.Substring(0, x.Nombre.Length)); if (oConceptoActual != null) { strFinConcepto = "TOT " + (oConceptoActual.Nombre.Length >= 21 ? oConceptoActual.Nombre.Substring(0, 21) : oConceptoActual.Nombre).Trim().ToUpper(); } } else if (Linea.Length >= strFinConcepto.Length && Linea.Substring(0, strFinConcepto.Length) == strFinConcepto) //Si estoy en la compañía aerea y estoy en el cierre de un concepto { oConceptoActual = null; } else if (BSPActions.EsNuevoTicket(Linea)) //Si estoy en la compañía aerea y estoy en el concepto, y si los primeros 10 caracteres son long... { if (oBSP_Ticket != null) { semanaToImport.TicketsBSP.Add(oBSP_Ticket); oBSP_Ticket = null; } oBSP_Ticket = BSPActions.GetTicket(Linea, semanaToImport.Periodo.Year); oBSP_Ticket.Concepto = oConceptoActual; oBSP_Ticket.Compania = oCompaniaActual; oBSP_Ticket.Rg = Tipo; oBSP_Ticket_Detalle = BSPActions.GetTicketDetalle(Linea); //ACM y ADM if (listACM != null && oConceptoActual.Tipo == 'C') { ACM oACM = listACM.Find(x => x.Billete == oBSP_Ticket.Billete); if (oACM != null) { oBSP_Ticket_Detalle.Observaciones += (string.IsNullOrEmpty(oBSP_Ticket_Detalle.Observaciones) ? "" : "|") + oACM.Observaciones; } } if (listADM != null && oConceptoActual.Tipo == 'D') { ADM oADM = listADM.Find(x => x.Billete == oBSP_Ticket.Billete); if (oADM != null) { oBSP_Ticket_Detalle.Observaciones += (string.IsNullOrEmpty(oBSP_Ticket_Detalle.Observaciones) ? "" : "|") + oADM.Observaciones; } } oBSP_Ticket.Detalle.Add(oBSP_Ticket_Detalle); oBSP_Ticket_Detalle = null; } else if (oBSP_Ticket != null) { oBSP_Ticket_Detalle = BSPActions.GetTicketDetalle(Linea); oBSP_Ticket.Detalle.Add(oBSP_Ticket_Detalle); oBSP_Ticket_Detalle = null; } } } } else { Linea = arrLineas[10]; string strMoneda = Linea.Substring(("MONEDA: ").Length, 3); Moneda Moneda = strMoneda == "ARS" ? Moneda.Peso : Moneda.Dolar; foreach (BSP_Ticket bsp_ticket in semanaToImport.TicketsBSP.Where(x => x.Moneda == null)) { bsp_ticket.Moneda = Moneda; } if (oBSP_Ticket != null) { oBSP_Ticket.Moneda = Moneda; } } } } if (oBSP_Ticket != null) { semanaToImport.TicketsBSP.Add(oBSP_Ticket); oBSP_Ticket = null; } semanaToImport.TicketsBSP = semanaToImport.TicketsBSP.OrderBy(x => x.Compania.Codigo).ThenBy(x => x.Billete).ToList(); semanaToImport.BSPCargado = true; pdfReader.Close(); if (lstNuevasCompanias.Count > 0) { string mensaje = "Se han encontrado Compañías Aéreas que no estaban registradas en el sistema:\n\n"; lstNuevasCompanias.ForEach(x => mensaje += "ID: " + x.ID + " | Nombre: " + x.Nombre + "\n"); mensaje += "\nÉstas han sido guardadas automáticamente, pero el código alfanumérico deberá ser ingresado manualmente.\n"; mensaje += "Por favor, ingrese al \"ABM de Compañías\" y complete la información solicitada.\n"; mensaje += "Muchas gracias."; MessageBox.Show(mensaje, "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception Exception1) { TextToFile.Errores(TextToFile.Error(Exception1)); MessageBox.Show("Error: " + Exception1.Message + "\nfileName: " + fileName + "\npage: " + page + "\nline: " + index, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { companias.CloseConnection(); conceptos.CloseConnection(); } }
public JsonResult SaveDeploymentPeriod(ACM.Model.DeploymentPeriod deploymentperiod) { //return RedirectToAction("DeploymentPeriodDashboard"); try { if (ModelState.IsValid) { if (deploymentperiod.DeploymentPeriodId == 0) { deploymentperiod.CreatedDate = DateTime.Now; DeploymentPeriodBO deploymentPeriodBO = new DeploymentPeriodBO(); deploymentPeriodBO.DeploymentPeriodAdd(deploymentperiod); // return RedirectToRoute("DeploymentPeriodDashboard"); // return RedirectToAction("DeploymentPeriodDashboard","DeploymentPeriod"); // return Json(deploymentperiod); return Json(deploymentperiod); } else { deploymentperiod.ModifiedDate = DateTime.Now ; DeploymentPeriodBO deploymentPeriodBO = new DeploymentPeriodBO(); // deploymentPeriodBO.DeploymentPeriodAdd(deploymentperiod); // deploymentperiod = deploymentPeriodBO.DeploymentPeriodInquiry(deploymentperiod); //deploymentperiod.Closed = "N"; //deploymentperiod.Status = "Open"; deploymentPeriodBO.DeploymenPeriodModification (deploymentperiod); // return RedirectToRoute("DeploymentPeriodDashboard"); // return RedirectToAction("DeploymentPeriodDashboard","DeploymentPeriod"); // return Json(deploymentperiod); // return RedirectToAction("DeploymentPeriodDashboard", "DeploymentPeriod"); return Json(deploymentperiod); } } else { IEnumerable<ModelError> errors = ModelState.Values.SelectMany(v => v.Errors); return Json(errors); } } catch (Exception ex) { return Json("Error"); } // return Json(Url.Action("DeploymentPeriodDashboard", "DeploymentPeriod")); // return RedirectToAction("DeploymentPeriodDashboard", "DeploymentPeriod"); }
public void SaveCampaign(ACM.Model.Campaign campaign, List<CampaignTargetFileProvider> campaignTargetFileProviderList, List<CampaignLocation> campaignLocationList) { try { /* ACM.Model.Campaign campaignObj = new ACM.Model.Campaign(); { campaignObj.CampaignId = campaign.CampaignId; campaignObj.RequestorId = campaign.RequestorId; campaignObj.LOBId = campaign.LOBId; campaignObj.CampaignName = campaign.CampaignName; } ACMContex.Campaigns.Add(campaignObj); */ // ACMContex.Entry(campaign).State = EntityState.Modified; int maxid = ACMContex.Campaigns.Select(r => r.CampaignId).Max(); campaign.CampaignId = maxid + 1; ACMContex.Campaigns.Add(campaign); if (campaignTargetFileProviderList != null) { foreach (CampaignTargetFileProvider campaignTargetFileProvider in campaignTargetFileProviderList) { CampaignTargetFileProvider campaignTargetFileProviderObj = new CampaignTargetFileProvider(); campaignTargetFileProvider.CampaignId = maxid + 1; //int CampaignLocationId = ACMContex.CampaignTargetFileProviders .Select(r => r.Id).Max(); //campaignTargetFileProvider.Id = CampaignLocationId + 1; /* campaignTargetFileProviderObj.CampaignId = campaignTargetFileProvider.CampaignId; campaignTargetFileProviderObj.TargetFileProviderDesc = campaignTargetFileProvider.TargetFileProviderDesc; campaignTargetFileProviderObj.Frequency = campaignTargetFileProvider.Frequency; campaignTargetFileProviderObj.CreatedBy = campaignTargetFileProvider.CreatedBy; campaignTargetFileProviderObj.CreatedDate = campaignTargetFileProvider.CreatedDate; campaignTargetFileProviderObj.ModifiedBy = campaignTargetFileProvider.ModifiedBy; campaignTargetFileProviderObj.ModifiedDate = campaignTargetFileProvider.ModifiedDate; campaignTargetFileProviderObj.Status = campaignTargetFileProvider.Status; */ campaignTargetFileProvider.Status = "Active"; ACMContex.CampaignTargetFileProviders.Add(campaignTargetFileProvider); } } if (campaignLocationList != null) { foreach (CampaignLocation campaignLocation in campaignLocationList) { CampaignLocation campaignLocationObj = new CampaignLocation(); campaignLocationObj.CampaignId = maxid + 1; // campaignLocationObj.CampaignId = campaignLocation.CampaignId; campaignLocationObj.RegionId = campaignLocation.RegionId; campaignLocationObj.SuperRegionId = campaignLocation.SuperRegionId; //campaignLocationObj.SpecifyRegionName = campaignLocation.SpecifyRegionName; campaignLocationObj.CreatedBy = campaignLocation.CreatedBy; campaignLocationObj.CreatedDate = campaignLocation.CreatedDate; campaignLocationObj.ModifiedBy = campaignLocation.ModifiedBy; campaignLocationObj.ModifiedDate = campaignLocation.ModifiedDate; // campaignLocationObj.Status = campaignLocation.Status; ACMContex.CampaignLocations.Add(campaignLocationObj); } } //ACMContex.Campaigns.Add ACMContex.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw; } }
public virtual bool IsCanRemoveLoan(LoanData data) { ACM.Reset(SelfBaseUnit); ACM.Add(new ExCondition(IsLoanExpire(data), "AC_债务没有到期")); return(ACM.IsTrue()); }