public ActionResult ViewMashov(string file_number, string form_ver) { // get the user UserData user = (UserData)this.Session["user"]; if (user.Type.ToLower() == "momhee") { // check if the momhee has excess to this request if (!RequestManager.Manager.IsRequestAllowedForMomhee(user.Id, file_number)) { return(RedirectToAction("RequestsManage", "AdminGovExp")); } } // load the mashov var dataFile = Server.MapPath("~/App_Data/Mashovs/mashov_" + file_number + ".json"); string json = System.IO.File.ReadAllText(@dataFile); Dictionary <string, string> values = FormValues.LoadJson(json).Values; // load the form of the mashov var mashovFile = Server.MapPath("~/App_Data/Forms/MashovForm_v_" + form_ver + ".xml"); PostedForm pR = new PostedForm(FormManager.Manager.Load(mashovFile).FormComponents[0], values); // load extra data of the request string where = "file_number='" + file_number + "'"; ViewData["request"] = RequestManager.Manager.GetAllWhere(where, null, 1, 1)[0]; ViewData["names"] = RequestManager.Manager.GetAllColNames(); return(View(pR)); }
/// <summary> /// Creates a Web Enquiry record based on the <see cref="PostedForm"/>. /// </summary> /// <param name="context"></param> protected override void ExecuteActivity(CodeActivityContext context) { // Get and check entity reference EntityReference postedForm = PostedForm.Get(context); if (postedForm == null) { throw new InvalidOperationException("Posted Form has not been specified", new ArgumentNullException("Posted Form")); } TracingService.Trace("Posted Form {0}", postedForm); var targetFields = new List <AttributeMetadata>(EnumerateWebEnquiryFields(Service)); var postedFields = new List <KeyValuePair <string, string> >(EnumeratePostedFields(Service, postedForm.Id)); Entity webEnquiry = new Entity(WebEnquiryName); foreach (var postedField in postedFields) { var targetField = targetFields.Find(a => a.LogicalName == postedField.Key); if (targetField != null) { if (targetField.AttributeType.HasValue) { var targetValue = ConvertValue(postedField.Value, targetField.AttributeType.Value); if (targetValue != null) { TracingService.Trace("Setting value {0}", targetValue); webEnquiry[targetField.LogicalName] = targetValue; } } } } // add other things var postedFormEntity = Service.Retrieve(postedForm.LogicalName, postedForm.Id, new ColumnSet(new string[] { "cdi_contactid" })); webEnquiry["ace_senderid"] = postedFormEntity["cdi_contactid"]; webEnquiry["senton"] = DateTime.Now; // go on and create it TracingService.Trace("Creating web enquiry..."); Guid id = Service.Create(webEnquiry); TracingService.Trace("Web Enquiry created ({0})", id); WebEnquiry.Set(context, new EntityReference(WebEnquiryName, id)); }