This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Interreg.App.Audit.Application{ | |
using Domain.Model.Applications; | |
public class ApplicationAudit:Audit{ | |
public override void AttachHandlers(){ | |
On<AttachmentAdded>(e=>e.Source.LogEvent( | |
"Attachment named '{0}' added".With(e.Attachment.Name))); | |
On<AttachmentRemoved>(e=>e.Source.LogEvent( | |
"Attachment named '{0}' removed".With(e.Attachment.Name))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Xml.Linq; | |
public class WordTemplateFiller{ | |
private readonly Zipper _zipper=new Zipper(); | |
private const string _pathToCustomPropXml="docprops\\custom.xml"; | |
/// <returns>path to filled docx</returns> | |
public FileInfo FillTemplate(string templatePath,Dictionary<string,string> props){ | |
var docPath=Path.GetTempFileName(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
public class TempDirectory:IDisposable{ | |
private readonly string _path; | |
public TempDirectory(){ | |
var path=Path.Combine(Path.GetTempPath(),Path.GetRandomFileName()); | |
Directory.CreateDirectory(path); | |
_path=path; | |
} | |
public void Dispose(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Interreg.Web{ | |
using System; | |
using System.Security.Principal; | |
using System.Web.Security; | |
using MvcExtensions.StructureMap; | |
public class MvcApplication:StructureMapMvcApplication{ | |
//ignore this bullshit code... | |
protected void Application_AuthenticateRequest(Object sender,EventArgs e){ | |
var authCookie=Context.Request.Cookies[FormsAuthentication.FormsCookieName]; | |
if(authCookie==null||authCookie.Value=="") return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserSession:IUserSession{ | |
private readonly IAuthenticationService _authenticationService; | |
private readonly ICryptographer _crypto; | |
private readonly IUserRepository _repository; | |
public UserSession(IUserRepository repository,IAuthenticationService authenticationService,ICryptographer crypto){ | |
Guard.AgainstNull(repository); | |
Guard.AgainstNull(authenticationService); | |
Guard.AgainstNull(crypto); | |
_repository=repository; | |
_crypto=crypto; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Interreg.Infra.Forms{ | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using Microsoft.Office.Interop.Excel; | |
public interface IExcelReader:IDisposable{ | |
void Open(string path); | |
string Get(string key); | |
void ChangeSheet(string key); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Map=BudgetPerPartnersMap; | |
//you all going to die down here! | |
public static class BudgetPerPartnersReader{ | |
public static void Read(IExcelReader r,ApplicationForm f){ | |
r.ChangeSheet(SheetMap.BudgetPerPartners); | |
var b=f.BudgetPerPartners; | |
var fillCostsType=new Action<CostsType,string[,]>( | |
(costsType,map)=>{ | |
costsType.AllPartnersTotal=r.Get(Map.AllPartnersTotal[0]); | |
for(var i=0;i<map.GetUpperBound(0);i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//class Application { | |
public virtual void ReceivePaperVersion(DateTime sendDate,DateTime arrivalDate){ | |
if(Statuses.ApplicationStatus!=ApplicationStatus.ReceivedElectronically) | |
throw new ApplicationException | |
("Paper version can be received only right after electronic version is received."); | |
var d=Call.ApplicationDeadlines; | |
if(sendDate>d.PaperVersionSendDeadline) | |
throw new ApplicationException("Send date exceeds call deadline"); | |
if(arrivalDate>d.PaperVersionArrivalDeadline) | |
throw new ApplicationException("Arrival date exceeds call deadline"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public ActionResult ReceivePaperVersion(Application a,ReceivePaperVersionInput inp){ | |
var r=new Func<ActionResult>(()=>RedirectToAction("Details",new {a.Id})); | |
return this.Do( | |
()=>{ | |
a.ReceivePaperVersion(inp.PaperVersionSendDate.Value,inp.PaperVersionArrivalDate.Value); | |
this.Flash("Application paper version received!"); | |
return r(); | |
},r); //1st arg==happy path, 2nd arg==onFail | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ((sTemp.IndexOf(".") == -1) && (sTemp.Length >= 1) && | |
(sTemp.ToUpper().IndexOf("N") == -1) && (sTemp.IndexOf("-") == -1)) | |
{ | |
invRow.AT13 = true; | |
} | |
else | |
{ | |
invRow.AT13 = false; | |
} | |
sTemp = |