public ActionResult DeleteConfirmed(int id) { ProjectFiles projectFiles = this.filmngr.DetailsById(id); this.filmngr.Delete(projectFiles); return(RedirectToAction("Index")); }
internal void AddFileIfMissing(string path) { path = Path.GetFullPath(path); if (!UpdateProjectFile || !ProjectFound) { return; } Log("Checking if project \"{0}\" contains file \"{1}\"", ProjectPath, path); var line = string.Format(LineFormat, path.Substring(ProjectDir.Length + 1, path.Length - ProjectDir.Length - 1)); lock (_dictionaryLock) { if (ProjectFiles.ContainsKey(line)) { Log("Project \"{0}\" contains file \"{1}\"", ProjectPath, path); return; } Log("Project \"{0}\" does not contains file \"{1}\"", ProjectPath, path); ProjectFiles.Add(line, line); } if (UseTfsToCheckoutFiles) { Tfs.Add(path); } Console.WriteLine(path + " added to project."); ProjectUpdated = true; }
public MSBuildProject(FilePath filePath) { FilePath = filePath; _msBuildProject = ProjectRootElement.Open(filePath.FullPath, _globalCollection); foreach (var item in _msBuildProject.Items) { if (item.ItemType == "Reference") { References.Add(item.Include); } else if (item.ItemType == "Compile" || item.ItemType == "None") { var entry = new ProjectFileEntry(new FilePath(this.ProjectDirectory, item.Include)); foreach (var element in item.Metadata) { if (element.Name == "DependentUpon") { entry.Dependencies.Add(element.Value); } } entry.ParentProject = this; AddFileEventHandlers(entry); ProjectFiles.Add(entry); } } SetupEventHandlers(); HasUnsavedData = false; }
private void btnRemoveFileItem_Click(object sender, RoutedEventArgs e) { var propertyGroup = (PropertyGroup)((Button)e.OriginalSource).DataContext; ProjectFiles.Remove(propertyGroup); e.Handled = true; }
public override bool Execute() { var properties = new Dictionary <string, string> { { "Configuration", "$(Configuration)" }, { "Platform", "$(Platform)" }, { "TargetFramework", "$(TargetFramework)" } }; Log.LogMessage(MessageImportance.High, "Configuration : {0}", Configuration); Log.LogMessage(MessageImportance.High, "Platform : {0}", Platform); Log.LogMessage(MessageImportance.High, "TargetFramework : {0}", TargetFramework); List <ITaskItem> pList = ProjectFiles.ToList(); List <ITaskItem> tizenList = new List <ITaskItem>(); foreach (var pItem in pList) { // Load the project into a separate project collection so // we don't get a redundant-project-load error. var collection = new ProjectCollection(properties); var project = collection.LoadProject(pItem.ItemSpec); ProjectProperty pp = project.Properties.Where(p => p.Name == "TizenProject" && p.EvaluatedValue == "true").FirstOrDefault(); if (pp != null) { tizenList.Add(pItem); } } tizenProjectFiles = tizenList; return(true); }
public override bool RunTask() { if (ProjectFiles.Length != 1) { Log.LogCodedError("XA1015", Properties.Resources.XA1015); } var wearProj = ProjectFiles.First(); var manifestXml = XDocument.Load(wearProj.ItemSpec) .Root.Elements(msbuildNS + "PropertyGroup").Elements(msbuildNS + "AndroidManifest").Select(e => e.Value).FirstOrDefault(); if (string.IsNullOrEmpty(manifestXml)) { Log.LogCodedError("XA1016", Properties.Resources.XA1016, wearProj); } manifestXml = Path.Combine(Path.GetDirectoryName(wearProj.ItemSpec), manifestXml.Replace('\\', Path.DirectorySeparatorChar)); ApplicationManifestFile = manifestXml; Log.LogDebugMessage(" [Output] ApplicationManifestFile: " + ApplicationManifestFile); ApplicationPackageName = AndroidAppManifest.CanonicalizePackageName(XDocument.Load(manifestXml).Root.Attributes("package").Select(a => a.Value).FirstOrDefault()); if (string.IsNullOrEmpty(ApplicationPackageName)) { Log.LogCodedError("XA1017", Properties.Resources.XA1017); } Log.LogDebugMessage(" [Output] ApplicationPackageName: " + ApplicationPackageName); return(true); }
internal void AddFileIfMissing(string path) { path = Path.GetFullPath(path); if (!UpdateProjectFile || File.Exists(path) || !ProjectFound) { return; } var line = string.Format(LineFormat, path.Substring(ProjectDir.Length + 1, path.Length - ProjectDir.Length - 1)); lock (_dictionaryLock) { if (ProjectFiles.ContainsKey(line)) { return; } ProjectFiles.Add(line, line); } if (TfsWorkspace != null) { // Create File so it can be added: using (File.Create(path)) { TfsWorkspace.PendAdd(path, false); } } ProjectUpdated = true; }
public Boolean AddProjectFile(ProjectFile pf) { if (ProjectFiles.Contains(pf)) { // TODO: maybe the build system is dumb and recompiles the same file multiple times? return(false); } ProjectFiles.Add(pf); if (pf.ProjectFolder != null) { // create project structure RelativeCrosspath projectFolder = new RelativeCrosspath(pf.ProjectFolder); Stack <String> todo = new Stack <String>(); while (true) { String fldr = projectFolder.ToString().Replace('/', '\\'); if (fldr == "." || ProjectFilters.Contains(fldr)) { break; } todo.Push(fldr); projectFolder.ToContainingDirectory(); } foreach (String filter in todo) { ProjectFilters.Add(filter); } } return(true); }
public override bool Execute() { if (ProjectFiles.Length != 1) { Log.LogError("More than one Android Wear project is specified as the paired project. It can be at most one."); } var wearProj = ProjectFiles.First(); var manifestXml = XDocument.Load(wearProj.ItemSpec) .Root.Elements(msbuildNS + "PropertyGroup").Elements(msbuildNS + "AndroidManifest").Select(e => e.Value).FirstOrDefault(); if (string.IsNullOrEmpty(manifestXml)) { Log.LogError("Target Wear application's project '{0}' does not specify required 'AndroidManifest' project property.", wearProj); } manifestXml = Path.Combine(Path.GetDirectoryName(wearProj.ItemSpec), manifestXml.Replace('\\', Path.DirectorySeparatorChar)); ApplicationManifestFile = manifestXml; Log.LogDebugMessage(" [Output] ApplicationManifestFile: " + ApplicationManifestFile); ApplicationPackageName = AndroidAppManifest.CanonicalizePackageName(XDocument.Load(manifestXml).Root.Attributes("package").Select(a => a.Value).FirstOrDefault()); if (string.IsNullOrEmpty(ApplicationPackageName)) { Log.LogError("Target Wear application's AndroidManifest.xml does not specify required 'package' attribute."); } Log.LogDebugMessage(" [Output] ApplicationPackageName: " + ApplicationPackageName); return(true); }
public void CloseProject() { mode = md.select; projprev.SetActive(false); selectproj.SetActive(true); for (int i = prevopt.osscroll.childCount - 1; i >= 0; i--) { Destroy(prevopt.osscroll.GetChild(i).gameObject); } for (int i = prevopt.funcscroll.childCount - 1; i >= 0; i--) { Destroy(prevopt.funcscroll.GetChild(i).gameObject); } scene.bg.sprite = prew.defbg; config.bigicon.text = "0"; config.smallicon.text = "0"; curProj = new ProjectFiles(); prevopt.functog = new List <Toggle>(); prevopt.ostog = new List <Toggle>(); GetProjects(); }
public static void Main() { string DigitalPath = Path.GetFullPath(@"Digital Project"); string pinMapPath = Path.Combine(DigitalPath, "PinMap.pinmap"); string specPath = Path.Combine(DigitalPath, "Specifications.specs"); string levelsPath = Path.Combine(DigitalPath, "PinLevels.digilevels"); string timingPath = Path.Combine(DigitalPath, "Timing.digitiming"); string[] patternPaths = Directory.GetFiles(Path.Combine(DigitalPath, "RFFE Command Patterns"), "*.digipat"); ProjectFiles projectFiles = new ProjectFiles { PinMapFile = pinMapPath, SpecificationsFiles = new string[1] { specPath }, PinLevelsFiles = new string[1] { levelsPath }, TimingFiles = new string[1] { timingPath }, DigitalPatternFiles = patternPaths }; //Initialize hardware and load pinmap plus sheets into //digital pattern instrument. Most of the fucntions below are //a lightweight wrapper around NI - Digital functions. //If you change the insturment name below, you must also change the instrument name //in the PinMap file NIDigital digital = new NIDigital("PXIe-6570", false, false, ""); LoadProjectFiles(digital, projectFiles); //Turn RFFE bus power on digital.PinAndChannelMap.GetPinSet("RFFEVIO").WriteStatic(PinState._1); //Setup new register data to send to register 0 RegisterData regData = new RegisterData { SlaveAddress = 0xF, //15 WriteRegisterData = new byte[1] { 0x8 }, ByteCount = 1 }; //Trgger type is set to none so burst will start immediately TriggerConfiguration triggerConfig = new TriggerConfiguration { BurstTriggerType = TriggerType.None, }; //Burst a Reg0Write command using the data specified in regData BurstRFFE(digital, regData, "RFFEDATA", RFFECommand.Reg0Write, triggerConfig); Console.ReadKey(); DisconnectAndClose(digital); }
/// <summary> /// Constructs an instance of Project. /// </summary> ///<param name="projectName">Name of the project.</param> /// <param name="projectPath">Absolute path to the project folder.</param> /// <param name="videoPath">Absolute path to the video file.</param> /// <param name="copyVideo">Whether or not to copy the video file into the project folder.</param> public Project(string projectName, string projectPath, string videoPath, bool copyVideo) { ProjectName = projectName; string projectFolder = Path.Combine(projectPath, projectName); Folders = new ProjectFolders { Project = projectFolder, Cache = ProjectFile.FromRelativePath(Names.CacheFolder, projectFolder), Descriptions = ProjectFile.FromRelativePath(Names.DescriptionsFolder, projectFolder), }; Files = new ProjectFiles { Project = ProjectFile.FromRelativePath(projectName + Names.ProjectExtension, projectFolder), Descriptions = ProjectFile.FromRelativePath(Names.DescriptionsFile, projectFolder), Spaces = ProjectFile.FromRelativePath(Names.SpacesFile, projectFolder), WaveFormHeader = ProjectFile.FromRelativePath(Path.Combine(Folders.Cache.RelativePath, Names.WaveFormHeader), projectFolder), WaveForm = ProjectFile.FromRelativePath(Path.Combine(Folders.Cache.RelativePath, Names.WaveFormFile), projectFolder), }; if (copyVideo) { string videoFileName = Path.GetFileName(videoPath); Files.Video = ProjectFile.FromRelativePath(videoFileName, Folders.Project); } else Files.Video = ProjectFile.FromAbsolutePath(videoPath, Folders.Project); }
private void BuildBanks() { SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Building banks", OutputMessageType.Information); ProjectModel projectModel = ModelManager.Get <ProjectModel>(); string outputPath = Path.GetFullPath(projectModel.Build.OutputFilePath); List <FileModelVO> bankModelVOs = ProjectFiles.GetModels <BankModel>(); const int cellSizeInBytes = 128; // 16 bytes each cell foreach (FileModelVO vo in bankModelVOs) { BankModel bank = vo.Model as BankModel; int cellsCount = 0; switch (bank.BankSize) { case BankSize.Size4Kb: cellsCount = 16 * 16; break; case BankSize.Size2Kb: cellsCount = 16 * 8; break; case BankSize.Size1Kb: cellsCount = 16 * 4; break; } Dictionary <string, WriteableBitmap> bitmapCache = new Dictionary <string, WriteableBitmap>(); BitArray outputBits = new BitArray(cellSizeInBytes * cellsCount); outputBits.SetAll(false); int currentIndex = 0; WriteableBitmap bitmap = BanksUtils.CreateImage(bank, ref bitmapCache, false); using (bitmap.GetBitmapContext()) { WriteIntoBitArray(bank, bitmap, ref outputBits, ref currentIndex); } for (int i = 0; i < cellSizeInBytes * cellsCount;) { Reverse(ref outputBits, i, 8); i += 8; } byte[] bytes = new byte[outputBits.Length / 8]; outputBits.CopyTo(bytes, 0); string fullPath = Path.Combine(outputPath, vo.Name.ToLower() + ".bin"); File.WriteAllBytes(fullPath, bytes); } SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Finishing building banks", OutputMessageType.Information); }
private void BuildBackgrounds() { SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Building background", OutputMessageType.Information); ProjectModel projectModel = ModelManager.Get <ProjectModel>(); List <FileModelVO> models = ProjectFiles.GetModels <MapModel>(); foreach (FileModelVO item in models) { MapModel model = item.Model as MapModel; string fullPath = Path.Combine(Path.GetFullPath(projectModel.Build.OutputFilePath), item.Name + ".s"); using (StreamWriter outputFile = new StreamWriter(fullPath)) { outputFile.WriteLine("; This file is autogenerated!"); outputFile.Write(Environment.NewLine); outputFile.WriteLine($"nt_{item.Name}:"); List <byte> serializedMap = new List <byte>(); SerializeNametable(model, ref serializedMap); if (projectModel.Build.UseRLEOnMaps) { RLE.Compress(serializedMap, out List <byte> compressedData); serializedMap = compressedData; } FormatBytes(serializedMap, outputFile, 32); serializedMap.Clear(); if (model.ExportAttributeTable) { outputFile.WriteLine($"att_{item.Name}:"); SerializeAttributes(model, ref serializedMap); if (projectModel.Build.UseRLEOnMaps) { RLE.Compress(serializedMap, out List <byte> compressedData); serializedMap = compressedData; } FormatBytes(serializedMap, outputFile, 8); } PrintMetaData(model, item, outputFile); } } SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Finishing building background", OutputMessageType.Information); }
public static WriteableBitmap CreateImage(EntityModel entityModel) { WriteableBitmap bankBitmap = BitmapFactory.New(64, 64); using (bankBitmap.GetBitmapContext()) { foreach (CharacterTile tile in entityModel.Frame.Tiles) { if (string.IsNullOrEmpty(tile.BankID) || string.IsNullOrEmpty(tile.BankTileID)) { continue; } BankModel ptModel = ProjectFiles.GetModel <BankModel>(tile.BankID); if (ptModel == null) { continue; } PTTileModel bankModel = ptModel.GetTileModel(tile.BankTileID); if (string.IsNullOrEmpty(bankModel.GUID) && string.IsNullOrEmpty(bankModel.TileSetID)) { continue; } WriteableBitmap sourceBitmap = CreateImageUtil.GetCacheBitmap(bankModel.TileSetID); if (sourceBitmap == null) { continue; } using (sourceBitmap.GetBitmapContext()) { WriteableBitmap cropped = sourceBitmap.Crop((int)bankModel.Point.X, (int)bankModel.Point.Y, 8, 8); if (tile.FlipX) { cropped = WriteableBitmapExtensions.Flip(cropped, WriteableBitmapExtensions.FlipMode.Vertical); } if (tile.FlipY) { cropped = WriteableBitmapExtensions.Flip(cropped, WriteableBitmapExtensions.FlipMode.Horizontal); } int destX = (int)Math.Floor(tile.Point.X / 8) * 8; int destY = (int)Math.Floor(tile.Point.Y / 8) * 8; Util.CopyBitmapImageToWriteableBitmap(ref bankBitmap, destX, destY, cropped); } } } return(bankBitmap); }
public ActionResult Edit([Bind(Include = "Id,ReleaseId,FileName,Path,RowVersion")] ProjectFiles projectFiles) { if (ModelState.IsValid) { this.filmngr.Edit(projectFiles); return(RedirectToAction("Index")); } return(View(projectFiles)); }
public ActionResult Create([Bind(Include = "Id,ReleaseId,FileName,Path")] ProjectFiles projectFiles, HttpPostedFileBase file, int?releaseid) { if (ModelState.IsValid && file != null) { this.filmngr.Create(projectFiles, file); return(RedirectToAction("Index")); } return(View(projectFiles)); }
public IEnumerable <string> GetAnimationDefinitions(string animationData) { var item = ProjectFiles.FirstOrDefault(x => x.Path == animationData); if (item != null) { return(GetAnimationData(item).AnimationDefinitions.Select(x => x.Name)); } return(null); }
/* * Update the panel on the right hand side to show most recently selected file */ private void updateMostRecentFile(ProjectFiles p) { RFImage.Source = p.RenderedImg; RFLabel1.Content = p.Title; RFLabel2.Content = p.AccsTime; //RFLabel3.Content = p.Progress; RFLabel4.Content = String.Format("Number of Beacons: {0}", p.BeaconCount); pbStatus.Value = p.Progress; }
/* * opens the file when users click on the open button */ private void OpenButton_Click(object sender, RoutedEventArgs e) { if (sender != null) { System.Windows.Controls.Button btn = (System.Windows.Controls.Button)sender; ProjectFiles p = btn.DataContext as ProjectFiles; Process.Start(p.FullPath); updateLastOpenedFile(p); } updateFiles(); }
private void btnAllQualifierVersion_Click(object sender, RoutedEventArgs e) { var qualifierVersion = txtQualifier.Text; if (qualifierVersion.Length > 0 && int.TryParse(qualifierVersion.Substring(0, 1), out _)) { qualifierVersion = "-" + qualifierVersion;//qualifier version can not start with a number } ProjectFiles.ToList().ForEach(pgFile => ChangeFileVersion(pgFile, pg => pg.QualifierVersion = qualifierVersion)); }
private void ProjectDataService_ProjectLoaded(RecentProject p, EventArgs e) { ProjectFiles.Clear(); foreach (BaseMd fileMd in projectDataService.ProjectFiles) { // Scan for a tag that describes the type. // TODO: create the proper model classes to assign them in here. //File.OpenRead(filePath); ProjectFiles.Add(fileMd); } }
public static WriteableBitmap GetCacheBitmap(string tileSetID) { if (!TileSetModel.BitmapCache.TryGetValue(tileSetID, out WriteableBitmap tileSetBitmap)) { // The tileset exists but the bitmap is not in the cache, so I will try to load it here TileSetModel tileSetModel = ProjectFiles.GetModel <TileSetModel>(tileSetID); return(tileSetModel != null?TileSetModel.LoadBitmap(tileSetModel) : null); } return(tileSetBitmap); }
static void Main() { NIDigital digital = new NIDigital("PXIe-6570", false, false, ""); string pinMapPath = Path.GetFullPath(@"Support Files\PinMap.pinmap"); string specPath = Path.GetFullPath(@"Support Files\Specifications.specs"); string levelsPath = Path.GetFullPath(@"Support Files\PinLevels.digilevels"); string timingPath = Path.GetFullPath(@"Support Files\Timing.digitiming"); string patternPath = Path.GetFullPath(@"Support Files\Pattern.digipat"); ProjectFiles projectFiles = new ProjectFiles { PinMapFile = pinMapPath, SpecificationsFiles = new string[1] { specPath }, PinLevelsFiles = new string[1] { levelsPath }, TimingFiles = new string[1] { timingPath }, DigitalPatternFiles = new string[1] { patternPath } }; // Alternatively, you could use the following command to search for all matching NI-Digital project files // projectFiles = Digital.Utilities.SearchForProjectFiles(Path.GetFullPath(@"Support Files\"), true) LoadProjectFiles(digital, projectFiles); SourcePinConfiguration sourcePin = SourcePinConfiguration.GetDefault(); sourcePin.PinName = "DUTPin1"; ConfigureAndSourcePin(digital, sourcePin); TriggerConfiguration triggerConfig = new TriggerConfiguration { BurstTriggerType = TriggerType.None }; InitiatePatternGeneration(digital, "new_pattern", triggerConfig); Console.WriteLine("Pattern generation has begun. Press any key to abort, disconnect pins, and close the program."); Console.ReadKey(); digital.PatternControl.Abort(); DisconnectAndClose(digital); }
public ProjectFile GetFile(int projectId, int fileId) { try { var file = ProjectFiles.Where <ProjectFile>(p => p.FileID == fileId && p.ProjectID == projectId).FirstOrDefault(); return(file); } catch (Exception) { throw; } }
private void AddProject(Match match, string workingDirectory) { var projectName = match.Groups["ProjectName"].Value; var projectPath = match.Groups["ProjectPath"].Value; projectPath = Path.Combine(workingDirectory, projectPath); if (ShouldAddProject(projectName, projectPath)) { InfoFormat("Dependency: Adding project files {0} @ {1}...", projectName, projectPath); ProjectFiles.Add(projectName, new FileInfo(projectPath)); } }
/* * Event handler for project selection changed */ private void listView33_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender != null) { System.Windows.Controls.ListBox lb = (System.Windows.Controls.ListBox)sender; ProjectFiles p = (ProjectFiles)lb.SelectedItem; if (p != null) { SelectedProject = p; updateMostRecentFile(p); } } }
private void BuildPalettes() { SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Building palettes", OutputMessageType.Information); ProjectModel projectModel = ModelManager.Get <ProjectModel>(); string fullPath = Path.Combine(Path.GetFullPath(projectModel.Build.OutputFilePath), "palettes.s"); using (StreamWriter outputFile = new StreamWriter(fullPath)) { List <FileModelVO> paletteModelVOs = ProjectFiles.GetModels <PaletteModel>(); outputFile.WriteLine("; This file is autogenerated!"); SortedDictionary <string, StringWriter> pals = new SortedDictionary <string, StringWriter>(); foreach (FileModelVO vo in paletteModelVOs) { PaletteModel model = vo.Model as PaletteModel; string name = "palette_" + vo.Name.Replace(' ', '_').ToLower(); Color color0 = Util.GetColorFromInt(model.Color0); Color color1 = Util.GetColorFromInt(model.Color1); Color color2 = Util.GetColorFromInt(model.Color2); Color color3 = Util.GetColorFromInt(model.Color3); StringWriter stringWriter = new StringWriter(); stringWriter.Write($" .byte "); stringWriter.Write($"${Util.ColorToColorHex(color0)},"); stringWriter.Write($"${Util.ColorToColorHex(color1)},"); stringWriter.Write($"${Util.ColorToColorHex(color2)},"); stringWriter.Write($"${Util.ColorToColorHex(color3)}"); pals.Add(name, stringWriter); } foreach (var item in pals) { outputFile.WriteLine(""); outputFile.WriteLine($"{item.Key}:"); outputFile.Write(item.Value.ToString()); outputFile.Write(Environment.NewLine); } } SignalManager.Get <WriteBuildOutputSignal>().Dispatch("Finished building palettes", OutputMessageType.Information); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProjectFiles projectFiles = this.filmngr.DetailsById(id); if (projectFiles == null) { return(HttpNotFound()); } return(View(projectFiles)); }
/* * Opens up the Revit file when the users double click the item. */ private void ListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (sender != null) { System.Windows.Controls.ListBox lb = (System.Windows.Controls.ListBox)sender; ProjectFiles p = (ProjectFiles)lb.SelectedItem; if (p != null) { Process.Start(p.FullPath); updateLastOpenedFile(p); } } updateFiles(); }
protected void CreateProject_Click(object sender, EventArgs e) { string filename = ""; if (ProjectFiles.HasFile) { filename = Path.GetFileName(ProjectFiles.FileName); ProjectFiles.SaveAs(Server.MapPath("~/files/ProjectsFiles/") + filename); } int psID; if (ProjectOfferConfirmed.Checked) { psID = 2; // הזמנת עבודה } else { psID = 1; // הצעת מחיר } Project p = new Project(); DateTime InstallationDate; InstallationDate = ProjectInstallationDate.Value == "" ? InstallationDate = DateTime.MinValue : DateTime.ParseExact(ProjectInstallationDate.Value, "MM/dd/yyyy", null); p = new Project(DateTime.ParseExact(ProjectDateOpened.Value, "MM/dd/yyyy", null), DateTime.ParseExact(ProjectExpirationDate.Value, "MM/dd/yyyy", null), InstallationDate, ProjectName.Value, ProjectComments.Value, ProjectCost.Value, ProjectHatches.Value, ProjectArchitectName.Value, ProjectArchitectMobile.Value, ProjectContractorName.Value, ProjectContractorMobile.Value, ProjectSupervisorName.Value, ProjectSupervisorMobile.Value); //if ((Request.Url.Query == "?Source=NewCustomer" && Session["Customer"] != null)) || (Request.Url.Query == "?Source=ProjectsPerCustomer" && Session["CustomerID"] != null)) if (Session["Customer"] != null) { int CustomerID = 0; if (Request.Url.Query == "?Source=NewCustomer") { Customer c = new Customer(); c = (Customer)Session["Customer"]; CustomerID = c.cID; } else if (Request.Url.Query == "?Source=ProjectsPerCustomer") { CustomerID = Convert.ToInt32(Session["CustomerID"]); } p.InsertNewProject(CustomerID, psID); if (psID == 2) { InsertNewProjectNotification(ProjectName.Value); } Response.Redirect("~/Projects.aspx"); } }