public void ProcessRequest(HttpContext context)
        {
            string country = context.Request.Params["country"];
            String data = String.Empty;
            List<StateProvince> spList = new List<StateProvince>();

            if ("us".Equals(country))
            {
                StateProvince sp = new StateProvince();
                sp.abbr = "IL";
                spList.Add(sp);
                sp = new StateProvince();
                sp.abbr = "WI";
                spList.Add(sp);
            //                data = "[{'abbr':'IL','name':'Illinois','url':'www2.illinois.gov','population':0},{'abbr':'MI','name':'Michigan','population':0},{'abbr':'IN','name':'Indiana','population':0}]";
            }
            else if ("canada".Equals(country))
            {
                StateProvince sp = new StateProvince();
                sp.abbr = "ON";
                spList.Add(sp);
                sp = new StateProvince();
                sp.abbr = "NF";
                spList.Add(sp);
            //                data = "[{'abbr':'ON','name':'Ontario','population':0},{'abbr':'NF','name':'Newfoundland','population':0}]";
            }

            var serialiser = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = serialiser.Serialize(spList);
            context.Response.Write(json);

            //            context.Response.ContentType = "application/json";
            //            context.Response.Write(data);
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            List<InventoryModel> Equipments = new List<InventoryModel>();
            InventoryModel Eq1 = new InventoryModel
            {
                ID = 1,
                Code = "C0001",
                Category = "Laptop",
                Description = "Powerful. Sleek. Light. Affordable ",
                Name = "Lenovo"
            };

            InventoryModel Eq2 = new InventoryModel
            {
                ID = 2,
                Code = "C0002",
                Category = "Computer",
                Description = " Big! Light! ",
                Name = "Mac Desktop "
            };

            InventoryModel Eq3 = new InventoryModel
            {
                ID = 3,
                Code = "P0003",
                Category = "Printer ",
                Description = " Fast printer, WiFi, copy! ",
                Name = "MNV Printer"
            };

            Equipments.Add(Eq1);
            Equipments.Add(Eq2);
            Equipments.Add(Eq3);

            Application["MyList"] = Equipments;

            List<string> CatList = new List<string>();
            CatList.Add("Printer");
            CatList.Add("Laptop");
            CatList.Add("Computer");

            Application["MyCategoryList"] = CatList;
        }
示例#3
0
        public static List<Buscar> getEquipoCli(String criteria)
        {
            List<Buscar> dBuscar = new List<Buscar>();
            String conSql = System.Configuration.ConfigurationManager.ConnectionStrings["Conexion_DB_Intranet"].ConnectionString;

            using (SqlConnection con = new SqlConnection(conSql))
            {
                con.Open();
                string qry = "SELECT * FROM BUSQUEDA WHERE NRO_DOCUMENTO LIKE '%'+@buscar+'%' OR NOMBRE_DOCUMENTO LIKE '%'+@buscar+'%'";
                SqlCommand cmd = new SqlCommand(qry, con);
                cmd.Parameters.Add(new SqlParameter("buscar", SqlDbType.VarChar)).Value = criteria;
                SqlDataReader read = cmd.ExecuteReader();

                while (read.Read())
                {
                    Buscar dBusca = new Buscar();
                    dBusca.nro_documento = Convert.ToString(read["Nro_Documento"]);
                    dBusca.nombre_documento = Convert.ToString(read["Nombre_Documento"]);
                    dBusca.dir_documento = getDireccion(Convert.ToString(read["Dir_Documento"]));

                    dBuscar.Add(dBusca);
                }
            }

            return dBuscar;
        }
        protected void Application_Start(object sender, EventArgs e)
        {
            List<Customer> custlist = new List<Customer>();

            String Stat = "select * from KannegantiS_WADfl13_Customers ";
            SqlCommand sc = new SqlCommand(Stat, connect);
            try
            {
                connect.Open();

                SqlDataReader sqlReader = sc.ExecuteReader();
                while (sqlReader.Read())
                {
                    Customer c = new Customer();
                    c.EmailAddress = (String)sqlReader["emailAddress"];
                    c.Password = (String)sqlReader["password"];
                    c.FirstName = (String)sqlReader["firstName"];
                    c.LastName = (String)sqlReader["lastName"];
                    c.FullAddress = (String)sqlReader["fullAddress"];
                    c.ContactPhone = (String)sqlReader["contactPhone"];
                    c.Country = sqlReader["country"].ToString();
                    c.OrderDate = sqlReader["orderDate"].ToString();
                    c.NumberofMinutes = sqlReader["numberofMinutes"].ToString();
                    c.DollarAmount = sqlReader["dollaramount"].ToString();
                    c.PaymentMethod = sqlReader["paymentMethod"].ToString();
                    custlist.Add(c);
                }
                Application["CustomerList"] = custlist;
            }

            finally
            {
                connect.Close();
            }
        }
        public static List<Student> GetAllStudent()
        {
            List<Student> listStudent = new List<Student>();
            string cs1 = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString;
            SqlConnection connection = new SqlConnection(cs1);
            connection.Open();
            string qry1 = "select* from student2";
            SqlCommand cmd = new SqlCommand(qry1, connection);
            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                Student student = new Student();
                student.UserName = rdr[0].ToString();
                student.Password = rdr[1].ToString();
                student.ConfirmPassword = rdr[2].ToString();
                student.FirstName = rdr[3].ToString();
                student.LastName = rdr[4].ToString();
                student.Email = rdr[5].ToString();
                student.Phone = rdr[6].ToString();
                student.Location = rdr[7].ToString();

                listStudent.Add(student);
            }
            connection.Close();
            return listStudent;
        }
示例#6
0
 public void AddNewTag(string tagName, string tagUrlSeo)
 {
     List<int> numlist = new List<int>();
     int num = 0;
     var tags = _context.Tags.ToList();
     if (tags.Count() != 0)
     {
         foreach (var tg in tags)
         {
             var tagid = tg.Id;
             Int32.TryParse(tagid.Replace("tag", ""), out num);
             numlist.Add(num);
         }
         numlist.Sort();
         num = numlist.Last();
         num++;
     }
     else
     {
         num = 1;
     }
     var newid = "tag" + num.ToString();
     var tag = new Tag { Id = newid, Name = tagName, UrlSeo = tagUrlSeo, Checked = false };
     _context.Tags.Add(tag);
     Save();
 }
        public void GetAllEmployees()
        {
            //LIST
            List<dao.Employee> listEmployees = new List<dao.Employee>();

            //CONNECT TO DB
            string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            using (SqlConnection con = new SqlConnection(cs))
            {
                //QUERY
                SqlCommand cmd = new SqlCommand("SELECT * FROM tblEmployees", con);

                //OPEN CONNECTION
                con.Open();

                //READER
                SqlDataReader rdr = cmd.ExecuteReader();

                //LOOP
                while (rdr.Read())
                {
                    dao.Employee employee = new dao.Employee();
                    employee.id = Convert.ToInt32(rdr["Id"]);
                    employee.name = (rdr["Name"].ToString());
                    employee.gender = (rdr["Gender"].ToString());
                    employee.salary = Convert.ToInt32(rdr["Salary"]);

                    //ADD TO LIST
                    listEmployees.Add(employee);
                }
            }
            //JAVASCRIPT SERIALIZER
            JavaScriptSerializer js = new JavaScriptSerializer();
            Context.Response.Write(js.Serialize(listEmployees));
        }
        public static List<Product> ReadProductsFromDataBase()
        {
            var listOfProducts = new List<Product>();

            using (var reader = new StreamReader(FileOperation.FilePath))
            {

                var CurrentProduct = reader.ReadLine();

                while (CurrentProduct != null)
                {
                    var currentProduct = CurrentProduct.Split('|');
                    var product = new Product(
                        DateTime.Parse(currentProduct[0].Trim()),
                        currentProduct[1].Trim(),
                        double.Parse(currentProduct[2].Trim()));

                    listOfProducts.Add(product);

                    CurrentProduct = reader.ReadLine();
                }
            }

            return listOfProducts;
        }
        private void populateTreeView(List<DoctorServiceRef.Doctor> doctors)
        {
            sortedDoctors = doctors.OrderBy(doc => doc.specialty).ToList();
            var topNode = new TreeNode("Services");
            TreeView1.Nodes.Add(topNode);
            string currentSpecialty = sortedDoctors.First().specialty;
            var treeNodes = new List<TreeNode>();
            var childNodes = new List<TreeNode>();
            foreach (DoctorServiceRef.Doctor doc in sortedDoctors)
            {
                if (currentSpecialty == doc.specialty)
                    childNodes.Add(new TreeNode(doc.firstName + " " + doc.lastName));
                else
                {
                    if (childNodes.Count > 0)
                    {
                        TreeNode newNode = new TreeNode(currentSpecialty);
                        foreach (TreeNode node in childNodes)
                        {
                            newNode.ChildNodes.Add(node);
                        }
                        treeNodes.Add(newNode);
                        childNodes = new List<TreeNode>();
                    }
                    childNodes.Add(new TreeNode(doc.firstName + " " + doc.lastName));
                    currentSpecialty = doc.specialty;
                }
            }
            if (childNodes.Count > 0)
            {

                TreeNode newNode = new TreeNode(currentSpecialty);
                foreach (TreeNode node in childNodes)
                {
                    newNode.ChildNodes.Add(node);
                }
                treeNodes.Add(newNode);
            }
            foreach (TreeNode node in treeNodes)
            {
                TreeView1.Nodes.Add(node);
            }
            TreeView1.CollapseAll();
            TreeView1.DataBind();
        }
		private IEnumerable<Item> GetTopCreators(int howMany)
		{
		DbEntities context = new DbEntities();
			var items = context.Item.Include(i => i.AspNetUsers);
			IEnumerable<IGrouping<string, Item>> outerSequence = items.GroupBy(i => i.AspNetUsersId);
			var sortedGroups = outerSequence.OrderByDescending(g => g.Count())
			.Take(howMany);
			List<Item> itemList = new List<Item>();					
			foreach (IGrouping<string, Item> keyGroupSequence in sortedGroups)
			{
				itemList.Add(keyGroupSequence.First());
			}
			return itemList;
			}
示例#11
0
        public string createFile(List<task> tasks, List<story> stories)
        {
            finalStrings = new List<string>();

            var filename = "report" + DateTime.Now.ToString("dd.MM.yyy.HH.mm") + ".txt";
            filename.Replace("/", "");
            String[] infos = new String[2];
            infos[0] = filename;
            var path = Server.MapPath("~/CreatedDocs/");
            infos[1] = path + filename;
            if (File.Exists(path + filename))
            {
                File.Delete(path + filename);
                File.Create(path + filename).Close();
            }
            else
            {
                File.Create(path + filename).Close();
            }

            foreach (story story in stories)
            {
                finalStrings.Add(formatString(story.name));
                foreach (task task in tasks)
                {
                    if (task.story_id == story.id)
                    {
                        finalStrings.Add(formatString(task.description, true));
                    }
                }
            }

            File.AppendAllLines(path + filename, finalStrings);

            return infos[0];
        }
示例#12
0
 public void AddNewCategory(string catName, string catUrlSeo, string catDesc)
 {
     List<int> numlist = new List<int>();
     int num = 0;
     var categories = _context.Categories.ToList();
     foreach (var cat in categories)
     {
         var catid = cat.id;
         Int32.TryParse(catid.Replace("cat", ""), out num);
         numlist.Add(num);
     }
     numlist.Sort();
     num = numlist.Last();
     num++;
     var newid = "cat" + num.ToString();
     var category = new Category { id = newid, Name = catName, Description = catDesc, UrlSeo = catUrlSeo, Checked = false };
     _context.Categories.Add(category);
     Save();
 }
示例#13
0
        public void GetCustomers()
        {

            List<Customers> listcustomer = new List<Customers>();

            string cs = ConfigurationManager.ConnectionStrings["YleanaConnectionString"].ConnectionString;
            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("Select * from Customers", con);
                con.Open();
                //cmd.CommandType = CommandType.StoredProcedure;

                //SqlParameter parameter = new SqlParameter();
                //parameter.ParameterName = "@Id";
                //parameter.Value = employeeId;

                //cmd.Parameters.Add(parameter);

                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    Customers cust = new Customers();
                    cust.CustomerID = Convert.ToInt32(rdr["CustomerID"]);
                    cust.CustomerName = rdr["CustomerName"].ToString();
                    cust.ContactName = rdr["ContactName"].ToString();
                    cust.Address = rdr["Address"].ToString();
                    cust.City = rdr["City"].ToString();
                    cust.Postalcode = rdr["Postalcode"].ToString();
                    cust.Country = rdr["Country"].ToString();
                    listcustomer.Add(cust);

                }

            }
            JavaScriptSerializer js = new JavaScriptSerializer();
            Context.Response.Write(js.Serialize(listcustomer));
            //return listcustomer;

            //return new JavaScriptSerializer().Serialize(listcustomer);


        }
示例#14
0
 public IList<Tag> GetPostTags(Post post)
 {
     //idia diadikasia me ton getpostcategories
     var tagIds = _context.PostTags.Where(p => p.PostId == post.Id).Select(p => p.TagId).ToList();
     List<Tag> tags = new List<Tag>();
     foreach (var tagId in tagIds)
     {
         tags.Add(_context.Tags.Where(p => p.Id == tagId).FirstOrDefault());
     }
     return tags;
 }
示例#15
0
 public IList<PostImage> GetPostImages(Post post)
 {
     var postUrls = _context.PostImages.Where(p => p.PostId == post.Id).ToList();
     List<PostImage> images = new List<PostImage>();
     foreach (var url in postUrls)
     {
         images.Add(url);
     }
     return images;
 }
        public void getAllDoctorName()
        {
            doctorList.AddRange(doctorService.GetAllDoctors());
            dropdownListItems = new List<String>();

            for (int i = 0; i < doctorList.Count; i++)
            {
                dropdownListItems.Add("(" + doctorList.ElementAt(i).id + ") " + doctorList.ElementAt(i).firstName + " " + doctorList.ElementAt(i).lastName);
            }
        }
 public void addTimeButtons()
 {
     buttons = new List<Button>();
     buttons.Add(Button730);
     buttons.Add(Button800);
     buttons.Add(Button830);
     buttons.Add(Button900);
     buttons.Add(Button930);
     buttons.Add(Button1000);
     buttons.Add(Button1030);
     buttons.Add(Button1100);
     buttons.Add(Button1130);
     buttons.Add(Button1200);
     buttons.Add(Button1230);
     buttons.Add(Button1300);
     buttons.Add(Button1330);
     buttons.Add(Button1400);
     buttons.Add(Button1430);
     buttons.Add(Button1500);
     for (int i = 0; i < buttons.Count; i++)
     {
         buttons[i].Click += MyButtonClick;
     }
 }
示例#18
0
        public string resolve()
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            string param = System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.Url.Query.ToString().Substring(1));
            string[] param_s = param.Split('&'); Hashtable key_values = new System.Collections.Hashtable(); ;
            foreach (string item in param_s)
            {
                string[] key_value = item.Split('=');
                //  this.GetType().GetField(key_value[0]).GetValue(key_value[1]).ToString();
                key_values.Add(key_value[0], key_value[1]);
            }

            String LocalPath = null;
            string column = key_values.ContainsKey("column") ? key_values["column"].ToString() : "", type = key_values.ContainsKey("type") ? key_values["type"].ToString() : "", doc_url = key_values.ContainsKey("doc_url") ? key_values["doc_url"].ToString() : "";
            if (column.Equals("") || type.Equals("") || doc_url.Equals(""))
                throw new Exception("输入参数不合法");
            //  return column;

            string message = null;
            try
            {
                String savePath = downfile(doc_url);
                //  string pdfpath = showwordfiles(savePath);
                //不需要此步判断了 if (!File.Exists(savePath)) throw new Exception("保存文件失败" );

                in_column = column;
                //WORD  中数据都规整为一个空格隔开来
                columns = column.Split(',');
                object fileName = savePath;

                object unknow = System.Type.Missing;

                //目前一个线程再跑
                if (type == "rs") { delet_tables(savePath); }

                //count the paragraphs

                if (type == "rs")
                {
                    //然后完成对文档的解析

                    List<System.Threading.Tasks.Task> TaskList = new List<System.Threading.Tasks.Task>();
                    // 开启线程池,线程分配算法
                    System.Threading.Tasks.Task t = null;

                    int k = (int)Math.Ceiling((Double)slice / doc_handler);
                    for (int i = 0; i < doc_handler; i++)
                    {
                        Microsoft.Office.Interop.Word.Application app_in = new Microsoft.Office.Interop.Word.Application();
                        var doc1 = app_in.Documents.Open(ref fileName, ref unknow, true, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow,
                        ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
                        pcount = doc1.Paragraphs.Count;
                        docs_list[i] = (doc1);
                        apps_list[i] = (app_in);

                        int block = (int)Math.Ceiling((Double)pcount / slice);
                        for (int j = i * k + 1; j <= (i + 1) * k && j <= slice; j++)
                        {

                            //Debug.WriteLine("传入{0},{1}", pcount * (i) / slice + 1 - key_line, pcount * (i + 1) / slice + key_line);
                            int start_in = block * (j - 1) + 1 - key_line <= 0 ? 1 : block * (j - 1) + 1 - key_line, end_in = block * (j) + key_line >= pcount ? pcount : block * (j) + key_line;
                            Debug.WriteLine("outside{0}=>{1},{2}", doc1.GetHashCode(), start_in, end_in);
                            t = new System.Threading.Tasks.Task(() => thread1(doc1, start_in, end_in));//, ref aaa.finals[i]));
                            t.Start();
                            TaskList.Add(t);
                        }
                    }

                    /*
                         var t1 = new System.Threading.Tasks.Task(() => thread1(1,pcount/8+key_line, map[0]));
                         t8.Start(); TaskList.Add(t8);

                 */

                    System.Threading.Tasks.Task.WaitAll(TaskList.ToArray());//t1, t2, t3, t4, t5, t6, t7, t8);
                    var json = new JavaScriptSerializer().Serialize(aaa.finalstrings.Where((x, i) => aaa.finalstrings.FindIndex(z => z["tag"] == x["tag"]) == i).ToList());
                    message = json;// "{\"success\":true,\"msg\":" + (new JavaScriptSerializer().Serialize(json)) + "}";

                }//rs
                else if (type == "tc")
                {

                    //tc并发并没有什么问题

                    List<System.Threading.Tasks.Task> TaskList = new List<System.Threading.Tasks.Task>();

                    int k = (int)Math.Ceiling((Double)slice / doc_handler);
                    Debug.WriteLine("buchang {0}", k);
                    for (int i = 0; i < doc_handler; i++)
                    {
                        Microsoft.Office.Interop.Word.Application app_in = new Microsoft.Office.Interop.Word.Application();
                        var doc1 = app_in.Documents.Open(ref fileName, ref unknow, true, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow, ref unknow,
                        ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
                        pcount = doc1.Tables.Count;
                        docs_list[i] = (doc1);
                        apps_list[i] = (app_in);
                        int block = (int)Math.Ceiling((Double)pcount / slice);

                        for (int j = i * k + 1; j <= (i + 1) * k && j <= slice; j++)
                        {
                            //Debug.WriteLine("传入{0},{1}", pcount * (i) / slice + 1 - key_line, pcount * (i + 1) / slice + key_line);

                            int start_in = block * (j - 1) + 1 <= 0 ? 1 : block * (j - 1) + 1, end_in = block * (j) >= pcount ? pcount : block * (j);
                            Debug.WriteLine("outside {0},{1}", start_in, end_in);
                            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(() => readtc(doc1, start_in, end_in));
                            t.Start();
                            TaskList.Add(t);
                        }
                    }

                    System.Threading.Tasks.Task.WaitAll(TaskList.ToArray());
                    var json = new JavaScriptSerializer().Serialize(aaa.final_tc);
                    //(new HashSet<Dictionary<string, object>>(aaa.final_tc)));
                    message = json;// "{\"success\":true,\"msg\":" + (new JavaScriptSerializer().Serialize(json)) + "}";

                }

            }

            catch (Exception e)
            {

                message = e.ToString();//
                // "{\"success\":false,\"msg\":\"" + e.Message + e.StackTrace + e.TargetSite + "\"}";

                return message;

            }

            finally
            {
                stopwatch.Stop();

                //  return  json;

                //异不异常到最后都关闭文档,避免word一直处于打开状态占用资源
                object unknows = System.Type.Missing;
                Debug.WriteLine("打开大小为{0}", docs_list.Length);
                //   if (doc != null) doc.Close();
                for (int i = 0; i < docs_list.Length; i++)
                {
                    if (docs_list[i] == null) { break; } Debug.WriteLine("开始close"); docs_list[i].Close(ref unknows, ref unknows, ref unknows); Debug.WriteLine("结束close");
                }
                for (int i = 0; i < apps_list.Length; i++)
                {

                    if (apps_list[i] == null) { break; } Debug.WriteLine("开始quit"); apps_list[i].Quit(ref unknows, ref unknows, ref unknows); Debug.WriteLine("结束quit");
                }

                GC.Collect();
                GC.Collect();
                Context.Response.ContentType = "text/json";
                // Context.Response.Write(stopwatch.Elapsed);
                Context.Response.Write(message);
                // Context.Response.Write(json);

                Context.Response.End();

                /*     app1.Quit(ref unknow, ref unknow, ref unknow);

                 */

            }//finally
            return null;//不是正常请求方式,不可见这结果
        }
        private List<Autocomplete> _GetPeople(string query)
        {
            List<Autocomplete> people = new List<Autocomplete>();
            try
            {
                var results = (from p in db.People
                               where (p.FirstName + " " + p.LastName).Contains(query)
                               orderby p.FirstName,p.LastName
                               select p).Take(10).ToList();
                foreach (var r in results)
                {
                    // create objects
                    Autocomplete person = new Autocomplete();

                    person.Name = string.Format("{0} {1}", r.FirstName, r.LastName);
                    person.Id = r.PersonId;

                    people.Add(person);
                }

            }
            catch (EntityCommandExecutionException eceex)
            {
                if (eceex.InnerException != null)
                {
                    throw eceex.InnerException;
                }
                throw;
            }
            catch
            {
                throw;
            }
            return people;
        }
示例#20
0
 //κατηγορίες
 public IList<Category> GetPostCategories(Post post)
 {
     //GetCategories category id of postcategory table
     var categoryIds = _context.PostCategories.Where(p => p.PostId == post.Id).Select(p => p.CategoryId).ToList();
     //creaty empty list of categories
     List<Category> categories = new List<Category>();
     //prosthiki ton id sti kaini lista
     foreach (var catId in categoryIds)
     {
         categories.Add(_context.Categories.Where(p => p.id == catId).FirstOrDefault());
     }
     return categories;
 }