public ActionResult AddProject(string ID) { ProjectViewModel objEmpViewMod = new ProjectViewModel(); if (ID != null) { Project aProject = new Project(); cProject aobPro = cProject.Get_ID(Convert.ToInt32(ID)); objEmpViewMod.hdnProjectID = aobPro.iID.ToString(); aProject.ProjectName = aobPro.sProjectName; aProject.Description = aobPro.sDescription; aProject.StartDate = aobPro.dtStartDate.ToString("dd/MM/yyyy"); aProject.EndDate = aobPro.dtEndDate.ToString("dd/MM/yyyy"); ViewBag.status = aobPro.objStatus.iObjectID; ViewBag.InternalHead = aobPro.iInternalHead; ViewBag.ExternalHead = aobPro.objExternalProjectHead.iObjectID; ViewBag.ClientID = aobPro.objClient.iObjectID; objEmpViewMod.objProject = aProject; } try { objEmpViewMod.ClientList = getIClientList(); objEmpViewMod.ExternalHeadList = getExternalHeadList(); objEmpViewMod.Internalheadlist = getInternalHeadList(); objEmpViewMod.StatusList = getStatusList(); return(View(objEmpViewMod)); } catch (Exception ex) { throw ex; } }
public static DatFileDesc ParseDatFileWithErrorsReturn(FileInfo path, string pass, ref List<gfErrors> errors, cProject cp = null) { if (!path.Exists) return null; errors = new List<gfErrors>(); string text = functions.DatFileToPlainText(path.FullName, pass); return ParseTextWithErrorsReturn(text, path.FullName, ref errors, cp); }
/// <summary> /// Finds and return cProject objects matching the specified criteria /// </summary> /// <param name="i_oFilter">Filter criteria (WHERE clause)</param> /// <returns>cProject objects</returns> public static List <cProject> Find(cFilter i_oFilter) { DataTable dt = Find_DataTable(i_oFilter, null); List <cProject> l = new List <cProject>(); cProject oObj; for (int i = 0; i < dt.Rows.Count; i++) { oObj = new cProject(); oObj.m_iID = Convert.ToInt32(dt.Rows[i]["iID"]); oObj.m_sName = dt.Rows[i]["sName"].ToString(); oObj.m_dtCreatedOn = Convert.ToDateTime(dt.Rows[i]["dtCreatedOn"]); oObj.m_dtLastUpdatedOn = Convert.ToDateTime(dt.Rows[i]["dtLastUpdatedOn"]); oObj.m_sProjectName = Convert.ToString(dt.Rows[i]["sProjectName"]); oObj.m_objClient.iObjectID = Convert.ToInt32(dt.Rows[i]["objClient"].ToString()); oObj.m_objExternalProjectHead.iObjectID = Convert.ToInt32(dt.Rows[i]["objExternalProjectHead"].ToString()); oObj.m_iInternalHead = Convert.ToInt32(dt.Rows[i]["iInternalHead"]); oObj.m_sDescription = Convert.ToString(dt.Rows[i]["sDescription"]); oObj.m_dtStartDate = Convert.ToDateTime(dt.Rows[i]["dtStartDate"]); oObj.m_dtEndDate = Convert.ToDateTime(dt.Rows[i]["dtEndDate"]); oObj.m_objStatus.iObjectID = Convert.ToInt32(dt.Rows[i]["objStatus"].ToString()); oObj.m_sCompletion = Convert.ToString(dt.Rows[i]["sCompletion"]); oObj.m_bIsActive = Convert.ToBoolean(dt.Rows[i]["bIsActive"]); oObj.m_bInvalid = false; l.Add(oObj); } return(l); }
/// <summary> /// Creates a cProject object. It will be saved in permanent storage only /// on calling Save() /// </summary> /// <returns>cProject object</returns> public static cProject Create() { cProject oObj = new cProject(); SecurityCheck((int)enProject_Action.Create); // Create an object in memory, will be saved to storage on calling Save() oObj.m_bCreating = true; oObj.m_bInvalid = false; return(oObj); }
/// <summary> /// Ensures that an object with the specified name exists, while creating other properties are set to their default values /// </summary> /// <param name="i_sName">Name</param> /// <returns>cProject object</returns> public static cProject CreateIfRequiredAndGet(string i_sName) { cProject oObj = cProject.Get_Name(i_sName); if (oObj == null) { oObj = cProject.Create(); oObj.sName = i_sName; oObj.Save(); } return(oObj); }
public JsonResult AddProject(ProjectViewModel objprojectviewmodel) { try { if (objprojectviewmodel.SelectedClient[0] == "" || objprojectviewmodel.SelectedInternalHead[0] == "" || objprojectviewmodel.SelectedExternalHead[0] == "") { return(Json("2")); } else { if (objprojectviewmodel.hdnProjectID != null && objprojectviewmodel.hdnProjectID != "") { cProject objproject = cProject.Get_ID(Convert.ToInt32(objprojectviewmodel.hdnProjectID)); objproject.sProjectName = objprojectviewmodel.objProject.ProjectName; string ClientId = objprojectviewmodel.SelectedClient[0].ToString(); objproject.objClient.iObjectID = Convert.ToInt32(ClientId); string interHeadID = objprojectviewmodel.SelectedInternalHead[0].ToString(); objproject.iInternalHead = Convert.ToInt32(interHeadID); string iStatus = objprojectviewmodel.SelectedStatus[0].ToString(); objproject.objStatus.iObjectID = Convert.ToInt32(iStatus); string iExternalHeadID = objprojectviewmodel.SelectedExternalHead[0].ToString(); objproject.objExternalProjectHead.iObjectID = Convert.ToInt32(iExternalHeadID); objproject.sDescription = objprojectviewmodel.objProject.Description; objproject.dtStartDate = Convert.ToDateTime(objprojectviewmodel.objProject.StartDate); objproject.dtEndDate = Convert.ToDateTime(objprojectviewmodel.objProject.EndDate); //objproject.sCompletion = objprojectviewmodel.Complition; objproject.Save(); return(Json("3")); } else { cProject objproject = cProject.Create(); objproject.sProjectName = objprojectviewmodel.objProject.ProjectName; string ClientId = objprojectviewmodel.SelectedClient[0].ToString(); objproject.objClient.iObjectID = Convert.ToInt32(ClientId); string interHeadID = objprojectviewmodel.SelectedInternalHead[0].ToString(); objproject.iInternalHead = Convert.ToInt32(interHeadID); string iStatus = objprojectviewmodel.SelectedStatus[0].ToString(); objproject.objStatus.iObjectID = Convert.ToInt32(iStatus); string iExternalHeadID = objprojectviewmodel.SelectedExternalHead[0].ToString(); objproject.objExternalProjectHead.iObjectID = Convert.ToInt32(iExternalHeadID); objproject.dtStartDate = Convert.ToDateTime(objprojectviewmodel.objProject.StartDate); objproject.dtEndDate = Convert.ToDateTime(objprojectviewmodel.objProject.EndDate); objproject.sDescription = objprojectviewmodel.objProject.Description; //objproject.sCompletion = objprojectviewmodel.Complition; objproject.Save(); return(Json("1")); } } } catch (Exception ex) { throw ex; } }
public static DatFileDesc ParseTextWithErrorsReturn(string text, string path, ref List<gfErrors> errors, cProject cp = null) { DatFileDesc result = null; try { Stopwatch sw = new Stopwatch(); sw.Start(); if (text.Trim().Length == 0) return null; result = new DatFileDesc() { header = new Header(), frames = new List<FrameInfo>(), regions = new List<RegionInfo>() }; errors = new List<gfErrors>(); StringReader sr = new StringReader(text); string line; int nline = 0; string oTag = ""; string cTag = ""; RegionInfo cri = null; WeaponStrListInfoEntry wsl = null; bool isRegion = false; bool isRegionend = false; while ((line = sr.ReadLine()) != null) { nline++; line = line.Trim(); if (line.Length == 0) continue; //--------------------------------------------------------------------------------------------------------------------------------- if (line.Contains("#region")) { cri = new RegionInfo(); isRegion = true; oTag = "#region"; string[] astr = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (astr.Length > 1) cri.caption = astr[1]; cri.oline = nline; result.regions.Add(cri); // continue; } if (line.Contains("#endregion")) { cTag = "#endregion"; if (oTag != "#region") errors.Add(new gfErrors("Closing tag #endregion found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; cri.cline = nline; continue; } if (line == "<bmp_begin>") { result.header.foldcaption = line; result.header.oline = nline; oTag = "<bmp_begin>"; continue; } if (line == "<weapon_strength_list>") { result.wsl_oline = nline; if (cTag != "<bmp_end>") errors.Add(new gfErrors("Closing tag <bmp_end> expected", nline, path, Utils.Project.GetNameProject(cp))); oTag = "<weapon_strength_list>"; continue; } if (line.Contains("<frame>") || line == "<frame_end>") { if (oTag == "<bmp_begin>") errors.Add(new gfErrors("Closing tag <bmp_end> expected", nline, path, Utils.Project.GetNameProject(cp))); if (oTag == "<weapon_strength_list>") errors.Add(new gfErrors("Closing tag <weapon_strength_list_end> expected", nline, path, Utils.Project.GetNameProject(cp))); oTag = "frame"; break; } //--------------------------------------------------------------------------------------------------------------------------------- if (line == "<bmp_end>") { if (result.header.cline==-1) result.header.cline = nline; cTag = "<bmp_end>"; if (oTag != "<bmp_begin>" && oTag != "#region") errors.Add(new gfErrors("Closing tag <bmp_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "<weapon_strength_list_end>") { result.wsl_cline = nline; cTag = "<weapon_strength_list_end>"; if (oTag != "<weapon_strength_list>") errors.Add(new gfErrors("Closing tag <weapon_strength_list_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); if (oTag == "<bmp_begin>") errors.Add(new gfErrors("Closing tag <bmp_end> expected", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; break; } //----------------------------------------Parsing----------------------------------------------------------------------------------------- if (oTag == "<bmp_begin>") { #region Parse bmp_begin if (line.Contains("file")) { FileDesc fd = new FileDesc(); string st = GetTextBetweenBraces(line); string[] s2 = st.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries); if (s2.Length > 1) { try { fd.firstFrame = Convert.ToInt32(s2[0]); fd.lastFrame = Convert.ToInt32(s2[1]); } catch { } } List<PropDesc> pd = GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag); if (pd.Count > 0) fd.path = pd[0].value; for (int i = 1; i < pd.Count; i++) { try { switch (pd[i].name) { case "w:": fd.width = Convert.ToInt32(pd[i].value); break; case "h:": fd.height = Convert.ToInt32(pd[i].value); break; case "row:": fd.col = Convert.ToInt32(pd[i].value); break; case "col:": fd.row = Convert.ToInt32(pd[i].value); break; } } catch { } } result.header.files.Add(fd); } else { PropDesc pd = GetProperty(line); result.header.properties.Add(pd); if (pd.name != null && pd.value != null) { if (!pd.name.Contains("sound") && !pd.name.Contains("file") && pd.name != "name:" && pd.name != "head:" && pd.name != "small:") { if (!isStringConsistsDigits(pd.value)) errors.Add(new gfErrors("Number value expected", nline, path, Utils.Project.GetNameProject(cp))); } } } #endregion continue; } if (oTag == "<weapon_strength_list>") { #region Parse weapon_strength_list block if (line.Contains("entry:")) { wsl = new WeaponStrListInfoEntry(); string[] st3 = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); wsl.number = Convert.ToInt32(st3[1]); } else { if (wsl != null) { wsl.props.AddRange(GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag)); result.wsl.Add(wsl); } } #endregion continue; } //--------------------------------------End parsing----------------------------------------------------------------------------------------- if (line == "<bmp_end>") { if (oTag != "<bmp_begin>") errors.Add(new gfErrors("Closing tag <bmp_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "<weapon_strength_list_end>") { if (oTag != "<weapon_strength_list>") errors.Add(new gfErrors("Closing tag <weapon_strength_list_end> found, but where opening tag?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } } if (line == null) return result; //---------------------------------------End parsing frame_begin and weapon list------------------------------------------------------------------------------------------ if (result.header.files.Count > 0) { firstPic = result.header.files[0].firstFrame; lastPic = result.header.files[0].lastFrame; for (int i = 1; i < result.header.files.Count; i++) { if (result.header.files[i].firstFrame < firstPic) firstPic = result.header.files[i].firstFrame; if (result.header.files[i].lastFrame > lastPic) lastPic = result.header.files[i].lastFrame; } } /////////////////////////////// bool isFrame = false; bool isFrameend = false; FrameInfo cfi = null; /* bool isBpoint = false; bool isBpointend = false; bool isCpoint = false; bool isCpointend = false; bool isWpoint = false; bool isWpointend = false; bool isOpoint = false; bool isOpointend = false; bool isBdy = false; bool isBdyend = false; bool isItr = false; bool isItrend = false;*/ //FrameInfo prev = new FrameInfo(); nline--; do { nline++; line = line.Trim(); if (line.Length == 0) continue; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (line.Contains("#region") || line.Contains("<frame>") || line == "bpoint:" || line == "wpoint:" || line == "cpoint:" || line == "opoint:" || line == "bdy:" || line == "itr:" || line == "<frame_end>") { if (oTag == "bpoint:") if (cTag != "bpoint_end:") { cfi.lnst.cl_bpoint = nline - 1; errors.Add(new gfErrors("Closing tag \"bpoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "wpoint:") if (cTag != "wpoint_end:") { cfi.lnst.cl_wpoint = nline - 1; errors.Add(new gfErrors("Closing tag \"wpoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "cpoint:") if (cTag != "cpoint_end:") { cfi.lnst.cl_cpoint = nline - 1; errors.Add(new gfErrors("Closing tag \"cpoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "opoint:") if (cTag != "opoint_end:") { cfi.lnst.cl_opoint = nline - 1; errors.Add(new gfErrors("Closing tag \"opoint_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "bdy:") if (cTag != "bdy_end:") { cfi.lnst.cl_bdy.Add(nline - 1); errors.Add(new gfErrors("Closing tag \"bdy_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } if (oTag == "itr:") if (cTag != "itr_end:") { cfi.lnst.cl_itr.Add(nline - 1); errors.Add(new gfErrors("Closing tag \"itr_end:\" expected", nline, path, Utils.Project.GetNameProject(cp))); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (line.Contains("#region")) { if (isRegion && !isRegionend) errors.Add(new gfErrors("Closing tag #endregion expected", nline, path, Utils.Project.GetNameProject(cp))); isRegion = true; isRegionend = false; oTag = "#region"; // if (cri != null) // result.regions.Add(cri); cri = new RegionInfo(); string[] astr = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (astr.Length > 1) cri.caption = astr[1]; cri.oline = nline; result.regions.Add(cri); continue; } if (line.Contains("<frame>")) { if (line.Contains("dummy")) { } if (isFrame == true && isFrameend == false) { cfi.cline = nline - 1; errors.Add(new gfErrors("Closing tag <frame_end> expected", nline, path, Utils.Project.GetNameProject(cp))); } isFrame = true; isFrameend = false; oTag = "<frame>"; if (cfi != null) { //prev = cfi; result.frames.Add(cfi); } cfi = new FrameInfo(); string[] astr = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (astr.Length > 1) try { cfi.number = Convert.ToInt32(astr[1]); } catch { cfi.number = -1; } //////////////// for (int i = 0; i < result.frames.Count; i++) { if (cfi.number == result.frames[i].number) { errors.Add(new gfErrors("Frame with this number value already exists", nline, path, Utils.Project.GetNameProject(cp))); break; } } //if (cfi.number < prev.number) // errors.Add(new gfErrors("Frame number value must be greater than number value in previous frames", nline, path, Utils.Project.GetNameProject(cp))); //////////////// if (astr.Length > 2) cfi.caption = astr[2]; else cfi.number = null; cfi.oline = nline; cfi.foldcaption = line; continue; } if (line == "bpoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "bpoint:"; cfi.lnst.ol_bpoint = nline; continue; } if (line == "wpoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "wpoint:"; cfi.lnst.ol_wpoint = nline; continue; } if (line == "bdy:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "bdy:"; cfi.lnst.ol_bdy.Add(nline); cfi.bdy.Add(new List<PropDesc>()); continue; } if (line == "itr:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "itr:"; cfi.lnst.ol_itr.Add(nline); cfi.itr.Add(new List<PropDesc>()); continue; } if (line == "cpoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "cpoint:"; cfi.lnst.ol_cpoint = nline; continue; } if (line == "opoint:") { if (oTag == "<frame>") cfi.lastheaderline = nline - 1; oTag = "opoint:"; cfi.lnst.ol_opoint = nline; continue; } ////////////////////////////////////////////////////////// #region Check errors (if open tag miss) if (line == "#endregion") { if (isRegion == false) errors.Add(new gfErrors("Found #endregion tag but where opening tag #region?", nline, path, Utils.Project.GetNameProject(cp))); isRegionend = true; oTag = ""; if (isRegion == true && isRegion == true) isRegion = false; if (cri != null) cri.cline = nline; continue; } if (line == "<frame_end>") { if (cfi.lastheaderline==-1) cfi.lastheaderline = nline - 1; if (isFrame == false) errors.Add(new gfErrors("Found <frame_end> tag but where opening tag <frame>?", nline, path, Utils.Project.GetNameProject(cp))); isFrameend = true; oTag = ""; if (isFrame == true && isFrameend == true) isFrame = false; if (cfi != null) cfi.cline = nline; // continue; } if (line == "bpoint_end:") { cfi.lnst.cl_bpoint = nline; if (oTag != "bpoint:") errors.Add(new gfErrors("Found \"bpoint_end:\" tag but where opening tag \"bpoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); //isBpoint = true; //oTag = ""; cTag = "bpoint_end:"; continue; } if (line == "wpoint_end:") { cfi.lnst.cl_wpoint = nline; if (oTag != "wpoint:") errors.Add(new gfErrors("Found \"wpoint_end:\" tag but where opening tag \"wpoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "bdy_end:") { cfi.lnst.cl_bdy.Add(nline); if (oTag != "bdy:") errors.Add(new gfErrors("Found \"bdy_end:\" tag but where opening tag \"bdy:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "itr_end:") { cfi.lnst.cl_itr.Add(nline); if (oTag != "itr:") errors.Add(new gfErrors("Found \"itr_end:\" tag but where opening tag \"itr:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "cpoint_end:") { cfi.lnst.cl_cpoint = nline; if (oTag != "cpoint:") errors.Add(new gfErrors("Found \"cpoint_end:\" tag but where opening tag \"cpoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } if (line == "opoint_end:") { cfi.lnst.cl_opoint = nline; if (oTag != "opoint:") errors.Add(new gfErrors("Found \"opoint_end:\" tag but where opening tag \"opoint:\"?", nline, path, Utils.Project.GetNameProject(cp))); oTag = ""; continue; } #endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (oTag == "<frame>") { if (cfi.firstheaderline == -1) cfi.firstheaderline = nline; cfi.header.AddRange(GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag)); continue; } if (oTag == "bpoint:" && cfi != null) { cfi.bpoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "wpoint:" && cfi != null) { cfi.wpoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "bdy:" && cfi != null) { cfi.bdy[cfi.bdy.Count - 1].AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "itr:" && cfi != null) { cfi.itr[cfi.itr.Count - 1].AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "cpoint:" && cfi != null) { cfi.cpoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } if (oTag == "opoint:" && cfi != null) { cfi.opoint.AddRange((GetPropertiesFromString(line, ref errors, nline, path, Utils.Project.GetNameProject(cp), oTag))); continue; } } while ((line = sr.ReadLine()) != null); if (isRegion == true && isRegionend == false) errors.Add(new gfErrors("Closing tag #endregion expected", nline, path, Utils.Project.GetNameProject(cp))); if (isFrame == true && isFrameend == false) errors.Add(new gfErrors("Closing tag <frame_end> expected", nline, path, Utils.Project.GetNameProject(cp))); sw.Stop(); result.frames.Add(cfi); // G.mainWindow.teOutput.AppendText // ("ParseDatFileFromString-время прошло: " + sw.ElapsedMilliseconds + " миллисекунд" + Environment.NewLine); // G.mainWindow.teOutput.ScrollToEnd(); } catch (Exception ex) { new wException(ex).ShowDialog(); } return result; }
public static string GetNameProject(cProject cp) { if (cp == null) return "no project"; return (cp.files[0] as ArrayList)[0] as string; }
using System;