Example #1
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;
        }
        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;
        }
Example #3
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();
 }
Example #4
0
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.MapHubs();

            var users = new List<ChatUser> {
                new ChatUser { name = "Jon" },
                new ChatUser { name = "Fred" },
                new ChatUser { name = "Tim" }
            };

            var rand = new Random(DateTime.Now.Millisecond);
            var i = rand.Next(0, users.Count - 1);
            var user = users[i];

            ChatConnectionManager
                .Configure()
                .ForUser(token =>
                {
                    user.token = token;
                    return user;
                })
                .ForFriends(token => {

                    var friends = new List<ChatUser>() {
                        new ChatUser() { name = "Sam", status = ChatConnectionStatus.Active },
                        new ChatUser() { name = "Jim", status = ChatConnectionStatus.Active },
                        new ChatUser() { name = "Tim", status = ChatConnectionStatus.Inactive },
                        new ChatUser() { name = "Jon", status = ChatConnectionStatus.Offline }
                    };

                    return friends;

                });
        }
        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;
        }
        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);
        }
        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));
        }
        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();
            }
        }
Example #9
0
 public ActionResult Partners()
 {
     Crew k = new Crew();
     List<Crew> Lic = new List<Crew>();
     Lic = k.IndexDisplay();
     ViewData["IndexDisplay"] = Lic;
     return View(Lic);
 }
Example #10
0
        public ActionResult More()
        {
            Map p = new Map();
            List<Map> Li = new List<Map>();

            Li = p.MapDisplay();
            ViewData["MapDisplay"] = Li;
            return View(Li);
        }
        public void SaveCustomer(List<Customers> custdata)
        {
            string cs = ConfigurationManager.ConnectionStrings["YleanaConnectionString"].ConnectionString;
            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("spaddcustomer", con);
                cmd.CommandType = CommandType.StoredProcedure;
                //yourArrayList.get(yourArrayList.size() - 1);
               // int i=custdata.get(custdata.l - 1);
               var lastitem= custdata.LastOrDefault();
               
                cmd.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@CustomerName",
                   // Value = custdata[0].CustomerName
                   Value=lastitem.CustomerName
                });

                cmd.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@ContactName",
                    //Value = custdata[0].ContactName
                     Value=lastitem.ContactName
                });

                cmd.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@Address",
                   // Value = custdata[0].Address
                    Value = lastitem.Address
                });
                cmd.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@City",
                   // Value = custdata[0].City
                     Value=lastitem.City
                });
                cmd.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@Postalcode",
                   // Value = custdata[0].Postalcode
                     Value=lastitem.Postalcode
                });
                cmd.Parameters.Add(new SqlParameter()
                {
                    ParameterName = "@Country",
                   // Value = custdata[0].Country
                     Value=lastitem.Country
                });
               
                cmd.ExecuteNonQuery();
                con.Close();
            }

           //return custdata;
        }
Example #12
0
        public ActionResult Partners()
        {
            Images p = new Images();
            List<Images> Li = new List<Images>();

            Li = p.IndexDisplay();
            ViewData["IndexDisplay"] = Li;
            return View(Li);
        }
Example #13
0
        public void AddImageToPost(string postid, string Imagename)
        {
            List<int> numlist = new List<int>();
            int num = 1;

            var check = _context.PostImages.Where(x => x.PostId == postid && x.Imagename == Imagename).Any();

                var image = new PostImage { Id = num, PostId = postid, Imagename = Imagename };
                _context.PostImages.Add(image);
                Save();
        }
		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;
			}
        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;
        }
        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();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     List<Project> list=new List<Project>()
         {
             new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 },
                 new Project()
                 {
                     Name = "aa",Price = 23.5
                 }
         };
     Response.Write(list.Sum(p => p.Price));
 }
Example #18
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();
 }
        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);


        }
Example #20
0
        protected void MyAsyncMethod()
        {
            //MyService.MyWebService proxy =
            //    new MyService.MyWebService();

            proxy.HelloWorldAverageCompleted += Proxy_HelloWorldAverageCompleted;
            int a = 5;
            int b = 3;
            proxy.HelloWorldAverageAsync(a, b);
            List<DayTimeType> TypesDictionary = (List<DayTimeType>)Cache["TypesDictionary"];
            if (TypesDictionary == null)
            {
                TypesDictionary = new List<DayTimeType>()
                {
                    new DayTimeType { Name = "K",  ColorStr ="913D88"},
                    new DayTimeType { Name = "ПК", ColorStr = "9B59B6"},
                    new DayTimeType { Name = "Я",  ColorStr ="acf3a7"},
                    new DayTimeType { Name = "В",  ColorStr ="C8F7C5"},
                    new DayTimeType { Name = "Б",  ColorStr ="2574A9"},
                    new DayTimeType { Name = "НН", ColorStr = "D91E18"},
                    new DayTimeType { Name = "ОТ", ColorStr = "913D88"},
                    new DayTimeType { Name = "ДО", ColorStr = "F4D03F"},
                    new DayTimeType { Name = "ОЗ", ColorStr = "2574A9"},
                    new DayTimeType { Name = "ОЧ", ColorStr = "D91E18"},
                    new DayTimeType { Name = "ОЖ", ColorStr = "F9BF3B"},
                    new DayTimeType { Name = "Р",  ColorStr ="2574A9"},
                    new DayTimeType { Name = "ПМ", ColorStr = "D91E18"},
                    new DayTimeType { Name = "РВ", ColorStr = "913D88"},
                    new DayTimeType { Name = "Д",  ColorStr ="2574A9"},
                    new DayTimeType { Name = "ОД", ColorStr = "D91E18"}
                };
                Cache["TypesDictionary"] = TypesDictionary;
                // Алиса: ручная настройка:
                // Cache.Add("TypesDictionary", TypesDictionary,
                            //null, DateTime.Now.AddHours(2),
                            //TimeSpan.FromMinutes(30), System.Web.Caching.CacheItemPriority.Normal,
                            //null);
            }
        }
Example #21
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];
        }
 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;
     }
 }
Example #23
0
 /// <summary>
 /// 执行SQL(事务)
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public int Execute(List<string> sqlList, List<SqlParameter[]> parameterList)
 {
     if (sqlList.Count > parameterList.Count)
     {
         throw new Exception("参数错误");
     }
     using (SqlConnection conn = new SqlConnection(ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = new SqlCommand())
         {
             int i = 0;
             cmd.Connection = conn;
             for (int j = 0; j < sqlList.Count; j++)
             {
                 cmd.CommandType = CommandType.Text;
                 cmd.CommandText = sqlList[j];
                 if (parameterList[j] != null && parameterList[j].Length > 0)
                 {
                     cmd.Parameters.AddRange(parameterList[j]);
                 }
                 i += cmd.ExecuteNonQuery();
                 cmd.Parameters.Clear();
                 cmd.Prepare();
             }
             return i;
         }
     }
 }
Example #24
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;//不是正常请求方式,不可见这结果
        }
Example #25
0
 /// <summary>
 /// 递归复制文件夹集
 /// </summary>
 /// <param name="list">集合</param>
 /// <param name="FileID">老文件夹ID</param>
 /// <param name="newFileID">新文件夹ID</param>
 /// <param name="oldParentIDs">老文件夹父级IDs</param>
 /// <param name="newParentIDs">新文件夹父级IDs</param>
 void ForeachCopyFile(List<OS_Files> list, string FileID, string newFileID, string oldParentIDs, string newParentIDs)
 {
     var v = list.Where(p => p.ParentID == new Guid(FileID));
     foreach (var _v in v)
     {
         OS_Files model = new OS_Files();
         model.ID = Guid.NewGuid();
         model.Name = _v.Name;
         model.ParentID = new Guid(newFileID);
         model.ParentIDs = _v.ParentIDs.Replace(oldParentIDs, newParentIDs) + newFileID + "|";
         model.state = 0;
         model.ModifiedDate = model.CreatedDate = DateTime.Now;
         db.OS_Files.Add(model);
         ForeachCopyFile(list, _v.ID.ToString(), model.ID.ToString(), _v.ParentIDs, model.ParentIDs);
     }
 }
        private void SetButtonColor()
        {
            List<String> appointmentDates = new List<String>();
            appointmentDates.AddRange(appointmentService.getAppointmentsByDocAndDate(SelectedDate, DoctorId));

            if (appointmentDates.Count<1)
            {
                for (int i = 0; i < buttons.Count; i++)
                {
                    buttons[i].BackColor = System.Drawing.Color.Green;
                }
            }
            else
            {
                for (int i = 0; i < buttons.Count; i++)
                {
                    int e = 0;
                    Boolean found = false;
                    while (e < appointmentDates.Count && found == false)
                    {
                        if (appointmentDates[e].Equals(buttons[i].Text))
                        {
                            buttons[i].BackColor = System.Drawing.Color.Red;
                            found = true;
                        }

                        else
                        {
                            buttons[i].BackColor = System.Drawing.Color.Green;
                            e++;
                        }
                    }
                }
            }
        }
        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);
            }
        }
Example #28
0
 /// <summary>
 /// 执行SQL(事务)
 /// </summary>
 /// <param name="sql"></param>
 /// <returns></returns>
 public int Execute(List<string> sqlList)
 {
     using (SqlConnection conn = new SqlConnection(ConnectionString))
     {
         conn.Open();
         using (SqlCommand cmd = new SqlCommand())
         {
             int i = 0;
             cmd.Connection = conn;
             foreach (string sql in sqlList)
             {
                 cmd.CommandType = CommandType.Text;
                 cmd.CommandText = sql;
                 cmd.Prepare();
                 i += cmd.ExecuteNonQuery();
             }
             return i;
         }
     }
 }
        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;
        }
Example #30
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;
 }