コード例 #1
0
        public bool newReport(Report r, ReportCategory rc, Attachments atach = null)
        {
            Report newReport = clientDb.Reports.Create();

            //  ReportCategory newRc = clientDb.ReportCategories.Create();
            //  Attachments newAtach = clientDb.Attachments.Create();

            newReport.Sender_ID    = r.Sender_ID;
            newReport.Sender       = r.Sender;
            newReport.Recipient    = r.Recipient;
            newReport.Recipient_ID = r.Recipient_ID;
            newReport.SendDate     = r.SendDate;
            newReport.isRead       = r.isRead;
            newReport.isMark       = r.isMark;
            newReport.Title        = r.Title;
            if (atach != null)
            {
                newReport.Attachment = atach;
            }
            newReport.ReportCategory = rc;
            clientDb.Reports.Add(newReport);
            try{
                clientDb.SaveChanges();
                Console.WriteLine(r.Id.ToString() + "is Added");
                return(true);
            }
            catch {
                return(false);
            }
        }
コード例 #2
0
ファイル: Report.cs プロジェクト: farzinsarvaramini/factory
 public Report(int senderId, string sender, int recipientId, string recipient, string description, string title,
               Attachments attach = null, ReportCategory repCat = null)
 {
     Sender_ID    = senderId;
     Sender       = sender;
     Recipient_ID = recipientId;
     Recipient    = recipient;
     Description  = description;
     //add title here
     Attachment     = attach;
     ReportCategory = repCat;
 }
コード例 #3
0
        public bool sendReport()
        {
            //MessageBox.Show("send request");
            _communication.Connect();


            _report           = new Report();
            _report.Sender_ID = SessionInfos.login_user.Id;
            _report.Sender    = SessionInfos.login_user.FirstName + " "
                                + SessionInfos.login_user.LastName + " - "
                                + SessionInfos.login_user.RoleName;
            _report.Recipient_ID = _view.getRecipientID();
            _report.Recipient    = _view.getRecipient();
            _report.Description  = _view.getTDescription();
            _report.Title        = _view.getTitle();
            _report.SendDate     = DateTime.Now;
            _report.isMark       = false;
            _report.isRead       = false;


            Attachments attach;

            if (!String.IsNullOrEmpty(_view.getAttachments()))
            {
                attach = new Attachments();
                attach.FileLocation = _view.getAttachments();
                attach.uploadTime   = DateTime.Now;
            }
            else
            {
                attach = null;
            }

            ReportCategory repCat = new ReportCategory();

            repCat.Title = _view.getCategoryTitle();

            saveNewReport(_report, repCat, attach);

            Request reportRequest = new Request(RequestType.NEW_REPORT, new object[] { _report, repCat, attach });

            _communication.SendRequest(reportRequest);
            if (attach != null)
            {
                this.uploadFile();
            }

            _communication.Disconnect();

            return(true);
        }
コード例 #4
0
        public string ExeRequest(Request req)
        {
            switch (req.Type)
            {
            case RequestType.NEW_REPORT:
                Report         report   = req.ToModel <Report>(0);
                ReportCategory category = req.ToModel <ReportCategory>(1);
                Attachments    att      = req.ToModel <Attachments>(2);
                // save report in Db of server.
                break;

            // case RequestType.DOWNLOAD: handled in server communication.

            case RequestType.NEW_REQUESTMODEL:
                RequestModel rM = req.ToModel <RequestModel>(0);
                // save Request in db of server
                break;

            //case RequestType.FOLLOW:
            //int RequestModelId = req.ToModel<int>(0);
            // search db for id of RequestModel
            // change column of this RequestModel
            // and save.

            case RequestType.GET:
                //int userId = req.ToModel<int>(0);
                //List<Tuple<Report, ReportCategory, Attachments>> reports = _dbCenter.dbReportCenter.GetNewReports(userId);
                //List<RequestModel> requestModels = _dbRequestCenter.GetNewRequestModels(userId);
                //List<Request> requests;
                //for (int i = 0; i < reports.Count; ++i)
                //{
                //    object[] obj = { reports[i].Item1, reports[i].Item2, reports[i].Item3 };
                //    Request r = new Request(RequestType.NEW_REPORT, obj);
                //    requests.Add(r);
                //}
                //for (int i = 0; i < requests.Count; ++i)
                //{
                //    object[] obj = { requests[i] };
                //    Request r = new Request(RequestType.NEW_REQUESTMODEL, obj);
                //    requests.Add(r);
                //}


                break;
            }

            return(_response);
        }
コード例 #5
0
        public int newReportWithId(Report r, ReportCategory rc, Attachments atach = null)
        {
            Report         newReport = clientDb.Reports.Create();
            ReportCategory newRc     = clientDb.ReportCategories.Create();
            Attachments    newAtach  = clientDb.Attachments.Create();

            newReport.Sender_ID    = r.Sender_ID;
            newReport.Sender       = r.Sender;
            newReport.Recipient    = r.Recipient;
            newReport.Recipient_ID = r.Recipient_ID;
            newReport.SendDate     = r.SendDate;
            newReport.isRead       = r.isRead;
            newReport.isMark       = r.isMark;
            newReport.Title        = r.Title;
            newReport.Description  = r.Description;
            if (atach != null)
            {
                newReport.Attachment = newAtach;
            }
            newReport.ReportCategory = newRc;


            newRc.Reports.Add(newReport);
            newRc.Title = rc.Title;

            newAtach.FileLocation = atach.FileLocation;
            newAtach.Report       = newReport;
            newAtach.uploadTime   = atach.uploadTime;

            clientDb.Reports.Add(newReport);
            try
            {
                clientDb.SaveChanges();
                Console.WriteLine("000000000000\n");
                return(newReport.Id);
            }
            catch (Exception e)
            {
                Console.WriteLine("goh \n" + e.StackTrace + "    ljkkjhghj    " + e.Message);
                return(0);
            }
        }
コード例 #6
0
        public bool sendReport()
        {
            //MessageBox.Show("send request");
            _communication.Connect();


            _report = new Report(_view.getRecipientID(), _view.getRecipient(), _view.getTDescription(),
                                 _view.getTitle());
            Attachments attach;

            if (!String.IsNullOrEmpty(_view.getAttachments()))
            {
                attach = new Attachments();
                attach.FileLocation = _view.getAttachments();
                attach.uploadTime   = DateTime.Now;
            }
            else
            {
                attach = null;
            }

            ReportCategory repCat = new ReportCategory();

            repCat.Title = _view.getCategoryTitle();

            saveNewReport(_report, repCat, attach);

            Request reportRequest = new Request(RequestType.New_Report, new object[] { _report, repCat, attach });

            _communication.SendRequest(reportRequest);
            if (attach != null)
            {
                this.uploadFile();
            }

            _communication.Disconnect();

            return(true);
        }
コード例 #7
0
        private void sendReport_b_Click(object sender, RoutedEventArgs e)
        {
            //////////////////////////////////////////////////////////
            //code by farzin
            //fill comboboxes

            clientContainer clientDb = new clientContainer();

            Report         re    = clientDb.Reports.Create();
            ReportCategory rc    = clientDb.ReportCategories.Create();
            Attachments    atach = clientDb.Attachments.Create();

            re.Attachment     = atach;
            re.Description    = "یییییییی";
            re.isMark         = true;
            re.isRead         = true;
            re.Recipient      = "ss";
            re.Recipient_ID   = 222;
            re.ReportCategory = rc;
            re.SendDate       = DateTime.Now;
            re.Sender         = "Ali";
            re.Sender_ID      = 23323;
            re.Title          = "hhhd";

            rc.Title = "تولید";
            rc.Reports.Add(re);

            atach.FileLocation = "fads";
            atach.Report       = re;
            atach.uploadTime   = DateTime.Now;

            clientDb.ReportCategories.Add(rc);

            try
            {
                clientDb.SaveChanges();
            }
            catch
            {
                Console.WriteLine("Not Addedddddddddddddddddd");
            }

            User usr  = clientDb.Users.Create();
            User usr1 = clientDb.Users.Create();

            usr.Address        = "لنگرود"; usr1.Address = "همدان";
            usr.Age            = 20; usr1.Age = 20;
            usr.AvatarLocation = "ABC"; usr1.AvatarLocation = "ABC";
            usr.Email          = "e@yahoo"; usr1.Email = "e@yahoo";
            usr.EmploymentDate = DateTime.Now; usr1.EmploymentDate = DateTime.Now;
            usr.FirstName      = "احسان"; usr1.FirstName = "فرزین";
            usr.Gender         = true; usr1.Gender = true;
            usr.LastName       = "گلشنی"; usr1.LastName = "امینی";
            usr.NationalId     = 32433; usr1.NationalId = 32433;
            usr.Password       = "******"; usr1.Password = "******";
            usr.PhoneNumber    = "000122312"; usr1.PhoneNumber = "000122312";
            usr.Resume         = "بیکار"; usr1.Resume = "رئیس";
            usr.RoleId         = 23433; usr1.RoleId = 234232;
            usr.RoleName       = "للل"; usr1.RoleName = "سیسشب";
            //usr.UserId = usr1.Id; usr1.UserId = usr.Id;
            usr.Username    = "******"; usr1.Username = "******";
            usr.DefaultUser = false; usr1.DefaultUser = false;
            usr.IsNew       = false; usr1.IsNew = false;

            clientDb.Users.Add(usr);
            clientDb.Users.Add(usr1);

            try
            {
                clientDb.SaveChanges();
            }
            catch
            {
                Console.WriteLine("Not Addedddddddddddddddddd");
            }

            //////////////////////////////////////////////////


            this.controller.sReportC.showView();
        }
コード例 #8
0
 public bool saveNewReport(Report r, ReportCategory rC, Attachments a)
 {
     return(_db.newReport(r, rC, a));
 }
コード例 #9
0
 private string NewReport(Report report, ReportCategory category, Attachments attachment)
 {
     //_dbCenter.NewReport(report, category, attachment);
     return(_response);
 }