TODO: Update summary.
		public SnapshotController(
			Project project,
			string prefix) :
			base(project)
		{
			_prefix = prefix;
		}
예제 #2
0
        public void RaiseIfResourceIsNull()
        {
            Project project = new Project();

            DateTime fromDate = new DateTime(2012, 9, 18);
            DateTime toDate = new DateTime(2012, 9, 20);
            int dailyload = 6;

            project.AllocateResource(null, fromDate, toDate, dailyload);
        }
 public string SaveProject(Project project, string delete = null)
 {
     if (IsDelete(delete))
     {
         Mongo.Projects.Remove(project.Id);
         return "Deleted";
     }
     Mongo.Projects.Save(project);
     return "Saved";
 }
예제 #4
0
        public void Setup()
        {
            this.project = new Project();
            this.john = new Resource();
            this.mary = new Resource();
            this.joe = new Resource();

            DateTime from = new DateTime(2012, 9, 11);
            DateTime to = new DateTime(2012, 9, 18);

            this.project.AllocateResource(john, from, to, 6);
            this.project.AllocateResource(mary, from, to, 6);
        }
예제 #5
0
        public void AllocateResourceToProject()
        {
            Project project = new Project();
            Resource resource = new Resource();

            DateTime fromDate = new DateTime(2012, 9, 18);
            DateTime toDate = new DateTime(2012, 9, 20);
            int dailyload = 6;

            project.AllocateResource(resource, fromDate, toDate, dailyload);

            var result = project.GetDailyLoad(resource, fromDate);
            Assert.AreEqual(6, result);
            result = project.GetDailyLoad(resource, fromDate.AddDays(-1));
            Assert.AreEqual(0, result);
        }
예제 #6
0
        public void AllocateResourceTwoWeeksToProjectSkippingWeekEnd()
        {
            Project project = new Project();
            Resource resource = new Resource();

            DateTime fromDate = new DateTime(2012, 9, 11);
            DateTime toDate = new DateTime(2012, 9, 21);
            DateTime saturday = new DateTime(2012, 9, 15);
            DateTime sunday = new DateTime(2012, 9, 16);
            int dailyload = 6;

            project.AllocateResource(resource, fromDate, toDate, dailyload);

            var result = project.GetDailyLoad(resource, saturday);
            Assert.AreEqual(0, result);
            result = project.GetDailyLoad(resource, sunday);
            Assert.AreEqual(0, result);
        }
        public static FileGroup[] DetectFileGroupsFromExcelFile(
            Project project,
            string filePath)
        {
            if (string.IsNullOrEmpty(filePath) ||
                (
                StringExtensionMethods.ToLowerInvariantIntelligent(ZlpPathHelper.GetExtension(filePath)) != @".xls" &&
                StringExtensionMethods.ToLowerInvariantIntelligent(ZlpPathHelper.GetExtension(filePath)) != @".xlsx"
                )
                ||
                !ZlpIOHelper.FileExists(filePath))
            {
                return null;
            }
            else
            {
                using (var tfc = new TemporaryFileCloner(filePath))
                {
                    var ds = CoreExcelImporter.ImportExcelFromFile(tfc.FilePath);

                    return detectFileGroupsFromWorkbook(project, ds);
                }
            }
        }
        private static FileGroup[] detectFileGroupsFromWorkbook(
            Project project,
            DataSet dataSet)
        {
            var result = new List<FileGroup>();

            var checkSums = new Set<long>();

            foreach (DataTable table in dataSet.Tables)
            {
                int totalChecksumRows;
                var ix = extractColumnCheckSums(table, out totalChecksumRows);
                foreach (var pair in ix)
                {
                    checkSums.Add(pair.First);
                }
            }

            // ReSharper disable LoopCanBeConvertedToQuery
            foreach (var checkSum in checkSums)
            // ReSharper restore LoopCanBeConvertedToQuery
            {
                var group = getFileGroupForCheckSum(project, checkSum);

                if (group != null)
                {
                    if (!group.IgnoreDuringExportAndImport &&
                        (group.ParentSettings == null || !group.ParentSettings.EffectiveIgnoreDuringExportAndImport))
                    {
                        result.Add(group);
                    }
                }
            }

            return result.ToArray();
        }
예제 #9
0
		public static bool CommentsAreVisible(
			Project project,
			DataRow row,
			CommentVisibilityScope commentVisibilityScope)
		{
			return CommentsAreVisible(project, row.Table, commentVisibilityScope);
		}
예제 #10
0
		public static string GetComment(
			Project project,
			DataRow row)
		{
			if (CommentsAreVisible(project, row, CommentVisibilityScope.InMemory))
			{
				return row[row.Table.Columns.Count - 1] as string;
			}
			else
			{
				return null;
			}
		}
예제 #11
0
		/// <summary>
		/// Create the data table for the grid.
		/// </summary>
		private DataTable getTable(
			Project project,
			bool forceCommentColumn)
		{
			// Load File from filesystem
			loadFiles();

			var table = new DataTable();

			// Add primary key columns.
			table.Columns.Add(
				new DataColumn
					{
						ColumnName = @"FileGroup",
						Caption = Resources.SR_ColumnCaption_FileGroup,
					});
			table.Columns.Add(
				new DataColumn
				{
					ColumnName = @"Name",
					Caption = Resources.SR_ColumnCaption_Name,
				});
			table.PrimaryKey =
				new[]
					{
						table.Columns[@"FileGroup"],
						table.Columns[@"Name"]
					};

			// AJ CHANGE

			// Add a Column for each filename
			foreach (var resxFile in _resxFiles)
			{
				var cn = resxFile.FilePath.Name;

				var culture =
					new LanguageCodeDetection(
						_gridEditableData.Project)
						.DetectCultureFromFileName(
							_gridEditableData.ParentSettings,
							cn);

				var cultureCaption =
					string.Format(
						@"{0} ({1})",
						culture.DisplayName,
						culture.Name);

				//Member 802361: only file names are loaded if same culture is not added first. there are no references any more to other files with same culture. So we name each column by culture and not by file name.
				//TODO: please check if no side effects elsewere
				if (!containsCaption(table.Columns, cultureCaption))
				{
					var column =
						new DataColumn(culture.Name)
							{
								Caption = cultureCaption
							};
					table.Columns.Add(column);
				}
			}

			if (GetShowCommentColumn(project) || forceCommentColumn)
			{
				table.Columns.Add(
					new DataColumn
						{
							ColumnName = @"Comment",
							Caption = Resources.SR_ColumnCaption_Comment
						});
			}

			// --

			// Add rows and fill them with data
			foreach (var resxFile in _resxFiles)
			{
				var fgcs = resxFile.FileInformation.FileGroup.GetChecksum(project);
				var cn = resxFile.FilePath.Name;

				var culture =
					new LanguageCodeDetection(
						_gridEditableData.Project)
						.DetectCultureFromFileName(
							_gridEditableData.ParentSettings,
							cn);

				var cultureCaption =
					string.Format(
						@"{0} ({1})",
						culture.DisplayName,
						culture.Name);

				var doc = resxFile.Document;
				var data = doc.GetElementsByTagName(@"data");

				var captionIndexCache = new Dictionary<string, int>();

				// Each "data" node of the XML document is processed
				foreach (XmlNode node in data)
				{
					var process = true;

					//Check if this is a non string data tag
					if (node.Attributes != null && node.Attributes[@"type"] != null)
					{
						process = false;
					}

					//skip mimetype like application/x-microsoft.net.object.binary.base64
					// http://www.codeproject.com/KB/aspnet/ZetaResourceEditor.aspx?msg=3367544#xx3367544xx
					if (node.Attributes != null && node.Attributes[@"mimetype"] != null)
					{
						process = false;
					}

					if (process)
					{
						// Get value of the "name" attribute 
						// and look for it in the datatable
						var name = node.Attributes == null ? string.Empty : node.Attributes[@"name"].Value;
						var row = table.Rows.Find(new object[] { fgcs, name });

						// Fixes the "value of second file displayed in first column" bug_.
						if (row == null)
						{
							table.Rows.Add(fgcs, name);
							row = table.Rows.Find(new object[] { fgcs, name });

							// AJ CHANGE
							if (GetShowCommentColumn(project) || forceCommentColumn)
							{
								var comment = node.SelectSingleNode(@"comment");
								if (comment != null)
								{
									row[@"Comment"] =
										string.IsNullOrEmpty(comment.InnerText)
											? string.Empty
											: AdjustLineBreaks(comment.InnerText);
									row.AcceptChanges();
								}
							}
						}

						var value = node.SelectSingleNode(@"value");

						if (value != null)
						{
							setAtCultureCaption(
								captionIndexCache,
								table.Columns,
								row,
								cultureCaption,
								string.IsNullOrEmpty(value.InnerText)
									? string.Empty
									: AdjustLineBreaks(value.InnerText));
							row.AcceptChanges();
						}
					}
				}
			}

			return table;
		}
예제 #12
0
		/// <summary>
		/// Store the changes in the data table back to the .RESX files
		/// </summary>
		private void saveTable(
			Project project,
			DataTable table,
			bool wantBackupFiles,
			bool omitEmptyStrings)
		{
			var index = 0;
			var languageCodeDetection = new LanguageCodeDetection(_gridEditableData.Project);

			foreach (var resxFile in _resxFiles)
			{
				try
				{
					var checksum = resxFile.FileInformation.FileGroup.GetChecksum(project);
					var document = resxFile.Document;
					var fileName = resxFile.FilePath.Name;

					//Member 802361: access value by culture and not by filename
					var culture =
						languageCodeDetection.DetectLanguageCodeFromFileName(
							_gridEditableData.Project,
							fileName);

					// 2011-04-09, Uwe Keim: "nb" => "nb-NO".
					var cultureLong = LanguageCodeDetection.MakeValidCulture(culture).Name;

					foreach (DataRow row in table.Rows)
					{
						if (row.RowState != DataRowState.Deleted)
						{
							if (!FileGroup.IsInternalRow(row))
							{
								var fileGroupCheckSum = ConvertHelper.ToInt64(row[@"FileGroup"]);

								// 2010-10-23, Uwe Keim: Only save if same file group.
								if (fileGroupCheckSum == checksum)
								{
									var tagName = (string)row[@"Name"];

									var xpathQuery =
										string.Format(
											@"child::data[attribute::name='{0}']",
											escapeXsltChars(tagName));

									if (document.DocumentElement != null)
									{
										var node = document.DocumentElement.SelectSingleNode(xpathQuery);
										var found = node != null;

										var content = row[cultureLong] as string;
										var textToSet = content ?? string.Empty;

										var commentsAreVisible =
											CommentsAreVisible(project, row, CommentVisibilityScope.InMemory);

										// AJ CHANGE
										var commentToSet =
											commentsAreVisible
												? row[@"Comment"] == DBNull.Value
													? string.Empty
													: (string)row[@"Comment"]
												: null;

										if (found)
										{
											var n = node.SelectSingleNode(@"value");

											//CHANGED: 	Member 802361 if content is null remove this entry
											if (content != null &&
												(!string.IsNullOrEmpty(textToSet) || !omitEmptyStrings))
											{
												// If not present (for whatever reason, e.g. 
												// manually edited and therefore misformed).
												if (n == null)
												{
													n = document.CreateElement(@"value");
													node.AppendChild(n);
												}

												n.InnerText = textToSet;

												// AJ CHANGE
												// Only write the comment to the main resx file
												if (commentsAreVisible)
												{
													if (resxFile == _resxFiles[0])
													{
														n = node.SelectSingleNode(@"comment");
														// If not present (for whatever reason, e.g. 
														// manually edited and therefore misformed).
														if (n == null)
														{
															n = document.CreateElement(@"comment");
															node.AppendChild(n);
														}

														n.InnerText = commentToSet ?? string.Empty;
													}
												}
											}
											else
											{
												if (n != null)
												{
													node.RemoveChild(n);
												}

												if (node.ParentNode != null)
												{
													node.ParentNode.RemoveChild(node);
												}
											}
										}
										else // Resource doesn't exist in XML.
										{
											if (content != null &&
												(!string.IsNullOrEmpty(textToSet) || !omitEmptyStrings))
											{
												// Member 802361: only do it if editing single fileGroup. 
												// If no we don't know where to add the new entry.
												// TODO: may be add to default file in the list?
												if (_gridEditableData.FileGroup == null)
												{
													//look if base file has same tagName
													//if base file skip it
													if (string.Compare(
														_gridEditableData.Project.NeutralLanguageCode,
														culture,
														true) == 0 ||
													    string.Compare(
													    	_gridEditableData.Project.NeutralLanguageCode,
													    	cultureLong,
													    	true) == 0)
													{
														continue;
													}

													// 2011-01-26, Uwe Keim:
													var pattern =
														resxFile.FileInformation.FileGroup.ParentSettings.EffectiveNeutralLanguageFileNamePattern;
													pattern = pattern.Replace(@"[basename]", resxFile.FileInformation.FileGroup.BaseName);
													pattern = pattern.Replace(@"[languagecode]", project.NeutralLanguageCode);
													pattern = pattern.Replace(@"[extension]", resxFile.FileInformation.FileGroup.BaseExtension);
													pattern = pattern.Replace(@"[optionaldefaulttypes]",
													                          resxFile.FileInformation.FileGroup.BaseOptionalDefaultType);

													//has base culture value?
													var baseName = pattern;

													// 2011-01-26, Uwe Keim:
													var file = resxFile;
													var baseResxFile =
														_resxFiles.Find(
															resx =>
															resx.FilePath.Name == baseName &&
															resx.FileInformation.FileGroup.UniqueID ==
															file.FileInformation.FileGroup.UniqueID);
													if (baseResxFile == null ||
													    baseResxFile.Document == null ||
													    baseResxFile.Document.DocumentElement == null)
													{
														continue;
													}

													var baseNode =
														baseResxFile.Document.DocumentElement.
															SelectSingleNode(xpathQuery);
													if (null == baseNode)
													{
														continue;
													}
													//ok we can add it.
												}
												//TODO: use default instead

												//Create the new Node
												XmlNode newData = document.CreateElement(@"data");
												var newName = document.CreateAttribute(@"name");
												var newSpace = document.CreateAttribute(@"xml:space");
												XmlNode newValue = document.CreateElement(@"value");

												// Set the Values
												newName.Value = (string)row[@"Name"];
												newSpace.Value = @"preserve";
												newValue.InnerText = textToSet;

												// Get them together
												if (newData.Attributes != null)
												{
													newData.Attributes.Append(newName);
													newData.Attributes.Append(newSpace);
												}
												newData.AppendChild(newValue);

												// AJ CHANGE
												// Only write the comment to the main resx file
												if (commentsAreVisible && index == 0)
												{
													XmlNode newComment = document.CreateElement(@"comment");
													newComment.InnerText = commentToSet ?? string.Empty;
													newData.AppendChild(newComment);
												}

												XmlNode root = document.DocumentElement;
												if (root != null)
												{
													root.InsertAfter(newData, root.LastChild);
												}
											}
										}
									}
								}
							}
						}
					}
				}
				finally
				{
					index++;
				}
			}

			if (wantBackupFiles)
			{
				backupFiles();
			}

			// Store files back to filesystem
			storeFiles();
		}
		// ------------------------------------------------------------------
		#endregion

		#region Public methods and properties.
		// ------------------------------------------------------------------

		public LanguageCodeDetection(
			Project project)
		{
			_project = project;
		}
예제 #14
0
 public AdminItem(Project project)
 {
     Summary = project.Name;
     AdminType = AdminFilters.AdminType.Project;
     Id = project.Id;
 }
예제 #15
0
		/// <summary>
		/// Stores the changes made in the grid back to the .RESX files
		/// </summary>
		public void SaveDataTableToResxFiles(
			Project project,
			DataTable table)
		{
			var createBackups = project != null && project.CreateBackupFiles;
			var omitEmptyStrings = project != null && project.OmitEmptyItems;

			SaveDataTableToResxFiles(project, table, createBackups, omitEmptyStrings);
		}
예제 #16
0
		/// <summary>
		/// Creates the data source for the grid as "<see cref="DataTable"/>".
		/// </summary>
		public DataTable GetDataTableFromResxFiles(
			Project project)
		{
			return GetDataTableFromResxFiles(project, false);
		}
		public static void GetTranslationAppID(
			Project project,
			out string appID,
			out string appID2)
		{
			if (!_translationAppIDSet)
			{
				if (project != null)
				{
					var uid = project.TranslationEngineUniqueInternalName;
					if (!StringExtensionMethods.IsNullOrWhiteSpace(uid))
					{
						var ids = project.TranslationAppIDs;
						if (ids != null)
						{
							foreach (var key in project.TranslationAppIDs.Keys)
							{
								if (key != null && key == uid)
								{
									_translationAppIDSet = true;
									_translationAppID = safeGetValue(project.TranslationAppIDs, key);
									_translationAppID2 = safeGetValue(project.TranslationAppIDs, key + @"-2");

									appID = _translationAppID;
									appID2 = _translationAppID2;
									return;
								}
							}
						}
					}
				}
			}

			appID = _translationAppID;
			appID2 = _translationAppID2;
		}
예제 #18
0
		// AJ CHANGE
		// Checks if the Column Comment is visible in the row
		public static bool CommentsAreVisible(
			Project project,
			DataTable table,
			CommentVisibilityScope commentVisibilityScope)
		{
			if (commentVisibilityScope == CommentVisibilityScope.InMemory || GetShowCommentColumn(project))
			{
				var colName = table.Columns[table.Columns.Count - 1].ColumnName;

				// Sometimes the comment column gets the prefix col, depends on the visibility state
				return colName == @"colComment" ||
					   colName == @"Comment" ||
					   colName == @"col" + Resources.SR_ColumnCaption_Comment ||
					   colName == @"col" + Resources.SR_CommandProcessorSend_Process_Comment ||
					   colName == Resources.SR_ColumnCaption_Comment;
			}
			else
			{
				return false;
			}
		}
예제 #19
0
        private void новыйToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (pro.Figures.Count > 0)
              {
            DialogResult dr = MessageBox.Show(@"Сохранить текущий проект?", @"Сохранение", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            if (dr == DialogResult.OK)
            {
              сохранитьПроектToolStripMenuItem_Click(сохранитьПроектToolStripMenuItem, new EventArgs());
            }
            else if (dr == DialogResult.Cancel)
            {
              return;
            }
              }

              pro = new Project();
              mainPictureBox.Invalidate();
        }
		private void doLoadProjectFile(
			ZlpFileInfo projectFilePath)
		{
			closeProject();

			using (new WaitCursor(this, WaitCursorOption.ShortSleep))
			{
				var project = new Project();
				project.Load(projectFilePath);

				// Only assign if successfully loaded.
				Project = project;
				Project.ModifyStateChanged += project_ModifyStateChanged;

				fillFromProject();
				new TreeListViewState(treeView).RestoreState(@"projectsTree");

				// Instruct right pane to load the recent files.
				MainForm.Current.GroupFilesControl.LoadRecentFiles(project);
			}
		}
예제 #21
0
		/// <summary>
		/// Stores the changes made in the grid back to the .RESX files
		/// </summary>
		public void SaveDataTableToResxFiles(
			Project project,
			DataTable table,
			bool backupFiles,
			bool omitEmptyStrings)
		{
			saveTable(project, table, backupFiles, omitEmptyStrings);
		}
        private static FileGroup getFileGroupForCheckSum(
            Project project,
            long checkSum)
        {
            // ReSharper disable LoopCanBeConvertedToQuery
            foreach (var fileGroup in project.FileGroups)
            // ReSharper restore LoopCanBeConvertedToQuery
            {
                if (fileGroup.GetChecksum(project) == checkSum)
                {
                    return fileGroup;
                }
            }

            return null;
        }
		protected SnapshotControllerBase(
			Project project)
		{
			_project = project;
		}
		public static ITranslationEngine GetTranslationEngine(
			Project project)
		{
			if (_translationEngine == null)
			{
				if (project != null)
				{
					var uid = project.TranslationEngineUniqueInternalName;
					if (!StringExtensionMethods.IsNullOrWhiteSpace(uid))
					{
						foreach (var engine in Engines)
						{
							if (string.Compare(uid, engine.UniqueInternalName, StringComparison.OrdinalIgnoreCase) == 0)
							{
								_translationEngine = engine;
								return engine;
							}
						}
					}
				}

				foreach (var engine in Engines)
				{
					if (engine.IsDefault)
					{
						_translationEngine = engine;
						return engine;
					}
				}

				throw new Exception();
			}

			return _translationEngine;
		}
예제 #25
0
		public DataTable GetDataTableFromResxFiles(
			Project project,
			bool forceCommentColumn)
		{
			return getTable(project, forceCommentColumn);
		}
예제 #26
0
        private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog1.InitialDirectory = Application.StartupPath + @"\Projects";

              if (pro.Figures.Count > 0)
              {
            DialogResult dr = MessageBox.Show(@"Сохранить текущий проект?", @"Сохранение", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            if (dr == DialogResult.Yes)
            {
              сохранитьПроектToolStripMenuItem_Click(сохранитьПроектToolStripMenuItem, new EventArgs());
            }
            else if (dr == DialogResult.Cancel)
            {
              return;
            }
              }

              if (openFileDialog1.ShowDialog() == DialogResult.OK)
              {
            FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open);
            BinaryFormatter bf = new BinaryFormatter();
            pro = (Project)bf.Deserialize(fs);
            mainPictureBox.Invalidate();
              }
        }
예제 #27
0
		public static bool GetShowCommentColumn(Project project)
		{
			return project != null && project.ShowCommentsColumnInGrid;
		}