コード例 #1
0
ファイル: SendDoc.cs プロジェクト: JuRogn/OA
        private void SendDocByCompanyid(string companyid)
        {
            Dictionary<string, string> dicCompany=new Dictionary<string,string>();
            string strSunCompany = @"select c.companyid,c.cname from smthrm.t_hr_company c
            where c.fatherid='" + companyid + "'";
            OracleHelp.Connect();
            DataTable dtsun = OracleHelp.getTable(strSunCompany);
            if (dtsun != null)
            {
                if (dtsun.Rows.Count > 0)
                {
                    for (int i = 0; i < dtsun.Rows.Count; i++)
                    {
                        dicCompany.Add(dtsun.Rows[i]["cname"].ToString(), dtsun.Rows[i]["companyid"].ToString());
                        string strGrandSunCompany = @"select c.companyid,c.cname from smthrm.t_hr_company c
                            where c.fatherid='" + dtsun.Rows[i]["companyid"].ToString() + "'";

                        DataTable dtGrandSun = OracleHelp.getTable(strGrandSunCompany);
                        if (dtGrandSun != null)
                        {
                            if (dtGrandSun.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtGrandSun.Rows.Count; j++)
                                {
                                    dicCompany.Add(dtGrandSun.Rows[j]["cname"].ToString(), dtGrandSun.Rows[j]["companyid"].ToString());
                                }
                            }
                        }
                    }
                }
            }
            OracleHelp.close();
            if (string.IsNullOrEmpty(TxtSendDocid.Text))
            {
                MessageBox.Show("请先查询公文id");
                return;
            }
            string msg = string.Empty;
            ObservableCollection<T_OA_DISTRIBUTEUSER> distributeAddList = new ObservableCollection<T_OA_DISTRIBUTEUSER>() ;
            SmtOACommonOfficeClient DocDistrbuteClient = new SmtOACommonOfficeClient();
            ObservableCollection<string> CompanyIDsList = new ObservableCollection<string>(); 
            ObservableCollection<string> StrDepartmentIDsList = new ObservableCollection<string>();  //获取部门ID
            ObservableCollection<string> StrPositionIDsList = new ObservableCollection<string>();
            ObservableCollection<string> StrStaffList = new ObservableCollection<string>();  //员工ID


            if (dicCompany.Count > 0)
            {
                foreach (var q in dicCompany)
                {
                    //if (q.Key == "杭州新神州通货物运输有限公司") continue;
                    ShowMessage("发布公文给这个公司:"+q.Key+" 公司id:"+q.Value);
                    CompanyIDsList.Add(q.Value);

                    T_OA_DISTRIBUTEUSER distributeTmp = new T_OA_DISTRIBUTEUSER();
                    distributeTmp.DISTRIBUTEUSERID = Guid.NewGuid().ToString();
                    distributeTmp.MODELNAME = "CompanySendDoc";
                    distributeTmp.FORMID = TxtSendDocid.Text;
                    distributeTmp.VIEWTYPE = "0";//公司
                    distributeTmp.VIEWER = q.Value;

                    distributeTmp.CREATEDATE = DateTime.Now;
                    distributeTmp.CREATEUSERID =GlobalParameters.employeeid;
                    distributeTmp.CREATEUSERNAME = GlobalParameters.employeeName;
                    distributeTmp.CREATEPOSTID = GlobalParameters.employeeMasterPostid;
                    distributeTmp.CREATEDEPARTMENTID = GlobalParameters.employeeMasterDepartmentid;
                    distributeTmp.CREATECOMPANYID = GlobalParameters.employeeMasterCompanyid;
                    distributeTmp.OWNERID =GlobalParameters.employeeid;
                    distributeTmp.OWNERNAME = GlobalParameters.employeeName;
                    distributeTmp.OWNERPOSTID = GlobalParameters.employeeMasterPostid;
                    distributeTmp.OWNERDEPARTMENTID = GlobalParameters.employeeMasterDepartmentid;
                    distributeTmp.OWNERCOMPANYID = GlobalParameters.employeeMasterCompanyid;
                    distributeAddList.Add(distributeTmp);
                }
                ShowMessage("发布公文给所有公司完毕,共发送:" + dicCompany.Count+ " 条数据");
            }
            V_BumfCompanySendDoc tmpSenddoc=DocDistrbuteClient.GetBumfDocInfo(TxtSendDocid.Text);
            if (tmpSenddoc.OACompanySendDoc == null)
            {
                MessageBox.Show("通过id获取的公文为空,请检查后再试");
                return;
            }
            T_OA_SENDDOC sendDoc = tmpSenddoc.OACompanySendDoc;
            sendDoc.T_OA_SENDDOCTYPE = null;
            sendDoc.T_OA_SENDDOCTYPEReference = null;

            DocDistrbuteClient.BatchAddCompanyDocDistrbuteForNew(distributeAddList.ToArray(), CompanyIDsList.ToArray(), StrDepartmentIDsList.ToArray(), StrPositionIDsList.ToArray(), StrStaffList.ToArray(), sendDoc);
            //MessageBox.Show("发布公文成功!");
        }
コード例 #2
0
ファイル: SendDoc.cs プロジェクト: jjg0519/OA
        private void SendDocByCompanyid(string companyid)
        {
            Dictionary <string, string> dicCompany = new Dictionary <string, string>();
            string strSunCompany = @"select c.companyid,c.cname from smthrm.t_hr_company c
            where c.fatherid='" + companyid + "'";

            OracleHelp.Connect();
            DataTable dtsun = OracleHelp.getTable(strSunCompany);

            if (dtsun != null)
            {
                if (dtsun.Rows.Count > 0)
                {
                    for (int i = 0; i < dtsun.Rows.Count; i++)
                    {
                        dicCompany.Add(dtsun.Rows[i]["cname"].ToString(), dtsun.Rows[i]["companyid"].ToString());
                        string strGrandSunCompany = @"select c.companyid,c.cname from smthrm.t_hr_company c
                            where c.fatherid='" + dtsun.Rows[i]["companyid"].ToString() + "'";

                        DataTable dtGrandSun = OracleHelp.getTable(strGrandSunCompany);
                        if (dtGrandSun != null)
                        {
                            if (dtGrandSun.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtGrandSun.Rows.Count; j++)
                                {
                                    dicCompany.Add(dtGrandSun.Rows[j]["cname"].ToString(), dtGrandSun.Rows[j]["companyid"].ToString());
                                }
                            }
                        }
                    }
                }
            }
            OracleHelp.close();
            if (string.IsNullOrEmpty(TxtSendDocid.Text))
            {
                MessageBox.Show("请先查询公文id");
                return;
            }
            string msg = string.Empty;
            ObservableCollection <T_OA_DISTRIBUTEUSER> distributeAddList = new ObservableCollection <T_OA_DISTRIBUTEUSER>();
            SmtOACommonOfficeClient       DocDistrbuteClient             = new SmtOACommonOfficeClient();
            ObservableCollection <string> CompanyIDsList       = new ObservableCollection <string>();
            ObservableCollection <string> StrDepartmentIDsList = new ObservableCollection <string>(); //获取部门ID
            ObservableCollection <string> StrPositionIDsList   = new ObservableCollection <string>();
            ObservableCollection <string> StrStaffList         = new ObservableCollection <string>(); //员工ID


            if (dicCompany.Count > 0)
            {
                foreach (var q in dicCompany)
                {
                    //if (q.Key == "杭州新神州通货物运输有限公司") continue;
                    ShowMessage("发布公文给这个公司:" + q.Key + " 公司id:" + q.Value);
                    CompanyIDsList.Add(q.Value);

                    T_OA_DISTRIBUTEUSER distributeTmp = new T_OA_DISTRIBUTEUSER();
                    distributeTmp.DISTRIBUTEUSERID = Guid.NewGuid().ToString();
                    distributeTmp.MODELNAME        = "CompanySendDoc";
                    distributeTmp.FORMID           = TxtSendDocid.Text;
                    distributeTmp.VIEWTYPE         = "0";//公司
                    distributeTmp.VIEWER           = q.Value;

                    distributeTmp.CREATEDATE         = DateTime.Now;
                    distributeTmp.CREATEUSERID       = GlobalParameters.employeeid;
                    distributeTmp.CREATEUSERNAME     = GlobalParameters.employeeName;
                    distributeTmp.CREATEPOSTID       = GlobalParameters.employeeMasterPostid;
                    distributeTmp.CREATEDEPARTMENTID = GlobalParameters.employeeMasterDepartmentid;
                    distributeTmp.CREATECOMPANYID    = GlobalParameters.employeeMasterCompanyid;
                    distributeTmp.OWNERID            = GlobalParameters.employeeid;
                    distributeTmp.OWNERNAME          = GlobalParameters.employeeName;
                    distributeTmp.OWNERPOSTID        = GlobalParameters.employeeMasterPostid;
                    distributeTmp.OWNERDEPARTMENTID  = GlobalParameters.employeeMasterDepartmentid;
                    distributeTmp.OWNERCOMPANYID     = GlobalParameters.employeeMasterCompanyid;
                    distributeAddList.Add(distributeTmp);
                }
                ShowMessage("发布公文给所有公司完毕,共发送:" + dicCompany.Count + " 条数据");
            }
            V_BumfCompanySendDoc tmpSenddoc = DocDistrbuteClient.GetBumfDocInfo(TxtSendDocid.Text);

            if (tmpSenddoc.OACompanySendDoc == null)
            {
                MessageBox.Show("通过id获取的公文为空,请检查后再试");
                return;
            }
            T_OA_SENDDOC sendDoc = tmpSenddoc.OACompanySendDoc;

            sendDoc.T_OA_SENDDOCTYPE          = null;
            sendDoc.T_OA_SENDDOCTYPEReference = null;

            DocDistrbuteClient.BatchAddCompanyDocDistrbuteForNew(distributeAddList.ToArray(), CompanyIDsList.ToArray(), StrDepartmentIDsList.ToArray(), StrPositionIDsList.ToArray(), StrStaffList.ToArray(), sendDoc);
            //MessageBox.Show("发布公文成功!");
        }