Beispiel #1
0
        protected override void OnInitData()
        {
            ModelDBHelper helper = ModelDBHelper.Create(ModelName);
            Criteria      c      = CreateEntryCriteria();
            DataTable     dt     = helper.Query(c, CreateOrders(), 0, 0, Fields);

            if (null != dt)
            {
                JoinEx               joinex  = new JoinEx();
                MoldPanel            mp      = new MoldPanel();
                ColumnInfoCollection columns = mp.GetPanelContext(ModelName, "list").Panel.ListInfo.Groups[0].Columns;
                foreach (ColumnInfo item in columns)
                {
                    if (!string.IsNullOrEmpty(item.Params["model"]))
                    {
                        joinex.JoinInfo.Add(item.Name, new JoinEx()
                        {
                            MainField = item.Name, PriMaryKeyName = item.Params["valuefield"], ToField = item.Params["textfield"], ToTableName = item.Params["model"]
                        });
                    }
                }
                if (joinex.JoinInfo != null && joinex.JoinInfo.Count > 0)
                {
                    DataBaseAssistant db = new DataBaseAssistant();
                    dt = db.Join(dt, joinex);
                }
            }

            /*end*/
            Item = dt != null && dt.Rows.Count > 0 ? dt.Rows[0] : dt.NewRow();

            //更新点击次数
            if (dt.Columns.Contains("Clicks"))
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                int clicks = Item["Clicks"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(Item["Clicks"]);
                clicks++;
                dic.Add("Clicks", clicks);
                helper.Update(dic, c);
            }
        }
Beispiel #2
0
        protected override void OnInitData()
        {
            Criteria     c  = CreateCriteria();
            List <Order> os = CreateOrders();

            ModelDBHelper dbhelper = ModelDBHelper.Create(ModelName);
            // Items = dbhelper.QueryPagedList(c, os, 0, PageSize).Rows;
            DataTable dt = dbhelper.QueryPagedList(c, os, 0, PageSize, Fields);

            /*begin 表关联相关*/
            if (null != dt)
            {
                JoinEx               joinex  = new JoinEx();
                MoldPanel            mp      = new MoldPanel();
                ColumnInfoCollection columns = mp.GetPanelContext(ModelName, "list").Panel.ListInfo.Groups[0].Columns;
                foreach (ColumnInfo item in columns)
                {
                    if (!string.IsNullOrEmpty(item.Params["model"]))
                    {
                        joinex.JoinInfo.Add(item.Name, new JoinEx()
                        {
                            MainField = item.Name, PriMaryKeyName = item.Params["valuefield"], ToField = item.Params["textfield"], ToTableName = item.Params["model"]
                        });
                    }
                }
                if (joinex.JoinInfo != null && joinex.JoinInfo.Count > 0)
                {
                    DataBaseAssistant db = new DataBaseAssistant();
                    dt = db.Join(dt, joinex);
                }
            }

            /*end*/
            if (dt != null)
            {
                Items = dt.Rows;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Our Primary Thread in this class
        /// It will be created 1 time by the caller
        /// Then it will create secondary worker threads
        /// which it will then block (wait on)
        /// until they have completed or failed or shut down
        /// </summary>
        public string CreateProfiles(OrganizationServiceProxy _service)
        {
            // We need to create our file if it exists
            // or if it's already open, generate a second one.

            /// <summary>
            /// validate if we want to add directly to CRM or not
            /// </summary>
            try
            {
                if (this.Clients > 0)
                {
                    // since we are dividing up the creates per thread
                    // we have to check if it is equal across all threads
                    // if not then we want to add the rest to the last thread
                    // technically we could create another client thread
                    // but we are going by what they told us.
                    // this shouldn't cause too many issues based on count and remainder

                    List <Thread> threads = new List <Thread>();

                    for (int createthreads = 0; createthreads < this.Clients; createthreads++)
                    {
                        // create our thread and start it
                        // it's a parameterized query so pass in the proper values from above
                        Thread clientthread = new Thread(() => CreateCDSProfile(_service));
                        clientthread.Name = createthreads.ToString() + "-" + profileType.ToString();
                        clientthread.Start();

                        // add to our list of threads
                        // we do this so that we can essentially block the main console
                        // thread..otherwise it would exit before these guys are done
                        // add these to the total list first
                        threads.Add(clientthread);
                    }

                    // once all threads are created
                    // join with them.. if it fails that only means the thread
                    // was done (possibly a weird other situation.. but doubtful)
                    // so it's ok to fail on any threads (or all)
                    // which would either make us block for them to complete
                    // or if they were magically done.. join (0) and exit.
                    foreach (Thread t in threads)
                    {
                        try
                        {
                            t.Join();
                        }
                        catch (Exception JoinEx)
                        {
                            // ignore for now as it's not useful to the process
                            // if we error out because the thread was already done
                            // which might be possible in a multi-threaded usage scenario
                            // but that is ok
                            System.Diagnostics.Debug.WriteLine("Thread Join Error: " + JoinEx.ToString());
                        }
                    }


                    switch (ProfileType)
                    {
                    case Profile.ProfileType.Standard:
                    {
                        Contact.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Patient:
                    {
                        Patient.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Practitioner:
                    {
                        Practitioner.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.RelatedPerson:
                    {
                        RelatedPerson.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Organization:
                    {
                        Organization.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Location:
                    {
                        Location.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }

                    case Profile.ProfileType.Medication:
                    {
                        Location.ExportToJson(FileName, OutgoingProfiles);
                        break;
                    }
                    }
                }

                else
                {
                    throw new ArgumentException("Invalid Client value. Client must be > 0");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }

            return(FileName);
        }