public ActionResult GetApplication(string application)
        {
            if (Session["key"] != null)
            {
                dynamic param = new ExpandoObject();
                param.application_id = application;
                param.access_key     = Session["key"].ToString();
                param.mode           = "preview";

                var client = new HttpClient();
                client.BaseAddress = new Uri("http://server-erp2.sma.gov.jm:1786/api/data/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var content = new StringContent(JsonConvert.SerializeObject(param), Encoding.UTF8, "application/json");
                HttpResponseMessage response = client.PostAsync("GetApplication", content).Result;
                if (response.IsSuccessStatusCode)
                {
                    string      result = response.Content.ReadAsStringAsync().Result;
                    Models.Form form   = JsonConvert.DeserializeObject <Models.Form>(result);

                    return(Json(new { form }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { responseText = "unavailable" }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                return(Json(new { responseText = "session_invalid" }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #2
0
        public static Models.Form Create(string name, double totalCost)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = SessionManager.Get(SessionManager.Keys.FullName).ToString() + " , " + DateTime.Now.ToString();
            }
            ExpenseEntities db = new ExpenseEntities();

            Models.Form form = new Models.Form();
            form.Id          = Guid.NewGuid();
            form.Date        = DateTime.Now;
            form.Description = SessionManager.Get(SessionManager.Keys.FullName).ToString() + " Adlı kullanıcının" + DateTime.Now.ToString() + "Tarihli Formu";
            form.Name        = name;
            form.OwnerId     = Guid.Parse((SessionManager.Get(SessionManager.Keys.UserId).ToString()));
            State state = (State)db.States.Where(s => s.Name == "Pending").FirstOrDefault();

            form.StateId = state.Id;
            form.Total   = (int)totalCost;
            db.Forms.Add(form);
            db.SaveChanges();



            return(form);
        }
Beispiel #3
0
        public async Task <IActionResult> PostEvent([FromBody] Models.Form @form)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Forms.Add(@form);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (FormExists(@form.FormId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetForm", new { id = @form.FormId }, @form));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Type,Name,Label,Description,DateCreate,DateUpdate")] Models.Form form)
        {
            if (id != form.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    form.Type = 1;
                    _context.Update(form);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FormExists(form.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(form));
        }
Beispiel #5
0
        public async Task <IActionResult> PutForm([FromRoute] int id, [FromBody] Models.Form @form)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != @form.FormId)
            {
                return(BadRequest());
            }

            _context.Entry(@form).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FormExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #6
0
        public ActionResult FormDetails(int ID)
        {
            db = new Models.ProjeEntities1();

            Models.Form form = db.Forms.Where(x => x.userId == ID).FirstOrDefault();

            return(View(form));
        }
        public async Task <IActionResult> Create([Bind("Name,Description")] Models.Form form)
        {
            if (ModelState.IsValid)
            {
                form.DateCreate = DateTime.Now;
                _context.Add(form);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Fields), new { id = form.Id }));
            }
            return(View(form));
        }
        public string AddForm([FromBody] Models.Form form)
        {
            if (ModelState.IsValid)
            {
                if (form.Name == form.Password)
                {
                    ModelState.AddModelError("", "name and password do not coincide");
                }
            }

            return("success");
        }
        public IActionResult Result(string Name, string Locations, string Languages, string Comments)
        {
            Models.Form info = new Models.Form(Name, Locations, Languages, Comments);
            TryValidateModel(info);

            if (ModelState.IsValid)
            {
                return(View("results", info));
            }
            else
            {
                return(View("index"));
            }
        }
Beispiel #10
0
        public ActionResult Save(FormCollection form)
        {
            List <string> names, dates, descriptions, costs;

            //Get values
            names        = new List <string>(form.GetValues("name[]"));
            dates        = new List <string>(form.GetValues("date[]"));
            descriptions = new List <string>(form.GetValues("description[]"));
            costs        = new List <string>(form.GetValues("cost[]"));

            string formName = string.Empty;

            //Create new form

            if (!string.IsNullOrEmpty(form["formName"]))
            {
                formName = form["formName"];
            }

            // TODO: validation
            double totalCost = costs.Sum(c => double.Parse(c));

            Models.Form newForm = new Models.Form();
            newForm = FormHelper.Create(formName, totalCost);



            using (ExpenseEntities db = new ExpenseEntities())
            {
                Models.Expense expense;
                for (int i = 0; i < names.Count; i++)
                {
                    expense             = new Models.Expense();
                    expense.Id          = Guid.NewGuid();
                    expense.Name        = names[i];
                    expense.Date        = DateTime.Parse(dates[i]);
                    expense.Description = descriptions[i];
                    expense.Cost        = int.Parse(costs[i]);
                    expense.FormId      = newForm.Id;
                    expense.StateId     = newForm.StateId;
                    db.Expenses.Add(expense);
                }

                db.SaveChanges();
            }



            return(RedirectToAction("New", "Expense"));
        }
        public IActionResult Create(Models.Form form)
        {
            if (form.Name == form.Password)
            {
                ModelState.AddModelError("", "name and password do not coincide");
            }

            if (ModelState.IsValid)
            {
                return(Content($"{form.Name} - {form.Email}"));
            }

            return(View(form));
        }
        public ActionResult CreateForm(String[] jsonData)
        {
            string[] list        = jsonData[4].Split(',');
            int[]    positionIds = new int[list.Length];

            for (int i = 0; i < list.Length; i++)
            {
                positionIds[i] = Convert.ToInt32(list[i]);
            }

            Form form = new Models.Form
            {
                Name     = jsonData[0],
                Status   = Models.Form.FormStatus.Template,
                FormData = jsonData[2]
            };

            _db.form.Add(form);
            _db.SaveChanges();


            Workflow workFlow = new Models.Workflow
            {
                FormId = form.Id
            };

            List <Positions> positions = new List <Positions>();

            for (int i = 0; i < positionIds.Length; i++)
            {
                positions.Add(_db.position.Find(positionIds[i]));
            }

            workFlow.Positions = positions;

            _db.flow.Add(workFlow);
            _db.SaveChanges();


            form.WorkflowId = workFlow.FlowId;

            _db.SaveChanges();

            return(View());
        }
        protected override void Save()
        {
            Models.Form f = new Models.Form();
            f.Lp               = Int32.Parse(txtLp.Text);
            f.Info             = txtInfo.Text;
            f.FormStatusId     = Int32.Parse(comboStatus.SelectedValue.ToString());
            f.SeniorId         = Int32.Parse(comboSenior.SelectedValue.ToString());
            f.WorkerId         = Int32.Parse(comboWorker.SelectedValue.ToString());
            f.RegistrationDate = new DateTime(dtRegistDate.Value.Year, dtRegistDate.Value.Month, dtRegistDate.Value.Day);
            f.RepairDate       = new DateTime(dtRepairDate.Value.Year, dtRepairDate.Value.Month, dtRepairDate.Value.Day);

            GoldenHandContext.Instance.Forms.Add(f);
            GoldenHandContext.Instance.SaveChanges();
            MessageBox.Show("Dodano formularz.");

            ReloadForms?.Invoke(btnSave, new FormEventArgs(f));
            Close();
        }
Beispiel #14
0
        public ActionResult Approve(Guid id)
        {
            Models.Form     form = new Models.Form();
            ExpenseEntities db   = new ExpenseEntities();

            form = db.Forms.Where(f => f.Id == id).FirstOrDefault();
            State state = db.States.Where(s => s.Name == "Approved").FirstOrDefault();

            form.StateId = state.Id;
            List <Models.Expense> expenses = new List <Models.Expense>();

            expenses = db.Expenses.Where(e => e.FormId == id).ToList();
            foreach (Models.Expense e in expenses)
            {
                e.StateId = state.Id;
            }
            db.SaveChanges();

            return(RedirectToAction("List", "Form"));
        }
        public ActionResult MoreTables(int id)
        {
            var model = new Models.Form()
            {
                Name     = "Name",
                Age      = 22,
                Tel      = 0277468,
                Email    = "*****@*****.**",
                Sex      = true,
                Date     = DateTime.Now,
                Password = "******"
            };

            var items = new List <Models.Form>();

            items.Add(model);


            var result = JsonConvert.SerializeObject(items);

            return(Content(result, "application/json"));
        }
Beispiel #16
0
        public ActionResult Yanitla(int ID)
        {
            db = new Models.ProjeEntities1();
            Models.Form form = db.Forms.Where(x => x.userId == ID).FirstOrDefault();

            try
            {
                WebMail.SmtpServer = "smtp.gmail.com";
                WebMail.EnableSsl  = true;
                WebMail.UserName   = "******";
                WebMail.Password   = "******";
                WebMail.SmtpPort   = 587;
                form.userMessage   = form.yetkiliMessage;

                WebMail.Send(
                    form.userMail,        // alıcının mail adresi
                    "İş Başvurusu Yanıt", //mailin konusu
                    form.userMessage,     //mailin kendisi
                    null,
                    null,
                    null,
                    true,
                    null,
                    null,
                    null,
                    null,
                    null,
                    null
                    );

                return(RedirectToAction("Gönderildi"));
            }
            catch (Exception ex)
            {
                ViewData.ModelState.AddModelError("_HATA", ex.Message);
                return(View("Panel"));
            }
        }
Beispiel #17
0
        public static Models.Form Create(string name, double totalCost)
        {
            if (string.IsNullOrEmpty(name))
            {
                name = SessionManager.Get(SessionManager.Keys.FullName).ToString() + " , " + DateTime.Now.ToString();
            }
            ExpenseEntities db = new ExpenseEntities();
            Models.Form form = new Models.Form();
            form.Id = Guid.NewGuid();
            form.Date = DateTime.Now;
            form.Description = SessionManager.Get(SessionManager.Keys.FullName).ToString() + " Adlı kullanıcının"  + DateTime.Now.ToString() + "Tarihli Formu";
            form.Name = name;
            form.OwnerId = Guid.Parse((SessionManager.Get(SessionManager.Keys.UserId).ToString()));
            State state = (State)db.States.Where(s => s.Name == "Pending").FirstOrDefault();
            form.StateId = state.Id;
            form.Total = (int)totalCost;
            db.Forms.Add(form);
            db.SaveChanges();
          
           

            return form;
        }
Beispiel #18
0
        public static Models.Form UpdateForm(ContentServiceConfiguration settings, Models.Form formToUpdate)
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(settings.BaseUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                client.DefaultRequestHeaders.Add("api-version", "1.0");

                var stringContent = new StringContent(JsonConvert.SerializeObject(formToUpdate),
                                                      Encoding.UTF8,
                                                      "application/json");

                HttpResponseMessage response = client.PutAsync(settings.ResourceRoot + "/forms/" + formToUpdate.FormId.ToString(), stringContent).Result;
                if (response.IsSuccessStatusCode)
                {
                    string stringData = response.Content.ReadAsStringAsync().Result;
                    return(JsonConvert.DeserializeObject <Models.Form>(stringData));
                }
            }

            return(null);
        }
Beispiel #19
0
        public IActionResult G(IFormFile file, string city)
        {
            var fname = Guid.NewGuid().ToString().Replace("-", "") + System.IO.Path.GetExtension(file.GetFileName());
            var path  = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fname);

            file.SaveAs(path);
            string connStr;

            if (System.IO.Path.GetExtension(path) == ".xls")
            {
                connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + ";" + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\"";
            }
            else
            {
                connStr = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + path + ";" + ";Extended Properties=\"Excel 12.0;HDR=NO;IMEX=1\"";
            }
            using (var conn = new OleDbConnection(connStr))
            {
                conn.Open();
                var schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                var rows        = schemaTable.Rows;
                foreach (DataRow r in rows)
                {
                    if (r["TABLE_NAME"].ToString() == "_xlnm#_FilterDatabase")
                    {
                        continue;
                    }
                    var cmd  = new OleDbCommand($"select * from [{r["TABLE_NAME"].ToString()}]", conn);
                    var adpt = new OleDbDataAdapter(cmd);
                    var dt   = new DataTable();
                    adpt.Fill(dt);
                    var text = new List <string>();
                    text.Add(dt.Rows[1][3].ToString());
                    text.Add(dt.Rows[1][8].ToString());
                    text.Add(dt.Rows[2][3].ToString());
                    text.Add(dt.Rows[2][8].ToString());
                    text.Add(dt.Rows[3][3].ToString());
                    text.Add(dt.Rows[3][8].ToString());
                    text.Add(dt.Rows[4][3].ToString());
                    text.Add(dt.Rows[4][8].ToString());
                    text.Add(dt.Rows[5][3].ToString());
                    text.Add(dt.Rows[5][8].ToString());
                    text.Add(dt.Rows[6][3].ToString());
                    text.Add(dt.Rows[6][8].ToString());
                    text.Add(dt.Rows[7][3].ToString());
                    text.Add(dt.Rows[7][8].ToString());
                    text.Add(dt.Rows[8][3].ToString());
                    text.Add(dt.Rows[8][8].ToString());
                    text.Add(dt.Rows[9][3].ToString());
                    text.Add(dt.Rows[9][8].ToString());
                    text.Add(dt.Rows[10][3].ToString());
                    text.Add(dt.Rows[10][8].ToString());
                    var form = new Models.Form
                    {
                        City    = city,
                        Content = JsonConvert.SerializeObject(text),
                        Time    = DateTime.Now,
                        Type    = Models.FormType.疑难站址档案
                    };
                    DB.Forms.Add(form);

                    for (var i = 11; i + 3 < dt.Rows.Count; i += 3)
                    {
                        var text2 = new List <string>();
                        text2.Add(dt.Rows[i][3].ToString());
                        text2.Add(dt.Rows[i][8].ToString());
                        text2.Add(dt.Rows[i + 1][3].ToString());
                        text2.Add(dt.Rows[i + 1][8].ToString());
                        text2.Add(dt.Rows[i + 2][3].ToString());
                        DB.Forms.Add(new Models.Form
                        {
                            City     = city,
                            Time     = DateTime.Now,
                            Type     = Models.FormType.疑难站址档案2,
                            ParentId = form.Id,
                            Content  = JsonConvert.SerializeObject(text2),
                        });
                    }

                    DB.SaveChanges();
                }
            }
            return(RedirectToAction("G", "Form", null));
        }
Beispiel #20
0
        public ActionResult Pay(Guid id)
        {
            Models.Form form = new Models.Form();
            ExpenseEntities db = new ExpenseEntities();
            form = db.Forms.Where(f => f.Id == id).FirstOrDefault();
            State state = db.States.Where(s => s.Name == "Paid").FirstOrDefault();
            form.StateId = state.Id;
            List<Models.Expense> expenses = new List<Models.Expense>();
            expenses = db.Expenses.Where(e => e.FormId == id).ToList();
            foreach (Models.Expense e in expenses)
            {
                e.StateId = state.Id;
            }
            
            db.SaveChanges();

            AddExpenseToCrm(form);

            return RedirectToAction("List", "Form");
        }
Beispiel #21
0
        public static Models.Form GetFormParser(string content, string id)
        {
            var obj = JObject.Parse(content);

            var    result = obj["result"];
            string title  = result["title"].ToString();

            Debug.WriteLine("[Form Parser] - GET - Title: " + title);

            List <MultipleChoiceQuestion> multipleChoiceQuestions = new List <MultipleChoiceQuestion>();
            List <DiscursiveQuestion>     discursiveQuestions     = new List <DiscursiveQuestion>();

            if (result["multipleChoices"] != null)
            {
                JArray multipleChoices = (JArray)result["multipleChoices"];
                Debug.WriteLine("[Form Parser] - GET - Multiple Choices: " + multipleChoices.ToString());

                foreach (JObject question in multipleChoices)
                {
                    string questionTitle   = question["question"].ToString();
                    bool   multipleAnswers = question["multiple_anwsers"].ToObject <bool>();
                    Debug.WriteLine("[Form Parser] - GET - Multiple answers: " + multipleAnswers.ToString());
                    List <Option> optionsList = new List <Option>();

                    JArray options = (JArray)question["options"];
                    foreach (string optionText in options)
                    {
                        Option option = new Option {
                            OptionText = optionText
                        };
                        optionsList.Add(option);
                        Debug.WriteLine("[Form Parser] - GET - Option: " + option.OptionText);
                    }
                    Debug.WriteLine("[Form Parser] - GET - Question Title: " + questionTitle);

                    MultipleChoiceQuestion multipleQuestion = new MultipleChoiceQuestion(questionTitle, multipleAnswers);
                    foreach (Option option in optionsList)
                    {
                        multipleQuestion.Add(option);
                    }

                    multipleChoiceQuestions.Add(multipleQuestion);
                }
            }

            if (result["discussive"] != null)
            {
                JArray discursives = (JArray)result["discussive"];

                foreach (JObject question in discursives)
                {
                    Debug.WriteLine("[Form Parser] - GET - Discursive: " + question);
                    var questionTitle = question["question"].ToString();
                    discursiveQuestions.Add(new DiscursiveQuestion {
                        Question = questionTitle
                    });
                }
            }

            Models.Form newForm = new Models.Form {
                Title = title,
                MultipleChoiceQuestions = multipleChoiceQuestions,
                DiscursiveQuestions     = discursiveQuestions,
                RemoteId = id
            };

            return(newForm);
        }
Beispiel #22
0
 public ActionResult Edit(Models.Form form)
 {
     return(View(form));
 }
        public ActionResult CreateForm(String[] jsonData)
        {
            string[] list = jsonData[4].Split(',');
            int[] positionIds = new int[list.Length];

            for (int i = 0; i < list.Length; i++)
            {
                positionIds[i] = Convert.ToInt32(list[i]); 
            }
            
            Form form = new Models.Form
            {
                Name = jsonData[0],
                Status = Models.Form.FormStatus.Template,
                FormData = jsonData[2]


            };
            _db.form.Add(form);
            _db.SaveChanges();

            
            Workflow workFlow = new Models.Workflow
            {
                FormId = form.Id

            };

            List<Positions> positions = new List<Positions>();

            for(int i = 0; i < positionIds.Length; i++)
            {
                positions.Add(_db.position.Find(positionIds[i]));
            }

            workFlow.Positions = positions;

            _db.flow.Add(workFlow);
            _db.SaveChanges();


            form.WorkflowId = workFlow.FlowId;

            _db.SaveChanges();

            return View();
        }
        public IActionResult G(IFormFile file, string city)
        {
            var fname = Guid.NewGuid().ToString().Replace("-", "") + System.IO.Path.GetExtension(file.GetFileName());
            var path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fname);
            file.SaveAs(path);
            string connStr;
            if (System.IO.Path.GetExtension(path) == ".xls")
                connStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + ";" + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1\"";
            else
                connStr = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + path + ";" + ";Extended Properties=\"Excel 12.0;HDR=NO;IMEX=1\"";
            using (var conn = new OleDbConnection(connStr))
            {
                conn.Open();
                var schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                var rows = schemaTable.Rows;
                foreach (DataRow r in rows)
                {
                    if (r["TABLE_NAME"].ToString() == "_xlnm#_FilterDatabase")
                        continue;
                    var cmd = new OleDbCommand($"select * from [{r["TABLE_NAME"].ToString()}]", conn);
                    var adpt = new OleDbDataAdapter(cmd);
                    var dt = new DataTable();
                    adpt.Fill(dt);
                    var text = new List<string>();
                    text.Add(dt.Rows[1][3].ToString());
                    text.Add(dt.Rows[1][8].ToString());
                    text.Add(dt.Rows[2][3].ToString());
                    text.Add(dt.Rows[2][8].ToString());
                    text.Add(dt.Rows[3][3].ToString());
                    text.Add(dt.Rows[3][8].ToString());
                    text.Add(dt.Rows[4][3].ToString());
                    text.Add(dt.Rows[4][8].ToString());
                    text.Add(dt.Rows[5][3].ToString());
                    text.Add(dt.Rows[5][8].ToString());
                    text.Add(dt.Rows[6][3].ToString());
                    text.Add(dt.Rows[6][8].ToString());
                    text.Add(dt.Rows[7][3].ToString());
                    text.Add(dt.Rows[7][8].ToString());
                    text.Add(dt.Rows[8][3].ToString());
                    text.Add(dt.Rows[8][8].ToString());
                    text.Add(dt.Rows[9][3].ToString());
                    text.Add(dt.Rows[9][8].ToString());
                    text.Add(dt.Rows[10][3].ToString());
                    text.Add(dt.Rows[10][8].ToString());
                    var form = new Models.Form
                    {
                        City = city,
                        Content = JsonConvert.SerializeObject(text),
                        Time = DateTime.Now,
                        Type = Models.FormType.疑难站址档案
                    };
                    DB.Forms.Add(form);

                    for (var i = 11; i + 3 < dt.Rows.Count; i += 3)
                    {
                        var text2 = new List<string>();
                        text2.Add(dt.Rows[i][3].ToString());
                        text2.Add(dt.Rows[i][8].ToString());
                        text2.Add(dt.Rows[i + 1][3].ToString());
                        text2.Add(dt.Rows[i + 1][8].ToString());
                        text2.Add(dt.Rows[i + 2][3].ToString());
                        DB.Forms.Add(new Models.Form
                        {
                            City = city,
                            Time = DateTime.Now,
                            Type = Models.FormType.疑难站址档案2,
                            ParentId = form.Id,
                            Content = JsonConvert.SerializeObject(text2),
                        });
                    }

                    DB.SaveChanges();
                }
            }
            return RedirectToAction("G", "Form", null);
        }
 public string Form(Models.Form form)
 {
     return($"{form.Name}, {form.Age}, {form.Date}, {form.Tel}, {form.Password}, {form.Email}, {form.Sex}");
 }