Exemple #1
0
        private static string GetSoql <T>(int limit)
        {
            global::System.Collections.Generic.List <string> supportedTypes =
                new global::System.Collections.Generic.List <string> {
                "Boolean", "String", "Datetime", "DateTime", "Double", "Int32"
            };

            StringBuilder sb = new StringBuilder();
            var           memberProperties = typeof(T).GetProperties().ToList();

            sb.Append("SELECT ");

            foreach (var memberProperty in memberProperties)
            {
                //Console.WriteLine(memberProperty.PropertyType.Name + " : " + memberProperty.Name);

                if (supportedTypes.Contains(memberProperty.PropertyType.Name) && memberProperty.Name != "ExternalId")
                {
                    sb.Append(memberProperty.Name).Append(',');
                }
            }

            var soql = sb.ToString();

            // Remove the last comma
            soql = soql.TrimEnd(',');
            soql = soql + " FROM " + typeof(T).Name + " LIMIT " + limit;


            return(soql);
        }
Exemple #2
0
 private global::System.Data.DataRow[] GetRealUpdatedRows(global::System.Data.DataRow[] updatedRows, global::System.Collections.Generic.List <global::System.Data.DataRow> allAddedRows)
 {
     if (((updatedRows == null) ||
          (updatedRows.Length < 1)))
     {
         return(updatedRows);
     }
     if (((allAddedRows == null) ||
          (allAddedRows.Count < 1)))
     {
         return(updatedRows);
     }
     global::System.Collections.Generic.List <global::System.Data.DataRow> realUpdatedRows = new global::System.Collections.Generic.List <global::System.Data.DataRow>();
     for (int i = 0; (i < updatedRows.Length); i = (i + 1))
     {
         global::System.Data.DataRow row = updatedRows[i];
         if ((allAddedRows.Contains(row) == false))
         {
             realUpdatedRows.Add(row);
         }
     }
     return(realUpdatedRows.ToArray());
 }
Exemple #3
0
        public static T QueryById <T>(string Id) where T : SObject
        {
            global::System.Collections.Generic.List <string> supportedTypes =
                new global::System.Collections.Generic.List <string> {
                "Boolean", "String", "Datetime", "DateTime", "Double", "Int32"
            };

            StringBuilder sb = new StringBuilder();
            var           memberProperties = typeof(T).GetProperties().ToList();

            sb.Append("SELECT ");

            foreach (var memberProperty in memberProperties)
            {
                //Console.WriteLine(memberProperty.PropertyType.Name + " : " + memberProperty.Name);

                if (supportedTypes.Contains(memberProperty.PropertyType.Name) && memberProperty.Name != "ExternalId")
                {
                    sb.Append(memberProperty.Name).Append(',');
                }
            }

            var soql = sb.ToString();

            // Remove the last comma
            soql = soql.TrimEnd(',');
            soql = soql + " FROM " + typeof(T).Name + " WHERE Id = '" + Id + "'";

            var lasyResult = new Lazy <global::System.Collections.Generic.List <T> >(() =>
            {
                return(PerformQuery <T>(soql));
            });

            // return as polymorphic query instance
            return(new SoqlQuery <T>(lasyResult, soql));
        }
Exemple #4
0
        private void ReadData()
        {
            global::System.Collections.Generic.IList <string>
            RenderItemList       = new global::System.Collections.Generic.List <string>(),
                RenderDeleteList = new global::System.Collections.Generic.List <string>();

            do
            {
                while (this.Base.HasChange)//如果得到或者設置數據狀態改變
                {
                    // read current job information ..//讀黨前的工作信息
                    DataTable DataStatus = this.Base.GetQueueStatus;

                    if (DataStatus != null)
                    {
                        #region Invoke Render Status Data Object Delegate Procedure調用Render狀態數據對象代表Procedure
                        RenderDataCallBack RenderData = delegate(ListViewItem Item, string DeleteItemText)
                        {
                            if (!string.IsNullOrEmpty(DeleteItemText))
                            {
                                for (int i = 0; i < ListView_Render_Status.Items.Count; i++)
                                {
                                    // processing application all events ..//進程應用程序所有事件
                                    Application.DoEvents();

                                    if (this.ListView_Render_Status.Items[i].SubItems[0].Text == DeleteItemText)
                                    {
                                        // remove item ..//移除項
                                        this.ListView_Render_Status.Items[i].Remove();
                                    }

                                    // refresh control ..//刷新控制
                                    this.ListView_Render_Status.Update();
                                }

                                return;
                            }

                            foreach (ListViewItem RenderItem in this.ListView_Render_Status.Items)
                            {
                                // processing application all events ..//進程應用程序所有事件
                                Application.DoEvents();

                                if (RenderItem.Text == Item.Text)
                                {
                                    // update the item of sub items ..//修改子項的項
                                    for (int i = 0; i < RenderItem.SubItems.Count; i++)
                                    {
                                        RenderItem.SubItems[i] = Item.SubItems[i];
                                    }

                                    // refresh control ..//刷新控制
                                    this.ListView_Render_Status.Update();

                                    return;
                                }
                            }

                            // processing application all events ..//processing應用程序所有事件
                            Application.DoEvents();

                            // add new items to the listview control ..//添加新項到listview控制
                            this.ListView_Render_Status.Items.Add(Item);

                            // sorting ..//排序
                            this.ListViewSorter.SortColumn = 0;
                            this.ListView_Render_Status.Sort();

                            // refresh control ..//刷新控制
                            this.ListView_Render_Status.Update();

                            // append to logs object ..//追加到日志對象
                            RenderEvents.AppendLog(string.Format("{0}", "refresh listview render data."));
                        };

                        foreach (global::System.Data.DataRow row in DataStatus.Rows)
                        {
                            if (!RenderItemList.Contains(row["Job_Id"].ToString().Trim()))
                            {
                                RenderItemList.Add(row["Job_Id"].ToString().Trim());
                            }

                            string[] subitems =
                            {
                                row["Job_Id"].ToString().Trim(),
                                row["Job_Group_Id"].ToString().Trim(),
                                row["Proc_Id"].ToString().Trim(),
                                row["Proc_Type"].ToString().Trim(),
                                row["Command"].ToString().Trim(),
                                row["Args"].ToString().Trim(),
                                row["Status"].ToString().Trim(),
                                row["Start_Time"].ToString().Trim(),
                                row["Finish_Time"].ToString().Trim()
                            };

                            try
                            {
                                // invoke job list view delegate control ..//調用工作列view代表控制
                                this.Invoke(RenderData, new object[] { new ListViewItem(subitems), null });//調用RenderData
                            }
                            catch (InvalidOperationException)
                            {
                                // if delegate object already clean, exit loop ..//如果代表對象已經清空,退出loop
                                break;
                            }
                        }

                        // search deleted items ..//查看刪除項
                        foreach (string s in RenderItemList)
                        {
                            if (DataStatus.PrimaryKey.Length == 0)
                            {
                                break;
                            }

                            if (!DataStatus.Rows.Contains(s))
                            {
                                try
                                {
                                    // invoke job list view delegate control ..//調用工作列視圖代表控制
                                    this.Invoke(RenderData, new object[] { new ListViewItem(), s });

                                    // add to remove list ..//添加到移除列
                                    RenderDeleteList.Add(s);
                                }
                                catch (InvalidOperationException)
                                {
                                    // if delegate object already clean, exit loop ..//如果代表對象已經清空,退出loop
                                    break;
                                }
                            }
                        }

                        foreach (string s in RenderDeleteList)
                        {
                            // remove data record ..//移除數據記錄
                            RenderItemList.Remove(s);
                        }

                        // clear all delete list ..//清空所有刪除列
                        RenderDeleteList.Clear();
                        #endregion
                    }

                    // reset change flag ..//重置改變標志
                    this.Base.HasChange = false;
                }

                // set access state timespan ..//設置接口狀態timespan
                Thread.Sleep(500);
            } while (!requeststop);
        }