void SendToCissa(HumDistributionPlan obj) { var HumDistributionPlanDefId = new Guid("{8C9BC637-06E2-4AE7-ACD8-F498C1CA1620}"); var HumDistributionPlanItemDefId = new Guid("{EAA7299C-E4AF-4203-8D18-1733F639F902}"); var portalStateTypeId = new Guid("{D6D8589D-46EF-4323-B25F-BE312260F1BB}"); var positionId = new Guid("{DF1C36BB-85B0-4C53-8729-F18A5D6615F4}"); if (obj.Company != null) { var company = obj.Company; var cissameta = new CissaMeta.MetaProxy(); var cissa_portal_users = cissameta.GetUsersByPositionId(positionId, company.OrgId ?? Guid.Empty); if (cissa_portal_users != null && cissa_portal_users.Count() > 0) { var user = cissa_portal_users.First(); var context = CreateContext(user.User_Name, user.Id); var docRepo = context.Documents; var reportDoc = docRepo.New(HumDistributionPlanDefId); reportDoc["RegDate"] = obj.Date; reportDoc["LegalPerson"] = GetLegalPerson(context, obj); reportDoc["PortalEntryId"] = obj.Id; reportDoc["CurrencyISOCode"] = obj.CurrencyISOCode; reportDoc["TotalSum"] = obj.Items.Sum(x => x.Sum); docRepo.Save(reportDoc); docRepo.SetDocState(reportDoc, portalStateTypeId); foreach (var objItem in obj.Items) { var item = docRepo.New(HumDistributionPlanItemDefId); item["HumDistributionPlan"] = reportDoc.Id; item["Consumer"] = objItem.Consumer.Name; item["Region"] = objItem.Area.Name; item["Address"] = objItem.Address; item["ProductName"] = objItem.Product.Name; item["Unit"] = objItem.UnitType.EnumId; item["Amount"] = objItem.Amount; //item["Weight"] = objItem.Weight; item["Sum"] = objItem.Sum; docRepo.Save(item); } } else { throw new ArgumentNullException(paramName: "cissa_portal_users", message: "Пользователь не найден!"); } } else { throw new ArgumentNullException(paramName: "Report.Company", message: "Компания не найдена!"); } }
public ActionResult Create([Bind(Include = "Id,ReportId,PIN,LastName,FirstName,MiddleName,BirthDate,GenderId,PassportSeries,PassportNo,PassportDate,PassportOrg,BirthCertificateNo,DateFrom,DateTo,Citizenship,DeadCadThrowRepublicBudget,SixDay,Highlands,SalaryOf3Months,BirthCountWorkingDays,AmountAverageEarnings,BirthCashThrowLegalOrg,BirthCadThrowRepublicBudget")] BirthInfoOnPayBenefit birthInfoOnPayBenefit) { if (ModelState.IsValid) { var positionId = new Guid("{DF1C36BB-85B0-4C53-8729-F18A5D6615F4}"); var report = db.LegalReportSections.Find(birthInfoOnPayBenefit.ReportId); var company = db.Companies.Find(report.CompanyId); if (company != null) { //var RGUSOrgId = new Guid("{6853C82D-751E-40DD-AA14-21AF0AB7C64E}"); var cissameta = new CissaMeta.MetaProxy(); //var code = cissameta.OrgCode(company.OrgId ?? Guid.Empty); var cissa_portal_users = cissameta.GetUsersByPositionId(positionId, company.OrgId ?? Guid.Empty); if (cissa_portal_users != null && cissa_portal_users.Count() > 0) { var user = cissa_portal_users.First(); var context = CreateContext(user.User_Name, user.Id); try { CalcBirthInfoOnPayBenefits.Execute(context, birthInfoOnPayBenefit); db.BirthInfoOnPayBenefits.Add(birthInfoOnPayBenefit); db.SaveChanges(); return(RedirectToAction("Details", "LegalReportSections", new { id = birthInfoOnPayBenefit.ReportId })); } catch (Exception e) { ModelState.AddModelError("", e.Message); } } } } ViewBag.GenderId = new SelectList(db.Genders, "Id", "Name", birthInfoOnPayBenefit.GenderId); return(View(birthInfoOnPayBenefit)); }
void SendToCissa(LegalReportSection obj) { var LegalReportSectionDefId = new Guid("{EC14A952-D4D8-4EA8-90F5-50121CC4B173}"); var BirthInfoOnPayBenefitDefId = new Guid("{46C27FED-B9E0-4DAA-9DD4-F984A526D9B5}"); var DeadInfoOnPayBenefitDefId = new Guid("{89ADB43B-0D29-4287-AF5B-0E0DCED18B01}"); var personDefId = new Guid("{D71CE61A-9B59-4B5E-8713-8131DBB5BA02}"); var portalStateTypeId = new Guid("{D6D8589D-46EF-4323-B25F-BE312260F1BB}"); var positionId = new Guid("{DF1C36BB-85B0-4C53-8729-F18A5D6615F4}"); var maleEnumItemId = new Guid("{74C6C7FE-53C6-4492-A62F-65A7A49AB644}"); var femaleEnumItemId = new Guid("{56E07640-5B5B-47FA-832D-A6639F36EB71}"); if (obj.Company != null) { var company = obj.Company; //var RGUSOrgId = new Guid("{6853C82D-751E-40DD-AA14-21AF0AB7C64E}"); var cissameta = new CissaMeta.MetaProxy(); //var code = cissameta.OrgCode(company.OrgId ?? Guid.Empty); var cissa_portal_users = cissameta.GetUsersByPositionId(positionId, company.OrgId ?? Guid.Empty); if (cissa_portal_users != null && cissa_portal_users.Count() > 0) { var user = cissa_portal_users.First(); var context = CreateContext(user.User_Name, user.Id); var docRepo = context.Documents; var reportDoc = docRepo.New(LegalReportSectionDefId); reportDoc["RegDate"] = obj.ReportDate; reportDoc["LegalPerson"] = GetLegalPerson(context, obj); reportDoc["ReportDate"] = obj.ReportDate.Value.ToShortDateString(); reportDoc["BalanceBegin"] = obj.BalanceBegin; reportDoc["AccruedBenefitsBegin"] = obj.AccruedBenefitsBegin; reportDoc["IncludingMonth"] = obj.IncludingMonth; reportDoc["IncreaseDecreaseAmount"] = obj.IncreaseDecreaseAmount; reportDoc["RefundedRepBudgetBegin"] = obj.RefundedRepBudgetBegin; reportDoc["DebtBalanceEnd"] = obj.DebtBalanceEnd; docRepo.Save(reportDoc); docRepo.SetDocState(reportDoc, portalStateTypeId); foreach (var objItem in obj.BirthInfoOnPayBenefits) { var item = docRepo.New(BirthInfoOnPayBenefitDefId); item["LegalReportSection"] = reportDoc.Id; var person = docRepo.New(personDefId); person["PIN"] = objItem.PIN; person["LastName"] = objItem.LastName; person["FirstName"] = objItem.FirstName; person["MiddleName"] = objItem.MiddleName; person["BirthDate"] = objItem.BirthDate; docRepo.Save(person); item["Person"] = person.Id; item["Nationality"] = objItem.Citizenship; item["BirthNumberCertificate"] = objItem.BirthCertificateNo; item["DateFrom"] = objItem.DateFrom; item["DateTo"] = objItem.DateTo; item["SixDay"] = objItem.SixDay; item["Highlands"] = objItem.Highlands; item["SalaryOf3Months"] = objItem.SalaryOf3Months; item["BirthCountWorkingDays"] = objItem.BirthCountWorkingDays; item["AmountAverageEarnings"] = objItem.AmountAverageEarnings; item["BirthCashThrowLegalOrg"] = objItem.BirthCashThrowLegalOrg; item["BirthCadThrowRepublicBudget"] = objItem.BirthCadThrowRepublicBudget; item["BirthTotalAmount"] = objItem.BirthTotalAmount; docRepo.Save(item); } foreach (var objItem in obj.DeadInfoOnPayBenefits) { var item = docRepo.New(DeadInfoOnPayBenefitDefId); item["LegalReportSection"] = reportDoc.Id; var person = docRepo.New(personDefId); person["PIN"] = objItem.PIN; person["LastName"] = objItem.LastName; person["FirstName"] = objItem.FirstName; person["MiddleName"] = objItem.MiddleName; person["BirthDate"] = objItem.BirthDate; docRepo.Save(person); item["Person"] = person.Id; item["Citizenship"] = objItem.Citizenship; item["DeadCadThrowRepublicBudget"] = objItem.DeadCadThrowRepublicBudget; docRepo.Save(item); } } } else { throw new ArgumentNullException(paramName: "Report.Company", message: "Компания не найдена!"); } }