コード例 #1
0
        /// <summary>
        /// طرح پشتیبان
        /// </summary>
        private void PoshtibanDesign(OleDbConnection aConnection, OleDbTransaction aTransaction, SqlConnection sConnection, SqlTransaction sTransaction)
        {
            Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            DataTable dtWorkOrder = Atend.Base.Design.DPackage.AccessWorkOrders(aTransaction, aConnection);

            Atend.Base.Design.DDesignProfile _DDesignProfile      = Atend.Base.Design.DDesignProfile.SelectByDesignID(sTransaction, sConnection, Atend.Control.Common.DesignId);
            Atend.Base.Design.DDesign        _DDesign             = Atend.Base.Design.DDesign.SelectByID(sTransaction, sConnection, Atend.Control.Common.DesignId);
            Atend.Base.Design.DDesignFile    _DDesignFile         = Atend.Base.Design.DDesignFile.SelectByDesignId(sTransaction, sConnection, Atend.Control.Common.DesignId);
            Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection);

            if (_DDesignProfile.Id != -1)
            {
                if (currentDesignProfile.DesignId != -1)
                {
                    if (!currentDesignProfile.UpdateByDesignId(sTransaction, sConnection))
                    {
                        throw new System.Exception("currentDesignProfile.Update 4");
                    }
                }
                else
                {
                    throw new System.Exception("DDesignProfile access record was not found");
                }
            }
            else
            {
                if (currentDesignProfile.DesignId != -1)
                {
                    if (!currentDesignProfile.Insert(sTransaction, sConnection))
                    {
                        throw new System.Exception("currentDesignProfile.Insert 5");
                    }
                }
            }

            #region design
            _DDesign.Region = Convert.ToByte(Atend.Base.Base.BRegion.SelectByCodeLoacal(currentDesignProfile.Zone).SecondCode);
            if (!_DDesign.Update(sTransaction, sConnection))
            {
                throw new System.Exception("_DDesign.Update ");
            }
            #endregion

            #region DesignFile
            _DDesignFile.DesignId = Atend.Control.Common.DesignId;
            _DDesignFile.File     = new byte[0];

            #region ATNX file
            FileStream fs;
            fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open);
            BinaryReader br = new BinaryReader(fs);
            _DDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length);
            fs.Dispose();
            #endregion

            #region PDF file
            if (txtBookAddress.Text != string.Empty)
            {
                fs = new FileStream(txtBookAddress.Text, FileMode.Open);
                br = new BinaryReader(fs);
                _DDesignFile.Book = br.ReadBytes((Int32)br.BaseStream.Length);
                fs.Dispose();
            }
            else
            {
                _DDesignFile.Book = new byte[0];
            }
            #endregion

            #region DWF file
            if (txtBookAddress.Text != string.Empty)
            {
                fs = new FileStream(txtDWFAddress.Text, FileMode.Open);
                br = new BinaryReader(fs);
                _DDesignFile.Image = br.ReadBytes((Int32)br.BaseStream.Length);
                fs.Dispose();
            }
            else
            {
                _DDesignFile.Image = new byte[0];
            }
            #endregion


            if (_DDesignFile.Id != -1)
            {
                if (!_DDesignFile.Update(sTransaction, sConnection))
                {
                    throw new System.Exception("NewDesignFile.Insert 5");
                }
            }
            else
            {
                if (!_DDesignFile.Insert(sTransaction, sConnection))
                {
                    throw new System.Exception("CurrentDesignFile.Update 4");
                }
            }
            #endregion

            #region StatusReport
            Atend.Global.Utility.UOtherOutPut Output = new Atend.Global.Utility.UOtherOutPut();
            Atend.Report.dsSagAndTension      ds     = Output.FillStatusReport();
            Atend.Base.Design.DStatusReport.DeleteByDesignId(currentDesignProfile.DesignId);
            for (int i = 0; i < ds.Tables["StatusReport"].Rows.Count; i++)
            {
                Atend.Base.Design.DStatusReport STR = new Atend.Base.Design.DStatusReport();
                STR.DesignId = currentDesignProfile.DesignId;
                if (Atend.Control.NumericValidation.Int32Converter(ds.Tables["StatusReport"].Rows[i]["Code"].ToString()))
                {
                    STR.ProductCode = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["Code"].ToString());
                }
                else
                {
                    STR.ProductCode = 0;
                }

                DataTable ExTbl = Atend.Base.Base.BEquipStatus.SelectAllX();
                STR.Existance = Convert.ToInt32(ExTbl.Select("Name = '" + ds.Tables["StatusReport"].Rows[i]["Exist"].ToString() + "'")[0]["ACode"].ToString());
                int pc = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["ProjectCode"]);
                //int pc = Atend.Base.Base.BProjectCode.AccessSelectByCode(Convert.ToInt32(Table.Rows[i]["ProjectCode"].ToString())).AdditionalCode;
                STR.ProjectCode = pc;
                ds.Tables["StatusReport"].Rows[i]["ProjectCode"] = pc;
                ds.Tables["StatusReport"].Rows[i]["Count"]       = Math.Round(Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString()), 2);
                STR.Count = Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString());
                if (!STR.Insert(sTransaction, sConnection))
                {
                    ed.WriteMessage("\nError In D_StatusReport Insertion\n");
                }
            }
            #endregion

            #region WorkOrder
            if (Atend.Base.Design.DWorkOrder.Delete(Atend.Control.Common.DesignId, sTransaction, sConnection))
            {
                foreach (DataRow drWorkOrder in dtWorkOrder.Rows)
                {
                    Atend.Base.Design.DWorkOrder WO = new Atend.Base.Design.DWorkOrder();
                    WO.DesignID  = Atend.Control.Common.DesignId;;
                    WO.WorkOrder = Convert.ToInt32(drWorkOrder["WorkOrderCode"].ToString());
                    if (!WO.Insert(sTransaction, sConnection))
                    {
                        throw new System.Exception("WorkOrder.Insert Failed 5");
                    }
                }
            }
            #endregion
        }
コード例 #2
0
        /// <summary>
        /// طرح جدید بدون پشتیبان
        /// </summary>
        private void NewDesignWithoutPoshtiban(OleDbConnection aConnection, OleDbTransaction aTransaction, SqlConnection sConnection, SqlTransaction sTransaction)
        {
            Autodesk.AutoCAD.EditorInput.Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;

            //طرح کد نداره و در پشتیبان طرحی نداره پی یک طرح جدید تولید می کنیم
            ed.WriteMessage("@@@@ 1\n");
            DataTable dtWorkOrder = Atend.Base.Design.DPackage.AccessWorkOrders(aTransaction, aConnection);

            Atend.Base.Design.DDesignProfile currentDesignProfile = Atend.Base.Design.DDesignProfile.AccessSelect(aTransaction, aConnection);
            Atend.Base.Design.DDesign        currentDesign        = new Atend.Base.Design.DDesign();
            currentDesign.Title     = currentDesignProfile.DesignName;
            currentDesign.ArchiveNo = currentDesignProfile.DesignCode;
            currentDesign.PRGCode   = 0;
            ed.WriteMessage("@@@@ 2\n");
            currentDesign.RequestType = 0;
            currentDesign.Region      = Convert.ToByte(Atend.Base.Base.BRegion.SelectByCodeLoacal(currentDesignProfile.Zone).SecondCode);
            currentDesign.IsAtend     = true;
            currentDesign.Address     = currentDesignProfile.Address;
            ed.WriteMessage("@@@@ 3\n");
            if (!currentDesign.Insert(sTransaction, sConnection))
            {
                ed.WriteMessage("@@@@ 4\n");
                throw new System.Exception("currentDesign.Insert 1");
            }
            ed.WriteMessage("@@@@ 5\n");
            foreach (DataRow drWorkOrder in dtWorkOrder.Rows)
            {
                Atend.Base.Design.DWorkOrder WO = new Atend.Base.Design.DWorkOrder();
                WO.DesignID  = currentDesign.Id;
                WO.WorkOrder = Convert.ToInt32(drWorkOrder["WorkOrderCode"].ToString());
                if (!WO.Insert(sTransaction, sConnection))
                {
                    throw new System.Exception("WorkOrder.Insert Failed 1");
                }
            }

            ed.WriteMessage("@@@@ 6\n");
            currentDesignProfile.DesignId = currentDesign.Id;
            if (!currentDesignProfile.AccessUpdate(aTransaction, aConnection))
            {
                throw new System.Exception("currentDesignProfile.AccessUpdate 1");
            }

            ed.WriteMessage("@@@@ 7\n");
            Atend.Base.Design.DDesignFile currentDesignFile = new Atend.Base.Design.DDesignFile();
            currentDesignFile.DesignId = currentDesign.Id;
            currentDesignFile.File     = new byte[0];


            ed.WriteMessage("@@@@ 8\n");
            #region ATNX file
            FileStream fs;
            fs = new FileStream(string.Format(@"{0}\{1}", Atend.Control.Common.DesignFullAddress, Atend.Control.Common.DesignName.Replace(".DWG", ".ATNX")), FileMode.Open);
            BinaryReader br = new BinaryReader(fs);
            currentDesignFile.File = br.ReadBytes((Int32)br.BaseStream.Length);
            fs.Dispose();
            #endregion

            ed.WriteMessage("@@@@ 9\n");
            #region PDF file
            if (txtBookAddress.Text != string.Empty)
            {
                fs = new FileStream(txtBookAddress.Text, FileMode.Open);
                br = new BinaryReader(fs);
                currentDesignFile.Book = br.ReadBytes((Int32)br.BaseStream.Length);
                fs.Dispose();
            }
            else
            {
                currentDesignFile.Book = new byte[0];
            }
            #endregion

            ed.WriteMessage("@@@@ 10\n");
            #region DWF file
            if (txtBookAddress.Text != string.Empty)
            {
                fs = new FileStream(txtDWFAddress.Text, FileMode.Open);
                br = new BinaryReader(fs);
                currentDesignFile.Image = br.ReadBytes((Int32)br.BaseStream.Length);
                fs.Dispose();
            }
            else
            {
                currentDesignFile.Image = new byte[0];
            }
            #endregion

            ed.WriteMessage("@@@@ 11\n");

            if (!currentDesignFile.Insert(sTransaction, sConnection))
            {
                throw new System.Exception("currentDesignFile.Insert 1");
            }
            ed.WriteMessage("@@@@ 12\n");
            if (!currentDesignProfile.Insert(sTransaction, sConnection))
            {
                throw new System.Exception("currentDesignProfile.Insert 1");
            }
            ed.WriteMessage("@@@@ 13\n");
            #region StatusReport
            Atend.Global.Utility.UOtherOutPut Output = new Atend.Global.Utility.UOtherOutPut();
            ed.WriteMessage("@@@@ 13.1\n");
            Atend.Report.dsSagAndTension ds = Output.FillStatusReport();
            ed.WriteMessage("@@@@ 13.2\n");
            Atend.Base.Design.DStatusReport.DeleteByDesignId(currentDesignProfile.DesignId);
            ed.WriteMessage("@@@@ 14,{0}\n", ds.Tables["StatusReport"].Rows.Count);
            for (int i = 0; i < ds.Tables["StatusReport"].Rows.Count; i++)
            {
                Atend.Base.Design.DStatusReport STR = new Atend.Base.Design.DStatusReport();
                STR.DesignId = currentDesignProfile.DesignId;
                if (Atend.Control.NumericValidation.Int32Converter(ds.Tables["StatusReport"].Rows[i]["Code"].ToString()))
                {
                    STR.ProductCode = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["Code"].ToString());
                }
                else
                {
                    STR.ProductCode = 0;
                }

                DataTable ExTbl = Atend.Base.Base.BEquipStatus.SelectAllX();
                STR.Existance = Convert.ToInt32(ExTbl.Select("Name = '" + ds.Tables["StatusReport"].Rows[i]["Exist"].ToString() + "'")[0]["ACode"].ToString());
                int pc = Convert.ToInt32(ds.Tables["StatusReport"].Rows[i]["ProjectCode"]);
                //int pc = Atend.Base.Base.BProjectCode.AccessSelectByCode(Convert.ToInt32(Table.Rows[i]["ProjectCode"].ToString())).AdditionalCode;
                STR.ProjectCode = pc;
                ds.Tables["StatusReport"].Rows[i]["ProjectCode"] = pc;
                ds.Tables["StatusReport"].Rows[i]["Count"]       = Math.Round(Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString()), 2);
                STR.Count = Convert.ToDouble(ds.Tables["StatusReport"].Rows[i]["Count"].ToString());
                if (!STR.Insert(sTransaction, sConnection))
                {
                    ed.WriteMessage("\nError In D_StatusReport Insertion\n");
                }
                ed.WriteMessage("@@@@ 15\n");
            }
            #endregion
        }